Exemple #1
0
 /// <summary>
 /// Get param via key
 /// </summary>
 public void GetParamByKey(string paramKey)
 {
     try
     {
         string            msg      = string.Empty;
         DataSet           dsReturn = null;
         IServerObjFactory factor   = CallRemotingService.GetRemoteObject();
         if (null != factor)
         {
             dsReturn = factor.CreateIParamEngine().GetParamByKey(paramKey);
             msg      = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
             if (msg != string.Empty)
             {
                 MessageService.ShowError(msg);
             }
             else
             {
                 SetParamProperties(dsReturn.Tables[BASE_PARAMETER_FIELDS.DATABASE_TABLE_NAME]);
                 SetDerivaParamProperties(dsReturn.Tables[BASE_PARAMETER_DERIVTION_FIELDS.DATABASE_TABLE_NAME]);
                 dsReturn.Tables.Remove(BASE_PARAMETER_FIELDS.DATABASE_TABLE_NAME);
                 dsReturn.Tables.Remove(BASE_PARAMETER_DERIVTION_FIELDS.DATABASE_TABLE_NAME);
             }
         }
     }
     catch (Exception ex)
     {
         MessageService.ShowError(ex);
     }
     finally
     {
         CallRemotingService.UnregisterChannel();
     }
 }
Exemple #2
0
        /// <summary>
        /// Send delete data to server
        /// </summary>
        /// <returns>bool</returns>
        public override bool Delete()
        {
            try
            {
                string            msg      = string.Empty;
                DataSet           dsReturn = null;
                IServerObjFactory factor   = CallRemotingService.GetRemoteObject();
                if (null != factor)
                {
                    dsReturn = factor.CreateIParamEngine().DeleteParam(_paramKey);
                    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);
        }
Exemple #3
0
        /// <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 paramName = this.txtParamName.Text.Trim();

                if (paramName.Length > 0)
                {
                    htParams.Add(BASE_PARAMETER_FIELDS.FIELD_PARAM_NAME, paramName);
                }
                if (!string.IsNullOrEmpty(this._category))
                {
                    htParams.Add(BASE_PARAMETER_FIELDS.FIELD_PARAM_CATEGORY, this._category);
                    htParams.Add(BASE_PARAMETER_FIELDS.FIELD_STATUS, "1");
                }
                DataTable dtParams = CommonUtils.ParseToDataTable(htParams);
                dtParams.TableName = BASE_PARAMETER_FIELDS.DATABASE_TABLE_NAME;
                dsParams.Tables.Add(dtParams);

                string            msg           = string.Empty;
                DataSet           dsReturn      = new DataSet();
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                if (serverFactory != null)
                {
                    dsReturn = serverFactory.CreateIParamEngine().SearchParam(dsParams);
                    msg      = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                    if (msg != string.Empty)
                    {
                        MessageService.ShowError(msg);
                    }
                    else
                    {
                        gcParamList.MainView   = gvParamList;
                        gcParamList.DataSource = dsReturn.Tables[BASE_PARAMETER_FIELDS.DATABASE_TABLE_NAME];
                    }
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
        }
Exemple #4
0
        /// <summary>
        /// 根据参数主键获取用于计算该参数值的参数。
        /// </summary>
        /// <param name="paramKey">参数主键。</param>
        /// <returns>包含计算指定参数主键参数值的参数。
        /// 【ROW_KEY,DERIVATION_KEY,PARAM_KEY,PARAM_NAME】
        /// </returns>
        public DataSet GetParamDerivationByKey(string paramKey)
        {
            DataSet dsParams = new DataSet();

            try
            {
                IServerObjFactory factor = CallRemotingService.GetRemoteObject();
                dsParams = factor.CreateIParamEngine().GetParamDerivationByKey(paramKey);
                ErrorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsParams);
            }
            catch (Exception ex)
            {
                ErrorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(dsParams);
        }
Exemple #5
0
        /// <summary>
        /// Validate param name exist or not
        /// </summary>
        public bool ParamNameValidate()
        {
            try
            {
                string            msg      = string.Empty;
                DataSet           dsReturn = null;
                IServerObjFactory factor   = CallRemotingService.GetRemoteObject();
                if (null != factor)
                {
                    dsReturn = factor.CreateIParamEngine().GetDistinctParamName();
                    msg      = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                    if (msg != string.Empty)
                    {
                        MessageService.ShowError(msg);
                    }
                    else
                    {
                        foreach (DataRow dataRow in dsReturn.Tables[BASE_PARAMETER_FIELDS.DATABASE_TABLE_NAME].Rows)
                        {
                            if (_paramName == dataRow[BASE_PARAMETER_FIELDS.FIELD_PARAM_NAME].ToString())
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            return(true);
        }
Exemple #6
0
        public DataSet GetBaseParamsByCategory()
        {
            DataSet dsReturn = null;

            try
            {
                _msg = string.Empty;
                IServerObjFactory factor = CallRemotingService.GetRemoteObject();
                if (null != factor)
                {
                    dsReturn = factor.CreateIParamEngine().GetBaseParamsByCategory();
                    _msg     = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _msg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(dsReturn);
        }
Exemple #7
0
        /// <summary>
        /// Send insert data to server
        /// </summary>
        /// <returns>bool</returns>
        public override bool Insert()
        {
            DataSet dataSet = new DataSet();
            //Add basic data
            DataTable paramTable = DataTableHelper.CreateDataTableForInsertParam();
            Dictionary <string, string> dataRow = new Dictionary <string, string>()
            {
                { BASE_PARAMETER_FIELDS.FIELD_PARAM_KEY, _paramKey },
                { BASE_PARAMETER_FIELDS.FIELD_PARAM_NAME, _paramName },
                { BASE_PARAMETER_FIELDS.FIELD_DESCRIPTIONS, _paramDescription },
                { BASE_PARAMETER_FIELDS.FIELD_PARAM_CATEGORY, _paramCategory },
                { BASE_PARAMETER_FIELDS.FIELD_DATA_TYPE, _paramDataType },
                { BASE_PARAMETER_FIELDS.FIELD_DEFAULT_UOM, _paramDefaultUom },
                { BASE_PARAMETER_FIELDS.FIELD_UPPER_BOUNDARY, _paramUpperBoundary },
                { BASE_PARAMETER_FIELDS.FIELD_UPPER_SPEC, _paramUpperSpec },
                { BASE_PARAMETER_FIELDS.FIELD_TARGET, _paramTarget },
                { BASE_PARAMETER_FIELDS.FIELD_LOWER_BOUNDARY, _paramLowerBoundary },
                { BASE_PARAMETER_FIELDS.FIELD_LOWER_SPEC, _paramLowerSpec },
                { BASE_PARAMETER_FIELDS.FIELD_MANDATORY, _paramMandatory },
                { BASE_PARAMETER_FIELDS.FIELD_STATUS, Convert.ToInt32(_paramStatus).ToString() },
                { BASE_PARAMETER_FIELDS.FIELD_ISDERIVED, _isDerived },
                { BASE_PARAMETER_FIELDS.FIELD_CALCULATE_TYPE, _calculateType },
                { COMMON_FIELDS.FIELD_COMMON_CREATOR, PropertyService.Get(PROPERTY_FIELDS.USER_NAME) },
                { COMMON_FIELDS.FIELD_COMMON_EDITOR, PropertyService.Get(PROPERTY_FIELDS.USER_NAME) },
                { BASE_PARAMETER_FIELDS.FIELD_DEVICE_TYPE, _deviceType }
            };

            FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref paramTable, dataRow);
            dataSet.Tables.Add(paramTable);

            if (_isDerived == "1")
            {
                if (derivaParamTable.Rows.Count > 0)
                {
                    dataSet.Tables.Add(derivaParamTable);
                }
            }

            try
            {
                int               code     = 0;
                string            msg      = string.Empty;
                DataSet           dsReturn = null;
                IServerObjFactory factor   = CallRemotingService.GetRemoteObject();
                if (null != factor)
                {
                    dsReturn = factor.CreateIParamEngine().ParamInsert(dataSet);
                    msg      = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn, ref code);
                    if (code == -1)
                    {
                        MessageService.ShowError(msg);
                        return(false);
                    }
                    else
                    {
                        this.ResetDirtyList();
                        MessageService.ShowMessage("${res:Global.SuccessMessage}", "${res:Global.SystemInfo}");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
                dataSet.Tables.Clear();
            }

            return(true);
        }
Exemple #8
0
        /// <summary>
        /// Update param status
        /// </summary>
        public override bool UpdateStatus()
        {
            if (IsDirty)
            {
                DataSet dataSet = new DataSet();

                if (this.DirtyList.Count > 0)
                {
                    DataTable paramTable =
                        DataTableHelper.CreateDataTableForUpdateBasicData(BASE_PARAMETER_FIELDS.DATABASE_TABLE_NAME);

                    List <string> possibleDirtyFields = new List <string>()
                    {
                        BASE_PARAMETER_FIELDS.FIELD_STATUS,
                        COMMON_FIELDS.FIELD_COMMON_EDITOR
                    };

                    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, _paramKey },
                                { 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 paramTable, rowData);
                        }
                    }
                    if (paramTable.Rows.Count > 0)
                    {
                        dataSet.Tables.Add(paramTable);
                    }
                }

                try
                {
                    string            msg      = string.Empty;
                    DataSet           dsReturn = null;
                    IServerObjFactory factor   = CallRemotingService.GetRemoteObject();
                    if (null != factor)
                    {
                        dsReturn = factor.CreateIParamEngine().ParamUpdate(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);
        }