예제 #1
0
        public ActionResult Login(UserDataViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (ZOOM3Entities db = new ZOOM3Entities()){
                   

                    var query = db.UserData.Where(e => e.US_Email.Equals(model.US_Email) && e.US_Password.Equals(model.US_Password)).FirstOrDefault();
                    if (query != null)
                    {
                        Session["UserId"] = query.US_Id;
                        Session["UserName"] = query.US_Name;
                        Session["UserLastname"] = query.US_LastName;
                        Session["PhotosNo"] = query.Photo.Count();
                        Session["ProfilePhoto"] = query.US_HasImage;
                        var cartUnits = db.Cart.Where(u => u.C_US_Id == query.US_Id);
                        var not = db.Notifications.Where(u => u.NOT_U_Id == query.US_Id && u.NOT_Leido == false);
                        Session["Cart"] = cartUnits.Count();
                        Session["Notifications"] = not.Count();
                        Session["Rol"] = query.US_ROL_Id;
                        ViewBag.noti = not;
                        return RedirectToAction("Index", "Home");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Email o Contraseña Incorrectos");
                        return View();
                    }
                }

                return RedirectToAction("Index", "Home");
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }
        private async void ImportFromFileButton_Click(object sender, RoutedEventArgs e)
        {
            await this.RunAsyncOperation(async() =>
            {
                this.userImportData.Clear();

                if (await MessageBoxHelper.ShowConfirmationDialog(string.Format("This will allow you to import the total amounts that each user had, assign them to this {0}, and will overwrite any amounts that each user has." +
                                                                                Environment.NewLine + Environment.NewLine + "This process may take some time; are you sure you wish to do this?", this.CurrencyRankIdentifierString)))
                {
                    try
                    {
                        string filePath = ChannelSession.Services.FileService.ShowOpenFileDialog();
                        if (!string.IsNullOrEmpty(filePath))
                        {
                            string fileContents = await ChannelSession.Services.FileService.ReadFile(filePath);
                            string[] lines      = fileContents.Split(new string[] { Environment.NewLine, "\n" }, StringSplitOptions.RemoveEmptyEntries);
                            if (lines.Count() > 0)
                            {
                                foreach (string line in lines)
                                {
                                    UserModel user  = null;
                                    uint id         = 0;
                                    string username = null;
                                    int amount      = 0;

                                    string[] segments = line.Split(new string[] { " ", "\t", "," }, StringSplitOptions.RemoveEmptyEntries);
                                    if (segments.Count() == 2)
                                    {
                                        if (!int.TryParse(segments[1], out amount))
                                        {
                                            throw new InvalidOperationException("File is not in the correct format");
                                        }

                                        if (!uint.TryParse(segments[0], out id))
                                        {
                                            username = segments[0];
                                        }
                                    }
                                    else if (segments.Count() == 3)
                                    {
                                        if (!uint.TryParse(segments[0], out id))
                                        {
                                            throw new InvalidOperationException("File is not in the correct format");
                                        }

                                        if (!int.TryParse(segments[2], out amount))
                                        {
                                            throw new InvalidOperationException("File is not in the correct format");
                                        }
                                    }
                                    else
                                    {
                                        throw new InvalidOperationException("File is not in the correct format");
                                    }

                                    if (amount > 0)
                                    {
                                        if (id > 0)
                                        {
                                            user = await ChannelSession.Connection.GetUser(id);
                                        }
                                        else if (!string.IsNullOrEmpty(username))
                                        {
                                            user = await ChannelSession.Connection.GetUser(username);
                                        }
                                    }

                                    if (user != null)
                                    {
                                        UserDataViewModel data = ChannelSession.Settings.UserData.GetValueIfExists(user.id, new UserDataViewModel(user));
                                        if (!this.userImportData.ContainsKey(data))
                                        {
                                            this.userImportData[data] = amount;
                                        }
                                        this.userImportData[data]         = Math.Max(this.userImportData[data], amount);
                                        this.ImportFromFileButton.Content = string.Format("{0} Imported...", this.userImportData.Count());
                                    }
                                }

                                foreach (var kvp in this.userImportData)
                                {
                                    kvp.Key.SetCurrencyAmount(this.currency, kvp.Value);
                                }

                                this.ImportFromFileButton.Content = "Import From File";
                                return;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Base.Util.Logger.Log(ex);
                    }

                    await MessageBoxHelper.ShowMessageDialog("We were unable to import the data. Please ensure your file is in one of the following formats:" +
                                                             Environment.NewLine + Environment.NewLine + "<USERNAME> <AMOUNT>" +
                                                             Environment.NewLine + Environment.NewLine + "<USER ID> <AMOUNT>" +
                                                             Environment.NewLine + Environment.NewLine + "<USER ID> <USERNAME> <AMOUNT>");

                    this.ImportFromFileButton.Content = "Import From File";
                }
            });
        }
예제 #3
0
        public ActionResult Index(UserDataViewModel data)
        {
            ViewBag.MessageForTest = "MessageForTest";
            try
            {
                if (ModelState.IsValid)
                {//проверка всех данных_покрытие тестами_тестирование
                    if (data.A == 0)
                    {
                        ViewBag.Message = "Коэффициент 'a' не может быть равен нулю! ";
                        return(View(UserData()));
                    }
                    else if (data.Step <= 0)
                    {
                        ViewBag.Message = "Коэффициент 'step' не может быть равен или меньше нуля! ";
                        return(View(UserData()));
                    }
                    else if (data.RangeTo == 0)
                    {
                        ViewBag.Message = "Коэффициент 'rangeTo' не должен быть равен нулю! ";
                        return(View(UserData()));
                    }
                    else if (data.RangeFrom == 0)
                    {
                        ViewBag.Message = "Коэффициент 'rangeFrom' не должен быть равен нулю! ";
                        return(View(UserData()));
                    }
                    else
                    {
                        ViewBag.Block = "block";
                        var mapper = new MapperConfiguration(cfg => cfg.CreateMap <UserDataViewModel, UserDataDTO>()).CreateMapper();
                        var _chart = mapper.Map <UserDataViewModel, UserDataDTO>(data);
                        funcService.Create(_chart);

                        int      count = (-data.RangeFrom) + (data.RangeTo);
                        string[] arrx  = new string[count];
                        string[] arry  = new string[count];
                        int      ii    = 0;
                        var      x     = -(data.B) / 2 * data.A;
                        var      y     = data.A * Math.Pow(x, 2) + data.B * x + data.C;
                        for (decimal i = data.RangeFrom; i < data.RangeTo; i += data.Step)
                        {
                            if (data.A < 0)
                            {//проверка направления ветвей
                                arrx[ii] = (x + (i * data.A)).ToString() + " ";
                                arry[ii] = ((y - Math.Pow((double)i, 2))).ToString() + " ";
                                ii++;
                            }
                            else
                            {
                                arrx[ii] = (x + (i * data.A)).ToString() + " ";
                                arry[ii] = (-(y - Math.Pow((double)i, 2))).ToString() + " ";
                                ii++;
                            }
                        }
                        if (data.A < 0)
                        {
                            Array.Reverse(arrx);
                        }

                        string dataY = JsonConvert.SerializeObject(arrx, Formatting.None);
                        ViewBag.DataY = new HtmlString(dataY);

                        string dataX = JsonConvert.SerializeObject(arry, Formatting.None);
                        ViewBag.DataX = new HtmlString(dataX);
                        return(View(data));
                    }
                }
                ViewBag.Block = "none";
            }
            catch (Exception p)
            {
                ViewBag.Message = p.Message;
                ViewBag.Block   = "none";
            }

            return(View("Index", data));
        }
예제 #4
0
        public ActionResult Register(UserDataViewModel model)
        {
            //if (ModelState.IsValid)
            //{
            //    // Attempt to register the user
            //    try
            //    {
            //        WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
            //        WebSecurity.Login(model.UserName, model.Password);
            //        return RedirectToAction("Index", "Home");
            //    }
            //    catch (MembershipCreateUserException e)
            //    {
            //        ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
            //    }
            //}

            //// If we got this far, something failed, redisplay form
            //return View(model);
            var email = 0;
            //Check if the email exits
            var query = (
               from c in db.UserData
               where c.US_Email == model.US_Email
               select c).Count();

            if (email == 0)
            {
                try
                {
                    model.RememberMe = false;
                    model.US_ROL_Id = 1;
                    if (ModelState.IsValid)
                    {
                        AutoMapper.Mapper.CreateMap<UserDataViewModel, UserData>();
                        var usuario = AutoMapper.Mapper.Map<UserDataViewModel, UserData>(model);
                        Session["UserId"] = model.US_Id;
                        Session["UserName"] = model.US_Name;
                        Session["UserLastname"] = model.US_LastName;
                        Session["PhotosNo"] = model.Photo.Count();
                        Session["ProfilePhoto"] = model.US_HasImage;
                        var cartUnits = db.Cart.Where(u => u.C_US_Id == model.US_Id);
                        var not = db.Notifications.Where(u => u.NOT_U_Id == model.US_Id && u.NOT_Leido == false);
                        Session["Cart"] = cartUnits.Count();
                        Session["Notifications"] = not.Count();
                        usuario.US_RegDate = DateTime.Now;

                        db.UserData.Add(usuario);
                        db.SaveChanges();
                        return RedirectToAction("Index", "Home");
                    }
                }
                catch (Exception e)
                {

                    Console.WriteLine("{0} Exception caught.", e);
                    RedirectToAction("ErrorPage", "Error");
                }
            }
            else
            {
                ModelState.AddModelError("", "El Usuario ya existe");
                //RedirectToAction("Error");
            }

            return View(model);
        }
        private async Task ProcessDeveloperAPIRequest(HttpListenerContext listenerContext, string httpMethod, List <string> urlSegments, string data)
        {
            if (urlSegments[0].Equals("mixer"))
            {
                if (urlSegments.Count() == 3 && urlSegments[1].Equals("users"))
                {
                    if (httpMethod.Equals(GetHttpMethod))
                    {
                        string identifier = urlSegments[2];

                        UserModel user = null;
                        if (uint.TryParse(identifier, out uint userID))
                        {
                            user = ChannelSession.Connection.GetUser(userID).Result;
                        }
                        else
                        {
                            user = ChannelSession.Connection.GetUser(identifier).Result;
                        }

                        if (user != null)
                        {
                            await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(user));

                            return;
                        }
                        else
                        {
                            await this.CloseConnection(listenerContext, HttpStatusCode.NotFound, "Could not find the user specified");

                            return;
                        }
                    }
                }
            }
            else if (urlSegments[0].Equals("users") && urlSegments.Count() >= 2)
            {
                string identifier = urlSegments[1];

                UserDataViewModel user = null;
                if (uint.TryParse(identifier, out uint userID) && ChannelSession.Settings.UserData.ContainsKey(userID))
                {
                    user = ChannelSession.Settings.UserData[userID];
                }
                else
                {
                    user = ChannelSession.Settings.UserData.Values.FirstOrDefault(u => u.UserName.ToLower().Equals(identifier));
                }

                if (httpMethod.Equals(GetHttpMethod))
                {
                    if (user != null)
                    {
                        await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(new UserDeveloperAPIModel(user)));

                        return;
                    }
                    else
                    {
                        await this.CloseConnection(listenerContext, HttpStatusCode.NotFound, "Could not find the user specified");

                        return;
                    }
                }
                else if (httpMethod.Equals(PutHttpMethod) || httpMethod.Equals(PatchHttpMethod))
                {
                    UserDeveloperAPIModel updatedUserData = SerializerHelper.DeserializeFromString <UserDeveloperAPIModel>(data);
                    if (updatedUserData != null && updatedUserData.ID.Equals(user.ID))
                    {
                        user.ViewingMinutes = updatedUserData.ViewingMinutes;
                        foreach (UserCurrencyDeveloperAPIModel currencyData in updatedUserData.CurrencyAmounts)
                        {
                            if (ChannelSession.Settings.Currencies.ContainsKey(currencyData.ID))
                            {
                                user.SetCurrencyAmount(ChannelSession.Settings.Currencies[currencyData.ID], currencyData.Amount);
                            }
                        }

                        await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(new UserDeveloperAPIModel(user)));

                        return;
                    }
                    else
                    {
                        await this.CloseConnection(listenerContext, HttpStatusCode.NotFound, "Invalid data/could not find matching user");

                        return;
                    }
                }
            }
            else if (urlSegments[0].Equals("currency") && urlSegments.Count() == 2)
            {
                if (httpMethod.Equals(GetHttpMethod))
                {
                    string identifier = urlSegments[1];
                    if (Guid.TryParse(identifier, out Guid currencyID) && ChannelSession.Settings.Currencies.ContainsKey(currencyID))
                    {
                        await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(ChannelSession.Settings.Currencies[currencyID]));

                        return;
                    }
                    else
                    {
                        await this.CloseConnection(listenerContext, HttpStatusCode.NotFound, "Could not find the currency specified");

                        return;
                    }
                }
            }
            else if (urlSegments[0].Equals("commands"))
            {
                List <CommandBase> allCommands = new List <CommandBase>();
                allCommands.AddRange(ChannelSession.Settings.ChatCommands);
                allCommands.AddRange(ChannelSession.Settings.InteractiveCommands);
                allCommands.AddRange(ChannelSession.Settings.EventCommands);
                allCommands.AddRange(ChannelSession.Settings.TimerCommands);
                allCommands.AddRange(ChannelSession.Settings.ActionGroupCommands);
                allCommands.AddRange(ChannelSession.Settings.GameCommands);

                if (httpMethod.Equals(GetHttpMethod))
                {
                    if (urlSegments.Count() == 1)
                    {
                        await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(allCommands));

                        return;
                    }
                    else if (urlSegments.Count() == 2 && Guid.TryParse(urlSegments[1], out Guid ID))
                    {
                        CommandBase command = allCommands.FirstOrDefault(c => c.ID.Equals(ID));
                        if (command != null)
                        {
                            await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(command));

                            return;
                        }
                        else
                        {
                            await this.CloseConnection(listenerContext, HttpStatusCode.NotFound, "Could not find the command specified");

                            return;
                        }
                    }
                }
                else if (httpMethod.Equals(PostHttpMethod))
                {
                    if (urlSegments.Count() == 2 && Guid.TryParse(urlSegments[1], out Guid ID))
                    {
                        CommandBase command = allCommands.FirstOrDefault(c => c.ID.Equals(ID));
                        if (command != null)
                        {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                            command.Perform();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                            await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(command));

                            return;
                        }
                        else
                        {
                            await this.CloseConnection(listenerContext, HttpStatusCode.NotFound, "Could not find the command specified");

                            return;
                        }
                    }
                }
                else if (httpMethod.Equals(PutHttpMethod) || httpMethod.Equals(PatchHttpMethod))
                {
                    if (urlSegments.Count() == 2 && Guid.TryParse(urlSegments[1], out Guid ID))
                    {
                        CommandBase commandData    = SerializerHelper.DeserializeAbstractFromString <CommandBase>(data);
                        CommandBase matchedCommand = allCommands.FirstOrDefault(c => c.ID.Equals(ID));
                        if (matchedCommand != null)
                        {
                            matchedCommand.IsEnabled = commandData.IsEnabled;

                            await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(matchedCommand));

                            return;
                        }
                        else
                        {
                            await this.CloseConnection(listenerContext, HttpStatusCode.NotFound, "Invalid data/could not find matching command");

                            return;
                        }
                    }
                }
            }
            else if (urlSegments[0].Equals("spotify") && urlSegments.Count() >= 2)
            {
                if (ChannelSession.Services.Spotify != null)
                {
                    if (httpMethod.Equals(GetHttpMethod))
                    {
                        if (urlSegments.Count() == 2)
                        {
                            if (urlSegments[1].Equals("current"))
                            {
                                await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(await ChannelSession.Services.Spotify.GetCurrentlyPlaying()));

                                return;
                            }
                            else if (urlSegments[1].StartsWith("search?query="))
                            {
                                string search = urlSegments[1].Replace("search?query=", "");
                                search = HttpUtility.UrlDecode(search);

                                await this.CloseConnection(listenerContext, HttpStatusCode.OK, SerializerHelper.SerializeToString(await ChannelSession.Services.Spotify.SearchSongs(search)));

                                return;
                            }
                        }
                    }
                    else if (httpMethod.Equals(PostHttpMethod))
                    {
                        if (urlSegments.Count() == 2)
                        {
                            if (urlSegments[1].Equals("play"))
                            {
                                if (string.IsNullOrEmpty(data))
                                {
                                    await ChannelSession.Services.Spotify.PlayCurrentlyPlaying();

                                    await this.CloseConnection(listenerContext, HttpStatusCode.OK, string.Empty);

                                    return;
                                }
                                else
                                {
                                    if (await ChannelSession.Services.Spotify.PlaySong(data))
                                    {
                                        await this.CloseConnection(listenerContext, HttpStatusCode.OK, string.Empty);
                                    }
                                    else
                                    {
                                        await this.CloseConnection(listenerContext, HttpStatusCode.BadRequest, "We were unable to play the uri you specified. If your uri is correct, please try again in a moment");
                                    }
                                    return;
                                }
                            }
                            else if (urlSegments[1].Equals("pause"))
                            {
                                await ChannelSession.Services.Spotify.PauseCurrentlyPlaying();

                                await this.CloseConnection(listenerContext, HttpStatusCode.OK, string.Empty);

                                return;
                            }
                            else if (urlSegments[1].Equals("next"))
                            {
                                await ChannelSession.Services.Spotify.NextCurrentlyPlaying();

                                await this.CloseConnection(listenerContext, HttpStatusCode.OK, string.Empty);

                                return;
                            }
                            else if (urlSegments[1].Equals("previous"))
                            {
                                await ChannelSession.Services.Spotify.PreviousCurrentlyPlaying();

                                await this.CloseConnection(listenerContext, HttpStatusCode.OK, string.Empty);

                                return;
                            }
                        }
                    }
                }
                else
                {
                    await this.CloseConnection(listenerContext, HttpStatusCode.ServiceUnavailable, "The Spotify service is not currently connected in Mix It Up");
                }
            }

            await this.CloseConnection(listenerContext, HttpStatusCode.BadRequest, "This is not a valid API");
        }
예제 #6
0
        private async Task HandleUserSpecialIdentifiers(UserViewModel user, string identifierHeader)
        {
            if (user != null && this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader))
            {
                await user.RefreshDetails();

                if (ChannelSession.Settings.UserData.ContainsKey(user.ID))
                {
                    UserDataViewModel userData = ChannelSession.Settings.UserData[user.ID];

                    foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values.OrderByDescending(c => c.UserAmountSpecialIdentifier))
                    {
                        UserCurrencyDataViewModel currencyData = userData.GetCurrency(currency);
                        UserRankViewModel         rank         = currencyData.GetRank();
                        UserRankViewModel         nextRank     = currencyData.GetNextRank();

                        this.ReplaceSpecialIdentifier(identifierHeader + currency.UserRankNextNameSpecialIdentifier, nextRank.Name);
                        this.ReplaceSpecialIdentifier(identifierHeader + currency.UserAmountNextSpecialIdentifier, nextRank.MinimumPoints.ToString());

                        this.ReplaceSpecialIdentifier(identifierHeader + currency.UserRankNameSpecialIdentifier, rank.Name);
                        this.ReplaceSpecialIdentifier(identifierHeader + currency.UserAmountSpecialIdentifier, currencyData.Amount.ToString());
                    }

                    foreach (UserInventoryViewModel inventory in ChannelSession.Settings.Inventories.Values.OrderByDescending(c => c.UserAmountSpecialIdentifierHeader))
                    {
                        if (this.ContainsSpecialIdentifier(identifierHeader + inventory.UserAmountSpecialIdentifierHeader))
                        {
                            UserInventoryDataViewModel inventoryData = userData.GetInventory(inventory);
                            List <string> allItemsList = new List <string>();

                            foreach (UserInventoryItemViewModel item in inventory.Items.Values.OrderByDescending(i => i.Name))
                            {
                                int amount = inventoryData.GetAmount(item);
                                if (amount > 0)
                                {
                                    allItemsList.Add(item.Name + " x" + amount);
                                }

                                string itemSpecialIdentifier = identifierHeader + inventory.UserAmountSpecialIdentifierHeader + item.SpecialIdentifier;
                                this.ReplaceSpecialIdentifier(itemSpecialIdentifier, amount.ToString());
                            }

                            if (allItemsList.Count > 0)
                            {
                                this.ReplaceSpecialIdentifier(identifierHeader + inventory.UserAllAmountSpecialIdentifier, string.Join(", ", allItemsList.OrderBy(i => i)));
                            }
                            else
                            {
                                this.ReplaceSpecialIdentifier(identifierHeader + inventory.UserAllAmountSpecialIdentifier, "Nothing");
                            }
                        }
                    }

                    this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "time", userData.ViewingTimeString);
                    this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "hours", userData.ViewingHoursString);
                    this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "mins", userData.ViewingMinutesString);

                    this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "moderationstrikes", userData.ModerationStrikes.ToString());
                }

                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "primaryrole", user.PrimaryRoleString);
                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "avatar", user.AvatarLink);
                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "url", "https://www.mixer.com/" + user.UserName);
                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "name", user.UserName);
                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "id", user.ID.ToString());
                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "sparks", user.Sparks.ToString());

                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "mixerage", user.MixerAgeString);
                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "followage", user.FollowAgeString);
                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "subage", user.MixerSubscribeAgeString);
                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "submonths", user.SubscribeMonths.ToString());

                this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "title", user.Title);

                if (this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "followers") || this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "game") ||
                    this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "channel"))
                {
                    ExpandedChannelModel channel = await ChannelSession.Connection.GetChannel(user.UserName);

                    this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "followers", channel?.numFollowers.ToString() ?? "0");

                    if (channel.type != null)
                    {
                        this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "gameimage", channel.type.coverUrl);
                        this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "game", channel.type.name.ToString());
                    }

                    this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "channelid", channel.id.ToString());
                    this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "channellive", channel.online.ToString());
                    this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "channelfeatured", channel.featured.ToString());
                }

                if (this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogression"))
                {
                    UserFanProgressionModel fanProgression = await ChannelSession.Connection.GetUserFanProgression(ChannelSession.Channel, user.GetModel());

                    if (fanProgression != null && fanProgression.level != null)
                    {
                        this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogressionnext", fanProgression.level.nextLevelXp.ToString());
                        this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogressionrank", fanProgression.level.level.ToString());
                        this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogressioncolor", fanProgression.level.color.ToString());
                        this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogressionimage", fanProgression.level.LargeGIFAssetURL.ToString());
                        this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogression", fanProgression.level.currentXp.ToString());
                    }
                }
            }
        }
예제 #7
0
 public bool TrySubtractAmount(UserDataViewModel userData)
 {
     return(this.TrySubtractAmount(userData, this.Amount));
 }
예제 #8
0
        private User AdjustInventory(UserDataViewModel user, Guid inventoryID, [FromBody] AdjustInventory inventoryUpdate)
        {
            if (!ChannelSession.Settings.Inventories.ContainsKey(inventoryID))
            {
                var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content = new ObjectContent <Error>(new Error {
                        Message = $"Unable to find inventory: {inventoryID.ToString()}."
                    }, new JsonMediaTypeFormatter(), "application/json"),
                    ReasonPhrase = "Inventory ID not found"
                };
                throw new HttpResponseException(resp);
            }

            if (inventoryUpdate == null)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new ObjectContent <Error>(new Error {
                        Message = "Unable to parse inventory adjustment from POST body."
                    }, new JsonMediaTypeFormatter(), "application/json"),
                    ReasonPhrase = "Invalid POST Body"
                };
                throw new HttpResponseException(resp);
            }

            UserInventoryViewModel inventory = ChannelSession.Settings.Inventories[inventoryID];

            if (string.IsNullOrEmpty(inventoryUpdate.Name) || !inventory.Items.ContainsKey(inventoryUpdate.Name))
            {
                var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new ObjectContent <Error>(new Error {
                        Message = "Unable to find requested inventory item."
                    }, new JsonMediaTypeFormatter(), "application/json"),
                    ReasonPhrase = "Invalid Inventory Item"
                };
                throw new HttpResponseException(resp);
            }

            if (inventoryUpdate.Amount < 0)
            {
                int quantityToRemove = inventoryUpdate.Amount * -1;
                if (!user.HasInventoryAmount(inventory, inventoryUpdate.Name, quantityToRemove))
                {
                    // If the request is to remove inventory, but user doesn't have enough, fail
                    var resp = new HttpResponseMessage(HttpStatusCode.Forbidden)
                    {
                        Content = new ObjectContent <Error>(new Error {
                            Message = "User does not have enough inventory to remove"
                        }, new JsonMediaTypeFormatter(), "application/json"),
                        ReasonPhrase = "Not Enough Inventory"
                    };
                    throw new HttpResponseException(resp);
                }

                user.SubtractInventoryAmount(inventory, inventoryUpdate.Name, quantityToRemove);
            }
            else if (inventoryUpdate.Amount > 0)
            {
                user.AddInventoryAmount(inventory, inventoryUpdate.Name, inventoryUpdate.Amount);
            }

            return(UserFromUserDataViewModel(user));
        }
예제 #9
0
        public ActionResult Login(UserDataViewModel objUser)
        {
            //UserDataViewModel model = new UserDataViewModel();
            try
            {
                if (ModelState.IsValid)
                {
                    using (ShoppingCartAppEntities db = new ShoppingCartAppEntities())
                    {
                        if (objUser.Email != null && objUser.Password != null)
                        {
                            string rank = db.Users.Where(a => a.Email == objUser.Email).FirstOrDefault().Role;
                            var    obj  = db.Users.Where(a => a.Email.Equals(objUser.Email) && a.Password.Equals(objUser.Password)).FirstOrDefault();
                            if (obj != null && rank == "Admin")
                            {
                                FormsAuthentication.SetAuthCookie(objUser.Email, objUser.Remember);
                                FormsAuthentication.SetAuthCookie(objUser.Password, objUser.Remember);
                                Session["UserId"]    = obj.UserId.ToString();
                                Session["Email"]     = obj.Email.ToString();
                                Session["Role"]      = obj.Role.ToString();
                                Session["FirstName"] = obj.FirstName.ToString();
                                Session["LastName"]  = obj.LastName.ToString();
                                if (objUser.Remember)
                                {
                                    HttpCookie cookie = new HttpCookie("Login");
                                    cookie.Values.Add("Email", obj.Email);
                                    cookie.Values.Add("Password", obj.Password);
                                    cookie.Expires = DateTime.Now.AddDays(15);
                                    Response.Cookies.Add(cookie);
                                }
                                else
                                {
                                    Response.Cookies["Email"].Expires    = DateTime.Now.AddDays(-1);
                                    Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
                                }
                                //Response.Cookies["UserName"].Value = obj.Email.Trim();
                                //Response.Cookies["Password"].Value = obj.Password.Trim();
                                return(RedirectToAction("Display"));
                            }
                            else if (obj != null && rank == "User")
                            {
                                FormsAuthentication.SetAuthCookie(objUser.Email, objUser.Remember);
                                FormsAuthentication.SetAuthCookie(objUser.Password, objUser.Remember);
                                Session["UserId"] = obj.UserId.ToString();
                                Session["Email"]  = obj.Email.ToString();
                                //return RedirectToAction("UserDataDisplay");

                                if (objUser.Remember)
                                {
                                    HttpCookie cookie = new HttpCookie("Login");
                                    cookie.Values.Add("Email", obj.Email);
                                    cookie.Values.Add("Password", obj.Password);
                                    cookie.Expires = DateTime.Now.AddDays(15);
                                    Response.Cookies.Add(cookie);
                                }
                                else
                                {
                                    Response.Cookies["Email"].Expires    = DateTime.Now.AddDays(-1);
                                    Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
                                }
                                Response.Cookies["Email"].Value    = obj.Email.Trim();
                                Response.Cookies["Password"].Value = obj.Password.Trim();
                                return(RedirectToAction("Display"));
                            }
                            else
                            {
                                ViewBag.Message = "Your Password is Wrong";
                                return(View("Login"));
                            }
                        }

                        else
                        {
                            ViewBag.Message = "Please Fill the UserName and Password.";
                            return(View("Login"));
                        }
                    }
                }
                return(View(objUser));
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Please Fill the UserName and Password Correct.";
                return(View("Login"));
            }
        }
 public GetUserAvatarRequestListener(UserDataViewModel userData)
 {
     _userData = userData;
 }
예제 #11
0
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            if (ChannelSession.Chat != null)
            {
                string amountTextValue = await this.ReplaceStringWithSpecialModifiers(this.Amount, user, arguments);

                if (!int.TryParse(amountTextValue, out int amountValue))
                {
                    await ChannelSession.Chat.Whisper(user.UserName, string.Format("{0} is not a valid amount of {1}", amountTextValue, ChannelSession.Settings.Currencies[this.CurrencyID].Name));

                    return;
                }

                if (amountValue <= 0)
                {
                    await ChannelSession.Chat.Whisper(user.UserName, "The amount specified must be greater than 0");

                    return;
                }

                UserCurrencyDataViewModel        senderCurrencyData    = user.Data.GetCurrency(this.CurrencyID);
                List <UserCurrencyDataViewModel> receiverCurrencyDatas = new List <UserCurrencyDataViewModel>();
                if (this.CurrencyActionType == CurrencyActionTypeEnum.AddToUser)
                {
                    receiverCurrencyDatas.Add(senderCurrencyData);
                }
                else if (this.CurrencyActionType == CurrencyActionTypeEnum.GiveToSpecificUser)
                {
                    if (!string.IsNullOrEmpty(this.Username))
                    {
                        string usernameString = await this.ReplaceStringWithSpecialModifiers(this.Username, user, arguments);

                        UserModel receivingUser = await ChannelSession.Connection.GetUser(usernameString);

                        if (receivingUser != null)
                        {
                            UserDataViewModel userData = ChannelSession.Settings.UserData.GetValueIfExists(receivingUser.id, new UserDataViewModel(new UserViewModel(receivingUser)));
                            receiverCurrencyDatas.Add(userData.GetCurrency(this.CurrencyID));
                        }
                        else
                        {
                            await ChannelSession.Chat.Whisper(user.UserName, "The user could not be found");

                            return;
                        }
                    }
                }
                else if (this.CurrencyActionType == CurrencyActionTypeEnum.GiveToAllChatUsers)
                {
                    foreach (UserViewModel chatUser in await ChannelSession.ActiveUsers.GetAllWorkableUsers())
                    {
                        receiverCurrencyDatas.Add(chatUser.Data.GetCurrency(this.CurrencyID));
                    }
                    receiverCurrencyDatas.Remove(senderCurrencyData);
                }

                if ((this.DeductFromUser && receiverCurrencyDatas.Count > 0) || this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromUser)
                {
                    if (senderCurrencyData.Amount < amountValue)
                    {
                        await ChannelSession.Chat.Whisper(user.UserName, string.Format("You do not have the required {0} {1} to do this", amountValue, ChannelSession.Settings.Currencies[this.CurrencyID].Name));

                        return;
                    }
                    senderCurrencyData.Amount -= amountValue;
                }

                if (receiverCurrencyDatas.Count > 0)
                {
                    foreach (UserCurrencyDataViewModel receiverCurrencyData in receiverCurrencyDatas)
                    {
                        receiverCurrencyData.Amount += amountValue;
                    }
                }
            }
        }
        private async Task AddUserData(IEnumerable <string> dataValues)
        {
            int currentColumn = 1;
            UserDataViewModel importedUserData = new UserDataViewModel();

            foreach (string dataValue in dataValues)
            {
                bool columnMatched = false;
                foreach (ImportDataColumns dataColumn in this.dataColumns)
                {
                    if (dataColumn.GetColumnNumber() == currentColumn)
                    {
                        switch (dataColumn.DataName)
                        {
                        case "User ID":
                            if (uint.TryParse(dataValue, out uint id))
                            {
                                importedUserData.ID = id;
                            }
                            columnMatched = true;
                            break;

                        case "User Name":
                            importedUserData.UserName = dataValue;
                            columnMatched             = true;
                            break;

                        case "Live Viewing Time (Hours)":
                            if (int.TryParse(dataValue, out int liveHours))
                            {
                                importedUserData.ViewingMinutes = liveHours * 60;
                            }
                            columnMatched = true;
                            break;

                        case "Live Viewing Time (Mins)":
                            if (int.TryParse(dataValue, out int liveMins))
                            {
                                importedUserData.ViewingMinutes = liveMins;
                            }
                            columnMatched = true;
                            break;

                        case "Offline Viewing Time (Hours)":
                            if (int.TryParse(dataValue, out int offlineHours))
                            {
                                importedUserData.OfflineViewingMinutes = offlineHours * 60;
                            }
                            columnMatched = true;
                            break;

                        case "Offline Viewing Time (Mins)":
                            if (int.TryParse(dataValue, out int offlineMins))
                            {
                                importedUserData.OfflineViewingMinutes = offlineMins;
                            }
                            columnMatched = true;
                            break;

                        default:
                            foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values)
                            {
                                if (currency.Name.Equals(dataColumn.DataName))
                                {
                                    if (int.TryParse(dataValue, out int currencyAmount))
                                    {
                                        importedUserData.SetCurrencyAmount(currency, currencyAmount);
                                    }
                                    columnMatched = true;
                                    break;
                                }
                            }
                            break;
                        }
                    }

                    if (columnMatched)
                    {
                        break;
                    }
                }
                currentColumn++;
            }

            if (importedUserData.ID == 0)
            {
                UserModel user = await ChannelSession.Connection.GetUser(importedUserData.UserName);

                if (user != null)
                {
                    importedUserData.ID = user.id;
                }
            }
            else if (string.IsNullOrEmpty(importedUserData.UserName))
            {
                UserModel user = await ChannelSession.Connection.GetUser(importedUserData.ID);

                if (user != null)
                {
                    importedUserData.UserName = user.username;
                }
            }

            if (importedUserData.ID > 0 && !string.IsNullOrEmpty(importedUserData.UserName))
            {
                ChannelSession.Settings.UserData[importedUserData.ID] = importedUserData;
                usersImported++;
                this.Dispatcher.Invoke(() => { this.ImportDataButton.Content = string.Format("Imported {0} Users", usersImported); });
            }
        }
예제 #13
0
        private async void ConstellationClient_OnSubscribedEventOccurred(object sender, ConstellationLiveEventModel e)
        {
            ChannelModel  channel = null;
            UserViewModel user    = null;

            JToken userToken;

            if (e.payload.TryGetValue("user", out userToken))
            {
                user = new UserViewModel(userToken.ToObject <UserModel>());

                JToken subscribeStartToken;
                if (e.payload.TryGetValue("since", out subscribeStartToken))
                {
                    user.SubscribeDate = subscribeStartToken.ToObject <DateTimeOffset>();
                }
            }
            else if (e.payload.TryGetValue("hoster", out userToken))
            {
                channel = userToken.ToObject <ChannelModel>();
                user    = new UserViewModel(channel.id, channel.token);
            }

            if (user != null)
            {
                UserDataViewModel userData = ChannelSession.Settings.UserData.GetValueIfExists(user.ID, new UserDataViewModel(user));

                if (e.channel.Equals(ConstellationClientWrapper.ChannelFollowEvent.ToString()))
                {
                    foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values)
                    {
                        userData.SetCurrencyAmount(currency, currency.OnFollowBonus);
                    }
                }
                else if (e.channel.Equals(ConstellationClientWrapper.ChannelHostedEvent.ToString()))
                {
                    foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values)
                    {
                        userData.SetCurrencyAmount(currency, currency.OnHostBonus);
                    }
                }
                else if (e.channel.Equals(ConstellationClientWrapper.ChannelSubscribedEvent.ToString()) || e.channel.Equals(ConstellationClientWrapper.ChannelResubscribedEvent.ToString()) ||
                         e.channel.Equals(ConstellationClientWrapper.ChannelResubscribedSharedEvent.ToString()))
                {
                    foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values)
                    {
                        userData.SetCurrencyAmount(currency, currency.OnSubscribeBonus);
                    }
                }

                if (e.channel.Equals(ConstellationClientWrapper.ChannelSubscribedEvent.ToString()))
                {
                    user.SubscribeDate = DateTimeOffset.Now;
                }
            }

            if (e.channel.Equals(ConstellationClientWrapper.ChannelUpdateEvent.ToString()))
            {
                IDictionary <string, JToken> payloadValues = e.payload;
                if (payloadValues.ContainsKey("online") && (bool)payloadValues["online"])
                {
                    UptimeChatCommand.SetUptime(DateTimeOffset.Now);
                }
            }
            else
            {
                foreach (EventCommand command in ChannelSession.Settings.EventCommands)
                {
                    EventCommand foundCommand = null;

                    if (command.MatchesEvent(e))
                    {
                        foundCommand = command;
                    }

                    if (command.EventType == ConstellationEventTypeEnum.channel__id__subscribed && e.channel.Equals(ConstellationClientWrapper.ChannelResubscribeSharedEvent.ToString()))
                    {
                        foundCommand = command;
                    }

                    if (foundCommand != null)
                    {
                        if (command.EventType == ConstellationEventTypeEnum.channel__id__hosted && channel != null)
                        {
                            foundCommand.AddSpecialIdentifier("hostviewercount", channel.viewersCurrent.ToString());
                        }

                        if (user != null)
                        {
                            await foundCommand.Perform(user);
                        }
                        else
                        {
                            await foundCommand.Perform();
                        }

                        return;
                    }
                }
            }

            if (this.OnEventOccurred != null)
            {
                this.OnEventOccurred(this, e);
            }
        }
예제 #14
0
        public ActionResult Register()
        {
            UserDataViewModel Log = new UserDataViewModel();

            return(View(Log));
        }
예제 #15
0
 public bool TrySubtractMultiplierAmount(UserDataViewModel userData, int multiplier)
 {
     return(this.TrySubtractAmount(userData, multiplier * this.Amount));
 }
예제 #16
0
        public UserDataViewModel fromJSON(string plotRequest)
        {
            UserDataViewModel _request = JsonConvert.DeserializeObject <UserDataViewModel>(plotRequest);

            return(_request);
        }
예제 #17
0
 public SettingsPage(User user)
 {
     InitializeComponent();
     BindingContext = new UserDataViewModel(new PageService(), user);
 }
예제 #18
0
        public ActionResult SaveUserData(UserDataViewModel model)
        {
            UserData ud = model.ToUserData();
            //db.Entry(ud).State = System.Data.EntityState.Modified;

            if (db.UserData.Find(WebSecurity.CurrentUserId) != null)
            {
                var additionalInfo = from userAddInfo in db.UserData.Find(model.UserId).UserProperties select userAddInfo;
                if (model.UserProperties == null)
                {
                    for (; additionalInfo.Count() > 0; )
                        db.Entry(additionalInfo.First()).State = System.Data.EntityState.Deleted;

                }
                else
                {
                    if (additionalInfo.Count() != 0)
                    {
                        List<int> toDelete = new List<int>();
                        foreach (var item in additionalInfo)
                        {
                            if (model.UserProperties.Find(obj => obj.Id == item.Id) == null) toDelete.Add(item.Id);
                        }
                        for (int i = 0; i < toDelete.Count; i++)
                        {
                            db.Entry(additionalInfo.First(item => item.Id == toDelete[i])).State = System.Data.EntityState.Deleted;
                        }
                    }
                    foreach (var item in ud.UserProperties)
                    {
                        if (item.UserId == 0)
                        {
                            item.UserId = WebSecurity.CurrentUserId;
                            db.Entry(item).State = System.Data.EntityState.Added;
                        }
                    }
                }
                if (model.Picture != null)
                {
                    try
                    {
                        if (db.UserData.Find(WebSecurity.CurrentUserId).Images != null)
                            db.Entry(db.UserData.Find(WebSecurity.CurrentUserId).Images).State = System.Data.EntityState.Deleted;
                    }
                    finally
                    {
                        db.Images.Add(ud.Images);
                        //db.Entry(ud).State = System.Data.EntityState.Modified;
                    }
                }
                db.SaveChanges();
                if (ud.Images != null)
                {
                    db.UserData.Find(WebSecurity.CurrentUserId).PictureId = ud.Images.Id;
                    db.Entry(db.UserData.Find(WebSecurity.CurrentUserId)).State = System.Data.EntityState.Modified;
                    db.SaveChanges();
                }
            }
            else
            {
                db.UserData.Add(ud);
                db.SaveChanges();
            }

            return RedirectToAction("Manage");
        }
예제 #19
0
        private async void ImportUserCurrencyFromFileButton_Click(object sender, RoutedEventArgs e)
        {
            await this.RunAsyncOperation(async() =>
            {
                this.userImportData.Clear();

                string message = "This will allow you to import the total amounts that each user had and assign them to this ";
                message       += (this.isRank) ? "rank" : "currency";
                message       += " and will overwrite any amounts that each user has.";
                message       += Environment.NewLine + Environment.NewLine + "This process may take some time; are you sure you wish to do this?";

                if (await MessageBoxHelper.ShowConfirmationDialog(message))
                {
                    try
                    {
                        string filePath = ChannelSession.Services.FileService.ShowOpenFileDialog();
                        if (!string.IsNullOrEmpty(filePath))
                        {
                            string fileContents = await ChannelSession.Services.FileService.OpenFile(filePath);
                            string[] lines      = fileContents.Split(new string[] { Environment.NewLine, "\n" }, StringSplitOptions.RemoveEmptyEntries);
                            if (lines.Count() > 0)
                            {
                                Dictionary <uint, UserDataViewModel> userData = ChannelSession.Settings.UserData.ToDictionary();
                                foreach (string line in lines)
                                {
                                    string[] segments = line.Split(new string[] { " ", "\t" }, StringSplitOptions.RemoveEmptyEntries);
                                    if (segments.Count() == 2)
                                    {
                                        int amount = 0;
                                        if (!int.TryParse(segments[1], out amount))
                                        {
                                            throw new InvalidOperationException("File is not in the correct format");
                                        }

                                        UserModel user = null;
                                        if (uint.TryParse(segments[0], out uint id))
                                        {
                                            if (userData.ContainsKey(id))
                                            {
                                                this.userImportData[id] = amount;
                                            }
                                            else
                                            {
                                                user = await ChannelSession.Connection.GetUser(id);
                                                if (user != null)
                                                {
                                                    UserViewModel userViewModel = new UserViewModel(user);
                                                    UserDataViewModel data      = new UserDataViewModel(userViewModel);
                                                    ChannelSession.Settings.UserData[data.ID] = data;
                                                    this.userImportData[data.ID] = amount;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            UserDataViewModel data = userData.Values.FirstOrDefault(u => u.UserName.Equals(segments[0]));
                                            if (data != null)
                                            {
                                                this.userImportData[data.ID] = amount;
                                            }
                                            else
                                            {
                                                user = await ChannelSession.Connection.GetUser(segments[0]);
                                                if (user != null)
                                                {
                                                    UserViewModel userViewModel = new UserViewModel(user);
                                                    data = new UserDataViewModel(userViewModel);
                                                    ChannelSession.Settings.UserData[data.ID] = data;
                                                    this.userImportData[data.ID] = amount;
                                                }
                                            }
                                        }
                                    }
                                    else if (segments.Count() == 3)
                                    {
                                        uint id = 0;
                                        if (!uint.TryParse(segments[0], out id))
                                        {
                                            throw new InvalidOperationException("File is not in the correct format");
                                        }

                                        int amount = 0;
                                        if (!int.TryParse(segments[2], out amount))
                                        {
                                            throw new InvalidOperationException("File is not in the correct format");
                                        }

                                        if (userData.ContainsKey(id))
                                        {
                                            this.userImportData[id] = amount;
                                        }
                                        else
                                        {
                                            UserDataViewModel data = new UserDataViewModel(id, segments[1]);
                                            ChannelSession.Settings.UserData[data.ID] = data;
                                            this.userImportData[data.ID] = amount;
                                        }
                                    }

                                    this.ImportUserCurrencyFromFileButton.Content = string.Format("{0} Imported...", this.userImportData.Count());
                                }
                                this.ImportUserCurrencyFromFileButton.Content = "Import From File";
                                return;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(ex);
                    }

                    await MessageBoxHelper.ShowMessageDialog("We were unable to import the data. Please ensure your file is in one of the following formats:" +
                                                             Environment.NewLine + Environment.NewLine + "<USERNAME> <AMOUNT>" +
                                                             Environment.NewLine + Environment.NewLine + "<USER ID> <AMOUNT>" +
                                                             Environment.NewLine + Environment.NewLine + "<USER ID> <USERNAME> <AMOUNT>");

                    this.ImportUserCurrencyFromFileButton.Content = "Import From File";
                }
            });
        }