Ejemplo n.º 1
0
        /// <summary>
        /// 更新空閒記錄的狀態
        /// </summary>
        /// <param name="info"></param>
        /// <returns>true/false</returns>
        public override bool UpdateMachineSpareStatus(MachineSpareStatus info)
        {
            try
            {

                MachineSpareStatus updateInfo = this.GetMachineSpareStatusInfoByKey(info.RecordID);
                if (updateInfo != null)
                {
                    updateInfo.LastDate = DateTime.Now;
                    updateInfo.sst_StatusID = info.sst_StatusID;
                    updateInfo.sst_cStatusName = info.sst_cStatusName;

                    //updateInfo.RecordEditStatus = 2;
                    this.OnProductionChanged(updateInfo);
                    this.OnProductionDataUpdate();
                }
                else
                {
                    Exception newEx = new Exception("找不到空闲记录要结束");
                    this.OnException(newEx);
                    throw newEx;
                }

                return true;
            }
            catch (Exception ex) { this.OnException(mc_strClassName, "UpdateMachineSpareStatus", ex.Message); throw; }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 新增機台空閒狀態記錄(SST)
        /// </summary>
        /// <param name="model">model</param>
        /// <param name="tran">SqlTransaction</param>
        /// <returns></returns>
        public bool AddMachineSpareStatus(MachineSpareStatus model, SqlTransaction tran)
        {
            try
            {
                MappingHelper.HandleNullProperty(model);

                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into SpareStatus_sst(");
                strSql.Append("sst_RecordID,sst_iSIFOID,sst_cMachineNO,sst_StatusID,sst_cStatusName,sst_dBeginTime,sst_dEndTime,sst_lSync,sst_dAddDate,sst_dLastDate,sst_iTime)");
                strSql.Append(" values (");
                strSql.Append("@sst_RecordID,@sst_iSIFOID,@sst_cMachineNO,@sst_StatusID,@sst_cStatusName,@sst_dBeginTime,@sst_dEndTime,@sst_lSync,@sst_dAddDate,@sst_dLastDate,@sst_iTime)");
                SqlParameter[] parameters = {
                    DbHelperSQL.MakeInParam("@sst_RecordID", SqlDbType.UniqueIdentifier,16, model.RecordID),
                    DbHelperSQL.MakeInParam("@sst_iSIFOID", SqlDbType.UniqueIdentifier,16, model.sst_iSIFOID),
                    DbHelperSQL.MakeInParam("@sst_cMachineNO", SqlDbType.NVarChar,20, model.sst_cMachineNO),
                    DbHelperSQL.MakeInParam("@sst_StatusID", SqlDbType.UniqueIdentifier,16, model.sst_StatusID),
                    DbHelperSQL.MakeInParam("@sst_cStatusName", SqlDbType.NVarChar,100, model.sst_cStatusName),
                    DbHelperSQL.MakeInParam("@sst_dBeginTime", SqlDbType.DateTime, 0, model.sst_dBeginTime),
                    DbHelperSQL.MakeInParam("@sst_dEndTime", SqlDbType.DateTime, 0, model.sst_dEndTime),
                    DbHelperSQL.MakeInParam("@sst_lSync", SqlDbType.Bit,1, 0),//model.sst_lSync;
                    DbHelperSQL.MakeInParam("@sst_dAddDate", SqlDbType.DateTime, 0, model.AddDate),
                    DbHelperSQL.MakeInParam("@sst_dLastDate", SqlDbType.DateTime, 0, model.LastDate),
                    DbHelperSQL.MakeInParam("@sst_iTime", SqlDbType.Int,4, model.sst_iTime)};

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

                return true;
            }
            catch (Exception ex) { throw ex; }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 機台空閒記錄開始
        /// </summary>
        public override void SpareStart(DateTime dBeginDt)
        {
            try
            {
                //判斷是否需要創建記錄
                bool l_lIsCreated = false;
                if (this.SpareStatusRecords == null || this.SpareStatusRecords.Count == 0) //記錄集完全沒數據,需要創建
                    l_lIsCreated = true;
                else
                {
                    //存在沒結束時間的記錄,不需要創建
                    if (! this.IsFindNotEndTimeRecord())
                        l_lIsCreated = true;
                }

                if (!l_lIsCreated) return;

                MachineSpareStatus info = new MachineSpareStatus();
                info.RecordID = Guid.NewGuid();
                info.sst_iSIFOID = this.SIFOID;
                info.sst_cMachineNO = this.MachineID;

                MachineIdleStateName defaultStatusInfo = null;
                if (this.MachineIdleStateNames != null)
                    defaultStatusInfo = this.MachineIdleStateNames.FirstOrDefault(p => p.IsBuildin == true);
                if (defaultStatusInfo != null)
                {
                    info.sst_StatusID = new Guid(defaultStatusInfo.Code);
                    info.sst_cStatusName = defaultStatusInfo.Description;
                }
                info.sst_dBeginTime = dBeginDt;
                info.AddDate = dBeginDt;

                //info.RecordEditStatus = 1;
                this.CurrentSpareStatusRecord = info;
                this.SpareStatusRecords.Add(info);

                this.OnProductionChanged(info);
                this.OnProductionDataUpdate();
            }
            catch (Exception ex) { this.OnException(mc_strClassName, "SpareStart", ex.Message); }
        }