Esempio n. 1
0
 /// <summary>
 /// 原因代码名称验证。
 /// </summary>
 /// <returns>true:通过;否则失败。</returns>
 public bool ReasonCodeNameValidate()
 {
     try
     {
         IServerObjFactory factor   = CallRemotingService.GetRemoteObject();
         DataSet           dsReturn = factor.CreateIReasonCodeEngine().GetReasonCode(this._codeType, this._codeName, this._codeClass);
         string            msg      = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
         if (!string.IsNullOrEmpty(msg))
         {
             MessageService.ShowError(msg);
             return(false);
         }
         if (dsReturn != null &&
             dsReturn.Tables.Count > 0 &&
             dsReturn.Tables[0].Rows.Count > 0)
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         MessageService.ShowError(ex);
         return(false);
     }
     finally
     {
         CallRemotingService.UnregisterChannel();
     }
     return(true);
 }
Esempio n. 2
0
        /// <summary>
        /// 根据主键获取工序记录。
        /// </summary>
        /// <param name="operationKey">工序主键。</param>
        private void GetOperationByKey(string operationKey)
        {
            try
            {
                string            msg      = string.Empty;
                IServerObjFactory factor   = CallRemotingService.GetRemoteObject();
                DataSet           dsReturn = factor.CreateIOperationEngine().GetOperationByKey(operationKey);
                msg = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                if (msg != string.Empty)
                {
                    this.ErrorMsg = msg;
                    MessageService.ShowError(msg);
                }
                else
                {
                    SetOperationProperties(dsReturn.Tables[POR_ROUTE_OPERATION_VER_FIELDS.DATABASE_TABLE_NAME]);

                    this._params = dsReturn.Tables[POR_ROUTE_OPERATION_PARAM_FIELDS.DATABASE_TABLE_NAME];
                    if (null != dsReturn.Tables[POR_ROUTE_OPERATION_ATTR_FIELDS.DATABASE_TABLE_NAME])
                    {
                        SetOperationUDAs(dsReturn.Tables[POR_ROUTE_OPERATION_ATTR_FIELDS.DATABASE_TABLE_NAME]);
                    }
                }
            }
            catch (Exception ex)
            {
                this.ErrorMsg = ex.Message;
                MessageService.ShowError(ex);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 保存标签或铭牌数据。
 /// </summary>
 /// <param name="dsParams">包含标签或铭牌数据的数据集对象。</param>
 /// <returns>包含执行结果的数据集对象。</returns>
 public void SavePrintLabelData(DataSet dsParams)
 {
     try
     {
         IServerObjFactory obj      = CallRemotingService.GetRemoteObject();
         DataSet           dsReturn = obj.Get <IBasicPrintLabelEngine>().SavePrintLabelData(dsParams);
         _errorMsg = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
     }
     catch (Exception ex)
     {
         _errorMsg = ex.Message;
     }
     finally
     {
         CallRemotingService.UnregisterChannel();
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 根据托盘号获取批次信息。
        /// </summary>
        /// <param name="pallet_no">托盘号</param>
        /// <returns>包含批次信息的数据集</returns>
        public DataSet GetLotInfoByPallet_No(string pallet_no)
        {
            DataSet dsReturn = null;

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                dsReturn  = serverFactory.CreateILotEngine().GetLotInfoByPallet_No(pallet_no);
                _errorMsg = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(dsReturn);
        }
Esempio n. 5
0
        /// <summary>
        /// 根据厂别获取组件录入卡控信息
        /// </summary>
        /// <param name="sFactoryName">厂别。</param>
        /// <returns>
        /// 根据厂别获取组件录入卡控信息
        /// </returns>
        public DataSet GetCheckbarcodeInputType(string sFactoryName)
        {
            DataSet dsReturn = null;

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                dsReturn  = serverFactory.CreateILotEngine().GetCheckbarcodeInputType(sFactoryName);
                _errorMsg = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(dsReturn);
        }
Esempio n. 6
0
        public DataSet GetEquipments()
        {
            DataSet dsReturn = null;

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                dsReturn  = serverFactory.CreateIEquipments().GetEquipments();
                _errorMsg = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(dsReturn);
        }
Esempio n. 7
0
        /// <summary>
        /// 根据批次号及指定等级。获取批次对应工单中符合指定等级条件的推荐产品数据。
        /// </summary>
        /// <param name="lotNo">批次号。</param>
        /// <param name="grade">等级。</param>
        /// <returns>包含产品数据的数据集对象。</returns>
        public DataSet GetLotProductData(string lotNo, string grade)
        {
            DataSet dsReturn = null;

            try
            {
                _errorMsg = string.Empty;
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                dsReturn  = serverFactory.CreateILotEngine().GetLotProductData(lotNo, grade);
                _errorMsg = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(dsReturn);
        }
Esempio n. 8
0
        /// <summary>
        /// 获取指定工步采集参数对应的工单参数设定数据。用于比对在采集时输入的数据是否符合工单参数设定。
        /// </summary>
        /// <param name="workorderKey">工单主键。</param>
        /// <param name="stepKey">工步主键。</param>
        /// <param name="dcType">数据采集时刻。0:进站时采集 1:出站时采集</param>
        /// <returns>包含工单参数设定数据的数据集对象。</returns>
        public DataSet GetWorkOrderParam(string workorderKey, string stepKey, OperationParamDCType dcType)
        {
            DataSet dsReturn = new DataSet();

            try
            {
                //调用远程对象
                IServerObjFactory factor = CallRemotingService.GetRemoteObject();
                dsReturn       = factor.CreateIWorkOrders().GetWorkOrderParam(workorderKey, stepKey, (int)dcType);
                this._errorMsg = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
            }
            catch (Exception e)
            {
                this._errorMsg = e.Message;
            }
            finally
            {
                //注销通道
                CallRemotingService.UnregisterChannel();
            }
            return(dsReturn);
        }
Esempio n. 9
0
 /// <summary>
 /// 是否允许设置标签或数据为无效数据。
 /// </summary>
 /// <param name="labelId">标签或铭牌ID</param>
 /// <returns>包含执行结果的数据集对象。</returns>
 public bool IsAllowInvalid(string labelId)
 {
     try
     {
         IServerObjFactory obj      = CallRemotingService.GetRemoteObject();
         DataSet           dsReturn = obj.Get <IBasicPrintLabelEngine>().IsAllowInvalid(labelId);
         _errorMsg = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
         if (!string.IsNullOrEmpty(_errorMsg))
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         _errorMsg = ex.Message;
         return(false);
     }
     finally
     {
         CallRemotingService.UnregisterChannel();
     }
     return(true);
 }
Esempio n. 10
0
 /// <summary>
 /// 获取标签或铭牌明细数据。
 /// </summary>
 /// <returns>包含标签或铭牌明细数据的数据集对象。</returns>
 public DataSet GetPrintLabelDetailData(string labelId)
 {
     try
     {
         IServerObjFactory obj      = CallRemotingService.GetRemoteObject();
         DataSet           dsReturn = obj.Get <IBasicPrintLabelEngine>().GetPrintLabelDetailData(labelId);
         _errorMsg = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
         if (!string.IsNullOrEmpty(_errorMsg))
         {
             return(null);
         }
         return(dsReturn);
     }
     catch (Exception ex)
     {
         _errorMsg = ex.Message;
     }
     finally
     {
         CallRemotingService.UnregisterChannel();
     }
     return(null);
 }
Esempio n. 11
0
        /// <summary>
        /// Execute SAP Remote Function Call from Remoting Server
        /// </summary>
        /// <param name="functionName"></param>
        /// <param name="inputData"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        /// Owner:Andy Gao 2011-05-31 10:39:48
        public static DataSet ExecuteRFC(string functionName, DataSet inputData, out string msg)
        {
            msg = string.Empty;

            DataSet outputData = null;

            #region Call Remoting Interface

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

                if (serverFactory == null)
                {
                    msg = "The Server Factory is null.";
                }
                else
                {
                    outputData = serverFactory.CreateIRFCEngine().ExecuteRFC(functionName, inputData);

                    msg = ReturnMessageUtils.GetServerReturnMessage(outputData);
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            #endregion

            return(outputData);
        }
Esempio n. 12
0
        /// <summary>
        /// 检查批次是否需要进行数据采集。
        /// </summary>
        /// <param name="dbTrans"></param>
        /// <param name="lotKey">唯一标识批次的主键或批次号。</param>
        /// <param name="equipmentKey">唯一表示设备的主键。</param>
        /// <param name="edcpntKey">数据抽检设置主键。输出参数。</param>
        /// <returns>true:批次需要抽检。false:批次不需要抽检。</returns>
        private bool CheckNeedEdc(DbTransaction dbTrans, string lotKey, string equipmentKey, out string edcpntKey)
        {
            edcpntKey = string.Empty;
            DataSet dsLot = GetLotsInfo(dbTrans, lotKey);
            string  msg   = ReturnMessageUtils.GetServerReturnMessage(dsLot);

            if (!string.IsNullOrEmpty(msg))
            {
                throw new Exception(msg);
            }
            //获取批次信息
            DataTable  dtLot         = dsLot.Tables[0];
            string     routeKey      = dtLot.Rows[0][POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY].ToString();      //工艺流程主键。
            string     stepKey       = dtLot.Rows[0][POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY].ToString();       //工步主键
            string     oprLine       = dtLot.Rows[0][POR_LOT_FIELDS.FIELD_OPR_LINE].ToString();               //操作线别
            string     partNumber    = dtLot.Rows[0][POR_WORK_ORDER_FIELDS.FIELD_PART_NUMBER].ToString();     //成品号
            string     operationName = dtLot.Rows[0][POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME].ToString(); //工序名称
            IEDCEngine edcEngine     = RemotingServer.ServerObjFactory.Get <IEDCEngine>();
            Hashtable  hashTable     = new Hashtable();

            hashTable.Add(POR_WORK_ORDER_FIELDS.FIELD_PART_NUMBER, partNumber);
            hashTable.Add(POR_ROUTE_OPERATION_VER_FIELDS.FIELD_ROUTE_OPERATION_NAME, operationName);
            hashTable.Add(EDC_POINT_FIELDS.FIELD_ACTION_NAME, ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_TRACKOUT);
            hashTable.Add(EDC_POINT_FIELDS.FIELD_ROUTE_VER_KEY, routeKey);
            if (equipmentKey != string.Empty)
            {
                hashTable.Add(EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_KEY, equipmentKey);
            }
            DataTable dataTable = new DataTable();

            dataTable = SolarViewer.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
            //获取数据抽检点。
            DataSet dsEdcPoint = edcEngine.CheckEdc(dataTable);

            msg = SolarViewer.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsEdcPoint);
            if (msg == string.Empty) //成功获取到数据抽检点集合。
            {
                string samplingKey = string.Empty;
                //获取的数据抽检点集合存在数据。
                if (dsEdcPoint.Tables.Count > 0 && dsEdcPoint.Tables[0].Rows.Count > 0)
                {
                    string edcPointKey = dsEdcPoint.Tables[0].Rows[0][EDC_POINT_FIELDS.FIELD_ROW_KEY].ToString();
                    //抽检参数没有满足条件的,则不进行抽检。
                    if (!edcEngine.CheckEDCPointParams(edcPointKey))
                    {
                        return(false);
                    }
                    string edcKey = dsEdcPoint.Tables[0].Rows[0][EDC_POINT_FIELDS.FIELD_EDC_KEY].ToString();
                    if (dsEdcPoint.Tables[0].Rows[0][EDC_POINT_FIELDS.FIELD_SP_KEY] != null)
                    {
                        samplingKey = dsEdcPoint.Tables[0].Rows[0][EDC_POINT_FIELDS.FIELD_SP_KEY].ToString();
                    }
                    bool blNeedSamp = false;
                    //获取当前工步是否有依赖的抽样工步。
                    string dependSampStep = GetStepUdaValue(db, stepKey, "DependSampStep");
                    //依赖的抽样工步不为空
                    if (dependSampStep != string.Empty && dependSampStep.Length > 0)
                    {
                        //检查是否进行了抽检。true 进行抽检,false没有进行抽检。
                        //如果该批次在依赖的抽样工步进行了抽检,则该批次在当前工步必须抽检。
                        blNeedSamp = edcEngine.CheckDependSampStep(lotKey, dependSampStep);
                    }
                    //依赖的抽样工步没有进行抽检 并且 依赖抽检的工步为空。
                    if (blNeedSamp == false && dependSampStep == string.Empty)
                    {
                        //如果抽样规则主键为空,则需要进行抽检。
                        if (samplingKey == string.Empty)
                        {
                            blNeedSamp = true;
                        }
                        else
                        {//如果抽样规则主键不为空,则需要根据抽检规则进行判断是否进行抽检。
                            blNeedSamp = edcEngine.CheckSampling(
                                lotKey,
                                stepKey,
                                dtLot.Rows[0][POR_LOT_FIELDS.FIELD_CUR_PRODUCTION_LINE_KEY].ToString(),
                                samplingKey,
                                ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_OUTEDC,
                                equipmentKey);
                        }
                    }
                    //上面判断需要进行抽检。
                    if (blNeedSamp)
                    {
                        edcpntKey = edcPointKey;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            //批次不需要抽检
            return(false);
        }
Esempio n. 13
0
        /// <summary>
        /// 更新工序记录。
        /// </summary>
        /// <returns>true:更新成功。false:更新失败。</returns>
        public override bool Update()
        {
            if (IsDirty)
            {
                DataSet   dsParams = new DataSet();
                Hashtable htCommon = new Hashtable();
                htCommon.Add(COMMON_FIELDS.FIELD_COMMON_EDIT_TIMEZONE, this.EditTimeZone);
                htCommon.Add(COMMON_FIELDS.FIELD_COMMON_EDITOR, this.Editor);
                htCommon.Add(COMMON_FIELDS.FIELD_COMMON_EDIT_TIME, this.EditTime);
                DataTable dtCommon = CommonUtils.ParseToDataTable(htCommon);
                dtCommon.TableName = TRANS_TABLES.TABLE_MAIN_DATA;
                dsParams.Tables.Add(dtCommon);
                //组织工序数据
                if (this.DirtyList.Count > 0)
                {
                    Hashtable htOpeartion = new Hashtable();
                    htOpeartion.Add(POR_ROUTE_OPERATION_VER_FIELDS.FIELD_ROUTE_OPERATION_VER_KEY, _operationVerKey);
                    foreach (string Key in this.DirtyList.Keys)
                    {
                        htOpeartion.Add(Key, this.DirtyList[Key].FieldNewValue);
                    }
                    DataTable dtOperation = CommonUtils.ParseToDataTable(htOpeartion);
                    dtOperation.TableName = POR_ROUTE_OPERATION_VER_FIELDS.DATABASE_TABLE_NAME;
                    dsParams.Tables.Add(dtOperation);
                }
                //组织自定义属性。
                if (_operationUDAs.IsDirty)
                {
                    DataTable operationUdaTable = DataTableHelper.CreateDataTableForUDA
                                                      (POR_ROUTE_OPERATION_ATTR_FIELDS.DATABASE_TABLE_NAME, POR_ROUTE_OPERATION_ATTR_FIELDS.FIELD_OPERATION_VER_KEY);
                    _operationUDAs.ParseUpdateDataToDataTable(ref operationUdaTable);
                    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
                {
                    string            msg      = string.Empty;
                    DataSet           dsReturn = null;
                    IServerObjFactory factor   = CallRemotingService.GetRemoteObject();
                    if (null != factor)
                    {
                        dsReturn = factor.CreateIOperationEngine().OperationUpdate(dsParams);
                        msg      = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                        if (msg != string.Empty)
                        {
                            this.ErrorMsg = msg;
                            MessageService.ShowError(msg);
                            return(false);
                        }
                        else
                        {
                            foreach (UserDefinedAttr uda in _operationUDAs.UserDefinedAttrList)
                            {
                                uda.OperationAction = OperationAction.Update;
                            }
                            foreach (DataRow dr in this._params.Rows)
                            {
                                int isDeleted = Convert.ToInt32(dr[POR_ROUTE_OPERATION_PARAM_FIELDS.FIELD_IS_DELETED]);
                                if (isDeleted == 1)
                                {
                                    dr.Delete();
                                }
                            }
                            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();
                }
            }
            else
            {
                MessageService.ShowMessage
                    ("${res:Global.UpdateItemDataMessage}", "${res:Global.SystemInfo}");
            }

            return(true);
        }
Esempio n. 14
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);
        }
Esempio n. 15
0
        /// <summary>
        /// 批次自动过站。
        /// </summary>
        /// <param name="rowKey">WIP_JOB表主键。</param>
        /// <returns>包含自动过站执行结果的数据集。</returns>
        public DataSet AutoTrackOut(string rowKey)
        {
            DataSet dsReturn = new DataSet();

            try
            {
                string msg = string.Empty;
                //获取批次自动过站任务记录
                string  sql   = string.Format(@"SELECT * FROM WIP_JOB WHERE ROW_KEY='{0}'", rowKey);
                DataSet dsJob = db.ExecuteDataSet(CommandType.Text, sql);
                if (dsJob == null || dsJob.Tables.Count <= 0 || dsJob.Tables[0].Rows.Count <= 0)
                {
                    ReturnMessageUtils.AddServerReturnMessage(dsReturn, "WIP_JOB表主键对应的记录不存在。");
                    return(dsReturn);
                }
                string equipmentKey  = dsJob.Tables[0].Rows[0][EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_KEY].ToString();
                string enterpriseKey = dsJob.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_ENTERPRISE_KEY].ToString();
                string routeKey      = dsJob.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_ROUTE_KEY].ToString();
                string stepKey       = dsJob.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_STEP_KEY].ToString();
                string lotKey        = dsJob.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_LOT_KEY].ToString();
                string editor        = dsJob.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_EDITOR].ToString();
                string editTimeZone  = dsJob.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_EDIT_TIMEZONE].ToString();
                string strToUser     = dsJob.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_EDITOR].ToString();
                //获取自动出站的批次信息。
                ILotEngine lotEngine = RemotingServer.ServerObjFactory.Get <ILotEngine>();
                DataSet    dsLots    = lotEngine.GetLotInfo(lotKey);
                msg = ReturnMessageUtils.GetServerReturnMessage(dsLots);
                if (!string.IsNullOrEmpty(msg) ||
                    dsLots == null ||
                    dsLots.Tables.Count <= 0 ||
                    dsLots.Tables[0].Rows.Count <= 0)
                {
                    ReturnMessageUtils.AddServerReturnMessage(dsReturn, msg);
                    WipManagement.RecordErrorMessage(db, "批次出站异常:获取批次信息失败,", msg, strToUser, "EMSGOUT", editor, editTimeZone, lotKey, "LOT");
                    return(dsReturn);
                }
                DataRow drLot     = dsLots.Tables[0].Rows[0];
                int     stateFlag = Convert.ToInt32(drLot[POR_LOT_FIELDS.FIELD_STATE_FLAG]);
                if (stateFlag == 9 || stateFlag == 4)
                {
                    DataSet dsParams = new DataSet();
                    //获取下一个工步数据。
                    IEnterpriseEngine enterpriseEngine = RemotingServer.ServerObjFactory.Get <IEnterpriseEngine>();
                    DataSet           dsRouteNextStep  = enterpriseEngine.GetEnterpriseNextRouteAndStep(enterpriseKey, routeKey, stepKey);
                    msg = ReturnMessageUtils.GetServerReturnMessage(dsRouteNextStep);
                    if (!string.IsNullOrEmpty(msg))
                    {
                        ReturnMessageUtils.AddServerReturnMessage(dsReturn, msg);
                        WipManagement.RecordErrorMessage(db, "批次出站异常:获取下一工艺流程失败,", msg, strToUser, "EMSGOUT", editor, editTimeZone, lotKey, "LOT");
                        return(dsReturn);
                    }
                    string enterpriseName   = Convert.ToString(drLot[POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ENTERPRISE_NAME]);
                    string routeName        = Convert.ToString(drLot[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME]);
                    string stepName         = Convert.ToString(drLot[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]);
                    string toEnterpriseKey  = enterpriseKey;
                    string toRouteKey       = routeKey;
                    string toStepKey        = stepKey;
                    string toEnterpriseName = enterpriseName;
                    string toRouteName      = routeName;
                    string toStepName       = stepName;
                    if (null != dsRouteNextStep &&
                        dsRouteNextStep.Tables.Count > 0 &&
                        dsRouteNextStep.Tables[0].Rows.Count > 0)
                    {
                        DataRow drRouteNextStep = dsRouteNextStep.Tables[0].Rows[0];
                        toEnterpriseKey  = Convert.ToString(drRouteNextStep[POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]);
                        toRouteKey       = Convert.ToString(drRouteNextStep[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_ROUTE_VER_KEY]);
                        toStepKey        = Convert.ToString(drRouteNextStep[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_KEY]);
                        toEnterpriseName = Convert.ToString(drRouteNextStep[POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ENTERPRISE_NAME]);
                        toRouteName      = Convert.ToString(drRouteNextStep[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME]);
                        toStepName       = Convert.ToString(drRouteNextStep[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]);
                    }
                    //组织下一工步数据。
                    Hashtable htStepTransaction = new Hashtable();
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_EDIT_TIME, null);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_EDIT_TIMEZONE, editTimeZone);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_EDITOR, "SYSTEM");
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_KEY, enterpriseKey);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_ROUTE_KEY, routeKey);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_STEP_KEY, stepKey);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_TO_ENTERPRISE_KEY, toEnterpriseKey);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_TO_ENTERPRISE_NAME, toEnterpriseName);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_TO_ROUTE_KEY, toRouteKey);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_TO_ROUTE_NAME, toRouteName);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_TO_STEP_KEY, toStepKey);
                    htStepTransaction.Add(WIP_STEP_TRANSACTION_FIELDS.FIELD_TO_STEP_NAME, toStepName);
                    DataTable dtStepTransaction = CommonUtils.ParseToDataTable(htStepTransaction);
                    dtStepTransaction.TableName = WIP_STEP_TRANSACTION_FIELDS.DATABASE_TABLE_NAME;
                    dsParams.Tables.Add(dtStepTransaction);
                    //组织操作数据。
                    string    shiftName     = RemotingServer.ServerObjFactory.Get <IShift>().GetShiftNameBySysdate();
                    string    shiftKey      = RemotingServer.ServerObjFactory.Get <IShift>().IsExistsShift(shiftName);
                    Hashtable htTransaction = new Hashtable();
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_PIECE_KEY, lotKey);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY, ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_TRACKOUT);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_IN, drLot[POR_LOT_FIELDS.FIELD_QUANTITY]);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_OUT, drLot[POR_LOT_FIELDS.FIELD_QUANTITY]);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_KEY, enterpriseKey);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_NAME, enterpriseName);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ROUTE_KEY, routeKey);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ROUTE_NAME, routeName);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_STEP_KEY, stepKey);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_STEP_NAME, stepName);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_WORK_ORDER_KEY, drLot[POR_LOT_FIELDS.FIELD_WORK_ORDER_KEY]);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_SHIFT_KEY, shiftKey);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_SHIFT_NAME, shiftName);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_STATE_FLAG, stateFlag);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_REWORK_FLAG, drLot[POR_LOT_FIELDS.FIELD_IS_REWORKED]);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPERATOR, editor);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_COMPUTER, "SYSTEM");
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_LINE_KEY, drLot[POR_LOT_FIELDS.FIELD_CUR_PRODUCTION_LINE_KEY]);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE, drLot[POR_LOT_FIELDS.FIELD_OPR_LINE]);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EQUIPMENT_KEY, equipmentKey);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_TO_STEP_KEY, toStepKey);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE_PRE, drLot[POR_LOT_FIELDS.FIELD_OPR_LINE]);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDC_INS_KEY, drLot[POR_LOT_FIELDS.FIELD_EDC_INS_KEY]);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY_COMMENT, string.Empty);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDITOR, "SYSTEM");
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIME, null);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIMEZONE_KEY, editTimeZone);
                    htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_TIME_STAMP, null);
                    DataTable dtTransaction = CommonUtils.ParseToDataTable(htTransaction);
                    dtTransaction.TableName = WIP_TRANSACTION_FIELDS.DATABASE_TABLE_NAME;
                    dsParams.Tables.Add(dtTransaction);
                    //组织其他附加参数数据
                    Hashtable htMaindata  = new Hashtable();
                    string    lotEditTime = Convert.ToString(drLot[POR_LOT_FIELDS.FIELD_EDIT_TIME]);
                    htMaindata.Add(COMMON_FIELDS.FIELD_COMMON_EDIT_TIME, lotEditTime);
                    IRouteEngine routeEngine    = RemotingServer.ServerObjFactory.Get <IRouteEngine>();
                    DataSet      dsStepBaseData = routeEngine.GetStepBaseDataAndParamDataByKey(stepKey, 0);
                    msg = ReturnMessageUtils.GetServerReturnMessage(dsStepBaseData);
                    if (!string.IsNullOrEmpty(msg) ||
                        dsStepBaseData == null ||
                        dsStepBaseData.Tables.Count <= 0 ||
                        dsStepBaseData.Tables[0].Rows.Count <= 0)
                    {
                        ReturnMessageUtils.AddServerReturnMessage(dsReturn, msg);
                        WipManagement.RecordErrorMessage(db, "批次出站异常:获取当前工艺流程数据失败,", msg, strToUser, "EMSGOUT", editor, editTimeZone, lotKey, "LOT");
                        return(dsReturn);
                    }
                    string operationKey = Convert.ToString(dsStepBaseData.Tables[0].Rows[0][POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_OPERATION_VER_KEY]);
                    string duration     = Convert.ToString(dsStepBaseData.Tables[0].Rows[0][POR_ROUTE_STEP_FIELDS.FIELD_DURATION]);
                    string partNumber   = Convert.ToString(drLot[POR_LOT_FIELDS.FIELD_PART_NUMBER]);
                    htMaindata.Add(POR_ROUTE_OPERATION_VER_FIELDS.FIELD_ROUTE_OPERATION_VER_KEY, operationKey);
                    htMaindata.Add(POR_ROUTE_STEP_FIELDS.FIELD_DURATION, duration);
                    htMaindata.Add(POR_LOT_FIELDS.FIELD_LOT_NUMBER, drLot[POR_LOT_FIELDS.FIELD_LOT_NUMBER]);
                    htMaindata.Add(POR_LOT_FIELDS.FIELD_WORK_ORDER_NO, drLot[POR_LOT_FIELDS.FIELD_WORK_ORDER_NO]);
                    htMaindata.Add(POR_LOT_FIELDS.FIELD_PART_NUMBER, partNumber);
                    htMaindata.Add(ROUTE_OPERATION_ATTRIBUTE.IsShowSetNewRoute, false);
                    DataTable dtParams = CommonUtils.ParseToDataTable(htMaindata);
                    dtParams.TableName = TRANS_TABLES.TABLE_PARAM;
                    dsParams.Tables.Add(dtParams);
                    dsReturn = LotTrackOut(dsParams);
                    msg      = ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                    if (string.IsNullOrEmpty(msg))
                    {
                        sql = @"UPDATE WIP_JOB SET JOB_STATUS=1 WHERE ROW_KEY='" + rowKey.PreventSQLInjection() + "'";
                        db.ExecuteNonQuery(CommandType.Text, sql);
                    }
                    else
                    {
                        WipManagement.RecordErrorMessage(db, "批次出站异常", msg, strToUser, "EMSGOUT", editor, editTimeZone, lotKey, "LOT");
                    }
                }
                else
                {
                    msg = "批次" + dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_LOT_NUMBER].ToString() + "抽检未完成";
                    WipManagement.RecordErrorMessage(db, "批次出站异常", msg, strToUser, "EMSGOUT", editor, editTimeZone, lotKey, "LOT");
                    //更新WIP_JOB表。
                    sql = string.Format(@"UPDATE WIP_JOB
                                        SET JOB_NEXTRUNTIME = DATEADD(mi,5,GETDATE()),JOB_RUNACCOUNT=JOB_RUNACCOUNT +1
                                        WHERE ROW_KEY = '{0}'", rowKey.PreventSQLInjection());
                    db.ExecuteNonQuery(CommandType.Text, sql);
                }
                if (msg.Length > 0)
                {
                    msg = string.Format("批次[{0}] 自动出站失败.\n\t原因:{1}", drLot[POR_LOT_FIELDS.FIELD_LOT_NUMBER], msg);
                }
                else
                {
                    msg = string.Format("批次[{0}] 自动出站成功.", drLot[POR_LOT_FIELDS.FIELD_LOT_NUMBER]);
                }
                ReturnMessageUtils.AddServerReturnMessage(dsReturn, msg);
            }
            catch (Exception ex)
            {
                ReturnMessageUtils.AddServerReturnMessage(dsReturn, ex.Message);
                LogService.LogError("AutoTrackOut Error: " + ex.Message);
            }
            return(dsReturn);
        }
Esempio n. 16
0
        /// <summary>
        /// 批次自动过站。
        /// </summary>
        /// <param name="rowKey">WIP_JOB表主键。</param>
        /// <returns>包含自动过站执行结果的数据集。</returns>
        public DataSet AutoTrackOut(string rowKey)
        {
            EnterpriseEngine enterpriseEngine = new EnterpriseEngine();
            DataSet          dsReturn = new DataSet();
            DataSet          dsAutoActionReturn = new DataSet();
            DataSet          dsLotInfo = new DataSet();
            Hashtable        mainDataHashTable = new Hashtable();
            DataTable        mainDataTable = new DataTable();
            DataSet          dataSet = new DataSet();
            string           equipmentKey = "", enterpriseKey = "", routeKey = "", stepKey = "", lotKey = "";
            string           nextEnterpriseKey = "", nextRouteKey = "", nextStepKey = "", editor = "", editTimeZone = "";
            string           isFinished = "False", strToUser = "";
            string           msg = "", strAutoReturnMsg = "";

            try
            {
                #region 获取批次自动过站任务记录
                string sql = string.Format(@"SELECT * FROM WIP_JOB WHERE ROW_KEY='{0}'", rowKey);
                dsLotInfo = db.ExecuteDataSet(CommandType.Text, sql);
                if (dsLotInfo.Tables.Count > 0 && dsLotInfo.Tables[0].Rows.Count > 0)
                {
                    equipmentKey  = dsLotInfo.Tables[0].Rows[0][EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_KEY].ToString();
                    enterpriseKey = dsLotInfo.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_ENTERPRISE_KEY].ToString();
                    routeKey      = dsLotInfo.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_ROUTE_KEY].ToString();
                    stepKey       = dsLotInfo.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_STEP_KEY].ToString();
                    lotKey        = dsLotInfo.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_LOT_KEY].ToString();
                    editor        = dsLotInfo.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_EDITOR].ToString();
                    editTimeZone  = dsLotInfo.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_EDIT_TIMEZONE].ToString();
                    strToUser     = dsLotInfo.Tables[0].Rows[0][WIP_JOB_FIELDS.FIELDS_EDITOR].ToString();
                }
                #endregion

                #region TrackOutLot
                DataSet dsLots = GetLotsInfo(lotKey);
                if (dsLots != null && dsLots.Tables.Count > 0 && dsLots.Tables[0].Rows.Count > 0)
                {
                    string stateFage = dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_STATE_FLAG].ToString();
                    if (stateFage == "9" || stateFage == "4")
                    {
                        #region get lot detail information form por_lot
                        mainDataHashTable.Add(POR_LOT_FIELDS.FIELD_LOT_KEY, lotKey);
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_OUT, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_QUANTITY].ToString());
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_IN, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_QUANTITY].ToString());
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY, ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_TRACKOUT);
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY_COMMENT, string.Empty);
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_EDITOR, editor);
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIMEZONE_KEY, editTimeZone);
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIME, null);
                        //mainDataHashTable.Add(POR_LOT_FIELDS.FIELD_MODULE, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_MODULE].ToString());
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_LINE_KEY, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_CUR_PRODUCTION_LINE_KEY].ToString());
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_SHIFT_NAME, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_SHIFT_NAME].ToString());
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_WORK_ORDER_KEY, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_WORK_ORDER_KEY].ToString());
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_STEP_KEY, stepKey);
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_ROUTE_KEY, routeKey);
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_KEY, enterpriseKey);

                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_OPERATOR, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_OPERATOR].ToString());
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_REWORK_FLAG, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_IS_REWORKED].ToString());
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_OPR_LINE].ToString());
                        mainDataHashTable.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_COMPUTER, dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_OPR_COMPUTER].ToString());

                        #endregion

                        #region equipment information
                        if (equipmentKey != string.Empty)
                        {
                            Hashtable equHashData  = new Hashtable();
                            DataTable equDataTable = new DataTable();
                            equHashData.Add(EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_KEY, equipmentKey);
                            equDataTable           = SolarViewer.Hemera.Share.Common.CommonUtils.ParseToDataTable(equHashData);
                            equDataTable.TableName = EMS_EQUIPMENTS_FIELDS.DATABASE_TABLE_NAME;
                            dataSet.Tables.Add(equDataTable);
                        }
                        #endregion

                        #region get next route and step
                        if (enterpriseKey != string.Empty && routeKey != string.Empty && stepKey != string.Empty)
                        {
                            Hashtable hashTable   = new Hashtable();
                            DataTable dataTable   = new DataTable();
                            DataSet   dsOperation = new DataSet();
                            hashTable.Add("ROUTE_ENTERPRISE_VER_KEY", enterpriseKey);
                            hashTable.Add("ROUTE_ROUTE_VER_KEY", routeKey);
                            hashTable.Add("ROUTE_STEP_KEY", stepKey);
                            dataTable = SolarViewer.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
                            dsOperation.Tables.Add(dataTable);
                            DataSet dsReturnOperation = enterpriseEngine.GetEnterpriseNextRouteAndStep(dsOperation);
                            string  errorMsg          = ReturnMessageUtils.GetServerReturnMessage(dsReturnOperation);
                            if (!string.IsNullOrEmpty(errorMsg))
                            {
                                SolarViewer.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(dsAutoActionReturn, errorMsg);
                                RecordErrorMessage("批次出站异常:获取下一工艺流程失败,", errorMsg, strToUser, "EMSGOUT", editor, editTimeZone, lotKey, "LOT");
                                return(dsAutoActionReturn);
                            }
                            else
                            {
                                if (null == dsReturnOperation ||
                                    dsReturnOperation.Tables.Count == 0 ||
                                    dsReturnOperation.Tables[0].Rows.Count == 0)
                                {
                                    nextEnterpriseKey = enterpriseKey;
                                    nextRouteKey      = routeKey;
                                    nextStepKey       = stepKey;
                                    isFinished        = "True";
                                }
                                else
                                {
                                    if (dsReturnOperation.Tables.Count > 0 && dsReturnOperation.Tables.Contains(POR_ROUTE_STEP_FIELDS.DATABASE_TABLE_NAME))
                                    {
                                        DataTable dtRouteStep = dsReturnOperation.Tables[POR_ROUTE_STEP_FIELDS.DATABASE_TABLE_NAME];
                                        if (dtRouteStep.Rows.Count > 0)
                                        {
                                            nextStepKey       = dtRouteStep.Rows[0][POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_KEY].ToString();
                                            nextRouteKey      = dtRouteStep.Rows[0][POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_ROUTE_VER_KEY].ToString();
                                            nextEnterpriseKey = dtRouteStep.Rows[0][POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY].ToString();
                                        }
                                    }
                                }
                            }
                            mainDataHashTable.Add(WIP_FIELDS.FIELDS_TO_ROUTE_VER_KEY, nextRouteKey);
                            mainDataHashTable.Add(WIP_FIELDS.FIELDS_TO_STEP_VER_KEY, nextStepKey);
                            mainDataHashTable.Add(WIP_FIELDS.FIELDS_TO_ENTERPRISE_VER_KEY, nextEnterpriseKey);

                            mainDataHashTable.Add("LAST_STEP", isFinished);
                            //mainDataHashTable.Add(POR_LOT_FIELDS.FIELD_QUANTITY_REWORK, "0");
                        }
                        #endregion

                        #region 执行出站操作
                        mainDataTable.TableName = TRANS_TABLES.TABLE_PARAM;
                        mainDataTable           = SolarViewer.Hemera.Share.Common.CommonUtils.ParseToDataTable(mainDataHashTable);
                        dataSet.Tables.Add(mainDataTable);
                        dsReturn = TrackOutLot(dataSet);
                        msg      = SolarViewer.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                        if (msg == string.Empty)
                        {
                            string strSql = @"UPDATE WIP_JOB SET JOB_STATUS=1 WHERE ROW_KEY='" + rowKey.PreventSQLInjection() + "'";
                            db.ExecuteNonQuery(CommandType.Text, strSql);
                        }
                        else
                        {
                            //throw new Exception(msg);
                            RecordErrorMessage("批次出站异常", msg, strToUser, "EMSGOUT", editor, editTimeZone, lotKey, "LOT");
                        }

                        #endregion
                    }
                    else
                    {
                        string content = "批次" + dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_LOT_NUMBER].ToString() + "抽检未完成";
                        msg = content;
                        RecordErrorMessage("批次出站异常", content, strToUser, "EMSGOUT", editor, editTimeZone, lotKey, "LOT");
                        //update wip_job
                        sql = string.Format(@"UPDATE WIP_JOB
                                            SET JOB_NEXTRUNTIME = DATEADD(mi,5,GETDATE()),JOB_RUNACCOUNT=JOB_RUNACCOUNT +1
                                            WHERE ROW_KEY = '{0}'", rowKey.PreventSQLInjection());
                        db.ExecuteNonQuery(CommandType.Text, sql);
                    }
                    if (msg.Length > 0)
                    {
                        strAutoReturnMsg = "批次[" + dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_LOT_NUMBER].ToString() + "] 自动出站失败.\n\t" +
                                           "原因:" + msg;
                    }
                    else
                    {
                        strAutoReturnMsg = "批次[" + dsLots.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_LOT_NUMBER].ToString() + "] 自动出站成功.";
                    }
                    SolarViewer.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(dsAutoActionReturn, strAutoReturnMsg);
                }

                #endregion
            }
            catch (Exception ex)
            {
                strAutoReturnMsg = "批次自动出站失败.\n\t" +
                                   "原因:" + ex.Message;
                SolarViewer.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(dsAutoActionReturn, strAutoReturnMsg);

                LogService.LogError("AutoTrackOutLot Error: " + ex.Message);
                //inser wip message
                RecordErrorMessage("自动出站异常", ex.Message, strToUser, "EMSGOUT", editor, editTimeZone, lotKey, "JOB");
            }
            return(dsAutoActionReturn);
        }