Пример #1
0
 protected override void OnPreRender(EventArgs e)
 {
     base.OnPreRender(e);
     //Приходится делать SetCulture, т.к. есть подозрение что Sharepoint в какой то момент устанавливает свою Culture
     ClientScript.RegisterClientScriptResource(typeof(BaseMainPage), "Nat.Web.Controls.GenerationClasses.MainScripts.js");
     LocalizationHelper.SetCulture();
     BaseMainPage.RegisterStartupScript(Page, GetType(), _updateProgressBar.ClientID);
 }
Пример #2
0
        protected override void OnInit(EventArgs e)
        {
            if (File.Exists(HttpContext.Current.Server.MapPath("WebServiceFilters.asmx")))
            {
                ScriptManager?.Services.Add(
                    new ServiceReference
                {
                    Path = "/WebServiceFilters.asmx",
                });
            }

            Trace.WriteExt("BaseMainPage.BeginOnInit");
            if (PlaceHolderInUpInternal != null)
            {
                hiddenfieldForUrl    = new HiddenField();
                hiddenfieldForUrl.ID = "hfCUrl";
                PlaceHolderInUpInternal.Controls.Add(hiddenfieldForUrl);
                var value = Request.Params[hiddenfieldForUrl.UniqueID];
                if (!string.IsNullOrEmpty(value))
                {
                    MainPageUrlBuilder.Current = new MainPageUrlBuilder(value);
                }
            }

            var url = MainPageUrlBuilder.Current;

            if (url.IsDownload)
            {
                if (url.QueryParameters.ContainsKey("ManagerType"))
                {
                    var type        = BuildManager.GetType(url.QueryParameters["ManagerType"], false, true);
                    var fileManager = (IFileManager)Activator.CreateInstance(type);
                    if (fileManager.CheckPermit(Page))
                    {
                        fileManager.DownloadFile(Convert.ToInt64(url.QueryParameters["ID"]), url.QueryParameters["fieldName"], Response);
                        _control = Page.LoadControl("/UserControls/FileNotExists.ascx");
                    }
                    else
                    {
                        _control = Page.LoadControl("/UserControls/NoPermit.ascx");
                    }
                    PlaceHolder.Controls.Add(_control);
                }
            }

            if (url.IsExecute)
            {
                if (url.QueryParameters.ContainsKey("ManagerType"))
                {
                    var type           = BuildManager.GetType(url.QueryParameters["ManagerType"], false, true);
                    var executeManager = (IExecuteManager)Activator.CreateInstance(type);
                    if (executeManager.CheckPermit(Page))
                    {
                        executeManager.Execute(url.QueryParameters, Page);
                    }
                    else
                    {
                        _control = Page.LoadControl("/UserControls/NoPermit.ascx");
                    }
                    PlaceHolder.Controls.Add(_control);
                }
            }
            else if (!string.IsNullOrEmpty(url.UserControl))
            {
                if (!EmptyPage)
                {
                    _updateProgressBar = new UpdateProgressBar
                    {
                        ModalPopupBehaviorID = "UpdateProgressBar"
                    };
                    _picturePreview = (PicturePreview)LoadControl("/Preview/PicturePreview.ascx");
                    Form.Controls.Add(_updateProgressBar);
                    Form.Controls.Add(_picturePreview);
                }

                string redirectUrl = GetRedirectUrl(url.UserControl);
                if (!string.IsNullOrEmpty(redirectUrl))
                {
                    Response.Redirect(redirectUrl);
                }
                _control = BaseMainPage.LoadControl(Page, url.UserControl);
                //проверка прав, если нет прав, то загрузить контрол "Нет прав"
                var access = _control as IAccessControl;
                Trace.WriteExt("BaseMainPage.OnInit.BeginCheckPermit");
                if ((access != null && !access.CheckPermit(this)))
                {
                    _control = Page.LoadControl("/UserControls/NoPermit.ascx");
                }
                Trace.WriteExt("BaseMainPage.OnInit.EndCheckPermit");
                if (!UserRoles.IsInRole(UserRoles.ADMIN))
                {
                    Trace.WriteExt("BaseMainPage.OnInit.BeginEnsureRecordCardCorrect");
                    var userControl = EnsureRecordCardCorrect();
                    Trace.WriteExt("BaseMainPage.OnInit.EndEnsureRecordCardCorrect");
                    if (userControl != null)
                    {
                        _control = userControl;
                    }
                }

                if (url.NavigateTo)
                {
                    var navControl  = (AbstractUserControl)_control;
                    var projectName = navControl.ProjectName;
                    var tableName   = navControl.TableName;
                    var baseType    = navControl.GetType().BaseType;

                    if (string.IsNullOrEmpty(projectName))
                    {
                        projectName = baseType.Assembly.FullName.Split(',')[0];
                    }

                    if (string.IsNullOrEmpty(tableName) && baseType.Name.EndsWith(MainPageUrlBuilder.UserControlTypeEdit))
                    {
                        tableName = baseType.Name;
                        tableName = tableName.Substring(0, tableName.Length - MainPageUrlBuilder.UserControlTypeEdit.Length);
                    }

                    var navigateUrl = NavigatorManager.GetReadUrlForRecord(
                        projectName,
                        tableName,
                        url.QueryParameters[MainPageUrlBuilder.ReferencIDPrefix + tableName],
                        url.QueryParameters.ContainsKey(MainPageUrlBuilder.NavigateToDestinationParentTableName)
                            ? url.QueryParameters[MainPageUrlBuilder.NavigateToDestinationParentTableName]
                            : string.Empty,
                        regexPublicKeyToken.Match(baseType.Assembly.FullName).Groups[1].Value);
                    Response.Redirect(navigateUrl);
                }

                var selected = _control as ISelectedValue;
                _control.ID = "item";
                var placeHolder = GetMainPlaceHolder();
                if (url.TimeoutInSQL)
                {
                    placeHolder.Controls.Add(new Literal
                    {
                        Text = "<span class=\"font14\" style=\"color:red\">"
                               + Resources.SFilterInSqlTimeOutException
                               + "</span>",
                    });
                }

                if (_control is IFilterSupport fSupport && InitializerSection.AddFilterInMainPageInternal && (url.IsSelect || url.ShowFilter))
                {
                    _filterControl    = LoadControlFilter(fSupport.GetDefaultFilterControl());
                    _filterControl.ID = "filter";
                    placeHolder.Controls.Add(_filterControl);
                    placeHolder.Controls.Add(new Literal {
                        Text = "<br /><br />"
                    });
                    fSupport.FilterControl = _filterControl.ID;
                }

                if (selected != null)
                {
                    selected.ShowHistory = url.ShowHistory;
                    selected.IsNew       = url.IsNew;
                    selected.IsRead      = url.IsRead;
                    selected.IsSelect    = url.IsSelect;
                }

                placeHolder.Controls.Add(_control);
            }
            else if (!string.IsNullOrEmpty(DefaultControl))
            {
                _control = Page.LoadControl(DefaultControl);
                if (_control != null)
                {
                    PlaceHolder.Controls.Add(_control);
                }
            }
            Trace.WriteExt("BaseMainPage.EndOnInit");
            base.OnInit(e);
            PreRenderComplete += Page_PreRenderComplete;
        }
Пример #3
0
 private void Page_PreRenderComplete(object sender, EventArgs e)
 {
     BaseMainPage.ChangeFormSubmit(Form);
 }