Пример #1
0
 public static void GetCurrency(DropDownList drpCurrency)
 {
     drpCurrency.DataSource     = CurrencyAction.GetCurrency();
     drpCurrency.DataValueField = "CurrencyId";
     drpCurrency.DataTextField  = "Description";
     drpCurrency.DataBind();
 }
Пример #2
0
 //Performs an action once on BenchItem, or many times on copies of it to build mass results
 private void DoCurrencyRolls(CurrencyAction action, int count)
 {
     if (count == 1)
     {
         action(BenchItem);
     }
     else
     {
         MassResults.Clear();
         if (count >= Properties.Settings.Default.ProgressBarThreshold)
         {
             ProgressDialog p = new ProgressDialog()
             {
                 Title = "Rolling...", Steps = count, ReportStep = Math.Max(count / 100, 1)
             };
             p.Increment = () =>
             {
                 ItemCraft copy = BenchItem.Copy();
                 action(copy);
                 MassResults.Add(copy);
             };
             p.ShowDialog();
         }
         else
         {
             for (int n = 0; n < count; n++)
             {
                 ItemCraft copy = BenchItem.Copy();
                 action(copy);
                 MassResults.Add(copy);
             }
         }
     }
 }
Пример #3
0
    /// <summary>
    /// Function to Calculate Rate based on currency exchange values
    /// </summary>
    /// <param name="CountryId">Currency ID</param>
    /// <param name="rate">Rates</param>
    /// <returns>Amount in local currency rate</returns>
    public static decimal CalculateRateBasedOnCurrencyExchange(string CurrencyId, decimal rate)
    {
        decimal amount        = 0;
        decimal CurrencyValue = 0;

        Currency objCurrency = new Currency();

        objCurrency   = CurrencyAction.GetCurrencyById(CurrencyId);
        CurrencyValue = objCurrency.CurrencyValue;

        amount = rate * CurrencyValue;

        return(amount);
    }
Пример #4
0
        internal static void SeperateChatFromCurrencyActions(List <ActionBase> actions)
        {
            for (int i = 0; i < actions.Count; i++)
            {
                ActionBase action = actions[i];
                if (action is CurrencyAction)
                {
                    CurrencyAction cAction = (CurrencyAction)action;
#pragma warning disable CS0612 // Type or member is obsolete
                    ChatAction chatAction = new ChatAction(cAction.ChatText, sendAsStreamer: false, isWhisper: cAction.IsWhisper, whisperUserName: (cAction.IsWhisper) ? cAction.Username : null);
#pragma warning restore CS0612 // Type or member is obsolete
                    actions.Insert(i + 1, chatAction);
                }
            }
        }
        private void AddActions()
        {
            if (!_context.AssetActions.Any())
            {
                _logger.LogInformation("Add asset actions");
                var buy = new AssetAction()
                {
                    Name = SeedFinanceData.BUY_ACTION
                };

                var sell = new AssetAction()
                {
                    Name = SeedFinanceData.SELL_ACTION
                };

                _context.AssetActions.AddRange(buy, sell);
                _context.SaveChanges();
                _logger.LogInformation("Added asset actions successfully");
            }

            if (!_context.CurrencyActions.Any())
            {
                _logger.LogInformation("Add currency actions");
                var refill = new CurrencyAction()
                {
                    Name = SeedFinanceData.REFILL_ACTION
                };

                var withdrawal = new CurrencyAction()
                {
                    Name = SeedFinanceData.WITHDRAWAL_ACTION
                };

                _context.CurrencyActions.AddRange(refill, withdrawal);
                _context.SaveChanges();
                _logger.LogInformation("Added currency actions successfully");
            }
        }
 public CurrencyActionControl(CurrencyAction action) : this()
 {
     this.action = action;
 }
Пример #7
0
 public CurrencyActionControl(ActionContainerControl containerControl, CurrencyAction action) : this(containerControl) { this.action = action; }
Пример #8
0
        private static async Task Version2Upgrade(int version, string filePath)
        {
            if (version < 2)
            {
                string data = File.ReadAllText(filePath);
                data = data.Replace("interactiveControlsInternal", "interactiveCommandsInternal");
                data = data.Replace("CapsBlockCount", "ModerationCapsBlockCount");
                data = data.Replace("PunctuationBlockCount", "ModerationPunctuationBlockCount");
                data = data.Replace("EmoteBlockCount", "ModerationEmoteBlockCount");
                data = data.Replace("BlockLinks", "ModerationBlockLinks");
                data = data.Replace("Timeout1MinuteOffenseCount", "ModerationTimeout1MinuteOffenseCount");
                data = data.Replace("Timeout5MinuteOffenseCount", "ModerationTimeout5MinuteOffenseCount");
                File.WriteAllText(filePath, data);

                DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath);

                await ChannelSession.Services.Settings.Initialize(settings);

                List <CommandBase> commands = new List <CommandBase>();
                commands.AddRange(settings.ChatCommands);
                commands.AddRange(settings.InteractiveCommands);
                commands.AddRange(settings.EventCommands);
                commands.AddRange(settings.TimerCommands);

                foreach (CommandBase command in commands)
                {
                    foreach (ActionBase action in command.Actions)
                    {
                        if (action is ChatAction)
                        {
                            ChatAction nAction = (ChatAction)action;
                            nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.ChatText);
                        }
                        else if (action is CurrencyAction)
                        {
                            CurrencyAction nAction = (CurrencyAction)action;
                            nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.ChatText);
                        }
                        else if (action is OBSStudioAction)
                        {
                            OBSStudioAction nAction = (OBSStudioAction)action;
                            nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.SourceText);
                        }
                        else if (action is OverlayAction)
                        {
                            OverlayAction nAction = (OverlayAction)action;
                            nAction.ImagePath = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.ImagePath);
                            nAction.Text      = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.Text);
                        }
                        else if (action is TextToSpeechAction)
                        {
                            TextToSpeechAction nAction = (TextToSpeechAction)action;
                            nAction.SpeechText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.SpeechText);
                        }
                        else if (action is XSplitAction)
                        {
                            XSplitAction nAction = (XSplitAction)action;
                            nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.SourceText);
                        }
                    }
                }

                await ChannelSession.Services.Settings.Save(settings);
            }
        }
Пример #9
0
        private static async Task Version5Upgrade(int version, string filePath)
        {
            if (version < 5)
            {
                LegacyDesktopChannelSettings legacySettings = await SerializerHelper.DeserializeFromFile <LegacyDesktopChannelSettings>(filePath);

                DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath);

                await ChannelSession.Services.Settings.Initialize(settings);

                foreach (string quote in legacySettings.quotesInternal)
                {
                    settings.UserQuotes.Add(new UserQuoteViewModel(quote));
                }

                List <CommandBase> commands = new List <CommandBase>();
                commands.AddRange(settings.ChatCommands);
                commands.AddRange(settings.InteractiveCommands);
                commands.AddRange(settings.EventCommands);
                commands.AddRange(settings.TimerCommands);

                UserCurrencyViewModel currency = settings.Currencies.Values.FirstOrDefault(c => !c.IsRank);
                if (currency == null)
                {
                    currency = settings.Currencies.Values.FirstOrDefault();
                }

                foreach (CommandBase command in commands)
                {
                    foreach (ActionBase action in command.Actions)
                    {
                        if (action is InteractiveAction)
                        {
                            InteractiveAction nAction = (InteractiveAction)action;
#pragma warning disable CS0612 // Type or member is obsolete
                            if (nAction.AddUserToGroup)
                            {
                                nAction.InteractiveType = InteractiveActionTypeEnum.MoveUserToGroup;
                            }
                            else
                            {
                                nAction.InteractiveType = InteractiveActionTypeEnum.MoveGroupToScene;
                            }
                            nAction.SceneID = nAction.MoveGroupToScene;
#pragma warning restore CS0612 // Type or member is obsolete
                        }

                        if (currency != null)
                        {
                            if (action is ChatAction)
                            {
                                ChatAction nAction = (ChatAction)action;
                                nAction.ChatText = nAction.ChatText.Replace("$usercurrencyname", currency.Name);
                            }
                            else if (action is CurrencyAction)
                            {
                                CurrencyAction nAction = (CurrencyAction)action;
                                nAction.ChatText = nAction.ChatText.Replace("$usercurrencyname", currency.Name);
                            }
                            else if (action is OBSStudioAction)
                            {
                                OBSStudioAction nAction = (OBSStudioAction)action;
                                if (!string.IsNullOrEmpty(nAction.SourceText))
                                {
                                    nAction.SourceText = nAction.SourceText.Replace("$usercurrencyname", currency.Name);
                                }
                            }
                            else if (action is OverlayAction)
                            {
                                OverlayAction nAction = (OverlayAction)action;
                                if (!string.IsNullOrEmpty(nAction.Text))
                                {
                                    nAction.Text = nAction.Text.Replace("$usercurrencyname", currency.Name);
                                }
                            }
                            else if (action is TextToSpeechAction)
                            {
                                TextToSpeechAction nAction = (TextToSpeechAction)action;
                                nAction.SpeechText = nAction.SpeechText.Replace("$usercurrencyname", currency.Name);
                            }
                            else if (action is XSplitAction)
                            {
                                XSplitAction nAction = (XSplitAction)action;
                                if (!string.IsNullOrEmpty(nAction.SourceText))
                                {
                                    nAction.SourceText = nAction.SourceText.Replace("$usercurrencyname", currency.Name);
                                }
                            }
                        }
                    }
                }

                foreach (GameCommandBase game in settings.GameCommands)
                {
                    if (game is IndividualProbabilityGameCommand)
                    {
                        IndividualProbabilityGameCommand individualGame = (IndividualProbabilityGameCommand)game;
                        DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(individualGame.UserJoinedCommand);
                        DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(individualGame.LoseLeftoverCommand);
                        foreach (GameOutcome outcome in individualGame.Outcomes)
                        {
                            DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(outcome.ResultCommand);
                        }
                    }
                    else if (game is OnlyOneWinnerGameCommand)
                    {
                        OnlyOneWinnerGameCommand oneWinnerGame = (OnlyOneWinnerGameCommand)game;
                        DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(oneWinnerGame.UserJoinedCommand);
                    }
                }

                await ChannelSession.Services.Settings.Save(settings);
            }
        }
Пример #10
0
        private static async Task Version4Upgrade(int version, string filePath)
        {
            if (version < 4)
            {
                string data = File.ReadAllText(filePath);
                data = data.Replace("MixItUp.Base.Actions.RankAction", "MixItUp.Base.Actions.CurrencyAction");
                data = data.Replace("\"Type\": 13\n", "\"Type\": 1\n");
                File.WriteAllText(filePath, data);

                LegacyDesktopChannelSettings legacySettings = await SerializerHelper.DeserializeFromFile <LegacyDesktopChannelSettings>(filePath);

                legacySettings.InitializeDB = false;

                List <LegacyUserDataViewModel> legacyUsers = new List <LegacyUserDataViewModel>();
                if (legacySettings.IsStreamer)
                {
                    string dbPath = ((DesktopSettingsService)ChannelSession.Services.Settings).GetDatabaseFilePath(legacySettings);
                    SQLiteDatabaseWrapper databaseWrapper = new SQLiteDatabaseWrapper(dbPath);
                    await databaseWrapper.RunReadCommand("SELECT * FROM Users", (SQLiteDataReader dataReader) =>
                    {
                        LegacyUserDataViewModel userData = new LegacyUserDataViewModel(dataReader);
                        legacyUsers.Add(userData);
                    });

                    File.Copy(DesktopSettingsService.SettingsTemplateDatabaseFileName, dbPath, overwrite: true);
                }

                await ChannelSession.Services.Settings.Initialize(legacySettings);

                DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath);

                settings.InitializeDB = false;
                await ChannelSession.Services.Settings.Initialize(settings);

                UserCurrencyViewModel currency = null;
                UserCurrencyViewModel rank     = null;
                if (settings.IsStreamer)
                {
                    if (!string.IsNullOrEmpty(legacySettings.CurrencyAcquisition.Name))
                    {
                        currency = legacySettings.CurrencyAcquisition;
                        currency.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(currency.Name);
                        settings.Currencies.Add(legacySettings.CurrencyAcquisition.ID, legacySettings.CurrencyAcquisition);
                    }

                    if (!string.IsNullOrEmpty(legacySettings.RankAcquisition.Name))
                    {
                        rank = legacySettings.RankAcquisition;
                        rank.SpecialIdentifier  = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rank.Name);
                        rank.Ranks              = legacySettings.Ranks;
                        rank.RankChangedCommand = legacySettings.RankChangedCommand;
                        settings.Currencies.Add(legacySettings.RankAcquisition.ID, legacySettings.RankAcquisition);
                    }

                    foreach (LegacyUserDataViewModel user in legacyUsers)
                    {
                        settings.UserData[user.ID] = user;
                        if (rank != null)
                        {
                            settings.UserData[user.ID].SetCurrencyAmount(rank, user.RankPoints);
                        }
                        if (currency != null)
                        {
                            settings.UserData[user.ID].SetCurrencyAmount(currency, user.CurrencyAmount);
                        }
                    }

                    if (currency != null)
                    {
                        if (legacySettings.GiveawayCurrencyCost > 0)
                        {
                            settings.GiveawayCurrencyRequirement = new UserCurrencyRequirementViewModel(currency, legacySettings.GiveawayCurrencyCost);
                        }
                        if (legacySettings.GameQueueCurrencyCost > 0)
                        {
                            settings.GameQueueCurrencyRequirement = new UserCurrencyRequirementViewModel(currency, legacySettings.GameQueueCurrencyCost);
                        }
                    }

                    if (rank != null)
                    {
                        if (legacySettings.GiveawayUserRank != null && rank.Ranks.Any(r => r.Name.Equals(legacySettings.GiveawayUserRank)))
                        {
                            settings.GiveawayRankRequirement = new UserCurrencyRequirementViewModel(rank, rank.Ranks.FirstOrDefault(r => r.Name.Equals(legacySettings.GiveawayUserRank)));
                        }
                        if (legacySettings.GameQueueMinimumRank != null)
                        {
                            settings.GameQueueRankRequirement = new UserCurrencyRequirementViewModel(rank, legacySettings.GameQueueMinimumRank);
                        }
                    }
                }

                List <CommandBase> commands = new List <CommandBase>();
                commands.AddRange(settings.ChatCommands);
                commands.AddRange(settings.InteractiveCommands);
                commands.AddRange(settings.EventCommands);
                commands.AddRange(settings.TimerCommands);

                foreach (CommandBase command in commands)
                {
                    foreach (ActionBase action in command.Actions)
                    {
                        if (action is ChatAction)
                        {
                            ChatAction nAction = (ChatAction)action;
                            nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.ChatText, currency, rank);
                        }
                        else if (action is CurrencyAction)
                        {
                            CurrencyAction nAction = (CurrencyAction)action;
                            nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.ChatText, currency, rank);
                        }
                        else if (action is OBSStudioAction)
                        {
                            OBSStudioAction nAction = (OBSStudioAction)action;
                            nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.SourceText, currency, rank);
                        }
                        else if (action is OverlayAction)
                        {
                            OverlayAction nAction = (OverlayAction)action;
                            nAction.ImagePath = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.ImagePath, currency, rank);
                            nAction.Text      = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.Text, currency, rank);
                        }
                        else if (action is TextToSpeechAction)
                        {
                            TextToSpeechAction nAction = (TextToSpeechAction)action;
                            nAction.SpeechText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.SpeechText, currency, rank);
                        }
                        else if (action is XSplitAction)
                        {
                            XSplitAction nAction = (XSplitAction)action;
                            nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.SourceText, currency, rank);
                        }
                    }
                }

                if (settings.IsStreamer)
                {
                    foreach (ChatCommand command in settings.ChatCommands)
                    {
#pragma warning disable CS0612 // Type or member is obsolete
                        if (command.CurrencyCost > 0)
                        {
                            command.CurrencyRequirement = new UserCurrencyRequirementViewModel(currency, command.CurrencyCost);
                        }
#pragma warning restore CS0612 // Type or member is obsolete
                    }
                }

                await ChannelSession.Services.Settings.Save(settings);
            }
        }