Exemplo 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;
            IConfig gridInfo        = webInterface.Registry.RequestModuleInterface <ISimulationBase> ().ConfigSource.Configs ["GridInfoService"];
            var     inWorldCurrency = gridInfo.GetString("CurrencySymbol", string.Empty) + " ";
            var     realCurrency    = gridInfo.GetString("RealCurrencySymbol", string.Empty) + " ";

            var vars          = new Dictionary <string, object> ();
            var purchasesList = new List <Dictionary <string, object> > ();

            var    today      = DateTime.Now;
            var    thirtyDays = today.AddDays(-7);
            string dateStart  = thirtyDays.ToShortDateString();
            string dateEnd    = today.ToShortDateString();

            IMoneyModule moneyModule = webInterface.Registry.RequestModuleInterface <IMoneyModule> ();
            string       noDetails   = translator.GetTranslatedString("NoPurchasesText");

            // Check if we're looking at the standard page or the submitted one
            if (requestParameters.ContainsKey("Submit"))
            {
                if (requestParameters.ContainsKey("date_start"))
                {
                    dateStart = requestParameters ["date_start"].ToString();
                }

                if (requestParameters.ContainsKey("date_end"))
                {
                    dateEnd = requestParameters ["date_end"].ToString();
                }
            }

            UserAccount user = Authenticator.GetAuthentication(httpRequest);

            if (user == null)
            {
                response = "<h3>Error validating user details</h3>" +
                           "<script language=\"javascript\">" +
                           "setTimeout(function() {window.location.href = \"/?page=user_purchases\";}, 1000);" +
                           "</script>";

                return(null);
            }

            // Purchases Logs
            var      timeNow  = DateTime.Now.ToString("HH:mm:ss");
            var      dateFrom = DateTime.Parse(dateStart + " " + timeNow);
            var      dateTo   = DateTime.Parse(dateEnd + " " + timeNow);
            TimeSpan period   = dateTo.Subtract(dateFrom);

            var purchases = new List <AgentPurchase> ();

            if (moneyModule != null)
            {
                purchases = moneyModule.GetPurchaseHistory(user.PrincipalID, dateFrom, dateTo, null, null);
            }

            // data
            if (purchases.Count > 0)
            {
                noDetails = "";

                foreach (var purchase in purchases)
                {
                    purchasesList.Add(new Dictionary <string, object> {
                        { "ID", purchase.ID },
                        { "AgentID", purchase.AgentID },
                        { "AgentName", user.Name },
                        { "LoggedIP", purchase.IP },
                        { "Description", "Purchase" },
                        { "Amount", purchase.Amount },
                        { "RealAmount", ((float)purchase.RealAmount / 100).ToString("0.00") },
                        { "PurchaseDate", Culture.LocaleDate(purchase.PurchaseDate.ToLocalTime(), "MMM dd, hh:mm:ss tt") },
                        { "UpdateDate", Culture.LocaleDate(purchase.UpdateDate.ToLocalTime(), "MMM dd, hh:mm:ss tt") }
                    });
                }
            }

            if (purchasesList.Count == 0)
            {
                purchasesList.Add(new Dictionary <string, object> {
                    { "ID", "" },
                    { "AgentID", "" },
                    { "AgentName", "" },
                    { "LoggedIP", "" },
                    { "Description", translator.GetTranslatedString("NoPurchasesText") },
                    { "Amount", "" },
                    { "RealAmount", "" },
                    { "PurchaseDate", "" },
                    { "UpdateDate", "" }
                });
            }

            // always required data
            vars.Add("DateStart", dateStart);
            vars.Add("DateEnd", dateEnd);
            vars.Add("Period", period.TotalDays + " " + translator.GetTranslatedString("DaysText"));
            vars.Add("PurchasesList", purchasesList);
            vars.Add("NoPurchasesText", noDetails);

            // labels
            vars.Add("UserName", user.Name);
            vars.Add("PurchasesText", translator.GetTranslatedString("PurchasesText"));
            vars.Add("DateInfoText", translator.GetTranslatedString("DateInfoText"));
            vars.Add("DateStartText", translator.GetTranslatedString("DateStartText"));
            vars.Add("DateEndText", translator.GetTranslatedString("DateEndText"));
            vars.Add("SearchUserText", translator.GetTranslatedString("AvatarNameText"));

            vars.Add("PurchaseAgentText", translator.GetTranslatedString("TransactionToAgentText"));
            vars.Add("PurchaseDateText", translator.GetTranslatedString("TransactionDateText"));
            vars.Add("PurchaseUpdateDateText", translator.GetTranslatedString("TransactionDateText"));
            vars.Add("PurchaseDetailText", translator.GetTranslatedString("TransactionDetailText"));
            vars.Add("LoggedIPText", translator.GetTranslatedString("LoggedIPText"));
            vars.Add("PurchaseAmountText", inWorldCurrency + translator.GetTranslatedString("TransactionAmountText"));
            vars.Add("PurchaseRealAmountText", realCurrency + translator.GetTranslatedString("PurchaseCostText"));

            return(vars);
        }
Exemplo n.º 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;
            IConfig gridInfo        = webInterface.Registry.RequestModuleInterface <ISimulationBase> ().ConfigSource.Configs ["GridInfoService"];
            var     InWorldCurrency = gridInfo.GetString("CurrencySymbol", string.Empty) + " ";
            var     RealCurrency    = gridInfo.GetString("RealCurrencySymbol", string.Empty) + " ";

            var vars          = new Dictionary <string, object> ();
            var purchasesList = new List <Dictionary <string, object> > ();

            var    today      = DateTime.Now;
            var    thirtyDays = today.AddDays(-30);
            string DateStart  = thirtyDays.ToShortDateString();
            string DateEnd    = today.ToShortDateString();
            string UserName   = "";
            UUID   UserID     = UUID.Zero;

            IMoneyModule moneyModule = webInterface.Registry.RequestModuleInterface <IMoneyModule> ();
            string       noDetails   = translator.GetTranslatedString("NoPurchasesText");

            if (moneyModule != null)
            {
                // Check if we're looking at the standard page or the submitted one
                if (requestParameters.ContainsKey("Submit"))
                {
                    if (requestParameters.ContainsKey("date_start"))
                    {
                        DateStart = requestParameters ["date_start"].ToString();
                    }

                    if (requestParameters.ContainsKey("date_end"))
                    {
                        DateEnd = requestParameters ["date_end"].ToString();
                    }

                    if (requestParameters.ContainsKey("user_name"))
                    {
                        UserName = requestParameters ["user_name"].ToString();
                    }

                    IUserAccountService accountService = webInterface.Registry.RequestModuleInterface <IUserAccountService> ();

                    if (UserName != "")
                    {
                        UserID = (UUID)Constants.LibraryOwnerUUID;         // This user should hopefully never have transactions

                        if (UserName.Split(' ').Length == 2)
                        {
                            var userAccount = accountService.GetUserAccount(null, UserName);

                            if (userAccount != null)
                            {
                                UserID = userAccount.PrincipalID;
                            }
                        }
                    }

                    // Purchases Logs
                    var timeNow   = DateTime.Now.ToString("HH:mm:ss");
                    var dateFrom  = DateTime.Parse(DateStart + " " + timeNow);
                    var dateTo    = DateTime.Parse(DateEnd + " " + timeNow);
                    var purchases = new List <AgentPurchase> ();

                    if (UserID != UUID.Zero)
                    {
                        purchases = moneyModule.GetPurchaseHistory(UserID, dateFrom, dateTo, null, null);
                    }
                    else
                    {
                        purchases = moneyModule.GetPurchaseHistory(dateFrom, dateTo, null, null);
                    }

                    // data
                    if (purchases != null && purchases.Count > 0)
                    {
                        noDetails = "";

                        foreach (var purchase in purchases)
                        {
                            var    account   = accountService.GetUserAccount(null, purchase.AgentID);
                            string AgentName = "";

                            if (account != null)
                            {
                                AgentName = account.Name;
                            }

                            purchasesList.Add(new Dictionary <string, object> {
                                { "ID", purchase.ID },
                                { "AgentID", purchase.AgentID },
                                { "AgentName", AgentName },
                                { "LoggedIP", purchase.IP },
                                { "Description", "Purchase" },
                                { "Amount", purchase.Amount },
                                { "RealAmount", ((float)purchase.RealAmount / 100).ToString("0.00") },
                                { "PurchaseDate", Culture.LocaleDate(purchase.PurchaseDate.ToLocalTime(), "MMM dd, hh:mm:ss tt") },
                                { "UpdateDate", Culture.LocaleDate(purchase.UpdateDate.ToLocalTime(), "MMM dd, hh:mm:ss tt") }
                            });
                        }
                    }
                }

                if (purchasesList.Count == 0)
                {
                    purchasesList.Add(new Dictionary <string, object> {
                        { "ID", "" },
                        { "AgentID", "" },
                        { "AgentName", "" },
                        { "LoggedIP", "" },
                        { "Description", translator.GetTranslatedString("NoPurchasesText") },
                        { "Amount", "" },
                        { "RealAmount", "" },
                        { "PurchaseDate", "" },
                        { "UpdateDate", "" }
                    });
                }
            }

            // always required data
            vars.Add("DateStart", DateStart);
            vars.Add("DateEnd", DateEnd);
            vars.Add("SearchUser", UserName);
            vars.Add("PurchasesList", purchasesList);
            vars.Add("NoPurchasesText", noDetails);

            // labels
            vars.Add("PurchasesText", translator.GetTranslatedString("PurchasesText"));
            vars.Add("DateInfoText", translator.GetTranslatedString("DateInfoText"));
            vars.Add("DateStartText", translator.GetTranslatedString("DateStartText"));
            vars.Add("DateEndText", translator.GetTranslatedString("DateEndText"));
            vars.Add("SearchUserText", translator.GetTranslatedString("AvatarNameText"));

            vars.Add("PurchaseAgentText", translator.GetTranslatedString("TransactionToAgentText"));
            vars.Add("PurchaseDateText", translator.GetTranslatedString("TransactionDateText"));
            vars.Add("PurchaseUpdateDateText", translator.GetTranslatedString("TransactionDateText"));
            vars.Add("PurchaseDetailText", translator.GetTranslatedString("TransactionDetailText"));
            vars.Add("LoggedIPText", translator.GetTranslatedString("LoggedIPText"));
            vars.Add("PurchaseAmountText", InWorldCurrency + translator.GetTranslatedString("TransactionAmountText"));
            vars.Add("PurchaseRealAmountText", RealCurrency + translator.GetTranslatedString("PurchaseCostText"));

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

            return(vars);
        }
Exemplo n.º 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;
            IConfig gridInfo        = webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs ["GridInfoService"];
            var     InWorldCurrency = gridInfo.GetString("CurrencySymbol", String.Empty) + " ";
            var     RealCurrency    = gridInfo.GetString("RealCurrencySymbol", String.Empty) + " ";

            var vars          = new Dictionary <string, object>();
            var purchasesList = new List <Dictionary <string, object> >();

            uint   amountPerQuery = 25;
            var    today          = DateTime.Now;
            var    thirtyDays     = today.AddDays(-7);
            string DateStart      = thirtyDays.ToShortDateString();
            string DateEnd        = today.ToShortDateString();
            UUID   UserID         = UUID.Zero;
            int    start          = 0;


            IMoneyModule moneyModule = webInterface.Registry.RequestModuleInterface <IMoneyModule>();
            string       noDetails   = translator.GetTranslatedString("NoPurchasesText");

            // Check if we're looking at the standard page or the submitted one
            if (requestParameters.ContainsKey("Submit"))
            {
                if (requestParameters.ContainsKey("date_start"))
                {
                    DateStart = requestParameters ["date_start"].ToString();
                }
                if (requestParameters.ContainsKey("date_end"))
                {
                    DateEnd = requestParameters ["date_end"].ToString();
                }

                // pagination
                start = httpRequest.Query.ContainsKey("Start")
                    ? int.Parse(httpRequest.Query ["Start"].ToString())
                    : 0;
                int count    = (int)moneyModule.NumberOfPurchases(UserID);
                int maxPages = (int)(count / amountPerQuery) - 1;

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

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

            UserAccount user = Authenticator.GetAuthentication(httpRequest);

            // Purchases Logs
            var      timeNow  = DateTime.Now.ToString("HH:mm:ss");
            var      dateFrom = DateTime.Parse(DateStart + " " + timeNow);
            var      dateTo   = DateTime.Parse(DateEnd + " " + timeNow);
            TimeSpan period   = dateTo.Subtract(dateFrom);

            List <AgentPurchase> purchases;

            purchases = moneyModule.GetPurchaseHistory(user.PrincipalID, dateFrom, dateTo, (uint)start, amountPerQuery);

            // data
            if (purchases.Count > 0)
            {
                noDetails = "";

                foreach (var purchase in purchases)
                {
                    purchasesList.Add(new Dictionary <string, object> {
                        { "ID", purchase.ID },
                        { "AgentID", purchase.AgentID },
                        { "AgentName", user.Name },
                        { "LoggedIP", purchase.IP },
                        { "Description", "Purchase" },
                        { "Amount", purchase.Amount },
                        { "RealAmount", ((float)purchase.RealAmount / 100).ToString("0.00") },
                        { "PurchaseDate", Culture.LocaleDate(purchase.PurchaseDate.ToLocalTime(), "MMM dd, hh:mm:ss tt") },
                        { "UpdateDate", Culture.LocaleDate(purchase.UpdateDate.ToLocalTime(), "MMM dd, hh:mm:ss tt") }
                    });
                }
            }

            if (purchasesList.Count == 0)
            {
                purchasesList.Add(new Dictionary <string, object> {
                    { "ID", "" },
                    { "AgentID", "" },
                    { "AgentName", "" },
                    { "LoggedIP", "" },
                    { "Description", translator.GetTranslatedString("NoPurchasesText") },
                    { "Amount", "" },
                    { "RealAmount", "" },
                    { "PurchaseDate", "" },
                    { "UpdateDate", "" },
                });
            }

            // always required data
            vars.Add("DateStart", DateStart);
            vars.Add("DateEnd", DateEnd);
            vars.Add("Period", period.TotalDays + " " + translator.GetTranslatedString("DaysText"));
            vars.Add("PurchasesList", purchasesList);
            vars.Add("NoPurchasesText", noDetails);

            // labels
            vars.Add("PurchasesText", translator.GetTranslatedString("PurchasesText"));
            vars.Add("DateInfoText", translator.GetTranslatedString("DateInfoText"));
            vars.Add("DateStartText", translator.GetTranslatedString("DateStartText"));
            vars.Add("DateEndText", translator.GetTranslatedString("DateEndText"));
            vars.Add("SearchUserText", translator.GetTranslatedString("AvatarNameText"));

            vars.Add("PurchaseAgentText", translator.GetTranslatedString("TransactionToAgentText"));
            vars.Add("PurchaseDateText", translator.GetTranslatedString("TransactionDateText"));
            vars.Add("PurchaseUpdateDateText", translator.GetTranslatedString("TransactionDateText"));
            vars.Add("PurchaseDetailText", translator.GetTranslatedString("TransactionDetailText"));
            vars.Add("LoggedIPText", translator.GetTranslatedString("LoggedIPText"));
            vars.Add("PurchaseAmountText", InWorldCurrency + translator.GetTranslatedString("TransactionAmountText"));
            vars.Add("PurchaseRealAmountText", RealCurrency + translator.GetTranslatedString("PurchaseCostText"));

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

            return(vars);
        }