Ejemplo n.º 1
0
        public static void ExportToExcel(Sql sql)
        {
            var exportFileName = Web.PageFileNameNoExtn;

            if (exportFileName.IsBlank())
            {
                exportFileName = "Export-" + Fmt.DateTimeCompressed(DateTime.Now);
            }
            exportFileName += ".xls";
            ExportToExcel(sql, exportFileName);
        }
Ejemplo n.º 2
0
    private string GetDBCreateScript(string serverName)
    {
        string result = @"
CREATE DATABASE [thatcher].[NewProj] 
GO
USE [thatcher].[NewProj]
GO
IF NOT EXISTS (SELECT name FROM [thatcher].sys.filegroups WHERE is_default=1 AND name = N'PRIMARY') ALTER DATABASE [thatcher].[NewProj] MODIFY FILEGROUP [PRIMARY] DEFAULT
GO


--user create
USE [thatcher].[master]
GO
CREATE LOGIN [NewProj_user] WITH PASSWORD=N'**PWD**', DEFAULT_DATABASE=[NewProj], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
USE [thatcher].[NewProj]
GO
CREATE USER [NewProj_user] FOR LOGIN [NewProj_user]
GO
EXEC sp_addrolemember N'db_datareader', N'NewProj_user'
GO
EXEC sp_addrolemember N'db_datawriter', N'NewProj_user'
GO
EXEC sp_addrolemember N'db_owner', N'NewProj_user'
GO
		"        ;

        result = result.Replace("NewProj", Request["projname"]);
        result = result.Replace("**PWD**", pwd);
        if (serverName + "" != "")
        {
            result = result.Replace("[thatcher]", "[" + serverName + "]");
        }
        else
        {
            // no server, remove references to thatcher
            result = result.Replace("[thatcher].", "");
        }
        //FileSystem.CreateFolder("~/_beweb");
        FileSystem.WriteTextFile("~/_beweb/create_db_script_" + Fmt.DateTimeCompressed(DateTime.Now) + ".sql", result);
        return(result);
    }
Ejemplo n.º 3
0
 private void ReplaceSampleSitenameInConfig(string filename, string sitename, string subpath, string theme)
 {
     if (File.Exists(filename))
     {
         string origText        = FileSystem.GetFileContents(filename, false);
         string appsettingsFile = origText;
         //Web.Write(appsettingsFile.FmtPlainTextAsHtml());
         //sitename.beweb.co.nz
         //sitename.co.nz
         //<add key="SiteName" value="sitename"/>
         //[email protected]
         //staging.beweb.co.nz
         //www.sitename.co.nz
         appsettingsFile = appsettingsFile.Replace("clientname/sitename", subpath);
         appsettingsFile = appsettingsFile.Replace("sitename", sitename.ToLower());              // this should correctly do the same as the below (given Replace is case sensitive)
         //appsettingsFile = appsettingsFile.Replace("<add key=\"SiteName\" value=\"sitename\"/>", "<add key=\"SiteName\" value=\"" + sitename.SplitTitleCase() + "\"/>");
         //appsettingsFile = appsettingsFile.Replace("sitename.beweb.co.nz", "" + sitename.ToLower() + ".beweb.co.nz");
         //appsettingsFile = appsettingsFile.Replace("sitename.co.nz", "" + sitename.ToLower() + ".co.nz");
         //appsettingsFile = appsettingsFile.Replace("*****@*****.**", "website@" + sitename.ToLower() + ".co.nz");
         //appsettingsFile = appsettingsFile.Replace("sitename.beweb.co.nz", "" + sitename.ToLower() + ".beweb.co.nz");
         //appsettingsFile = appsettingsFile.Replace("www.sitename.co.nz", "www." + sitename.ToLower() + ".co.nz");
         appsettingsFile = appsettingsFile.Replace(@"key=""Theme"" value=""focus""", @"key=""Theme"" value=""blanktheme""");
         appsettingsFile = appsettingsFile.Replace("blanktheme", theme);
         appsettingsFile = appsettingsFile.Replace("--CryptKey--", RandomPassword.Generate(48, 48,
                                                                                           RandomPassword.PASSWORD_CHARS_LCASE,
                                                                                           RandomPassword.PASSWORD_CHARS_UCASE,
                                                                                           RandomPassword.PASSWORD_CHARS_NUMERIC,
                                                                                           RandomPassword.PASSWORD_CHARS_SPECIAL
                                                                                           )); //jdsjnkjksdioa89493920sdjkasn-1239mflmkkckd$%^*(
         appsettingsFile = appsettingsFile.Replace("BuildStartDate\" value=\"tbd", "BuildStartDate\" value=\"" + Fmt.DateTimeCompressed(DateTime.Now));
         if (appsettingsFile != origText)
         {
             File.WriteAllText(filename, appsettingsFile);
             Log("updated appsetting[" + filename + "] <br />");
         }
         else
         {
             Log("didnt update the appsettings [" + filename + "]<br />");
         }
     }
 }