コード例 #1
0
        /// <summary>
        /// 值班人員簽核
        /// </summary>
        /// <param name="CheckSNs">日常檢核件編號集合</param>
        /// <param name="CheckIDs">機房檢核項目ID集合</param>
        /// <param name="CheckDate">檢核日期</param>
        /// <param name="Shift">班別</param>
        /// <param name="SignedDatas">簽章值集合</param>
        /// <returns></returns>
        public string Confirm(string[] CheckSNs, int[] CheckIDs,
                              string CheckDate, string Shift,
                              string[] SignedDatas)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Process";
            SL.Action        = "Confirm";
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            try
            {
                int i = 0;
                foreach (var item in CheckSNs)
                {
                    //取得CHECKPROCESS物件
                    CHECKPROCESS CP = context.CHECKPROCESSES.Find(item);

                    if (CP != null)
                    {
                        //update CHECKPROCESSES
                        EPSUSER U = context.EPSUSERS.Find(Session["UserID"].ToString().Trim());

                        switch (Shift)
                        {
                        //早班
                        case "01":
                            CP.ShiftOne     = U.UserName;
                            CP.ShiftOneSign = SignedDatas[i];
                            CP.CloseStutus  = "早班檢核完畢";
                            break;

                        //晚班
                        case "03":
                            CP.ShiftThree     = U.UserName;
                            CP.ShiftThreeSign = SignedDatas[i];
                            CP.CloseStutus    = "晚班檢核完畢";
                            break;

                        //假日班
                        case "04":
                            CP.ShiftFour     = U.UserName;
                            CP.ShiftFourSign = SignedDatas[i];
                            CP.CloseStutus   = "假日班檢核完畢";
                            break;
                        }

                        CP.UpadteAccount        = Session["UserID"].ToString().Trim();
                        CP.UpdateTime           = DateTime.Now;
                        context.Entry(CP).State = EntityState.Modified;
                        context.SaveChanges();

                        string     CheckTitle = "";
                        CHECKTITLE CT         = context.CHECKTITLES.Find(CheckIDs[i]);
                        if (CT != null)
                        {
                            CheckTitle = CT.Title;
                        }

                        //更新覆核表單
                        var query = context.REVIEWDATAS.Where(b => b.CheckDate == CheckDate);
                        if (query.Count() > 0)
                        {
                            foreach (var q in query.ToList())
                            {
                                if (q.ListName == "事件描述及行動" || q.ListName == "交接事項")
                                {
                                    if (Shift == "01")
                                    {
                                        q.ShiftOneChecked = "";
                                    }
                                    else if (Shift == "03")
                                    {
                                        q.ShiftTrheeChecked = "";
                                    }
                                    else if (Shift == "04")
                                    {
                                        q.ShiftFourChecked = "";
                                    }
                                }
                                else
                                {
                                    var query01 = context.CHECKLISTS.Where(b => b.ShiftID == Shift)
                                                  .Where(b => b.ListName == q.ListName);

                                    if (query01.Count() > 0)
                                    {
                                        if (Shift == "01")
                                        {
                                            if (getCheckReuslt(CheckDate, Shift, q.ListName))
                                            {
                                                q.ShiftOneChecked = "正常";
                                            }
                                            else
                                            {
                                                q.ShiftOneChecked = "異常";
                                            }
                                        }
                                        else if (Shift == "03")
                                        {
                                            if (getCheckReuslt(CheckDate, Shift, q.ListName))
                                            {
                                                q.ShiftTrheeChecked = "正常";
                                            }
                                            else
                                            {
                                                q.ShiftTrheeChecked = "異常";
                                            }
                                        }
                                        else if (Shift == "04")
                                        {
                                            if (getCheckReuslt(CheckDate, Shift, q.ListName))
                                            {
                                                q.ShiftFourChecked = "正常";
                                            }
                                            else
                                            {
                                                q.ShiftFourChecked = "異常";
                                            }
                                        }
                                    }
                                }

                                q.UpadteAccount        = Session["UserID"].ToString().Trim();
                                q.UpdateTime           = DateTime.Now;
                                context.Entry(q).State = EntityState.Modified;
                                context.SaveChanges();
                            }
                        }
                        else
                        {
                            //沒有覆核表單
                        }
                    }

                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = 1;
                    SL.SuccessCount = 1;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "確認[" + item + "]作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                }
                i++;

                if (Shift == "03" || Shift == "04")
                {
                    bool   CanNotify   = true;
                    string CloseStutus = "";
                    var    queryCP     = context.CHECKPROCESSES.Where(b => b.CheckDate == CheckDate);
                    foreach (var item1 in queryCP.ToList())
                    {
                        if (Shift == "03")
                        {
                            CloseStutus = "晚班檢核完畢";
                            if (item1.ShiftOne == "" || item1.ShiftThree == "")
                            {
                                CanNotify = false;
                                break;
                            }
                        }
                        else if (Shift == "04")
                        {
                            CloseStutus = "假日班檢核完畢";
                            if (item1.ShiftFour == "")
                            {
                                CanNotify = false;
                                break;
                            }
                        }
                    }

                    if (CanNotify)
                    {
                        //通知下一位負責人
                        SF.emailNotify2ReviewbyDate(CloseStutus, Session["UserID"].ToString(),
                                                    CheckDate, "覆核");
                    }
                }
                return("確認成功");
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 0;
                SL.SuccessCount = 0;
                SL.FailCount    = 0;
                SL.Result       = false;
                SL.Msg          = "確認作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return("確認失敗");
            }
        }
コード例 #2
0
        /// <summary>
        /// 駁回
        /// </summary>
        /// <param name="CheckSNs"></param>
        /// <param name="CheckDates"></param>
        /// <param name="Reason"></param>
        /// <returns></returns>
        public string Reject(List <string> CheckSNs, List <string> CheckDates, string Reason)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Review";
            SL.Action        = "Reject";
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            int  TotalCount   = 0;
            int  SuccessCount = 0;
            int  FailCount    = 0;
            bool RejectOK     = true;

            try
            {
                TotalCount = CheckSNs.Distinct().Count();
                foreach (var item in CheckSNs.Distinct())
                {
                    CHECKPROCESS CP = context.CHECKPROCESSES.Find(item);
                    REJECTREASON RR = new REJECTREASON();

                    if (CP != null)
                    {
                        CP.CloseStutus          = "檢查中";
                        CP.UpadteAccount        = Session["UserID"].ToString().Trim();
                        CP.UpdateTime           = DateTime.Now;
                        context.Entry(CP).State = EntityState.Modified;

                        RR.CheckSN       = item;
                        RR.Reason        = Reason;
                        RR.CreateAccount = Session["UserID"].ToString().Trim();
                        RR.CreateTime    = DateTime.Now;
                        context.REJECTREASONS.Add(RR);
                        context.SaveChanges();

                        SuccessCount   += 1;
                        SL.EndDateTime  = DateTime.Now;
                        SL.TotalCount   = 1;
                        SL.SuccessCount = 1;
                        SL.FailCount    = 0;
                        SL.Result       = false;
                        SL.Msg          = "駁回[" + item + "]作業成功";
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    }
                    else
                    {
                        FailCount      += 1;
                        RejectOK        = false;
                        SL.EndDateTime  = DateTime.Now;
                        SL.TotalCount   = 1;
                        SL.SuccessCount = 0;
                        SL.FailCount    = 1;
                        SL.Result       = false;
                        SL.Msg          = "駁回[" + item + "]作業失敗,查無檢核流程資料";
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    }
                }

                if (RejectOK)
                {
                    int    Role        = int.Parse(Session["UserRole"].ToString());
                    string CloseStutus = "";
                    ////通知下一位負責人
                    switch (Role)
                    {
                    //機房領班
                    case 3:
                        CloseStutus = "領班駁回";
                        break;

                    //主管
                    case 4:
                        CloseStutus = "主管駁回";
                        break;

                    //系統部主管
                    case 5:
                        CloseStutus = "系統部主管駁回";
                        break;
                    }

                    SF.emailNotify2RejectbyDate(CloseStutus, Session["UserID"].ToString(),
                                                CheckDates[0].ToString());
                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = TotalCount;
                    SL.SuccessCount = SuccessCount;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "[" + CheckDates[0].ToString() + "]駁回作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return("全部駁回成功");
                }
                else
                {
                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = TotalCount;
                    SL.SuccessCount = SuccessCount;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "[" + CheckDates[0].ToString() + "]駁回作業失敗";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return("有" + FailCount.ToString() + "筆資料駁回失敗");
                }
            }
            catch (Exception ex)
            {
                RejectOK        = false;
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = CheckSNs.Count();
                SL.SuccessCount = 0;
                SL.FailCount    = CheckSNs.Count();
                SL.Result       = false;
                SL.Msg          = "駁回作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return("駁回發生異常");
            }
        }
コード例 #3
0
        /// <summary>
        /// 產生CHECKPROCESS資料
        /// </summary>
        /// <param name="CheckSNList">檢核編號清單</param>
        /// <param name="CheckDate">檢核日期</param>
        /// <returns></returns>
        private bool GenCheckProcess(List <string> CheckSNList, string CheckDate)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = "System";
            SL.Controller    = "Process";
            SL.Action        = "GenCheckProcess";
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            bool Result = true;

            try
            {
                var CT = context.CHECKTITLES.ToList();

                if (CheckSNList != null)
                {
                    //產生CHECKPROCESS
                    int i = 0;
                    foreach (var item in CT)
                    {
                        CHECKPROCESS newCP = new CHECKPROCESS();
                        newCP.CheckSN       = CheckSNList[i];
                        newCP.CheckID       = item.CheckID;
                        newCP.CheckDate     = CheckDate;
                        newCP.CloseStutus   = "檢查中";
                        newCP.CreateAccount = "System";
                        newCP.CreateTime    = DateTime.Now;
                        newCP.UpadteAccount = "System";
                        newCP.UpdateTime    = DateTime.Now;
                        newCP.CheckDate     = CheckDate;
                        context.CHECKPROCESSES.Add(newCP);
                        context.SaveChanges();

                        i++;
                    }
                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = CheckSNList.Count();
                    SL.SuccessCount = CheckSNList.Count();
                    SL.FailCount    = 0;
                    SL.Result       = true;
                    SL.Msg          = "建立[" + CheckDate + "]檢核流程作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return(Result);
                }
                else
                {
                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = 0;
                    SL.SuccessCount = 0;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "建立[" + CheckDate + "]檢核流程作業失敗," + "錯誤訊息[無檢核編號]";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    Result = false;

                    return(Result);
                }
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 0;
                SL.SuccessCount = 0;
                SL.FailCount    = 0;
                SL.Result       = false;
                SL.Msg          = "建立[" + CheckDate + "]檢核流程作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                Result = false;

                return(Result);
            }
        }
コード例 #4
0
        /// <summary>
        /// 簽核
        /// </summary>
        /// <param name="CheckSNs"></param>
        /// <param name="CheckDates"></param>
        /// <param name="SignedData"></param>
        /// <returns></returns>
        public string Confirm(List <string> CheckSNs, List <string> CheckDates, string SignedData)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Review";
            SL.Action        = "Confirm";
            SL.StartDateTime = DateTime.Now;

            string UId = Session["UserID"].ToString();

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            int  TotalCount   = 0;
            int  SuccessCount = 0;
            int  FailCount    = 0;
            bool ReviewOK     = true;

            try
            {
                string CloseStutus = "";
                TotalCount = CheckSNs.Count();
                foreach (var item in CheckSNs)
                {
                    CHECKPROCESS CP = context.CHECKPROCESSES.Find(item);

                    if (CP != null)
                    {
                        //update CHECKPROCESSES
                        EPSUSER U    = context.EPSUSERS.Find(UId);
                        int     Role = U.RId;// int.Parse(UId);

                        switch (Role)
                        {
                        //機房領班
                        case 3:
                            CP.ShiftTop     = U.UserName;
                            CP.ShiftTopSign = SignedData;
                            CP.CloseStutus  = "領班覆核完畢";
                            CloseStutus     = "領班覆核完畢";
                            break;

                        //主管
                        case 4:
                            CP.ManageOne     = U.UserName;
                            CP.ManageOneSign = SignedData;
                            CP.CloseStutus   = "主管覆核完畢";
                            CloseStutus      = "主管覆核完畢";
                            break;

                        //系統部主管
                        case 5:
                            CP.ManageTop     = U.UserName;
                            CP.ManageTopSign = SignedData;
                            CP.CloseStutus   = "已結案";
                            CloseStutus      = "已結案";
                            break;
                        }

                        CP.UpadteAccount        = UId;
                        CP.UpdateTime           = DateTime.Now;
                        context.Entry(CP).State = EntityState.Modified;
                        context.SaveChanges();
                        SuccessCount += 1;

                        SL.EndDateTime  = DateTime.Now;
                        SL.TotalCount   = 1;
                        SL.SuccessCount = 1;
                        SL.FailCount    = 0;
                        SL.Result       = false;
                        SL.Msg          = "覆核[" + item + "]作業成功";
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    }
                    else
                    {
                        FailCount      += 1;
                        ReviewOK        = false;
                        SL.EndDateTime  = DateTime.Now;
                        SL.TotalCount   = 1;
                        SL.SuccessCount = 0;
                        SL.FailCount    = 1;
                        SL.Result       = false;
                        SL.Msg          = "覆核[" + item + "]作業失敗,查無檢核流程資料";
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    }
                }

                if (ReviewOK)
                {
                    //通知下一位負責人,已結案則通知機房領班、機房主管、系統部主管
                    if (CloseStutus == "已結案")
                    {
                        SF.emailNotify2ClosebyDate(CloseStutus, UId,
                                                   CheckDates[0].ToString(), CloseStutus);
                    }
                    else
                    {
                        SF.emailNotify2ReviewbyDate(CloseStutus, UId,
                                                    CheckDates[0].ToString(), "覆核");
                    }
                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = TotalCount;
                    SL.SuccessCount = SuccessCount;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "[" + CheckDates[0].ToString() + "]覆核作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return("全部覆核成功");
                }
                else
                {
                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = TotalCount;
                    SL.SuccessCount = SuccessCount;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "[" + CheckDates[0].ToString() + "]覆核作業失敗";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return("有" + FailCount.ToString() + "筆資料覆核失敗");
                }
            }
            catch (Exception ex)
            {
                ReviewOK        = false;
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = CheckSNs.Count();
                SL.SuccessCount = 0;
                SL.FailCount    = CheckSNs.Count();
                SL.Result       = false;
                SL.Msg          = "覆核作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return("覆核發生異常");
            }
        }