Exemplo n.º 1
0
        /// <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);
 }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 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);
 }