Example #1
0
        public bool InstallParamaetersValidation(IDPSetup iDPSetup)
        {
            var result = true;

            result = ParamaetersValidation(iDPSetup);

            if (!string.IsNullOrEmpty(iDPSetup.DomainName))
            {
                if (webDeployHelper.ExistVirtualDirectoryV2(iDPSetup.DomainName, iDPSetup.IDPFolderName))
                {
                    result = false;
                    Console.Error.WriteLine("IDPFolderName directory already exists !!!");
                }

                if (webDeployHelper.ExistVirtualDirectoryV2(iDPSetup.DomainName, iDPSetup.AdminFolderName))
                {
                    result = false;
                    Console.Error.WriteLine("AdminFolderName directory already exists !!!");
                }
            }

            if (Directory.Exists(GetRealFileAddress(iDPSetup.IDPPath, iDPSetup.IDPFolderName)))
            {
                result = false;
                Console.WriteLine("IDPFolderName folder already exists !!!");
            }

            if (Directory.Exists(GetRealFileAddress(iDPSetup.AdminPath, iDPSetup.AdminFolderName)))
            {
                result = false;
                Console.Error.WriteLine("AdminFolderName folder already exists !!!");
            }
            return(result);
        }
Example #2
0
        private void SaveSetupRegistry(
            IDPSetup idpSetup, Manifest manifest)
        {
            var setupPath = new InstallPathInfo
            {
                PackageId = manifest.PackageId,
                IISName   = idpSetup.IDPFolderName
            };

            setupPath.Meta.Add("DomainName", idpSetup.DomainName);
            setupPath.Meta.Add("IDPFolderName", idpSetup.IDPFolderName);
            setupPath.Meta.Add("IDPPath", idpSetup.IDPPath);
            setupPath.Meta.Add("AdminFolderName", idpSetup.AdminFolderName);
            setupPath.Meta.Add("AdminPath", idpSetup.AdminPath);
            setupPath.Meta.Add("IDPAddress", idpSetup.IDPAddress);
            setupPath.Meta.Add("catalog", idpSetup.CatalogName);
            setupPath.Meta.Add("databasename", idpSetup.DatabaseName);
            setupPath.Meta.Add("username", idpSetup.Username);
            //setupPath.Meta.Add("password", idpSetup.Password);
            setupPath.Meta.Add("servername", idpSetup.Servername);

            //setupPath.Meta.Add("ApplicationName", virtualDir.Name);
            //setupPath.Meta.Add("ApplicationPath", virtualDir.Path);
            //setupPath.Meta.Add("ApplicationNameAdmin", adminSiteName);
            //setupPath.Meta.Add("ApplicationPathAdmin", adminPath);
            //setupPath.Meta.Add("PhysicalPathAdmin", realFileAddressadmin);
            setupRegistry.Add(manifest, setupPath);
            setupRegistry.Commit();
        }
        private IDPSetup IDPSetupMapper(InstallPathInfo installPathInfo)
        {
            var idpSetup = new IDPSetup();

            idpSetup.DomainName      = installPathInfo.Meta["DomainName"];
            idpSetup.IDPPath         = installPathInfo.Meta["IDPPath"];
            idpSetup.IDPFolderName   = installPathInfo.Meta["IDPFolderName"];
            idpSetup.AdminFolderName = installPathInfo.Meta["AdminFolderName"];
            idpSetup.AdminPath       = installPathInfo.Meta["AdminPath"];
            idpSetup.IDPAddress      = installPathInfo.Meta["IDPAddress"];
            idpSetup.Servername      = installPathInfo.Meta["servername"];
            idpSetup.DatabaseName    = installPathInfo.Meta["databasename"];
            idpSetup.CatalogName     = installPathInfo.Meta["catalog"];
            idpSetup.Username        = installPathInfo.Meta["username"];

            return(idpSetup);
        }
Example #4
0
        public async Task <bool> CommandLineDelete(string jsonConfig)
        {
            var result = SimpleJSON.JSON.Parse(jsonConfig);

            var idpSetup = new IDPSetup
            {
                DomainName      = result["DomainName"].Value,
                IDPFolderName   = result["IDPSiteName"].Value,
                IDPPath         = result["IDPSitePath"].Value,
                AdminPath       = result["AdminSitePath"].Value,
                AdminFolderName = result["AdminSiteName"].Value?.ToString().ToLower(),
                IDPAddress      = result["IDPServerAddress"],
                DatabaseName    = result["DbName"].Value,
                Password        = result["DbPassword"].Value,
                Servername      = result["DbServername"].Value,
                Username        = result["DbUsername"].Value,
                CatalogName     = result["DbCatalogName"].Value,
            };

            if (ParamaetersValidation(idpSetup))
            {
                Console.WriteLine("Deleting Start");
                try
                {
                    setupServices.Delete(idpSetup, Guid.Empty, CommandTypeEnum.Cli);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + " / " + ex.StackTrace);
                    return(await Task.FromResult(false));
                }
                return(await Task.FromResult(true));
            }

            return(await Task.FromResult(false));
        }
Example #5
0
        public bool ParamaetersValidation(IDPSetup iDPSetup)
        {
            var result = true;

            if (string.IsNullOrEmpty(iDPSetup.DomainName))
            {
                result = false;
                Console.Error.WriteLine("DomainName is require !!!");
            }
            if (string.IsNullOrEmpty(iDPSetup.IDPAddress))
            {
                result = false;
                Console.Error.WriteLine("IDPAddress is require !!!");
            }
            else
            {
                if (iDPSetup.IDPAddress.Length > 64)
                {
                    result = false;
                    Console.Error.WriteLine("IDPAddress cannot be more than 64 characters !!!");
                }
            }

            if (string.IsNullOrEmpty(iDPSetup.IDPPath))
            {
                result = false;
                Console.Error.WriteLine("IDPPath is require !!!");
            }
            else
            {
                if (Path.IsPathRooted(iDPSetup.IDPPath))
                {
                    string idpPath = Path.GetPathRoot(iDPSetup.IDPPath);
                    if (!Directory.Exists(idpPath))
                    {
                        result = false;
                        Console.Error.WriteLine("IDPPath does not exist !!!");
                    }
                }
                else
                {
                    result = false;
                    Console.Error.WriteLine("IDPPath is not valid !!!");
                }
            }


            if (string.IsNullOrEmpty(iDPSetup.AdminFolderName))
            {
                result = false;
                Console.Error.WriteLine("AdminFolderName is require !!!");
            }
            else
            {
                if (iDPSetup.AdminFolderName.Length > 64)
                {
                    result = false;
                    Console.Error.WriteLine("AdminFolderName cannot be more than 64 characters !!!");
                }
            }

            if (string.IsNullOrEmpty(iDPSetup.AdminPath))
            {
                result = false;
                Console.Error.WriteLine("AdminPath is require !!!");
            }
            else
            {
                if (Path.IsPathRooted(iDPSetup.AdminPath))
                {
                    string adminPath = Path.GetPathRoot(iDPSetup.AdminPath);
                    if (!Directory.Exists(adminPath))
                    {
                        result = false;
                        Console.Error.WriteLine("AdminPath does not exist !!!");
                    }
                }
                else
                {
                    result = false;
                    Console.Error.WriteLine("AdminPath is not valid !!!");
                }
            }

            if (string.IsNullOrEmpty(iDPSetup.IDPAddress))
            {
                result = false;
                Console.Error.WriteLine("IDPAddress is require !!!");
            }

            if (string.IsNullOrEmpty(iDPSetup.CatalogName))
            {
                result = false;
                Console.Error.WriteLine("Catalog name is require !!!");
            }

            if (string.IsNullOrEmpty(iDPSetup.Username))
            {
                result = false;
                Console.Error.WriteLine("Username is require !!!");
            }

            if (string.IsNullOrEmpty(iDPSetup.Password))
            {
                result = false;
                Console.Error.WriteLine("Password is require !!!");
            }

            if (string.IsNullOrEmpty(iDPSetup.DatabaseName))
            {
                result = false;
                Console.Error.WriteLine("Database name is require !!!");
            }

            if (string.IsNullOrEmpty(iDPSetup.Servername))
            {
                result = false;
                Console.Error.WriteLine("DbServer address is require !!!");
            }

            if (iDPSetup.IDPFolderName == iDPSetup.AdminFolderName)
            {
                result = false;
                Console.Error.WriteLine("IDPFolderName could not equal to AdminFolderName !!!");
            }

            if (!ValidateConnection(iDPSetup.Servername, iDPSetup.DatabaseName, iDPSetup.Username, iDPSetup.Password))
            {
                result = false;
                Console.Error.WriteLine("Database connection string error !!!");
            }

            return(result);
        }
Example #6
0
        public void Update(IDPSetup setupConfig, Guid packageId, CommandTypeEnum commandType)
        {
            var realFileAddress  = GetRealFileAddress(setupConfig.IDPPath, setupConfig.IDPFolderName);
            var realAdminAddress = GetRealFileAddress(setupConfig.AdminPath, setupConfig.AdminFolderName);

            //DeleteVirtualDirectories(realFileAddress, realAdminAddress);
            DeleteFiles(realFileAddress, realAdminAddress);
            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke(" بروزرسانی تنظیمات مربوط به AppSettings");
            }
            else
            {
                onStateChanged?.Invoke("Appsetting configuration...");
            }

            PopulateJsonConfiguration(setupConfig.CatalogName);
            PopulateAdminJsonConfiguration(setupConfig.CatalogName, setupConfig.IDPFolderName, setupConfig.IDPAddress);
            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke("بروزرسانی فایل ها");
            }
            else
            {
                onStateChanged?.Invoke("Update files...");
            }
            CopyFile(realFileAddress);
            CopyAdminFile(realAdminAddress);
            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke("بروزرسانی تنظیمات پنل ادمین");
            }
            else
            {
                onStateChanged?.Invoke("Update admin panel configuration...");
            }

            // populate html
            PopulateHtmlIndex(realAdminAddress, setupConfig.AdminFolderName);

            //Set Settings
            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke("بروزرسانی تنظیمات دیتابیس");
            }
            else
            {
                onStateChanged?.Invoke("Update databse configuration...");
            }


            //var fileAddress = GetRealFileAddress(_userControl.txtFileAddress.Text, _userControl.txtIISName.Text);
            SetSiteConnection(
                realFileAddress,
                setupConfig.DatabaseName,
                setupConfig.Password,
                setupConfig.Servername,
                setupConfig.Username,
                setupConfig.CatalogName
                );

            SetSiteConnection(
                realAdminAddress,
                setupConfig.DatabaseName,
                setupConfig.Password,
                setupConfig.Servername,
                setupConfig.Username,
                setupConfig.CatalogName
                );
            InstallPathInfo installPathInfo = null;

            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke(" بروزرسانی تنظیمات در رجیستری");
            }
            else
            {
                onStateChanged?.Invoke("Update registry configuration...");
            }
            var manifest = packageResolver.GetPackage();

            if (packageId != Guid.Empty)
            {
                installPathInfo = setupRegistry[packageId];
            }
            else
            {
                installPathInfo = setupRegistry.GetInstallPathByIISName(setupConfig.IDPFolderName);
            }
            if (installPathInfo != null)
            {
                setupRegistry.Remove(manifest, installPathInfo);
                SaveSetupRegistry(setupConfig, manifest);
            }
            if (commandType == CommandTypeEnum.Gui)
            {
                OnComleted("عملیات بروزرسانی نسخه مورد نظر با موفقیت پایان پذیرفت");
            }
            else
            {
                onStateChanged?.Invoke("Goodluck...");
            }
        }
Example #7
0
        public void Install(IDPSetup setupConfig, CommandTypeEnum commandType)
        {
            var manifest = packageResolver.GetPackage();

            var realFileAddress  = GetRealFileAddress(setupConfig.IDPPath, setupConfig.IDPFolderName);
            var realAdminAddress = GetRealFileAddress(setupConfig.AdminPath, setupConfig.AdminFolderName);

            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke(" ذخیره تنظیمات مربوط به AppSettings");
            }
            else
            {
                onStateChanged?.Invoke("Appsetting proccessing.");
            }

            PopulateJsonConfiguration(setupConfig.CatalogName);
            PopulateAdminJsonConfiguration(setupConfig.CatalogName, setupConfig.IDPFolderName, setupConfig.IDPAddress);


            //Install Programs
            //OnSubStateChanged?.Invoke("نصب نرم افزارهای جانبی");
            //CheckDotNetCoreInstalled();//InstallApplications();

            // copying files
            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke("کپی فایل ها");
            }
            else
            {
                onStateChanged?.Invoke("Copy files...");
            }

            CopyFile(realFileAddress);
            CopyAdminFile(realAdminAddress);

            // populate html
            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke("ثبت تنظیمات پنل ادمین");
            }
            else
            {
                onStateChanged?.Invoke("Admin configuration...");
            }
            PopulateHtmlIndex(realAdminAddress, setupConfig.AdminFolderName);


            //Set Settings
            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke("ایجاد تنظیمات دیتابیس");
            }
            else
            {
                onStateChanged?.Invoke("Databse configuration...");
            }
            //var fileAddress = GetRealFileAddress(_userControl.txtFileAddress.Text, _userControl.txtIISName.Text);
            SetSiteConnection(
                realFileAddress,
                setupConfig.DatabaseName,
                setupConfig.Password,
                setupConfig.Servername,
                setupConfig.Username,
                setupConfig.CatalogName
                );

            SetSiteConnection(
                realAdminAddress,
                setupConfig.DatabaseName,
                setupConfig.Password,
                setupConfig.Servername,
                setupConfig.Username,
                setupConfig.CatalogName
                );


            StopIIS();
            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke("ساخت دایرکتوری ها");
            }
            else
            {
                onStateChanged?.Invoke("Virtualdirectory configuration");
            }
            // create application pool and app in iis
            var virtualDir = MakeVirtualDirectoryV2(setupConfig.DomainName, setupConfig.IDPFolderName, realFileAddress);
            // MakeWebSite(setupConfig.AdminFolderName, realAdminAddress, setupConfig.AdminPort);
            var adminVirtualDir = MakeVirtualDirectoryV2(setupConfig.DomainName, setupConfig.AdminFolderName, realAdminAddress);

            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke(" ذخیره تنظیمات در رجیستری");
            }
            else
            {
                onStateChanged?.Invoke("Registry configuration");
            }

            SaveSetupRegistry(setupConfig, manifest);
            //SaveAdminSetupRegistry(setupConfig.AdminFolderName, setupConfig.AdminPath, realAdminAddress);

            StartIIS();

            if (commandType == CommandTypeEnum.Gui)
            {
                OnComleted(" عملیات نصب نسخه مورد نظر با موفقیت پایان پذیرفت");
            }
            else
            {
                OnComleted("Goodluck!");
            }
            //await Task.FromResult(true);
        }
Example #8
0
        public void Delete(IDPSetup setupConfig, Guid packageId, CommandTypeEnum commandType)
        {
            var realFileAddress  = GetRealFileAddress(setupConfig.IDPPath, setupConfig.IDPFolderName);
            var realAdminAddress = GetRealFileAddress(setupConfig.AdminPath, setupConfig.AdminFolderName);

            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke("حذف دایرکتوری ها");
            }
            else
            {
                onStateChanged?.Invoke("Remove directories...");
            }
            StopIIS();


            DeleteVirtualDirectoriesV2(setupConfig.IDPFolderName, setupConfig.DomainName);
            DeleteVirtualDirectoriesV2(setupConfig.AdminFolderName, setupConfig.DomainName);
            DeleteApplicationPools(setupConfig.IDPFolderName, setupConfig.AdminFolderName);


            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke("حذف فایل ها");
            }
            else
            {
                onStateChanged?.Invoke("Remove files...");
            }

            DeleteFiles(realFileAddress, realAdminAddress);
            if (commandType == CommandTypeEnum.Gui)
            {
                onStateChanged?.Invoke(" ذخیره تنظیمات در رجیستری");
            }
            else
            {
                onStateChanged?.Invoke("Registry configuration...");
            }
            var             manifest        = packageResolver.GetPackage();
            InstallPathInfo installPathInfo = null;

            if (packageId != Guid.Empty)
            {
                installPathInfo = setupRegistry[packageId];
            }
            else
            {
                installPathInfo = setupRegistry.GetInstallPathByIISName(setupConfig.IDPFolderName);
            }

            if (installPathInfo != null)
            {
                setupRegistry.Remove(manifest, installPathInfo);
                setupRegistry.Commit();
            }

            StartIIS();
            if (commandType == CommandTypeEnum.Gui)
            {
                OnComleted("عملیات حذف نسخه مورد نظر با موفقیت پایان پذیرفت");
            }
            else
            {
                onStateChanged?.Invoke("Goodluck...");
            }
        }