Пример #1
0
        public override void MaintainRecordCreate(MaintainRecordView maintainInfo)
        {
            if (maintainInfo == null)
            {
                return;
            }

            if (this.MachineMaintainRecords != null)
            {
                MachineMaintainRecord recordInfo = new MachineMaintainRecord();

                recordInfo.RecordID = System.Guid.NewGuid();
                recordInfo.AddDate = DateTime.Now;
                recordInfo.LastDate = DateTime.Now;
                recordInfo.mtr_cDescription = maintainInfo.Description;
                recordInfo.mtr_cRemark = maintainInfo.Remark;
                recordInfo.mtr_MOMID = maintainInfo.OperationCode;
                recordInfo.mtr_cMachineID = this.MachineID;
                recordInfo.RecordEditStatus = 1;

                this.MachineMaintainRecords.Add(recordInfo);

                this.OnProductionChanged(recordInfo);
            }

            this.SetMaintainRecordViews();
            this.OnProductionDataUpdate();
        }
Пример #2
0
        /// <summary>
        /// 新增機台保養
        /// </summary>
        /// <param name="model">model</param>
        /// <param name="tran">SqlTransaction</param>
        /// <returns></returns>
        public bool AddMachineMaintainRecord(MachineMaintainRecord model, SqlTransaction tran)
        {
            try
            {
                MappingHelper.HandleNullProperty(model);

                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into MaintainRecord_mtr(");
                strSql.Append("mtr_RecordID,mtr_cMachineID,mtr_iPlanID,mtr_MOMID,mtr_cDescription,mtr_cRemark,mtr_dBeginTime,mtr_dEndTime,mtr_cStatus,mtr_lDeleted,mtr_dAddDate,mtr_dLastDate,mtr_lSync)");
                strSql.Append(" values (");
                strSql.Append("@mtr_RecordID,@mtr_cMachineID,@mtr_iPlanID,@mtr_MOMID,@mtr_cDescription,@mtr_cRemark,@mtr_dBeginTime,@mtr_dEndTime,@mtr_cStatus,@mtr_lDeleted,@mtr_dAddDate,@mtr_dLastDate,@mtr_lSync)");
                SqlParameter[] parameters = {
                    DbHelperSQL.MakeInParam("@mtr_RecordID", SqlDbType.UniqueIdentifier,16, model.RecordID),
                    DbHelperSQL.MakeInParam("@mtr_cMachineID", SqlDbType.NVarChar,20, model.mtr_cMachineID),
                    DbHelperSQL.MakeInParam("@mtr_iPlanID", SqlDbType.Int,4, model.mtr_iPlanID),
                    DbHelperSQL.MakeInParam("@mtr_MOMID", SqlDbType.Int,4, model.mtr_MOMID),
                    DbHelperSQL.MakeInParam("@mtr_cDescription", SqlDbType.NVarChar,200, model.mtr_cDescription),
                    DbHelperSQL.MakeInParam("@mtr_cRemark", SqlDbType.NVarChar,500, model.mtr_cRemark),
                    DbHelperSQL.MakeInParam("@mtr_dBeginTime", SqlDbType.DateTime, 0, model.mtr_dBeginTime),
                    DbHelperSQL.MakeInParam("@mtr_dEndTime", SqlDbType.DateTime, 0, model.mtr_dEndTime),
                    DbHelperSQL.MakeInParam("@mtr_cStatus", SqlDbType.Int,4, model.mtr_cStatus),
                    DbHelperSQL.MakeInParam("@mtr_lDeleted", SqlDbType.Bit,1, 0),//model.mtr_lDeleted;
                    DbHelperSQL.MakeInParam("@mtr_dAddDate", SqlDbType.DateTime, 0, model.AddDate),
                    DbHelperSQL.MakeInParam("@mtr_dLastDate", SqlDbType.DateTime, 0, model.LastDate),
                    DbHelperSQL.MakeInParam("@mtr_lSync", SqlDbType.Bit,1, 0)};//model.mtr_lSync;

                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, strSql.ToString(), parameters);

                return true;
            }
            catch (Exception ex) { throw ex; }
        }
Пример #3
0
        /// <summary>
        /// 創建計劃性的保養記錄
        /// </summary>
        private void CreatePlanMaintainRecords()
        {
            if (this.MachineMaintainPlanInfos == null)
            {
                return;
            }

            if (this.MachineMaintainRecords == null)
            {
                return;
            }

            this.MachineMaintainRecords.Clear();

            for (int i = 0; i < this.MachineMaintainPlanInfos.Count;i++)
            {
                MachineMaintainPlanInfo plan = this.MachineMaintainPlanInfos[i];

                if (CheckTodayPlan(plan))
                {
                    MachineMaintainRecord mtr = new MachineMaintainRecord();
                    mtr.RecordID = Guid.NewGuid();
                    mtr.mtr_cMachineID = this.MachineID;
                    mtr.AddDate = DateTime.Now;
                    mtr.LastDate = DateTime.Now;
                    mtr.mtr_iPlanID =Convert.ToInt32(plan.Code);
                    mtr.OperationName = plan.Description;
                    mtr.mtr_MOMID = plan.MaintainOperationID;
                    mtr.mtr_cStatus = 0;
                    mtr.RecordEditStatus = 1;

                    if (this.MachineMaintainOperationList != null && this.MachineMaintainOperationList.Count > 0)
                    {
                        MachineMaintainOperation operation = this.MachineMaintainOperationList.SingleOrDefault(t => t.RecordID == plan.MaintainOperationID);
                        if (operation != null)
                        {
                            mtr.OperationCode = operation.Code;
                            mtr.OperationType = operation.OperationType;
                            mtr.OperationCompleteTime = operation.CompleteTime;
                            mtr.StandardFilePath = operation.StandardFilePath;
                        }
                    }

                    mtr.MachineMaintainOperationEquipments = this.GetMachineMaintainOperationEquipments(plan.MaintainOperationID);

                    this.MachineMaintainRecords.Add(mtr);
                    this.OnProductionChanged(mtr);
                }

            }
        }
Пример #4
0
        /// <summary>
        /// 保存保存部件清单
        /// </summary>
        /// <param name="p_objMOMInfo"></param>
        /// <param name="p_objMaintainInfo"></param>
        /// <param name="p_lisEquipments"></param>
        /// <returns></returns>
        /// <remarks>(NO:0005078) Add By Leothlink TonyWu On 07/18/2014</remarks>
        public static bool SaveMaintainEquipments(MachineMaintainRecord machineMaintainRecord)
        {
            if (machineMaintainRecord == null)
            {
                return true;
            }

            List<MaintainOperation> l_lisInsert = new List<MaintainOperation>();

            try
            {
                if (machineMaintainRecord.MachineMaintainOperationEquipments!=null && machineMaintainRecord.MachineMaintainOperationEquipments.Count > 0)
                {
                    foreach (var l_objEquipment in machineMaintainRecord.MachineMaintainOperationEquipments)
                    {
                        MaintainOperation l_objItem = new MaintainOperation()
                        {
                            AddBy = l_objEquipment.mpe_cAddBy,
                            AddTime = DateTime.Now,
                            Duration = machineMaintainRecord.OperationCompleteTime.ToString(),
                            EndTime = machineMaintainRecord.mtr_dEndTime,
                            EquipNumber = l_objEquipment.mpe_cEquipmentNum,
                            IsActive = true,
                            OperationCode = machineMaintainRecord.OperationCode,
                            OperationName = machineMaintainRecord.OperationName,
                            OperationType = machineMaintainRecord.OperationType,
                            ParentEquipNumber = l_objEquipment.mpe_cPreEquipmentNum,
                            RecordId = l_objEquipment.mpe_cRecordID,
                            StandardFile = machineMaintainRecord.StandardFilePath,
                            StartTime = machineMaintainRecord.mtr_dBeginTime,
                            MtrId = machineMaintainRecord.RecordID,
                            MtrPlanId = machineMaintainRecord.mtr_iPlanID == null ? 0 : machineMaintainRecord.mtr_iPlanID
                        };

                        l_lisInsert.Add(l_objItem);
                    }
                }
                else
                {
                    MaintainOperation l_objItem = new MaintainOperation()
                    {
                        AddBy = "SYSTEM",
                        AddTime = DateTime.Now,
                        Duration = machineMaintainRecord.OperationCompleteTime.ToString(),
                        EndTime = machineMaintainRecord.mtr_dEndTime,
                        EquipNumber = "",
                        IsActive = true,
                        OperationCode = machineMaintainRecord.OperationCode,
                        OperationName = machineMaintainRecord.OperationName,
                        OperationType = machineMaintainRecord.OperationType,
                        ParentEquipNumber = "",
                        RecordId = Guid.Empty,
                        StandardFile = machineMaintainRecord.StandardFilePath,
                        StartTime = machineMaintainRecord.mtr_dBeginTime,
                        MtrId = machineMaintainRecord.RecordID,
                        MtrPlanId = machineMaintainRecord.mtr_iPlanID == null ? 0 : machineMaintainRecord.mtr_iPlanID
                    };

                    l_lisInsert.Add(l_objItem);
                }

                _MaximoServiceWS.SaveMaintainList(machineMaintainRecord.RecordID, l_lisInsert.ToArray());

                return true;
            }
            catch
            {
                return false;
            }
        }
Пример #5
0
        /// <summary>
        ///  “機台保養”記錄信息數據上傳到服務器數據庫中
        /// </summary>
        /// <param name="machineMaintainRecord">機台保養</param>
        /// <returns></returns>
        public bool SynFirstMaintainRecordToDB(MachineMaintainRecord machineMaintainRecord)
        {
            try
            {
                bool l_lIsSuess = false;

                using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
                {
                    SqlTransaction transaction = null;

                    conn.Open(); //開啟連接
                    transaction = conn.BeginTransaction(); //開啟事務

                    try
                    {
                        //★通過判斷記錄的“記錄編輯狀態”(RecordEditStatus :Insert = 1,Update = 2,Delete = 4)來對記錄進行同步
                        if (machineMaintainRecord != null)
                        {
                            if (machineMaintainRecord.RecordEditStatus == 1)
                            {
                                this.m_objProductionDataSynDAL.AddMachineMaintainRecord(machineMaintainRecord, transaction);
                            }
                            else if (machineMaintainRecord.RecordEditStatus == 2)
                            {
                                this.m_objProductionDataSynDAL.UpdateMachineMaintainRecord(machineMaintainRecord, transaction);
                            }
                            else if (machineMaintainRecord.RecordEditStatus == 4)
                            {
                                this.m_objProductionDataSynDAL.DeleteMachineMaintainRecord_ByID(machineMaintainRecord.RecordID, transaction);
                            }

                        }

                        l_lIsSuess = true;
                    }
                    catch (Exception exTran)
                    {
                        l_lIsSuess = false;
                        throw exTran;
                    }
                    finally
                    {
                        if (l_lIsSuess)
                            transaction.Commit();
                        else
                            transaction.Rollback();
                    }

                    return true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 /// <summary>
 /// 新增一條機台保養記錄數據對象
 /// </summary>
 public override void AddMaintainRecord(MachineMaintainRecord MaintainRecord)
 {
     try
     {
         if (MaintainRecord == null)
         {
             return;
         }
         if (this.m_queueMachineMaintain == null)
         {
             this.m_queueMachineMaintain = new Queue<MachineMaintainRecord>();
         }
         this.m_queueMachineMaintain.Enqueue(MaintainRecord);
     }
     catch (Exception ex)
     {
         base.OnException(mc_strControllerName, "AddMaintainRecord", ex.Message);
     }
 }
 /// <summary>
 /// 新增一條機台保養記錄數據對象
 /// </summary>
 /// <param name="RealTimeData"></param>
 public abstract void AddMaintainRecord(MachineMaintainRecord MaintainRecord);