Example #1
0
        private static void ParseArg(SiteData data, string arg)
        {
            string[] argParts = arg.Split('=');
            if (argParts.Length < 2) return;

            switch(argParts[0].Trim().ToLowerInvariant())
            {
                case "-path":
                    data.Location = argParts[1];
                    break;
                case "-sqlserver":
                    data.SQLServer = argParts[1];
                    break;
                case "-sqldatabase":
                    data.SQLDatabase = argParts[1];
                    break;
                case "-sqluser":
                    data.SQLUsername = argParts[1];
                    break;
                case "-sqlpassword":
                    data.SQLPassword = argParts[1];
                    break;
                case "-url":
                    data.WebSiteAddress = argParts[1];
                    break;
                case "-debug":
                    data.ForceDebug = true;
                    break;
            }
        }
 public void CreateStore(SiteData data)
 {
     this.InstallWorked = false;
     localData = data;
     this.OutputField.Text = string.Empty;
     this.backgroundWorker1.RunWorkerAsync(data);
 }
Example #3
0
        public bool CreateSite(SiteData data)
        {
            // Make sure data isn't null
            if (data == null)
            {
                wl("Site data was missing");
                return(false);
            }

            wl("Starting install at " + DateTime.Now.ToString());
            wl("=================================================");

            // Create Local Path
            if (!CreateLocalPath(data.Location))
            {
                return(false);
            }

            wl("-------------------------------------------------");

            // Copy Files to Path

            // - Start File Copy Code
            if (data.InstallSourceCode)
            {
                FileCopyNoBackup(data.SourceFolder, data.Location);
            }
            // End File Copy Code

            wl("-------------------------------------------------");

            wl("Updating web.config file...");
            UpdateWebConfig(data);
            wl("-------------------------------------------------");

            //System.Threading.Thread.Sleep(500);
            wl("Files Installed");
            wl("=================================================");
            wl("");
            wl("What's Next?");
            wl("-------------------------------------------------");
            wl("1) Create an Empty Database in SQL Server");
            wl("2) Run the 3 SQL Scripts in Order ");
            wl("3) Create an IIS Web Application");
            wl("4) Open the web site in a browser");
            wl("");
            wl("Instructions.RTF file has more details");
            wl("");

            return(true);
        }
Example #4
0
        public bool CreateSite(SiteData data)
        {
            // Make sure data isn't null
            if (data == null)
            {
                wl("Site data was missing");
                return false;
            }

            wl("Starting install at " + DateTime.Now.ToString());
            wl("=================================================");

            // Create Local Path
            if (!CreateLocalPath(data.Location)) return false;

            wl("-------------------------------------------------");

            // Copy Files to Path

            // - Start File Copy Code
            if (data.InstallSourceCode)
            {
                FileCopyNoBackup(data.SourceFolder, data.Location);
            }
            // End File Copy Code

            wl("-------------------------------------------------");

            wl("Updating web.config file...");
            UpdateWebConfig(data);
            wl("-------------------------------------------------");

            //System.Threading.Thread.Sleep(500);
            wl("Files Installed");
            wl("=================================================");
            wl("");
            wl("What's Next?");
            wl("-------------------------------------------------");
            wl("1) Create an Empty Database in SQL Server");
            wl("2) Run the 3 SQL Scripts in Order ");
            wl("3) Create an IIS Web Application");
            wl("4) Open the web site in a browser");
            wl("");
            wl("Instructions.RTF file has more details");
            wl("");
            
            return true;
        }
Example #5
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
                        
            SiteData storeData = new SiteData();
            storeData.Location = this.LocalFilePath.Text.Trim();
            storeData.SQLServer = this.SQLServerField.Text.Trim();
            storeData.SQLDatabase = this.SQLDatabaseField.Text.Trim();
            storeData.SQLUsername = this.SQLUsernameField.Text.Trim();
            storeData.SQLPassword = this.SQLPasswordField.Text.Trim();
            storeData.SourceFolder = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\src\\";

            storeData.WebSiteAddress = this.WebSiteAddressField.Text.Trim();
            storeData.PrepArgs();
            
            storeData.InstallSourceCode = true;

            CreateSiteWorker worker = new CreateSiteWorker();
            worker.Show();
            worker.Focus();
            worker.CreateStore(storeData);

            this.Dispose();
        }
Example #6
0
        static void Main(string[] args)
        {
            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            Console.WriteLine("Create MT Store | " + version);
            Console.WriteLine();

            if (args.Length < 6)
            {
                ShowHelp();
                return;
            }

            Console.WriteLine("Parsing Arguments");

            SiteData data = new SiteData();
            data.InstallSourceCode = true;            
            data.SourceFolder = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\src\\";
            
            foreach (string arg in args)
            {
                ParseArg(data, arg);
            }

            data.PrepArgs();
            
            SiteBuilder builder = new SiteBuilder();
            builder.ProgressReport += new SiteBuilder.ProgressReportDelegate(builder_ProgressReport);

            if (builder.CreateSite(data))
            {
                Console.WriteLine("Create store SUCCESS!");
            }
            else
            {
                Console.WriteLine("Create store FAILED!");
            }
        }
Example #7
0
        private bool UpdateWebConfig(SiteData data)
        {
            bool result = false;

            try
            {
                string configFile = Path.Combine(data.Location, "MerchantTribeStore\\web.config");
                if (data.InstallSourceCode == false)
                {
                    configFile = Path.Combine(data.Location, "web.config");
                }

                if (File.Exists(configFile))
                {
                    FileInfo     writerInfo = this.GetTemporaryFileInfo();
                    StreamWriter writer     = new StreamWriter(writerInfo.OpenWrite());

                    using (StreamReader reader = File.OpenText(configFile))
                    {
                        string line = reader.ReadLine();

                        while (line != null)
                        {
                            bool foundReplacement = false;

                            // Connection Strings
                            if (line.Trim().StartsWith("<add name=\"commerce6ConnectionString\""))
                            {
                                wl("Found Match for Connection 1");
                                writer.WriteLine("<add name=\"commerce6ConnectionString\" connectionString=\"" + data.ConnectionString() + "\"/>");
                                foundReplacement = true;
                            }

                            if (TrySettingReplace(writer, line,
                                                  "BaseApplicationUrl", data.WebSiteAddress))
                            {
                                foundReplacement = true;
                            }


                            if (data.ForceDebug)
                            {
                                string _CompileMatch   = "<compilation debug=\"false\" targetFramework=\"4.0\">";
                                string _CompileReplace = "<compilation debug=\"true\" targetFramework=\"4.0\">";
                                if (line.Trim().StartsWith(_CompileMatch))
                                {
                                    wl("Found Match for Debug Switch");
                                    writer.WriteLine(_CompileReplace);
                                    foundReplacement = true;
                                }
                            }

                            // Write the default line if we didn't match
                            if (foundReplacement == false)
                            {
                                writer.WriteLine(line);
                            }

                            line = reader.ReadLine();
                        }
                    }

                    writer.Close();
                    File.Copy(writerInfo.FullName, configFile, true);

                    result = true;
                }
            }
            catch (Exception ex)
            {
                wl(ex.Message);
            }

            return(result);
        }
Example #8
0
        private bool UpdateWebConfig(SiteData data)
        {
            bool result = false;
            try
            {

                string configFile = Path.Combine(data.Location, "MerchantTribeStore\\web.config");
                if (data.InstallSourceCode == false)
                {
                    configFile = Path.Combine(data.Location, "web.config");
                }

                if (File.Exists(configFile))
                {

                    FileInfo writerInfo = this.GetTemporaryFileInfo();
                    StreamWriter writer = new StreamWriter(writerInfo.OpenWrite());

                    using (StreamReader reader = File.OpenText(configFile))
                    {
                        string line = reader.ReadLine();

                        while (line != null)
                        {
                            bool foundReplacement = false;

                            // Connection Strings
                            if (line.Trim().StartsWith("<add name=\"commerce6ConnectionString\""))
                            {
                                wl("Found Match for Connection 1");
                                writer.WriteLine("<add name=\"commerce6ConnectionString\" connectionString=\"" + data.ConnectionString() + "\"/>");
                                foundReplacement = true;
                            }

                            if (TrySettingReplace(writer, line,
                               "BaseApplicationUrl", data.WebSiteAddress)) foundReplacement = true;


                            if (data.ForceDebug)
                            {                                
                                string _CompileMatch = "<compilation debug=\"false\" targetFramework=\"4.0\">";
                                string _CompileReplace = "<compilation debug=\"true\" targetFramework=\"4.0\">";
                                if (line.Trim().StartsWith(_CompileMatch))
                                {
                                    wl("Found Match for Debug Switch");
                                    writer.WriteLine(_CompileReplace);
                                    foundReplacement = true;
                                }        
                            }

                            // Write the default line if we didn't match
                            if (foundReplacement == false)
                            {
                                writer.WriteLine(line);
                            }

                            line = reader.ReadLine();
                        }
                    }

                    writer.Close();
                    File.Copy(writerInfo.FullName, configFile, true);

                    result = true;
                }

            }
            catch (Exception ex)
            {
                wl(ex.Message);
            }

            return result;
        }