コード例 #1
0
ファイル: CodeUserDao.cs プロジェクト: BiancoLee/BETA
        /**
         * 查詢出所有使用者資料(for畫面下拉選單使用)
         **/
        public SelectList loadSelectList()
        {
            dbTreasuryEntities context = new dbTreasuryEntities();

            List <UserMgrModel> result1 = (from user in context.CODE_USER
                                           select new UserMgrModel
            {
                cUserID = user.USER_ID.Trim()
            }
                                           ).ToList();


            OaEmpDao oaEmpDao = new OaEmpDao();

            using (DB_INTRAEntities dbIntra = new DB_INTRAEntities())
            {
                foreach (UserMgrModel user in result1)
                {
                    try
                    {
                        user.cUserName = user.cUserID + " " + StringUtil.toString(oaEmpDao.qryByUsrId(user.cUserID, dbIntra).EMP_NAME);
                    }
                    catch (Exception e)
                    {
                    }
                }
            }



            var items = new SelectList
                        (
                items: result1,
                dataValueField: "cUserID",
                dataTextField: "cUserName",
                selectedValue: (object)null
                        );


            return(items);
        }
コード例 #2
0
ファイル: UserMgrController.cs プロジェクト: BiancoLee/BETA
        /// <summary>
        /// 取中文姓名
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public ActionResult getUserName(string userId)
        {
            string   userName = "";
            OaEmpDao oaEmpDao = new OaEmpDao();
            V_EMPLY2 emp      = new V_EMPLY2();

            using (DB_INTRAEntities dbIntra = new DB_INTRAEntities())
            {
                emp = oaEmpDao.qryByUsrId(userId, dbIntra);
                if (emp != null)
                {
                    userName = StringUtil.toString(emp.EMP_NAME);
                }
            }

            if ("".Equals(userName))
            {
                return(Json(new { success = false, err = "無此帳號資料,不可新增!!" }));
            }
            else
            {
                return(Json(new { success = true, userName = userName }));
            }
        }
コード例 #3
0
        ///// <summary>
        ///// 開啟使用者修改明細畫面
        ///// </summary>
        ///// <param name="aplyNo"></param>
        ///// <returns></returns>
        //public ActionResult detailUser(string cReviewSeq)
        //{
        //    try
        //    {
        //        using (DbAccountEntities db = new DbAccountEntities())
        //        {
        //            CodeUserHisDao codeUserHisDao = new CodeUserHisDao();
        //            AuthReviewUserModel userData = codeUserHisDao.qryByNowHis(cReviewSeq, db);

        //            string[] cDateTime = userData.cCrtDateTime.Split(' ');
        //            userData.cCrtDateTime = DateUtil.formatDateTimeDbToSc(cDateTime[0] + " " + cDateTime[1], "DT");

        //            ViewBag.bHaveData = "Y";
        //            ViewBag.cReviewSeq = cReviewSeq;
        //            return View(userData);
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        ViewBag.bHaveData = "N";
        //        return View();
        //    }
        //}


        /// <summary>
        /// 開啟使用者修改明細畫面
        /// </summary>
        /// <param name="aplyNo"></param>
        /// <returns></returns>
        public ActionResult detailUser(string aplyNo, string userId)
        {
            try
            {
                string      execAction  = "";
                AuthApprDao AuthApprDao = new AuthApprDao();

                AUTH_APPR authAppr = new AUTH_APPR();


                if (!"".Equals(StringUtil.toString(aplyNo)))
                {
                    authAppr      = AuthApprDao.qryByKey(aplyNo);
                    ViewBag.bView = "N";
                }

                else
                {
                    authAppr = AuthApprDao.qryByFreeRole(userId);
                    if (authAppr != null)
                    {
                        aplyNo = StringUtil.toString(authAppr.APLY_NO);
                    }

                    ViewBag.bView = "Y";
                }



                AuthReviewUserModel userData = new AuthReviewUserModel();
                userData.aplyNo    = aplyNo;
                userData.userId    = authAppr.APPR_MAPPING_KEY;
                userData.createUid = authAppr.CREATE_UID;

                OaEmpDao oaEmpDao = new OaEmpDao();
                using (DB_INTRAEntities dbIntra = new DB_INTRAEntities())
                {
                    try
                    {
                        userData.createUid = userData.createUid == null ? "" : StringUtil.toString(oaEmpDao.qryByUsrId(userData.createUid, dbIntra).EMP_NAME);
                        userData.userName  = userData.userId == null ? "" : StringUtil.toString(oaEmpDao.qryByUsrId(userData.userId, dbIntra).EMP_NAME);
                    }
                    catch (Exception e)
                    {
                    }
                }
                userData.createDt = authAppr.CREATE_DT.ToString();


                SysCodeDao sysCodeDao = new SysCodeDao();
                Dictionary <string, string> dicExecAction = sysCodeDao.qryByTypeDic("EXEC_ACTION");
                Dictionary <string, string> dicYNFlag     = sysCodeDao.qryByTypeDic("YN_FLAG");

                CodeUserHisDao codeUserHisDao = new CodeUserHisDao();
                CODE_USER_HIS  codeUserHis    = codeUserHisDao.qryByAplyNo(aplyNo);
                if (codeUserHis != null)
                {
                    execAction = StringUtil.toString(codeUserHis.EXEC_ACTION);
                }

                if ("".Equals(execAction))
                {
                    CodeUserDao codeUserDao = new CodeUserDao();
                    CODE_USER   codeUser    = new CODE_USER();
                    codeUser = codeUserDao.qryUserByKey(authAppr.APPR_MAPPING_KEY);

                    userData.isMailB     = StringUtil.toString(codeUser.IS_MAIL);
                    userData.isDisabledB = StringUtil.toString(codeUser.IS_DISABLED);
                    userData.memoB       = StringUtil.toString(codeUser.MEMO);
                }
                else
                {
                    if ("A".Equals(execAction))
                    {
                        userData.isMail     = StringUtil.toString(codeUserHis.IS_MAIL);
                        userData.isDisabled = StringUtil.toString(codeUserHis.IS_DISABLED);
                        userData.memo       = StringUtil.toString(codeUserHis.MEMO);
                    }
                    else
                    {
                        userData.isMail     = StringUtil.toString(codeUserHis.IS_MAIL);
                        userData.isDisabled = StringUtil.toString(codeUserHis.IS_MAIL);
                        userData.memo       = StringUtil.toString(codeUserHis.MEMO);

                        userData.isMailB     = StringUtil.toString(codeUserHis.IS_MAIL_B);
                        userData.isDisabledB = StringUtil.toString(codeUserHis.IS_DISABLED_B);
                        userData.memoB       = StringUtil.toString(codeUserHis.MEMO_B);
                    }
                }


                userData.execAction      = execAction;
                userData.execActionDesc  = dicExecAction.ContainsKey(userData.execAction) ? dicExecAction[userData.execAction] : userData.execAction;
                userData.isDisabledDesc  = dicYNFlag.ContainsKey(userData.isDisabled) ? dicYNFlag[userData.isDisabled] : userData.isDisabled;
                userData.isDisabledDescB = dicYNFlag.ContainsKey(userData.isDisabledB) ? dicYNFlag[userData.isDisabledB] : userData.isDisabledB;
                userData.isMailDesc      = dicYNFlag.ContainsKey(userData.isMail) ? dicYNFlag[userData.isMail] : userData.isMail;
                userData.isMailDescB     = dicYNFlag.ContainsKey(userData.isMailB) ? dicYNFlag[userData.isMailB] : userData.isMailB;



                ViewBag.bHaveData = "Y";
                ViewBag.aplyNo    = aplyNo;
                return(View(userData));
            }
            catch (Exception e)
            {
                ViewBag.bHaveData = "N";
                return(View());
            }
        }
コード例 #4
0
        /**
         * 角色資訊(含功能授權)
         **/
        public ActionResult detailRole(string cRoleId, string execType)
        {
            /*---畫面下拉選單初始值---*/

            //金庫設備
            TreaEquipDao treaEquipDao = new TreaEquipDao();

            ViewBag.equipList = treaEquipDao.jqgridSelect();

            //存取項目
            TreaItemDao treaItemDao = new TreaItemDao();

            ViewBag.itemList = treaItemDao.jqgridSelect("");

            SysCodeDao sysCodeDao = new SysCodeDao();

            //停用註記
            var isDisabledList = sysCodeDao.loadSelectList("IS_DISABLED");

            ViewBag.isDisabledList = isDisabledList;

            //角色群組
            var roleAuthTypeList = sysCodeDao.loadSelectList("ROLE_AUTH_TYPE");

            ViewBag.roleAuthTypeList = roleAuthTypeList;

            //控管模式
            var controlList = sysCodeDao.loadSelectList("CONTROL_MODE");

            ViewBag.controlList = controlList;
            //ViewBag.controlList = sysCodeDao.jqGridList("CONTROL_MODE");


            //控管方式
            var custodyList = sysCodeDao.loadSelectList("CUSTODY_MODE");

            ViewBag.custodyList = custodyList;
            //ViewBag.custodyList = sysCodeDao.jqGridList("CUSTODY_MODE");


            //入庫作業類型
            ViewBag.itemOpTypeList = sysCodeDao.jqGridList("ITEM_OP_TYPE");



            //覆核狀態  add by daiyu 20180214
            Dictionary <string, string> dicReview = sysCodeDao.qryByTypeDic("DATA_STATUS");



            //查詢角色資訊
            CodeRoleDao codeRoleDao = new CodeRoleDao();
            CODE_ROLE   codeRole    = new CODE_ROLE();

            if (cRoleId != null)
            {
                codeRole = codeRoleDao.qryRoleByKey(cRoleId);
            }



            //將值搬給畫面欄位
            RoleMgrModel roleMgrModel = new RoleMgrModel();

            qryUserFunc(cRoleId);  //取得已授權、未授權功能清單

            if (!"".Equals(StringUtil.toString(codeRole.ROLE_ID)))
            {
                roleMgrModel.cRoleID      = StringUtil.toString(codeRole.ROLE_ID);
                roleMgrModel.cRoleName    = StringUtil.toString(codeRole.ROLE_NAME);
                roleMgrModel.roleAuthType = StringUtil.toString(codeRole.ROLE_AUTH_TYPE);
                roleMgrModel.isDisabled   = StringUtil.toString(codeRole.IS_DISABLED);
                roleMgrModel.vMemo        = StringUtil.toString(codeRole.MEMO);
                roleMgrModel.dataStatus   = StringUtil.toString(codeRole.DATA_STATUS) == "" ? "" : codeRole.DATA_STATUS + "." + dicReview[codeRole.DATA_STATUS];

                roleMgrModel.cCrtDateTime = codeRole.CREATE_DT == null ? "" : DateUtil.DatetimeToString(codeRole.CREATE_DT, "");

                roleMgrModel.cUpdDateTime = codeRole.LAST_UPDATE_DT == null ? "" : DateUtil.DatetimeToString(codeRole.LAST_UPDATE_DT, "");

                OaEmpDao oaEmpDao = new OaEmpDao();
                using (DB_INTRAEntities dbIntra = new DB_INTRAEntities())
                {
                    try
                    {
                        roleMgrModel.cCrtUserID = codeRole.CREATE_UID == null ? "" : StringUtil.toString(oaEmpDao.qryByUsrId(codeRole.CREATE_UID, dbIntra).EMP_NAME);
                    }
                    catch (Exception e)
                    {
                    }

                    try
                    {
                        roleMgrModel.cUpdUserID = codeRole.LAST_UPDATE_UID == null ? "" : StringUtil.toString(oaEmpDao.qryByUsrId(codeRole.LAST_UPDATE_UID, dbIntra).EMP_NAME);
                    }
                    catch (Exception e)
                    {
                    }
                }


                roleMgrModel.Categories = ViewBag.funcList;

                ViewBag.bHaveData = "Y";
                //return RedirectToAction("Index", "Home");
                return(View(roleMgrModel));
            }
            else
            {
                if ("A".Equals(execType))
                {
                    qryUserFunc("");  //取得已授權、未授權功能清單

                    roleMgrModel.cRoleID      = "";
                    roleMgrModel.cRoleName    = "";
                    roleMgrModel.isDisabled   = "N";
                    roleMgrModel.vMemo        = "";
                    roleMgrModel.cCrtUserID   = "";
                    roleMgrModel.cCrtDateTime = "";
                    roleMgrModel.cUpdUserID   = "";
                    roleMgrModel.cUpdDateTime = "";
                    roleMgrModel.dataStatus   = "";

                    roleMgrModel.Categories = ViewBag.funcList;
                    ViewBag.bHaveData       = "Y";
                    return(View(roleMgrModel));
                }
                else
                {
                    ViewBag.bHaveData = "N";
                    return(View("detailRole"));
                }
            }
        }
コード例 #5
0
ファイル: CodeFuncDao.cs プロジェクト: BiancoLee/BETA
        /// <summary>
        /// 以功能編號為鍵項,查詢功能詳細資訊
        /// </summary>
        /// <param name="cFuncId"></param>
        /// <returns></returns>
        public FuncMgrDetailModel qryByKey(String cFuncId)
        {
            FuncMgrDetailModel funcMgrDetail = new FuncMgrDetailModel();

            using (new TransactionScope(
                       TransactionScopeOption.Required,
                       new TransactionOptions
            {
                IsolationLevel = IsolationLevel.ReadUncommitted
            }))
            {
                using (dbTreasuryEntities db = new dbTreasuryEntities())
                {
                    //codeFunction = db.CODEFUNCTION.Where(x => x.CFUNCTIONID == cFuncId).FirstOrDefault();

                    funcMgrDetail = (from main in db.CODE_FUNC
                                     join parent in db.CODE_FUNC on main.PARENT_FUNC_ID equals parent.FUNC_ID into psParent
                                     from xParent in psParent.DefaultIfEmpty()
                                     where main.FUNC_ID == cFuncId
                                     select new FuncMgrDetailModel
                    {
                        cFunctionID = main.FUNC_ID.Trim(),
                        cParentFunctionID = main.PARENT_FUNC_ID.Trim(),
                        cParentFunctionName = xParent.FUNC_NAME.Trim(),
                        cFunctionName = main.FUNC_NAME.Trim(),
                        cFunctionType = "",
                        iFunctionLevel = main.FUNC_LEVEL,
                        vFunctionMemo = main.FUNC_MEMO.Trim(),
                        vFunctionUrl = main.FUNC_URL.Trim(),
                        iSortBy = main.FUNC_ORDER,
                        cFlag = main.IS_DISABLED.Trim(),
                        cCrtUserID = main.CREATE_UID.Trim(),
                        cCrtUserName = "",
                        cCrtDate = main.CREATE_DT == null ? "" : SqlFunctions.DateName("year", main.CREATE_DT) + "/" +
                                   SqlFunctions.DatePart("m", main.CREATE_DT) + "/" +
                                   SqlFunctions.DateName("day", main.CREATE_DT).Trim() + " " +
                                   SqlFunctions.DateName("hh", main.CREATE_DT).Trim() + ":" +
                                   SqlFunctions.DateName("n", main.CREATE_DT).Trim() + ":" +
                                   SqlFunctions.DateName("s", main.CREATE_DT).Trim()
                        ,
                        // cCrtTime = main.CCRTTIME.Trim(),
                        cUpdUserID = main.LAST_UPDATE_UID == null ? "": main.LAST_UPDATE_UID.Trim(),
                        cUpdUserName = "",
                        cUpdDate = main.LAST_UPDATE_DT == null ? "" : SqlFunctions.DateName("year", main.LAST_UPDATE_DT) + "/" +
                                   SqlFunctions.DatePart("m", main.LAST_UPDATE_DT) + "/" +
                                   SqlFunctions.DateName("day", main.LAST_UPDATE_DT).Trim() + " " +
                                   SqlFunctions.DateName("hh", main.LAST_UPDATE_DT).Trim() + ":" +
                                   SqlFunctions.DateName("n", main.LAST_UPDATE_DT).Trim() + ":" +
                                   SqlFunctions.DateName("s", main.LAST_UPDATE_DT).Trim()
                                   //  cUpdTime = main.CUPDTIME.Trim()
                    }).FirstOrDefault();
                }
            }

            //取得新增人員姓名、異動人員姓名
            OaEmpDao oaEmpDao = new OaEmpDao();

            using (DB_INTRAEntities dbIntra = new DB_INTRAEntities())
            {
                try
                {
                    funcMgrDetail.cCrtUserName = StringUtil.toString(oaEmpDao.qryByUsrId(funcMgrDetail.cCrtUserID, dbIntra).EMP_NAME);
                }
                catch (Exception e)
                {
                }

                try
                {
                    funcMgrDetail.cUpdUserName = StringUtil.toString(oaEmpDao.qryByUsrId(funcMgrDetail.cUpdUserID, dbIntra).EMP_NAME);
                }
                catch (Exception e)
                {
                }
            }



            return(funcMgrDetail);
        }
コード例 #6
0
        /// <summary>
        /// 開啟角色修改明細畫面
        /// </summary>
        /// <param name="aplyNo"></param>
        /// <returns></returns>
        public ActionResult detailRole(string aplyNo, string roleId)
        {
            try
            {
                string      execAction  = "";
                AuthApprDao AuthApprDao = new AuthApprDao();

                AUTH_APPR authAppr = new AUTH_APPR();



                if (!"".Equals(StringUtil.toString(aplyNo)))
                {
                    authAppr      = AuthApprDao.qryByKey(aplyNo);
                    ViewBag.bView = "N";
                }

                else
                {
                    authAppr = AuthApprDao.qryByFreeRole(roleId);
                    if (authAppr != null)
                    {
                        aplyNo = StringUtil.toString(authAppr.APLY_NO);
                    }

                    ViewBag.bView = "Y";
                }



                AuthReviewRoleModel roleData = new AuthReviewRoleModel();
                roleData.aplyNo    = aplyNo;
                roleData.createUid = authAppr.CREATE_UID;

                OaEmpDao oaEmpDao = new OaEmpDao();
                using (DB_INTRAEntities dbIntra = new DB_INTRAEntities())
                {
                    try
                    {
                        roleData.createUid = roleData.createUid == null ? "" : StringUtil.toString(oaEmpDao.qryByUsrId(roleData.createUid, dbIntra).EMP_NAME);
                    }
                    catch (Exception e)
                    {
                    }
                }
                roleData.createDt    = authAppr.CREATE_DT.ToString();
                roleData.roleName    = "";
                roleData.isDisabled  = "";
                roleData.memo        = "";
                roleData.roleNameB   = "";
                roleData.isDisabledB = "";
                roleData.memoB       = "";


                CodeRoleHisDao CodeRoleHisDao = new CodeRoleHisDao();
                CODE_ROLE_HIS  codeRoleHis    = CodeRoleHisDao.qryByAplyNo(aplyNo);
                if (codeRoleHis != null)
                {
                    execAction = StringUtil.toString(codeRoleHis.EXEC_ACTION);
                }

                if ("".Equals(execAction))
                {
                    CodeRoleDao CodeRoleDao = new CodeRoleDao();
                    CODE_ROLE   codeRole    = new CODE_ROLE();
                    codeRole = CodeRoleDao.qryRoleByKey(authAppr.APPR_MAPPING_KEY);

                    roleData.roleId       = StringUtil.toString(codeRole.ROLE_ID);
                    roleData.roleAuthType = StringUtil.toString(codeRole.ROLE_AUTH_TYPE);
                    roleData.roleNameB    = StringUtil.toString(codeRole.ROLE_NAME);
                    roleData.isDisabledB  = StringUtil.toString(codeRole.IS_DISABLED);
                    roleData.memoB        = StringUtil.toString(codeRole.MEMO);
                }
                else
                {
                    roleData.roleId       = StringUtil.toString(codeRoleHis.ROLE_ID);
                    roleData.roleAuthType = StringUtil.toString(codeRoleHis.ROLE_AUTH_TYPE);

                    if ("A".Equals(execAction))
                    {
                        roleData.roleName   = StringUtil.toString(codeRoleHis.ROLE_NAME);
                        roleData.isDisabled = StringUtil.toString(codeRoleHis.IS_DISABLED);
                        roleData.memo       = StringUtil.toString(codeRoleHis.MEMO);
                    }
                    else
                    {
                        roleData.roleName   = StringUtil.toString(codeRoleHis.ROLE_NAME);
                        roleData.isDisabled = StringUtil.toString(codeRoleHis.IS_DISABLED);
                        roleData.memo       = StringUtil.toString(codeRoleHis.MEMO);

                        roleData.roleNameB   = StringUtil.toString(codeRoleHis.ROLE_NAME_B);
                        roleData.isDisabledB = StringUtil.toString(codeRoleHis.IS_DISABLED_B);
                        roleData.memoB       = StringUtil.toString(codeRoleHis.MEMO_B);
                    }
                }


                SysCodeDao sysCodeDao = new SysCodeDao();
                SYS_CODE   sysCode    = new SYS_CODE();
                sysCode = sysCodeDao.qryByKey("ROLE_AUTH_TYPE", StringUtil.toString(roleData.roleAuthType));
                if (sysCode != null)
                {
                    roleData.roleAuthTypeDesc = StringUtil.toString(sysCode.CODE_VALUE);
                }

                sysCode = sysCodeDao.qryByKey("IS_DISABLED", StringUtil.toString(roleData.isDisabledB));
                if (sysCode != null)
                {
                    roleData.isDisabledB = StringUtil.toString(sysCode.CODE_VALUE);
                }

                sysCode = sysCodeDao.qryByKey("IS_DISABLED", StringUtil.toString(roleData.isDisabled));
                if (sysCode != null)
                {
                    roleData.isDisabled = StringUtil.toString(sysCode.CODE_VALUE);
                }


                ViewBag.bHaveData = "Y";
                ViewBag.aplyNo    = aplyNo;
                return(View(roleData));
            }
            catch (Exception e)
            {
                ViewBag.bHaveData = "N";
                return(View());
            }
        }
コード例 #7
0
ファイル: AccountController.cs プロジェクト: BiancoLee/BETA
        public ActionResult Login(LoginModel loginModel)
        {
            logger.Info("[AccountController][Login]UserId:" + loginModel.UserId);
            bool hasuser         = System.Web.HttpContext.Current.User != null;
            bool isAuthenticated = hasuser && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;



            if (ModelState.IsValid)
            //if (isAuthenticated)
            {
                logger.Info("[AccountController][Login]IsValid");
                this.HttpContext.Response.RemoveOutputCacheItem(Url.Action("MenuByUser", "NavigationController"));
                string ADPath = System.Configuration.ConfigurationManager.AppSettings.Get("ADPath");
                loginModel.UserId = loginModel.UserId.ToUpper();



                DirectoryEntry entry = new DirectoryEntry(ADPath, loginModel.UserId, loginModel.Password);

                try
                {
                    string objectSid = (new SecurityIdentifier((byte[])entry.Properties["objectSid"].Value, 0).Value);

                    //AD驗證成功,檢查該user是否有系統權限
                    CodeUserDao codeUserDao = new CodeUserDao();


                    CODE_USER codeUser = codeUserDao.qryUserByKey(loginModel.UserId);
                    if (codeUser != null)
                    {
                        if ("N".Equals(codeUser.IS_DISABLED))
                        {
                            Session["UserID"] = loginModel.UserId;
                            //Session["UserID"] = "A8272";
                            //Session["UserID"] = "A7040";
                            //Session["UserID"] = "A0190";


                            //Session["AgentID"] = codeUser.CAGENTID;

                            //Session["UserName"] = "";
                            //Session["UserUnit"] = "";

                            OaEmpDao oaEmpDao = new OaEmpDao();
                            try
                            {
                                using (DB_INTRAEntities dbIntra = new DB_INTRAEntities())
                                {
                                    V_EMPLY2 emp = oaEmpDao.qryByUsrId(loginModel.UserId, dbIntra);
                                    if (emp != null)
                                    {
                                        Session["UserName"] = StringUtil.toString(emp.EMP_NAME);
                                        Session["UserUnit"] = StringUtil.toString(emp.DPT_CD);
                                        //Session["UserUnit"] = "VE303";
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                            }

                            writeLog("I", true, loginModel.UserId, codeUser);

                            LoginProcess(loginModel.UserId, false);

                            //System.Web.HttpContext context = System.Web.HttpContext.Current;
                            //SessionIDManager smgr = new SessionIDManager();
                            //string newId = smgr.CreateSessionID(context);
                            //string oldId = context.Session.SessionID;
                            //bool redirected = false;
                            //bool isAdded = false;
                            //smgr.SaveSessionID(context, newId, out redirected, out isAdded);


                            //string guid = Guid.NewGuid().ToString();
                            //string guid2 = Guid.NewGuid().ToString();
                            //Session["ASP.NET_SessionId"] = guid;
                            //// now create a new cookie with this guid value
                            //Response.Cookies["ASP.NET_SessionId"].Value = guid;
                            //Response.Cookies["adAuthCookie"].Value = guid2;
                            //Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", guid));
                            //Response.Cookies.Add(new HttpCookie("adAuthCookie", guid2));

                            return(RedirectToAction("Index", "Home"));
                        }
                    }

                    writeLog("I", false, loginModel.UserId, null);
                    ModelState.AddModelError("", "找不到這個使用者或登入帳號密碼失敗!");
                    return(View(loginModel));
                }
                catch (Exception e)
                {
                    logger.Error("[Login]其它錯誤:" + e.ToString());
                    writeLog("I", false, loginModel.UserId, null);


                    //驗證失敗
                    ModelState.AddModelError("", "找不到這個使用者或登入帳號密碼失敗!");
                    return(View(loginModel));
                }
                finally
                {
                    logger.Info("[Login]finally:" + loginModel.UserId);
                    //entry.Dispose();
                }
            }
            else
            {
                logger.Info("[Login](ModelState.IsValid=false):" + loginModel.UserId);
                return(View(loginModel));
            }
        }
コード例 #8
0
ファイル: CodeUserDao.cs プロジェクト: BiancoLee/BETA
        /// <summary>
        /// 新增使用者
        /// </summary>
        /// <param name="user"></param>
        /// <param name="conn"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public int Create(CODE_USER user, SqlConnection conn, SqlTransaction transaction)
        {
            using (DB_INTRAEntities db = new DB_INTRAEntities())
            {
                OaEmpDao oaEmpDao = new OaEmpDao();
                V_EMPLY2 emp      = new V_EMPLY2();
                try
                {
                    emp = oaEmpDao.qryByUsrId(user.USER_ID, db);
                    if (emp != null)
                    {
                        user.USER_UNIT = StringUtil.toString(emp.DPT_CD);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            string sql = @"

INSERT INTO [dbo].[CODE_USER]
           ([USER_ID]
           ,[USER_UNIT]
           ,[IS_DISABLED]
           ,[IS_MAIL]
           ,[MEMO]
           ,[DATA_STATUS]
           ,[CREATE_UID]
           ,[CREATE_DT]
           ,[LAST_UPDATE_UID]
           ,[LAST_UPDATE_DT]
           ,[APPR_UID]
           ,[APPR_DT]
)
     VALUES
(
 @USER_ID
,@USER_UNIT
,@IS_DISABLED
,@IS_MAIL
,@MEMO
,@DATA_STATUS
,@CREATE_UID
,@CREATE_DT
,@LAST_UPDATE_UID
,@LAST_UPDATE_DT
,@APPR_UID
,@APPR_DT
)
        ";


            SqlCommand command = conn.CreateCommand();


            command.Connection  = conn;
            command.Transaction = transaction;

            try
            {
                command.CommandText = sql;
                command.Parameters.AddWithValue("@USER_ID", StringUtil.toString(user.USER_ID));
                command.Parameters.AddWithValue("@USER_UNIT", StringUtil.toString(user.USER_UNIT));
                command.Parameters.AddWithValue("@IS_DISABLED", StringUtil.toString(user.IS_DISABLED));
                command.Parameters.AddWithValue("@IS_MAIL", StringUtil.toString(user.IS_MAIL));
                command.Parameters.AddWithValue("@MEMO", StringUtil.toString(user.MEMO));
                command.Parameters.AddWithValue("@DATA_STATUS", StringUtil.toString(user.DATA_STATUS));
                command.Parameters.AddWithValue("@CREATE_UID", StringUtil.toString(user.CREATE_UID));

                command.Parameters.Add("@CREATE_DT", System.Data.SqlDbType.DateTime).Value = (System.Object)user.CREATE_DT ?? System.DBNull.Value;

                command.Parameters.AddWithValue("@LAST_UPDATE_UID", StringUtil.toString(user.LAST_UPDATE_UID));

                command.Parameters.Add("@LAST_UPDATE_DT", System.Data.SqlDbType.DateTime).Value = (System.Object)user.LAST_UPDATE_DT ?? System.DBNull.Value;

                command.Parameters.AddWithValue("@APPR_UID", StringUtil.toString(user.APPR_UID));

                command.Parameters.Add("@APPR_DT", System.Data.SqlDbType.DateTime).Value = (System.Object)user.APPR_DT ?? System.DBNull.Value;


                int cnt = command.ExecuteNonQuery();


                return(cnt);
            }
            catch (Exception e)
            {
                throw e;
            }
        }