// End the extraction process public void EndEnvironmentSetupProcess(IAsyncResult result) { ProcessEnvironment processTask = (ProcessEnvironment)result.AsyncState; string[] strResult = processTask.EndInvoke(result); ExtractorService.RemoveKey(strResult[0]); if (ExtractorService.StatusMessages.Keys.Count(x => x == strResult[0] + "_Errors") == 1) { string errorMessages = ExtractorService.statusMessages[strResult[0] + "_Errors"]; if (errorMessages != "") { //also, log message to file system string logPath = Server.MapPath("~") + @"\Log"; string accountName = strResult[1]; string fileName = string.Format("{0}_{1}.txt", "Extractor_", DateTime.Now.ToString("ddMMMyyyy_HHmmss")); if (!Directory.Exists(logPath)) { Directory.CreateDirectory(logPath); } System.IO.File.AppendAllText(Path.Combine(logPath, fileName), errorMessages); //Create ISSUE work item with error details in VSTSProjectgenarator account string patBase64 = System.Configuration.ConfigurationManager.AppSettings["PATBase64"]; string url = System.Configuration.ConfigurationManager.AppSettings["URL"]; string projectId = System.Configuration.ConfigurationManager.AppSettings["PROJECTID"]; string issueName = string.Format("{0}_{1}", "Extractor_", DateTime.Now.ToString("ddMMMyyyy_HHmmss")); IssueWI objIssue = new IssueWI(); ExtractorService.logger.Info(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + "\t Extractor_" + errorMessages + "\n"); string logWIT = "true"; //System.Configuration.ConfigurationManager.AppSettings["LogWIT"]; if (logWIT == "true") { objIssue.CreateIssueWI(patBase64, "4.1", url, issueName, errorMessages, projectId, "Extractor"); } } } }
/// <summary> /// End the process /// </summary> /// <param name="result"></param> public void EndEnvironmentSetupProcess(IAsyncResult result) { string templateUsed = string.Empty; string ID = string.Empty; string accName = string.Empty; try { ProcessEnvironment processTask = (ProcessEnvironment)result.AsyncState; string[] strResult = processTask.EndInvoke(result); if (strResult != null && strResult.Length > 0) { ID = strResult[0]; accName = strResult[1]; templateUsed = strResult[2]; projectService.RemoveKey(ID); if (ProjectService.StatusMessages.Keys.Count(x => x == ID + "_Errors") == 1) { string errorMessages = ProjectService.statusMessages[ID + "_Errors"]; if (errorMessages != "") { //also, log message to file system string logPath = Server.MapPath("~") + @"\Log"; string accountName = strResult[1]; string fileName = string.Format("{0}_{1}.txt", templateUsed, DateTime.Now.ToString("ddMMMyyyy_HHmmss")); if (!Directory.Exists(logPath)) { Directory.CreateDirectory(logPath); } System.IO.File.AppendAllText(Path.Combine(logPath, fileName), errorMessages); //Create ISSUE work item with error details in VSTSProjectgenarator account string patBase64 = System.Configuration.ConfigurationManager.AppSettings["PATBase64"]; string url = System.Configuration.ConfigurationManager.AppSettings["URL"]; string projectId = System.Configuration.ConfigurationManager.AppSettings["PROJECTID"]; string issueName = string.Format("{0}_{1}", templateUsed, DateTime.Now.ToString("ddMMMyyyy_HHmmss")); IssueWI objIssue = new IssueWI(); errorMessages = errorMessages + "\t" + "TemplateUsed: " + templateUsed; errorMessages = errorMessages + "\t" + "ProjectCreated : " + ProjectService.projectName; ProjectService.logger.Error(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + "\t Error: " + errorMessages); string logWIT = System.Configuration.ConfigurationManager.AppSettings["LogWIT"]; if (logWIT == "true") { objIssue.CreateIssueWI(patBase64, "4.1", url, issueName, errorMessages, projectId, "Demo Generator"); } } } } } catch (Exception ex) { ProjectService.logger.Info(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + "\t" + ex.Message + "\t" + "\n" + ex.StackTrace + "\n"); } finally { DeletePrivateTemplate(templateUsed); } }