Beispiel #1
0
        public ActionResult Create()
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Role";
            SL.Action = "Create";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                vEPSROLE_Manage VRM = new vEPSROLE_Manage();
                var query = from f in context.FUNCS
                            select new
                            {
                                f.FId,
                                f.FuncName
                            };

                VRM.Funcs= new SelectList(query, "FId", "FuncName");
                //預設給予登出功能
                VRM.FuncList = new int[] { 100 };
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 0;
                SL.SuccessCount = 0;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "建立角色表單作業成功";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return View(VRM);
            }
            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 RedirectToAction("Index", "Role");
            }
        }
Beispiel #2
0
        public ActionResult Create()
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Account";
            SL.Action = "Create";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                vEPSUSER_Manage VUM = new vEPSUSER_Manage();

                var query = from r in context.EPSROLES
                            select new
                            {
                                r.RId,
                                r.RoleName
                            };
                VUM.RId = 1;
                VUM.Role = new SelectList(query, "RId", "RoleName");
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 0;
                SL.SuccessCount = 0;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "建立使用者表單作業成功";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return View(VUM);
            }
            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 RedirectToAction("Index", "Account");
            }
        }
Beispiel #3
0
        //
        // GET: /Fun/Create
        public ActionResult Create()
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Fun";
            SL.Action = "Create";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                vFUNC_Manage VFM = new vFUNC_Manage();
                VFM.PId = 0;
                VFM.IsEnable = true;

                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 0;
                SL.SuccessCount = 0;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "建立角色表單作業成功";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return View(VFM);
            }
            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 RedirectToAction("Index", "Fun");
            }
        }
Beispiel #4
0
        public ActionResult Edit(vEPSROLE_Manage VRM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Role";
            SL.Action = "Edit";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                EPSROLE R = context.EPSROLES.Find(VRM.RId);
                R.RoleName = VRM.RoleName;
                R.UpadteAccount= Session["UserID"].ToString().Trim();
                R.UpdateTime = DateTime.Now;
                //取得目前角色擁有的權限
                var query1 = from rm in context.ROLEFUNCMAPPINGS
                             where rm.RId ==VRM.RId
                             select new
                             {
                                 rm.FId
                             };
                List<int> TmpList = new List<int>();
                foreach (var item in query1)
                {
                    TmpList.Add(item.FId);
                }

                //取得新增清單
                var addResultList = VRM.FuncList.Except(TmpList);
                //取得移除清單
                var delResultList = TmpList.Except(VRM.FuncList);

                //新增權限作業
                if (addResultList !=null)
                {
                    foreach (var item in addResultList)
                    {
                        ROLEFUNCMAPPING RM = new ROLEFUNCMAPPING();
                        RM.RId = VRM.RId;
                        RM.FId = item;
                        RM.CreateAccount = Session["UserID"].ToString().Trim();
                        RM.CreateTime = DateTime.Now;
                        RM.UpadteAccount = Session["UserID"].ToString().Trim();
                        RM.UpdateTime = DateTime.Now;

                        context.ROLEFUNCMAPPINGS.Add(RM);
                        context.SaveChanges();
                    }
                }

                //移除權限作業
                if (delResultList !=null)
                {
                    foreach (var item in delResultList)
                    {
                        ROLEFUNCMAPPING RM = context.ROLEFUNCMAPPINGS.Where(b => b.RId == VRM.RId)
                                                                     .Where(b => b.FId == item)
                                                                     .First();
                        context.Entry(RM).State = EntityState.Deleted;
                        context.SaveChanges();
                    }
                }

                context.Entry(R).State = EntityState.Modified;
                context.SaveChanges();

                SL.EndDateTime = DateTime.Now;
                SL.SuccessCount = 1;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "編輯角色作業成功,RId:[" + VRM.RId.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return RedirectToAction("Index", "Role");
            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 0;
                SL.FailCount = 1;
                SL.Result = false;
                SL.Msg = "編輯角色作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["EditMsg"] = "<script>alert('發生異常');</script>";

                return RedirectToAction("Edit", "Role",new { RId= VRM.RId });
            }
        }
Beispiel #5
0
        /// <summary>
        /// Email通知系統管理人員
        /// </summary>
        /// <param name="_WitreDB">是否要將通知結果寫入資料庫</param>
        /// <param name="_MailSubject">郵件主旨</param>
        /// <param name="_MailBody">郵件內容</param>
        /// <remarks></remarks>
        public void EmailNotify2Sys(string _MailServer, int _MailServerPort, string _MailSender, List<string> _MailReceiver, bool _WitreDB, string _MailSubject, string _MailBody)
        {
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = "System";
            SL.Action = "通知系統管理人員作業";
            SL.StartDateTime = DateTime.Now;
            SL.TotalCount = 1;

            bool WitreDB = _WitreDB;

            string MailServer = _MailServer;
            int MailServerPort = _MailServerPort;
            string MailSender = _MailSender;
            List<string> MailReceiver = _MailReceiver;
            string MailSubject = _MailSubject;
            string MailBody = _MailBody;
            string SendResult = string.Empty;

            //寄送通知信給系統管理人員
            SendResult = SendEmail(MailServer, MailServerPort, MailSender, MailReceiver, MailSubject, MailBody.ToString());
            SL.EndDateTime = DateTime.Now;

            if (SendResult == "success")
            {
                //寫入文字檔Log
                logandshowInfo("[" + SL.UId + "]執行[" + SL.Action + "]成功", log_Info);

                SL.SuccessCount = 1;
                SL.Result = true;
            }
            else
            {
                //寫入文字檔Log
                logandshowInfo("[" + SL.UId + "]執行[通知系統管理人員作業]失敗,請查詢Debug Log得到詳細資訊", log_Info);
                logandshowInfo("[" + SL.UId + "]執行[通知系統管理人員作業]失敗,詳細資訊如下", log_Err);
                logandshowInfo("錯誤訊息:[" + SendResult + "]", log_Err);

                SL.FailCount = 1;
                SL.Msg = SendResult;
            }

            if (WitreDB == true)
            {
                //寫入DB Log
                //OPLoger.SetOPLog(this.op_name, op_action, op_stime, op_etime, op_a_count, op_s_count, op_f_count, op_msg, op_result);
                log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 通知覆核人
        /// </summary>
        /// <param name="CloseStatus">結案狀態</param>
        /// <param name="UId">執行人</param>
        /// <param name="CheckSN">日常檢核件編號</param>
        /// <param name="CheckTitle">機房檢核主題名稱</param>
        /// <param name="CheckDate">檢核日期</param>
        public void emailNotify2Review(string CloseStatus,string UId,
                                         string CheckSN,string CheckTitle,
                                         string CheckDate,string Action)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = UId;
            SL.Controller = "Process";
            SL.Action = "emailNotify2Reviewer";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                var query = context.REVIEWPROFILES.Where(b => b.CloseStauts == CloseStatus).ToList();
                if (query.Count() > 0)
                {
                    foreach (var item in query)
                    {
                        MAILTEMPLATE MT = context.MAILTEMPLATES.Find(item.MailTempID);

                        if (MT != null)
                        {
                            MAILSERVER MS = context.MAILSERVERS.Find(MT.MailServerID);
                            if (MS != null)
                            {
                                string TmpRole = item.NextReviews;
                                string[] TmpRoles = TmpRole.Split(',');
                                int[] Roles = new int[TmpRoles.Count()];
                                if (TmpRoles.Count() > 0)
                                {
                                    int i = 0;
                                    foreach (var R in TmpRoles)
                                    {
                                        Roles[i] = int.Parse(R);
                                        i++;
                                    }
                                }
                                    var queryUsers = context.EPSUSERS.Where(b => Roles.Contains(b.RId)).ToList();
                                    if (queryUsers.Count() > 0)
                                    {
                                        StringBuilder UserNameb = new StringBuilder();
                                        string UserName = "";
                                        foreach (var U in queryUsers)
                                        {
                                            UserNameb.Append(U.UserName + Configer.SplitSymbol);
                                        }
                                        UserName = StringProcessor.CutlastChar(UserName.ToString());
                                        //組合通知信標頭
                                        DateTime parsed;
                                        string parsedTime = "取得檢核件時間錯誤";
                                        if (DateTime.TryParseExact(CheckDate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                                        {
                                            parsedTime = parsed.ToString("yyyy-MM-dd");
                                        }

                                        MT.Subject.Replace("#Time", parsedTime)
                                                  .Replace("#Action", Action);

                                        MT.Body.Replace("#UserName", UserName);

                                        char[] s = { ',' };
                                        List<string> Receivers = StringProcessor.SplitString2Array(UserName, s);

                                        //寄信
                                        string SendResult = SendEmail(MS.ServerIP, MS.ServerPort, MT.Sender, Receivers, MT.Subject, MT.Body);
                                        if (SendResult == "success")
                                        {
                                            SL.EndDateTime = DateTime.Now;
                                            SL.TotalCount = query.Count();
                                            SL.SuccessCount = query.Count();
                                            SL.FailCount = 0;
                                            SL.Result = true;
                                            SL.Msg = "通知[" + CheckSN + "]覆核人流程作業成功";
                                            log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                                        }
                                        else
                                        {
                                            //寄信失敗
                                            SL.EndDateTime = DateTime.Now;
                                            SL.TotalCount = 0;
                                            SL.SuccessCount = 0;
                                            SL.FailCount = 0;
                                            SL.Result = true;
                                            SL.Msg = "通知[" + CheckSN + "]覆核人流程作業失敗," + "錯誤訊息[" + SendResult + "]";
                                            log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                                        }
                                    }
                                    else
                                    {
                                        //沒有角色
                                        SL.EndDateTime = DateTime.Now;
                                        SL.TotalCount = 0;
                                        SL.SuccessCount = 0;
                                        SL.FailCount = 0;
                                        SL.Result = true;
                                        SL.Msg = "通知[" + CheckSN + "]覆核人流程作業失敗,沒有設定角色";
                                        log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                                    }
                                }
                                else
                                {
                                    //沒有設定MAILSERVER
                                    SL.EndDateTime = DateTime.Now;
                                    SL.TotalCount = 0;
                                    SL.SuccessCount = 0;
                                    SL.FailCount = 0;
                                    SL.Result = true;
                                    SL.Msg = "通知[" + CheckSN + "]覆核人流程作業失敗,沒有設定MAILSERVER";
                                    log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                                }
                            }
                            else
                            {
                                //沒有設定MAILTEMPLATE
                                SL.EndDateTime = DateTime.Now;
                                SL.TotalCount = 0;
                                SL.SuccessCount = 0;
                                SL.FailCount = 0;
                                SL.Result = true;
                                SL.Msg = "通知[" + CheckSN + "]覆核人流程作業失敗,沒有設定MAILTEMPLATE";
                                log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                            }
                        }
                    }
                else
                {
                    //沒有設定REVIEWPROFILE
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = 0;
                    SL.SuccessCount = 0;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "通知[" + CheckSN + "]覆核人流程作業失敗,沒有設定REVIEWPROFILE";
                    log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                }
            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 0;
                SL.SuccessCount = 0;
                SL.FailCount = 0;
                SL.Result = false;
                SL.Msg = "通知[" + CheckSN + "]覆核人流程作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
            }
        }
Beispiel #7
0
        public ActionResult Logout()
        {
            //初始化系統參數
            Configer.Init();

            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Account";
            SL.Action = "Logout";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                SL.EndDateTime = DateTime.Now;
                SL.SuccessCount = 1;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "登出作業成功,UId:[" + Session["UserID"].ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                Session.Clear();

                return RedirectToAction("Login", "Account");
            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 0;
                SL.FailCount = 1;
                SL.Result = false;
                SL.Msg = "登出作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return RedirectToAction("Login", "Account");
            }
        }
Beispiel #8
0
        public ActionResult Create(vFUNC_Manage VFM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Fun";
            SL.Action = "Create";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                if (ModelState.IsValid)
                {
                    FUNC F = new FUNC();
                    F.FId = VFM.FId;
                    F.FuncName = VFM.FuncName;
                    F.Controller = VFM.Controller;
                    F.Action = VFM.Action;
                    F.Url = VFM.Url;
                    F.PId = VFM.PId;
                    F.ShowOrder = VFM.ShowOrder;
                    F.IsEnable = VFM.IsEnable;
                    F.CreateAccount = Session["UserID"].ToString().Trim();
                    F.CreateTime = DateTime.Now;
                    F.UpadteAccount = Session["UserID"].ToString().Trim();
                    F.UpdateTime = DateTime.Now;

                    context.FUNCS.Add(F);
                    context.SaveChanges();

                    SL.EndDateTime = DateTime.Now;
                    SL.SuccessCount = 1;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "建立功能作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    //TempData["CreateMsg"] = "<script>alert('新增成功');</script>";

                    return RedirectToAction("Index", "Fun");
                }
                else
                {
                    TempData["CreateMsg"] = "<script>alert('新增失敗');</script>";

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

                TempData["CreateMsg"] = "<script>alert('發生異常');</script>";

                return RedirectToAction("Create", "Fun");
            }
        }
Beispiel #9
0
        // GET: Fun
        public ActionResult Index()
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Fun";
            SL.Action = "Index";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                var query = context.FUNCS.ToList();
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = query.Count();
                SL.SuccessCount = query.Count();
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "取得功能清單作業成功";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return View(query);
            }
            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 RedirectToAction("Login", "Account");
            }
        }
Beispiel #10
0
        public ActionResult Summary(string CheckDate)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Review";
            SL.Action = "Summary";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                vReviewSummary vRS = new vReviewSummary();
                vRS.CheckDate = CheckDate;
                string CheckSN = CheckDate + "01";
                vRS.EventItem = context.CHECKPROCESSDETAILS.Where(b => b.CheckSN == CheckSN).Where(b => b.ListID == 1).First().CheckResult;
                vRS.HandoverItem = context.CHECKPROCESSDETAILS.Where(b => b.CheckSN == CheckSN).Where(b => b.ListID == 2).First().CheckResult;
                var query01 = context.CHECKPROCESSES.Where(b => b.CheckDate == CheckDate).Where(b => b.CheckID == 1);
                if (query01.Count()>0)
                {
                    vRS.ShiftOne = query01.First().ShiftOne;
                    vRS.ShiftThree = query01.First().ShiftThree;
                    vRS.ShiftFour = query01.First().ShiftFour;
                    vRS.ShiftTop = query01.First().ShiftTop;
                    vRS.ManageOne = query01.First().ManageOne;
                    vRS.ManageTop = query01.First().ManageTop;
                }

                var query = context.REVIEWDATAS.Where(b => b.CheckDate == CheckDate);
                    //.Where(b=>b.ListName!= "事件描述及行動").Where(b=>b.ListName != "交接事項");
                if (query.Count() > 0)
                {
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = query.Count();
                    SL.SuccessCount = query.Count();
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得[" + CheckDate + "]覆核資料作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    DateTime parsed;
                    string parsedTime = "取得檢核件時間錯誤";
                    if (DateTime.TryParseExact(CheckDate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedTime = parsed.ToString("yyyy-MM-dd");
                    }

                    TempData["TitleText"] = parsedTime + " 檢核資料";
                    vRS.RD = query.ToList();
                    return View(vRS);
                }
                else
                {
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = query.Count();
                    SL.SuccessCount = query.Count();
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得[" + CheckDate + "]覆核資料作業失敗," + "錯誤訊息[找不到待覆核資料]";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return null;
                }
            }
            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);

                return null;
            }
        }
Beispiel #11
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 "覆核發生異常";
            }
        }
Beispiel #12
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 "駁回發生異常";
            }
        }
Beispiel #13
0
        // GET: Review
        public ActionResult Index()
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Review";
            SL.Action = "Index";
            SL.StartDateTime = DateTime.Now;

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

            //int RoleID = Int32.Parse(Session["UserRole"].ToString());
            string RoleID = Session["UserRole"].ToString();

            try
            {
                var query = from rp in context.REVIEWPROFILES.Where(b => b.NextReviews == RoleID)
                            join cp in context.CHECKPROCESSES.Where(b => b.CloseStutus != "檢查中")
                                                             .Where(b=>b.CloseStutus != "早班檢核完畢")
                            on rp.CloseStauts equals cp.CloseStutus
                            join ct in context.CHECKTITLES on cp.CheckID equals ct.CheckID into x
                            from y in x.DefaultIfEmpty()
                            select new vReview
                            {
                                CheckSN = cp.CheckSN,
                                CheckDate=cp.CheckDate,
                                Title = y.Title,
                                CloseStutus = cp.CloseStutus,
                                ShiftOne = cp.ShiftOne,
                                ShiftThree = cp.ShiftThree,
                                ShiftFour = cp.ShiftFour,
                                ShiftTop = cp.ShiftTop,
                                ManageOne = cp.ManageOne,
                                ManageTop = cp.ManageTop
                            };

                if (query.Count() > 0)
                {
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = query.Count();
                    SL.SuccessCount = query.Count();
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得[待覆核資料]流程作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return View(query.OrderBy(b => b.CheckSN).ToList());
                }
                else
                {
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = 0;
                    SL.SuccessCount = 0;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得[待覆核資料]流程作業成功,目前無待覆核資料";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return null;
                }
            }
            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 null;
            }
        }
Beispiel #14
0
        public ActionResult Detail(string CheckSN,string CheckDate)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Review";
            SL.Action = "Detail";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                vCHECKPROCESS vCP = GetProcess(CheckSN, CheckDate);
                if (vCP != null)
                {
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = 1;
                    SL.SuccessCount = 1;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得[" + CheckSN + "]明細作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return View(vCP);
                }
                else
                {
                    //沒有檢核項目錯誤
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = 0;
                    SL.SuccessCount = 0;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得[" + CheckSN + "]明細作業失敗,查無明細資料";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    return null;
                }

            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 0;
                SL.SuccessCount = 0;
                SL.FailCount = 0;
                SL.Result = false;
                SL.Msg = "取得[" + CheckSN + "]明細作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                return null;
            }
        }
Beispiel #15
0
        public ActionResult Create(vEPSROLE_Manage VRM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Role";
            SL.Action = "Create";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                if (ModelState.IsValid)
                {
                    EPSROLE R = new EPSROLE();
                    R.RoleName = VRM.RoleName;
                    R.CreateAccount = Session["UserID"].ToString().Trim();
                    R.CreateTime = DateTime.Now;
                    R.UpadteAccount = Session["UserID"].ToString().Trim();
                    R.UpdateTime = DateTime.Now;

                    context.EPSROLES.Add(R);
                    context.SaveChanges();

                    foreach (var item in VRM.FuncList)
                    {
                        ROLEFUNCMAPPING RM = new ROLEFUNCMAPPING();
                        RM.RId = R.RId;
                        RM.FId = item;
                        RM.CreateAccount = Session["UserID"].ToString().Trim();
                        RM.CreateTime = DateTime.Now;
                        RM.UpadteAccount = Session["UserID"].ToString().Trim();
                        RM.UpdateTime = DateTime.Now;

                        context.ROLEFUNCMAPPINGS.Add(RM);
                        context.SaveChanges();
                    }
                    SL.EndDateTime = DateTime.Now;
                    SL.SuccessCount = 1;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "建立使用者作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    //TempData["CreateMsg"] = "<script>alert('新增成功');</script>";

                    return RedirectToAction("Index", "Role");
                }
                else
                {
                    TempData["CreateMsg"] = "<script>alert('新增失敗');</script>";

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

                TempData["CreateMsg"] = "<script>alert('發生異常');</script>";

                return RedirectToAction("Create", "Role");
            }
        }
Beispiel #16
0
        // GET: Fun/Edit
        public ActionResult Edit(int SN)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Fun";
            SL.Action = "Edit";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                vFUNC_Manage VFM = new vFUNC_Manage();
                FUNC F = context.FUNCS.Find(SN);

                VFM.SN = F.SN;
                VFM.FId = F.FId;
                VFM.FuncName = F.FuncName;
                VFM.PId = F.PId;
                VFM.Controller = F.Controller;
                VFM.Action = F.Action;
                VFM.Url = F.Url;
                VFM.ShowOrder = F.ShowOrder;
                VFM.IsEnable = F.IsEnable;

                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 1;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "取得功能資料作業成功,FId:[" + F.FId.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return View(VFM);
            }
            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 RedirectToAction("Index", "Fun");
            }
        }
Beispiel #17
0
        public ActionResult Edit(vFUNC_Manage VFM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Fun";
            SL.Action = "Edit";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                FUNC F = context.FUNCS.Find(VFM.SN);
                F.FuncName = VFM.FuncName;
                F.Controller = VFM.Controller;
                F.Action = VFM.Action;
                F.Url = VFM.Url;
                F.PId = VFM.PId;
                F.ShowOrder = VFM.ShowOrder;
                F.IsEnable = VFM.IsEnable;
                F.UpadteAccount = Session["UserID"].ToString().Trim();
                F.UpdateTime = DateTime.Now;

                context.Entry(F).State = EntityState.Modified;
                context.SaveChanges();

                SL.EndDateTime = DateTime.Now;
                SL.SuccessCount = 1;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "編輯功能作業成功,FId:[" + VFM.FId.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return RedirectToAction("Index", "Fun");
            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 0;
                SL.FailCount = 1;
                SL.Result = false;
                SL.Msg = "編輯功能作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["EditMsg"] = "<script>alert('發生異常');</script>";

                return RedirectToAction("Edit", "Fun", new { SN = VFM.SN });
            }
        }
Beispiel #18
0
        /// <summary>
        /// 取得vCHECKPROCESS模型
        /// </summary>
        /// <param name="CheckSN">檢核編號</param>
        /// <param name="CheckDate">檢核日期</param>
        /// <returns></returns>
        private vCHECKPROCESS GetProcess(string CheckSN, string CheckDate)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Review";
            SL.Action = "GetProcess";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                vCHECKPROCESS vCP = new vCHECKPROCESS();
                vCP.CheckSN = CheckSN;
                vCP.CheckDate = CheckDate;
                int CheckID = context.CHECKPROCESSES.Find(CheckSN).CheckID;
                CHECKTITLE CT = context.CHECKTITLES.Find(CheckID);
                vCP.Title = CT.Title;

                var query = from cp in context.CHECKPROCESSES
                            where cp.CheckSN == CheckSN
                            where cp.CheckDate == CheckDate
                            join cd in context.CHECKPROCESSDETAILS.Where(b => b.CheckDate == CheckDate) on cp.CheckID equals cd.CheckID
                            join cl in context.CHECKLISTS on cd.ListID equals cl.ListID into x
                            from y in x.DefaultIfEmpty()
                            select new vCHECKDETAIL
                            {
                                ListID = y.ListID,
                                CheckID = y.CheckID,
                                ListName = y.ListName,
                                CheckType = y.CheckType,
                                Shift = y.ShiftID,
                                StartTime = y.StartTime,
                                EndTime = y.EndTime,
                                CheckResult = cd.CheckResult,
                                CloseStatus = cp.CloseStutus
                            };

                if (query.Count() > 0)
                {
                    //根據班別挑出檢核項目
                    //var Shifts = new string[] { "00", Shift };
                    //query = query.Where(b => Shifts.Contains(b.Shift));

                    vCP.vCHECKDETAILs = query.OrderBy(b => b.StartTime).ToList();
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = query.Count();
                    SL.SuccessCount = query.Count();
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得[" + CheckSN + "]檢核流程作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    return vCP;
                }
                else
                {
                    //沒有檢核項目錯誤
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = 0;
                    SL.SuccessCount = 0;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得[" + CheckSN + "]檢核流程作業失敗,沒有對應檢核項目";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    return null;
                }
            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 0;
                SL.SuccessCount = 0;
                SL.FailCount = 0;
                SL.Result = false;
                SL.Msg = "取得[" + CheckSN + "]檢核流程作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                return null;
            }
        }
Beispiel #19
0
        public ActionResult AddItem(vCHECKLIST_Manage VCLM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Document";
            SL.Action = "AddItem";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                if (ModelState.IsValid)
                {
                    CHECKLIST CL = new CHECKLIST();
                    CL.CheckID = VCLM.CheckID;
                    CL.ListName = VCLM.ListName;
                    CL.Definition = VCLM.Definition;
                    CL.CheckType = VCLM.CheckType;
                    CL.ClassID = VCLM.ClassID;
                    CL.ChargerID = VCLM.ChargerID;
                    CL.ShiftID = VCLM.ShiftID;
                    CL.StartTime = VCLM.StartTime;
                    CL.EndTime = VCLM.EndTime;
                    CL.AlwaysShow = VCLM.AlwaysShow;
                    CL.ShowOrder = VCLM.ShowOrder;
                    CL.CreateAccount = Session["UserID"].ToString().Trim();
                    CL.CreateTime = DateTime.Now;
                    CL.UpadteAccount = Session["UserID"].ToString().Trim();
                    CL.UpdateTime = DateTime.Now;

                    context.CHECKLISTS.Add(CL);
                    context.SaveChanges();

                    SL.EndDateTime = DateTime.Now;
                    SL.SuccessCount = 1;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "建立檢核項目作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    //TempData["CreateMsg"] = "<script>alert('新增成功');</script>";

                    return RedirectToAction("AddItem", "Document", new { CheckID = VCLM.CheckID, Title = VCLM.CheckTitle });

                }
                else
                {
                    TempData["CreateMsg"] = "<script>alert('新增失敗');</script>";

                    return RedirectToAction("AddItem", "Document", new { CheckID = VCLM.CheckID, Title = VCLM.CheckTitle });
                }
            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 0;
                SL.FailCount = 1;
                SL.Result = false;
                SL.Msg = "建立檢核項目作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["CreateMsg"] = "<script>alert('發生異常');</script>";

                return RedirectToAction("AddItem", "Document", new { CheckID = VCLM.CheckID, Title = VCLM.CheckTitle });
            }
        }
Beispiel #20
0
        public ActionResult Create(vDOCUMENT_Manage VDM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Document";
            SL.Action = "Create";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                if (ModelState.IsValid)
                {
                    CHECKTITLE CT = new CHECKTITLE();
                    CT.Title = VDM.Title;
                    CT.Definition = VDM.Definition;
                    CT.Attachment = VDM.Attachment;
                    CT.CreateAccount = Session["UserID"].ToString().Trim();
                    CT.CreateTime = DateTime.Now;
                    CT.UpadteAccount = Session["UserID"].ToString().Trim();
                    CT.UpdateTime = DateTime.Now;

                    context.CHECKTITLES.Add(CT);
                    context.SaveChanges();

                    SL.EndDateTime = DateTime.Now;
                    SL.SuccessCount = 1;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "建立文件作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    //TempData["CreateMsg"] = "<script>alert('新增成功');</script>";

                    return RedirectToAction("AddItem", "Document", new { CheckID = CT.CheckID, CheckTitle = CT.Title });
                }
                else
                {
                    TempData["CreateMsg"] = "<script>alert('新增失敗');</script>";

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

                TempData["CreateMsg"] = "<script>alert('發生異常');</script>";

                return RedirectToAction("Create", "Document");
            }
        }
Beispiel #21
0
        public ActionResult Index()
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Account";
            SL.Action = "Index";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                var query = from u in context.EPSUSERS
                            join r in context.EPSROLES on u.RId equals r.RId into USERS
                            from x in USERS.DefaultIfEmpty()
                            select new vEPSUSER
                            {
                                UId=u.UId,
                                UserName = u.UserName,
                                UserEmail = u.UserEmail,
                                RoleName = x.RoleName,
                                CreateAccount = u.CreateAccount,
                                CreateTime = u.CreateTime,
                                UpadteAccount = u.UpadteAccount,
                                UpdateTime = u.UpdateTime
                            };

                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = query.Count();
                SL.SuccessCount = query.Count();
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "取得使用者清單作業成功";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return View(query.ToList());
            }
            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 RedirectToAction("Login", "Account");
            }
        }
Beispiel #22
0
        public ActionResult EditItem(int ListID)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Document";
            SL.Action = "EditItem";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                CHECKLIST CL = context.CHECKLISTS.Find(ListID);
                CHECKTITLE CT = context.CHECKTITLES.Find(CL.CheckID);
                vCHECKLIST_Manage VCTM = new vCHECKLIST_Manage();

                VCTM.CheckTitle = CT.Title;
                VCTM.CheckID = CL.CheckID;
                VCTM.ListName = CL.ListName;
                VCTM.Definition = CL.Definition;
                VCTM.CheckTitle = CT.Title;
                TempData["CheckID"] = CL.CheckID;
                TempData["Title"] = CT.Title;

                //取得班別清單
                var query1 = from s in context.CHECKSHIFTS
                             select new
                             {
                                 s.ShiftID,
                                 s.ShiftValue
                             };
                VCTM.ShiftID = CL.ShiftID;
                VCTM.ShiftIDList = new SelectList(query1, "ShiftID", "ShiftValue");

                //取得分類清單
                var query2 = from c in context.CHECKCLASSES
                             select new
                             {
                                 c.ClassID,
                                 c.ClassValue
                             };
                VCTM.ClassID = CL.ClassID;
                VCTM.ClassIDList = new SelectList(query2, "ClassID", "ClassValue");

                //取得負責人清單
                var query = from u in context.EPSUSERS
                            select new
                            {
                                u.UId,
                                u.UserName
                            };
                VCTM.ChargerID = CL.ChargerID;
                VCTM.ChargerList = new SelectList(query, "UId", "UserName");
                VCTM.CheckType = CL.CheckType;
                VCTM.AlwaysShow = CL.AlwaysShow;
                VCTM.StartTime = CL.StartTime;
                VCTM.EndTime = CL.EndTime;
                VCTM.ShowOrder = CL.ShowOrder;

                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 1;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "取得檢核項目資料作業成功,ListID:[" + ListID.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return View(VCTM);
            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 0;
                SL.FailCount = 1;
                SL.Result = false;
                SL.Msg = "取得檢核項目資料作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return RedirectToAction("ListItem", "Document");
            }
        }
Beispiel #23
0
        public ActionResult Login(LoginInfo model)
        {
            //初始化系統參數
            Configer.Init();

            AD AD = new AD();
            VA VA = new VA();
            LoginProcessor LP = new LoginProcessor();
            bool UseCertLogin = false;
            string LDAPName = Configer.LDAPName;
            //string VAVerifyURL = WebConfigurationManager.AppSettings["VAVerifyURL"];
            //string ConnStr = Configer.C_DBConnstring;
            Boolean ContinueLogin = true;

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = model.UserID;
            SL.Controller = "Account";
            SL.Action = "Login";
            SL.StartDateTime = DateTime.Now;
            SL.TotalCount = 1;

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

            if (ModelState.IsValid)
            {
                if (LDAPName == "")
                {
                    //缺少系統參數,需記錄錯誤
                    SL.EndDateTime = DateTime.Now;
                    SL.SuccessCount = 0;
                    SL.FailCount = 1;
                    SL.Msg = "登入作業失敗,錯誤訊息:[缺少系統參數LDAPName]";
                    SL.Result = false;
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    ContinueLogin = false;
                }
                if (ContinueLogin)
                {
                    AD.UserName = model.UserID;
                    AD.Pwd = model.Pwd;
                    AD.validType = AD.ValidType.Domain;
                    AD.LDAPName = LDAPName;

                    //VA.SignData = model.SignData;
                    //VA.Plaintext = model.Plaintext;
                    //VA.txnCode = "TxnCode";
                    //VA.VAVerifyURL = VAVerifyURL;
                    //VA.Tolerate = 120;

                    DateTime LoginStartTime = DateTime.Now;
                    SF.logandshowInfo("登入開始@" + LoginStartTime.ToString(Configer.SystemDateTimeFormat), log_Info);
                    bool LoginResult = LP.DoLogin(UseCertLogin, AD, VA);
                    DateTime LoginEndTime = DateTime.Now;
                    SF.logandshowInfo("登入結束@" + LoginEndTime.ToString(Configer.SystemDateTimeFormat), log_Info);
                    string LoginSpanTime = OtherProcesser.TimeDiff(LoginStartTime, LoginEndTime, "Milliseconds");
                    SF.logandshowInfo("本次登入共花費@" + LoginSpanTime + "毫秒", log_Info);

                    if (LoginResult == true)
                    {
                        //登入成功,需紀錄
                        SL.EndDateTime = DateTime.Now;
                        SL.SuccessCount = 1;
                        SL.FailCount = 0;
                        SL.Msg = "登入成功";
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                        Session["UseCertLogin"] = UseCertLogin;
                        //Session["UseCertLogin"] = true;
                        Session["UserID"] = model.UserID;
                        //Session["UserID"] = "TAS191";
                        int UserRole= SF.getUserRole(model.UserID);
                        Session["UserRole"] = UserRole;

                        //主管導向覆核頁面
                        if (UserRole > 3)
                        {
                            return RedirectToAction("Index", "Review");
                        }
                        else
                        {
                            //導向檢查頁面
                            return RedirectToAction("Index", "Process");
                        }
                    }
                    else
                    {
                        //string a=VA.ResultStr;

                        //登入失敗,需記錄錯誤
                        SL.EndDateTime = DateTime.Now;
                        SL.FailCount = 1;
                        if (UseCertLogin)
                        {
                            SL.Msg = "登入失敗,錯誤訊息:[AD或VA驗證失敗]";
                        }
                        else
                        {
                            SL.Msg = "登入失敗,錯誤訊息:[AD驗證失敗]";
                        }
                        SL.Result = false;
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                        TempData["LoginMsg"] = SL.Msg;

                        return RedirectToAction("Login", "Account");
                    }
                }
                else
                {
                    TempData["LoginMsg"] = "登入失敗,錯誤訊息:[系統登入參數遺失]";
                    return RedirectToAction("Login", "Account");
                }
            }
            else
            {
                return RedirectToAction("Login", "Account");
            }
        }
Beispiel #24
0
        public ActionResult AddItem(int CheckID, string Title)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Document";
            SL.Action = "AddItem";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                vCHECKLIST_Manage VCTM = new vCHECKLIST_Manage();
                VCTM.CheckID = CheckID;
                VCTM.CheckTitle = Title;
                TempData["Title"] = Title;

                //取得班別清單
                var query1 = from s in context.CHECKSHIFTS
                             select new
                             {
                                 s.ShiftID,
                                 s.ShiftValue
                             };

                VCTM.ShiftIDList = new SelectList(query1, "ShiftID", "ShiftValue");

                //取得分類清單
                var query2 = from c in context.CHECKCLASSES
                             select new
                             {
                                 c.ClassID,
                                 c.ClassValue
                             };

                VCTM.ClassIDList = new SelectList(query2, "ClassID", "ClassValue");

                //取得負責人清單
                var query = from u in context.EPSUSERS
                            select new
                            {
                                u.UId,
                                u.UserName
                            };

                VCTM.ChargerList = new SelectList(query, "UId", "UserName");
                VCTM.AlwaysShow = true;
                VCTM.StartTime = "00:00";
                VCTM.EndTime = "24:00";
                VCTM.ShowOrder = getShowOrder(CheckID);

                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 0;
                SL.SuccessCount = 0;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "建立檢核項目表單作業成功";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

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

                TempData["CreateMsg"] = "<script>alert('發生異常');</script>";

                return RedirectToAction("Create", "Document");
            }
        }
Beispiel #25
0
        public ActionResult Create(vEPSUSER_Manage VUM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Account";
            SL.Action = "Create";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                if (ModelState.IsValid)
                {
                    EPSUSER U = new EPSUSER();
                    U.UId = VUM.UId;
                    U.UserName = VUM.UserName;
                    U.UserPwd = VUM.UserPwd;
                    U.UserEmail = VUM.UserEmail;
                    U.RId = VUM.RId;
                    U.CreateAccount = Session["UserID"].ToString().Trim();
                    U.CreateTime = DateTime.Now;
                    U.UpadteAccount = Session["UserID"].ToString().Trim();
                    U.UpdateTime = DateTime.Now;

                    context.EPSUSERS.Add(U);
                    context.SaveChanges();

                    SL.SuccessCount = 1;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "建立使用者作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    //TempData["CreateMsg"] = "<script>alert('新增成功');</script>";

                    return RedirectToAction("Index", "Account");
                }
                else
                {
                    TempData["CreateMsg"] = "<script>alert('新增失敗');</script>";

                    return RedirectToAction("Create", "Account");
                }
            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 0;
                SL.FailCount = 1;
                SL.Result = false;
                SL.Msg = "建立使用者作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["CreateMsg"] = "<script>alert('發生異常');</script>";

                return RedirectToAction("Create", "Account");
            }
        }
Beispiel #26
0
        public ActionResult EditItem(vCHECKLIST_Manage VCLM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Document";
            SL.Action = "EditItem";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                if (ModelState.IsValid)
                {
                    CHECKLIST nowCL = context.CHECKLISTS.Find(VCLM.ListID);
                    //nowCL.ListID = CL.ListID;
                    nowCL.CheckID = VCLM.CheckID;
                    nowCL.ListName = VCLM.ListName;
                    nowCL.Definition = VCLM.Definition;
                    nowCL.StartTime = VCLM.StartTime;
                    nowCL.EndTime = VCLM.EndTime;
                    nowCL.ShiftID = VCLM.ShiftID;
                    nowCL.ClassID = VCLM.ClassID;
                    nowCL.CheckType = VCLM.CheckType;
                    nowCL.AlwaysShow = VCLM.AlwaysShow;
                    nowCL.ChargerID = VCLM.ChargerID;
                    nowCL.ShowOrder = VCLM.ShowOrder;
                    nowCL.UpadteAccount= Session["UserID"].ToString().Trim(); ;
                    nowCL.UpdateTime = DateTime.Now;

                    context.Entry(nowCL).State = EntityState.Modified;
                    context.SaveChanges();

                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = 1;
                    SL.SuccessCount = 1;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "編輯檢核項目作業成功,ListID:[" + VCLM.ListID + "]";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    //string Title = context.CHECKTITLES.Find(VCLM.CheckID).Title;

                    return RedirectToAction("ListItem", "Document",new { CheckID = VCLM.CheckID, Title = VCLM.CheckTitle });

                }
                else
                {
                    TempData["EditMsg"] = "<script>alert('編輯失敗');</script>";

                    return RedirectToAction("EditItem", "Document", new { ListID = VCLM.ListID });
                }
            }
            catch (Exception ex)
            {

                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 0;
                SL.FailCount = 1;
                SL.Result = false;
                SL.Msg = "編輯檢核項目作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["EditMsg"] = "<script>alert('發生異常');</script>";

                return RedirectToAction("EditItem", "Document", new { ListID = VCLM.ListID });
            }
        }
Beispiel #27
0
        public void emailNotify2ReviewbyDate(string CloseStatus, string UId,
                                             string CheckDate,string Action)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = UId;
            SL.Controller = "Process";
            SL.Action = "emailNotify2ReviewerbyDate";
            SL.StartDateTime = DateTime.Now;

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

            DateTime parsed;
            string parsedTime = "取得檢核件時間錯誤";
            if (DateTime.TryParseExact(CheckDate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
            {
                parsedTime = parsed.ToString("yyyy-MM-dd");
            }

            try
            {

                var query = context.REVIEWPROFILES.Where(b => b.CloseStauts == CloseStatus).ToList();
                if (query.Count() > 0)
                {
                    foreach (var item in query)
                    {
                        MAILTEMPLATE MT = context.MAILTEMPLATES.Find(item.MailTempID);

                        if (MT != null)
                        {
                            MAILSERVER MS = context.MAILSERVERS.Find(MT.MailServerID);
                            if (MS != null)
                            {
                                string TmpRole = item.NextReviews;
                                string[] TmpRoles = TmpRole.Split(',');
                                int[] Roles = new int[TmpRoles.Count()];
                                if (TmpRoles.Count() > 0)
                                {
                                    int i = 0;
                                    foreach (var R in TmpRoles)
                                    {
                                        Roles[i] = int.Parse(R);
                                        i++;
                                    }

                                    var queryUsers = context.EPSUSERS.Where(b => Roles.Contains(b.RId)).ToList();
                                    if (queryUsers.Count() > 0)
                                    {
                                        StringBuilder UserNameb = new StringBuilder();
                                        StringBuilder UserEmailb = new StringBuilder();
                                        string UserName = "";
                                        string UserEmail = "";
                                        foreach (var U in queryUsers)
                                        {
                                            UserNameb.Append(U.UserName + Configer.SplitSymbol);
                                            UserEmailb.Append(U.UserEmail + Configer.SplitSymbol);
                                        }
                                        UserName = StringProcessor.CutlastChar(UserNameb.ToString());
                                        UserEmail = StringProcessor.CutlastChar(UserEmailb.ToString());
                                        //組合通知信標頭
                                        string MailSubject = MT.Subject.Replace("#Time", parsedTime)
                                                  .Replace("#Action", Action);
                                        //組合通知信內容
                                        string MailBody = "";
                                        string HtmlBody = "";
                                        HtmlBody = "<table border=1 with='80%'>";
                                        HtmlBody += "<tr><td>檢核編號</td>";
                                        HtmlBody += "<td>表單名稱</td>";
                                        HtmlBody += "<td>早班</td>";
                                        HtmlBody += "<td>晚班</td>";
                                        HtmlBody += "<td>假日班</td></tr>";

                                        var cps = context.CHECKPROCESSES.Where(b => b.CheckDate == CheckDate).ToList();

                                        foreach (var cp in cps)
                                        {
                                            HtmlBody += "<tr>";
                                            HtmlBody += "<td>" + cp.CheckSN + "</td>";
                                            CHECKTITLE ct = context.CHECKTITLES.Find(cp.CheckID);
                                            HtmlBody += "<td>" + ct.Definition + "</td>";
                                            if (cp.ShiftOne == "")
                                            {
                                                HtmlBody += "<td>N/A</td>";
                                            }
                                            else {
                                                HtmlBody += "<td>" + cp.ShiftOne + "</td>";
                                            }
                                            if (cp.ShiftThree == "")
                                            {
                                                HtmlBody += "<td>N/A</td>";
                                            }
                                            else {
                                                HtmlBody += "<td>" + cp.ShiftThree + "</td>";
                                            }
                                            if (cp.ShiftFour == "")
                                            {
                                                HtmlBody += "<td>N/A</td>";
                                            }
                                            else {
                                                HtmlBody += "<td>" + cp.ShiftFour + "</td>";
                                            }

                                            MailBody += "</tr>";
                                        }
                                        HtmlBody += "</table>";
                                        MailBody = MT.Body.Replace("#UserName", UserName)
                                                          .Replace("#Body", HtmlBody)
                                                          .Replace("#Link", "<a href='" + Configer.SystemURL + "'>機房表單系統連結</a>");

                                        char[] s = { ',' };
                                        List<string> Receivers = StringProcessor.SplitString2Array(UserEmail, s);

                                        //寄信
                                        string SendResult = SendEmail(MS.ServerIP, MS.ServerPort, MT.Sender, Receivers, MailSubject, MailBody);
                                        if (SendResult == "success")
                                        {
                                            SL.EndDateTime = DateTime.Now;
                                            SL.TotalCount = query.Count();
                                            SL.SuccessCount = query.Count();
                                            SL.FailCount = 0;
                                            SL.Result = true;
                                            SL.Msg = "通知[" + parsedTime + "]覆核人流程作業成功";
                                            log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                                        }
                                        else
                                        {
                                            //寄信失敗
                                            SL.EndDateTime = DateTime.Now;
                                            SL.TotalCount = 0;
                                            SL.SuccessCount = 0;
                                            SL.FailCount = 0;
                                            SL.Result = true;
                                            SL.Msg = "通知[" + parsedTime + "]覆核人流程作業失敗," + "錯誤訊息[" + SendResult + "]";
                                            log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                                        }
                                    }
                                    else
                                    {
                                        //沒有角色
                                        SL.EndDateTime = DateTime.Now;
                                        SL.TotalCount = 0;
                                        SL.SuccessCount = 0;
                                        SL.FailCount = 0;
                                        SL.Result = true;
                                        SL.Msg = "通知[" + parsedTime + "]覆核人流程作業失敗,沒有設定角色";
                                        log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                                    }
                                }
                                else
                                {
                                    //沒有設定MAILSERVER
                                    SL.EndDateTime = DateTime.Now;
                                    SL.TotalCount = 0;
                                    SL.SuccessCount = 0;
                                    SL.FailCount = 0;
                                    SL.Result = true;
                                    SL.Msg = "通知[" + parsedTime + "]覆核人流程作業失敗,沒有設定MAILSERVER";
                                    log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                                }
                            }
                            else
                            {
                                //沒有設定MAILTEMPLATE
                                SL.EndDateTime = DateTime.Now;
                                SL.TotalCount = 0;
                                SL.SuccessCount = 0;
                                SL.FailCount = 0;
                                SL.Result = true;
                                SL.Msg = "通知[" + parsedTime + "]覆核人流程作業失敗,沒有設定MAILTEMPLATE";
                                log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                            }
                        }
                    }
                }
                else
                {
                    //沒有設定REVIEWPROFILE
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = 0;
                    SL.SuccessCount = 0;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "通知[" + parsedTime + "]覆核人流程作業失敗,沒有設定REVIEWPROFILE";
                    log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                }

            }
            catch (Exception ex)
            {
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 0;
                SL.SuccessCount = 0;
                SL.FailCount = 0;
                SL.Result = false;
                SL.Msg = "通知[" + parsedTime + "]覆核人流程作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
            }
        }
Beispiel #28
0
        public ActionResult ListItem(int CheckID, string Title)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Document";
            SL.Action = "ListItem";
            SL.TotalCount = 1;
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                TempData["CheckID"] = CheckID;
                TempData["Title"] = Title;
                var query = from cl in context.CHECKLISTS
                            where cl.CheckID == CheckID
                            orderby cl.ShowOrder descending
                            join cs in context.CHECKSHIFTS on cl.ShiftID equals cs.ShiftID
                            join c in context.CHECKCLASSES on cl.ClassID equals c.ClassID
                            join u in context.EPSUSERS on cl.ChargerID equals u.UId into x
                            from y in x.DefaultIfEmpty()
                            select new vCHECKLIST
                            {
                                ListID = cl.ListID,
                                CheckID=cl.CheckID,
                                ListName=cl.ListName,
                                Definition=cl.Definition,
                                StartTime=cl.StartTime,
                                EndTime=cl.EndTime,
                                ShiftName=cs.ShiftValue,
                                ClassName=c.ClassValue,
                                Charger=y.UserName,
                                AlwaysShow=cl.AlwaysShow,
                                ShowOrder=cl.ShowOrder,
                                CreateAccount = cl.CreateAccount,
                                CreateTime = cl.CreateTime,
                                UpadteAccount = cl.UpadteAccount,
                                UpdateTime = cl.UpdateTime
                            };

                if (query.Count() > 0)
                {
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = query.Count();
                    SL.SuccessCount = query.Count();
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得檢核項目清單作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return View(query.ToList());
                }
                else
                {
                    SL.EndDateTime = DateTime.Now;
                    SL.TotalCount = 0;
                    SL.SuccessCount = 0;
                    SL.FailCount = 0;
                    SL.Result = true;
                    SL.Msg = "取得檢核項目清單作成功" + "訊息["+ Title + "文件內尚未有檢核項目]";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return RedirectToAction("Index", "Dcoument");
                }
            }
            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 RedirectToAction("Index", "Dcoument");
            }
        }
Beispiel #29
0
        /// <summary>
        /// 將執行結果寫入資料庫
        /// </summary>
        /// <param name="_OPLogger">OPLoger類別</param>
        /// <remarks>2014/03/04 黃富彥</remarks>
        public void log2DB(SYSTEMLOG _SL, 
                           string _MailServer, 
                           int _MailServerPort, 
                           string _MailSender, 
                           List<string> _MailReceiver)
        {
            SYSTEMLOG SL = _SL;
            string MailServer = _MailServer;
            int MailServerPort = _MailServerPort;
            string MailSender = _MailSender;
            List<string> MailReceiver = _MailReceiver;
            string MailSubject = string.Empty;
            StringBuilder MailBody = new StringBuilder();
            string SendResult = string.Empty;

            try
            {
                using (EPSContext context =new EPSContext())
                {
                    context.SYSTEMLOG.Add(SL);
                    context.SaveChanges();

                    //寫入文字檔Log
                    logandshowInfo("[" + SL.UId + "]執行[寫入資料庫紀錄作業]成功", log_Info);
                }
            }
            catch (Exception ex)
            {
                //異常
                //寫入文字檔Log
                logandshowInfo("[" + SL.UId + "]執行[寫入資料庫紀錄作業]發生未預期的異常,請查詢Debug Log得到詳細資訊", log_Info);
                logandshowInfo("[" + SL.UId + "]執行[寫入資料庫紀錄作業]發生未預期的異常,詳細資訊如下", log_Err);
                logandshowInfo("執行人:[" + SL.UId + "]", log_Err);
                logandshowInfo("執行模組名稱:[" + SL.Controller + "]", log_Err);
                logandshowInfo("執行作業名稱:[" + SL.Action + "]", log_Err);
                logandshowInfo("處理結果:[" + SL.Result.ToString() + "]", log_Err);
                logandshowInfo("起始時間:[" + SL.StartDateTime.ToString() + "]", log_Err);
                logandshowInfo("結束時間:[" + SL.EndDateTime.ToString() + "]", log_Err);
                logandshowInfo("處理總筆數:[" + SL.TotalCount.ToString() + "]", log_Err);
                logandshowInfo("處理成功筆數:[" + SL.SuccessCount.ToString() + "]", log_Err);
                logandshowInfo("處理失敗筆數:[" + SL.FailCount.ToString() + "]", log_Err);
                logandshowInfo("作業訊息:[" + SL.Msg + "]", log_Err);
                logandshowInfo("錯誤訊息:[" + ex.ToString() + "]", log_Err);

                //通知系統管理人員
                MailSubject = "[異常]機房電子表單系統-執行[寫入資料庫紀錄作業]失敗";
                MailBody.Append("<table>");
                MailBody.Append("<tr><td>");
                MailBody.Append("執行人:[" + SL.UId + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("執行模組名稱:[" + SL.Controller + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("執行作業名稱:[" + SL.Action + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("處理結果:[" + SL.Result.ToString() + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("起始時間:[" + SL.StartDateTime.ToString() + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("結束時間:[" + SL.EndDateTime.ToString() + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("處理總筆數:[" + SL.TotalCount.ToString() + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("處理成功筆數:[" + SL.SuccessCount.ToString() + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("處理失敗筆數:[" + SL.FailCount.ToString() + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("作業訊息:[" + SL.Msg + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("<tr><td>");
                MailBody.Append("錯誤訊息:[" + ex.ToString() + "]");
                MailBody.Append("</td></tr>");
                MailBody.Append("</table>");

                EmailNotify2Sys(MailServer, MailServerPort, MailSender, MailReceiver, false, MailSubject, MailBody.ToString());
            }
        }
Beispiel #30
0
        // GET: Role/Edit
        public ActionResult Edit(int RId)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = Session["UserID"].ToString();
            SL.Controller = "Role";
            SL.Action = "Edit";
            SL.StartDateTime = DateTime.Now;

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

            try
            {
                vEPSROLE_Manage VRM = new vEPSROLE_Manage();
                EPSROLE R = context.EPSROLES.Find(RId);

                VRM.RId = RId;
                VRM.RoleName = R.RoleName;
                //取得系統提供之所有權限
                var query = from f in context.FUNCS
                            select new
                            {
                                f.FId,
                                f.FuncName
                            };

                VRM.Funcs = new SelectList(query, "FId", "FuncName");
                //取得目前角色擁有的權限
                var query1 = from rm in context.ROLEFUNCMAPPINGS
                             where rm.RId == RId
                             select new
                             {
                                rm.FId
                             };
                List<int> TmpList= new List<int>();
                foreach (var item in query1)
                {
                    TmpList.Add(item.FId);
                }

                VRM.FuncList = TmpList.ToArray();
                SL.EndDateTime = DateTime.Now;
                SL.TotalCount = 1;
                SL.SuccessCount = 1;
                SL.FailCount = 0;
                SL.Result = true;
                SL.Msg = "取得角色資料作業成功,RId:[" + RId.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return View(VRM);
            }
            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 RedirectToAction("Index", "Role");
            }
        }