示例#1
0
        private void initSelectedView(bool ForceReload)
        {
            //bz # 5150 init from query param
            string ViewIdFromQueryParam = string.Empty;
            bool   ViewLoaded           = false;

            if (_CswNbtView == null || ForceReload)
            {
                if (Request.QueryString["viewid"] != null && Request.QueryString["viewid"] != string.Empty)
                {
                    ViewIdFromQueryParam = CswTools.QueryStringParamToUrl(Request.QueryString["viewid"].ToString());
                    CswNbtViewId TargetViewId = new CswNbtViewId(CswConvert.ToInt32(ViewIdFromQueryParam));
                    if (Session["ViewId"] != null && Session["ViewId"].ToString() != TargetViewId.ToString())   // BZ 10125
                    {
                        ViewLoaded = (null != (_CswNbtView = CswNbtResources.ViewSelect.restoreView(TargetViewId)));
                    }
                }

                if (false == ViewLoaded)
                {
                    if (Session["ActionId"] != null)
                    {
                        // Action
                        _ActionId = CswConvert.ToInt32(Session["ActionId"].ToString());
                        // BZ 9934 - No need for 'default view' anymore
                        //// this is for when we come back
                        //_CswNbtView = (CswNbtView) CswNbtViewFactory.restoreView( CswNbtResources, CswNbtResources.CurrentNbtUser.DefaultViewId );

                        if (ForceReload)
                        {
                            Master.HandleLoadAction(_ActionId);
                        }
                    }
                    else
                    {
                        // View
                        _CswNbtView = new CswNbtView(CswNbtResources);
                        if (Session["SessionViewId"] != null)
                        {
                            CswNbtSessionDataId SessionDataId = null;
                            Int32 SessionViewId = CswConvert.ToInt32(Session["SessionViewId"]);
                            if (Int32.MinValue != SessionViewId)
                            {
                                SessionDataId = new CswNbtSessionDataId(SessionViewId);
                            }
                            else
                            {
                                string SessionDataIdString = CswConvert.ToString(Session["SessionViewId"]);
                                if (false == string.IsNullOrEmpty(SessionDataIdString))
                                {
                                    SessionDataId = new CswNbtSessionDataId(SessionDataIdString);
                                }
                            }
                            if (null != SessionDataId && SessionDataId.isSet())
                            {
                                _CswNbtView = CswNbtResources.ViewSelect.getSessionView(SessionDataId);
                                ViewLoaded  = (null != _CswNbtView);
                            }
                        }

                        if (Session["ViewId"] != null)
                        {
                            CswNbtViewId NbtViewId = null;
                            Int32        ViewId    = CswConvert.ToInt32(Session["ViewId"]);
                            if (Int32.MinValue != ViewId)
                            {
                                NbtViewId = new CswNbtViewId(ViewId);
                            }
                            else
                            {
                                string ViewIdStr = CswConvert.ToString(Session["ViewId"]);
                                if (false == string.IsNullOrEmpty(ViewIdStr))
                                {
                                    NbtViewId = new CswNbtViewId(ViewIdStr);
                                }
                            }
                            if (null != NbtViewId && NbtViewId.isSet())
                            {
                                _CswNbtView = CswNbtResources.ViewSelect.restoreView(NbtViewId);
                                ViewLoaded  = (null != _CswNbtView);
                            }
                        }

                        if (false == ViewLoaded && Session["ViewXml"] != null)
                        {
                            string SessionViewXml = CswConvert.ToString(Session["ViewXml"]);
                            if (false == string.IsNullOrEmpty(SessionViewXml))
                            {
                                _CswNbtView = CswNbtResources.ViewSelect.restoreView(SessionViewXml);
                            }
                            ViewLoaded = (null != _CswNbtView);
                        }

                        // BZ 9934 - No need for 'default view' anymore
                        //if( !ViewLoaded && CswNbtResources.CurrentUser != null && CswNbtResources.CurrentNbtUser.DefaultViewId > 0 )
                        //    ViewLoaded = ( null != ( _CswNbtView = (CswNbtView) CswNbtViewFactory.restoreView( CswNbtResources, CswNbtResources.CurrentNbtUser.DefaultViewId ) ) );

                        if (ForceReload)
                        {
                            Master.HandleLoadView(_CswNbtView);
                        }
                    }
                }

                if (_CswNbtView == null)
                {
                    // BZ 8321 - If all else fails, use an empty view
                    _CswNbtView = new CswNbtView(CswNbtResources);
                }
            } // if( _CswNbtView == null || ForceReload )
        }     // initSelectedView()