コード例 #1
0
    protected void rptAccounts_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "Del":
            string[] args       = e.CommandArgument.ToString().Split(',');
            int      empId      = Convert.ToInt32(args[0]);
            string   empAccount = args[1];

            bool result = empAuth.DeleteEmployeeData(empId);

            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = string.Format(".刪除帳號/Delete account .代碼/id[{0}] 帳號/account[{1}] 結果/result[{2}]", empId, empAccount, result),
                IP          = c.GetClientIP()
            });

            // log to file
            c.LoggerOfUI.InfoFormat("{0} deletes {1}, result: {2}", c.GetEmpAccount(), "Emp-" + empId.ToString() + "-" + empAccount, result);

            if (result)
            {
                DisplayAccounts();
            }
            else
            {
                Master.ShowErrorMsg(Resources.Lang.ErrMsg_DeleteAccountFailed);
            }

            break;
        }
    }
コード例 #2
0
    protected void rptSubitems_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        bool result = false;
        int  opId   = 0;

        switch (e.CommandName)
        {
        case "Del":
            string[] args = e.CommandArgument.ToString().Split(',');
            opId = Convert.ToInt32(args[0]);
            string   subject = args[1];
            OpParams param   = new OpParams()
            {
                OpId = opId
            };

            result = empAuth.DeleteOperationData(param);

            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = string.Format(".刪除作業選項/Delete operation .代碼/id[{0}] 標題/subject[{1}] 結果/result[{2}]", opId, subject, result),
                IP          = c.GetClientIP()
            });

            // log to file
            c.LoggerOfUI.InfoFormat("{0} deletes {1}, result: {2}", c.GetEmpAccount(), "op-" + opId.ToString() + "-" + subject, result);

            if (!result)
            {
                if (param.IsThereSubitemOfOp)
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_ThereIsSubitemofOp);
                }
                else
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_DeleteOperationFailed);
                }
            }

            break;

        case "MoveUp":
            opId   = Convert.ToInt32(e.CommandArgument);
            result = empAuth.DecreaseOperationSortNo(opId, c.GetEmpAccount());
            break;

        case "MoveDown":
            opId   = Convert.ToInt32(e.CommandArgument);
            result = empAuth.IncreaseOperationSortNo(opId, c.GetEmpAccount());
            break;
        }

        if (result)
        {
            DisplaySubitems();
            Master.RefreshOpMenu();
        }
    }
コード例 #3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Master.ShowErrorMsg("");

        if (!c.seRoleOpPvgs.Any(p => string.Compare(p.RoleName, ltrRoleName.Text) == 0))
        {
            Master.ShowErrorMsg(Resources.Lang.ErrMsg_ThereIsnotAnyChangesOfPvg);
            return;
        }

        //取得異動的權限
        List <RoleOpPvg> changes = c.seRoleOpPvgs.Where(p => string.Compare(p.RoleName, ltrRoleName.Text) == 0).ToList();

        c.ClearRoleDataOfRoleOpPvgs(ltrRoleName.Text);

        try
        {
            bool result = empAuth.SaveListOfEmployeeRolePrivileges(new RolePrivilegeParams()
            {
                RoleName    = ltrRoleName.Text,
                pvgChanges  = changes,
                PostAccount = c.GetEmpAccount()
            });

            if (result)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Privilege"), true);
            }
            else
            {
                Master.ShowErrorMsg(Resources.Lang.ErrMsg_RolePrivilegeSaveFailed);
            }

            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = string.Format(".{0} .儲存權限/Save privileges .身分/Role[{1}] .異動數量/changes[{2}] 結果/result[{3}]", Title, ltrRoleName.Text, changes.Count, result),
                IP          = c.GetClientIP()
            });
        }
        catch (Exception ex)
        {
            c.LoggerOfUI.Error("", ex);
            Master.ShowErrorMsg(ex.Message);
        }
    }
コード例 #4
0
    protected void rptDepartments_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "Del":
            string[]   args     = e.CommandArgument.ToString().Split(',');
            int        deptId   = Convert.ToInt32(args[0]);
            string     deptName = args[1];
            DeptParams param    = new DeptParams()
            {
                DeptId = deptId
            };

            bool result = empAuth.DeleteDepartmentData(param);

            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = string.Format(".刪除部門/Delete department .代碼/id[{0}] 名稱/name[{1}] 結果/result[{2}]", deptId, deptName, result),
                IP          = c.GetClientIP()
            });

            // log to file
            c.LoggerOfUI.InfoFormat("{0} deletes {1}, result: {2}", c.GetEmpAccount(), "dept-" + deptId.ToString() + "-" + deptName, result);

            if (result)
            {
                DisplayDepartments();
            }
            else
            {
                if (param.IsThereAccountsOfDept)
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_ThereIsAccountOfDept);
                }
                else
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_DeleteDeptFailed);
                }
            }

            break;
        }
    }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }

        if (c.seLoginEmpData.EmpAccount != null &&
            Request.AppRelativeCurrentExecutionFilePath != "~/Back-End-Log.aspx")
        {
            //新增後端操作記錄
            string description = string.Format(".{0} .頁碼/Page[{1}] .路徑/Route[{2}] .IsPostBack[{3}]",
                                               ltrHead.Text, c.qsPageCode, Common.Utility.StringUtility.RemoveHtmlTag(ltrBreadcrumb.Text.Replace("</", "/</")), IsPostBack);

            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = description,
                IP          = c.GetClientIP()
            });
        }
    }
コード例 #6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        try
        {
            txtOpSubject.Text      = txtOpSubject.Text.Trim();
            txtEnglishSubject.Text = txtEnglishSubject.Text.Trim();
            txtIconImageFile.Text  = txtIconImageFile.Text.Trim();
            txtLinkUrl.Text        = txtLinkUrl.Text.Trim();
            txtCommonClass.Text    = txtCommonClass.Text.Trim();

            OpParams param = new OpParams()
            {
                SortNo         = Convert.ToInt32(txtSortNo.Text),
                OpSubject      = txtOpSubject.Text,
                EnglishSubject = txtEnglishSubject.Text,
                IconImageFile  = txtIconImageFile.Text,
                LinkUrl        = txtLinkUrl.Text,
                IsNewWindow    = chkIsNewWindow.Checked,
                IsHideSelf     = chkIsHideSelf.Checked,
                CommonClass    = txtCommonClass.Text,
                PostAccount    = c.GetEmpAccount()
            };

            bool result = false;

            if (c.qsAct == ConfigFormAction.add)
            {
                param.ParentId = c.qsId;
                result         = empAuth.InsertOperationData(param);

                if (!result)
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddFailed);
                }
            }
            else if (c.qsAct == ConfigFormAction.edit)
            {
                param.OpId = c.qsId;
                result     = empAuth.UpdateOperaionData(param);

                if (!result)
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_UpdateFailed);
                }
            }

            if (result)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Config"), true);
            }

            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = string.Format(".{0} .儲存後端作業選項/Save operation[{1}][{2}] OpId[{3}] 結果/result[{4}]", Title, txtOpSubject.Text, txtEnglishSubject.Text, param.OpId, result),
                IP          = c.GetClientIP()
            });
        }
        catch (Exception ex)
        {
            c.LoggerOfUI.Error("", ex);
            Master.ShowErrorMsg(ex.Message);
        }
    }
コード例 #7
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Master.ShowErrorMsg("");

        if (!IsValid)
        {
            return;
        }

        try
        {
            txtVidLinkUrl.Text    = txtVidLinkUrl.Text.Trim();
            txtSourceVideoId.Text = txtSourceVideoId.Text.Trim();

            ArticleVideoParams param = new ArticleVideoParams()
            {
                SortNo        = Convert.ToInt32(txtSortNo.Text),
                VidLinkUrl    = txtVidLinkUrl.Text,
                SourceVideoId = txtSourceVideoId.Text,
                PostAccount   = c.GetEmpAccount()
            };

            txtVidSubjectZhTw.Text = txtVidSubjectZhTw.Text.Trim();
            txtVidDescZhTw.Text    = txtVidDescZhTw.Text.Trim();

            ArticleVideoMultiLangParams paramZhTw = new ArticleVideoMultiLangParams()
            {
                CultureName  = LangManager.CultureNameZHTW,
                VidSubject   = txtVidSubjectZhTw.Text,
                IsShowInLang = chkIsShowInLangZhTw.Checked,
                VidDesc      = txtVidDescZhTw.Text,
                PostAccount  = c.GetEmpAccount()
            };

            txtVidSubjectEn.Text = txtVidSubjectEn.Text.Trim();
            txtVidDescEn.Text    = txtVidDescEn.Text.Trim();

            ArticleVideoMultiLangParams paramEn = new ArticleVideoMultiLangParams()
            {
                CultureName  = LangManager.CultureNameEN,
                VidSubject   = txtVidSubjectEn.Text,
                IsShowInLang = chkIsShowInLangEn.Checked,
                VidDesc      = txtVidDescEn.Text,
                PostAccount  = c.GetEmpAccount()
            };

            bool result = false;

            if (c.qsAct == ConfigFormAction.add)
            {
                Guid newVidId = Guid.NewGuid();
                param.VidId     = newVidId;
                param.ArticleId = c.qsArtId;

                result = artPub.InsertArticleVideoData(param);

                if (result)
                {
                    //zh-TW
                    if (result && LangManager.IsEnableEditLangZHTW())
                    {
                        paramZhTw.VidId = param.VidId;
                        result          = artPub.InsertArticleVideoMultiLangData(paramZhTw);
                    }

                    //en
                    if (result && LangManager.IsEnableEditLangEN())
                    {
                        paramEn.VidId = param.VidId;
                        result        = artPub.InsertArticleVideoMultiLangData(paramEn);
                    }

                    if (!result)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddMultiLangFailed);
                    }
                }
                else
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddFailed);
                }
            }
            else if (c.qsAct == ConfigFormAction.edit)
            {
                param.VidId = c.qsVidId;

                result = artPub.UpdateArticleVideoData(param);

                if (result)
                {
                    //zh-TW
                    if (result && LangManager.IsEnableEditLangZHTW())
                    {
                        paramZhTw.VidId = param.VidId;
                        result          = artPub.UpdateArticleVideoMultiLangData(paramZhTw);
                    }

                    //en
                    if (result && LangManager.IsEnableEditLangEN())
                    {
                        paramEn.VidId = param.VidId;
                        result        = artPub.UpdateArticleVideoMultiLangData(paramEn);
                    }

                    if (!result)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_UpdateMultiLangFailed);
                    }
                }
                else
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_UpdateFailed);
                }
            }

            if (result)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Video"), true);
            }

            //新增後端操作記錄
            string description = string.Format(".{0} .儲存網頁影片/Save article video[{1}][{2}] VidId[{3}] 結果/result[{4}]",
                                               Title, txtVidSubjectZhTw.Text, txtVidSubjectEn.Text, param.VidId, result);

            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = description,
                IP          = c.GetClientIP()
            });
        }
        catch (Exception ex)
        {
            c.LoggerOfUI.Error("", ex);
            Master.ShowErrorMsg(ex.Message);
        }
    }
コード例 #8
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        try
        {
            txtDeptName.Text = txtDeptName.Text.Trim();

            DeptParams param = new DeptParams()
            {
                DeptName    = txtDeptName.Text,
                SortNo      = Convert.ToInt32(txtSortNo.Text),
                PostAccount = c.GetEmpAccount()
            };

            bool result = false;

            if (c.qsAct == ConfigFormAction.add)
            {
                result = empAuth.InsertDepartmentData(param);

                if (!result)
                {
                    if (param.HasDeptNameBeenUsed)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_DeptNameHasBeenUsed);
                    }
                    else
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddFailed);
                    }
                }
            }
            else if (c.qsAct == ConfigFormAction.edit)
            {
                param.DeptId = c.qsId;
                result       = empAuth.UpdateDepartmentData(param);

                if (!result)
                {
                    if (param.HasDeptNameBeenUsed)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_DeptNameHasBeenUsed);
                    }
                    else
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_UpdateFailed);
                    }
                }
            }

            if (result)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Config"), true);
            }

            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = string.Format(".{0} .儲存部門/Save department[{1}] DeptId[{2}] 結果/result[{3}]", Title, txtDeptName.Text, param.DeptId, result),
                IP          = c.GetClientIP()
            });
        }
        catch (Exception ex)
        {
            c.LoggerOfUI.Error("", ex);
            Master.ShowErrorMsg(ex.Message);
        }
    }
コード例 #9
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        txtCheckCode.Text = "";

        if (!IsValid)
        {
            return;
        }

        txtAccount.Text  = txtAccount.Text.Trim();
        txtPassword.Text = txtPassword.Text.Trim();

        //登入驗證
        EmployeeToLogin empVerify = empAuth.GetEmployeeDataToLogin(txtAccount.Text);

        if (empVerify == null && empAuth.GetDbErrMsg() != "")
        {
            //異常錯誤
            ShowErrorMsg(string.Format("{0}: {1}", Resources.Lang.ErrMsg_Exception, empAuth.GetDbErrMsg()));
            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = "",
                Description = string.Format(".帳號登入驗證時發生異常錯誤,帳號[{0}] .An exception error occurred during login verification! Account[{0}]", txtAccount.Text),
                IP          = c.GetClientIP()
            });
            //檢查登入失敗次數,是否顯示驗證圖
            CheckLoginFailedCountToShowCaptcha(true);
            return;
        }

        //判斷是否有資料
        if (empVerify == null)
        {
            //沒資料
            ShowErrorMsg(ACCOUNT_FAILED_ERRMSG);
            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = "",
                Description = string.Format(".帳號不存在,輸入帳號[{0}] .Account doesn't exist! Account[{0}]", txtAccount.Text),
                IP          = c.GetClientIP()
            });
            //檢查登入失敗次數,是否顯示驗證圖
            CheckLoginFailedCountToShowCaptcha(true);
            return;
        }

        //有資料

        //檢查密碼
        string passwordHash      = HashUtility.GetPasswordHash(txtPassword.Text);
        string empPassword       = empVerify.EmpPassword;
        bool   isPasswordCorrect = false;

        if (empVerify.PasswordHashed)
        {
            isPasswordCorrect = (passwordHash == empPassword);
        }
        else
        {
            isPasswordCorrect = (txtPassword.Text == empPassword);
        }

        if (!isPasswordCorrect)
        {
            ShowErrorMsg(ACCOUNT_FAILED_ERRMSG);
            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = "",
                Description = string.Format(".密碼錯誤,帳號[{0}] .Password is incorrect! Account[{0}]", txtAccount.Text),
                IP          = c.GetClientIP()
            });
            //檢查登入失敗次數,是否顯示驗證圖
            CheckLoginFailedCountToShowCaptcha(true);
            return;
        }

        //檢查是否停權
        if (empVerify.IsAccessDenied)
        {
            ShowErrorMsg(Resources.Lang.ErrMsg_AccountUnavailable);
            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = "",
                Description = string.Format(".帳號停用,帳號[{0}] .Account is denied! Account[{0}]", txtAccount.Text),
                IP          = c.GetClientIP()
            });
            //檢查登入失敗次數,是否顯示驗證圖
            CheckLoginFailedCountToShowCaptcha(true);
            return;
        }

        //檢查上架日期
        if (string.Compare(txtAccount.Text, "admin", true) != 0)    // 不檢查帳號 admin
        {
            DateTime startDate = empVerify.StartDate.Value.Date;
            DateTime endDate   = empVerify.EndDate.Value.Date;
            DateTime today     = DateTime.Today;

            if (today < startDate || endDate < today)
            {
                ShowErrorMsg(Resources.Lang.ErrMsg_AccountUnavailable);
                //新增後端操作記錄
                empAuth.InsertBackEndLogData(new BackEndLogData()
                {
                    EmpAccount  = "",
                    Description = string.Format(".帳號超出有效範圍,帳號[{0}] .Account validation date is out of range! Account[{0}]", txtAccount.Text),
                    IP          = c.GetClientIP()
                });
                //檢查登入失敗次數,是否顯示驗證圖
                CheckLoginFailedCountToShowCaptcha(true);
                return;
            }
        }

        //記錄登入時間與IP
        empAuth.UpdateEmployeeLoginInfo(txtAccount.Text, c.GetClientIP());

        //確認可登入後,取得員工資料
        EmployeeForBackend emp = empAuth.GetEmployeeData(txtAccount.Text);

        if (emp == null && empAuth.GetDbErrMsg() != "")
        {
            //異常錯誤
            ShowErrorMsg(string.Format("{0}: {1}", Resources.Lang.ErrMsg_Exception, empAuth.GetDbErrMsg()));
            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = "",
                Description = string.Format(".帳號登入取得使用者資料時發生異常錯誤,帳號[{0}] .An exception error occurred during obtaining user profile! Account[{0}]", txtAccount.Text),
                IP          = c.GetClientIP()
            });
            //檢查登入失敗次數,是否顯示驗證圖
            CheckLoginFailedCountToShowCaptcha(true);
            return;
        }

        //清除登入失敗次數
        c.seLoginFailedCount = 0;

        DateTime
            thisLoginTime = DateTime.MinValue,
            lastLoginTime = DateTime.MinValue;

        if (emp.ThisLoginTime.HasValue)
        {
            thisLoginTime = emp.ThisLoginTime.Value;
        }

        if (emp.LastLoginTime.HasValue)
        {
            lastLoginTime = emp.LastLoginTime.Value;
        }

        LoginEmployeeData loginEmpData = new LoginEmployeeData()
        {
            EmpId           = emp.EmpId,
            EmpName         = emp.EmpName,
            Email           = emp.Email,
            DeptId          = emp.DeptId,
            DeptName        = emp.DeptName,
            RoleId          = emp.RoleId,
            RoleName        = emp.RoleName,
            RoleDisplayName = emp.RoleDisplayName,
            StartDate       = emp.StartDate.Value,
            EndDate         = emp.EndDate.Value,
            EmpAccount      = emp.EmpAccount,
            ThisLoginTime   = thisLoginTime,
            ThisLoginIP     = emp.ThisLoginIP,
            LastLoginTime   = lastLoginTime,
            LastLoginIP     = emp.LastLoginIP
        };

        c.SaveLoginEmployeeDataIntoSession(loginEmpData);

        //新增後端操作記錄
        empAuth.InsertBackEndLogData(new BackEndLogData()
        {
            EmpAccount  = c.GetEmpAccount(),
            Description = ".登入系統! .Logged in!",
            IP          = c.GetClientIP()
        });

        //記錄指定語系
        c.seLangNoOfBackend = c.qsLangNo;

        //設定已登入
        FormsAuthentication.RedirectFromLoginPage(c.seLoginEmpData.EmpAccount, false);

        /* 需要帶入額外參數時使用
         * if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
         * {
         *  FormsAuthentication.SetAuthCookie(c.seLoginEmpData.EmpAccount, false);
         *  Response.Redirect(FormsAuthentication.DefaultUrl + "?l=" + c.qsLangNo.ToString());
         * }
         */
    }
コード例 #10
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Master.ShowErrorMsg("");

        if (!IsValid)
        {
            return;
        }

        try
        {
            txtArticleAlias.Text       = txtArticleAlias.Text.Trim();
            txtBannerPicFileName.Text  = txtBannerPicFileName.Text.Trim();
            txtLinkUrl.Text            = txtLinkUrl.Text.Trim();
            txtControlName.Text        = txtControlName.Text.Trim();
            txtSubItemControlName.Text = txtSubItemControlName.Text.Trim();
            txtSubItemLinkUrl.Text     = txtSubItemLinkUrl.Text.Trim();

            ArticleParams param = new ArticleParams()
            {
                ArticleAlias                = txtArticleAlias.Text,
                BannerPicFileName           = txtBannerPicFileName.Text,
                LayoutModeId                = Convert.ToInt32(rdolLayoutMode.SelectedValue),
                ShowTypeId                  = Convert.ToInt32(rdolShowType.SelectedValue),
                LinkUrl                     = txtLinkUrl.Text,
                LinkTarget                  = chkIsNewWindow.Checked ? "_blank" : "",
                ControlName                 = txtControlName.Text,
                SubItemControlName          = txtSubItemControlName.Text,
                IsHideSelf                  = chkIsHideSelf.Checked,
                IsHideChild                 = chkIsHideChild.Checked,
                StartDate                   = Convert.ToDateTime(txtStartDate.Text),
                EndDate                     = Convert.ToDateTime(txtEndDate.Text),
                SortNo                      = Convert.ToInt32(txtSortNo.Text),
                DontDelete                  = chkDontDelete.Checked,
                PostAccount                 = c.GetEmpAccount(),
                SubjectAtBannerArea         = chkSubjectAtBannerArea.Checked,
                PublishDate                 = Convert.ToDateTime(txtPublishDate.Text),
                IsShowInUnitArea            = chkIsShowInUnitArea.Checked,
                IsShowInSitemap             = chkIsShowInSitemap.Checked,
                SortFieldOfFrontStage       = hidSortFieldOfFrontStage.Text,
                IsSortDescOfFrontStage      = Convert.ToBoolean(hidIsSortDescOfFrontStage.Text),
                IsListAreaShowInFrontStage  = Convert.ToBoolean(hidIsListAreaShowInFrontStage.Text),
                IsAttAreaShowInFrontStage   = Convert.ToBoolean(hidIsAttAreaShowInFrontStage.Text),
                IsPicAreaShowInFrontStage   = Convert.ToBoolean(hidIsPicAreaShowInFrontStage.Text),
                IsVideoAreaShowInFrontStage = Convert.ToBoolean(hidIsVideoAreaShowInFrontStage.Text),
                SubItemLinkUrl              = txtSubItemLinkUrl.Text
            };

            txtArticleSubjectZhTw.Text = txtArticleSubjectZhTw.Text.Trim();
            txtCkeContextZhTw.Text     = StringUtility.GetSievedHtmlEditorValue(txtCkeContextZhTw.Text);
            txtSubtitleZhTw.Text       = txtSubtitleZhTw.Text.Trim();
            txtPublisherNameZhTw.Text  = txtPublisherNameZhTw.Text.Trim();

            ArticleMultiLangParams paramZhTw = new ArticleMultiLangParams()
            {
                CultureName    = LangManager.CultureNameZHTW,
                ArticleSubject = txtArticleSubjectZhTw.Text,
                ArticleContext = txtCkeContextZhTw.Text,
                IsShowInLang   = chkIsShowInLangZhTw.Checked,
                PostAccount    = c.GetEmpAccount(),
                Subtitle       = txtSubtitleZhTw.Text,
                PublisherName  = txtPublisherNameZhTw.Text,
                TextContext    = StringUtility.RemoveHtmlTag(txtCkeContextZhTw.Text)
            };

            txtArticleSubjectEn.Text = txtArticleSubjectEn.Text.Trim();
            txtCkeContextEn.Text     = StringUtility.GetSievedHtmlEditorValue(txtCkeContextEn.Text);
            txtSubtitleEn.Text       = txtSubtitleEn.Text.Trim();
            txtPublisherNameEn.Text  = txtPublisherNameEn.Text.Trim();

            ArticleMultiLangParams paramEn = new ArticleMultiLangParams()
            {
                CultureName    = LangManager.CultureNameEN,
                ArticleSubject = txtArticleSubjectEn.Text,
                ArticleContext = txtCkeContextEn.Text,
                IsShowInLang   = chkIsShowInLangEn.Checked,
                PostAccount    = c.GetEmpAccount(),
                Subtitle       = txtSubtitleEn.Text,
                PublisherName  = txtPublisherNameEn.Text,
                TextContext    = StringUtility.RemoveHtmlTag(txtCkeContextEn.Text)
            };

            bool result = false;

            if (c.qsAct == ConfigFormAction.add)
            {
                Guid newArticleId = Guid.NewGuid();
                param.ArticleId = newArticleId;
                param.ParentId  = c.qsArtId;

                if (param.ArticleAlias == "")
                {
                    param.ArticleAlias = newArticleId.ToString();
                }

                result = artPub.InsertArticleData(param);

                if (result)
                {
                    //ZhTw
                    if (result && LangManager.IsEnableEditLangZHTW())
                    {
                        paramZhTw.ArticleId = param.ArticleId;
                        result = artPub.InsertArticleMultiLangData(paramZhTw);
                    }

                    //En
                    if (result && LangManager.IsEnableEditLangEN())
                    {
                        paramEn.ArticleId = param.ArticleId;
                        result            = artPub.InsertArticleMultiLangData(paramEn);
                    }

                    if (!result)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddMultiLangFailed);
                    }
                }
                else
                {
                    if (param.HasIdBeenUsed)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_ArticleIdHasBeenUsed);
                    }
                    else if (param.HasAliasBeenUsed)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_ArticleAliasHasBeenUsed);
                    }
                    else
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddFailed);
                    }
                }
            }
            else if (c.qsAct == ConfigFormAction.edit)
            {
                param.ArticleId = c.qsArtId;

                if (param.ArticleAlias == "")
                {
                    param.ArticleAlias = c.qsArtId.ToString();
                }

                result = artPub.UpdateArticleData(param);

                if (result)
                {
                    //ZhTw
                    if (result && LangManager.IsEnableEditLangZHTW())
                    {
                        paramZhTw.ArticleId = param.ArticleId;
                        result = artPub.UpdateArticleMultiLangData(paramZhTw);
                    }

                    //En
                    if (result && LangManager.IsEnableEditLangEN())
                    {
                        paramEn.ArticleId = param.ArticleId;
                        result            = artPub.UpdateArticleMultiLangData(paramEn);
                    }

                    if (!result)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_UpdateMultiLangFailed);
                    }
                }
                else
                {
                    if (param.HasAliasBeenUsed)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_ArticleAliasHasBeenUsed);
                    }
                    else
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddFailed);
                    }
                }
            }

            if (result)
            {
                if (chkUpdateSearchDataSource.Checked)
                {
                    // call sql server agent job
                    //bool jobResult = artPub.CallSqlServerAgentJob("Update SampleEFCMS SearchDataSource");

                    // sp
                    artPub.BuildSearchDataSource("");
                }

                ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Config"), true);
            }

            //新增後端操作記錄
            string description = string.Format(".{0} .儲存網頁/Save article[{1}][{2}] ArticleId[{3}] 結果/result[{4}]",
                                               Title, txtArticleSubjectZhTw.Text, txtArticleSubjectEn.Text, param.ArticleId, result);

            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = description,
                IP          = c.GetClientIP()
            });
        }
        catch (Exception ex)
        {
            c.LoggerOfUI.Error("", ex);
            Master.ShowErrorMsg(ex.Message);
        }
    }
コード例 #11
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Master.ShowErrorMsg("");

        if (!IsValid)
        {
            return;
        }

        if (c.qsAct == ConfigFormAction.add && !fuPickedFile.HasFile)
        {
            return;
        }

        try
        {
            bool result = false;
            txtPicSubjectZhTw.Text = txtPicSubjectZhTw.Text.Trim();
            txtPicSubjectEn.Text   = txtPicSubjectEn.Text.Trim();

            artPicMgr.SortNo           = Convert.ToInt32(txtSortNo.Text);
            artPicMgr.AttSubjectZhTw   = txtPicSubjectZhTw.Text;
            artPicMgr.AttSubjectEn     = txtPicSubjectEn.Text;
            artPicMgr.IsShowInLangZhTw = chkIsShowInLangZhTw.Checked;
            artPicMgr.IsShowInLangEn   = chkIsShowInLangEn.Checked;

            result = artPicMgr.SaveData(fuPickedFile, c.GetEmpAccount());

            if (result)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Picture"), true);
            }
            else
            {
                string errMsg = ResUtility.GetErrMsgOfAttFileErrState(artPicMgr.GetErrState());

                if (errMsg == "")
                {
                    errMsg = Resources.Lang.ErrMsg_SaveFailed;
                }

                Master.ShowErrorMsg(errMsg);
            }

            //新增後端操作記錄
            string description = string.Format(".{0} .儲存網頁照片/Save article picture[{1}][{2}]" +
                                               " 有檔案/has file[{3}] PicId[{4}] 結果/result[{5}]",
                                               Title, txtPicSubjectZhTw.Text, txtPicSubjectEn.Text,
                                               fuPickedFile.HasFile, artPicMgr.AttId, result);

            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = description,
                IP          = c.GetClientIP()
            });
        }
        catch (Exception ex)
        {
            c.LoggerOfUI.Error("", ex);
            Master.ShowErrorMsg(ex.Message);
        }
    }
コード例 #12
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        try
        {
            txtRoleName.Text        = txtRoleName.Text.Trim();
            txtRoleDisplayName.Text = txtRoleDisplayName.Text.Trim();

            RoleParams param = new RoleParams()
            {
                RoleName        = txtRoleName.Text,
                RoleDisplayName = txtRoleDisplayName.Text,
                SortNo          = Convert.ToInt32(txtSortNo.Text.Trim()),
                PostAccount     = c.GetEmpAccount()
            };

            bool result = false;

            if (c.qsAct == ConfigFormAction.add)
            {
                if (ddlCopyPrivilegeFrom.SelectedIndex > 0)
                {
                    param.CopyPrivilegeFromRoleName = ddlCopyPrivilegeFrom.SelectedValue;
                }

                result = empAuth.InsertEmployeeRoleData(param);

                if (!result)
                {
                    if (param.HasRoleBeenUsed)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_RoleNameHasBeenUsed);
                    }
                    else
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddFailed);
                    }
                }
            }
            else if (c.qsAct == ConfigFormAction.edit)
            {
                param.RoleId = c.qsRoleId;
                result       = empAuth.UpdateEmployeeRoleData(param);

                if (!result)
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_UpdateFailed);
                }
            }

            if (result)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Config"), true);
            }

            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = string.Format(".{0} .儲存身分/Save role[{1}] RoleId[{2}] 結果/result[{3}]", Title, txtRoleName.Text, param.RoleId, result),
                IP          = c.GetClientIP()
            });
        }
        catch (Exception ex)
        {
            c.LoggerOfUI.Error("", ex);
            Master.ShowErrorMsg(ex.Message);
        }
    }
コード例 #13
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        try
        {
            txtEmpAccount.Text = txtEmpAccount.Text.Trim();
            txtPsw.Text        = txtPsw.Text.Trim();
            string passwordValue  = hidEmpPasswordOri.Text;
            bool   passwordHashed = Convert.ToBoolean(hidPasswordHashed.Text);

            if (txtPsw.Text != "")
            {
                passwordValue  = HashUtility.GetPasswordHash(txtPsw.Text);
                passwordHashed = true;
            }

            txtEmpName.Text      = txtEmpName.Text.Trim();
            txtEmail.Text        = txtEmail.Text.Trim();
            txtRemarks.Text      = txtRemarks.Text.Trim();
            txtOwnerAccount.Text = txtOwnerAccount.Text.Trim();

            AccountParams param = new AccountParams()
            {
                EmpAccount            = txtEmpAccount.Text,
                EmpPassword           = passwordValue,
                EmpName               = txtEmpName.Text,
                Email                 = txtEmail.Text,
                Remarks               = txtRemarks.Text,
                DeptId                = Convert.ToInt32(ddlDept.SelectedValue),
                RoleId                = Convert.ToInt32(ddlRoles.SelectedValue),
                IsAccessDenied        = chkIsAccessDenied.Checked,
                StartDate             = Convert.ToDateTime(txtStartDate.Text),
                EndDate               = Convert.ToDateTime(txtEndDate.Text),
                OwnerAccount          = txtOwnerAccount.Text,
                PasswordHashed        = passwordHashed,
                DefaultRandomPassword = hidDefaultRandomPassword.Text,
                PostAccount           = c.GetEmpAccount()
            };

            bool result = false;

            if (c.qsAct == ConfigFormAction.add)
            {
                result = empAuth.InsertEmployeeData(param);

                if (!result)
                {
                    if (param.HasAccountBeenUsed)
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_AccountHasBeenUsed);
                    }
                    else
                    {
                        Master.ShowErrorMsg(Resources.Lang.ErrMsg_AddFailed);
                    }
                }
            }
            else if (c.qsAct == ConfigFormAction.edit)
            {
                param.EmpId = c.qsEmpId;
                result      = empAuth.UpdateEmployeeData(param);

                if (!result)
                {
                    Master.ShowErrorMsg(Resources.Lang.ErrMsg_UpdateFailed);
                }
            }

            if (result)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Config"), true);
            }

            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = string.Format(".{0} .儲存帳號/Save account[{1}] EmpId[{2}] 結果/result[{3}]", Title, txtEmpAccount.Text, param.EmpId, result),
                IP          = c.GetClientIP()
            });
        }
        catch (Exception ex)
        {
            c.LoggerOfUI.Error("", ex);
            Master.ShowErrorMsg(ex.Message);
        }
    }