Пример #1
0
 public ScheduledService(
     ImporterService importerService,
     ArtistService artistService,
     IConfigurationRoot config
     )
 {
     _importerService = importerService;
     _artistService   = artistService;
     _config          = config;
 }
Пример #2
0
 public ImportController(
     RedisService redis,
     DbService db,
     ArtistService artistService,
     ImporterService importer,
     ScheduledService scheduledService
     ) : base(redis, db, artistService)
 {
     _scheduledService = scheduledService;
     _importer         = importer;
 }
Пример #3
0
 public ScheduledService(
     ImporterService importerService,
     ArtistService artistService,
     RedisService redisService,
     IConfiguration config
     )
 {
     _importerService = importerService;
     _artistService   = artistService;
     _config          = config;
     _redisService    = redisService;
 }
Пример #4
0
 public ImportController(
     RedisService redis,
     DbService db,
     ArtistService artistService,
     ImporterService importer,
     ScheduledService scheduledService,
     IConfiguration configuration
     ) : base(redis, db, artistService)
 {
     _configuration    = configuration;
     _scheduledService = scheduledService;
     _importer         = importer;
 }
Пример #5
0
 public ArtistService(DbService db, ImporterService importService) : base(db)
 {
     _importService = importService;
 }
        private void btn_ImportFile_Click(object sender, EventArgs e)
        {
            try
            {
                var importerService = new ImporterService();
                var fileText        = importerService.ReadFile(FileToImport);
                var lines           = importerService.SplitString(fileText, '\n');

                var dict         = new Dictionary <string, int>();
                var easyUoRecord = new EasyUoRecord();
                var actualtype   = easyUoRecord.GetType();
                foreach (var propertyInfo in actualtype.GetProperties())
                {
                    foreach (ColumnNumber columnNumber in propertyInfo.GetCustomAttributes(typeof(ColumnNumber), false))
                    {
                        dict.Add(propertyInfo.Name, columnNumber.Value);
                        break;
                    }
                }

                var armors = new List <Armor>();
                foreach (var line in lines)
                {
                    var data      = importerService.SplitString(line, '.');
                    var dataArray = data?.ToArray();
                    if (data == null || dataArray.Length == 0)
                    {
                        continue;
                    }

                    // Check for Resource based on Color
                    var itemColor = int.Parse(dataArray[dict[nameof(easyUoRecord.Color)]]);
                    var resource  = _resources.FirstOrDefault(r => r.Color == itemColor);
                    if (resource == null)
                    {
                        var result = MessageBox.Show($@"Unable find known color for '{itemColor}'." +
                                                     "\r\n\r\nWould you like to skip the record?",
                                                     @"Unknown Color", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            continue;
                        }
                        return;
                    }

                    // This tells us the Base Resists for this item
                    var itemType     = dataArray[dict[nameof(easyUoRecord.ItemType)]];
                    var armorRecords = _knownItemTypes[itemType];
                    var baseArmor    = armorRecords.FirstOrDefault(r => r.Color == itemColor);
                    if (baseArmor == null)
                    {
                        // Type to Color is a one to many relationship
                        var result = MessageBox.Show($@"Unable find Type '{itemType}' with Color '{itemColor}'." +
                                                     "\r\n\r\nWould you like to skip the record?",
                                                     @"Unexpected item Type/Color combination", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            continue;
                        }
                        return;
                    }

                    // Fetch the basics
                    var currentResists = new Resists
                    {
                        Physical = int.Parse(dataArray[dict[nameof(easyUoRecord.Physical)]]),
                        Fire     = int.Parse(dataArray[dict[nameof(easyUoRecord.Fire)]]),
                        Cold     = int.Parse(dataArray[dict[nameof(easyUoRecord.Cold)]]),
                        Poison   = int.Parse(dataArray[dict[nameof(easyUoRecord.Poison)]]),
                        Energy   = int.Parse(dataArray[dict[nameof(easyUoRecord.Energy)]]),
                    };
                    var armor = new Armor
                    {
                        CurrentResists = currentResists,
                        Slot           = baseArmor.Slot,
                    };
                    armor.Id = dataArray[dict[nameof(armor.Id)]];

                    // Set it's minimums
                    armor.BaseResists = _resistConfigurations[baseArmor.BaseResistConfigurationId];

                    // Check if it's imbued already
                    armor.EvaluateImbuedResists(_maxResistBonus);

                    // Add the bonus to the base if it it's not the default color
                    if (itemColor != baseArmor.Color)
                    {
                        var resourceResists = _resistConfigurations[resource.BonusResistConfigurationId];
                        armor.CurrentResists.Add(resourceResists);
                    }
                    else
                    {
                        armor.NeedsBonus = true;
                    }

                    armors.Add(armor);
                }

                _armorPieces = armors;
                MessageBox.Show($@"Imported '{_armorPieces.Count}' records.");
                btn_MakeSuit.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }