public async Task <IActionResult> RefreshDataPackage(string packageName)
        {
            try
            {
                var dataPackage = Program.AvailablePackages.FirstOrDefault(x => x.PackageName == packageName);
                if (dataPackage != null)
                {
                    var newDataPackage = new TelemetryPackage()
                    {
                        PackageName = packageName,
                        PackageData = await BlobStorageService.GetData(BlobStorageService.DataContainerName, packageName)
                    };

                    Program.AvailablePackages.Remove(dataPackage);
                    Program.AvailablePackages.Add(newDataPackage);
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewData["message"] = ex.Message;
                ViewData["trace"]   = ex.StackTrace;
                return(View("Error"));
            }
        }
        public static TelemetryPackage GetTelemetryPackageForDLC(Mod.MEGame game, string dlcDirectory, string dlcFoldername, string destinationDLCName, string modName, string modAuthor, string modSite, Mod telemetryMod)
        {
            TelemetryPackage tp = new TelemetryPackage();
            var sourceDir       = Path.Combine(dlcDirectory, dlcFoldername);

            tp.DLCFolderName = destinationDLCName; //this most times will be the same as dlcFoldername, but in case of alternates, it might not be
            if (telemetryMod != null && telemetryMod.HumanReadableCustomDLCNames.TryGetValue(dlcFoldername, out var modNameIni))
            {
                tp.ModName = modNameIni;
            }
            else
            {
                tp.ModName = modName;
            }

            tp.ModAuthor = modAuthor;
            tp.ModSite   = modSite;
            tp.Game      = game;
            switch (game)
            {
            case Mod.MEGame.ME1:
            {
                var ini       = new FileIniDataParser();
                var parsedIni = ini.Parser.Parse(File.ReadAllText(Path.Combine(sourceDir, @"AutoLoad.ini")));
                tp.MountPriority = int.Parse(parsedIni[@"ME1DLCMOUNT"][@"ModMount"]);
                tp.ModMountTLK1  = int.Parse(parsedIni[@"GUI"][@"NameStrRef"]);
                tp.MountFlagHR   = M3L.GetString(M3L.string_me1MountFlagsNotSupportedInM3);
                //No mount flag right now.
            }
            break;

            case Mod.MEGame.ME2:
            {
                var       mountFile = Path.Combine(sourceDir, @"CookedPC", @"mount.dlc");
                MountFile mf        = new MountFile(mountFile);
                tp.ModMountTLK1  = mf.TLKID;
                tp.MountPriority = mf.MountPriority;
                tp.MountFlag     = (int)mf.MountFlag;
                tp.MountFlagHR   = mf.MountFlag.ToString();
                var ini       = new FileIniDataParser();
                var parsedIni = ini.Parser.Parse(File.ReadAllText(Path.Combine(sourceDir, @"CookedPC", @"BIOEngine.ini")));
                tp.ModuleNumber = parsedIni[@"Engine.DLCModules"][dlcFoldername];
            }
            break;

            case Mod.MEGame.ME3:
            {
                var       mountFile = Path.Combine(sourceDir, @"CookedPCConsole", @"mount.dlc");
                MountFile mf        = new MountFile(mountFile);
                tp.ModMountTLK1  = mf.TLKID;
                tp.MountPriority = mf.MountPriority;
                tp.MountFlag     = (int)mf.MountFlag;
                tp.MountFlagHR   = mf.MountFlag.ToString();
            }
            break;
            }

            return(tp);
        }
        public async Task <IActionResult> LoadDataPackage(string packageName)
        {
            try
            {
                var dataPackage = new TelemetryPackage()
                {
                    PackageName = packageName,
                    PackageData = await BlobStorageService.GetData(BlobStorageService.DataContainerName, packageName)
                };

                Program.AvailablePackages.Add(dataPackage);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewData["message"] = ex.Message;
                ViewData["trace"]   = ex.StackTrace;
                return(View("Error"));
            }
        }
Esempio n. 4
0
        private void GatherTelemetryDataBGThread(object sender, DoWorkEventArgs e)
        {
            List <TelemetryPackage> telemetryPackages = new List <TelemetryPackage>();

            foreach (var mapping in TelemetryMod.GetJob(ModJob.JobHeader.CUSTOMDLC).CustomDLCFolderMapping)
            {
                TelemetryPackage tp = new TelemetryPackage();
                var sourceDir       = mapping.Key;
                tp.DLCFolderName = mapping.Value;
                if (TelemetryMod.HumanReadableCustomDLCNames.TryGetValue(mapping.Value, out var modName))
                {
                    tp.ModName = modName;
                }
                else
                {
                    tp.ModName = TelemetryMod.ModName;
                }

                tp.ModAuthor = TelemetryMod.ModDeveloper;
                tp.ModSite   = TelemetryMod.ModWebsite;
                tp.Game      = TelemetryMod.Game;
                switch (TelemetryMod.Game)
                {
                case Mod.MEGame.ME1:
                {
                    var ini       = new FileIniDataParser();
                    var parsedIni = ini.Parser.Parse(File.ReadAllText(Path.Combine(TelemetryMod.ModPath, mapping.Key, "AutoLoad.ini")));
                    tp.MountPriority = int.Parse(parsedIni["ME1DLCMOUNT"]["ModMount"]);
                    tp.ModMountTLK1  = int.Parse(parsedIni["GUI"]["NameStrRef"]);
                    tp.MountFlagHR   = "ME1 does not support mount flags in M3 currently";
                    //No mount flag right now.
                }
                break;

                case Mod.MEGame.ME2:
                {
                    var       mountFile = Path.Combine(TelemetryMod.ModPath, mapping.Key, "CookedPC", "mount.dlc");
                    MountFile mf        = new MountFile(mountFile);
                    tp.ModMountTLK1  = mf.TLKID;
                    tp.MountPriority = mf.MountPriority;
                    tp.MountFlag     = (int)mf.MountFlag;
                    tp.MountFlagHR   = mf.MountFlag.ToString();
                    var ini       = new FileIniDataParser();
                    var parsedIni = ini.Parser.Parse(File.ReadAllText(Path.Combine(TelemetryMod.ModPath, mapping.Key, "CookedPC", "BIOEngine.ini")));
                    tp.ModuleNumber = parsedIni["Engine.DLCModules"][mapping.Key];
                }
                break;

                case Mod.MEGame.ME3:
                {
                    var       mountFile = Path.Combine(TelemetryMod.ModPath, mapping.Key, "CookedPCConsole", "mount.dlc");
                    MountFile mf        = new MountFile(mountFile);
                    tp.ModMountTLK1  = mf.TLKID;
                    tp.MountPriority = mf.MountPriority;
                    tp.MountFlag     = (int)mf.MountFlag;
                    tp.MountFlagHR   = mf.MountFlag.ToString();
                }
                break;
                }
                telemetryPackages.Add(tp);
            }

            e.Result = telemetryPackages;
        }
        public static TelemetryPackage GetTelemetryPackageForDLC(MEGame game, string dlcDirectory, string dlcFoldername, string destinationDLCName, string modName, string modAuthor, string modSite, Mod telemetryMod)
        {
            try
            {
                TelemetryPackage tp = new TelemetryPackage();
                var sourceDir       = Path.Combine(dlcDirectory, dlcFoldername);
                tp.DLCFolderName = destinationDLCName; //this most times will be the same as dlcFoldername, but in case of alternates, it might not be
                if (telemetryMod != null && telemetryMod.HumanReadableCustomDLCNames.TryGetValue(dlcFoldername, out var modNameIni))
                {
                    tp.ModName = modNameIni;
                }
                else
                {
                    tp.ModName = modName;
                }

                tp.ModAuthor = modAuthor;
                tp.ModSite   = modSite;
                tp.Game      = game;
                switch (game)
                {
                case MEGame.LE1:
                case MEGame.ME1:
                {
                    var parsedIni = DuplicatingIni.LoadIni(Path.Combine(sourceDir, @"AutoLoad.ini"));
                    tp.MountPriority = int.Parse(parsedIni[@"ME1DLCMOUNT"][@"ModMount"]?.Value);
                    tp.ModMountTLK1  = int.Parse(parsedIni[@"GUI"][@"NameStrRef"]?.Value);
                    tp.MountFlagHR   = M3L.GetString(M3L.string_me1MountFlagsNotSupportedInM3);
                    //No mount flag right now.
                }
                break;

                case MEGame.ME2:
                case MEGame.LE2:
                {
                    var       mountFile = Path.Combine(sourceDir, game.CookedDirName(), @"mount.dlc");
                    MountFile mf        = new MountFile(mountFile);
                    tp.ModMountTLK1  = mf.TLKID;
                    tp.MountPriority = mf.MountPriority;
                    tp.MountFlag     = (int)mf.MountFlags.FlagValue;
                    tp.MountFlagHR   = mf.MountFlags.ToHumanReadableString();
                    var ini = DuplicatingIni.LoadIni(Path.Combine(sourceDir, game.CookedDirName(), @"BIOEngine.ini"));
                    tp.ModuleNumber = ini[@"Engine.DLCModules"][dlcFoldername]?.Value;
                }
                break;

                case MEGame.ME3:
                case MEGame.LE3:
                {
                    var       mountFile = Path.Combine(sourceDir, @"CookedPCConsole", @"mount.dlc");
                    MountFile mf        = new MountFile(mountFile);
                    tp.ModMountTLK1  = mf.TLKID;
                    tp.MountPriority = mf.MountPriority;
                    tp.MountFlag     = mf.MountFlags.FlagValue;
                    tp.MountFlagHR   = mf.MountFlags.ToHumanReadableString();
                }
                break;
                }

                return(tp);
            }
            catch (Exception e)
            {
                Log.Error($@"Error building telemetry package for {dlcFoldername}: {e.Message}.");
                return(null);
            }
        }