static void Main(string[] args) { try { string folderPath = "C:\\inetpub\\wwwroot\\TmsWS"; string applicationPath = "/TmsWS"; string applicationPoolName = "TmsWebService"; if (!FolderSecurityHelper.ExistFolderRights(folderPath)) { FolderSecurityHelper.SetFolderRights(folderPath); } if (!IISControlHelper.ExistApplicationPool(applicationPoolName)) { IISControlHelper.CreateApplicationPool(applicationPoolName); } if (!IISControlHelper.ExistApplication(applicationPath)) { IISControlHelper.CreateApplication(applicationPath, folderPath, applicationPoolName); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); } }
static void Main(string[] args) { Console.Title = "WebAPI Configuration"; string msg = ""; bool blnWait = true; int WaitTime = 0; try { //PrintLatticeChar("IIS"); //for (int i = 0; i < 15; i++) //{ // Console.WriteLine(); //} msg = "=============================================="; ConsoleColorWrite(msg, ConsoleColor.Green); msg = "== =="; ConsoleColorWrite(msg, ConsoleColor.Green); msg = "== Freight Mobile APP Server Side Installer =="; ConsoleColorWrite(msg, ConsoleColor.Green); msg = "== =="; ConsoleColorWrite(msg, ConsoleColor.Green); msg = "== Power By (C)2015 SysMagic. =="; ConsoleColorWrite(msg, ConsoleColor.Green); msg = "== =="; ConsoleColorWrite(msg, ConsoleColor.Green); msg = "=============================================="; ConsoleColorWrite(msg, ConsoleColor.Green); msg = "!! Note: Press Enter To Use Default Setting !!"; ConsoleColorWrite(msg, ConsoleColor.Yellow); msg = "Environment Ready,Press Any Key To Continue..."; ConsoleColorWrite(msg, ConsoleColor.Green); Console.ReadKey(); string folderPath = "C:\\inetpub\\wwwroot\\WebApi"; while (blnWait) { msg = "Enter Application Folder Path.\nDefault is 'C:\\inetpub\\wwwroot\\WebApi'"; ConsoleColorWrite(msg, ConsoleColor.Cyan); folderPath = ReadLineString(folderPath); if (Directory.Exists(folderPath)) { blnWait = false; if (!FolderSecurityHelper.ExistFolderRights(folderPath)) { FolderSecurityHelper.SetFolderRights(folderPath); } } else { WaitTime++; if (WaitTime > 3) { msg = "Failed To Many Times, Press Any Key To Close."; ConsoleColorWrite(msg, ConsoleColor.Red); Console.ReadLine(); return; } else { msg = "Application Folder Path '" + folderPath + "' Not Exist."; ConsoleColorWrite(msg, ConsoleColor.Red); } } } string applicationPoolName = "WebApiService"; blnWait = true; WaitTime = 0; while (blnWait) { msg = "Enter Application Pool Name.\nDefault is 'WebApiService'"; ConsoleColorWrite(msg, ConsoleColor.Cyan); applicationPoolName = ReadLineString(applicationPoolName); if (!IISControlHelper.ExistApplicationPool(applicationPoolName)) { blnWait = false; IISControlHelper.CreateApplicationPool(applicationPoolName); } else { WaitTime++; if (WaitTime > 3) { msg = "Failed To Many Times, Press Any Key To Close."; ConsoleColorWrite(msg, ConsoleColor.Red); Console.ReadLine(); return; } else { msg = "Application Pool Name '" + applicationPoolName + "' Already Exist."; ConsoleColorWrite(msg, ConsoleColor.Red); msg = "Enter 'Y' To Override Or 'S' To Skip This Step."; ConsoleColorWrite(msg, ConsoleColor.Cyan); string s = Console.ReadLine(); if (s.ToUpper() == 'Y'.ToString()) { blnWait = false; IISControlHelper.DeleteApplicationPool(applicationPoolName); IISControlHelper.CreateApplicationPool(applicationPoolName); } else if (s.ToUpper() == 'S'.ToString()) { blnWait = false; } } } } string applicationPath = "WebApi"; blnWait = true; WaitTime = 0; int siteIndex = 0; while (blnWait) { msg = "Enter Application Name.\nDefault is 'WebApi'"; ConsoleColorWrite(msg, ConsoleColor.Cyan); applicationPath = "/" + ReadLineString(applicationPath); ArrayList al = IISControlHelper.ListSites(); if (al.Count > 1) { msg = "Detect More then One WebSite, Enter The Number To Chose One."; ConsoleColorWrite(msg, ConsoleColor.Cyan); for (int i = 0; i < al.Count; i++) { msg = "( " + (i + 1).ToString() + " ) " + al[i].ToString(); ConsoleColorWrite(msg, ConsoleColor.White); } string s = Console.ReadLine(); siteIndex = int.Parse(s) - 1; } if (!IISControlHelper.ExistApplication(applicationPath, siteIndex)) { blnWait = false; IISControlHelper.CreateApplication(applicationPath, siteIndex, folderPath, applicationPoolName); } else { WaitTime++; if (WaitTime > 3) { msg = "Failed To Many Times, Press Any Key To Close."; ConsoleColorWrite(msg, ConsoleColor.Red); Console.ReadLine(); return; } else { msg = "Application Name '" + applicationPath + "' Already Exist."; ConsoleColorWrite(msg, ConsoleColor.Red); msg = "Enter 'Y' To Override Or 'S' To Skip This Step."; ConsoleColorWrite(msg, ConsoleColor.Cyan); string s = Console.ReadLine(); if (s.ToUpper() == 'Y'.ToString()) { blnWait = false; IISControlHelper.DeleteApplication(applicationPath, siteIndex); IISControlHelper.CreateApplication(applicationPath, siteIndex, folderPath, applicationPoolName); } else if (s.ToUpper() == 'S'.ToString()) { blnWait = false; } } } } msg = "Install Success! Press Any Key To Continue..."; ConsoleColorWrite(msg, ConsoleColor.Green); Console.ReadLine(); return; } catch (Exception ex) { ConsoleColorWrite(ex.Message, ConsoleColor.Red); Console.ReadLine(); } }