Ejemplo n.º 1
0
 private bool ValidateUserPagePurview()
 {
     htInputParameter = new Hashtable();
     htInputParameter.Add(ConstantsManager.MESSAGE_ID, "");
     htInputParameter.Add("UserID", CurrentUserInfo.UserID);
     htInputParameter.Add("UserGroupID", CurrentUserInfo.UserGroupID);
     htInputParameter.Add("PurviewID", CurrentAccessPermission);
     htOutputParameter = SystemValidateLibrary.ValidateUserPurview(htInputParameter);
     if (htOutputParameter[ConstantsManager.MESSAGE_ID] != DBNull.Value)
     {
         //得到鉴权失败消息
         strMessageInfo = MessageManager.GetMessageInfo(htOutputParameter[ConstantsManager.MESSAGE_ID].ToString(), strMessageInfo);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 2
0
        protected virtual void ProcessUIControlsStatus()
        {
            // for App
            if (MainContainerPlaceHolder != null && PageNavContainerPlaceHolder != null)
            {
                var txtObjectIDItem = (TextBox)MainContainerPlaceHolder.FindControl("ObjectID");
                if (txtObjectIDItem != null)
                {
                    txtObjectIDItem.Text = ObjectID;
                }
                var btnAddItem = (HtmlInputButton)MainContainerPlaceHolder.FindControl("btnAddItem");
                if (btnAddItem != null)
                {
                    btnAddItem.Visible = SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, GetWebUIAddAccessPurviewID());
                    btnAddItem.Attributes.Add("onclick",
                                              this.IsMobileDevice()
                                                   ? RedirectJsCode.FormatInvariantCulture(GetAddPageUrl())
                                                   : OpenWindowJsCode.FormatInvariantCulture(GetAddPageUrl()));
                }
                var btnEditItem = (HtmlInputButton)PageNavContainerPlaceHolder.FindControl("btnEditItem");
                if (btnEditItem != null)
                {
                    btnEditItem.Visible = !EditMode && !AddMode && SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, GetWebUIModifyAccessPurviewID());
                    btnEditItem.Attributes.Add("onclick",
                                               this.IsMobileDevice()
                                                   ? RedirectJsCode.FormatInvariantCulture(GetEditPageUrl(ObjectID))
                                                   : OpenWindowJsCode.FormatInvariantCulture(GetEditPageUrl(ObjectID)));
                }
                #region add page
                if (CurrentPageFileName.Equals(WEBUI_ADD_FILENAME, StringComparison.OrdinalIgnoreCase))
                {
                    var ControlContainer = MainContainerPlaceHolder.FindControl("ControlContainer");
                    var btnAddConfirm    = PageNavContainerPlaceHolder.FindControl("btnAddConfirm");
                    if (btnEditItem != null)
                    {
                        btnEditItem.Visible = btnEditItem.Visible && AccessPermission;
                        btnEditItem.Attributes.Add("onclick", "window.location='{0}';".FormatInvariantCulture(GetEditPageUrl(ObjectID)));
                    }
                    if (ControlContainer != null)
                    {
                        ControlContainer.Visible = AccessPermission;
                    }
                    if (btnAddConfirm != null)
                    {
                        btnAddConfirm.Visible = (CopyMode || AddMode || EditMode) && AccessPermission;
                    }
                }
                #endregion add page

                #region search page
                if (CurrentPageFileName.Equals(WEBUI_SEARCH_FILENAME, StringComparison.OrdinalIgnoreCase))
                {
                    var PageTitle = MainContainerPlaceHolder.FindControl("PageTitle") as Literal;
                    if (PageTitle != null)
                    {
                        PageTitle.Text = PageHeaderTitle;
                    }
                    if (!AccessPermission)
                    {
                        var advancesearchpage = MainContainerPlaceHolder.FindControl("advancesearchpage");
                        if (advancesearchpage != null)
                        {
                            advancesearchpage.Visible = false;
                        }
                        var SearchPageTopButtonBar = MainContainerPlaceHolder.FindControl("SearchPageTopButtonBar");
                        if (SearchPageTopButtonBar != null)
                        {
                            SearchPageTopButtonBar.Visible = false;
                        }
                        var SearchPageTopToolBar = MainContainerPlaceHolder.FindControl("SearchPageTopToolBar");
                        if (SearchPageTopToolBar != null)
                        {
                            SearchPageTopToolBar.Visible = false;
                        }
                        var ListControl = MainContainerPlaceHolder.FindControl("ListControl");
                        if (ListControl != null)
                        {
                            ListControl.Visible = false;
                        }
                    }
                }
                #endregion search page

                #region detail page
                if (CurrentPageFileName.Equals(WEBUI_DETAIL_FILENAME, StringComparison.OrdinalIgnoreCase))
                {
                    if (btnEditItem != null)
                    {
                        btnEditItem.Visible = btnEditItem.Visible && AccessPermission;
                        btnEditItem.Attributes.Add("onclick", "window.location='{0}';".FormatInvariantCulture(GetEditPageUrl(ObjectID)));
                    }
                    var ControlContainer = MainContainerPlaceHolder.FindControl("ControlContainer");
                    if (ControlContainer != null)
                    {
                        ControlContainer.Visible = AccessPermission;
                    }
                }
                #endregion detail page
            }
            // for Web
            else if (MainContentPlaceHolder != null)
            {
                var txtObjectIDItem = (TextBox)MainContentPlaceHolder.FindControl("ObjectID");
                if (txtObjectIDItem != null)
                {
                    txtObjectIDItem.Text = ObjectID;
                }
                var btnAddItem = (HtmlInputButton)MainContentPlaceHolder.FindControl("btnAddItem");
                if (btnAddItem != null)
                {
                    btnAddItem.Visible = SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, GetWebUIAddAccessPurviewID());
                    btnAddItem.Attributes.Add("onclick",
                                              this.IsMobileDevice()
                                                   ? RedirectJsCode.FormatInvariantCulture(GetAddPageUrl())
                                                   : OpenWindowJsCode.FormatInvariantCulture(GetAddPageUrl()));
                }
                var btnEditItem = (HtmlInputButton)MainContentPlaceHolder.FindControl("btnEditItem");
                if (btnEditItem != null)
                {
                    btnEditItem.Visible = !EditMode && !AddMode && SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, GetWebUIModifyAccessPurviewID());
                    btnEditItem.Attributes.Add("onclick",
                                               this.IsMobileDevice()
                                                   ? RedirectJsCode.FormatInvariantCulture(GetEditPageUrl(ObjectID))
                                                   : OpenWindowJsCode.FormatInvariantCulture(GetEditPageUrl(ObjectID)));
                }
                var btnCopyItem      = (HtmlInputButton)MainContentPlaceHolder.FindControl("btnCopyItem");
                var btnImportFromDoc = (HtmlInputButton)MainContentPlaceHolder.FindControl("btnImportFromDoc");
                if (btnImportFromDoc != null)
                {
                    btnImportFromDoc.Visible = SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, OPERATION_IMPORT_PURVIEW_ID);
                    btnImportFromDoc.Attributes.Add("onclick", OpenWindowJsCode.FormatInvariantCulture(GetImportDocPageUrl()));
                }
                var btnImportFromDataSet = (HtmlInputButton)MainContentPlaceHolder.FindControl("btnImportFromDataSet");
                if (btnImportFromDataSet != null)
                {
                    btnImportFromDataSet.Visible = SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, OPERATION_IMPORT_DS_PURVIEW_ID);
                    btnImportFromDataSet.Attributes.Add("onclick", OpenWindowJsCode.FormatInvariantCulture(GetImportDocPageUrl()));
                }
                var btnStatisticItem = (HtmlInputButton)MainContentPlaceHolder.FindControl("btnStatisticItem");
                if (btnStatisticItem != null)
                {
                    btnStatisticItem.Visible = SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, WEBUI_STATISTIC_ACCESS_PURVIEW_ID);
                    btnStatisticItem.Attributes.Add("onclick", OpenWindowJsCode.FormatInvariantCulture(GetStatisicPageUrl()));
                }
                if (MainContentPlaceHolder.FindControl("ddlOperation") != null)
                {
                    DropDownList ddlOperation  = (DropDownList)MainContentPlaceHolder.FindControl("ddlOperation");
                    var          deletePurview = SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, GetOperationDeletePurviewID());
                    if (!deletePurview)
                    {
                        var item = ddlOperation.Items.FindByValue("remove");
                        if (item != null)
                        {
                            int index = ddlOperation.Items.IndexOf(item);
                            ddlOperation.Items.RemoveAt(index);
                        }
                    }
                    if (ddlOperation.Items.Count <= 1)
                    {
                        ddlOperation.Visible = false;
                        var btnOperate = MainContentPlaceHolder.FindControl("btnOperate");
                        if (btnOperate != null)
                        {
                            btnOperate.Visible = false;
                        }
                        var chkAll = MainContentPlaceHolder.FindControl("chkAll");
                        if (chkAll != null)
                        {
                            chkAll.Visible = false;
                        }
                    }
                }
                var btnExportAllToFile  = MainContentPlaceHolder.FindControl("btnExportAllToFile");
                var ddlExportFileFormat = MainContentPlaceHolder.FindControl("ddlExportFileFormat");
                if (btnExportAllToFile != null)
                {
                    btnExportAllToFile.Visible = SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, OPERATION_EXPORTALL_PURVIEW_ID);
                }
                if (ddlExportFileFormat != null)
                {
                    ddlExportFileFormat.Visible = SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, OPERATION_EXPORTALL_PURVIEW_ID);
                }
                #region add page
                if (CurrentPageFileName.Equals(WEBUI_ADD_FILENAME, StringComparison.OrdinalIgnoreCase))
                {
                    var ControlContainer       = MainContentPlaceHolder.FindControl("ControlContainer");
                    var ImportControlContainer = MainContentPlaceHolder.FindControl("ImportControlContainer");
                    var btnInfoFromDoc         = MainContentPlaceHolder.FindControl("btnInfoFromDoc");
                    var btnInfoFromDocBatch    = MainContentPlaceHolder.FindControl("btnInfoFromDocBatch");
                    var btnInfoFromDocCancel   = MainContentPlaceHolder.FindControl("btnInfoFromDocCancel");
                    var btnInfoFromDS          = MainContentPlaceHolder.FindControl("btnInfoFromDS");
                    var InfoFromDoc            = MainContentPlaceHolder.FindControl("InfoFromDoc") as TextBox;
                    var btnAddConfirm          = MainContentPlaceHolder.FindControl("btnAddConfirm");
                    if (ImportDocMode && SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, OPERATION_IMPORT_PURVIEW_ID))
                    {
                        if (ControlContainer != null)
                        {
                            ControlContainer.Visible = false;
                        }
                        if (ImportControlContainer != null)
                        {
                            ImportControlContainer.Visible = AccessPermission;
                        }
                        if (btnInfoFromDoc != null)
                        {
                            btnInfoFromDoc.Visible = true;
                        }
                        if (btnInfoFromDocBatch != null)
                        {
                            btnInfoFromDocBatch.Visible = AccessPermission;
                        }
                        if (btnInfoFromDS != null)
                        {
                            btnInfoFromDS.Visible = false;
                        }
                        if (InfoFromDoc != null)
                        {
                            InfoFromDoc.Attributes.Add("onclick", "uploadfile(this);");
                        }
                        if (btnEditItem != null)
                        {
                            btnEditItem.Visible = false;
                        }
                        if (btnCopyItem != null)
                        {
                            btnCopyItem.Visible = false;
                        }
                        if (btnAddConfirm != null)
                        {
                            btnAddConfirm.Visible = false;
                        }
                        if (btnImportFromDoc != null)
                        {
                            btnImportFromDoc.Visible = false;
                        }
                    }
                    else if (ImportDSMode && SystemValidateLibrary.ValidateUserPurview(currentUserInfo.UserID, currentUserInfo.UserGroupID, OPERATION_IMPORT_DS_PURVIEW_ID))
                    {
                        //if (ControlContainer != null)
                        //{
                        //    ControlContainer.Visible = false;
                        //}
                        if (ImportControlContainer != null)
                        {
                            ImportControlContainer.Visible = AccessPermission;
                        }
                        if (btnInfoFromDoc != null)
                        {
                            btnInfoFromDoc.Visible = false;
                        }
                        if (btnInfoFromDocBatch != null)
                        {
                            btnInfoFromDocBatch.Visible = false;
                        }
                        if (btnInfoFromDS != null)
                        {
                            btnInfoFromDS.Visible = AccessPermission;
                        }
                        if (btnInfoFromDocCancel != null)
                        {
                            btnInfoFromDocCancel.Visible = false;
                        }
                        if (InfoFromDoc != null)
                        {
                            InfoFromDoc.Attributes.Add("onclick", "uploadfile(this);");
                        }
                        if (btnEditItem != null)
                        {
                            btnEditItem.Visible = false;
                        }
                        if (btnCopyItem != null)
                        {
                            btnCopyItem.Visible = false;
                        }
                        if (btnAddConfirm != null)
                        {
                            btnAddConfirm.Visible = false;
                        }
                        if (btnImportFromDoc != null)
                        {
                            btnImportFromDoc.Visible = false;
                        }
                    }
                    else
                    {
                        if (btnEditItem != null)
                        {
                            btnEditItem.Visible = btnEditItem.Visible && AccessPermission;
                            btnEditItem.Attributes.Add("onclick", "window.location='{0}';".FormatInvariantCulture(GetEditPageUrl(ObjectID)));
                        }
                        if (btnCopyItem != null)
                        {
                            btnCopyItem.Visible = ViewMode && AccessPermission;
                            btnCopyItem.Attributes.Add("onclick", "window.location='{0}';".FormatInvariantCulture(GetCopyPageUrl(ObjectID)));
                        }
                        if (ControlContainer != null)
                        {
                            ControlContainer.Visible = AccessPermission;
                        }
                        if (btnAddConfirm != null)
                        {
                            btnAddConfirm.Visible = (CopyMode || AddMode || EditMode) && AccessPermission;
                        }
                        if (ImportControlContainer != null)
                        {
                            ImportControlContainer.Visible = false;
                        }
                        if (btnInfoFromDoc != null)
                        {
                            btnInfoFromDoc.Visible = false;
                        }
                        if (btnInfoFromDocBatch != null)
                        {
                            btnInfoFromDocBatch.Visible = false;
                        }
                        if (btnInfoFromDS != null)
                        {
                            btnInfoFromDS.Visible = false;
                        }
                        if (btnInfoFromDocCancel != null)
                        {
                            btnInfoFromDocCancel.Visible = false;
                        }
                    }
                }
                #endregion add page

                #region search page
                if (CurrentPageFileName.Equals(WEBUI_SEARCH_FILENAME, StringComparison.OrdinalIgnoreCase))
                {
                    var PageTitle = MainContentPlaceHolder.FindControl("PageTitle") as Literal;
                    if (PageTitle != null)
                    {
                        PageTitle.Text = PageHeaderTitle;
                    }
                    if (!AccessPermission)
                    {
                        var advancesearchpage = MainContentPlaceHolder.FindControl("advancesearchpage");
                        if (advancesearchpage != null)
                        {
                            advancesearchpage.Visible = false;
                        }
                        var SearchPageTopButtonBar = MainContentPlaceHolder.FindControl("SearchPageTopButtonBar");
                        if (SearchPageTopButtonBar != null)
                        {
                            SearchPageTopButtonBar.Visible = false;
                        }
                        var SearchPageTopToolBar = MainContentPlaceHolder.FindControl("SearchPageTopToolBar");
                        if (SearchPageTopToolBar != null)
                        {
                            SearchPageTopToolBar.Visible = false;
                        }
                        var ListControl = MainContentPlaceHolder.FindControl("ListControl");
                        if (ListControl != null)
                        {
                            ListControl.Visible = false;
                        }
                    }
                }
                #endregion search page

                #region detail page
                if (CurrentPageFileName.Equals(WEBUI_DETAIL_FILENAME, StringComparison.OrdinalIgnoreCase))
                {
                    if (btnEditItem != null)
                    {
                        btnEditItem.Visible = btnEditItem.Visible && AccessPermission;
                        btnEditItem.Attributes.Add("onclick", "window.location='{0}';".FormatInvariantCulture(GetEditPageUrl(ObjectID)));
                    }
                    if (btnCopyItem != null)
                    {
                        btnCopyItem.Visible = AccessPermission;
                        btnCopyItem.Attributes.Add("onclick", "window.location='{0}';".FormatInvariantCulture(GetCopyPageUrl(ObjectID)));
                    }
                    var ControlContainer = MainContentPlaceHolder.FindControl("ControlContainer");
                    if (ControlContainer != null)
                    {
                        ControlContainer.Visible = AccessPermission;
                    }
                    var btnPrintPage = MainContentPlaceHolder.FindControl("btnPrintPage");
                    if (btnPrintPage != null)
                    {
                        btnPrintPage.Visible = AccessPermission;
                    }
                }
                #endregion detail page
            }
        }
Ejemplo n.º 3
0
    private void ValidateUserLogin()
    {
        htInputParameter = new Hashtable();
        htInputParameter.Add("UserLoginName", txtUserLoginName.Text);
        htInputParameter.Add("Password", txtPassword.Text);
        htInputParameter.Add("LastLoginIP", Request.ServerVariables["REMOTE_ADDR"]);
        htInputParameter.Add("lcodeFromUrl", Request.QueryString["lcode"]);
        htInputParameter.Add("UserID", null);
        htInputParameter.Add("UserGroupID", null);
        htInputParameter.Add("UserNickName", null);

        //对输入参数进行检验
        if (ValidateInputParameter() || !DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_SAVE_LOGIN_STATUS]))
        {
            if (((string)htInputParameter["Password"]).Length != 32)
            {
                htInputParameter["Password"] = SecurityManager.MD5(htInputParameter["Password"].ToString(), 32);
            }
            htOutputParameter = SystemValidateLibrary.ValidateUserLogin(htInputParameter);
            if (htOutputParameter[ConstantsManager.MESSAGE_ID] == DBNull.Value)
            {
                //初始化用户登录数据登录
                Session[ConstantsManager.SESSION_USER_ID]         = htOutputParameter["UserID"].ToString();
                Session[ConstantsManager.SESSION_USER_GROUP_ID]   = htOutputParameter["UserGroupID"].ToString();
                Session[ConstantsManager.SESSION_USER_LOGIN_NAME] = htOutputParameter["UserLoginName"].ToString();
                Session[ConstantsManager.SESSION_USER_NICK_NAME]  = htOutputParameter["UserNickName"].ToString();
                Session[ConstantsManager.SESSION_SSDW_ID]         = htOutputParameter["SubjectID"].ToString();
                Response.Cookies.Add(new HttpCookie(ConstantsManager.COOKIE_USER_ID, Server.UrlEncode(htOutputParameter["UserID"].ToString())));
                Response.Cookies.Add(new HttpCookie(ConstantsManager.COOKIE_USER_GROUP_ID, Server.UrlEncode(htOutputParameter["UserGroupID"].ToString())));
                Response.Cookies.Add(new HttpCookie(ConstantsManager.COOKIE_USER_LOGIN_NAME, Server.UrlEncode(htOutputParameter["UserLoginName"].ToString())));
                Response.Cookies[ConstantsManager.COOKIE_USER_LOGIN_NAME].Expires = DateTime.Now.AddDays(20);
                Response.Cookies.Add(new HttpCookie(ConstantsManager.COOKIE_USER_NICK_NAME, Server.UrlEncode(htOutputParameter["UserNickName"].ToString())));
                Response.Cookies.Add(new HttpCookie(ConstantsManager.COOKIE_SSDW_ID, Server.UrlEncode(htOutputParameter["SubjectID"].ToString())));
                if (chkSaveLoginStatus.Checked)
                {
                    Response.Cookies.Add(new HttpCookie(ConstantsManager.COOKIE_PASSWORD, Server.UrlEncode((string)htInputParameter["Password"])));
                    Response.Cookies[ConstantsManager.COOKIE_PASSWORD].Expires = DateTime.Now.AddDays(180);
                    Response.Cookies.Add(new HttpCookie(ConstantsManager.COOKIE_SAVE_LOGIN_STATUS, Server.UrlEncode("true")));
                    Response.Cookies[ConstantsManager.COOKIE_SAVE_LOGIN_STATUS].Expires = DateTime.Now.AddDays(180);
                }
                //得到登录成功消息
                strMessageInfo = MessageManager.GetMessageInfo(MessageManager.HINT_MSGID_0001, strMessageInfo);

                //记录日志开始
                string strLogTypeID = "A01";
                strMessageParam[0] = htOutputParameter["UserLoginName"].ToString();
                string strLogContent = MessageManager.GetMessageInfo(MessageManager.LOG_MSGID_0001, strMessageParam);
                LogLibrary.LogWrite(strLogTypeID, strLogContent, null, null, null);
                //记录日志结束

                //添加用户在线信息开始
                //                RICH.Common.BM.T_PM_UserOnlineInfo.T_PM_UserOnlineInfoApplicationData appData = new RICH.Common.BM.T_PM_UserOnlineInfo.T_PM_UserOnlineInfoApplicationData();
                //                RICH.Common.BM.T_PM_UserOnlineInfo.T_PM_UserOnlineInfoApplicationLogic instanceT_PM_UserOnlineInfoApplicationLogic
                //= (RICH.Common.BM.T_PM_UserOnlineInfo.T_PM_UserOnlineInfoApplicationLogic)CreateApplicationLogicInstance(typeof(RICH.Common.BM.T_PM_UserOnlineInfo.T_PM_UserOnlineInfoApplicationLogic));
                //                appData.UserID = (string)Session[ConstantsManager.SESSION_USER_ID];
                //                appData.OPCode = RICH.Common.Base.ApplicationData.ApplicationDataBase.OPType.PK;
                //                instanceT_PM_UserOnlineInfoApplicationLogic.Delete(appData);
                //                appData.AccessDate = DateTime.Now;
                //                appData.AccessIP = RICH.Common.IM.IPAddessLibrary.GetRemoteTrueIP();
                //                //appData.AccessLocation = RICH.Common.IM.IPAddessLibrary.GetLocationFromIP(appData.AccessIP.ToString());
                //                appData = instanceT_PM_UserOnlineInfoApplicationLogic.Add(appData);
                //添加用户在线信息结束

                //对正确消息进行处理
                Response.Write(strMessageInfo);
                Response.Redirect(this.IsMobileDevice() && chkSaveLoginStatus.Checked
                                      ? "Default.aspx?lcode={0}".FormatInvariantCulture(htOutputParameter["lcode"])
                                      : "Default.aspx");
            }
            else
            {
                //记录日志开始
                string strLogTypeID = "A01";
                strMessageParam[0] = htOutputParameter["UserLoginName"].ToString();
                string strLogContent = MessageManager.GetMessageInfo(MessageManager.LOG_MSGID_0002, strMessageParam);
                LogLibrary.LogWrite(strLogTypeID, strLogContent, null, null, null);
                //记录日志结束

                strMessageInfo = MessageManager.GetMessageInfo((string)htOutputParameter[ConstantsManager.MESSAGE_ID], strMessageInfo);
                //对错误消息进行处理
                Session.Remove(ConstantsManager.SESSION_CURRENT_PURVIEW);
                MessageLabel.Text = strMessageInfo;
            }
        }
        else
        {
            //对错误消息进行处理
            Session.Remove(ConstantsManager.SESSION_CURRENT_PURVIEW);
            MessageLabel.Text = strMessageInfo;
        }
    }