コード例 #1
0
ファイル: DBUtility.aspx.cs プロジェクト: kenstammjr/SPA
        public bool DeployDataSystem()
        {
            bool success = false;

            string[] TableList = new string[]
            {
                "CREATE_TABLES_Core_v1_0_0",
                "CREATE_TABLES_KnowledgeBank_v1_0_0",
                "CREATE_TABLES_Menu_v1_0_0",
                "CREATE_TABLES_Monitoring_v1_0_0",
                "CREATE_TABLES_Projects_v1_0_0",
                "CREATE_TABLES_RedirectProvider_v1_0_0",
                "CREATE_TABLES_SharePoint_v1_0_0",
                "CREATE_TABLES_Training_v1_0_0",

                "DROP_FUNCTION_OrgUnitHasOrgGrpMappings",
                "DROP_PROC_UpdateApplicationDisplayIndex",
                "DROP_PROC_UpdateSlideNumber",
                "DROP_PROC_UpdateTabDisplayIndex",
                "DROP_VIEW_ServerCertificates",
                "DROP_VIEW_ServerContacts",
                "DROP_VIEW_ServerPorts",
                "DROP_VIEW_TrngRoleAssignments",

                "CREATE_FUNCTION_OrgUnitHasOrgGrpMappings",
                "CREATE_PROC_UpdateApplicationDisplayIndex",
                "CREATE_PROC_UpdateSlideNumber",
                "CREATE_PROC_UpdateTabDisplayIndex",
                "CREATE_VIEW_ServerCertificates",
                "CREATE_VIEW_ServerContacts",
                "CREATE_VIEW_ServerPorts",
                "CREATE_VIEW_TrngRoleAssignments"
            };
            string ErrorList = string.Empty;

            success = DataSystem.CreateDatabase();
            lblErrorMessage.Text += "DataSystem.CreateDatabase(): " + success.ToString();
            if (success)
            {
                foreach (string tbl in TableList)
                {
                    lblErrorMessage.Text += "tbl in TableList: " + tbl;
                    if (!ExecSqlFile(string.Format("{0}.{1}.sql", SQL_FILE_LOCATION, tbl)))
                    {
                        success    = false;
                        ErrorList += string.Format("\\t{0}\\n", tbl);
                    }
                }
                if (success)
                {
                    if (!Framework.UpdateVersion())
                    {
                        success    = false;
                        ErrorList += "\\Framework Version\\n";
                    }
                }
            }
            if (!success)
            {
                int Errors = ErrorList.Replace("\\n", "|").Split('|').Length;
                _ErrorMessage = string.Format("Database creation/update failed {0}: \\n\\n{1}\\nDelete any existing constraints for {2}\\nand run the configuration utility again.", Errors > 2 ? "tables" : "table", ErrorList, Errors > 2 ? "these tables" : "this table");
            }
            else
            {
                try {
                    //   SaveCurrentUser();
                } catch (Exception ex) {
                    SPA.Error.WriteError(ex);
                    if (SPFarm.Local.CurrentUserIsAdministrator())
                    {
                        lblErrorMessage.Visible = true;
                    }
                    lblErrorMessage.Text = ex.ToString();
                }
            }
            return(success);
        }