public IncomingSupply GetIncomingSupply(long ID, string NOM_NAKL, string NOM_VAG) { try { string message = this.url + this.transaction_is + "&ID=" + ID.ToString() + "&NOM_NAKL=" + NOM_NAKL + "&NOM_VAG=" + NOM_VAG + "&OutputParameter=RSLT" + "&XacuteLoginName=" + this.login + "&XacuteLoginPassword="******"GET", "text/xml"); //String.Format("\r\n Выполнение метода GetIncomingSupply(ID={0}, NOM_NAKL={1}, NOM_VAG={2}) \r\nurl={3} \r\nxml={4}", ID, NOM_NAKL, NOM_VAG, message, response).WarningLog(); if (String.IsNullOrWhiteSpace(response)) { return(null); } XDocument doc = XDocument.Parse(response); //List<IncomingSupply> list_supply = new List<IncomingSupply>(); foreach (XElement element in doc.Element("Rowsets").Element("Rowset").Elements("Row")) { IncomingSupply sypply = new IncomingSupply() { ID = (string)element.Element("ID"), NOM_VAG = (string)element.Element("NOM_VAG"), NOM_NAKL = (string)element.Element("NOM_NAKL"), DATE_NAKL = (string)element.Element("DATE_NAKL"), VBELN = (string)element.Element("VBELN"), PSNR = (string)element.Element("PSNR"), WERKS = (string)element.Element("WERKS"), LGORT = (string)element.Element("LGORT"), LGOBE = (string)element.Element("LGOBE"), ERDAT = (string)element.Element("ERDAT"), ETIME = (string)element.Element("ETIME"), LGORT_10 = (string)element.Element("LGORT_10"), LGOBE_10 = (string)element.Element("LGOBE_10"), MATNR = (string)element.Element("MATNR"), MAKTX = (string)element.Element("MAKTX"), NAME_SH = (string)element.Element("NAME_SH"), KOD_R_10 = (string)element.Element("KOD_R_10"), }; //list_supply.Add(sypply); return(sypply); } return(null); //return list_supply; } catch (Exception e) { e.ExceptionMethodLog(String.Format("GetIncomingSupply(ID={0}, NOM_NAKL={1}, NOM_VAG={2})", ID, NOM_NAKL, NOM_VAG), servece_owner, eventID); return(null); } }
/// <summary> /// Обновить строку САП /// </summary> /// <param name="sap_is"></param> /// <returns></returns> public SAPIncomingSupply GetCurrentIncomingSupplyOfWebSAP(SAPIncomingSupply sap_is) { try { WebAPIClientSAP web_sap = new WebAPIClientSAP(this.servece_owner); IncomingSupply incoming_supply = web_sap.GetIncomingSupply(sap_is.id, sap_is.num_doc_uz.Trim(), sap_is.num.ToString().Trim()); if (incoming_supply != null) { string data = null; string time = null; if (!String.IsNullOrWhiteSpace(incoming_supply.ERDAT)) { data = incoming_supply.ERDAT.Insert(4, "-").Insert(7, "-"); } if (!String.IsNullOrWhiteSpace(incoming_supply.ETIME)) { time = incoming_supply.ETIME.Insert(2, ":").Insert(5, ":"); } sap_is.VBELN = incoming_supply.VBELN; sap_is.NUM_VBELN = !String.IsNullOrWhiteSpace(incoming_supply.PSNR) ? incoming_supply.PSNR : null; sap_is.WERKS = incoming_supply.WERKS; sap_is.LGORT = incoming_supply.LGORT; sap_is.LGOBE = incoming_supply.LGOBE; sap_is.ERDAT = !String.IsNullOrWhiteSpace(data) ? (DateTime?)DateTime.Parse(data, CultureInfo.CreateSpecificCulture("ru-RU")).Date : null; sap_is.ETIME = !String.IsNullOrWhiteSpace(time) ? (TimeSpan?)TimeSpan.Parse(time, CultureInfo.CreateSpecificCulture("ru-RU")) : null; sap_is.LGORT_10 = incoming_supply.LGORT_10; sap_is.LGOBE_10 = incoming_supply.LGOBE_10; sap_is.MATNR = incoming_supply.MATNR; sap_is.MAKTX = incoming_supply.MAKTX; sap_is.NAME_SH = incoming_supply.NAME_SH; sap_is.KOD_R_10 = incoming_supply.KOD_R_10; } sap_is.attempt = sap_is.attempt + 1; return(sap_is); } catch (Exception e) { e.ExceptionMethodLog(String.Format("GetCurrentIncomingSupplyOfWebSAP(sap_is={0})", sap_is), servece_owner, eventID); return(null);// Ошибка } }
/// <summary> /// Обновить информацию о входящей поставке /// </summary> /// <param name="sap_is"></param> /// <param name="user"></param> /// <returns></returns> public SAPIncomingSupply GetUpdateIncomingSupplyOfWebSAP(SAPIncomingSupply sap_is, string user) { try { // Проверим и скорректируем пользователя if (String.IsNullOrWhiteSpace(user)) { user = System.Environment.UserDomainName + @"\" + System.Environment.UserName; } WebAPIClientSAP web_sap = new WebAPIClientSAP(this.servece_owner); string num_doc_uz = sap_is.num_doc_uz.Trim(); IncomingSupply incoming_supply = web_sap.GetIncomingSupply(sap_is.id, num_doc_uz, sap_is.num.ToString().Trim()); // Проверка на документ с нулем впереди if (incoming_supply == null && sap_is.num_doc_uz != null && sap_is.num_doc_uz.Length <= 6) { // Добавим 0 и поищем еще num_doc_uz = "0" + sap_is.num_doc_uz.Trim(); incoming_supply = web_sap.GetIncomingSupply(sap_is.id, num_doc_uz, sap_is.num.ToString().Trim()); if (incoming_supply == null) { // Добавим 00 и поищем еще num_doc_uz = "00" + sap_is.num_doc_uz.Trim(); incoming_supply = web_sap.GetIncomingSupply(sap_is.id, num_doc_uz, sap_is.num.ToString().Trim()); } } if (incoming_supply != null) { string data = null; string time = null; sap_is.num_doc_uz = num_doc_uz; if (!String.IsNullOrWhiteSpace(incoming_supply.ERDAT)) { data = incoming_supply.ERDAT.Insert(4, "-").Insert(7, "-"); } if (!String.IsNullOrWhiteSpace(incoming_supply.ETIME)) { time = incoming_supply.ETIME.Insert(2, ":").Insert(5, ":"); } sap_is.VBELN = incoming_supply.VBELN; sap_is.NUM_VBELN = !String.IsNullOrWhiteSpace(incoming_supply.PSNR) ? incoming_supply.PSNR : null; sap_is.WERKS = incoming_supply.WERKS; sap_is.LGORT = incoming_supply.LGORT; sap_is.LGOBE = incoming_supply.LGOBE; sap_is.ERDAT = !String.IsNullOrWhiteSpace(data) ? (DateTime?)DateTime.Parse(data, CultureInfo.CreateSpecificCulture("ru-RU")).Date : null; sap_is.ETIME = !String.IsNullOrWhiteSpace(time) ? (TimeSpan?)TimeSpan.Parse(time, CultureInfo.CreateSpecificCulture("ru-RU")) : null; sap_is.LGORT_10 = incoming_supply.LGORT_10; sap_is.LGOBE_10 = incoming_supply.LGOBE_10; sap_is.MATNR = incoming_supply.MATNR; sap_is.MAKTX = incoming_supply.MAKTX; sap_is.NAME_SH = incoming_supply.NAME_SH; sap_is.KOD_R_10 = incoming_supply.KOD_R_10; sap_is.change = DateTime.Now; sap_is.change_user = user; } sap_is.attempt = sap_is.attempt + 1; return(sap_is); } catch (Exception e) { e.ExceptionMethodLog(String.Format("GetUpdateIncomingSupplyOfWebSAP(sap_is={0}, user={1})", sap_is, user), servece_owner, eventID); return(null);// Ошибка } }