İlk ad, soyadı vb. Gibi temel bilgileri oluşturabileceğim bir wpf personel oluşturma penceresi var, bu REST web hizmetimde çalışanlar oluşturur. Bir örnek:Excel dokümanı içeriği için webservice
İstemci tarafı:
private void CreateStaffMember_Click(object sender, RoutedEventArgs e)
{
string uri = "http://localhost:8001/Service/Staff";
StringBuilder sb = new StringBuilder();
sb.Append("<Staff>");
sb.AppendLine("<FirstName>" + this.textBox1.Text + "</FirstName>");
sb.AppendLine("<LastName>" + this.textBox2.Text + "</LastName>");
sb.AppendLine("<Password>" + this.passwordBox1.Password + "</Password>");
sb.AppendLine("</Staff>");
string NewStudent = sb.ToString();
byte[] arr = Encoding.UTF8.GetBytes(NewStudent);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
req.Method = "POST";
req.ContentType = "application/xml";
req.ContentLength = arr.Length;
Stream reqStrm = req.GetRequestStream();
reqStrm.Write(arr, 0, arr.Length);
reqStrm.Close();
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
MessageBox.Show("Staff Creation: Status " + resp.StatusDescription);
reqStrm.Close();
resp.Close();
}
Web Servis tarafı: bir excel elektronik tablosundan
#region POST
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/Staff")]
void AddStaff(Staff staff);
#endregion
public void AddStaff(Staff staff)
{
staff.StaffID = (++eCount).ToString();
staff.Salt = GenerateSalt();
byte[] passwordHash = Hash(staff.Password, staff.Salt);
staff.Password = Convert.ToBase64String(passwordHash);
staffmembers.Add(staff);
}
Bütün o tarafta ince, ama Im seyir için "ithal" personel bilgilerini değil içe aktarım doğru sözcükse, ancak böyle bir e-tabloda yer alan ad ve soyadlarını almak ve bunları istemci tarafındaki wpf uygulamasından web hizmetine eklemek istiyorum.
Nasıl yapmalıyım? Benim açık dosya iletişim vardır:
private void Import_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
// Show open file dialog box
Nullable<bool> result = dlg.ShowDialog();
// Process open file dialog box results
if (result == true)
{
// Open document
string filename = dlg.FileName;
}
}
Yani o zaman iç içeriğini alıp web hizmeti göndermeden hakkında gitmek benim excel elektronik tabloya açmak? Gerçekten kod üzerinde sıkışmış veya bu konuda gitmek için:/
Sadece adlarını elle yazmak yerine personel ekleyerek otomatik bir yol arıyor, ama personel excel doc olarak görmek açık dosya istedim bir şey seçilebilir iletişim kutusu. İçteki yapı her zaman aynı adı ve soyadı olacaktır. ilk isim, kolon 'B' soyadı ve sütun ise 'A' 'C' olan
(Sütun:
bu, hiçbir şekilde sorunuza cevap vermez ... ancak verileri bir DB'de depolamak daha kolay olmaz mı? – Pynner