Пример #1
0
        protected override void InitUIControls()
        {
            this.grdViewGroups.Columns.Clear();

            GridViewHelper.SetGridView(grdViewGroups);

            EMS_EQUIPMENT_GROUPS_FIELDS equipmentGroupsFields = new EMS_EQUIPMENT_GROUPS_FIELDS();

            int index = 0;

            foreach (KeyValuePair <string, FieldProperties> field in equipmentGroupsFields.FIELDS)
            {
                GridColumn column = new GridColumn();

                column.Name         = field.Key;
                column.FieldName    = field.Key;
                column.Visible      = true;
                column.VisibleIndex = index++;

                this.grdViewGroups.Columns.Add(column);
            }
        }
Пример #2
0
        /// <summary>
        /// 获取设备组信息。
        /// </summary>
        /// <param name="dsParams">包含查询条件的数据集对象。</param>
        /// <returns>包含设备组信息的数据集对象。</returns>
        public DataSet GetEquipmentGroups(DataSet dsParams)
        {
            DataSet resDS = new DataSet();

            try
            {
                EMS_EQUIPMENT_GROUPS_FIELDS equipmentGroupsFields = new EMS_EQUIPMENT_GROUPS_FIELDS();
                //创建列表存放设备组的字段信息
                List <string> interestColumns = new List <string>();

                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY);     //EQUIPMENT_GROUP_KEY
                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_NAME);    //EQUIPMENT_GROUP_NAME
                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_SPEC);                    //SPEC
                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_DESCRIPTION);             //DESCRIPTION

                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_CREATOR);                 //CREATOR
                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_CREATE_TIMEZONE_KEY);     //CREATE_TIMEZONE_KEY
                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_CREATE_TIME);             //CREATE_TIME
                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDITOR);                  //EDITOR
                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDIT_TIMEZONE_KEY);       //EDIT_TIMEZONE_KEY
                interestColumns.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDIT_TIME);               //FIELD_EDIT_TIME

                Conditions conditions = null;

                if (dsParams != null && dsParams.Tables.Contains(PARAMETERS_INPUT.DATABASE_TABLE_NAME))    //INPUT_PARAM_TABLE
                {
                    DataTable inputParamDataTable = dsParams.Tables[PARAMETERS_INPUT.DATABASE_TABLE_NAME];

                    if (inputParamDataTable != null && inputParamDataTable.Columns.Contains(PARAMETERS_INPUT.FIELD_KEY))
                    {
                        conditions = new Conditions();

                        foreach (DataRow row in inputParamDataTable.Rows)
                        {
                            object key = row[PARAMETERS_INPUT.FIELD_KEY];

                            if (key == null || key == DBNull.Value)
                            {
                                conditions.Add(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY, DatabaseCompareOperator.Null, string.Empty);
                            }
                            else
                            {
                                conditions.Add(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY, DatabaseCompareOperator.Equal, key.ToString());
                            }
                        }
                    }
                }

                string sqlString = DatabaseTable.BuildQuerySqlStatement(equipmentGroupsFields, interestColumns, conditions);

                db.LoadDataSet(CommandType.Text, sqlString, resDS, new string[] { EMS_EQUIPMENT_GROUPS_FIELDS.DATABASE_TABLE_NAME });

                FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, string.Empty);
            }
            catch (Exception ex)
            {
                FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, ex.Message);
                LogService.LogError("GetEquipmentGroups Error: " + ex.Message);
            }

            return(resDS);
        }
Пример #3
0
        /// <summary>
        /// 删除设备组数据。
        /// </summary>
        /// <param name="dsParams">包含删除条件的数据集对象。</param>
        /// <returns>包含执行结果的数据集对象。</returns>
        public DataSet DeleteEquipmentGroups(DataSet reqDS)
        {
            DataSet resDS = new DataSet();

            try
            {
                if (reqDS != null && reqDS.Tables.Contains(PARAMETERS_INPUT.DATABASE_TABLE_NAME))
                {
                    DataTable inputParamDataTable = reqDS.Tables[PARAMETERS_INPUT.DATABASE_TABLE_NAME];

                    #region Build Conditions List

                    List <Conditions> conditionsList = new List <Conditions>();

                    foreach (DataRow row in inputParamDataTable.Rows)
                    {
                        Conditions conditions = new Conditions();

                        Condition keyCondition;

                        if (row[PARAMETERS_INPUT.FIELD_KEY] != null && row[PARAMETERS_INPUT.FIELD_KEY] != DBNull.Value)
                        {
                            keyCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY,
                                                         DatabaseCompareOperator.Equal, row[PARAMETERS_INPUT.FIELD_KEY].ToString());
                        }
                        else
                        {
                            keyCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY,
                                                         DatabaseCompareOperator.Null, string.Empty);
                        }

                        conditions.Add(keyCondition);

                        Condition editorCondition;

                        if (row[PARAMETERS_INPUT.FIELD_EDITOR] != null && row[PARAMETERS_INPUT.FIELD_EDITOR] != DBNull.Value)
                        {
                            editorCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDITOR,
                                                            DatabaseCompareOperator.Equal, row[PARAMETERS_INPUT.FIELD_EDITOR].ToString());
                        }
                        else
                        {
                            editorCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDITOR,
                                                            DatabaseCompareOperator.Null, string.Empty);
                        }

                        conditions.Add(editorCondition);

                        Condition editTimeCondition;

                        if (row[PARAMETERS_INPUT.FIELD_EDIT_TIME] != null && row[PARAMETERS_INPUT.FIELD_EDIT_TIME] != DBNull.Value)
                        {
                            editTimeCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDIT_TIME,
                                                              DatabaseCompareOperator.Equal, row[PARAMETERS_INPUT.FIELD_EDIT_TIME].ToString());
                        }
                        else
                        {
                            editTimeCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDIT_TIME,
                                                              DatabaseCompareOperator.Null, string.Empty);
                        }

                        conditions.Add(editTimeCondition);

                        conditionsList.Add(conditions);
                    }

                    #endregion

                    EMS_EQUIPMENT_GROUPS_FIELDS equipmentGroupsFields = new EMS_EQUIPMENT_GROUPS_FIELDS();

                    List <string> sqlStringList = DatabaseTable.BuildDeleteSqlStatements(equipmentGroupsFields, conditionsList);

                    string sqlString = string.Empty;

                    if (sqlStringList.Count > 0)
                    {
                        sqlString = sqlStringList[0];
                    }

                    #region Check Equipments Reference

                    string equipmentGroupKey = inputParamDataTable.Rows[0][PARAMETERS_INPUT.FIELD_KEY].ToString();

                    Conditions checkConditions = new Conditions();

                    checkConditions.Add(DatabaseLogicOperator.And, EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY, DatabaseCompareOperator.Equal, equipmentGroupKey);

                    EMS_EQUIPMENTS_FIELDS equipmentsFields = new EMS_EQUIPMENTS_FIELDS();

                    List <string> interestColumns = new List <string>()
                    {
                        EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_KEY
                    };

                    string checkSqlString = DatabaseTable.BuildQuerySqlStatement(equipmentsFields, interestColumns, checkConditions);

                    object scalar = db.ExecuteScalar(CommandType.Text, checkSqlString);

                    if (scalar != null && scalar != DBNull.Value)
                    {
                        throw new Exception("${res:FanHai.Hemera.Modules.EMS.EquipmentGroups.M0002}");
                    }

                    #endregion

                    if (db.ExecuteNonQuery(CommandType.Text, sqlString) > 0)
                    {
                        FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, string.Empty);
                    }
                    else
                    {
                        throw new Exception("${res:FanHai.Hemera.Module.Common.M0002}");
                    }
                }
                else
                {
                    FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, "${res:FanHai.Hemera.Module.Common.M0001}");
                }
            }
            catch (Exception ex)
            {
                FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, ex.Message);
                LogService.LogError("DeleteEquipmentGroups Error: " + ex.Message);
            }

            return(resDS);
        }
Пример #4
0
        /// <summary>
        /// 更新设备组数据。
        /// </summary>
        /// <param name="dsParams">包含设备组数据的数据集对象。</param>
        /// <returns>包含执行结果的数据集对象。</returns>
        public DataSet UpdateEquipmentGroups(DataSet dsParams)
        {
            DataSet resDS = new DataSet();

            try
            {
                if (dsParams != null && dsParams.Tables.Contains(EMS_EQUIPMENT_GROUPS_FIELDS.DATABASE_TABLE_NAME) && dsParams.Tables.Contains(PARAMETERS_INPUT.DATABASE_TABLE_NAME))
                {
                    DataTable equipmentGroupsDataTable = dsParams.Tables[EMS_EQUIPMENT_GROUPS_FIELDS.DATABASE_TABLE_NAME];
                    DataTable inputParamDataTable      = dsParams.Tables[PARAMETERS_INPUT.DATABASE_TABLE_NAME];

                    #region Build Conditions List

                    List <Conditions> conditionsList = new List <Conditions>();

                    foreach (DataRow row in inputParamDataTable.Rows)
                    {
                        Conditions conditions = new Conditions();

                        Condition keyCondition;

                        if (row[PARAMETERS_INPUT.FIELD_KEY] != null && row[PARAMETERS_INPUT.FIELD_KEY] != DBNull.Value)
                        {
                            keyCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY,
                                                         DatabaseCompareOperator.Equal, row[PARAMETERS_INPUT.FIELD_KEY].ToString());
                        }
                        else
                        {
                            keyCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY,
                                                         DatabaseCompareOperator.Null, string.Empty);
                        }

                        conditions.Add(keyCondition);

                        Condition editorCondition;

                        if (row[PARAMETERS_INPUT.FIELD_EDITOR] != null && row[PARAMETERS_INPUT.FIELD_EDITOR] != DBNull.Value)
                        {
                            editorCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDITOR,
                                                            DatabaseCompareOperator.Equal, row[PARAMETERS_INPUT.FIELD_EDITOR].ToString());
                        }
                        else
                        {
                            editorCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDITOR,
                                                            DatabaseCompareOperator.Null, string.Empty);
                        }

                        conditions.Add(editorCondition);

                        Condition editTimeCondition;

                        if (row[PARAMETERS_INPUT.FIELD_EDIT_TIME] != null && row[PARAMETERS_INPUT.FIELD_EDIT_TIME] != DBNull.Value)
                        {
                            editTimeCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDIT_TIME,
                                                              DatabaseCompareOperator.Equal, row[PARAMETERS_INPUT.FIELD_EDIT_TIME].ToString());
                        }
                        else
                        {
                            editTimeCondition = new Condition(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDIT_TIME,
                                                              DatabaseCompareOperator.Null, string.Empty);
                        }

                        conditions.Add(editTimeCondition);

                        conditionsList.Add(conditions);
                    }

                    #endregion

                    EMS_EQUIPMENT_GROUPS_FIELDS equipmentGroupsFields = new EMS_EQUIPMENT_GROUPS_FIELDS();

                    List <string> sqlStringList = DatabaseTable.BuildUpdateSqlStatements(equipmentGroupsFields, equipmentGroupsDataTable, conditionsList);

                    string equipmentGroupKey  = string.Empty;
                    string equipmentGroupName = string.Empty;
                    string sqlString          = string.Empty;
                    string editTime           = string.Empty;

                    if (sqlStringList.Count > 0 && inputParamDataTable.Rows.Count > 0 && equipmentGroupsDataTable.Rows.Count > 0)
                    {
                        equipmentGroupKey = inputParamDataTable.Rows[0][PARAMETERS_INPUT.FIELD_KEY].ToString();

                        equipmentGroupName = equipmentGroupsDataTable.Rows[0][EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_NAME].ToString();

                        sqlString = sqlStringList[0];
                    }

                    using (DbConnection connection = db.CreateConnection())
                    {
                        connection.Open();

                        using (DbTransaction transaction = connection.BeginTransaction())
                        {
                            try
                            {
                                #region Check Equipment Group Name

                                if (!string.IsNullOrEmpty(equipmentGroupName))
                                {
                                    Conditions conditions = new Conditions();

                                    conditions.Add(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_NAME, DatabaseCompareOperator.Equal, equipmentGroupName);

                                    conditions.Add(DatabaseLogicOperator.And, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY, DatabaseCompareOperator.NotEqual, equipmentGroupKey);

                                    string returnData = AllCommonFunctions.GetSpecifyTableColumnData(equipmentGroupsFields, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_NAME, conditions, transaction);

                                    if (!string.IsNullOrEmpty(returnData))
                                    {
                                        throw new Exception("${res:FanHai.Hemera.Modules.EMS.EquipmentGroups.M0001}");
                                    }
                                }

                                #endregion

                                if (db.ExecuteNonQuery(transaction, CommandType.Text, sqlString) > 0)
                                {
                                    editTime = AllCommonFunctions.GetSpecifyTableColumnData(equipmentGroupsFields, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDIT_TIME, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY,
                                                                                            equipmentGroupKey, transaction);
                                }
                                else
                                {
                                    throw new Exception("${res:FanHai.Hemera.Module.Common.M0002}");
                                }

                                transaction.Commit();
                            }
                            catch (Exception ex)
                            {
                                LogService.LogError("UpdateEquipmentGroups Error: " + ex.Message);
                                transaction.Rollback();

                                throw;
                            }
                            finally
                            {
                                connection.Close();
                            }
                        }
                    }

                    FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, string.Empty, editTime);
                }
                else
                {
                    FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, "${res:FanHai.Hemera.Module.Common.M0001}");
                }
            }
            catch (Exception ex)
            {
                FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, ex.Message);
                LogService.LogError("UpdateEquipmentGroups Error: " + ex.Message);
            }

            return(resDS);
        }
Пример #5
0
        /// <summary>
        /// 新增设备组。
        /// </summary>
        /// <param name="dsParams">包含设备组数据的数据集对象。</param>
        /// <returns>包含执行结果的数据集对象。</returns>
        public DataSet InsertEquipmentGroups(DataSet dsParams)
        {
            DataSet resDS = new DataSet();

            try
            {
                if (dsParams != null && dsParams.Tables.Contains(EMS_EQUIPMENT_GROUPS_FIELDS.DATABASE_TABLE_NAME) && dsParams.Tables.Contains(PARAMETERS_INPUT.DATABASE_TABLE_NAME))
                {
                    DataTable equipmentGroupsDataTable = dsParams.Tables[EMS_EQUIPMENT_GROUPS_FIELDS.DATABASE_TABLE_NAME];
                    DataTable inputParamDataTable      = dsParams.Tables[PARAMETERS_INPUT.DATABASE_TABLE_NAME];

                    EMS_EQUIPMENT_GROUPS_FIELDS equipmentGroupsFields = new EMS_EQUIPMENT_GROUPS_FIELDS();

                    List <string> sqlStringList = DatabaseTable.BuildInsertSqlStatements(equipmentGroupsFields, equipmentGroupsDataTable);

                    string equipmentGroupKey  = string.Empty;
                    string equipmentGroupName = string.Empty;
                    string sqlString          = string.Empty;
                    string createTime         = string.Empty;

                    if (sqlStringList.Count > 0 && inputParamDataTable.Rows.Count > 0 && equipmentGroupsDataTable.Rows.Count > 0)
                    {
                        equipmentGroupKey = inputParamDataTable.Rows[0][PARAMETERS_INPUT.FIELD_KEY].ToString();

                        equipmentGroupName = equipmentGroupsDataTable.Rows[0][EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_NAME].ToString();

                        sqlString = sqlStringList[0];
                    }

                    using (DbConnection connection = db.CreateConnection())
                    {
                        connection.Open();

                        using (DbTransaction transaction = connection.BeginTransaction())
                        {
                            try
                            {
                                #region Check Equipment Group Name

                                string returnData = AllCommonFunctions.GetSpecifyTableColumnData(equipmentGroupsFields, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_NAME, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_NAME, equipmentGroupName, transaction);

                                if (!string.IsNullOrEmpty(returnData))
                                {
                                    throw new Exception("${res:FanHai.Hemera.Modules.EMS.EquipmentGroups.M0001}");
                                }

                                #endregion

                                if (db.ExecuteNonQuery(transaction, CommandType.Text, sqlString) > 0)
                                {
                                    createTime = AllCommonFunctions.GetSpecifyTableColumnData(equipmentGroupsFields, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_CREATE_TIME, EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY,
                                                                                              equipmentGroupKey, transaction);
                                }
                                else
                                {
                                    throw new Exception("${res:FanHai.Hemera.Module.Common.M0002}");
                                }

                                transaction.Commit();
                            }
                            catch (Exception ex)
                            {
                                LogService.LogError("InsertEquipmentGroups Error: " + ex.Message);
                                transaction.Rollback();

                                throw;
                            }
                            finally
                            {
                                connection.Close();
                            }
                        }
                    }

                    FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, string.Empty, createTime);
                }
                else
                {
                    FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, "${res:FanHai.Hemera.Module.Common.M0001}");
                }
            }
            catch (Exception ex)
            {
                FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(resDS, ex.Message);
                LogService.LogError("InsertEquipmentGroups Error: " + ex.Message);
            }

            return(resDS);
        }
Пример #6
0
        public override bool Update()
        {
            #region Variables

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

            #endregion

            #region Build Input Parameters

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

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

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

                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 Build Equipment Groups Data

            this.DirtyList.Add(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDIT_TIME, new DirtyItem(EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EDIT_TIME, "", ""));

            Editor       = PropertyService.Get(PROPERTY_FIELDS.USER_NAME);
            EditTimeZone = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE);

            DataTable equipmentGroupsDataTable = EMS_EQUIPMENT_GROUPS_FIELDS.CreateDataTable();

            FanHai.Hemera.Utils.Common.Utils.AddKeyValuesToDataTable(ref equipmentGroupsDataTable, DirtyList);

            equipmentGroupsDataTable.AcceptChanges();

            reqDS.Tables.Add(equipmentGroupsDataTable);

            #endregion

            #region Call Remoting Interface

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

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

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

            #endregion

            #region Process Output Parameters

            string outputEditTime = string.Empty;

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

            if (string.IsNullOrEmpty(returnMsg))
            {
                EditTime = outputEditTime;

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

                return(false);
            }

            #endregion
        }
Пример #7
0
        public override bool Insert()
        {
            #region Variables

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

            #endregion

            #region Build Equipment Groups Data

            DataTable equipmentGroupsDataTable = EMS_EQUIPMENT_GROUPS_FIELDS.CreateDataTable();

            Dictionary <string, string> dataRow = new Dictionary <string, string>()
            {
                { EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_KEY, equipmentGroupKey },
                { EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_EQUIPMENT_GROUP_NAME, equipmentGroupName },
                { EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_SPEC, spec },
                { EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_DESCRIPTION, description },
                { EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_CREATOR, Creator },
                { EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_CREATE_TIMEZONE_KEY, CreateTimeZone },
                { EMS_EQUIPMENT_GROUPS_FIELDS.FIELD_CREATE_TIME, string.Empty }
            };

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

            equipmentGroupsDataTable.AcceptChanges();

            reqDS.Tables.Add(equipmentGroupsDataTable);

            #endregion

            #region Build Input Parameters

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

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

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

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

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

                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.CreateIEquipmentGroups().InsertEquipmentGroups(reqDS);
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex);

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

            #endregion

            #region Process Output Parameters

            string outputcreateTime = string.Empty;

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

            if (string.IsNullOrEmpty(returnMsg))
            {
                CreateTime = outputcreateTime;

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

                return(false);
            }

            #endregion
        }