public SDMWebServiceHelper(string wsurl, string UserName, string Password) { ws = new SDMService.USD_WebService(); ws.Url = wsurl; SID = ws.login(UserName, Password); handle = ws.getHandleForUserid(SID, UserName); }
public void AddFav(string cntid, string pcatid) { try { string handleN = ""; string createObectResult = ""; System.Xml.XmlDocument Doc = new System.Xml.XmlDocument(); System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); XmlNodeList xHandle = default(XmlNodeList); string xResult = null; SDMService.USD_WebService ws = new SDMService.USD_WebService(); ws.Url = Helpers.GetSetting("CAwsurl", false); var sid = ws.login(Helpers.GetSetting("CALogin", false), Helpers.GetSetting("CAPassword", true)); var handle = ws.getHandleForUserid(sid, Helpers.GetSetting("CALogin", false)); String[] attrVals = new string[] { "cnt", cntid, "pcat", "pcat:" + pcatid, "delete_flag", "0" }; String[] attributes = new string[] { }; var result = ws.doSelect(sid, "zfav_pcat", "cnt = U'" + cntid + "' AND pcat = 'pcat:" + pcatid + "'", -1, attributes); xDoc.LoadXml(result.ToString()); xHandle = xDoc.GetElementsByTagName("Handle"); if (xHandle.Count > 0) { xResult = xHandle[0].InnerText; attrVals = new string[] { "delete_flag", "0" }; ws.updateObject(sid, xResult, attrVals, attributes); } else { ws.createObject(sid, "zfav_pcat", attrVals, attributes, ref createObectResult, ref handleN); } ws.logout(sid); } catch (Exception e) { LogToEventLog(e.ToString()); throw; } }
private void GenCorrespondenceList(HttpContext context) { try { string GenFrom = ReadLastId(); if (GenFrom == string.Empty) { GenFrom = "400000"; } string GenTo = context.Request.QueryString["SelectedItem"]; try { System.Xml.XmlDocument Doc = new System.Xml.XmlDocument(); System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); SDMService.USD_WebService ws = new SDMService.USD_WebService(); var sid = ws.login(Helpers.GetSetting("CALogin", false), Helpers.GetSetting("CAPassword", true)); var handle = ws.getHandleForUserid(sid, Helpers.GetSetting("CALogin", false)); String[] attributes = new string[] { "ref_num", "CorrespondanceLetterType.sym", "SenderEmployee.combo_name", "SenderOrganization.name", "Recipient.sym", "Street", "PostCode", "City", "Country", "OutcomeDate" }; var result = ws.doSelect(sid, "zCorrespondanceOucome", "id > " + GenFrom + " AND id <= " + GenTo, -1, attributes); xDoc.LoadXml(result.ToString()); using (DocX document = DocX.Load(new FileStream(context.Server.MapPath(@"~/App_Data/template_karta_korespondencji_wychodzacej.docx"), FileMode.Open, FileAccess.Read))) { document.ReplaceText("<gen_date>", DateTime.Now.ToString("yyyy-dd-MM HH:mm"), false, RegexOptions.IgnoreCase); Table ResultTable = document.AddTable(xDoc.GetElementsByTagName("Attributes").Count + 1, 10); ResultTable.Alignment = Alignment.center; ResultTable.Design = TableDesign.LightShadingAccent3; ResultTable.AutoFit = AutoFit.Contents; ResultTable.Rows[0].Cells[0].Paragraphs.First().Append("Ref").FontSize(8); ResultTable.Rows[0].Cells[1].Paragraphs.First().Append("Rodzaj").FontSize(8); ResultTable.Rows[0].Cells[2].Paragraphs.First().Append("Nadawca osoba").FontSize(8); ResultTable.Rows[0].Cells[3].Paragraphs.First().Append("Nadawca org").FontSize(8); ResultTable.Rows[0].Cells[4].Paragraphs.First().Append("Adresat").FontSize(8); ResultTable.Rows[0].Cells[5].Paragraphs.First().Append("Ulica").FontSize(8); ResultTable.Rows[0].Cells[6].Paragraphs.First().Append("Kod pocztowy").FontSize(8); ResultTable.Rows[0].Cells[7].Paragraphs.First().Append("Miasto").FontSize(8); ResultTable.Rows[0].Cells[8].Paragraphs.First().Append("Państwo").FontSize(8); ResultTable.Rows[0].Cells[9].Paragraphs.First().Append("Data").FontSize(8); int tRows = 1; int tCells = 0; foreach (XmlElement GetAttributes in xDoc.GetElementsByTagName("Attributes")) { tCells = 0; foreach (XmlElement Attribute in GetAttributes.GetElementsByTagName("Attribute")) { //string attrname = Attribute["AttrName"].InnerText; if (Attribute["AttrName"].InnerText == "OutcomeDate") { DateTime dt = UnixTimeStampToDateTime(Convert.ToDouble(Attribute["AttrValue"].InnerText)); ResultTable.Rows[tRows].Cells[tCells].Paragraphs.First().Append(dt.ToString("yyyy-MM-dd HH:mm")).FontSize(8); } else { ResultTable.Rows[tRows].Cells[tCells].Paragraphs.First().Append(Attribute["AttrValue"].InnerText).FontSize(8); } tCells++; } tRows++; } document.InsertTable(ResultTable); document.ReplaceText("<item_count>", tRows.ToString(), false, RegexOptions.IgnoreCase); System.IO.MemoryStream FileUploader = new MemoryStream(); document.SaveAs(FileUploader); context.Response.Buffer = true; context.Response.Clear(); context.Response.ContentType = "application/docx"; context.Response.AddHeader("content-disposition", "attachment; filename=" + string.Format("karta_korespondencji_wychodzacej_{0}.docx", DateTime.Now.ToString("yyyyMMdd_HHmm"))); context.Response.BinaryWrite(FileUploader.ToArray()); context.Response.Flush(); //context.Response.End(); FileUploader.Dispose(); } ws.logout(sid); SetLastId(GenTo); } catch (Exception ex) { File.AppendAllText(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "AppLog.log", "\r\n\r\nB" + DateTime.Now.ToString() + "\r\n" + ex.ToString()); } } catch (Exception ex) { File.AppendAllText(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "AppLog.log", "\r\n\r\nB" + DateTime.Now.ToString() + "\r\n" + ex.ToString()); } }