/// <summary> /// Get max version route /// </summary> public void GetMaxVerRoute(ref DataTable dataTable, DataSet ds) { try { string msg = string.Empty; DataSet dsReturn = null; IServerObjFactory factor = CallRemotingService.GetRemoteObject(); if (null != factor) { dsReturn = factor.CreateIRouteEngine().GetMaxVerRoute(ds); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (msg != string.Empty) { MessageService.ShowError(msg); } else { dataTable = dsReturn.Tables[POR_ROUTE_ROUTE_VER_FIELDS.DATABASE_TABLE_NAME]; } } } catch (Exception ex) { MessageService.ShowError(ex); } finally { CallRemotingService.UnregisterChannel(); } }
/// <summary> /// 根据主键获取工艺流程信息。 /// </summary> /// <param name="routeKey">工艺主键。</param> public void GetRouteByKey(string routeKey) { try { string msg = string.Empty; DataSet dsReturn = null; IServerObjFactory factor = CallRemotingService.GetRemoteObject(); dsReturn = factor.CreateIRouteEngine().GetRouteByKey(routeKey); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (msg != string.Empty) { MessageService.ShowError(msg); } else { SetRouteProperties(dsReturn.Tables[POR_ROUTE_ROUTE_VER_FIELDS.DATABASE_TABLE_NAME]); if (dsReturn.Tables.Count > 1) { SetRouteStep(dsReturn); } } } catch (Exception ex) { MessageService.ShowError(ex); } finally { CallRemotingService.UnregisterChannel(); } }
/// <summary> /// 删除工艺流程。 /// </summary> /// <returns>true:删除成功。false:删除失败。</returns> public override bool Delete() { try { string msg = string.Empty; DataSet dsReturn = null; IServerObjFactory factor = CallRemotingService.GetRemoteObject(); dsReturn = factor.CreateIRouteEngine().RouteDelete(_routeVerKey); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (msg != string.Empty) { MessageService.ShowError(msg); return(false); } else { MessageService.ShowMessage("${res:Global.SuccessMessage}", "${res:Global.SystemInfo}"); } } catch (Exception ex) { MessageService.ShowError(ex); } finally { CallRemotingService.UnregisterChannel(); } return(true); }
/// <summary> /// add Route Line Relation in DB /// </summary> private void addRouteLineRelation(string strRouteKey, string strLineKey, string strLineName) { string msg = ""; DataSet dsRouteLineGive = new DataSet(); DataSet dsRouteLineSearch = new DataSet(); DataSet dsRouteLineReceve = new DataSet(); Hashtable hsRouteLine = new Hashtable(); DataTable dtRouteLine = new DataTable(); hsRouteLine.Add("ROUTE_ROUTE_VER_KEY", strRouteKey); hsRouteLine.Add("PRODUCTION_LINE_KEY", strLineKey); hsRouteLine.Add("LINE_NAME", strLineName); dtRouteLine = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hsRouteLine); dsRouteLineGive.Tables.Add(dtRouteLine); IServerObjFactory serverFactory = null; serverFactory = CallRemotingService.GetRemoteObject(); if (serverFactory != null) { dsRouteLineSearch = (DataSet)serverFactory.CreateIRouteEngine().SearchRouteLine(dsRouteLineGive); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsRouteLineSearch); if (msg != "") { MessageService.ShowError(msg); } else { if (dsRouteLineSearch.Tables["POR_ROUTE_LINE"].Rows.Count == 0) { dsRouteLineReceve = (DataSet)serverFactory.CreateIRouteEngine().AddRouteLine(dsRouteLineGive); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsRouteLineReceve); if (msg != "") { MessageBox.Show(msg); } } else { MessageBox.Show(StringParser.Parse("${res:FanHai.Hemera.Addins.FMM.SearchLineDialog.Message}"), StringParser.Parse("${res:Global.SystemInfo}")); } } } CallRemotingService.UnregisterChannel(); }
/// <summary> /// 查询按钮。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQuery_Click(object sender, EventArgs e) { try { Hashtable htParams = new Hashtable(); DataSet dsParams = new DataSet(); string strName = this.txtName.Text.Trim(); if (strName.Length > 0) { htParams.Add(POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME, strName); } DataTable dtParams = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(htParams); dtParams.TableName = POR_ROUTE_ROUTE_VER_FIELDS.DATABASE_TABLE_NAME; dsParams.Tables.Add(dtParams); string msg = string.Empty; DataSet dsReturn = new DataSet(); IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); dsReturn = serverFactory.CreateIRouteEngine().RouteSearch(dsParams); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (msg != string.Empty) { MessageService.ShowError(msg); } else { if (dsReturn.Tables[POR_ROUTE_ROUTE_VER_FIELDS.DATABASE_TABLE_NAME].Rows.Count < 1) { MessageService.ShowMessage ("${res:FanHai.Hemera.Addins.FMM.SearchDialog.Message}", "${res:Global.SystemInfo}"); } gcResult.MainView = gvResult; gcResult.DataSource = dsReturn.Tables[POR_ROUTE_ROUTE_VER_FIELDS.DATABASE_TABLE_NAME]; } } catch (Exception ex) { MessageService.ShowError(ex); } finally { CallRemotingService.UnregisterChannel(); } }
/// <summary> /// 删除工艺流程关联的线别信息。 /// </summary> /// <param name="strRouteKey">工艺流程主键。</param> /// <param name="strLineKey">线别主键。</param> /// <returns>true:删除成功。false:删除失败。</returns> public bool DeleteRouteLineRelation(string strRouteKey, string strLineKey) { try { Hashtable hashTable = new Hashtable(); DataSet dataSet = new DataSet(); if (strRouteKey.Length > 1) { hashTable.Add(POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_ROUTE_VER_KEY, strRouteKey); hashTable.Add("PRODUCTION_LINE_KEY", strLineKey); } DataTable dataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable); dataSet.Tables.Add(dataTable); string msg = string.Empty; DataSet dsReturn = new DataSet(); IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); if (serverFactory != null) { dsReturn = serverFactory.CreateIRouteEngine().DeleteRouteLine(dataSet); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (msg != string.Empty) { MessageService.ShowError(msg); return(false); } else { MessageService.ShowMessage("${res:Global.SuccessMessage}", "${res:Global.SystemInfo}"); } } } catch (Exception ex) { MessageService.ShowError(ex); return(false); } finally { CallRemotingService.UnregisterChannel(); } return(true); }
/// <summary> /// 获取工步指定的自定义属性值。 /// </summary> /// <param name="stepKey">工步主键。</param> /// <param name="attributeName">自定义属性名。</param> /// <returns>自定义属性名对应的属性值。</returns> public string GetStepUdaValue(string stepKey, string attributeName) { try { this.ErrorMsg = string.Empty; IServerObjFactory factor = CallRemotingService.GetRemoteObject(); return(factor.CreateIRouteEngine().GetStepUdaValue(stepKey, attributeName)); } catch (Exception ex) { this.ErrorMsg = ex.Message; LoggingService.Error(this.ErrorMsg, ex); } finally { CallRemotingService.UnregisterChannel(); } return(null); }
/// <summary> /// 根据工步主键获取工步数据。 /// </summary> /// <returns> /// 包含工步数据的数据集对象。 /// </returns> public DataSet GetRouteStepDataByStepKey(string stepKey) { try { this.ErrorMsg = string.Empty; IServerObjFactory factor = CallRemotingService.GetRemoteObject(); DataSet dsReturn = factor.CreateIRouteEngine().GetStepDataByKey(stepKey); this.ErrorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); return(dsReturn); } catch (Exception ex) { this.ErrorMsg = ex.Message; LoggingService.Error(this.ErrorMsg, ex); } finally { CallRemotingService.UnregisterChannel(); } return(null); }
/// <summary> /// 获取工艺流程关联的线别信息。 /// </summary> /// <returns>包含工艺流程和线别关联信息的数据表对象。</returns> public DataTable GetRouteLineRelation() { try { Hashtable hashTable = new Hashtable(); DataSet dataSet = new DataSet(); if (_routeVerKey.Length > 1) { hashTable.Add(POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_ROUTE_VER_KEY, _routeVerKey); } DataTable dataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable); dataSet.Tables.Add(dataTable); string msg = string.Empty; DataSet dsReturn = new DataSet(); IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); dsReturn = serverFactory.CreateIRouteEngine().SearchRouteLine(dataSet); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (msg != string.Empty) { MessageService.ShowError(msg); } return(dsReturn.Tables["POR_ROUTE_LINE"]); } catch (Exception ex) { MessageService.ShowError(ex); } finally { CallRemotingService.UnregisterChannel(); } return(null); }
/// <summary> /// 更新工步数据。 /// </summary> /// <returns>true:更新成功。false:更新失败。</returns> public override bool Update() { if (IsDirty) { DataSet dsParams = new DataSet(); DataTable dtStepUpdate = DataTableHelper.CreateDataTableForUpdateBasicData (POR_ROUTE_STEP_FIELDS.DATABASE_TABLE_NAME + "_UPDATE"); DataTable dtStepUda = DataTableHelper.CreateDataTableForUDA (POR_ROUTE_STEP_ATTR_FIELDS.DATABASE_TABLE_NAME, POR_ROUTE_STEP_ATTR_FIELDS.FIELD_ROUTE_STEP_KEY); DataTable dtStepParam = CommonUtils.CreateDataTable(new POR_ROUTE_STEP_PARAM_FIELDS()); ParseUpdateDataToDataTable(ref dtStepUpdate, ref dtStepUda, ref dtStepParam); //组织工步数据 if (dtStepUpdate.Rows.Count > 0) { dsParams.Tables.Add(dtStepUpdate); } //组织工步自定义属性数据。 if (dtStepUda.Rows.Count > 0) { DealUdaTable(dtStepUda, "I"); dsParams.Tables.Add(dtStepUda); } //组织工步参数数据。 if (dtStepParam.Rows.Count > 0) { dsParams.Tables.Add(dtStepParam); } try { string msg = string.Empty; DataSet dsReturn = null; IServerObjFactory factor = CallRemotingService.GetRemoteObject(); dsReturn = factor.CreateIRouteEngine().RouteUpdate(dsParams); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (msg != string.Empty) { MessageService.ShowError(msg); return(false); } else { foreach (DataRow dr in this.Params.Rows) { int isDeleted = Convert.ToInt32(dr[POR_ROUTE_OPERATION_PARAM_FIELDS.FIELD_IS_DELETED]); if (isDeleted == 1) { dr.Delete(); } } this.Params.AcceptChanges(); this.ResetDirtyList(); MessageService.ShowMessage("${res:Global.SuccessMessage}", "${res:Global.SystemInfo}"); } } catch (Exception ex) { MessageService.ShowError(ex); } finally { CallRemotingService.UnregisterChannel(); } } else { MessageService.ShowMessage ("${res:Global.UpdateItemDataMessage}", "${res:Global.SystemInfo}"); } return(true); }
/// <summary> /// 更新工艺流程状态。 /// </summary> public override bool UpdateStatus() { if (IsDirty) { DataSet dataSet = new DataSet(); // Prepare Operation if (this.DirtyList.Count > 0) { DataTable routeTable = DataTableHelper.CreateDataTableForUpdateBasicData(POR_ROUTE_ROUTE_VER_FIELDS.DATABASE_TABLE_NAME); List <string> possibleDirtyFields = new List <string>() { POR_ROUTE_ROUTE_VER_FIELDS.FIELD_EDITOR, POR_ROUTE_ROUTE_VER_FIELDS.FIELD_EDIT_TIME, POR_ROUTE_ROUTE_VER_FIELDS.FIELD_EDIT_TIMEZONE, POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_STATUS }; string newValue = string.Empty; foreach (string field in possibleDirtyFields) { if (this.DirtyList.ContainsKey(field)) { Dictionary <string, string> rowData = new Dictionary <string, string>() { { COMMON_FIELDS.FIELD_COMMON_UPDATE_KEY, _routeVerKey }, { COMMON_FIELDS.FIELD_COMMON_UPDATE_NAME, field }, { COMMON_FIELDS.FIELD_COMMON_UPDATE_OLD_VALUE, this.DirtyList[field].FieldOriginalValue }, { COMMON_FIELDS.FIELD_COMMON_UPDATE_NEW_VALUE, this.DirtyList[field].FieldNewValue } }; FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref routeTable, rowData); } } if (routeTable.Rows.Count > 0) { dataSet.Tables.Add(routeTable); } } try { string msg = string.Empty; DataSet dsReturn = null; IServerObjFactory factor = CallRemotingService.GetRemoteObject(); if (null != factor) { dsReturn = factor.CreateIRouteEngine().RouteUpdate(dataSet); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (msg != string.Empty) { MessageService.ShowError(msg); return(false); } else { this.ResetDirtyList(); MessageService.ShowMessage("${res:Global.UpdateStatusMessage}", "${res:Global.SystemInfo}"); } } } catch (Exception ex) { MessageService.ShowError(ex); } finally { CallRemotingService.UnregisterChannel(); } } return(true); }
/// <summary> /// 更新工艺流程。 /// </summary> /// <returns>true:更新成功。false:更新失败。</returns> public override bool Update() { if (IsDirty) { DataSet dsParams = new DataSet(); //组织工艺流程数据。 if (this.DirtyList.Count > 1) { DataTable routeTable = DataTableHelper.CreateDataTableForUpdateBasicData(POR_ROUTE_ROUTE_VER_FIELDS.DATABASE_TABLE_NAME); foreach (string Key in this.DirtyList.Keys) { Dictionary <string, string> rowData = new Dictionary <string, string>() { { COMMON_FIELDS.FIELD_COMMON_UPDATE_KEY, _routeVerKey }, { COMMON_FIELDS.FIELD_COMMON_UPDATE_NAME, Key }, { COMMON_FIELDS.FIELD_COMMON_UPDATE_OLD_VALUE, this.DirtyList[Key].FieldOriginalValue }, { COMMON_FIELDS.FIELD_COMMON_UPDATE_NEW_VALUE, this.DirtyList[Key].FieldNewValue } }; FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref routeTable, rowData); } if (routeTable.Rows.Count > 0) { dsParams.Tables.Add(routeTable); } } //组织工步数据。 if (StepList.Count > 0) { //DataTable dtStep = DataTableHelper.CreateDataTableForInsertStep(); DataTable dtStep = CommonUtils.CreateDataTable(new POR_ROUTE_STEP_FIELDS()); dtStep.Columns.Add(COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION); DataTable dtStepUpdate = DataTableHelper.CreateDataTableForUpdateBasicData(POR_ROUTE_STEP_FIELDS.DATABASE_TABLE_NAME + "_UPDATE"); DataTable dtStepUda = DataTableHelper.CreateDataTableForUDA(POR_ROUTE_STEP_ATTR_FIELDS.DATABASE_TABLE_NAME, POR_ROUTE_STEP_ATTR_FIELDS.FIELD_ROUTE_STEP_KEY); DataTable dtStepParam = CommonUtils.CreateDataTable(new POR_ROUTE_STEP_PARAM_FIELDS()); ParseUpdateDataToDataTable(ref dtStep, ref dtStepUpdate, ref dtStepUda, ref dtStepParam); //组织工步数据。 if (dtStep.Rows.Count > 0) { dsParams.Tables.Add(dtStep); } //组织工步自定义属性数据。 if (dtStepUpdate.Rows.Count > 0) { dsParams.Tables.Add(dtStepUpdate); } //组织工步自定义属性数据。 if (dtStepUda.Rows.Count > 0) { dsParams.Tables.Add(dtStepUda); } //组织工步参数数据。 if (dtStepParam.Rows.Count > 0) { dsParams.Tables.Add(dtStepParam); } } try { string msg = string.Empty; DataSet dsReturn = null; IServerObjFactory factor = CallRemotingService.GetRemoteObject(); dsReturn = factor.CreateIRouteEngine().RouteUpdate(dsParams); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (msg != string.Empty) { MessageService.ShowError(msg); return(false); } else { this.ResetDirtyList(); foreach (StepEntity step in stepList) { foreach (DataRow dr in step.Params.Rows) { int isDeleted = Convert.ToInt32(dr[POR_ROUTE_OPERATION_PARAM_FIELDS.FIELD_IS_DELETED]); if (isDeleted == 1) { dr.Delete(); } } step.Params.AcceptChanges(); step.ResetDirtyList(); } MessageService.ShowMessage("${res:Global.SuccessMessage}", "${res:Global.SystemInfo}"); } } catch (Exception ex) { MessageService.ShowError(ex); } finally { CallRemotingService.UnregisterChannel(); } } else { MessageService.ShowMessage ("${res:Global.UpdateItemDataMessage}", "${res:Global.SystemInfo}"); } return(true); }
/// <summary> /// 新增工艺流程。 /// </summary> /// <returns>true:新增成功。false:新增失败。</returns> public override bool Insert() { DataSet dsParams = new DataSet(); //组织工艺流程数据。 DataTable dtRoute = CommonUtils.CreateDataTable(new POR_ROUTE_ROUTE_VER_FIELDS()); DataRow drRoute = dtRoute.NewRow(); dtRoute.Rows.Add(drRoute); drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_ROUTE_VER_KEY] = _routeVerKey; drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME] = _routeName; drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_EFFECTIVITY_START] = _routeEffectivityStart; drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_EFFECTIVITY_END] = _routeEffectivityEnd; drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_DESCRIPTION] = _routeDescription; drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_STATUS] = Convert.ToInt32(_routeStatus); drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_CREATE_TIMEZONE] = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE); drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_CREATOR] = PropertyService.Get(PROPERTY_FIELDS.USER_NAME); drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_EDIT_TIMEZONE] = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE); drRoute[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_EDITOR] = PropertyService.Get(PROPERTY_FIELDS.USER_NAME); dsParams.Tables.Add(dtRoute); //组织工步数据。 if (StepList.Count > 0) { DataTable dtStep = CommonUtils.CreateDataTable(new POR_ROUTE_STEP_FIELDS()); dtStep.Columns.Add(COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION); DataTable dtStepUda = DataTableHelper.CreateDataTableForUDA(POR_ROUTE_STEP_ATTR_FIELDS.DATABASE_TABLE_NAME, POR_ROUTE_STEP_ATTR_FIELDS.FIELD_ROUTE_STEP_KEY); DataTable dtStepParam = CommonUtils.CreateDataTable(new POR_ROUTE_STEP_PARAM_FIELDS()); foreach (StepEntity step in stepList) { step.RouteVerKey = _routeVerKey; step.ParseInsertAndDeleteDataToDataTable(ref dtStep, ref dtStepUda, ref dtStepParam); } if (dtStep.Rows.Count > 0) { dsParams.Tables.Add(dtStep); //组织工步自定义属性数据。 if (dtStepUda.Rows.Count > 0) { dsParams.Tables.Add(dtStepUda); } //组织工步参数数据。 if (dtStepParam.Rows.Count > 0) { dsParams.Tables.Add(dtStepParam); } } } try { int code = 0; string msg = string.Empty; DataSet dsReturn = null; IServerObjFactory factor = CallRemotingService.GetRemoteObject(); dsReturn = factor.CreateIRouteEngine().RouteInsert(dsParams); msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn, ref code); if (code == -1) { MessageService.ShowError(msg); return(false); } else { this.RouteVersion = msg; this.ResetDirtyList(); foreach (StepEntity step in stepList) { step.Params.AcceptChanges(); step.IsInitializeFinished = true; } MessageService.ShowMessage("${res:Global.SuccessMessage}", "${res:Global.SystemInfo}"); } } catch (Exception ex) { MessageService.ShowError(ex); } finally { CallRemotingService.UnregisterChannel(); } return(true); }