Beispiel #1
0
        public UsersMainControlViewModel(MainWindowViewModel windowViewModel)
            : base(windowViewModel)
        {
            this.ExportDataCommand = this.CreateCommand(async() =>
            {
                string filePath = ChannelSession.Services.FileService.ShowSaveFileDialog("User Data.txt");
                if (!string.IsNullOrEmpty(filePath))
                {
                    List <List <string> > contents = new List <List <string> >();

                    List <string> columns = new List <string>()
                    {
                        "MixItUpID", "TwitchID", "Username", "PrimaryRole", "ViewingMinutes", "OfflineViewingMinutes", "CustomTitle"
                    };
                    foreach (var kvp in ChannelSession.Settings.Currency)
                    {
                        columns.Add(kvp.Value.Name.Replace(" ", ""));
                    }
                    foreach (var kvp in ChannelSession.Settings.StreamPass)
                    {
                        columns.Add(kvp.Value.Name.Replace(" ", ""));
                    }
                    columns.AddRange(new List <string>()
                    {
                        "TotalStreamsWatched", "TotalAmountDonated", "TotalSubsGifted", "TotalSubsReceived", "TotalChatMessagesSent", "TotalTimesTagged",
                        "TotalCommandsRun", "TotalMonthsSubbed", "LastSeen"
                    });
                    contents.Add(columns);

                    await ChannelSession.Settings.LoadAllUserData();
                    foreach (UserDataModel user in ChannelSession.Settings.UserData.Values.ToList())
                    {
                        List <string> data = new List <string>()
                        {
                            user.ID.ToString(), user.TwitchID, user.Username, user.PrimaryRole.ToString(),
                            user.ViewingMinutes.ToString(), user.OfflineViewingMinutes.ToString(), user.CustomTitle
                        };
                        foreach (var kvp in ChannelSession.Settings.Currency)
                        {
                            data.Add(kvp.Value.GetAmount(user).ToString());
                        }
                        foreach (var kvp in ChannelSession.Settings.StreamPass)
                        {
                            data.Add(kvp.Value.GetAmount(user).ToString());
                        }
                        data.AddRange(new List <string>()
                        {
                            user.TotalStreamsWatched.ToString(), user.TotalAmountDonated.ToString(), user.TotalSubsGifted.ToString(), user.TotalSubsReceived.ToString(),
                            user.TotalChatMessageSent.ToString(), user.TotalTimesTagged.ToString(), user.TotalCommandsRun.ToString(), user.TotalMonthsSubbed.ToString(), user.LastSeen.ToFriendlyDateTimeString()
                        });
                        contents.Add(data);
                    }

                    await SpreadsheetFileHelper.ExportToCSV(filePath, contents);
                }
            });
        }
Beispiel #2
0
        public QuotesMainControlViewModel(MainWindowViewModel windowViewModel)
            : base(windowViewModel)
        {
            this.AddQuoteCommand = this.CreateCommand((parameter) =>
            {
                if (!string.IsNullOrEmpty(this.AddQuoteText))
                {
                    ChannelSession.Settings.Quotes.Add(new UserQuoteModel(UserQuoteViewModel.GetNextQuoteNumber(), this.AddQuoteText, DateTimeOffset.Now, ChannelSession.TwitchChannelV5?.game));
                    this.Refresh();

                    this.AddQuoteText = string.Empty;
                }
                return(Task.FromResult(0));
            });

            this.ExportQuotesCommand = this.CreateCommand(async(parameter) =>
            {
                string filePath = ChannelSession.Services.FileService.ShowSaveFileDialog("Quotes.txt");
                if (!string.IsNullOrEmpty(filePath))
                {
                    List <List <string> > contents = new List <List <string> >();

                    contents.Add(new List <string>()
                    {
                        "#", MixItUp.Base.Resources.Quote, MixItUp.Base.Resources.Game, MixItUp.Base.Resources.DateTime
                    });

                    foreach (UserQuoteViewModel quote in this.Quotes.ToList())
                    {
                        List <string> data = new List <string>();
                        data.Add(quote.ID.ToString());
                        data.Add(quote.Quote);
                        data.Add(quote.GameName);
                        data.Add(quote.DateTime.ToFriendlyDateTimeString());
                        contents.Add(data);
                    }

                    await SpreadsheetFileHelper.ExportToCSV(filePath, contents);
                }
            });
        }