Esempio n. 1
0
        /// <summary>
        /// Load Equipment Change State Data
        /// </summary>
        /// <param name="equipmentChangeStateKey"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        /// Owner:Andy Gao 2011-08-25 17:56:52
        public DataTable LoadEquipmentChangeStateData(string equipmentChangeStateKey, out string msg)
        {
            #region Call Remoting Interface

            DataSet reqDS = new DataSet();
            DataSet resDS = new DataSet();

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

                resDS = serverFactory.CreateIEquipmentChangeStates().GetEquipmentChangeStates(equipmentChangeStateKey);
            }
            catch (Exception ex)
            {
                msg = ex.Message;

                return(null);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(resDS);

            return(resDS.Tables[EMS_EQUIPMENT_CHANGE_STATES_FIELDS.DATABASE_TABLE_NAME]);;

            #endregion
        }
Esempio n. 2
0
        /// <summary>
        /// Load Equipment Change States Data
        /// </summary>
        /// Owner:Andy Gao 2010-07-16 10:02:36
        private void LoadEquipmentChangeStatesData()
        {
            #region Variables

            DataSet reqDS = new DataSet();
            DataSet resDS = new DataSet();

            #endregion

            #region Call Remoting Interface

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

                if (serverFactory != null)
                {
                    resDS = serverFactory.CreateIEquipmentChangeStates().GetEquipmentChangeStates(reqDS);
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex);

                return;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            #endregion

            #region Process Output Parameters

            string returnMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(resDS);

            if (string.IsNullOrEmpty(returnMsg))
            {
                BindDataToChangeStatesGrid(resDS.Tables[EMS_EQUIPMENT_CHANGE_STATES_FIELDS.DATABASE_TABLE_NAME]);
            }
            else
            {
                MessageService.ShowError(returnMsg);
            }

            #endregion
        }
Esempio n. 3
0
        /// <summary>
        /// Load Equipment Change State Data
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        /// Owner:Andy Gao 2011-08-03 14:48:24
        public DataTable LoadEquipmentChangeStateData(out string msg)
        {
            #region Call Remoting Interface

            DataSet reqDS = new DataSet();
            DataSet resDS = new DataSet();

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

                resDS = serverFactory.CreateIEquipmentChangeStates().GetEquipmentChangeStates(reqDS);
            }
            catch (Exception ex)
            {
                msg = ex.Message;

                return(null);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(resDS);

            DataTable dataTable = resDS.Tables[EMS_EQUIPMENT_CHANGE_STATES_FIELDS.DATABASE_TABLE_NAME];

            foreach (DataRow dataRow in dataTable.Rows)
            {
                //Equipment State 420EFAD0-CA7E-452b-8400-3F3863736152-000 is IDLE
                //Equipment State 3B78582E-136D-46d3-A7FE-D2EA3B5DC645-000 is Running
                if ((dataRow[EMS_EQUIPMENT_CHANGE_STATES_FIELDS.FIELD_EQUIPMENT_FROM_STATE_KEY].ToString() != "420EFAD0-CA7E-452b-8400-3F3863736152-000") ||
                    (dataRow[EMS_EQUIPMENT_CHANGE_STATES_FIELDS.FIELD_EQUIPMENT_TO_STATE_KEY].ToString() == "3B78582E-136D-46d3-A7FE-D2EA3B5DC645-000"))
                {
                    dataRow.Delete();
                }
            }

            dataTable.AcceptChanges();

            return(dataTable);

            #endregion
        }
Esempio n. 4
0
        /// <summary>
        /// Update Equipment Change States Data For Update The Description
        /// </summary>
        /// <returns></returns>
        /// Owner:Andy Gao 2010-07-20 15:12:47
        private bool UpdateEquipmentChangeStatesData()
        {
            #region Variables

            DataSet reqDS = new DataSet();
            DataSet resDS = new DataSet();

            #endregion

            #region Build Equipment Change States Data

            if (this.grdChangeStates.DataSource != null && this.grdChangeStates.DataSource is DataTable)
            {
                DataTable equipmentChangeStatesDataTalbe = (DataTable)this.grdChangeStates.DataSource;

                DataTable modifiedDataTable = equipmentChangeStatesDataTalbe.GetChanges(DataRowState.Modified);

                if (modifiedDataTable != null && modifiedDataTable.Rows.Count > 0)
                {
                    equipmentChangeStatesDataTalbe.TableName = EMS_EQUIPMENT_CHANGE_STATES_FIELDS.DATABASE_TABLE_NAME;

                    reqDS.Tables.Add(equipmentChangeStatesDataTalbe.Copy());
                }
                else
                {
                    return(true);
                }
            }

            #endregion

            #region Call Remoting Interface

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

                if (serverFactory != null)
                {
                    resDS = serverFactory.CreateIEquipmentChangeStates().UpdateEquipmentChangeStates(reqDS);
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex);

                return(false);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            #endregion

            #region Process Output Parameters

            string returnMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(resDS);

            if (string.IsNullOrEmpty(returnMsg))
            {
                return(true);
            }
            else
            {
                MessageService.ShowError(returnMsg);

                return(false);
            }

            #endregion
        }
Esempio n. 5
0
        public bool Save()
        {
            #region Variables

            DataSet reqDS = new DataSet();
            DataSet resDS = new DataSet();

            #endregion

            #region Build Equipment Change States Data

            DataTable equipmentChangeStatesDataTable = EMS_EQUIPMENT_CHANGE_STATES_FIELDS.CreateDataTable();

            foreach (EquipmentChangeStateEntity equipmentChangeStateEntity in equipmentChangeStateList)
            {
                if (equipmentChangeStateEntity.EntityState != EntityState.None)
                {
                    Dictionary <string, string> dataRow = new Dictionary <string, string>()
                    {
                        { EMS_EQUIPMENT_CHANGE_STATES_FIELDS.FIELD_EQUIPMENT_CHANGE_STATE_KEY, equipmentChangeStateEntity.EquipmentChangeStateKey },
                        { EMS_EQUIPMENT_CHANGE_STATES_FIELDS.FIELD_EQUIPMENT_CHANGE_STATE_NAME, equipmentChangeStateEntity.EquipmentChangeStateName },
                        { EMS_EQUIPMENT_CHANGE_STATES_FIELDS.FIELD_DESCRIPTION, equipmentChangeStateEntity.Description },
                        { EMS_EQUIPMENT_CHANGE_STATES_FIELDS.FIELD_EQUIPMENT_FROM_STATE_KEY, equipmentChangeStateEntity.EquipmentFromStateKey },
                        { EMS_EQUIPMENT_CHANGE_STATES_FIELDS.FIELD_EQUIPMENT_TO_STATE_KEY, equipmentChangeStateEntity.EquipmentToStateKey }
                    };

                    FanHai.Hemera.Utils.Common.Utils.AddKeyValuesToDataTable(ref equipmentChangeStatesDataTable, dataRow);

                    if (equipmentChangeStateEntity.EntityState == EntityState.Added)
                    {
                        equipmentChangeStatesDataTable.Rows[equipmentChangeStatesDataTable.Rows.Count - 1].AcceptChanges();
                        equipmentChangeStatesDataTable.Rows[equipmentChangeStatesDataTable.Rows.Count - 1].SetAdded();
                    }
                    else if (equipmentChangeStateEntity.EntityState == EntityState.Deleted)
                    {
                        equipmentChangeStatesDataTable.Rows[equipmentChangeStatesDataTable.Rows.Count - 1].AcceptChanges();
                        equipmentChangeStatesDataTable.Rows[equipmentChangeStatesDataTable.Rows.Count - 1].Delete();
                    }
                }
            }

            reqDS.Tables.Add(equipmentChangeStatesDataTable);

            #endregion

            #region Call Remoting Interface

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

                if (serverFactory != null)
                {
                    resDS = serverFactory.CreateIEquipmentChangeStates().UpdateEquipmentChangeStates(reqDS);
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex);

                return(false);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            #endregion

            #region Process Output Parameters

            string returnMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(resDS);

            if (string.IsNullOrEmpty(returnMsg))
            {
                return(true);
            }
            else
            {
                MessageService.ShowError(returnMsg);

                return(false);
            }

            #endregion
        }
Esempio n. 6
0
        public override bool Load()
        {
            #region Variables

            DataSet reqDS = new DataSet();
            DataSet resDS = new DataSet();

            #endregion

            #region Build Input Parameters

            if (!string.IsNullOrEmpty(equipmentChangeStateKey))
            {
                DataTable inputParamDataTable = PARAMETERS_INPUT.CreateDataTable();

                object inputKey      = DBNull.Value;
                object inputEditor   = DBNull.Value;
                object inputEditTime = DBNull.Value;

                if (!string.IsNullOrEmpty(equipmentChangeStateKey))
                {
                    inputKey = equipmentChangeStateKey;
                }

                if (!string.IsNullOrEmpty(Editor))
                {
                    inputEditor = Editor;
                }

                if (!string.IsNullOrEmpty(EditTime))
                {
                    inputEditTime = EditTime;
                }

                inputParamDataTable.Rows.Add(new object[] { inputKey, inputEditor, inputEditTime });

                inputParamDataTable.AcceptChanges();

                reqDS.Tables.Add(inputParamDataTable);
            }

            #endregion

            #region Call Remoting Interface

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

                if (serverFactory != null)
                {
                    resDS = serverFactory.CreateIEquipmentChangeStates().GetEquipmentChangeStates(reqDS);
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex);

                return(false);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            #endregion

            #region Process Output Parameters

            string returnMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(resDS);

            if (string.IsNullOrEmpty(returnMsg))
            {
                SetEquipmentChangeStateEntityProperties(resDS.Tables[EMS_EQUIPMENT_CHANGE_STATES_FIELDS.DATABASE_TABLE_NAME]);

                return(true);
            }
            else
            {
                MessageService.ShowError(returnMsg);

                return(false);
            }

            #endregion
        }