コード例 #1
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            if (requestParameters.ContainsKey("Submit"))
            {
                string             title     = requestParameters["NewsTitle"].ToString();
                string             text      = requestParameters["NewsText"].ToString();
                IGenericsConnector connector = Framework.Utilities.DataManager.RequestPlugin <IGenericsConnector>();
                GridNewsItem       item      = new GridNewsItem {
                    Text = text, Time = DateTime.Now, Title = title
                };
                item.ID = connector.GetGenericCount(UUID.Zero, "WebGridNews") + 1;
                connector.AddGeneric(UUID.Zero, "WebGridNews", item.ID.ToString(), item.ToOSD());
                response = "<h3>News item added successfully, redirecting to main page</h3>" +
                           "<script language=\"javascript\">" +
                           "setTimeout(function() {window.location.href = \"index.html?page=news_manager\";}, 0);" +
                           "</script>";
                return(null);
            }

            vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle"));
            vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText"));
            vars.Add("AddNewsText", translator.GetTranslatedString("AddNewsText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));

            return(vars);
        }
コード例 #2
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator)
        {
            var vars = new Dictionary <string, object>();

            if (requestParameters.ContainsKey("Submit"))
            {
                string             title     = requestParameters["NewsTitle"].ToString();
                string             text      = requestParameters["NewsText"].ToString();
                IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();
                GridNewsItem       item      = new GridNewsItem {
                    Text = text, Time = DateTime.Now, Title = title
                };
                item.ID = connector.GetGenericCount(UUID.Zero, "WebGridNews") + 1;
                connector.AddGeneric(UUID.Zero, "WebGridNews", item.ID.ToString(), item.ToOSD());
                vars["ErrorMessage"] = "News item added successfully";
                webInterface.Redirect(httpResponse, "index.html?page=news_manager", filename);
                return(vars);
            }
            else
            {
                vars["ErrorMessage"] = "";
            }

            vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle"));
            vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText"));
            vars.Add("AddNewsText", translator.GetTranslatedString("AddNewsText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));

            return(vars);
        }
コード例 #3
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            IGenericsConnector connector = Framework.Utilities.DataManager.RequestPlugin <IGenericsConnector>();
            var vars = new Dictionary <string, object>();

            vars.Add("News", translator.GetTranslatedString("News"));
            vars.Add("NewsDateText", translator.GetTranslatedString("NewsDateText"));
            vars.Add("NewsTitleText", translator.GetTranslatedString("NewsTitleText"));

            vars.Add("CurrentPageText", translator.GetTranslatedString("CurrentPageText"));
            vars.Add("FirstText", translator.GetTranslatedString("FirstText"));
            vars.Add("BackText", translator.GetTranslatedString("BackText"));
            vars.Add("NextText", translator.GetTranslatedString("NextText"));
            vars.Add("LastText", translator.GetTranslatedString("LastText"));

            uint amountPerQuery = 10;
            int  maxPages       = 0;
            int  start          = httpRequest.Query.ContainsKey("Start") ? int.Parse(httpRequest.Query["Start"].ToString()) : 0;

            if (connector != null)
            {
                uint count = (uint)connector.GetGenericCount(UUID.Zero, "WebGridNews");
                maxPages = (int)(count / amountPerQuery) - 1;

                if (start == -1)
                {
                    start = (maxPages < 0 ? 0 : maxPages);
                }

                var newsItems = connector.GetGenerics <GridNewsItem> (UUID.Zero, "WebGridNews");

                if (newsItems.Count == 0)
                {
                    newsItems.Add(GridNewsItem.NoNewsItem);
                }

                vars.Add("NewsList", newsItems.ConvertAll <Dictionary <string, object> >(item => item.ToDictionary()));
            }

            vars.Add("CurrentPage", start);
            vars.Add("NextOne", start + 1 > maxPages ? start : start + 1);
            vars.Add("BackOne", start - 1 < 0 ? 0 : start - 1);

            return(vars);
        }
コード例 #4
0
        /// <summary>
        /// Promotes a user to allow API access.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void PromoteAPIUser(IScene scene, string [] cmd)
        {
            var userName = MainConsole.Instance.Prompt("Name of user <First> <Last>");
            var userAcct = m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, userName);

            if (!userAcct.Valid)
            {
                MainConsole.Instance.Error("Sorry! Unable to locate this user.");
                return;
            }

            var authKey = UUID.Random().ToString();

            var apiItem = new APIAuthItem {
                Username = userAcct.Name, KeyDate = DateTime.Now, APIKey = authKey
            };

            apiItem.KeyID = generics.GetGenericCount((UUID)Constants.GovernorUUID, "APIKey") + 1;
            generics.AddGeneric((UUID)Constants.GovernorUUID, "APIKey", authKey, apiItem.ToOSD());

            MainConsole.Instance.InfoFormat("[API]: User {0} {1} - API key : {2}", userAcct.FirstName, userAcct.LastName, authKey);
        }