Esempio n. 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> ();
            var          directoryService = Framework.Utilities.DataManager.RequestPlugin <IDirectoryServiceConnector> ();
            var          eventListVars    = new List <Dictionary <string, object> > ();
            IMoneyModule moneyModule      = webInterface.Registry.RequestModuleInterface <IMoneyModule> ();

            var currencySymbol = "$";

            if (moneyModule != null)
            {
                currencySymbol = moneyModule.InWorldCurrencySymbol;
            }

            UserAccount user = Authenticator.GetAuthentication(httpRequest);

            var eventLevel = 7; // all events;
            var category   = (int)DirectoryManager.EventCategories.All;
            var timeframe  = 24;

            var pg_checked = "checked";
            var ma_checked = "checked";
            var ao_checked = "checked";

            if (requestParameters.ContainsKey("Submit"))
            {
                int level = 0;
                pg_checked = "";
                ma_checked = "";
                ao_checked = "";

                if (requestParameters.ContainsKey("display_pg"))
                {
                    level     += Util.ConvertEventMaturityToDBMaturity(DirectoryManager.EventFlags.PG);
                    pg_checked = "checked";
                }

                if (requestParameters.ContainsKey("display_ma"))
                {
                    level     += Util.ConvertEventMaturityToDBMaturity(DirectoryManager.EventFlags.Mature);
                    ma_checked = "checked";
                }

                if (requestParameters.ContainsKey("display_ao"))
                {
                    level     += Util.ConvertEventMaturityToDBMaturity(DirectoryManager.EventFlags.Adult);
                    ao_checked = "checked";
                }

                eventLevel = level;

                string cat = requestParameters ["category"].ToString();
                category = int.Parse(cat);

                string timsel = requestParameters ["timeframe"].ToString();
                timeframe = int.Parse(timsel);
            }

            // maturity selections
            vars.Add("PG_checked", pg_checked);
            vars.Add("MA_checked", ma_checked);
            vars.Add("AO_checked", ao_checked);

            // build category selection
            vars.Add("CategoryType", WebHelpers.EventCategorySelections(category, translator));

            // build timeframes
            vars.Add("TimeFrame", WebHelpers.EventTimeframesSelections(timeframe, translator));

            // get some events
            if (directoryService != null)
            {
                var events = new List <EventData> ();
                events = directoryService.GetUserEvents(user.PrincipalID.ToString(), timeframe, category, eventLevel);

                if (events.Count == 0)
                {
                    vars.Add("EditText", "");
                    eventListVars.Add(new Dictionary <string, object> {
                        { "EventID", "" },
                        { "CreatorUUID", "" },
                        { "EventDate", "" },
                        { "EventDateUTC", "" },
                        { "CoverCharge", "" },
                        { "Duration", "" },
                        { "Name", "" },
                        { "Description", translator.GetTranslatedString("NoDetailsText") },
                        { "SimName", "" },
                        { "GPosX", "" },
                        { "GPosY", "" },
                        { "GPosZ", "" },
                        { "LocalPosX", "" },
                        { "LocalPosY", "" },
                        { "LocalPosZ", "" },
                        { "Maturity", "" },
                        { "EventFlags", "" },   // same as maturity??
                        { "Category", "" }
                    });
                }
                else
                {
                    vars.Add("EditText", translator.GetTranslatedString("EditText"));
                    foreach (var evnt in events)
                    {
                        var evntDateTime = Util.ToDateTime(evnt.dateUTC).ToLocalTime();
                        eventListVars.Add(new Dictionary <string, object> {
                            { "EventID", evnt.eventID },
                            { "CreatorUUID", evnt.creator },
                            { "EventDate", evnt.date },
                            { "EventDateUTC", Culture.LocaleShortDateTime(evntDateTime) },
                            { "CoverCharge", currencySymbol + " " + evnt.amount },
                            { "Duration", WebHelpers.EventDuration((int)evnt.duration, translator) },
                            { "Name", evnt.name },
                            { "Description", evnt.description },
                            { "SimName", evnt.simName },
                            { "GPosX", evnt.globalPos.X.ToString() },
                            { "GPosY", evnt.globalPos.Y.ToString() },
                            { "GPosZ", evnt.globalPos.Z.ToString() },
                            { "LocalPosX", evnt.regionPos.X.ToString() },
                            { "LocalPosY", evnt.regionPos.Y.ToString() },
                            { "LocalPosZ", evnt.regionPos.Z.ToString() },
                            { "Maturity", WebHelpers.EventMaturity(evnt.maturity) },
                            { "EventFlags", evnt.eventFlags },
                            { "Category", WebHelpers.EventCategory(int.Parse(evnt.category), translator) }
                        });
                    }
                }

                vars.Add("EventList", eventListVars);
            }

            vars.Add("Events", translator.GetTranslatedString("Events"));

            // labels
            vars.Add("UserName", user.Name);
            vars.Add("EventsText", translator.GetTranslatedString("EventsText"));
            vars.Add("AddEventText", translator.GetTranslatedString("AddEventText"));
            vars.Add("EventDateText", translator.GetTranslatedString("EventDateText"));
            vars.Add("CategoryText", translator.GetTranslatedString("CategoryText"));
            vars.Add("LocationText", translator.GetTranslatedString("LocationText"));
            vars.Add("DescriptionText", translator.GetTranslatedString("DescriptionText"));
            vars.Add("MaturityText", translator.GetTranslatedString("MaturityText"));
            vars.Add("GeneralText", translator.GetTranslatedString("GeneralText"));
            vars.Add("MatureText", translator.GetTranslatedString("MatureText"));
            vars.Add("AdultText", translator.GetTranslatedString("AdultText"));
            vars.Add("CoverChargeText", translator.GetTranslatedString("CoverChargeText"));
            vars.Add("DurationText", translator.GetTranslatedString("DurationText"));
            vars.Add("SearchText", translator.GetTranslatedString("SearchText"));

            return(vars);
        }