Esempio n. 1
0
        private void workingDayFrom_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (workingDayFrom.SelectedItem != null)
            {
                lastSelectedTerm.StartTime = (TimeSpan)workingDayFrom.SelectedItem;
                ListOfTerms.RemoveAt(CurrentMonthDataGrid.SelectedIndex);
                ListOfTerms.Insert(CurrentMonthDataGrid.SelectedIndex, lastSelectedTerm);

                RefreshDataGrid();

                if (workingDayFrom.SelectedIndex == workingDayFrom.Items.Count - 1)
                {
                    workingDayTo.ItemsSource = ClassHelpers.GenerateListOfHours((TimeSpan)workingDayFrom.Items[workingDayFrom.SelectedIndex], ListOfOriginalDays()[lastSelectedIndex].EndTime);
                }
                else
                {
                    workingDayTo.ItemsSource = ClassHelpers.GenerateListOfHours((TimeSpan)workingDayFrom.Items[workingDayFrom.SelectedIndex + 1], ListOfOriginalDays()[lastSelectedIndex].EndTime);
                }

                if ((TimeSpan)workingDayFrom.SelectedItem > lastSelectedTerm.EndTime)
                {
                    workingDayTo.ItemsSource   = ClassHelpers.GenerateListOfHours((TimeSpan)workingDayFrom.Items[workingDayFrom.SelectedIndex + 1], ListOfOriginalDays()[lastSelectedIndex].EndTime);
                    workingDayTo.SelectedIndex = 0;
                }

                ClassSqlCalendar.UpdateTerm(lastSelectedTerm.TermId, lastSelectedTerm.StartTime, lastSelectedTerm.EndTime);
            }
        }
Esempio n. 2
0
        public static void RemoveAllExistingDpmIdDefinitions(List <string> dpmIDs)
        {
            List <string> listofAllConstants = new List <string>();

            using (StreamReader reader = new StreamReader(_currentDirectoryPath + "ALG.CRDIV.Constants.xsr"))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith("constant DPM_ID"))
                    {
                        string val = ClassHelpers.Between(line, "constant ", "=eba_met");
                        if (!ClassHelpers.HasValue(val, dpmIDs))
                        {
                            line = "";
                            listofAllConstants.Add(line);
                        }
                        else
                        {
                            listofAllConstants.Add(line);
                        }
                    }
                }
                reader.Close();
            }
        }
Esempio n. 3
0
        public static List <Constants> GetModifiedConstantDefinitions(List <string> dpmIds)
        {
            List <Constants> allconstsants = new List <Constants>();
            List <Constants> constsants    = new List <Constants>();

            if (File.Exists(_rootFilePath + "//Resources//Constants.xlsx"))
            {
                using (SLDocument inputExcel = new SLDocument(_rootFilePath + "//Resources//Constants.xlsx"))
                {
                    for (int i = 2; i <= 57407; i++)
                    {
                        string definition = inputExcel.GetCellValueAsString(i, 6);
                        string dpmID      = ClassHelpers.Between(definition, "constant ", "=eba_met");
                        allconstsants.Add(new Constants
                        {
                            Definitions = definition,
                            DPMID       = dpmID
                        });
                    }
                }

                foreach (var item in dpmIds)
                {
                    var aaaa = allconstsants.Where(x => x.DPMID == item).FirstOrDefault();
                    if (aaaa != null)
                    {
                    }
                    constsants.Add(allconstsants.Where(x => x.DPMID == item).FirstOrDefault());
                }
            }

            return(constsants);
        }
        private void workingDayFrom_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (workingDayFrom.SelectedItem != null)
            {
                lastSelectedDay.StartTime = (TimeSpan)workingDayFrom.SelectedItem;
                days.RemoveAt(CurrentMonthDataGrid.SelectedIndex);
                days.Insert(CurrentMonthDataGrid.SelectedIndex, lastSelectedDay);

                RefreshDataGrid();

                if (workingDayFrom.SelectedIndex == workingDayFrom.Items.Count - 1)
                {
                    workingDayTo.ItemsSource = ClassHelpers.GenerateListOfHours((TimeSpan)workingDayFrom.Items[workingDayFrom.SelectedIndex], lastSelectedDay.EndTime + new TimeSpan(0, 15, 0));
                }
                else
                {
                    workingDayTo.ItemsSource = ClassHelpers.GenerateListOfHours((TimeSpan)workingDayFrom.Items[workingDayFrom.SelectedIndex + 1], ListOfOriginalDays()[lastSelectedIndex].EndTime);
                }

                if ((TimeSpan)workingDayFrom.SelectedItem > lastSelectedDay.EndTime)
                {
                    workingDayTo.ItemsSource   = ClassHelpers.GenerateListOfHours((TimeSpan)workingDayFrom.Items[workingDayFrom.SelectedIndex + 1], ListOfOriginalDays()[lastSelectedIndex].EndTime);
                    workingDayTo.SelectedIndex = 0;
                }
            }
        }
        public WindowDoctorEditCalendarAdd()
        {
            InitializeComponent();

            workingDayFrom.ItemsSource = ClassHelpers.GenerateListOfHours(new TimeSpan(7, 0, 0), new TimeSpan(20, 0, 0));
            workingDayTo.ItemsSource   = ClassHelpers.GenerateListOfHours(new TimeSpan(7, 0, 0), new TimeSpan(20, 0, 0));
            AvailableDate.ItemsSource  = ListOfAvaiableDates();
        }
        public void TestGenerateHours()
        {
            //Arange
            List <TimeSpan> expectedListofGenerateHours = new List <TimeSpan>()
            {
                new TimeSpan(7, 0, 0), new TimeSpan(7, 15, 0), new TimeSpan(7, 30, 0), new TimeSpan(7, 45, 0), new TimeSpan(8, 0, 0),
                new TimeSpan(8, 15, 0), new TimeSpan(8, 30, 0), new TimeSpan(8, 45, 0), new TimeSpan(9, 0, 0), new TimeSpan(9, 15, 0), new TimeSpan(9, 30, 0), new TimeSpan(9, 45, 0), new TimeSpan(10, 0, 0), new TimeSpan(10, 15, 0), new TimeSpan(10, 30, 0), new TimeSpan(10, 45, 0), new TimeSpan(11, 0, 0), new TimeSpan(11, 15, 0), new TimeSpan(11, 30, 0), new TimeSpan(11, 45, 0), new TimeSpan(12, 0, 0), new TimeSpan(12, 15, 0), new TimeSpan(12, 30, 0), new TimeSpan(12, 45, 0), new TimeSpan(13, 0, 0), new TimeSpan(13, 15, 0), new TimeSpan(13, 30, 0), new TimeSpan(13, 45, 0), new TimeSpan(14, 0, 0), new TimeSpan(14, 15, 0), new TimeSpan(14, 30, 0), new TimeSpan(14, 45, 0), new TimeSpan(15, 0, 0), new TimeSpan(15, 15, 0), new TimeSpan(15, 30, 0), new TimeSpan(15, 45, 0), new TimeSpan(16, 0, 0), new TimeSpan(16, 15, 0), new TimeSpan(16, 30, 0), new TimeSpan(16, 45, 0), new TimeSpan(17, 0, 0), new TimeSpan(17, 15, 0), new TimeSpan(17, 30, 0), new TimeSpan(17, 45, 0), new TimeSpan(18, 0, 0), new TimeSpan(18, 15, 0), new TimeSpan(18, 30, 0), new TimeSpan(18, 45, 0), new TimeSpan(19, 0, 0), new TimeSpan(19, 15, 0), new TimeSpan(19, 30, 0), new TimeSpan(19, 45, 0), new TimeSpan(20, 0, 0)
            };

            // Act
            List <TimeSpan> actualListofGenerateHours = ClassHelpers.GenerateListOfHours(new TimeSpan(7, 0, 0), new TimeSpan(20, 0, 0));

            // Assert
            Xunit.Assert.Equal(expectedListofGenerateHours, actualListofGenerateHours);
        }
Esempio n. 7
0
        public static List <string> GetListofNotUsedConstants()
        {
            string mappingFilePath = _currentDirectoryPath + "SphinxRulesOutput_Consistency.xsr";
            Dictionary <int, string> dictGetUsedConstants = new Dictionary <int, string>();

            if (File.Exists(mappingFilePath))
            {
                dictGetUsedConstants = GeneralHelper.ReadMappingFromXsr(mappingFilePath);
            }
            if (dictGetUsedConstants.Count <= 0)
            {
                return(new List <string>());
            }

            List <string> listofMappings = new List <string>();

            listofMappings = dictGetUsedConstants.Values.ToList();


            List <string> listofNotUsedConstants = new List <string>();

            using (StreamReader reader = new StreamReader(_currentDirectoryPath + "ALG.CRDIV.Constants.xsr"))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith("constant DPM_ID"))
                    {
                        string val = "$" + ClassHelpers.Between(line, "constant ", "=eba_met");
                        if (!ClassHelpers.HasValue(val, listofMappings))
                        {
                            line = "//" + line;
                            listofNotUsedConstants.Add(line);
                        }
                        else
                        {
                            listofNotUsedConstants.Add(line);
                        }
                    }
                }
                reader.Close();
            }
            return(listofNotUsedConstants);
        }
Esempio n. 8
0
        private void CheckBoxWorkingDay_Checked(object sender, RoutedEventArgs e)
        {
            if (lastSelectedTerm != null)
            {
                workingDayFrom.IsEnabled = true;
                workingDayTo.IsEnabled   = true;

                ClassTerm term = (ClassTerm)CurrentMonthDataGrid.SelectedItem;
                RefreshLastSelectedItems(term);

                lastSelectedTerm.IsWorkingDay = true;
                ListOfTerms.RemoveAt(CurrentMonthDataGrid.SelectedIndex);
                ListOfTerms.Insert(CurrentMonthDataGrid.SelectedIndex, lastSelectedTerm);

                RefreshDataGrid();

                workingDayFrom.ItemsSource  = ClassHelpers.GenerateListOfHours(new TimeSpan(7, 0, 0), new TimeSpan(19, 45, 0));
                workingDayFrom.SelectedItem = lastSelectedTerm.StartTime;
                workingDayTo.ItemsSource    = ClassHelpers.GenerateListOfHours(new TimeSpan(7, 15, 0), new TimeSpan(20, 0, 0));
                workingDayTo.SelectedItem   = lastSelectedTerm.EndTime;
            }
        }
        private void CheckBoxWorkingDay_Checked(object sender, RoutedEventArgs e)
        {
            workingDayFrom.IsEnabled = true;
            workingDayTo.IsEnabled   = true;

            ClassCalendarDay day = (ClassCalendarDay)CurrentMonthDataGrid.SelectedItem;

            RefreshLastSelectedItems(day);

            day.IsWorkingDay = true;
            // day.StartTime = ListOfOriginalDays()[lastSelectedIndex].StartTime;
            // day.EndTime = ListOfOriginalDays()[lastSelectedIndex].EndTime;
            days.RemoveAt(CurrentMonthDataGrid.SelectedIndex);
            days.Insert(CurrentMonthDataGrid.SelectedIndex, day);

            RefreshDataGrid();

            workingDayFrom.ItemsSource  = ClassHelpers.GenerateListOfHours(ListOfOriginalDays()[lastSelectedIndex].StartTime, ListOfOriginalDays()[lastSelectedIndex].EndTime - new TimeSpan(0, 15, 0));
            workingDayFrom.SelectedItem = lastSelectedDay.StartTime;
            workingDayTo.ItemsSource    = ClassHelpers.GenerateListOfHours((TimeSpan)workingDayFrom.Items[workingDayFrom.SelectedIndex + 1], ListOfOriginalDays()[lastSelectedIndex].EndTime);
            workingDayTo.SelectedIndex  = workingDayTo.Items.Count - 1;
        }
Esempio n. 10
0
        private static async Task <bool> WaitForBo(Client client)
        {
            var initialLocation = client.Game.Me.Location;
            var stopWatch       = new Stopwatch();

            stopWatch.Start();
            while (stopWatch.Elapsed < TimeSpan.FromSeconds(10) && ClassHelpers.AnyPlayerIsMissingShouts(client))
            {
                await Task.Delay(TimeSpan.FromSeconds(0.5));

                await client.Game.MoveToAsync(initialLocation.Add((short)new Random().Next(-5, 5), (short)new Random().Next(-5, 5)));
            }

            if (stopWatch.Elapsed >= TimeSpan.FromSeconds(10))
            {
                Log.Warning($"Client {client.Game.Me.Name} Failed waiting for bo at area {client.Game.Area} at location {client.Game.Me.Location}");
                return(false);
            }

            client.Game.UseHealthPotion();

            return(true);
        }
Esempio n. 11
0
        public void ValidatePassword(string input, bool expected)
        {
            bool actual = ClassHelpers.IsValidPassword(input);

            Assert.Equal(expected, actual);
        }
Esempio n. 12
0
 private void TextBoxEmail_TextChanged(object sender, TextChangedEventArgs e)
 {
     ButtonNext.IsEnabled = ClassHelpers.ValidateEmail(TextBoxEmail.Text);
 }
 private void AddWorkingDayFrom_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     workingDayTo.ItemsSource = ClassHelpers.GenerateListOfHours((TimeSpan)(workingDayFrom.SelectedItem) + new TimeSpan(0, 15, 0), new TimeSpan(20, 0, 0));
 }
Esempio n. 14
0
        public static void WriteAllModifiedConstants(List <Constants> modifiedDefinitions, string fileName)
        {
            //Get All Constants from Existing files
            List <string> listofAllConstants = new List <string>();

            using (StreamReader reader = new StreamReader(_currentDirectoryPath + "ALG.CRDIV.Constants.xsr"))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    listofAllConstants.Add(line);
                }
                reader.Close();
            }

            //constant DPM_ID_10006=eba_met:md106[ eba_dim:ALO=eba_IM:x1;eba_dim:APL=eba_PL:x4;eba_dim:BAS=eba_BA:x6;eba_dim:MCY=eba_MC:x143;unit=unit(iso4217:EUR);]

            string fullFilePath = Path.Combine(_rootFilePath, "Resources", fileName);

            using (System.IO.StreamWriter filetoWritwe = new StreamWriter(File.Open(fullFilePath, System.IO.FileMode.Append)))
            {
                foreach (string listItem in listofAllConstants)
                {
                    if (listItem.StartsWith("constant DPM_ID"))
                    {
                        string constantID = ClassHelpers.Between(listItem, "constant ", "=eba_met");
                        var    val        = modifiedDefinitions.Where(x => x.DPMID.Equals(constantID));
                        if (val.Count() != 0)
                        {
                            string modifiedDefinition = modifiedDefinitions.Where(x => x.DPMID.Equals(constantID)).FirstOrDefault().Definitions;
                            filetoWritwe.WriteLine(modifiedDefinition);
                        }
                        else
                        {
                            filetoWritwe.WriteLine(listItem);
                        }
                    }
                    else if (listItem.StartsWith("macro DPM_ID"))
                    {
                        string constantID = ClassHelpers.Between(listItem, "macro ", "() eba_met");
                        var    val        = modifiedDefinitions.Where(x => x.DPMID.Equals(constantID));
                        if (val.Count() != 0)
                        {
                            string modifiedDefinition = modifiedDefinitions.Where(x => x.DPMID.Equals(constantID)).FirstOrDefault().Definitions;
                            string existingDefinition = ClassHelpers.Between(listItem.Replace("; ]", ";]"), "[", ";]");
                            modifiedDefinition = ClassHelpers.Between(modifiedDefinition, "[", ";]");
                            string finalItem = listItem.Replace(existingDefinition, modifiedDefinition);
                            filetoWritwe.WriteLine(finalItem);
                        }
                        else
                        {
                            filetoWritwe.WriteLine(listItem);
                        }
                    }

                    else
                    {
                        filetoWritwe.WriteLine(listItem);
                    }
                }
            }
        }
 private void PasswordBoxPassword_PasswordChanged(object sender, RoutedEventArgs e)
 {
     //Verify if both passwordboxes are the same
     Button_Save.IsEnabled = PasswordBoxPassword.Password.Equals(PasswordBox_RepeatPassword.Password) && ClassHelpers.IsValidPassword(PasswordBoxPassword.Password);
 }
Esempio n. 16
0
        private async Task <bool> BaseCsBot(CSManager csManager, Func <uint> getTeleportId,
                                            CancellationTokenSource nextGameCancellation, Client client,
                                            Func <CSManager, List <AliveMonster>, List <AliveMonster>, Task> action)
        {
            var localTeleportId = 0U;

            while (!nextGameCancellation.IsCancellationRequested && client.Game.IsInGame())
            {
                await Task.Delay(100);

                if (localTeleportId != getTeleportId() && !client.Game.IsInTown())
                {
                    Log.Information($"Client {client.Game.Me.Name} Taking town portal to town");
                    if (!await _townManagementService.TakeTownPortalToTown(client))
                    {
                        continue;
                    }
                }

                if (client.Game.IsInTown() && getTeleportId() != 0 && getTeleportId() != localTeleportId)
                {
                    Log.Information($"Client {client.Game.Me.Name} taking town portal to chaos");
                    var teleportPlayer = client.Game.Players.First(p => p.Name.Equals(_csconfig.TeleportCharacterName, StringComparison.CurrentCultureIgnoreCase));
                    if (!await _townManagementService.TakeTownPortalToArea(client, teleportPlayer, Area.ChaosSanctuary))
                    {
                        continue;
                    }

                    localTeleportId = getTeleportId();
                }

                if (!client.Game.IsInTown())
                {
                    var anyPlayersWithoutShouts = ClassHelpers.AnyPlayerIsMissingShouts(client);
                    if (anyPlayersWithoutShouts && client.Game.Me.Class == CharacterClass.Barbarian)
                    {
                        await ClassHelpers.CastAllShouts(client);
                    }
                    else if (ClassHelpers.IsMissingShouts(client.Game.Me))
                    {
                        Log.Information($"Client {client.Game.Me.Name} waiting for bo");
                        await WaitForBo(client);
                    }
                    else
                    {
                        await Task.Delay(100);

                        if (!await KillBosses(client, csManager, nextGameCancellation, client.Game.Me.Location, action, localTeleportId, getTeleportId))
                        {
                            return(false);
                        }
                    }
                }
            }

            if (!nextGameCancellation.IsCancellationRequested && !client.Game.IsInGame())
            {
                return(false);
            }

            return(true);
        }
Esempio n. 17
0
        public void RemoveLastCharOfString(string input, string expected)
        {
            string actual = ClassHelpers.RemoveLastCharOfString(input);

            Assert.Equal(expected, actual);
        }
Esempio n. 18
0
        public void ValidateEmail(string input, bool expected)
        {
            bool actual = ClassHelpers.ValidateEmail(input);

            Assert.Equal(expected, actual);
        }
Esempio n. 19
0
        public void IsValidNumberLenght(string input, int lenght, bool expected)
        {
            bool actual = ClassHelpers.IsValidNumberLenght(input, lenght);

            Assert.Equal(expected, actual);
        }
 public double ClassSumStaticMethod()
 {
     return(ClassHelpers.CalculateSum(_sc));
 }