/// <summary> /// Based on executable application path it creates application data and saves icon for application /// Application is also automaticaly selected as current /// </summary> /// <param name="applicationPath">Path to application user wants to add</param> public void AddNewApplication(string applicationPath) { var appData = new ApplicationRuntimeData { AppGUID = Guid.NewGuid(), AppName = Path.GetFileNameWithoutExtension(applicationPath), AppExecutablePath = applicationPath, }; using (var icon = Icon.ExtractAssociatedIcon(applicationPath)) { using (var bitmap = icon.ToBitmap()) { var iconPath = Path.Combine(LauncherHelper.GetAppIconsPath(), appData.AppGUID + ".png"); appData.AppIconPath = iconPath; using (var stream = new StreamWriter(iconPath)) { bitmap.Save(stream.BaseStream, System.Drawing.Imaging.ImageFormat.Png); stream.Close(); } } } ApplicationsData.Add(appData); SelectApplication(appData.AppGUID); _launcherDatabase.UpdateApplicationData(appData); }
public string Serialize(DeploymentConfig deploymentConfig) { var applicationsList = new List<ApplicationData>(); foreach (AppDeploymentConfig appDeploymentConfig in deploymentConfig) { applicationsList.Add(new ApplicationData(appDeploymentConfig.AppIdentity.Id, appDeploymentConfig.AppIdentity.Version.ToString(), appDeploymentConfig.TargetClusters.ToArray(), appDeploymentConfig.Properties.ToDictionary(kvp => kvp.Key, kvp => kvp.Value))); } ApplicationsData applicationsData = new ApplicationsData(applicationsList.ToArray()); return _jsonSerializer.Serialize(applicationsData); }
public async Task <DeploymentDirectoryConfig> ParseData(string json) { ApplicationsData data = await JsonUtils.ParseData <ApplicationsData>(json); var deploymentsConfigs = new List <DeploymentConfig>(); foreach (ApplicationData appData in data.Applications) { deploymentsConfigs.Add(new DeploymentConfig(new AppIdentity(appData.Id, new Version(appData.Version)), appData.DeploymentIds)); } return(new DeploymentDirectoryConfig(deploymentsConfigs)); }
public string Serialize(DeploymentConfig deploymentConfig) { var applicationsList = new List <ApplicationData>(); foreach (AppDeploymentConfig appDeploymentConfig in deploymentConfig) { applicationsList.Add(new ApplicationData(appDeploymentConfig.AppIdentity.Id, appDeploymentConfig.AppIdentity.Version.ToString(), appDeploymentConfig.TargetClusters.ToArray(), appDeploymentConfig.Properties.ToDictionary(kvp => kvp.Key, kvp => kvp.Value))); } ApplicationsData applicationsData = new ApplicationsData(applicationsList.ToArray()); return(_jsonSerializer.Serialize(applicationsData)); }
public string RawData() { var applicationsList = new List <ApplicationData>(); foreach (KeyValuePair <string, AppDeploymentConfig> app in _apps) { string appId = app.Key; AppDeploymentConfig appDeploymentConfig = app.Value; foreach (KeyValuePair <string, VersionDeploymentConfig> v in appDeploymentConfig.Versions) { string version = v.Key; VersionDeploymentConfig versionDeploymentConfig = v.Value; applicationsList.Add(new ApplicationData(appId, version, versionDeploymentConfig.DeploymentIds.ToArray())); } } ApplicationsData applicationsData = new ApplicationsData(applicationsList.ToArray()); return(JsonUtils.Serialize(applicationsData)); }
public DeploymentConfig Deserialize(string data) { DeploymentConfig deploymentConfig = new DeploymentConfig(); Dictionary <string, AppDeploymentConfig> apps = new Dictionary <string, AppDeploymentConfig>(); if (string.IsNullOrEmpty(data)) { return(deploymentConfig); } var appDeploymentConfigs = new List <AppDeploymentConfig>(); ApplicationsData appsData = _jsonSerializer.Deserialize <ApplicationsData>(data); foreach (ApplicationData appData in appsData.Applications) { AppIdentity appIdentity = new AppIdentity(appData.Id, appData.Version); AppDeploymentConfig appDeploymentConfig = new AppDeploymentConfig(appIdentity, appData.TargetClusters, appData.Properties); appDeploymentConfigs.Add(appDeploymentConfig); } return(new DeploymentConfig(appDeploymentConfigs)); }
private static Dictionary <string, AppDeploymentConfig> ParseDeploymentsConfig(string json) { Dictionary <string, AppDeploymentConfig> apps = new Dictionary <string, AppDeploymentConfig>(); if (string.IsNullOrEmpty(json)) { return(apps); } ApplicationsData appsData = JsonUtils.Deserialize <ApplicationsData>(json); foreach (ApplicationData appData in appsData.Applications) { VersionDeploymentConfig versionDeploymentConfig = new VersionDeploymentConfig(appData.Version, appData.DeploymentIds); apps = AddAppConfigIfNoneExists(apps, appData.Id); AppDeploymentConfig appDeploymentConfig = apps[appData.Id]; appDeploymentConfig = appDeploymentConfig.SetVersionConfig(versionDeploymentConfig); apps[appData.Id] = appDeploymentConfig; } return(apps); }
public string RawData() { var applicationsList = new List<ApplicationData>(); foreach (KeyValuePair<string, AppDeploymentConfig> app in _apps) { string appId = app.Key; AppDeploymentConfig appDeploymentConfig = app.Value; foreach (KeyValuePair<string, VersionDeploymentConfig> v in appDeploymentConfig.Versions) { string version = v.Key; VersionDeploymentConfig versionDeploymentConfig = v.Value; applicationsList.Add(new ApplicationData(appId, version, versionDeploymentConfig.DeploymentIds.ToArray())); } } ApplicationsData applicationsData = new ApplicationsData(applicationsList.ToArray()); return JsonUtils.Serialize(applicationsData); }