public ActionResult loginAccount(LoginUserModel model)
        {
            var dao = new AccountDao();

            if (ModelState.IsValid)
            {
                var res = dao.Login(model.UserID.Trim(), model.PassWord);
                if (res == 1)
                {
                    var userSession = new UserLogin();
                    //var checkAu = dao.Login2(tes);

                    var user = dao.GetByID(model.UserID.Trim());
                    userSession.UserID   = user.UserID.Trim();
                    userSession.UserName = user.Username;
                    string idUser = user.UserID.Trim();


                    PostmanService.PostmanServiceSoapClient postman = new PostmanService.PostmanServiceSoapClient();
                    DataTable tb = new DataTable();
                    tb = postman.GetEmpInfomation(idUser);
                    string   depart     = tb.Rows[0]["CURRENT_OU_NAME"].ToString();
                    string   costCode   = tb.Rows[0]["CURRENT_OU_CODE"].ToString();
                    string   mailUs     = tb.Rows[0]["NOTES_ID"].ToString();
                    DateTime checkLeave = DateTime.Parse(tb.Rows[0]["LEAVEDAY"].ToString());
                    DateTime timeCheck  = DateTime.Now;
                    if (timeCheck > checkLeave.AddMinutes(5))
                    {
                        string kq = " da nghi";
                    }
                    userSession.Department = depart;
                    userSession.CostCode   = costCode;
                    userSession.Mail       = mailUs;

                    Session.Add(CommonConstants.USER_SESSION, userSession);

                    return(RedirectToAction("WaitingForYourApproval", "APP_ESIGN", new { area = "Employee" }));
                }
                else
                {
                    var checkAu = dao.Login2(model.UserID.Trim());
                    if (checkAu == 0)
                    {
                        Session["errorLog"] = "Ban khong co quyen vao he thong vui long lien he IT!";
                        return(RedirectToAction("Index", "ErrorPage", new { area = "" }));
                    }
                }
            }
            return(View("Index"));
        }
예제 #2
0
        // gui mail cho nguoi dung
        public bool insertSenmail1(string empNo, string orderNo, string conten, string appliCant, string notes, string mail)
        {
            try
            {
                PostmanService.PostmanServiceSoapClient postman = new PostmanService.PostmanServiceSoapClient();
                DataTable tableEmp = postman.GetEmpInfomation(empNo);
                string    userName = tableEmp.Rows[0]["USER_NAME"].ToString();
                string    mailTo   = mail.Trim();

                Random newRan = new Random();
                int    num    = newRan.Next(1, 1000);
                string ran    = Convert.ToString(num);
                string id     = DateTime.Now.ToString("yyyyMMddHHmmss") + ran;

                DataTable tableEmp2 = postman.GetEmpInfomation(appliCant);
                string    userName2 = tableEmp2.Rows[0]["USER_NAME"].ToString();
                string    copyto    = "";
                if (mailTo.Equals(""))
                {
                    mailTo = nCode.getMailAccount(empNo);
                    if (mailTo != null || mailTo != "")
                    {
                        mailTo = tableEmp.Rows[0]["NOTES_ID"].ToString();
                        if (mailTo.Equals(""))
                        {
                            mailTo = ",";
                        }
                    }
                }

                string conte = conten;

                string fla       = "0";
                string mailTitle = userName + " , 您好, 《Esign-system 2.0》" + notes + "! 單據名稱:" + conte + ", 申請人: " + userName2 + " ,申請單號:" + orderNo;
                string mailBody1 = "\n《Esign-system 2.0》文件電子簽核申請信息,申請單號: " + orderNo;
                string mailBody2 = "系統網址(web site): https://appvn3.foxconn.com/";
                string mailBody3 = "\n單據簽核連接(web site of approve): https://appvn3.foxconn.com/Employee/ApplicationIT/formSign?appNo=" + orderNo;
                string mailBody4 = "\n";
                string mailBody5 = @"\n基本操作說明(Basic operating instructions):
1.點擊系統網址後會出現登錄畫面(使用域帳號登錄[開機帳號 + 開機密碼]).
 --enter the login page, key in your computer account / your computer password.
2.進入系統界面後,即可選擇申請單號進行簽核.

--login system select apply number to approve.
3.若沒有賬號請先註冊您的賬號,待審核審核通過即可登錄使用.
--If you don't have an account, please register your account first, and you can login to use after being approved.
基本操作說明:
                1.點擊系統網址後會出現登錄畫面()
     (1)若沒有手動註冊過,則初始賬號和密碼均為工號,該頁面權限已自動開通,無需聯繫系統管理員
     (2)若無法登錄,請注意查看系統提示信息,詳情如下:
         a)若提示沒有賬號,則請自行註冊(若有[新版]和[舊版],請點擊[舊版]進行註冊),註冊成功后再郵件通知系統管理員去開通權限或註冊時自動選擇相應權限(步驟:點擊[自助選擇權限]--》彈出的頁面中選擇相應權限)
         b)若提示沒有權限,則請郵件通知系統管理員去開通權限
         c)若提示密碼不對,則請重置開機密碼
         c)若提示賬號被鎖,則請點擊[忘記密碼] 自行解鎖
    2.進入系統界面後﹐即可選擇申請單號.
    3.系統管理員聯繫方式在系統登錄頁面,請自行查找(若有[新版]和[舊版],請點擊[舊版]進行查找).
";
                string mailBody6 = "IT聯絡信息 (Ext:535-27847/27123 Mail:[email protected])";
                string mailBody  = string.Format(@"{0}
{1}
{2} 
{3} 
{4} 
{5}
{6}", mailBody1.PadLeft(4), mailBody2.PadLeft(4), mailBody3.PadLeft(4), mailBody4.PadLeft(4), mailBody5.PadLeft(4), mailBody6.PadLeft(4), DateTime.Now.ToString().PadLeft(4));
                string title2    = mailTitle;

                string sqlQuery = @"insert into sendm(id,sendto,copyto,title,body,flag) values (@id,@sendto,@copyto,N'" + title2 + "',@body,@flag) ;";

                SqlParameter[] param = new SqlParameter[5];

                param.SetValue(new SqlParameter("id", id), 0);
                param.SetValue(new SqlParameter("sendto", mailTo), 1);
                param.SetValue(new SqlParameter("copyto", copyto), 2);

                param.SetValue(new SqlParameter("body", mailBody), 3);
                param.SetValue(new SqlParameter("flag", fla), 4);

                bool kr = sqlDB.ExcuteNonQuery(sqlQuery, param);

                return(kr);
            }
            catch
            {
                return(false);
            }
        }
        public ActionResult Callback()
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}
            if (Request.Params["error"] != null)
            {
                return(RedirectToAction("Index", "ErrorPage", new { area = "" }));
            }
            else if (Request.Params["code"] != null)
            {
                OAuthContext.Current.RequestToken(Request.Params["code"]);
                Dictionary <string, string> profile = OAuthContext.Current.profile;
                if (profile != null)
                {
                    if (Request.Params["state"] != null && Request.Params["state"].IndexOf("ReturnUrl=/") >= 0)
                    {
                        FormsAuthentication.SetAuthCookie(profile["username"] + '.' + profile["org"], false);

                        Response.Redirect(Request.Params["state"].Substring(11), true);
                    }
                    else
                    {
                        var dao = new AccountDao();
                        var tes = profile["username"].ToString();

                        DataTable tb = new DataTable();
                        tb = postman.GetEmpInfomation(tes);
                        DateTime checkLeave = DateTime.Parse(tb.Rows[0]["LEAVEDAY"].ToString());
                        DateTime timeCheck  = DateTime.Now;
                        if (timeCheck > checkLeave.AddMinutes(5))
                        {
                            return(RedirectToAction("CallBack", "Callback", new { area = " " }));
                        }
                        var userSession = new UserLogin();
                        // var checkAu = dao.Login2(tes);
                        //if(checkAu == 0)
                        //{
                        //    Session["errorLog"] = "Ban khong co quyen vao he thong vui long lien he IT!";
                        //    return RedirectToAction("Index", "ErrorPage", new { area = "" });
                        //}
                        string name = tb.Rows[0]["USER_NAME"].ToString();
                        //var user = dao.GetByID(tes);
                        userSession.UserID   = tes;
                        userSession.UserName = name;
                        //string idUser = user.UserID.Trim();


                        //PostmanService.PostmanServiceSoapClient postman = new PostmanService.PostmanServiceSoapClient();

                        string depart   = tb.Rows[0]["CURRENT_OU_NAME"].ToString();
                        string costCode = tb.Rows[0]["CURRENT_OU_CODE"].ToString();
                        string mailUs   = tb.Rows[0]["NOTES_ID"].ToString();
                        userSession.Department = depart;
                        userSession.CostCode   = costCode;
                        userSession.Mail       = mailUs;

                        Session.Add(CommonConstants.USER_SESSION, userSession);

                        return(RedirectToAction("WaitingForYourApproval", "APP_ESIGN", new { area = "Employee" }));
                    }
                }
                else
                {
                    return(RedirectToAction("Index", "ErrorPage", new { area = "" }));
                }
            }
            else
            {
                OAuthContext.Current.BeginAuth(Request.QueryString.ToString());
            }

            return(View());

            //FormsAuthentication.SetAuthCookie(profile["username"] + '.' + profile["org"], false);
            //Dictionary<string, string> profile = OAuthContext.Current.profile;
        }
        // [OutputCache(Location = System.Web.UI.OutputCacheLocation.Server, Duration = 3600 * 24, VaryByParam = "None")]
        public ActionResult FORM_IT_01()
        {
            FORM_IT_01Model formIT01 = new FORM_IT_01Model();
            var             formID   = "FORM_IT_01";
            var             newCode  = new NewCode();

            if (formID == null)
            {
                return(RedirectToAction(""));
            }


            formIT01.FormID = newCode.getFormID(formID);
            string    sqlQuery  = @"select * from TitleForm where FormID = '" + formIT01.FormID + "'";
            DataTable dataTitle = new DataTable();

            dataTitle = dbHelpers.DoSQLSelect(sqlQuery);
            string titleBu = "";
            string titleEx = "";

            if (dataTitle.Rows.Count > 0)
            {
                for (int i = 0; i < dataTitle.Rows.Count; i++)
                {
                    titleBu += dataTitle.Rows[i]["FormContent"].ToString() + ";";
                    titleEx += dataTitle.Rows[i]["Example"].ToString() + ";";
                }
            }

            // gan gia tri cho list signer
            string    sqlQuery1     = @"select * from SubmitSign where FormID = '" + formIT01.FormID + "' order by SignNo asc";
            DataTable tbSignProcess = new DataTable();

            tbSignProcess = dbHelpers.DoSQLSelect(sqlQuery1);
            string signEm   = "";
            string SignNa   = "";
            string statusNa = "";
            int    step1    = 0;
            //string agent = "";
            List <ApprovalAppModel> listAppro = new List <ApprovalAppModel>();


            if (tbSignProcess.Rows.Count > 0)
            {
                for (int i = 0; i < tbSignProcess.Rows.Count; i++)
                {
                    step1    = i;
                    statusNa = tbSignProcess.Rows[i]["SignName"].ToString();

                    listAppro.Add(new ApprovalAppModel
                    {
                        step       = step1,
                        statusName = statusNa,
                        signEmpNo  = "",
                        SignName   = ""
                    });
                }
            }

            formIT01.approvalApps = listAppro;
            // gan gia tri  cho title
            string[] titleList = titleBu.Split(';');

            formIT01.Title0 = titleList[0];
            formIT01.Title1 = titleList[1];
            formIT01.Title2 = titleList[2];
            formIT01.Title3 = titleList[3];
            formIT01.Title4 = titleList[4];

            formIT01.Title5 = titleList[5];
            formIT01.Title6 = titleList[6];
            formIT01.Title7 = titleList[7];
            formIT01.Title8 = titleList[8];
            formIT01.Title9 = titleList[9];

            formIT01.Title10 = titleList[10];
            formIT01.Title11 = titleList[11];
            formIT01.Title12 = titleList[12];
            formIT01.Title13 = titleList[13];
            formIT01.Title14 = titleList[14];

            formIT01.Title15 = titleList[15];
            formIT01.Title16 = titleList[16];
            formIT01.Title17 = titleList[17];
            formIT01.Title18 = titleList[18];
            formIT01.Title19 = titleList[19];

            formIT01.Title20 = titleList[20];
            formIT01.Title21 = titleList[21];
            formIT01.Title22 = titleList[22];
            formIT01.Title23 = titleList[23];
            formIT01.Title24 = titleList[24];

            formIT01.Title25 = titleList[25];

            formIT01.Title26 = titleList[26];

            string[] exampleList = titleEx.Split(';');
            formIT01.Title0Example = exampleList[0];
            formIT01.Title1Example = exampleList[1];
            formIT01.Title5Example = exampleList[5];
            formIT01.Title7Example = exampleList[7];
            formIT01.Title8Example = exampleList[8];

            formIT01.Title10Example = exampleList[10];
            formIT01.Title11Example = exampleList[11];
            formIT01.Title12Example = exampleList[12];
            formIT01.Title13Example = exampleList[13];
            formIT01.Title14Example = exampleList[14];
            formIT01.Title15Example = exampleList[15];
            formIT01.Title16Example = exampleList[16];
            formIT01.Title17Example = exampleList[17];

            formIT01.Title26Example = exampleList[26];



            var session = (UserLogin)Session[CommonConstants.USER_SESSION];

            formIT01.Title3Content = session.UserName.ToString();
            formIT01.Title4Content = session.UserID.ToString();

            PostmanService.PostmanServiceSoapClient postman = new PostmanService.PostmanServiceSoapClient();
            DataTable tbPost = new DataTable();

            tbPost = postman.GetEmpInfomation(formIT01.Title4Content.Trim());

            formIT01.Title17Content = tbPost.Rows[0]["NOTES_ID"].ToString();
            formIT01.Title1Content  = tbPost.Rows[0]["CURRENT_OU_NAME"].ToString();
            if (formIT01.Title17Content == null || formIT01.Title17Content == "")
            {
                formIT01.Title17Content = "";
            }
            //formIT01.titleName = titleList;
            setViewFac();
            var a = titleList.Count();

            return(View(formIT01));
        }