Example #1
0
        /// <summary>
        /// 新增用餐記錄
        /// </summary>
        /// <param name="model">model</param>
        /// <param name="tran">SqlTransaction</param>
        /// <returns></returns>
        public bool AddDinnerRecord(DinnerRecord model, SqlTransaction tran)
        {
            try
            {
                MappingHelper.HandleNullProperty(model);

                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into DinnerRecord_dnr(");
                strSql.Append("dnr_RecordID,dnr_DSMID,dnr_dDate,dnr_dBeginTime,dnr_dEndTime,dnr_lIsAuto,dnr_cMachineID,dsm_sstID,dsm_swlID,dsm_ppjID,dsm_splID,dsm_psrdID,dsm_cProjectStatus,dnr_cAdd,dnr_dAddDate,dnr_cLast,dnr_dLastDate,dnr_lsync)");
                strSql.Append(" values (");
                strSql.Append("@dnr_RecordID,@dnr_DSMID,@dnr_dDate,@dnr_dBeginTime,@dnr_dEndTime,@dnr_lIsAuto,@dnr_cMachineID,@dsm_sstID,@dsm_swlID,@dsm_ppjID,@dsm_splID,@dsm_psrdID,@dsm_cProjectStatus,@dnr_cAdd,@dnr_dAddDate,@dnr_cLast,@dnr_dLastDate,@dnr_lsync)");
                SqlParameter[] parameters = {
                    DbHelperSQL.MakeInParam("@dnr_RecordID", SqlDbType.UniqueIdentifier,16, model.RecordID),
                    DbHelperSQL.MakeInParam("@dnr_DSMID", SqlDbType.UniqueIdentifier,16, model.dnr_DSMID),
                    DbHelperSQL.MakeInParam("@dnr_dDate", SqlDbType.DateTime, 0, model.dnr_dDate),
                    DbHelperSQL.MakeInParam("@dnr_dBeginTime", SqlDbType.DateTime, 0, model.dnr_dBeginTime),
                    DbHelperSQL.MakeInParam("@dnr_dEndTime", SqlDbType.DateTime, 0, model.dnr_dEndTime),
                    DbHelperSQL.MakeInParam("@dnr_lIsAuto", SqlDbType.Bit,1, model.dnr_lIsAuto),
                    DbHelperSQL.MakeInParam("@dnr_cMachineID", SqlDbType.NVarChar,20, model.dnr_cMachineID),
                    DbHelperSQL.MakeInParam("@dsm_sstID", SqlDbType.UniqueIdentifier,16, model.dsm_sstID),
                    DbHelperSQL.MakeInParam("@dsm_swlID", SqlDbType.UniqueIdentifier,16, model.dsm_swlID),
                    DbHelperSQL.MakeInParam("@dsm_ppjID", SqlDbType.UniqueIdentifier,16, model.dsm_ppjID),
                    DbHelperSQL.MakeInParam("@dsm_splID", SqlDbType.UniqueIdentifier,16, model.dsm_splID),
                    DbHelperSQL.MakeInParam("@dsm_psrdID", SqlDbType.UniqueIdentifier,16, model.dsm_psrdID),
                    DbHelperSQL.MakeInParam("@dsm_cProjectStatus", SqlDbType.NVarChar,20, model.dsm_cProjectStatus),
                    DbHelperSQL.MakeInParam("@dnr_cAdd", SqlDbType.NVarChar,20, model.AddUser),
                    DbHelperSQL.MakeInParam("@dnr_dAddDate", SqlDbType.DateTime, 0, model.AddDate),
                    DbHelperSQL.MakeInParam("@dnr_cLast", SqlDbType.NVarChar,20, model.LastUser),
                    DbHelperSQL.MakeInParam("@dnr_dLastDate", SqlDbType.DateTime, 0, model.LastDate),
                    DbHelperSQL.MakeInParam("@dnr_lsync", SqlDbType.Bit,1, 0)};//model.dnr_lsync;

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

                return true;
            }
            catch (Exception ex) { throw ex; }
        }
Example #2
0
        /// <summary>
        /// 对象实体绑定数据(DinnerRecord)
        /// </summary>
        private DinnerRecord ReaderBind_DNR(IDataReader dataReader)
        {
            DinnerRecord model = new DinnerRecord();

            object ojb;
            ojb = dataReader["dnr_RecordID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RecordID = new Guid(ojb.ToString());
            }
            ojb = dataReader["dnr_DSMID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dnr_DSMID = new Guid(ojb.ToString());
            }
            ojb = dataReader["dnr_dDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dnr_dDate = (DateTime)ojb;
            }
            ojb = dataReader["dnr_dBeginTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dnr_dBeginTime = (DateTime)ojb;
            }
            ojb = dataReader["dnr_dEndTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dnr_dEndTime = (DateTime)ojb;
            }
            ojb = dataReader["dnr_lIsAuto"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dnr_lIsAuto = (bool)ojb;
            }
            model.dnr_cMachineID = dataReader["dnr_cMachineID"].ToString();
            ojb = dataReader["dsm_sstID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dsm_sstID = new Guid(ojb.ToString());
            }
            ojb = dataReader["dsm_swlID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dsm_swlID = new Guid(ojb.ToString());
            }
            ojb = dataReader["dsm_ppjID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dsm_ppjID = new Guid(ojb.ToString());
            }
            ojb = dataReader["dsm_splID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dsm_splID = new Guid(ojb.ToString());
            }
            ojb = dataReader["dsm_psrdID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.dsm_psrdID = new Guid(ojb.ToString());
            }
            model.dsm_cProjectStatus = dataReader["dsm_cProjectStatus"].ToString();
            model.AddUser = dataReader["dnr_cAdd"].ToString();
            ojb = dataReader["dnr_dAddDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AddDate = (DateTime)ojb;
            }
            model.LastUser = dataReader["dnr_cLast"].ToString();
            ojb = dataReader["dnr_dLastDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.LastDate = (DateTime)ojb;
            }
            ojb = dataReader["dnr_lsync"];
            if (ojb != null && ojb != DBNull.Value)
            {
                //model.dnr_lsync = (bool)ojb;
            }

            return model;
        }
Example #3
0
        void m_tmrAutoCheckDinner_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (this.m_blnIsRunningChkDinner)
            {
                return;
            }
            this.m_blnIsRunningChkDinner = true;

            try
            {
                if (base.MachineShiftInfo != null)//班次信息
                {
                    //根據現有班次信息創建所有用餐記錄
                    if (this.m_listInUseDinnerPlan != null && base.DinnerRecords != null)//已選取可用的用餐計劃主檔信息,同時生成了對應的當班次用餐記錄
                    {
                        //檢測用餐時間的開始和結束
                        if (this.m_InUseDinnerRec != null)//已存在當前使用中的用餐記錄
                        {
                            #region 判斷用餐是否需要結束

                            if (DateTime.Now > this.m_InUseDinnerRec.dnr_dEndTime.Value)//是否已到達結束時間
                            {
                                base.OnDinnerStatusChange(null);
                                this.m_InUseDinnerRec = null;
                            }

                            #endregion
                        }
                        else
                        {
                            #region 找出時段內的用餐記錄,用餐開始

                            //還未有當前在用的用餐記錄,在已經生成的當班次的用餐記錄列表中尋找
                            foreach (DinnerRecord itemDinner in base.DinnerRecords)
                            {
                                if (itemDinner.dnr_dBeginTime.Value <= DateTime.Now && itemDinner.dnr_dEndTime.Value >= DateTime.Now)
                                {
                                    if (this.m_InUseDinnerRec == null)
                                    {
                                        //當前使用的用餐記錄為空,則代表[正常啟動]或[異常重啟]
                                        this.m_InUseDinnerRec = itemDinner;
                                        base.OnDinnerStatusChange(itemDinner);
                                        string dinnerTitle = GetDinnerTitle(itemDinner);
                                        base.OnDinnerInformation(dinnerTitle);

                                        break;
                                    }
                                }
                            }

                            #endregion
                        }
                    }
                    else
                    {
                        #region 在用餐計劃主檔信息中抽取出可用的部分,並生成對應的當班次用餐記錄

                        //沒有現有可用的用餐計劃,則需要重新生成
                        if (base.DinnerPlanInfos != null && base.DinnerPlanInfos.Count > 0)
                        {
                            List<DinnerPlanInfo> listCanUseDinnerPlan = GetCanUseDinnerPlan();
                            if (listCanUseDinnerPlan != null)
                            {
                                this.m_listInUseDinnerPlan = listCanUseDinnerPlan;

                                bool isCreateNewDinnerRecord = false;

                                if (base.DinnerRecords != null & base.DinnerRecords.Count == 0)
                                {
                                    isCreateNewDinnerRecord = true;
                                }

                                foreach (DinnerPlanInfo itemPlan in listCanUseDinnerPlan)
                                {
                                    DinnerRecord dinnerRec = CreateDinnerRecord(itemPlan);

                                    if (dinnerRec != null)
                                    {
                                        if (isCreateNewDinnerRecord)
                                        {
                                            base.DinnerRecords.Add(dinnerRec);
                                        }
                                    }
                                }
                            }
                        }

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                base.OnException("DinnerControler", "m_tmrAutoCheckDinner_Elapsed", ex.Message);
            }

            this.m_blnIsRunningChkDinner = false;
        }
Example #4
0
 void InitParams()
 {
     this.m_blnIsRunningChkDinner = false;
     this.m_listInUseDinnerPlan = null;
     this.m_InUseDinnerRec = null;
 }
Example #5
0
        /// <summary>
        /// 獲取用餐顯示信息
        /// </summary>
        /// <param name="dinnerRecord">用餐記錄對象</param>
        /// <returns></returns>
        string GetDinnerTitle(DinnerRecord dinnerRecord)
        {
            string title = "就餐";

            if (dinnerRecord != null)
            {
                if (dinnerRecord.dnr_dDate != null && dinnerRecord.dnr_dBeginTime != null && dinnerRecord.dnr_dEndTime != null)
                {
                    title = dinnerRecord.dnr_dDate.Value.ToString(GlobalVar.DFormat) + " " + dinnerRecord.DinnerName + " [" + dinnerRecord.dnr_dBeginTime.Value.ToString(GlobalVar.TFormat) + "-" + dinnerRecord.dnr_dEndTime.Value.ToString(GlobalVar.TFormat) + "]";
                }
            }

            return title;
        }
Example #6
0
        /// <summary>
        /// 創建用餐記錄
        /// </summary>
        /// <param name="itemPlan">用餐計劃</param>
        /// <returns></returns>
        DinnerRecord CreateDinnerRecord(DinnerPlanInfo itemPlan)
        {
            if (itemPlan == null)
            {
                return null;
            }

            DateTime? beginTime = null;
            DateTime? endTime = null;

            DinnerRecord dinnerRec = new DinnerRecord();

            dinnerRec.RecordID = Guid.NewGuid();
            dinnerRec.AddDate = DateTime.Now;
            dinnerRec.LastDate = DateTime.Now;
            dinnerRec.DinnerName = itemPlan.Description.Trim();
            dinnerRec.dnr_cMachineID = base.MachineID.Trim();

            beginTime = DateTime.Parse(itemPlan.BeginTime.Trim());

            dinnerRec.dnr_dBeginTime = beginTime;

            endTime = DateTime.Parse(itemPlan.EndTime.Trim());

            if (endTime < beginTime)
            {
                dinnerRec.dnr_dEndTime = endTime.Value.AddDays(1);
            }
            else
            {
                dinnerRec.dnr_dEndTime = endTime;
            }

            if (itemPlan.IsOverDay)
            {
                dinnerRec.dnr_dBeginTime = dinnerRec.dnr_dBeginTime.Value.AddDays(1);
                dinnerRec.dnr_dEndTime = dinnerRec.dnr_dEndTime.Value.AddDays(1);
            }

            if (itemPlan.IsThePreviousDay)
            {
                dinnerRec.dnr_dBeginTime = dinnerRec.dnr_dBeginTime.Value.AddDays(-1);
                dinnerRec.dnr_dEndTime = dinnerRec.dnr_dEndTime.Value.AddDays(-1);
            }

            dinnerRec.dnr_dDate = dinnerRec.dnr_dBeginTime.Value.Date;

            dinnerRec.dnr_DSMID = new Guid(itemPlan.Code.Trim());
            dinnerRec.dnr_lIsAuto = true;

            return dinnerRec;
        }
Example #7
0
 /// <summary>
 /// 模塊重置
 /// </summary>
 public override void Reset()
 {
     this.m_blnIsRunningChkDinner = false;
     this.m_InUseDinnerRec = null;
     this.m_listInUseDinnerPlan = null;
 }