/// <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);// Ошибка } }