Example #1
0
        private ApplicationManagementClient GetApplicationManagementService()
        {
            var client = new ApplicationManagementClient(
                CreateDefaultBinding(),
                new EndpointAddress(ApplicationManagementUrl));

            return(client);
        }
Example #2
0
        private static List <ApplicationFolder> GetSubFolders(ApplicationManagementClient proxy, int?parentId)
        {
            var folders = proxy.GetApplicationFolders(parentId).ToList();

            foreach (var folder in folders.ToArray())
            {
                var subFolders = GetSubFolders(proxy, folder.ApplicationFolderId);
                folders.AddRange(subFolders);
            }
            return(folders);
        }
Example #3
0
        private static List <Application> GetAllApplications(ApplicationManagementClient proxy)
        {
            var folders      = GetSubFolders(proxy, null);
            var applications = new List <Application>();

            foreach (var folder in folders)
            {
                var apps = proxy.GetApplications(folder.ApplicationFolderId).ToList();
                applications.AddRange(apps);
            }
            return(applications);
        }
Example #4
0
        private InstallHeader CreateInstall(ApplicationManagementClient proxy, Application app)
        {
            using (var fileStream = new FileStream(InstallFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var install = new NewInstall
                {
                    ApplicationId               = app.ApplicationId,
                    CreatedByUserName           = Environment.UserName,
                    Version                     = Version,
                    InstallFileName             = Path.GetFileName(InstallFilePath),
                    InstallCommandLine          = InstallCommandLine,
                    ShouldRemovePreviousVersion = ShouldRemovePreviousVersion
                };
                var i = proxy.CreateInstall(install, fileStream);

                LogMessage(MessageImportance.Low, String.Format("Created new install id = {0}", i.InstallId));

                return(i);
            }
        }
Example #5
0
        private Application FindOrCreateApplication(ApplicationManagementClient proxy)
        {
            var applications = GetAllApplications(proxy);

            if (InstallFilePath.ToUpperInvariant().EndsWith(".MSI"))
            {
                var info = SimpleMsiReader.GetMsiInfo(InstallFilePath);
                Version = info.ProductVersion;
                if (string.IsNullOrEmpty(InstallCommandLine))
                {
                    InstallCommandLine = String.Format("/i \"{0}\" /qn", Path.GetFileName(InstallFilePath));
                }
                var app = applications.SingleOrDefault(p => p.ProductCode == info.ProductCode);
                if (app == null)
                {
                    app = proxy.CreateApplication(
                        new NewApplication
                    {
                        ApplicationFolderId         = 1,
                        ApplicationFormalName       = info.ProductName,
                        ProductCode                 = info.ProductCode,
                        CreatedByUserName           = Environment.UserName,
                        CustomDeviceHandlerModuleId = 4
                    });

                    LogMessage(MessageImportance.Low,
                               String.Format("Created new application '{0} ({1})' already exists", info.ProductName,
                                             info.ProductCode));
                }
                else
                {
                    LogMessage(MessageImportance.Low,
                               String.Format("Application '{0} ({1})' already exists", info.ProductName,
                                             info.ProductCode));
                }
                return(app);
            }

            if (InstallFilePath.ToUpperInvariant().EndsWith(".CAB"))
            {
                var name = GetApplicationNameFromCabFile(InstallFilePath);

                var app = applications.SingleOrDefault(p => p.ApplicationFormalName == name);
                if (app == null)
                {
                    app = proxy.CreateApplication(
                        new NewApplication
                    {
                        ApplicationFolderId         = 1,
                        ApplicationFormalName       = name,
                        CreatedByUserName           = Environment.UserName,
                        CustomDeviceHandlerModuleId = 3
                    });

                    LogMessage(MessageImportance.Low, String.Format("Created new application '{0}'", name));
                }
                else
                {
                    LogMessage(MessageImportance.Low, String.Format("Application '{0}' already exists", name));
                }
                return(app);
            }

            throw new NotImplementedException("Only CAB and MSI files are supported");
        }
        private ApplicationManagementClient GetApplicationManagementService()
        {
            var client = new ApplicationManagementClient(
                CreateDefaultBinding(),
                new EndpointAddress(ApplicationManagementUrl));

            return client;
        }
        private Application FindOrCreateApplication(ApplicationManagementClient proxy)
        {
            var applications = GetAllApplications(proxy);

            if (InstallFilePath.ToUpperInvariant().EndsWith(".MSI"))
            {
                var info = SimpleMsiReader.GetMsiInfo(InstallFilePath);
                Version = info.ProductVersion;
                if (string.IsNullOrEmpty(InstallCommandLine))
                {
                    InstallCommandLine = String.Format("/i \"{0}\" /qn", Path.GetFileName(InstallFilePath));
                }
                var app = applications.SingleOrDefault(p => p.ProductCode == info.ProductCode);
                if (app == null)
                {
                    app = proxy.CreateApplication(
                        new NewApplication
                            {
                                ApplicationFolderId = 1,
                                ApplicationFormalName = info.ProductName,
                                ProductCode = info.ProductCode,
                                CreatedByUserName = Environment.UserName,
                                CustomDeviceHandlerModuleId = 4
                            });

                    LogMessage(MessageImportance.Low,
                               String.Format("Created new application '{0} ({1})' already exists", info.ProductName,
                                             info.ProductCode));
                }
                else
                {
                    LogMessage(MessageImportance.Low,
                               String.Format("Application '{0} ({1})' already exists", info.ProductName,
                                             info.ProductCode));
                }
                return app;
            }

            if (InstallFilePath.ToUpperInvariant().EndsWith(".CAB"))
            {
                var name = GetApplicationNameFromCabFile(InstallFilePath);

                var app = applications.SingleOrDefault(p => p.ApplicationFormalName == name);
                if (app == null)
                {
                    app = proxy.CreateApplication(
                        new NewApplication
                            {
                                ApplicationFolderId = 1,
                                ApplicationFormalName = name,
                                CreatedByUserName = Environment.UserName,
                                CustomDeviceHandlerModuleId = 3
                            });

                    LogMessage(MessageImportance.Low, String.Format("Created new application '{0}'", name));
                }
                else
                {
                    LogMessage(MessageImportance.Low, String.Format("Application '{0}' already exists", name));
                }
                return app;
            }

            throw new NotImplementedException("Only CAB and MSI files are supported");
        }
        private InstallHeader CreateInstall(ApplicationManagementClient proxy, Application app)
        {
            using (var fileStream = new FileStream(InstallFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var install = new NewInstall
                                  {
                                      ApplicationId = app.ApplicationId,
                                      CreatedByUserName = Environment.UserName,
                                      Version = Version,
                                      InstallFileName = Path.GetFileName(InstallFilePath),
                                      InstallCommandLine = InstallCommandLine,
                                      ShouldRemovePreviousVersion = ShouldRemovePreviousVersion
                                  };
                var i = proxy.CreateInstall(install, fileStream);

                LogMessage(MessageImportance.Low, String.Format("Created new install id = {0}", i.InstallId));

                return i;
            }
        }
 private static List<ApplicationFolder> GetSubFolders(ApplicationManagementClient proxy, int? parentId)
 {
     var folders = proxy.GetApplicationFolders(parentId).ToList();
     foreach (var folder in folders.ToArray())
     {
         var subFolders = GetSubFolders(proxy, folder.ApplicationFolderId);
         folders.AddRange(subFolders);
     }
     return folders;
 }
 private static List<Application> GetAllApplications(ApplicationManagementClient proxy)
 {
     var folders = GetSubFolders(proxy, null);
     var applications = new List<Application>();
     foreach (var folder in folders)
     {
         var apps = proxy.GetApplications(folder.ApplicationFolderId).ToList();
         applications.AddRange(apps);
     }
     return applications;
 }