public IHttpActionResult ProductInstallation([FromBody] ProductInstall productInstall) { string message = string.Empty; using (var productRepository = new ProductRepository(productInstall.UserId)) { var result = productRepository.ProductInstallation(productInstall, out message); if (!string.IsNullOrEmpty(message)) { log.Info(message); } return(Ok(new { result.Status, data = result })); } }
public bool InsertUpdateInstallProduct(ProductInstall install, out long identity, out string message) { int rowEffected = 0; using (DBConnector connector = new DBConnector("Usp_InsertUpdateInstallProduct", true)) { connector.AddInParameterWithValue("@dtlProductId", install.dtlProductId); connector.AddInParameterWithValue("@productId", install.productId); connector.AddInParameterWithValue("@VehicleId", install.VehicleId); connector.AddInParameterWithValue("@InsttalationDate", install.InsttalationDate); connector.AddInParameterWithValue("@UnitName", install.UnitName); connector.AddInParameterWithValue("@Status", install.Status); rowEffected = connector.ExceuteNonQuery(); message = connector.GetParamaeterValue("@Message").ToString(); identity = install.dtlProductId == 0 ? Convert.ToInt64(connector.GetParamaeterValue("@identity")) : install.dtlProductId; } return(rowEffected > 0); }
public ResponseSingleModel <ProductInstall> ProductInstallation(ProductInstall install, out string message) { var result = new ResponseSingleModel <ProductInstall>(); long dtlProductId = 0; message = string.Empty; if (this.instance.InsertUpdateInstallProduct(install, out dtlProductId, out message)) { install.dtlProductId = dtlProductId; result.Status = Constants.WebApiStatusOk; } else { result.Status = Constants.WebApiStatusFail; result.Message = message; } result.Response = install; return(result); }
public ClientHandler(string basePath, ClientCreateArgs createArgs) { basePath = basePath ?? ""; BasePath = basePath; CreateArgs = createArgs; string flavorInfoProductCode = null; if (createArgs.UseContainer && !Directory.Exists(basePath)) { throw new FileNotFoundException("invalid archive directory"); } var dbPath = Path.Combine(basePath, createArgs.ProductDatabaseFilename); try { if (File.Exists(dbPath)) { using (var _ = new PerfCounter("AgentDatabase::ctor`string`bool")) foreach (var install in new AgentDatabase(dbPath).Data.ProductInstall) { if (string.IsNullOrEmpty(createArgs.Flavor) || install.Settings.GameSubfolder.Contains(createArgs.Flavor)) { AgentProduct = install; break; } } if (AgentProduct == null) { throw new InvalidDataException(); } Product = ProductHelpers.ProductFromUID(AgentProduct.ProductCode); } else { throw new InvalidDataException(); } } catch { try { if (File.Exists(Path.Combine(basePath, ".flavor.info"))) { // mixed installation, store the product code to be used below flavorInfoProductCode = File.ReadLines(Path.Combine(basePath, ".flavor.info")).Skip(1).First(); Product = ProductHelpers.ProductFromUID(flavorInfoProductCode); BasePath = basePath = Path.Combine(basePath, "../"); // lmao Logger.Info("Core", $".flavor.info detected. Found product \"{flavorInfoProductCode}\""); } else { throw new InvalidDataException(); } } catch { try { Product = ProductHelpers.ProductFromLocalInstall(basePath); } catch { if (createArgs.VersionSource == ClientCreateArgs.InstallMode.Local) // if we need an archive then we should be able to detect the product { throw; } Product = createArgs.OnlineProduct; } } AgentProduct = new ProductInstall { ProductCode = flavorInfoProductCode ?? createArgs.Product ?? ProductHelpers.UIDFromProduct(Product), Settings = new UserSettings { SelectedTextLanguage = createArgs.TextLanguage ?? "enUS", SelectedSpeechLanguage = createArgs.SpeechLanguage ?? "enUS", PlayRegion = "us" } }; if (AgentProduct.Settings.SelectedSpeechLanguage == AgentProduct.Settings.SelectedTextLanguage) { AgentProduct.Settings.Languages.Add(new LanguageSetting { Language = AgentProduct.Settings.SelectedTextLanguage, Option = LanguageOption.LangoptionTextAndSpeech }); } else { AgentProduct.Settings.Languages.Add(new LanguageSetting { Language = AgentProduct.Settings.SelectedTextLanguage, Option = LanguageOption.LangoptionText }); AgentProduct.Settings.Languages.Add(new LanguageSetting { Language = AgentProduct.Settings.SelectedSpeechLanguage, Option = LanguageOption.LangoptionSpeech }); } } if (string.IsNullOrWhiteSpace(createArgs.TextLanguage)) { createArgs.TextLanguage = AgentProduct.Settings.SelectedTextLanguage; } if (string.IsNullOrWhiteSpace(createArgs.SpeechLanguage)) { createArgs.SpeechLanguage = AgentProduct.Settings.SelectedSpeechLanguage; } if (createArgs.Online) { using var _ = new PerfCounter("INetworkHandler::ctor`ClientHandler"); if (createArgs.OnlineRootHost.StartsWith("ribbit:")) { NetHandle = new RibbitCDNClient(this); } else { NetHandle = new NGDPClient(this); } } if (createArgs.VersionSource == ClientCreateArgs.InstallMode.Local) { var installationInfoPath = Path.Combine(basePath, createArgs.InstallInfoFileName) + createArgs.ExtraFileEnding; if (!File.Exists(installationInfoPath)) { throw new FileNotFoundException(installationInfoPath); } using var _ = new PerfCounter("InstallationInfo::ctor`string"); InstallationInfo = new InstallationInfo(installationInfoPath, AgentProduct.ProductCode); } else { using var _ = new PerfCounter("InstallationInfo::ctor`INetworkHandler"); InstallationInfo = new InstallationInfo(NetHandle, createArgs.OnlineRegion); } Logger.Info("CASC", $"{Product} build {InstallationInfo.Values["Version"]}"); if (createArgs.UseContainer) { Logger.Info("CASC", "Initializing..."); using var _ = new PerfCounter("ContainerHandler::ctor`ClientHandler"); ContainerHandler = new ContainerHandler(this); } using (var _ = new PerfCounter("ConfigHandler::ctor`ClientHandler")) ConfigHandler = new ConfigHandler(this); using (var _ = new PerfCounter("EncodingHandler::ctor`ClientHandler")) EncodingHandler = new EncodingHandler(this); if (ConfigHandler.BuildConfig.VFSRoot != null) { using var _ = new PerfCounter("VFSFileTree::ctor`ClientHandler"); VFS = new VFSFileTree(this); } if (createArgs.Online) { m_cdnIdx = CDNIndexHandler.Initialize(this); } using (var _ = new PerfCounter("ProductHandlerFactory::GetHandler`TACTProduct`ClientHandler`Stream")) ProductHandler = ProductHandlerFactory.GetHandler(Product, this, OpenCKey(ConfigHandler.BuildConfig.Root.ContentKey)); Logger.Info("CASC", "Ready"); }
async Task BattleNetAddApplication(ProductInstall productInstall, string launcherExePath) { try { //Get application details //Improve find way to load proper uid string appUid = productInstall.uid; string installDir = productInstall.settings.installPath; //Check if application id is in blacklist if (vBattleNetUidBlacklist.Contains(appUid)) { Debug.WriteLine("BattleNet uid is blacklisted: " + appUid); return; } //Check if application is installed if (!Directory.Exists(installDir)) { Debug.WriteLine("BattleNet game is not installed: " + appUid); return; } //Set application launch argument string launchArgument = "--exec=\"launch_uid " + appUid + "\""; vLauncherAppAvailableCheck.Add(launcherExePath); //Check if application is already added DataBindApp launcherExistCheck = List_Launchers.Where(x => !string.IsNullOrWhiteSpace(x.Argument) && x.Argument.ToLower() == launchArgument.ToLower()).FirstOrDefault(); if (launcherExistCheck != null) { //Debug.WriteLine("BattleNet app already in list: " + appUid); return; } //Get application branch string appBranch = productInstall.settings.branch; appBranch = appBranch.Replace("_", string.Empty); foreach (string branchReplace in vBattleNetBranchReplace) { appBranch = appBranch.Replace(branchReplace, string.Empty); } appBranch = AVFunctions.ToTitleCase(appBranch); //Get application name string appName = Path.GetFileName(installDir); if (!string.IsNullOrWhiteSpace(appBranch)) { appName += " (" + appBranch + ")"; } //Check if application name is ignored string appNameLower = appName.ToLower(); if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower)) { //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName); await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower); return; } //Get application image BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, "Battle.Net" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0); //Add the application to the list DataBindApp dataBindApp = new DataBindApp() { Category = AppCategory.Launcher, Launcher = AppLauncher.BattleNet, Name = appName, ImageBitmap = iconBitmapImage, PathExe = launcherExePath, Argument = launchArgument, StatusLauncher = vImagePreloadBattleNet, LaunchKeyboard = true }; await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false); //Debug.WriteLine("Added BattleNet app: " + appName); } catch (Exception ex) { Debug.WriteLine("Failed adding BattleNet app: " + ex.Message); } }