Пример #1
0
        /// <summary>
        /// 填充要新增或删除的数据到数据表。
        /// </summary>
        /// <param name="stepUpdateTable">包含新增或删除工步数据的数据表。</param>
        /// <param name="stepUDAs">包含工步自定义属性新增或删除数据的数据表。</param>
        /// <param name="stepParams">包含工步参数更新数据的数据表。</param>
        internal void ParseInsertAndDeleteDataToDataTable(ref DataTable stepTable, ref DataTable stepUDAs, ref DataTable stepParams)
        {
            DataRow drStep = stepTable.NewRow();

            stepTable.Rows.Add(drStep);
            drStep[COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION]                 = Convert.ToInt32(_operationAction);
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_KEY]                  = _stepKey;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]                 = _stepName;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_STEP_VERSION]                    = _stepVersion;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_DURATION]                        = _osDuration;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_DESCRIPTIONS]                    = _osDescription;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_OPERATION_VER_KEY]         = _operationVerKey;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_OPERATION_NAME]            = _operationName;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_ROUTE_VER_KEY]             = _routeVerKey;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_SEQ]                  = _stepSeqence;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_PARAM_ORDER_TYPE]                = (int)_paramOrderType;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_PARAM_COUNT_PER_ROW]             = _paramCountPerRow;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_SCRAP_REASON_CODE_CATEGORY_KEY]  = _scrapCodesKey;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_DEFECT_REASON_CODE_CATEGORY_KEY] = _defectCodesKey;
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_CREATOR]         = PropertyService.Get(PROPERTY_FIELDS.USER_NAME);
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_CREATE_TIMEZONE] = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE);
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_EDITOR]          = PropertyService.Get(PROPERTY_FIELDS.USER_NAME);
            drStep[POR_ROUTE_STEP_FIELDS.FIELD_EDIT_TIMEZONE]   = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE);
            _stepUDAs.ParseInsertDataToDataTable(ref stepUDAs);

            if (this.Params != null)
            {
                DataTable dtStepParamChange = this.Params.GetChanges();
                if (dtStepParamChange != null)
                {
                    stepParams.Merge(dtStepParamChange, false, MissingSchemaAction.Ignore);
                }
                foreach (DataRow dr in stepParams.Rows)
                {
                    dr[POR_ROUTE_STEP_PARAM_FIELDS.FIELD_EDIT_TIME]     = DBNull.Value;
                    dr[POR_ROUTE_STEP_PARAM_FIELDS.FIELD_EDIT_TIMEZONE] = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE);
                    dr[POR_ROUTE_STEP_PARAM_FIELDS.FIELD_EDITOR]        = PropertyService.Get(PROPERTY_FIELDS.USER_NAME);
                }
            }
        }
Пример #2
0
        public override bool Insert()
        {
            bool    bResult = false;
            DataSet dataSet = new DataSet();

            DataTable dtComputerConf            = CreateDataTableForInsert();
            Dictionary <string, string> dataRow = new Dictionary <string, string>()
            {
                { COMPUTER_FIELDS.FIELDS_CODE_KEY, _codeKey },
                { COMPUTER_FIELDS.FIELDS_COMPUTER_NAME, _computerName.ToUpper() },
                { COMPUTER_FIELDS.FIELDS_EDITOR, PropertyService.Get(PROPERTY_FIELDS.USER_NAME) },
                { COMPUTER_FIELDS.FIELDS_DESCRIPTION, _computerDesc.ToUpper() }
            };

            FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref dtComputerConf, dataRow);
            if (dtComputerConf.Rows.Count > 0)
            {
                dataSet.Tables.Add(dtComputerConf);
            }

            // WorkOrder UDAs
            if (_UDAs.UserDefinedAttrList.Count > 0)
            {
                DataTable dtUDAs = DataTableHelper.CreateDataTableForUDA(COMPUTER_ATTR_FIELDS.DATABASE_TABLE_NAME, COMPUTER_ATTR_FIELDS.FIELDS_COMPUTER_KEY);
                _UDAs.ParseInsertDataToDataTable(ref dtUDAs);

                if (dtUDAs.Rows.Count > 0)
                {
                    dataSet.Tables.Add(dtUDAs);
                }
            }
            try
            {
                IServerObjFactory factor = CallRemotingService.GetRemoteObject();
                if (null != factor)
                {
                    if (dataSet.Tables.Count > 0)
                    {
                        DataSet retDS  = factor.CreateIComputerEngine().AddComputer(dataSet);
                        string  strMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(retDS);
                        if (strMsg.Length < 1)
                        {
                            foreach (UserDefinedAttr uda in _UDAs.UserDefinedAttrList)
                            {
                                uda.OperationAction = OperationAction.Update;
                            }
                            this.ResetDirtyList();
                            bResult = true;
                        }
                        else
                        {
                            MessageService.ShowError(strMsg);
                        }
                    }
                    else
                    {
                        MessageService.ShowWarning("No dataTable in input parameter");
                    }
                }
            }
            catch (Exception e)
            {
                MessageService.ShowError(e.Message);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(bResult);
        }
Пример #3
0
        /// <summary>
        /// 新增工序记录。
        /// </summary>
        /// <returns>true:新增成功。false:新增失败。</returns>
        public override bool Insert()
        {
            DataSet dsParams = new DataSet();
            POR_ROUTE_OPERATION_VER_FIELDS fields = new POR_ROUTE_OPERATION_VER_FIELDS();
            DataTable dtOperation = CommonUtils.CreateDataTable(fields);
            //组织工序数据。
            DataRow drOperation = dtOperation.NewRow();

            dtOperation.Rows.Add(drOperation);
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_ROUTE_OPERATION_VER_KEY] = _operationVerKey;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_ROUTE_OPERATION_NAME]    = _operationName;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_DURATION]                        = _osDuration;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_SORT_SEQ]                        = _sortSequence;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_OPERATION_STATUS]                = Convert.ToInt32(_operationStatus);
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_DESCRIPTIONS]                    = _osDescription;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_PARAM_ORDER_TYPE]                = Convert.ToInt32(_paramOrderType);
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_PARAM_COUNT_PER_ROW]             = _paramCountPerRow;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_SCRAP_REASON_CODE_CATEGORY_KEY]  = _scrapCodesKey;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_DEFECT_REASON_CODE_CATEGORY_KEY] = _defectCodesKey;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_CREATOR]         = this.Creator;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_EDITOR]          = this.Editor;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_EDIT_TIMEZONE]   = this.EditTimeZone;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_CREATE_TIMEZONE] = this.CreateTimeZone;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_CREATE_TIME]     = DBNull.Value;
            drOperation[POR_ROUTE_OPERATION_VER_FIELDS.FIELD_EDIT_TIME]       = DBNull.Value;
            dsParams.Tables.Add(dtOperation);
            //组织自定义属性数据。
            DataTable operationUdaTable = DataTableHelper.CreateDataTableForUDA(POR_ROUTE_OPERATION_ATTR_FIELDS.DATABASE_TABLE_NAME,
                                                                                POR_ROUTE_OPERATION_ATTR_FIELDS.FIELD_OPERATION_VER_KEY);

            _operationUDAs.ParseInsertDataToDataTable(ref operationUdaTable);
            if (operationUdaTable.Rows.Count > 0)
            {
                //如果有LINED_EDC类型的,则将参数名称转换为参数主键存储到数据库中。
                DealUdaTable(operationUdaTable, "I");
                dsParams.Tables.Add(operationUdaTable);
            }
            //组织工序参数数据。
            DataTable dtOperationParams = this._params.GetChanges();

            if (dtOperationParams != null)
            {
                dtOperationParams.TableName = POR_ROUTE_OPERATION_PARAM_FIELDS.DATABASE_TABLE_NAME;
                foreach (DataRow dr in dtOperationParams.Rows)
                {
                    dr[POR_ROUTE_OPERATION_PARAM_FIELDS.FIELD_EDITOR]        = this.Editor;
                    dr[POR_ROUTE_OPERATION_PARAM_FIELDS.FIELD_EDIT_TIME]     = DBNull.Value;
                    dr[POR_ROUTE_OPERATION_PARAM_FIELDS.FIELD_EDIT_TIMEZONE] = this.EditTimeZone;
                }
                dsParams.Tables.Add(dtOperationParams);
            }
            try
            {
                int               code     = 0;
                string            msg      = string.Empty;
                IServerObjFactory factor   = CallRemotingService.GetRemoteObject();
                DataSet           dsReturn = factor.CreateIOperationEngine().OperationInsert(dsParams);
                msg = ReturnMessageUtils.GetServerReturnMessage(dsReturn, ref code);
                if (code == -1)
                {
                    this.ErrorMsg = msg;
                    MessageService.ShowError(msg);
                    return(false);
                }
                else
                {
                    this.OperationVersion = msg;
                    foreach (UserDefinedAttr uda in _operationUDAs.UserDefinedAttrList)
                    {
                        uda.OperationAction = OperationAction.Update;
                    }
                    this._params.AcceptChanges();
                    this.ResetDirtyList();
                    MessageService.ShowMessage("${res:Global.SuccessMessage}", "${res:Global.SystemInfo}");
                }
            }
            catch (Exception ex)
            {
                this.ErrorMsg = ex.Message;
                MessageService.ShowError(ex);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(true);
        }