Exemple #1
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                //bz # 9278


                CswSessionResourcesNbt = new CswSessionResourcesNbt(Context.Application, Context.Request, Context.Response, Context, string.Empty, CswEnumSetupMode.NbtWeb);


                CswNbtResources = CswSessionResourcesNbt.CswNbtResources;


                _CswSessionManager      = CswSessionResourcesNbt.CswSessionManager;
                _CswNbtStatisticsEvents = CswSessionResourcesNbt.CswNbtStatisticsEvents;
                CswNbtResources.beginTransaction();

                // Setup statistics events
                OnEndOfPageLifeCycle += new EndOfPageLifeCycleHandler(_CswNbtStatisticsEvents.OnEndOfPageLifeCycle);

                //CswNbtResources.CswNbtNodeFactory.OnWriteNode += new CswNbtNode.OnRequestWriteNodeHandler( _CswNbtStatisticsEvents.OnWriteNode );
                //CswNbtResources.CswNbtNodeFactory.OnDeleteNode += new CswNbtNode.OnRequestDeleteNodeHandler( _CswNbtStatisticsEvents.OnDeleteNode );



                LogTimerResult("Base.OnInit() started", Timer.ElapsedDurationInSecondsAsString);

                //bz # 9278
                if (_CswSessionManager.IsAuthenticated() && _CswSessionManager.TimedOut)
                {
                    string LP = LogoutPath;
                    if (Page.Request.IsAuthenticated)
                    {
                        FormsAuthentication.SignOut();
                    }
                    //ReleaseAll();
                    //CswSessionResourcesNbt.DeAuthenticate(); //bz # 6163
                    Redirect(LP);
                }

                if (!CswSessionManager.IsAuthenticated())
                {
                    string ScriptName = HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"];
                    if (ScriptName.Substring(ScriptName.LastIndexOf('/')) != "/Main.html")
                    {
                        //ReleaseAll();
                        Redirect(LogoutPath);
                    }
                }

                base.OnInit(e);

                LogTimerResult("Base.OnInit() finished", Timer.ElapsedDurationInSecondsAsString);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }//OnInit()
        private bool _isChemSWAdminImpersonating(CswSessionResourcesNbt CswSessionResources)
        {
            bool Ret = false;

            if (CswSessionResources.CswSessionManager.isImpersonating())
            {
                Ret = _CswNbtResources.CswResources.AuditUsername.Equals(CswNbtObjClassUser.ChemSWAdminUsername);
            }

            return(Ret);
        }
Exemple #3
0
        public NodeTypeTreeService()
        {
            //        CswNbtSession CswSessionWeb = new CswNbtSession( Context.Application, Context.Session, Context.Request, Context.Response );


            //bz # 9278


            CswSessionResourcesNbt CswInitialization = new CswSessionResourcesNbt(Context.Application, Context.Request, Context.Response, Context, string.Empty, CswEnumSetupMode.NbtWeb);

            _CswNbtResources = CswInitialization.CswNbtResources;



            //string SessionId = string.Empty;
            //HttpCookie SessionCookie = Context.Request.Cookies.Get( CswSessionWeb.SessionCookieName );
            //if ( null != SessionCookie )
            //{
            //    SessionId = SessionCookie.Value;
            //    if ( string.Empty != SessionId )
            //    {
            //        CswNbtInitialization CswInitialization = new CswNbtInitialization( CswSessionWeb, _FilesPath, SetupMode.Web, null, null );
            //        _CswNbtResources = CswInitialization.CswNbtResources;
            //        _CswNbtResources.AccessId = "1"; //KLUDGE: SHould be masterid
            //        _CswNbtResources.CswResources.refreshDataDictionary();
            //        CswSessionWeb.CswNbtResources = _CswNbtResources;

            //        if ( CswSessionWeb.load( SessionId ) )
            //        {
            //            _CswNbtResources.AccessId = CswSessionWeb.AccessId;
            //        }
            //        else
            //        {
            //            throw ( new CswDniException( "Login required", "SessionId " + SessionCookie + " is not persisted" ) );
            //        }
            //    }
            //    else
            //    {
            //        throw ( new CswDniException( "Login required", "The cookie " + CswSessionWeb.SessionCookieName + " exists but has an empty value" ) );
            //    }
            //}
            //else
            //{
            //    throw ( new CswDniException( "Login required", "User should never have had a link to this page without having logged in" ) );
            //}
        }//ctor
        public ICswResources initResources()
        {
            _CswSessionResourcesNbt = new CswSessionResourcesNbt(_HttpContext.Application, _HttpContext.Request, _HttpContext.Response, _HttpContext, string.Empty, CswEnumSetupMode.NbtWeb);
            _CswNbtResources        = _CswSessionResourcesNbt.CswNbtResources;
            _CswNbtResources.beginTransaction();

            if (null != _AuthenticationRequest.RequiredModules)
            {
                foreach (string RequiredModule in _AuthenticationRequest.RequiredModules)
                {
                    if (false == _CswNbtResources.Modules.IsModuleEnabled(RequiredModule))
                    {
                        throw new CswDniException(CswEnumErrorType.Warning, "Not all required modules are enabled. Please contact your administrator.", "The " + RequiredModule + " module is required in order to complete this request.");
                    }
                }
            }
            _SessionAuthenticate = new CswNbtSessionAuthenticate(_CswNbtResources, _CswSessionResourcesNbt.CswSessionManager, _AuthenticationRequest);
            return(_CswNbtResources);
        }//_initResources()
        public static void wAddAuthenticationStatus(CswNbtResources CswNbtResources, CswSessionResourcesNbt CswSessionResources, CswWebSvcReturn SvcReturn, CswEnumAuthenticationStatus AuthenticationStatusIn, HttpContext HttpContext)
        {
            // ******************************************
            // IT IS VERY IMPORTANT for this function not to require the use of database resources,
            // since it occurs AFTER the call to _deInitResources(), and thus will leak Oracle connections
            // (see case 26273)
            // ******************************************
            if (null != SvcReturn)
            {
                SvcReturn.Authentication = SvcReturn.Authentication ?? new CswWebSvcSessionAuthenticateData.Authentication.Response();
                SvcReturn.Authentication.AuthenticationStatus = AuthenticationStatusIn;
                if (null != CswNbtResources)
                {
                    if (null != CswNbtResources.CswSessionManager)
                    {
                        SvcReturn.Authentication.TimeOut = CswDateTime.ToClientAsJavascriptString(CswNbtResources.CswSessionManager.TimeoutDate);
                    }
                    if (SvcReturn.Authentication.AuthenticationStatus == CswEnumAuthenticationStatus.ExpiredPassword)
                    {
                        SvcReturn.Authentication.ExpirationReset = new CswWebSvcSessionAuthenticateData.Authentication.Response.Expired();

                        ICswNbtUser CurrentUser = CswNbtResources.CurrentNbtUser;
                        SvcReturn.Authentication.ExpirationReset.UserId = CurrentUser.UserId.ToString();
                        CswNbtNodeKey FakeKey = new CswNbtNodeKey()
                        {
                            NodeId        = CurrentUser.UserId,
                            NodeSpecies   = CswEnumNbtNodeSpecies.Plain,
                            NodeTypeId    = CurrentUser.UserNodeTypeId,
                            ObjectClassId = CurrentUser.UserObjectClassId
                        };
                        SvcReturn.Authentication.ExpirationReset.UserKey = FakeKey.ToString();
                        CswPropIdAttr PasswordPropIdAttr = new CswPropIdAttr(CurrentUser.UserId, CurrentUser.PasswordPropertyId);
                        SvcReturn.Authentication.ExpirationReset.PasswordId = PasswordPropIdAttr.ToString();
                    }

                    SvcReturn.Performance               = SvcReturn.Performance ?? new CswWebSvcReturnBase.Performance();
                    SvcReturn.Performance.ServerInit    = Math.Round(CswNbtResources.ServerInitTime, 3);
                    SvcReturn.Performance.DbDeinit      = Math.Round(CswNbtResources.CswLogger.DbInitTime, 3);
                    SvcReturn.Performance.DbQuery       = Math.Round(CswNbtResources.CswLogger.DbQueryTime, 3);
                    SvcReturn.Performance.DbCommit      = Math.Round(CswNbtResources.CswLogger.DbCommitTime, 3);
                    SvcReturn.Performance.DbDeinit      = Math.Round(CswNbtResources.CswLogger.DbDeInitTime, 3);
                    SvcReturn.Performance.TreeLoaderSql = Math.Round(CswNbtResources.CswLogger.TreeLoaderSQLTime, 3);
                    SvcReturn.Performance.ServerTotal   = Math.Round(CswNbtResources.TotalServerTime, 3);

                    SvcReturn.Logging            = SvcReturn.Logging ?? new CswWebSvcReturnBase.Logging();
                    SvcReturn.Logging.CustomerId = CswNbtResources.AccessId;
                    SvcReturn.Logging.Server     = Environment.MachineName;
                    CswEnumLogLevels LogLevel = CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.Logging_Level);

                    if (LogLevel == CswNbtResources.UnknownEnum)
                    {
                        LogLevel = CswEnumLogLevels.Error;
                    }
                    SvcReturn.Logging.LogLevel = LogLevel;

                    // Return any messages acquired along the way
                    if (null != CswNbtResources.Messages && CswNbtResources.Messages.Count > 0)
                    {
                        SvcReturn.Status.Messages = CswNbtResources.Messages;
                    }
                }
            }
            HttpCookie AuthStatusCookie = HttpContext.Request.Cookies["CswAuthStatus"];

            if (null == AuthStatusCookie)
            {
                AuthStatusCookie = new HttpCookie("CswAuthStatus")
                {
                    HttpOnly = true
                };
            }
            if (AuthStatusCookie.Value != AuthenticationStatusIn.ToString())
            {
                AuthStatusCookie.Value = AuthenticationStatusIn;
                HttpContext.Response.Cookies.Add(AuthStatusCookie);
            }
        } // wAddAuthenticationStatus()
        public static void jAddAuthenticationStatus(CswNbtResources CswNbtResources, CswSessionResourcesNbt CswSessionResources, JObject SvcReturn, CswEnumAuthenticationStatus AuthenticationStatusIn, bool IsMobile = false)
        {
            if (SvcReturn != null)
            {
                SvcReturn["AuthenticationStatus"]     = AuthenticationStatusIn.ToString();
                SvcReturn["AuthenticationStatusText"] = CswEnumAuthenticationStatus.EuphamizedText[AuthenticationStatusIn];
                if (false == IsMobile)
                {
                    SvcReturn["server"] = Environment.MachineName;
                    if (null != CswNbtResources)
                    {
                        if (null != CswNbtResources.CswSessionManager)
                        {
                            SvcReturn["timeout"] = CswDateTime.ToClientAsJavascriptString(CswNbtResources.CswSessionManager.TimeoutDate);
                        }
                        if (AuthenticationStatusIn == CswEnumAuthenticationStatus.ExpiredPassword)
                        {
                            ICswNbtUser CurrentUser = CswNbtResources.CurrentNbtUser;
                            SvcReturn.Add(new JProperty("nodeid", CurrentUser.UserId.ToString()));
                            CswNbtNodeKey FakeKey = new CswNbtNodeKey()
                            {
                                NodeId        = CurrentUser.UserId,
                                NodeSpecies   = CswEnumNbtNodeSpecies.Plain,
                                NodeTypeId    = CurrentUser.UserNodeTypeId,
                                ObjectClassId = CurrentUser.UserObjectClassId
                            };
                            SvcReturn.Add(new JProperty("nodekey", FakeKey.ToString()));
                            CswPropIdAttr PasswordPropIdAttr = new CswPropIdAttr(CurrentUser.UserId, CurrentUser.PasswordPropertyId);
                            SvcReturn.Add(new JProperty("passwordpropid", PasswordPropIdAttr.ToString()));
                        }

                        SvcReturn["timer"] = new JObject();

                        SvcReturn["timer"]["serverinit"] = Math.Round(CswNbtResources.ServerInitTime, 3);
                        CswEnumLogLevels LogLevel = CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.Logging_Level);
                        if (LogLevel == CswNbtResources.UnknownEnum)
                        {
                            LogLevel = CswEnumLogLevels.Error;
                        }
                        SvcReturn["LogLevel"] = LogLevel.ToString().ToLower();

                        SvcReturn["timer"]["customerid"]    = CswNbtResources.AccessId;
                        SvcReturn["timer"]["dbinit"]        = Math.Round(CswNbtResources.CswLogger.DbInitTime, 3);
                        SvcReturn["timer"]["dbquery"]       = Math.Round(CswNbtResources.CswLogger.DbQueryTime, 3);
                        SvcReturn["timer"]["dbcommit"]      = Math.Round(CswNbtResources.CswLogger.DbCommitTime, 3);
                        SvcReturn["timer"]["dbdeinit"]      = Math.Round(CswNbtResources.CswLogger.DbDeInitTime, 3);
                        SvcReturn["timer"]["treeloadersql"] = Math.Round(CswNbtResources.CswLogger.TreeLoaderSQLTime, 3);
                        SvcReturn["timer"]["servertotal"]   = Math.Round(CswNbtResources.TotalServerTime, 3);

                        // Return any messages acquired along the way
                        if (null != CswNbtResources.Messages && CswNbtResources.Messages.Count > 0)
                        {
                            JArray Messages = new JArray();
                            SvcReturn["messages"] = Messages;
                            foreach (CswWebSvcReturnBase.ErrorMessage Message in CswNbtResources.Messages)
                            {
                                Messages.Add(Message.ToJObject());
                            }
                        }
                    }//if( null != CswNbtResources )
                }
            }
        }
        public JObject makeVersionJson(CswSessionResourcesNbt _CswSessionResources)
        {
            JObject ret = new JObject();

            string AssemblyFilePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "/_Assembly.txt";

            if (File.Exists(AssemblyFilePath))
            {
                TextReader AssemblyFileReader = new StreamReader(AssemblyFilePath);
                ret.Add(new JProperty("assembly", AssemblyFileReader.ReadLine()));
                AssemblyFileReader.Close();
            }

            JObject   ComponentObj   = new JObject();
            JProperty ComponentsProp = new JProperty("components", ComponentObj);

            ret.Add(ComponentsProp);
            string ThisYear = DateTime.Now.Year.ToString();

            ArrayList CswAssemblies = new ArrayList();

            CswAssemblies.Add("NbtWebApp");
            CswAssemblies.Add("CswCommon");
            CswAssemblies.Add("CswWebControls");
            CswAssemblies.Add("NbtLogic");
            CswAssemblies.Add("NbtWebControls");

            foreach (string AssemblyName in CswAssemblies)
            {
                string name = AssemblyName.Contains(",") ? AssemblyName.Substring(0, AssemblyName.IndexOf(',')) : AssemblyName;

                JObject AssemObj = new JObject();
                ComponentObj.Add(new JProperty(name, AssemObj));

                Assembly AssemblyInfo = Assembly.Load(AssemblyName);
                string   Version      = AssemblyInfo.GetName().Version.ToString();
                AssemObj.Add(new JProperty("name", name));
                AssemObj.Add(new JProperty("version", Version));
                AssemObj.Add(new JProperty("copyright", "Copyright © ChemSW, Inc. 2005-" + ThisYear));
            }

            ArrayList ThirdAssemblies = new ArrayList();

            ThirdAssemblies.Add("CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304");
            ThirdAssemblies.Add("Telerik.Web.UI");

            foreach (string AssemblyName in ThirdAssemblies)
            {
                string name = AssemblyName.Contains(",") ? AssemblyName.Substring(0, AssemblyName.IndexOf(',')) : AssemblyName;

                JObject AssemObj = new JObject();
                ComponentObj.Add(new JProperty(name, AssemObj));

                Assembly AssemblyInfo       = Assembly.Load(AssemblyName);
                object[] AssemblyAttributes = (object[])AssemblyInfo.GetCustomAttributes(true);

                string Version   = AssemblyInfo.GetName().Version.ToString();
                string Copyright = string.Empty;
                foreach (AssemblyCopyrightAttribute AssemblyAttribute in AssemblyAttributes.OfType <AssemblyCopyrightAttribute>())
                {
                    Copyright = (AssemblyAttribute).Copyright;
                }
                AssemObj.Add(new JProperty("name", name));
                AssemObj.Add(new JProperty("version", Version));
                AssemObj.Add(new JProperty("copyright", Copyright));
            }

            ComponentObj.Add(new JProperty("Schema",
                                           new JObject(
                                               new JProperty("name", "Schema"),
                                               new JProperty("version", _CswNbtResources.ConfigVbls.getConfigVariableValue("schemaversion")),
                                               new JProperty("copyright", "Copyright &copy; ChemSW, Inc. 2005-" + ThisYear)
                                               )

                                           ));

            #region ChemCatCentral Products Versions
            // Add ChemCatCentral version to the About dialog: Case 29380
            if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.C3Products))
            {
                CswC3Params           CswC3Params     = new CswC3Params();
                CswNbtC3ClientManager C3ClientManager = new CswNbtC3ClientManager(_CswNbtResources, CswC3Params);
                SearchClient          C3SearchClient  = C3ClientManager.initializeC3Client();
                if (null != C3SearchClient)
                {
                    string C3Version = C3ClientManager.getCurrentC3Version();
                    ComponentObj.Add(new JProperty("ChemCatCentral", new JObject(
                                                       new JProperty("name", "ChemCatCentral"),
                                                       new JProperty("version", Regex.Replace(C3Version, "_", " ")),
                                                       new JProperty("copyright", "Copyright &copy; ChemSW, Inc. 2005-" + ThisYear))));

                    // Add the datasource import dates (if they are available to the user and/or the module is enabled
                    CswC3ServiceLogicGetDataSourcesDataSource[] DataSourceDates = C3ClientManager.getDataSourceDates();
                    if (null != DataSourceDates)
                    {
                        JObject DSDatesObj = new JObject();
                        foreach (CswC3ServiceLogicGetDataSourcesDataSource ds in DataSourceDates)
                        {
                            if (ds.DataType == "Extra Chemical")
                            {
                                switch (ds.DataSourceName)
                                {
                                case "FireDb":
                                    if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.FireDbSync))
                                    {
                                        DSDatesObj[ds.DataSourceName] = new JObject(new JProperty("componentName", ds.DataSourceName), new JProperty("value", ds.ImportDate));
                                    }
                                    break;

                                case "PCID":
                                    if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.PCIDSync))
                                    {
                                        DSDatesObj[ds.DataSourceName] = new JObject(new JProperty("componentName", ds.DataSourceName), new JProperty("value", ds.ImportDate));
                                    }
                                    break;
                                } //switch
                            }
                            else
                            {
                                DSDatesObj[ds.DataSourceName] = new JObject(new JProperty("componentName", ds.DataSourceName), new JProperty("value", ds.ImportDate));
                            }
                        }
                        ret.Add(new JProperty("dsDates", DSDatesObj));
                    }
                }//if( C3ClientManager.checkC3ServiceReferenceStatus() )
            }
            #endregion ChemCatCentral Products Versions

            #region ACD Version
            if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.C3ACD))
            {
                CswC3Params           CswC3Params     = new CswC3Params();
                CswNbtC3ClientManager C3ClientManager = new CswNbtC3ClientManager(_CswNbtResources, CswC3Params);
                SearchClient          C3SearchClient  = C3ClientManager.initializeC3Client();
                if (null != C3SearchClient)
                {
                    CswRetObjSearchResults Results = C3SearchClient.getACDVersion(CswC3Params);
                    if (null != Results)
                    {
                        ComponentObj.Add(new JProperty("ACD", new JObject(
                                                           new JProperty("name", "Available Chemicals Directory (ACD)"),
                                                           new JProperty("version", Regex.Replace(Results.ACDVersion, "_", " ")),
                                                           new JProperty("copyright", "Copyright &copy; Accelrys, Inc. 1983-" + ThisYear))));
                    }
                }
            }
            #endregion ACD Version


            SortedList <string, CswSessionsListEntry> sessions = _CswSessionResources.CswSessionManager.SessionsList.AllSessions;
            CswDateTime loginDate = new CswDateTime(_CswNbtResources);
            foreach (var entry in sessions)
            {
                CswSessionsListEntry sessionEntry = entry.Value;
                if (sessionEntry.UserName.Equals(_CswNbtResources.CurrentUser.Username))
                {
                    loginDate.FromClientDateString(sessionEntry.LoginDate.ToString());
                }
            }

            JObject UserObj = new JObject();
            UserObj["customerid"]   = new JObject(new JProperty("componentName", "Customer ID:"), new JProperty("value", _CswNbtResources.AccessId));
            UserObj["loggedinas"]   = new JObject(new JProperty("componentName", "Logged in as:"), new JProperty("value", _CswNbtResources.CurrentUser.Username));
            UserObj["sessionsince"] = new JObject(new JProperty("componentName", "Session since:"), new JProperty("value", loginDate.ToDateTime().ToString()));

            ret.Add(new JProperty("userProps", UserObj));

            return(ret);
        } // makeVersionJson()
        public JObject getHeaderMenu(CswSessionResourcesNbt CswSessionResources)
        {
            JObject Ret = new JObject();

            Ret["Home"] = new JObject(new JProperty("action", "Home"));
            if (_CswNbtResources.CurrentNbtUser.IsAdministrator() || CswSessionResources.CswSessionManager.isImpersonating())
            {
                Ret["Admin"] = new JObject();
                Ret["Admin"]["haschildren"] = true;
                if (_CswNbtResources.CurrentNbtUser.IsAdministrator())
                {
                    Ret["Admin"]["Current User List"]           = new JObject();
                    Ret["Admin"]["Current User List"]["action"] = "Sessions";
                    Ret["Admin"]["Edit Config Vars"]            = new JObject();
                    Ret["Admin"]["Edit Config Vars"]["action"]  = "Config Vars";
                    //Ret["Admin"]["Statistics"] = new JObject();
                    //Ret["Admin"]["Statistics"]["href"] = "Statistics.aspx";
                    Ret["Admin"]["Quotas"]               = new JObject();
                    Ret["Admin"]["Quotas"]["action"]     = "Quotas";
                    Ret["Admin"]["Login Data"]           = new JObject();
                    Ret["Admin"]["Login Data"]["action"] = "Login Data";

                    //Removed condition for Case 29185
                    Ret["Admin"]["Impersonate"]           = new JObject();
                    Ret["Admin"]["Impersonate"]["action"] = "Impersonate";

                    if (_CswNbtResources.CurrentNbtUser.Username == CswNbtObjClassUser.ChemSWAdminUsername)
                    {
                        //Ret["Admin"]["View Log"] = new JObject();
                        //Ret["Admin"]["View Log"]["href"] = "DisplayLog.aspx";

                        Ret["Admin"]["Modules"]           = new JObject();
                        Ret["Admin"]["Modules"]["action"] = "Modules";
                    }

                    //if( _CswNbtResources.CurrentNbtUser.IsAdministrator() )
                    //{
                    //    Int32 DemoCount = _getSchemaDemoDataCount();
                    //    if( DemoCount > 0 )
                    //    {
                    //        Ret["Admin"]["Delete Demo Data (" + DemoCount + ")"] = new JObject();
                    //        Ret["Admin"]["Delete Demo Data (" + DemoCount + ")"]["action"] = "DeleteDemoNodes";
                    //    }
                    //}
                } // if( _CswNbtResources.CurrentNbtUser.IsAdministrator() )

                if (CswSessionResources.CswSessionManager.isImpersonating())
                {
                    Ret["Admin"]["End Impersonation"]           = new JObject();
                    Ret["Admin"]["End Impersonation"]["action"] = "EndImpersonation";
                }

                if ((CswSessionResources.CswSessionManager.didChangeSchema()))
                {
                    if (_CswNbtResources.CurrentNbtUser.Username == CswNbtObjClassUser.ChemSWAdminUsername || _isChemSWAdminImpersonating(CswSessionResources))
                    {
                        Ret["Admin"]["Return to NbtManager"]           = new JObject();
                        Ret["Admin"]["Return to NbtManager"]["action"] = "NbtManager";
                    }
                }
            } // if( _CswNbtResources.CurrentNbtUser.IsAdministrator() || CswSessionResources.CswSessionManager.isImpersonating() )

            Ret["Preferences"] = new JObject(
                new JProperty("haschildren", true),
                new JProperty("Profile", new JObject(
                                  new JProperty("action", "Profile"),
                                  new JProperty("userid", _CswNbtResources.CurrentNbtUser.UserId.ToString())
                                  )),
                new JProperty("Subscriptions", new JObject(
                                  new JProperty("action", "Subscriptions")
                                  ))
                );

            if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.Requesting) && _CswNbtResources.Permit.can(CswEnumNbtActionName.Submit_Request))
            {
                CswNbtActRequesting RequestAction = new CswNbtActRequesting(_CswNbtResources);
                Int32 CartCount = RequestAction.getCartContentCount();
                Ret["Cart (" + CartCount + ")"]           = new JObject();
                Ret["Cart (" + CartCount + ")"]["action"] = "Submit_Request";
            }

            Ret["Help"] = new JObject();
            Ret["Help"]["haschildren"]           = true;
            Ret["Help"]["Help"]                  = new JObject();
            Ret["Help"]["Help"]["popup"]         = "help/index.htm";
            Ret["Help"]["Clear Cache"]           = new JObject();
            Ret["Help"]["Clear Cache"]["action"] = "Clear Cache";
            CswNbtMetaDataObjectClass            feedbackOC        = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.FeedbackClass);
            IEnumerable <CswNbtMetaDataNodeType> feedbackNodeTypes = feedbackOC.getNodeTypes();

            if (feedbackNodeTypes.Any())
            {
                if (_CswNbtResources.Permit.canNodeType(Security.CswEnumNbtNodeTypePermission.Create, feedbackNodeTypes.First()))
                {
                    Ret["Help"]["Give Feedback"] = new JObject();
                    //Ret["Help"]["Give Feedback"]["action"] = "AddNode";
                    Ret["Help"]["Give Feedback"]["action"] = "AddFeedback";
                    CswNbtMetaDataNodeType feedbackNodeType = feedbackNodeTypes.First();
                    Ret["Help"]["Give Feedback"]["nodetypeid"] = feedbackNodeType.NodeTypeId;
                }
            }
            Ret["Help"]["Printing Labels"]           = new JObject();
            Ret["Help"]["Printing Labels"]["popup"]  = "PrintingLabels.html";
            Ret["Help"]["Reading Balances"]          = new JObject();
            Ret["Help"]["Reading Balances"]["popup"] = "ReadingBalances.html";
            Ret["Help"]["About"]           = new JObject();
            Ret["Help"]["About"]["action"] = "About";

            Ret["Logout"] = new JObject(new JProperty("action", "Logout"));

            return(Ret);
        }