private ServiceResult RunOne(SAPWebServiceEntity webServiceEntity, MaterialReceive materialReceive, DT_MES_SOURCESTOCK_REQ materialPOParameter) { IQCFacade iqcFacade = new IQCFacade(this.DataProvider); string xmlFilePath = SerializeUtil.SerializeFile(this.m_Argument.TransactionCode + "_Request.xml", typeof(DT_MES_SOURCESTOCK_REQ), materialPOParameter); #region TransferLog DBDateTime dateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); SAPDataTransferLog materialPOLog = new SAPDataTransferLog(); TransferFacade transferFacade = new TransferFacade(this.DataProvider); materialPOLog.JobID = TransferFacade.MaterialPOJobID; materialPOLog.TransactionCode = this.m_Argument.TransactionCode; materialPOLog.TransactionSequence = 1; materialPOLog.RequestDate = dateTime.DBDate; materialPOLog.RequestTime = dateTime.DBTime; materialPOLog.RequestContent = xmlFilePath; materialPOLog.OrganizationID = 2000; materialPOLog.SendRecordCount = 1; transferFacade.AddSAPDataTransferLog(materialPOLog); #endregion #region Begin for Calling WebService try { MaterialPOServiceClientProxy clientProxy = new MaterialPOServiceClientProxy(); clientProxy.RequestEncoding = Encoding.UTF8; clientProxy.Timeout = InternalVariables.MS_TimeOut * 1000; clientProxy.Url = webServiceEntity.Url; clientProxy.PreAuthenticate = true; System.Uri uri = new Uri(clientProxy.Url); clientProxy.Credentials = new NetworkCredential(webServiceEntity.UserName, webServiceEntity.Password).GetCredential(uri, ""); clientProxy.MI_MES_SOURCESTOCK_REQ(materialPOParameter); clientProxy.Dispose(); clientProxy = null; } catch (Exception e) { materialPOLog.Result = "Fail"; materialPOLog.ErrorMessage = e.Message; transferFacade.UpdateSAPDataTransferLog(materialPOLog); return(new ServiceResult(false, e.Message, materialPOLog.TransactionCode)); } #endregion #region UPDATE tblmaterialreceive try { this.DataProvider.BeginTransaction(); foreach (DT_MES_SOURCESTOCK_REQLIST post in materialPOParameter.LIST) { materialReceive = (MaterialReceive)iqcFacade.GetMaterialReceive(materialReceive.IQCNo, materialReceive.STLine); if (materialReceive != null) { materialReceive.Flag = FlagStatus.FlagStatus_POST; materialReceive.TransactionCode = this.m_Argument.TransactionCode; iqcFacade.UpdateMaterialReceive(materialReceive); } } this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); return(new ServiceResult(false, ex.Message, this.m_Argument.TransactionCode)); } #endregion return(new ServiceResult(true, "", this.m_Argument.TransactionCode)); }
/// <remarks/> public System.IAsyncResult BeginMI_MES_SOURCESTOCK_REQ(DT_MES_SOURCESTOCK_REQ MT_MES_SOURCESTOCK_REQ, System.AsyncCallback callback, object asyncState) { return(this.BeginInvoke("MI_MES_SOURCESTOCK_REQ", new object[] { MT_MES_SOURCESTOCK_REQ }, callback, asyncState)); }
public ServiceResult Run(RunMethod runMethod) { ServiceResult returnValue = null; SAPWebServiceEntity webServiceEntity = System.Configuration.ConfigurationManager.GetSection("MaterialPOTransferConfig") as SAPWebServiceEntity; if (webServiceEntity == null) { if (System.Configuration.ConfigurationManager.AppSettings["MPOWebServiceUrl"] != null && System.Configuration.ConfigurationManager.AppSettings["MPOWebServiceUserName"] != null && System.Configuration.ConfigurationManager.AppSettings["MPOWebServicePassword"] != null) { webServiceEntity = new SAPWebServiceEntity(); webServiceEntity.Url = System.Configuration.ConfigurationManager.AppSettings["MPOWebServiceUrl"]; webServiceEntity.UserName = System.Configuration.ConfigurationManager.AppSettings["MPOWebServiceUserName"]; webServiceEntity.Password = System.Configuration.ConfigurationManager.AppSettings["MPOWebServicePassword"]; } else { return(new ServiceResult(false, "没有维护MaterialPOTransfer对应的Service地址", this.m_Argument.TransactionCode)); } } #region Begin for Prepare input Paremeter IQCFacade iqcFacade = new IQCFacade(this.DataProvider); object[] materialReceiveList = null; if (runMethod == RunMethod.Auto) { materialReceiveList = iqcFacade.QueryMaterialReceiveNotConfirmed(100); } else if (runMethod == RunMethod.Manually) { MaterialReceive materialReceive = (MaterialReceive)iqcFacade.GetMaterialReceive(m_Argument.IQCNo, m_Argument.STLine); if (materialReceive != null && materialReceive.Flag == FlagStatus.FlagStatus_MES) { materialReceiveList = new MaterialReceive[] { materialReceive }; } } #endregion if (materialReceiveList != null) { List <DT_MES_SOURCESTOCK_REQLIST> inventoryList = new List <DT_MES_SOURCESTOCK_REQLIST>(); foreach (MaterialReceive materialReceive in materialReceiveList) { System.Threading.Thread.Sleep(500); this.NewTransactionCode(); inventoryList.Clear(); DT_MES_SOURCESTOCK_REQLIST post = new DT_MES_SOURCESTOCK_REQLIST(); post.PSTNG_DATE = materialReceive.AccountDate.ToString(); post.DOC_DATE = materialReceive.VoucherDate.ToString(); post.PO_NUMBER = materialReceive.OrderNo; post.PO_ITEM = materialReceive.OrderLine.ToString(); post.MATERIAL = materialReceive.ItemCode; post.PLANT = materialReceive.OrganizationID.ToString(); post.STGE_LOC = materialReceive.StorageID; post.ENTRY_QNT = materialReceive.RealReceiveQty.ToString(); post.ENTRY_UOM = materialReceive.Unit; post.HEADER_TXT = materialReceive.ReceiveMemo; post.MOVE_TYPE = "101"; inventoryList.Add(post); DT_MES_SOURCESTOCK_REQ materialPOParameter = new DT_MES_SOURCESTOCK_REQ(); materialPOParameter.TRANSCODE = this.m_Argument.TransactionCode; materialPOParameter.LIST = inventoryList.ToArray(); returnValue = RunOne(webServiceEntity, materialReceive, materialPOParameter); if (!returnValue.Result) { break; } } } if (returnValue == null) { returnValue = new ServiceResult(true, "", this.m_Argument.TransactionCode); } return(returnValue); }
public void MI_MES_SOURCESTOCK_REQ([System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:mes2sap:SourceStock")] DT_MES_SOURCESTOCK_REQ MT_MES_SOURCESTOCK_REQ) { this.Invoke("MI_MES_SOURCESTOCK_REQ", new object[] { MT_MES_SOURCESTOCK_REQ }); }