Example #1
0
        /// <summary>
        /// DeleteCrmAttribute
        /// </summary>
        public DataSet DeleteBasicData()
        {
            DataSet dsReturn = new DataSet();

            try
            {
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                if (null != iServerObjFactory)
                {
                    //DeleteBasicData
                    dsReturn  = iServerObjFactory.CreateICrmAttributeEngine().DeleteBasicData(_datasetValue);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            return(dsReturn);
        }
Example #2
0
        /// <summary>
        /// Get information of Lot
        /// </summary>
        /// <returns>dataset</returns>
        public DataSet GetBaseCategory()
        {
            #region variable define

            DataSet dsReturn = new DataSet();
            #endregion

            #region detail deal
            try
            {
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                if (null != iServerObjFactory)
                {
                    //get category information
                    dsReturn  = iServerObjFactory.CreateICrmAttributeEngine().GetBasicDataCategoryInfo(null);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            #endregion

            return(dsReturn);
        }
Example #3
0
        /// <summary>
        ///SaveBaseAttribute
        /// </summary>
        /// <param name="bNew"></param>
        /// 基础表新增列视图保存数据 modi by chao.pang
        public void SaveBaseAttribute()
        {
            #region variable define
            Hashtable mainDataHashTable = new Hashtable();   //根据哈希表创建一个数据表对象 modi by chao.pang
            DataSet   dataSet           = new DataSet();
            DataSet   dsReturn          = new DataSet();
            #endregion

            //添加数据到hashtable modi by chao.pang
            #region mainDataHashTable
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_ATTRIBUTE_KEY, _attributeKey);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_ATTRIBUTE_NAME, _attributeName);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_CATEGORY_KEY, _categoryKey);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_DATA_TYPE, _dataType);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_ATTRIBUTE_ORDER, _attributeOrder);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_CREATOR, _creator);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_DESCRIPTIONS, _descriptions);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_CREATE_TIME, _createTime);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_CREATE_TIMEZONE, _createTimeZone);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_EDITOR, _editor);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_EDIT_TIME, _editTime);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_EDIT_TIMEZONE, _editTimeZone);
            #endregion

            #region add table to dataset
            DataTable mainDataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable);
            mainDataTable.TableName = TRANS_TABLES.TABLE_MAIN_DATA;
            dataSet.Tables.Add(mainDataTable);
            #endregion

            #region detail deal
            try
            {
                //使用远程调用技术 modi by chao.pang
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                if (null != iServerObjFactory)
                {
                    //get category information 通过远程调用调用server端的AddBasicDataColumnInfo方法添加数据 mido by chao.pang
                    dsReturn  = iServerObjFactory.CreateICrmAttributeEngine().AddBasicDataColumnInfo(dataSet);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            #endregion
        }
Example #4
0
        /// <summary>
        /// UpdateCrmAttribute
        /// </summary>
        public void UpdateCrmAttribute()
        {
            #region variable define
            Hashtable mainDataHashTable = new Hashtable();
            DataSet   dataSet           = new DataSet();
            DataSet   dsReturn          = new DataSet();

            #endregion

            #region mainDataHashTable
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_ATTRIBUTE_KEY, _attributeKey);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_ATTRIBUTE_NAME, _attributeName);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_CATEGORY_KEY, _categoryKey);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_DATA_TYPE, "");
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_ATTRIBUTE_ORDER, "");
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_EDITOR, _editor);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_DESCRIPTIONS, "");
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_EDIT_TIME, _editTime);
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_EDIT_TIMEZONE, _editTimeZone);
            #endregion

            #region add table to dataset
            DataTable mainDataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable);
            mainDataTable.TableName = TRANS_TABLES.TABLE_MAIN_DATA;
            dataSet.Tables.Add(mainDataTable);
            #endregion

            #region detail deal
            try
            {
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                if (null != iServerObjFactory)
                {
                    //UpdateCrmAttribute
                    dsReturn  = iServerObjFactory.CreateICrmAttributeEngine().UpdateBasicDataColumnInfo(dataSet);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            #endregion
        }
Example #5
0
        /// <summary>
        ///SaveBaseCategory
        /// </summary>
        /// <param name="bNew"></param>
        ///  <summary>
        public void SaveBaseCategory()
        {
            #region variable define
            Hashtable mainDataHashTable = new Hashtable();      //根据哈希表创建一个数据表对象 modi by chao.pang
            DataSet   dataSet           = new DataSet();
            DataSet   dsReturn          = new DataSet();
            #endregion

            #region mainDataHashTable
            mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CATEGORY_KEY, _categoryKey);          //主键添加到mainDataHashTable      modi by chao.pang
            mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CATEGORY_NAME, _categoryName);        //类别名称添加到mainDataHashTable  modi by chao.pang
            mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CREATOR, _creator);                   //编辑人添加到mainDataHashTable    modi by chao.pang
            mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_DESCRIPTIONS, _descriptions);         //描述添加到mainDataHashTable      modi by chao.pang
            mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CREATE_TIME, _createTime);            //创建时间添加到mainDataHashTable  modi by chao.pang
            mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CREATE_TIMEZONE, _createTimeZone);    //创建时区添加到mainDataHashTable  modi by chao.pang
            #endregion

            #region add table to dataset
            DataTable mainDataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable); //传入参数mainDataHashTable生成数据表到datatable modi chao.pang
            mainDataTable.TableName = TRANS_TABLES.TABLE_MAIN_DATA;
            dataSet.Tables.Add(mainDataTable);
            #endregion

            #region detail deal
            try
            {
                //使用远程调用技术 modi by chao.pang
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                if (null != iServerObjFactory)
                {
                    //get category information 传入参数dataset返回数据表ATTRIBUTE_KEY和ATTRIBUTE_VALUE两列值 modi by chao.pang
                    dsReturn  = iServerObjFactory.CreateICrmAttributeEngine().AddBasicDataCategoryInfo(dataSet);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            #endregion
        }
Example #6
0
        public DataSet GetDistinctColumnsData(DataSet dataSet)
        {
            #region variable define
            Hashtable mainDataHashTable = new Hashtable();
            DataSet   dsReturn          = new DataSet();
            #endregion

            //#region mainDataHashTable
            //mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_CATEGORY_KEY, _categoryKey);
            //mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CATEGORY_NAME, _categoryName);
            //#endregion

            //#region add table to dataset
            //DataTable mainDataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable);
            //mainDataTable.TableName = TRANS_TABLES.TABLE_MAIN_DATA;
            //dataSet.Tables.Add(mainDataTable);
            //#endregion

            #region detail deal
            try
            {
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                if (null != iServerObjFactory)
                {
                    //GetDistinctColumnsData
                    dataSet.Tables[0].TableName = "Columns";
                    dataSet.Tables[1].TableName = "Category";
                    dsReturn  = iServerObjFactory.CreateICrmAttributeEngine().GetDistinctColumnsData(dataSet);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            #endregion

            return(dsReturn);
        }
Example #7
0
        public DataSet GetAttributsColumnsForSomeCategory()
        {
            #region variable define
            Hashtable mainDataHashTable = new Hashtable();
            DataSet   dsReturn          = new DataSet();
            DataSet   dataSet           = new DataSet();
            #endregion

            #region mainDataHashTable
            mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CATEGORY_NAME, _myCategory);
            #endregion

            #region add table to dataset
            DataTable mainDataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable);
            mainDataTable.TableName = BASE_ATTRIBUTE_CATEGORY_FIELDS.DATABASE_TABLE_NAME;
            dataSet.Tables.Add(mainDataTable);
            #endregion

            #region detail deal
            try
            {
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                if (null != iServerObjFactory)
                {
                    //GetGruopBasicData

                    dsReturn  = iServerObjFactory.CreateICrmAttributeEngine().GetAttributsColumnsForSomeCategory(dataSet);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            #endregion

            return(dsReturn);
        }
Example #8
0
        public DataSet GetColumnInfoByAttributeKey()
        {
            #region variable define
            Hashtable mainDataHashTable = new Hashtable();
            DataSet   dataSet           = new DataSet();
            DataSet   dsReturn          = new DataSet();
            #endregion

            #region mainDataHashTable
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_ATTRIBUTE_KEY, _attributeKey);
            #endregion

            #region add table to dataset
            DataTable mainDataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable);
            mainDataTable.TableName = TRANS_TABLES.TABLE_MAIN_DATA;
            dataSet.Tables.Add(mainDataTable);
            #endregion

            #region detail deal
            try
            {
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                if (null != iServerObjFactory)
                {
                    //get category information
                    dsReturn  = iServerObjFactory.CreateICrmAttributeEngine().GetColumnInfoByAttributeKey(dataSet);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            #endregion

            return(dsReturn);
        }
Example #9
0
        /// <summary>
        /// DeleteBaseAttribute
        /// </summary>
        public void DeleteBaseAttribute()
        {
            #region variable define
            Hashtable mainDataHashTable = new Hashtable();          //根据哈希表创建一个数据表对象 modi by chao.pang
            DataSet   dataSet           = new DataSet();
            DataSet   dsReturn          = new DataSet();
            #endregion

            #region mainDataHashTable
            mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_ATTRIBUTE_KEY, _attributeKey);    //将参数_attributeKey值传入哈希表中 modi by chao.pang
            #endregion

            #region add table to dataset
            DataTable mainDataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable);
            mainDataTable.TableName = TRANS_TABLES.TABLE_MAIN_DATA;
            dataSet.Tables.Add(mainDataTable);
            #endregion

            #region detail deal
            try
            {
                //使用远程调用技术 modi by chao.pang
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                if (null != iServerObjFactory)
                {
                    //get category information 返回到table中 modi by chao.pang
                    dsReturn = iServerObjFactory.CreateICrmAttributeEngine().DeleteBasicDataColumnInfo(dataSet);
                    //获取错误信息 modi by chao.pang
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            #endregion
        }
Example #10
0
        /// <summary>
        /// Load Equipment State Type Data 绑定设备状态类型的值
        /// </summary>
        private void LoadEquipmentStateTypeData()
        {
            #region Variables

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

            #endregion

            #region Build Input Parameters
            //GetTwoColumnsDataTable返回值为数据表包含2列  Key 和 Value
            DataTable dataTable = AddinCommonStaticFunction.GetTwoColumnsDataTable();

            dataTable.TableName = TRANS_TABLES.TABLE_PARAM;                                                              //表名PARAM

            dataTable.Rows.Add(new object[] { "CODE", EMS_EQUIPMENT_STATES_FIELDS.FIELD_EQUIPMENT_STATE_TYPE });         //EQUIPMENT_STATE_TYPE状态类型
            dataTable.Rows.Add(new object[] { "CATEGORY", EMS_EQUIPMENT_STATES_FIELDS.FIELD_EQUIPMENT_STATE_CATEGORY }); //EQUIPMENT_STATE_CATEGORY设备状态分类
            //对datatable进行更改
            dataTable.AcceptChanges();
            //将数据表添加到数据集reqDS中
            reqDS.Tables.Add(dataTable);

            #endregion

            #region Call Remoting Interface

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

                if (serverFactory != null)
                {
                    //获取基础数据的设备状态类型
                    resDS = serverFactory.CreateICrmAttributeEngine().GetSpecifyAttributeData(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))
            {
                //绑定设备状态类型下拉列表的数据
                BindDataToStateTypeList(resDS.Tables[TRANS_TABLES.TABLE_UDAS]);
            }
            else
            {
                MessageService.ShowError(returnMsg);
            }

            #endregion
        }
Example #11
0
        public static DataSet GetUdaDataSetOfSomeType(string categoryKey)
        {
            #region variable define

            DataSet   dataSetFromAll       = new DataSet(); //all data to pass
            DataSet   dataSetBackAll       = new DataSet(); //all data to receive
            DataSet   dataSetFromGroupInfo = new DataSet(); //group info to pass
            DataSet   dataSetBackGroupInfo = new DataSet(); //group info to receive
            Hashtable mainDataHashTable    = new Hashtable();
            DataSet   dataSet  = new DataSet();
            DataSet   dsReturn = new DataSet();

            #endregion

            try
            {
                //UnregisterChannel
                CallRemotingService.UnregisterChannel();
                //get server object factory
                IServerObjFactory iServerObjFactory = CallRemotingService.GetRemoteObject();
                //get dynamic dataset 两列ATTRIBUTE_KEY,ATTRIBUTE_VALUE
                dataSetFromAll = AddinCommonStaticFunction.GetTwoColumnsCommonDs();
                //add data to datatable 添加数据到数据集的第一张表的第一行  为CATEGORY_KEY和61 modi by chao.pang
                dataSetFromAll.Tables[0].Rows.Add();
                dataSetFromAll.Tables[0].Rows[0][0] = "CATEGORY_KEY";
                dataSetFromAll.Tables[0].Rows[0][1] = categoryKey;     //61
                //call remoting check
                if (iServerObjFactory != null)
                {
                    mainDataHashTable = new Hashtable();
                    dataSet           = new DataSet();
                    #region mainDataHashTable
                    //两行两列hash表
                    mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_CATEGORY_KEY, categoryKey);      //第一行CATEGORY_KEY    61
                    mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CATEGORY_NAME, "");     //第二行CATEGORY_NAME   空值   modi by chao.Pang
                    #endregion

                    #region add table to dataset
                    DataTable mainDataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable); //添加到maindatatable中
                    mainDataTable.TableName = TRANS_TABLES.TABLE_MAIN_DATA;                                               //表名   MAINDATA
                    dataSet.Tables.Add(mainDataTable);                                                                    //数据集中添加MAINDATA表
                    #endregion

                    //get result of excute sql
                    dataSetBackAll = iServerObjFactory.CreateICrmAttributeEngine().GetAllData(dataSet);  //重3张基础数据表中获取数据 modi by chao.pang
                }
                //if there are datas
                if (dataSetBackAll.Tables.Count == 2)
                {     //返回表数量为2 modi by chao.pang
                    if (dataSetBackAll.Tables[0].Rows.Count > 0)
                    { //第一张表返回数据不为空 modi by chao.Pang
                        mainDataHashTable = new Hashtable();
                        dataSet           = new DataSet();
                        #region mainDataHashTable
                        mainDataHashTable.Add(BASE_ATTRIBUTE_FIELDS.FIELDS_CATEGORY_KEY, categoryKey);    //第一行CATEGORY_KEY    61
                        mainDataHashTable.Add(BASE_ATTRIBUTE_CATEGORY_FIELDS.FIELDS_CATEGORY_NAME, "");   //第二行CATEGORY_NAME   空值   modi by chao.Pang
                        #endregion

                        #region add table to dataset
                        DataTable mainDataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable);
                        mainDataTable.TableName = TRANS_TABLES.TABLE_MAIN_DATA;
                        dataSet.Tables.Add(mainDataTable);
                        #endregion

                        //get result of excute sql
                        dataSetBackAll = iServerObjFactory.CreateICrmAttributeEngine().GetGruopBasicData(dataSet);

                        //remove parameter table
                        dataSetBackAll.Tables.Remove(dataSetBackAll.Tables[1]);
                        //add parameter to datasetfromall
                        dataSetBackAll.Merge(dataSetFromAll.Tables[0], false, MissingSchemaAction.Add);
                        dataSetBackAll.Tables[0].TableName = "Columns";
                        dataSetBackAll.Tables[1].TableName = "Category";
                        //get some group info
                        dataSetBackGroupInfo = iServerObjFactory.CreateICrmAttributeEngine().GetDistinctColumnsData(dataSetBackAll);
                    }
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
            finally
            {
                //UnregisterChannel
                CallRemotingService.UnregisterChannel();
            }
            return(dataSetBackGroupInfo);
        }
Example #12
0
        /// <summary>
        /// 从数据库中查询基础数据。
        /// 即查询CRM_ATTRIBUTE(属性数据表)中的数据并进行行列转换,
        /// 然后将以ATTRIBUTE_NAME中的值为列,以ATTRIBUTE_VALUE的值为数据行的数据表对象返回给调用函数。
        /// </summary>
        /// <param name="columnNames">
        /// 字符串数组。
        /// 数组中的数据来源于数据库表CRM_ATTRIBUTE的ATTRIBUTE_NAME栏位中的值。
        /// </param>
        /// <param name="baseCategory">键值对。
        /// 键数据来源于数据表 BASE_ATTRIBUTE_CATEGORY 的列名(一般设置为"CATEGORY_NAME"),
        /// 值数据来源于列对应的具体的值(一般为"CATEGORY_NAME"栏位中的值)。</param>
        /// <returns>包含基础数据信息的数据集对象。包含<paramref name="columnNames"/>中的列名。</returns>
        public static DataTable Get(string[] columnNames,
                                    KeyValuePair <string, string> baseCategory)
        {
            //列集合为null,列集合没有数据,存放基础数据分类名的键值对对象的键或值无数据
            if (null == columnNames || columnNames.Length < 1 || baseCategory.Key.Length < 1 || baseCategory.Value.Length < 1)
            {
                return(null);
            }

            DataSet baseData = new DataSet();

            //存放列名的数据表,为远程调用函数提供参数。
            DataTable columnTable = new DataTable("Columns");

            columnTable.Columns.Add("ColumnName");
            //遍历列名
            for (int i = 0; i < columnNames.Length; i++)
            {
                columnTable.Rows.Add();
                columnTable.Rows[i][0] = columnNames[i];
            }
            //存放分类名的数据表,为远程调用函数提供参数。
            DataTable categoryTable = new DataTable("Category");

            categoryTable.Columns.Add("ColumnName");
            categoryTable.Columns.Add("ColumnValue");
            categoryTable.Rows.Add();
            categoryTable.Rows[0][0] = baseCategory.Key;
            categoryTable.Rows[0][1] = baseCategory.Value;
            //将存放列名的数据表和存放分类名的数据表添加到数据集中。为远程调用函数提供参数。
            DataSet paramData = new DataSet();

            paramData.Merge(columnTable, false, MissingSchemaAction.Add);
            paramData.Merge(categoryTable, false, MissingSchemaAction.Add);

            try
            {
                //创建远程调用的工厂对象。
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                if (null != serverFactory)//工厂对象不为null
                {
                    //调用远程方法,根据分类名和列名从数据库中查询基础数据。
                    baseData = serverFactory.CreateICrmAttributeEngine().GetDistinctColumnsData(paramData);
                    //解析远程调用的结果消息。
                    string msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(baseData);
                    if (msg != string.Empty)//消息不为空
                    {
                        MessageService.ShowError(msg);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            //返回存放基础数据的数据表对象。
            return(baseData.Tables[0]);
        }
Example #13
0
        /// <summary>
        /// 根据查询条件获取基础数据。
        /// </summary>
        /// <param name="columnNames">列名。</param>
        /// <param name="categoryName">类别名的键值对。
        /// 键数据来源于数据表 BASE_ATTRIBUTE_CATEGORY 的列名(一般设置为"CATEGORY_NAME"),
        /// 值数据来源于列对应的具体的值(一般为"CATEGORY_NAME"栏位中的值)。
        /// </param>
        /// <param name="whereConditons">包含查询条件的键值对集合。</param>
        /// <returns> 包含基础数据信息的数据集对象。列名参考<paramref name="columnNames"/></returns>
        public static DataTable GetBasicDataByCondition(string[] columnNames,
                                                        KeyValuePair <string, string> baseCategory,
                                                        List <KeyValuePair <string, string> > whereConditons)
        {
            if (null == columnNames || columnNames.Length < 1 || baseCategory.Key.Length < 1 || baseCategory.Value.Length < 1)
            {
                return(null);
            }

            DataSet   paramData   = new DataSet();
            DataSet   baseData    = new DataSet();
            DataTable columnTable = new DataTable(BASIC_CONST.PARAM_TABLENAME_COLUMNS);

            columnTable.Columns.Add(BASIC_CONST.PARAM_COL_COLUMN_NAME);

            foreach (string columnName in columnNames)
            {
                columnTable.Rows.Add();
                columnTable.Rows[columnTable.Rows.Count - 1][BASIC_CONST.PARAM_COL_COLUMN_NAME] = columnName;
            }


            DataTable categoryTable = new DataTable(BASIC_CONST.PARAM_TABLENAME_CATEGORY);

            categoryTable.Columns.Add(BASIC_CONST.PARAM_COL_COLUMN_NAME);
            categoryTable.Columns.Add(BASIC_CONST.PARAM_COL_COLUMN_VALUE);
            categoryTable.Rows.Add();
            categoryTable.Rows[0][BASIC_CONST.PARAM_COL_COLUMN_NAME]  = baseCategory.Key;
            categoryTable.Rows[0][BASIC_CONST.PARAM_COL_COLUMN_VALUE] = baseCategory.Value;

            paramData.Merge(columnTable, false, MissingSchemaAction.Add);
            paramData.Merge(categoryTable, false, MissingSchemaAction.Add);

            if (null != whereConditons || whereConditons.Count > 0)
            {
                DataTable conditionTable = new DataTable(BASIC_CONST.PARAM_TABLENAME_CONDITIONS);
                conditionTable.Columns.Add(BASIC_CONST.PARAM_COL_COLUMN_NAME);
                conditionTable.Columns.Add(BASIC_CONST.PARAM_COL_COLUMN_VALUE);

                foreach (KeyValuePair <string, string> condition in whereConditons)
                {
                    conditionTable.Rows.Add();
                    conditionTable.Rows[conditionTable.Rows.Count - 1][BASIC_CONST.PARAM_COL_COLUMN_NAME]  = condition.Key;
                    conditionTable.Rows[conditionTable.Rows.Count - 1][BASIC_CONST.PARAM_COL_COLUMN_VALUE] = condition.Value;
                }
                paramData.Merge(conditionTable, false, MissingSchemaAction.Add);
            }

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                if (null != serverFactory)
                {
                    baseData = serverFactory.CreateICrmAttributeEngine().GetBasicDataByConditons(paramData);
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError(ex.Message);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            return(baseData.Tables[0]);
        }