public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            UserAccount  ourAccount     = Authenticator.GetAuthentication(httpRequest);
            IMoneyModule moneyModule    = webInterface.Registry.RequestModuleInterface <IMoneyModule> ();
            var          currencySymbol = "$";

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

            var directoryService = Framework.Utilities.DataManager.RequestPlugin <IDirectoryServiceConnector> ();

            response = null;
            var    eventData = new EventData();
            var    vars      = new Dictionary <string, object> ();
            string eventId;
            uint   eid = 0;

            if (httpRequest.Query.ContainsKey("eventid"))
            {
                eventId = httpRequest.Query ["eventid"].ToString();
            }
            else
            {
                if (requestParameters.ContainsKey("eventid"))
                {
                    eventId = requestParameters ["eventid"].ToString();
                }
                else
                {
                    response = "<h3>Event details not supplied, redirecting to main page</h3>" +
                               "<script>" +
                               "setTimeout(function() {window.location.href = \"index.html\";}, 1000);" +
                               "</script>";
                    return(null);
                }
            }

            uint.TryParse(eventId, out eid);

            if (requestParameters.ContainsKey("Delete"))
            {
                if (directoryService.DeleteEvent(eid.ToString()))
                {
                    response = "<h3>Event details have been deleted</h3>" +
                               "<script>" +
                               "setTimeout(function() {window.location.href = \"/?page=user_events\";}, 1000);" +
                               "</script>";
                }
                else
                {
                    response = "<h3>Error encountered when deleting event. Please try again later</h3>";
                }

                return(null);
            }

            if (requestParameters.ContainsKey("Submit"))
            {
                string eventName        = requestParameters ["eventName"].ToString();
                string eventDate        = requestParameters ["eventDate"].ToString();
                string eventTime        = requestParameters ["eventTime"].ToString();
                string eventDuration    = requestParameters ["eventDuration"].ToString();
                string eventLocation    = requestParameters ["eventLocation"].ToString();
                string eventCategory    = requestParameters ["eventCategory"].ToString();
                string eventCoverCharge = requestParameters ["eventCoverCharge"].ToString();
                string eventDescription = requestParameters ["eventDescription"].ToString();

                var regionData = Framework.Utilities.DataManager.RequestPlugin <IRegionData> ();

                var selParcel = eventLocation.Split(',');
                // Format: parcelLocationX, parcelLocationY, parcelLandingX, parcelLandingY, parcelLandingZ, parcelUUID
                // "1020,995,128,28,25,d436261b-7186-42a6-dcd3-b80c1bcafaa4"

                Framework.Services.GridRegion region = null;
                var parcel = directoryService.GetParcelInfo((UUID)selParcel [5]);

                if (parcel != null)
                {
                    region = regionData.Get(parcel.RegionID, null);
                }

                if (region == null)
                {
                    var error = "Parcel details not found!";
                    vars.Add("ErrorMessage", "<h3>" + error + "</h3>");
                    response = "<h3>" + error + "</h3>";
                    return(null);
                }

                // we have details...
                var eventDT  = DateTime.Parse(eventDate + " " + eventTime);
                var localPos = new Vector3(int.Parse(selParcel [0]), int.Parse(selParcel [0]), 0);

                eventData.eventID     = eid;    // used to delete the existing event details
                eventData.creator     = ourAccount.PrincipalID.ToString();
                eventData.regionId    = region.RegionID.ToString();
                eventData.parcelId    = selParcel [5];
                eventData.date        = eventDT.ToString("s");
                eventData.cover       = uint.Parse(eventCoverCharge);
                eventData.maturity    = (int)Util.ConvertAccessLevelToMaturity(region.Access);
                eventData.eventFlags  = region.Access;            // region maturity flags
                eventData.duration    = uint.Parse(eventDuration);
                eventData.regionPos   = localPos;
                eventData.name        = eventName;
                eventData.description = eventDescription;
                eventData.category    = eventCategory;

                var success = directoryService.UpdateAddEvent(eventData);

                if (success)
                {
                    response = "<h3>Event updated successfully</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"/?page=user_events\";}, 1000);" +
                               "</script>";
                }

                return(null);
            }

            eventData = directoryService.GetEventInfo(eid);

            if (eventData == null)
            {
                response = "<h3>Event details are not available</h3>" +
                           "<script language=\"javascript\">" +
                           "setTimeout(function() {window.location.href = \"/?page=user_events\";}, 1000);" +
                           "</script>";

                return(null);
            }

            // details
            vars.Add("EventID", eventData.eventID);
            vars.Add("Name", eventData.name);
            vars.Add("Description", eventData.description.Trim());
            vars.Add("SimName", eventData.simName);

            // Time selections
            var evntDateTime = Util.ToDateTime(eventData.dateUTC).ToLocalTime();

            vars.Add("EventDate", evntDateTime.ToShortDateString());
            vars.Add("EventTimes", WebHelpers.EventTimeSelections(evntDateTime.ToString("HH\\:mm\\:ss")));

            // event durations
            vars.Add("EventDurations", WebHelpers.EventDurationSelections((int)eventData.duration));

            // event locations
            vars.Add("EventLocations", WebHelpers.EventLocations(ourAccount, webInterface.Registry, eventData.parcelId));

            vars.Add("EventCategories", WebHelpers.EventCategorySelections(int.Parse(eventData.category), translator));
            vars.Add("EventCoverCharge", eventData.cover.ToString());

            // labels
            vars.Add("AddEventText", translator.GetTranslatedString("AddEventText"));
            vars.Add("EventNameText", translator.GetTranslatedString("EventNameText"));
            vars.Add("EventDateText", translator.GetTranslatedString("EventDateText"));
            vars.Add("EventTimeText", translator.GetTranslatedString("TimeText"));
            vars.Add("EventTimeInfoText", translator.GetTranslatedString("EventTimeInfoText"));
            vars.Add("EventDurationText", translator.GetTranslatedString("DurationText"));
            vars.Add("EventLocationText", translator.GetTranslatedString("EventLocationText"));
            vars.Add("EventCategoryText", translator.GetTranslatedString("CategoryText"));
            vars.Add("EventCoverChargeText", translator.GetTranslatedString("CoverChargeText") + " " + currencySymbol);
            vars.Add("EventDescriptionText", translator.GetTranslatedString("DescriptionText"));

            vars.Add("ErrorMessage", "");
            vars.Add("Delete", translator.GetTranslatedString("DeleteText"));
            vars.Add("Submit", translator.GetTranslatedString("SaveUpdates"));

            return(vars);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            UserAccount  ourAccount     = Authenticator.GetAuthentication(httpRequest);
            IMoneyModule moneyModule    = webInterface.Registry.RequestModuleInterface <IMoneyModule> ();
            var          currencySymbol = "$";

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

            response = null;
            var vars     = new Dictionary <string, object> ();
            var duration = 10;

            if (requestParameters.ContainsKey("Submit"))
            {
                string eventName        = requestParameters ["eventName"].ToString();
                string eventDate        = requestParameters ["eventDate"].ToString();
                string eventTime        = requestParameters ["eventTime"].ToString();
                string eventDuration    = requestParameters ["eventDuration"].ToString();
                string eventLocation    = requestParameters ["eventLocation"].ToString();
                string eventCategory    = requestParameters ["eventCategory"].ToString();
                string eventCoverCharge = requestParameters ["eventCoverCharge"].ToString();
                string eventDescription = requestParameters ["eventDescription"].ToString();

                var directoryService = Framework.Utilities.DataManager.RequestPlugin <IDirectoryServiceConnector> ();
                var regionData       = Framework.Utilities.DataManager.RequestPlugin <IRegionData> ();

                var selParcel = eventLocation.Split(',');
                // Format: parcelLocationX, parcelLocationY, parcelLandingX, parcelLandingY, parcelLandingZ, parcelUUID
                // "1020,995,128,28,25,d436261b-7186-42a6-dcd3-b80c1bcafaa4"

                Framework.Services.GridRegion region = null;
                var parcel = directoryService.GetParcelInfo((UUID)selParcel [5]);

                if (parcel != null)
                {
                    region = regionData.Get(parcel.RegionID, null);
                }

                if (region == null)
                {
                    var error = "Parcel details not found!";
                    vars.Add("ErrorMessage", "<h3>" + error + "</h3>");
                    response = "<h3>" + error + "</h3>";
                    return(null);
                }

                // we have details...
                var eventDT  = DateTime.Parse(eventDate + " " + eventTime);
                var localPos = new Vector3(int.Parse(selParcel [0]), int.Parse(selParcel [0]), 0);

                var nEvent = directoryService.CreateEvent(
                    ourAccount.PrincipalID,
                    region.RegionID,
                    (UUID)selParcel [5],
                    eventDT,
                    uint.Parse(eventCoverCharge),
                    (DirectoryManager.EventFlags)Util.ConvertAccessLevelToMaturity(region.Access),
                    region.Access,
                    uint.Parse(eventDuration),
                    localPos,
                    eventName,
                    eventDescription,
                    eventCategory
                    );

                if (nEvent != null)
                {
                    response = "<h3>Event added successfully, redirecting to main page</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"/?page=events\";}, 0);" +
                               "</script>";
                }

                return(null);
            }

            // Time selections
            var nearestHalf = Utilities.RoundUp(DateTime.Now, TimeSpan.FromMinutes(30)).ToString("HH\\:mm\\:ss");

            vars.Add("EventDate", DateTime.Now.AddDays(1).ToShortDateString());
            vars.Add("EventTimes", WebHelpers.EventTimeSelections(nearestHalf));

            // event durations
            vars.Add("EventDurations", WebHelpers.EventDurationSelections(duration));

            // event locations
            vars.Add("EventLocations", WebHelpers.EventLocations(ourAccount, webInterface.Registry, ""));

            vars.Add("EventCategories", WebHelpers.EventCategorySelections(-1, translator));
            vars.Add("EventCoverCharge", "0");

            // labels
            vars.Add("AddEventText", translator.GetTranslatedString("AddEventText"));
            vars.Add("EventNameText", translator.GetTranslatedString("EventNameText"));
            vars.Add("EventDateText", translator.GetTranslatedString("EventDateText"));
            vars.Add("EventTimeText", translator.GetTranslatedString("TimeText"));
            vars.Add("EventTimeInfoText", translator.GetTranslatedString("EventTimeInfoText"));
            vars.Add("EventDurationText", translator.GetTranslatedString("DurationText"));
            vars.Add("EventLocationText", translator.GetTranslatedString("EventLocationText"));
            vars.Add("EventCategoryText", translator.GetTranslatedString("CategoryText"));
            vars.Add("EventCoverChargeText", translator.GetTranslatedString("CoverChargeText") + " " + currencySymbol);
            vars.Add("EventDescriptionText", translator.GetTranslatedString("DescriptionText"));

            vars.Add("ErrorMessage", "");
            vars.Add("Submit", translator.GetTranslatedString("AddEventText"));

            return(vars);
        }