private void btnCreateDatabase_Click(object sender, EventArgs e) { string edition = cbEdition.SelectedIndex == 0 ? "web" : "business"; int dbSize = 1; if (tbNewDatabase.Text.Length == 0) { MessageBox.Show(label1.Text, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); tbNewDatabase.Focus(); return; } string sizeofdb = Regex.Match(cbMaxDatabaseSize.SelectedItem.ToString(), "[0-9]*").Value; if (sizeofdb.Length == 0) { cbMaxDatabaseSize.Focus(); return; } dbSize = Convert.ToInt32(sizeofdb); try { TargetProcessor tp = new TargetProcessor(); _TargetServerInfo.TargetDatabase = tbNewDatabase.Text; if (tp.DoesDatabaseExist(_TargetServerInfo)) { MessageBox.Show(Properties.Resources.MessageDatabaseExists, Properties.Resources.DatabaseExists, MessageBoxButtons.OK, MessageBoxIcon.Warning); tbNewDatabase.Focus(); return; } tp.CreateDatabase(_TargetServerInfo, ((Collation)cbCollations.SelectedValue).Name, edition, dbSize, false); DatabaseName = "[" + tbNewDatabase.Text + "]"; DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(CommonFunc.GetLowestException(ex), Properties.Resources.ErrorCreatingDB, MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.Abort; } Close(); }
public static void Process() { TargetProcessor tp = new TargetProcessor(); AsyncUpdateStatus updateStatus = new AsyncUpdateStatus(TargetAsyncUpdateStatusHandler); string sqlToExecute = CommonFunc.GetTextFromFile(_FileToProcess); _OutputResultsDirectory = _OutputResultsFile.Substring(0, _OutputResultsFile.LastIndexOf('\\') + 1); TargetServerInfo tsi = new TargetServerInfo(); tsi.ServerInstance = _TargetServerName; tsi.TargetDatabase = _TargetDatabase; if (Regex.IsMatch(_TargetServerName, CommonFunc.GetAppSettingsStringValue("RegexSearchForAzureServer"), RegexOptions.IgnoreCase)) { tsi.ServerType = ServerTypes.SQLAzure; } else { tsi.ServerType = ServerTypes.SQLServer; } if (_bTargetConnectNTAuth == true) { // Use Windows authentication tsi.LoginSecure = true; } else { // Use SQL Server authentication tsi.LoginSecure = false; tsi.Login = _TargetUserName; tsi.Password = _TargetPassword; } //AsyncProcessingStatus.FinishedProcessingJobs = true; AsyncQueueBCPJob queueBCPJob = new AsyncQueueBCPJob(AsyncQueueJobHandler); tp.CreateDatabase(tsi, _Collation, _TargetEdition, _TargetDatabaseSize, _bDropExistingDatabase); tp.ExecuteSQLonTarget(tsi, updateStatus, queueBCPJob, sqlToExecute); }
/// <summary> /// Starts search with current settings. /// </summary> /// <param name="showResults">Shows results in the %Maintainer window if true.</param> /// <returns>Array of IssueRecords in case you wish to manually iterate over them and make custom report.</returns> public static IssueRecord[] StartSearch(bool showResults) { if (!ProjectSettings.Issues.lookInScenes && !ProjectSettings.Issues.lookInAssets && !ProjectSettings.Issues.lookInProjectSettings) { MaintainerWindow.ShowNotification("Nowhere to search!"); return(null); } if (ProjectSettings.Issues.lookInScenes) { if (!CSSceneTools.SaveCurrentModifiedScenes(false)) { Debug.Log(Maintainer.LogPrefix + "Issues search canceled by user!"); return(null); } } var issues = new List <IssueRecord>(); PrepareToBatchOperation(); try { var sw = Stopwatch.StartNew(); CSTraverseTools.ClearStats(); var targetAssets = TargetCollector.CollectTargetAssets(); /*foreach (var targetAsset in targetAssets) * { * Debug.Log(targetAsset.Path); * }*/ TargetProcessor.SetIssuesList(issues); TargetProcessor.ProcessTargetAssets(targetAssets); var traverseStats = CSTraverseTools.GetStats(); var checkedAssets = targetAssets.Length; sw.Stop(); if (!operationCanceled) { var result = string.Format(CultureInfo.InvariantCulture, Maintainer.LogPrefix + ModuleName + " found issues: {0}\n" + "Seconds: {1:0.000}; Assets: {2}; Game Objects: {3}; Components: {4}; Properties: {5}", issues.Count, sw.Elapsed.TotalSeconds, checkedAssets, traverseStats.gameObjectsTraversed, traverseStats.componentsTraversed, traverseStats.propertiesTraversed); Debug.Log(result); } else { Debug.Log(Maintainer.LogPrefix + "Search canceled by user!"); } SearchResultsStorage.IssuesSearchResults = issues.ToArray(); if (showResults) { MaintainerWindow.ShowIssues(); } } catch (Exception e) { Debug.LogError(Maintainer.LogPrefix + ModuleName + ": something went wrong :(\n" + e); } EditorUtility.ClearProgressBar(); return(issues.ToArray()); }
private void Awake() { Instance = this; targetProcessor = GetComponent <TargetProcessor>(); }
public static void Process() { TargetProcessor tp = new TargetProcessor(); AsyncUpdateStatus updateStatus = new AsyncUpdateStatus(TargetAsyncUpdateStatusHandler); string sqlToExecute = CommonFunc.GetTextFromFile(_FileToProcess); _OutputResultsDirectory = _OutputResultsFile.Substring(0, _OutputResultsFile.LastIndexOf('\\') + 1); TargetServerInfo tsi = new TargetServerInfo(); tsi.ServerInstance = _TargetServerName; tsi.TargetDatabase = _TargetDatabase; if (_bTargetConnectNTAuth == true) { // Use Windows authentication tsi.LoginSecure = true; } else { // Use SQL Server authentication tsi.LoginSecure = false; tsi.Login = _TargetUserName; tsi.Password = _TargetPassword; } tsi.Version = ""; try { Retry.ExecuteRetryAction(() => { using (SqlConnection con = new SqlConnection(tsi.ConnectionStringRootDatabase)) { ScalarResults sr = SqlHelper.ExecuteScalar(con, CommandType.Text, "SELECT @@VERSION"); string version = (string)sr.ExecuteScalarReturnValue; if (version.IndexOf("Azure") > 0) { tsi.ServerType = ServerTypes.AzureSQLDB; } else { tsi.ServerType = ServerTypes.SQLServer; } Match result = Regex.Match(version, @"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); if (result.Success) { tsi.Version = result.Value; } else { Console.WriteLine(CommonFunc.FormatString(Properties.Resources.ErrorGettingSQLVersion, version)); return; } } }); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return; } int dbMajor = Convert.ToInt32(tsi.Version.Substring(0, 2)); //ok, we don't want to break the old version where they just passed in an int value without the "MB" or "GB". So, we //can guess based on the edition what it should be. //web = 100 MB, 1 GB, 5 GB //business = 10 GB, 20 GB, 30 GB, 40 GB, 50 GB, 100 GB, or 150 GB //basic = 100 MB, 500 MB, 1 GB, 2 GB //standard = 100 MB, 500 MB, 1 GB, 2 GB, 5 GB, 10 GB, 20 GB, 30 GB, 40 GB, 50 GB, 100 GB, 150 GB, 200 GB, or 250 GB //premium = 100 MB, 500 MB, 1 GB, 2 GB, 5 GB, 10 GB, 20 GB, 30 GB, 40 GB, 50 GB, 100 GB, 150 GB, 200 GB, 250 GB, 300 GB, 400 GB, or 500 GB if (tsi.ServerType == ServerTypes.AzureSQLDB) { if (_TargetEdition == "web") { if (dbMajor > 11) { Console.WriteLine(CommonFunc.FormatString(Properties.Resources.InvalidDatabaseEdition1V12, _TargetEdition)); return; } if (_TargetDatabaseSize[_TargetDatabaseSize.Length - 1] != 'B') { if (_TargetDatabaseSize == "1") { _TargetDatabaseSize = "1 GB"; } else if (_TargetDatabaseSize == "5") { _TargetDatabaseSize = "5 GB"; } else { _TargetDatabaseSize = "100 MB"; } } } else if (_TargetEdition == "business") { if (dbMajor > 11) { Console.WriteLine(CommonFunc.FormatString(Properties.Resources.InvalidDatabaseEdition1V12, _TargetEdition)); return; } if (_TargetDatabaseSize[_TargetDatabaseSize.Length - 1] != 'B') { _TargetDatabaseSize = _TargetDatabaseSize + " GB"; } } else if (_TargetEdition == "standard") { if (dbMajor > 11) { if (!Regex.IsMatch(_TargetDatabasePerforance, "S[0-3]")) { Console.WriteLine(CommonFunc.FormatString(Properties.Resources.InvalidPerformanceLevelV12, _TargetDatabasePerforance, _TargetEdition)); return; } } else { if (!Regex.IsMatch(_TargetDatabasePerforance, "S[0-2]")) { Console.WriteLine(CommonFunc.FormatString(Properties.Resources.InvalidPerformanceLevel, _TargetDatabasePerforance, _TargetEdition)); return; } } } else if (_TargetEdition == "premium") { if (!Regex.IsMatch(_TargetDatabasePerforance, "P[1-3]")) { Console.WriteLine(CommonFunc.FormatString(Properties.Resources.InvalidPerformanceLevel, _TargetDatabasePerforance, _TargetEdition)); return; } } } if (dbMajor == 12) { // Note with dbMajor 12 and above, disk size no longer matters _TargetDatabaseSize = ""; } else { if (!ValidateDatabaseSize(_TargetEdition, _TargetDatabaseSize)) { Console.WriteLine(CommonFunc.FormatString(Properties.Resources.InvalidDatabaseSize, _TargetEdition, _TargetDatabaseSize)); return; } } //AsyncProcessingStatus.FinishedProcessingJobs = true; AsyncQueueBCPJob queueBCPJob = new AsyncQueueBCPJob(AsyncQueueJobHandler); DatabaseCreateStatus dcs = tp.CreateDatabase(tsi, _Collation, _TargetEdition, _TargetDatabaseSize, _TargetDatabasePerforance, _bDropExistingDatabase); if (dcs == DatabaseCreateStatus.Waiting) { Console.Write(Properties.Resources.WaitingForDBCreation); while (!tp.DoesDatabaseExist(tsi)) { Thread.Sleep(2000); Console.Write("."); } Thread.Sleep(2000); Console.Write(Properties.Resources.DBCreated + Environment.NewLine); } else if (dcs == DatabaseCreateStatus.Failed) { Console.WriteLine(Properties.Resources.DBCreateFailed); return; } tp.ExecuteSQLonTarget(tsi, updateStatus, queueBCPJob, sqlToExecute); }
private void btnCreateDatabase_Click(object sender, EventArgs e) { if (tbNewDatabase.Text.Length == 0) { MessageBox.Show(label1.Text, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); tbNewDatabase.Focus(); return; } try { this.Cursor = Cursors.WaitCursor; TargetProcessor tp = new TargetProcessor(); _TargetServerInfo.TargetDatabase = tbNewDatabase.Text; if (tp.DoesDatabaseExist(_TargetServerInfo)) { this.Cursor = Cursors.Default; MessageBox.Show(Properties.Resources.MessageDatabaseExists, Properties.Resources.DatabaseExists, MessageBoxButtons.OK, MessageBoxIcon.Warning); tbNewDatabase.Focus(); } else { string size = ""; string edition = ""; string performanceLevel = ""; if (_TargetServerInfo.ServerType == ServerTypes.AzureSQLDB) { edition = ((DatabaseEdition)cbEdition.SelectedItem).Edition.Value; performanceLevel = ((KeyValuePair <string, string>)cbPerformanceLevel.SelectedItem).Value; if (_major < 12) { size = lbMaxDatabaseSize.Text; } } DatabaseCreateStatus dcs = tp.CreateDatabase(_TargetServerInfo, ((Collation)cbCollations.SelectedValue).Name, edition, size, performanceLevel, false); if (dcs == DatabaseCreateStatus.Success) { DatabaseName = "[" + tbNewDatabase.Text + "]"; DialogResult = DialogResult.OK; } else { // Ok, the database is in the process of being created, but the calling function // will have to check back later to see if it has been created. From what I have // heard, it can take Azure SQL DB up to 30 minutes to deploy. DialogResult = DialogResult.Retry; } Close(); this.Cursor = Cursors.Default; } } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBox.Show(CommonFunc.GetLowestException(ex), Properties.Resources.ErrorCreatingDB, MessageBoxButtons.OK, MessageBoxIcon.Error); } }