/// <summary> /// Returns list of generation parameters which are required for specified research. /// </summary> /// <param name="id">ID of research.</param> /// <returns>List of generation parameters.</returns> public static List <GenerationParameter> GetRequiredGenerationParameters(ResearchType rt, ModelType mt, GenerationType gt) { List <GenerationParameter> gp = new List <GenerationParameter>(); if (rt == ResearchType.Collection || rt == ResearchType.Structural) { return(gp); } if (gt == GenerationType.Static) { gp.Add(GenerationParameter.AdjacencyMatrix); return(gp); } ModelTypeInfo[] info = (ModelTypeInfo[])mt.GetType().GetField(mt.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false); Type t = Type.GetType(info[0].Implementation, true); RequiredGenerationParameter[] rRequiredGenerationParameters = (RequiredGenerationParameter[])t.GetCustomAttributes(typeof(RequiredGenerationParameter), true); for (int i = 0; i < rRequiredGenerationParameters.Length; ++i) { GenerationParameter g = rRequiredGenerationParameters[i].Parameter; if (g != GenerationParameter.AdjacencyMatrix) { gp.Add(g); } } return(gp); }
private void InitializeGenerationParameters() { GenerationParameterValues.Clear(); if (GetResearchType() == ResearchType.Collection || GetResearchType() == ResearchType.Structural) { return; } if (generationType == GenerationType.Static) { GenerationParameterValues.Add(GenerationParameter.AdjacencyMatrix, null); return; } ModelTypeInfo info = ((ModelTypeInfo[])modelType.GetType().GetField(modelType.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false))[0]; Type t = Type.GetType(info.Implementation, true); RequiredGenerationParameter[] gp = (RequiredGenerationParameter[])t.GetCustomAttributes(typeof(RequiredGenerationParameter), false); for (int i = 0; i < gp.Length; ++i) { GenerationParameter g = gp[i].Parameter; if (g != GenerationParameter.AdjacencyMatrix) { GenerationParameterInfo[] gInfo = (GenerationParameterInfo[])g.GetType().GetField(g.ToString()).GetCustomAttributes(typeof(GenerationParameterInfo), false); GenerationParameterValues.Add(g, gInfo[0].DefaultValue); } } }
private void LoadResearchAndGenerationParameters(Worksheet sheet, ResearchResult r) { int rowIndex = 12; string currentParameter = sheet.get_Range("A" + rowIndex).Cells.Value; if ("Research Parameters" == sheet.get_Range("A11").Cells.Value) { while (currentParameter != null) { ResearchParameter rp = (ResearchParameter)Enum.Parse(typeof(ResearchParameter), currentParameter); r.ResearchParameterValues.Add(rp, sheet.get_Range("B" + rowIndex).Cells.Value); ++rowIndex; currentParameter = sheet.get_Range("A" + rowIndex).Cells.Value; } rowIndex += 2; currentParameter = sheet.get_Range("A" + rowIndex).Cells.Value; } while (currentParameter != null) { GenerationParameter gp = (GenerationParameter)Enum.Parse(typeof(GenerationParameter), currentParameter); r.GenerationParameterValues.Add(gp, sheet.get_Range("B" + rowIndex).Cells.Value); ++rowIndex; currentParameter = sheet.get_Range("A" + rowIndex).Cells.Value; } }
private Object GetGenerationParameterValue(GenerationParameter gp) { if (dType == DialogType.Create) { return(GetDefaultValueForGenerationParameter(gp)); } Dictionary <GenerationParameter, Object> gv = SessionManager.GetGenerationParameterValues(researchId); if (gv.ContainsKey(gp)) { return(gv[gp]); } else { return(GetDefaultValueForGenerationParameter(gp)); } }
/// <summary> /// Creates multiple EnsembleManagers, running sequentially. /// </summary> public override void StartResearch() { if (GenerationParameterValues.ContainsKey(GenerationParameter.Probability)) probabilityParameter = GenerationParameter.Probability; else if (GenerationParameterValues.ContainsKey(GenerationParameter.Mu)) probabilityParameter = GenerationParameter.Mu; else throw new SystemException("Unexpected generation parameter set."); minProbability = Convert.ToSingle(GenerationParameterValues[probabilityParameter]); currentProbability = minProbability; maxProbability = Convert.ToSingle(ResearchParameterValues[ResearchParameter.ProbabilityMax]); delta = Convert.ToSingle(ResearchParameterValues[ResearchParameter.ProbabilityDelta]); Status = ResearchStatus.Running; StartCurrentEnsemble(); }
/// <summary> /// Sets value of specified generation parameter for specified research. /// </summary> /// <param name="id">ID of research.</param> /// <param name="p">Generation parameter.</param> /// <param name="value">Value to set.</param> public static void SetGenerationParameterValue(Guid id, GenerationParameter p, object value) { try { if (existingResearches[id].StatusInfo.Status == ResearchStatus.NotStarted) { existingResearches[id].GenerationParameterValues[p] = value; } else { throw new CoreException("Unable to modify research after start."); } } catch (KeyNotFoundException) { throw new CoreException("Specified research does not exists."); } }
/// <summary> /// Creates multiple EnsembleManagers, running sequentially. /// </summary> public override void StartResearch() { ValidateResearchParameters(); Debug.Assert(GenerationParameterValues.ContainsKey(GenerationParameter.Probability) || GenerationParameterValues.ContainsKey(GenerationParameter.Mu)); probabilityParameter = GenerationParameterValues.ContainsKey(GenerationParameter.Probability) ? GenerationParameter.Probability : GenerationParameter.Mu; minProbability = Double.Parse(GenerationParameterValues[probabilityParameter].ToString(), CultureInfo.InvariantCulture); currentProbability = minProbability; maxProbability = Double.Parse(ResearchParameterValues[ResearchParameter.ProbabilityMax].ToString(), CultureInfo.InvariantCulture); delta = Double.Parse(ResearchParameterValues[ResearchParameter.ProbabilityDelta].ToString(), CultureInfo.InvariantCulture); StatusInfo = new ResearchStatusInfo(ResearchStatus.Running, 0); Logger.Write("Research ID - " + ResearchID.ToString() + ". Research - " + ResearchName + ". STARTED Threshold RESEARCH."); StartCurrentEnsemble(); }
private bool SetGenerationParameterValues(GenerationParameter gp, UIElement uIValue, ref Type paramType) { GenerationParameterInfo[] info = (GenerationParameterInfo[])gp.GetType().GetField(gp.ToString()).GetCustomAttributes(typeof(GenerationParameterInfo), false); string paramName = gp.ToString(); paramType = info[0].Type; String paramValue = ((TextBox)uIValue).Text; object value = Convert.ChangeType(paramValue, paramType, CultureInfo.InvariantCulture); if (gp == GenerationParameter.Probability && !((double)value >= 0 && (double)value <= 1)) { MessageBox.Show(paramName + " parameter value must be rational number between 0 and 1.", "Error"); return(false); } if (gp == GenerationParameter.Vertices && (int)value > MAX_VERTEX_COUNT) { MessageBox.Show("Maximum number of vertices is " + MAX_VERTEX_COUNT); return(false); } LabSessionManager.SetGenerationParameterValue(gp, value); return(true); }
private void generateBtn_Click(object sender, EventArgs e) { if (!this.CheckParameters()) { return; } var generationObjects = GenerationHelper.GetGenerationObjects(this.treeView); int genObjectCount = generationObjects.Sum(x => x.Value.Count); if (genObjectCount == 0) { MessageBoxHelper.DisplayInfo(Resources.ShouldCheckedTreeNode); return; } int fileCount = genObjectCount * this.templateListBox.SelectedItems.Count; this.generateBtn.Enabled = false; this.completedLbl.Visible = false; this.totalFileCountLbl.Text = fileCount.ToString(); this.genProgressBar.Maximum = fileCount; GenerationParameter parameter = new GenerationParameter( ModelManager.Clone(), GenerationHelper.GetGenerationObjects(this.treeView), this.GetGenerationSettings()); try { this.codeGeneration.GenerateAsync(parameter, Guid.NewGuid().ToString()); } catch (Exception ex) { logger.Error(Resources.GenerateFailure, ex); } }
private Object GetGenerationParameterValue(GenerationParameter gp) { if (dType == DialogType.Create) return GetDefaultValueForGenerationParameter(gp); Dictionary<GenerationParameter, Object> gv = SessionManager.GetGenerationParameterValues(researchId); if (gv.ContainsKey(gp)) return gv[gp]; else return GetDefaultValueForGenerationParameter(gp); }
public RequiredGenerationParameter(GenerationParameter parameter) { Parameter = parameter; }
public static string GenerateFieldAssignmentSimple(GenerationParameter field, string recordName) { return(recordName + "." + field.Name + " = " + field.Name); }
public virtual ActionResult GenerateReportsAndSendToIDBDocs(PMRPublicReportModel model) { if (string.IsNullOrEmpty(model.Operations)) { return(null); } if (!IDBContext.Current.HasRole(Role.RM_ADMINISTRATOR)) { Logger.GetLogger().WriteMessage( "PMRPublicController", "No RM Administrator in PMR Public. Security issue?"); throw new Exception("You don't have permissions to use PMR Public"); } try { string[] operationsToSend = model.Operations.Split('|'); int ini, buildReportTime, createDocTime, addDocToDBTime; foreach (string operation in operationsToSend) { var reportResponse = new ReportResponse(); //Parse the operation information sent string[] operationInfo = operation.Split(';'); string operationId = operationInfo[0]; string operationNumber = operationInfo[1]; ini = Environment.TickCount; var reportCognos = new CognosReportBuilder(); var reportParameter = new GenerationParameter { OutputFormat = CognosGlobalValues.FORMAT_PDF, ReportParameters = new Dictionary <string, string> { { CognosGlobalValues.P_OPER_NUMBER, operationNumber }, { CognosGlobalValues.P_CYCLE, model.PmrCycleId }, { CognosGlobalValues.P_SECTION, CognosGlobalValues.ALL_SECTIONS } } }; reportResponse = reportCognos.Generate(reportParameter); if (!reportResponse.IsValid) { throw new Exception(reportResponse.ErrorMessage); } buildReportTime = Environment.TickCount; string docNum = CreateIDBDocsDocument( new UploadDocumentRequest { OperationNumber = operationNumber, FileStream = reportResponse.Data, FileName = operationNumber + " " + model.PmrCycleName + "-Public Report.pdf", TrusteeList = TRUSTEE_LIST, BusinessAreaCode = BusinessAreaCodeEnum.BA_PMR, AccessInformation = AccessInformationCategoryEnum.PUBLIC, StageCode = "PMR PUBLIC", TypeId = "Report" }); createDocTime = Environment.TickCount; if (!CreateDocumentInDatabase( operationId, operationNumber, docNum, model.PmrCycleId)) { DeleteDocumentInIDBDocs(new DeleteDocumentRequest { DocumentNumber = docNum, VersionId = string.Empty }); throw new Exception( "An error occurred when saving the document in the database." + " Refer to the log for further information"); } addDocToDBTime = Environment.TickCount; Logger.GetLogger().WriteDebug("PMRPublicController", string.Format( "--- TOTAL TIME GENERATING PMR DOCUMENT FOR OPERATION {0} ---", operationNumber)); Logger.GetLogger().WriteDebug("PMRPublicController", string.Format( "TOTAL: {0}s", (addDocToDBTime - ini) / 1000)); Logger.GetLogger().WriteDebug("PMRPublicController", string.Format( "GENERATE REPORT: {0}s", (buildReportTime - ini) / 1000)); Logger.GetLogger().WriteDebug("PMRPublicController", string.Format( "CREATE DOC IN IDBDOCS: {0}s", (createDocTime - buildReportTime) / 1000)); Logger.GetLogger().WriteDebug("PMRPublicController", string.Format( "CREATE ENTRY IN DATABASE: {0}s", (addDocToDBTime - createDocTime) / 1000)); } PMRPublicReportModel resultModel = CreateFilteredModel(model); return(PartialView( "~/Areas/Administration/Views/PMRPublic/Partial/_PMRPublicTablePartial.cshtml", resultModel)); } catch (Exception e) { Logger.GetLogger().WriteError( "PMRPublicController", "Error when uploading Cognos report", e); throw; } }
public virtual FileResult GeneratePDFCompositeReport(string reportParametersPDF) { if (!IDBContext.Current.HasRole(Role.RM_ADMINISTRATOR)) { Logger.GetLogger().WriteMessage( "PMRPublicController", "No RM Administrator in PMR Public. Security issue?"); throw new Exception("You don't have permissions to use PMR Public"); } try { int pmrCycleId = GetPmrCycleId(reportParametersPDF); string pmrCycleName = GetPmrCycleName(pmrCycleId); ReportResponse reportResponse; string reportName = string.Empty; string cookieDomain = ConfigurationManager.AppSettings["cookie:Domain"].ToString(); bool cookieHttpOnly = bool.Parse(ConfigurationManager.AppSettings["cookie:HttpOnly"].ToString()); bool cookieSecure = bool.Parse(ConfigurationManager.AppSettings["cookie:Secure"].ToString()); Response.AppendCookie(new HttpCookie( PMRGlobalValues.COOKIE_REPORT_READY_PMR_PUBLIC_PDF_COMPOSITE, PMRGlobalValues.COOKIE_REPORT_READY_PMR_PUBLIC_PDF_COMPOSITE) { Domain = cookieDomain, HttpOnly = cookieHttpOnly, Secure = cookieSecure }); List <string> operationNumbers = GetOperations(reportParametersPDF); Document fullDoc = new Document(); License license = new License(); string licenseFile = Path.Combine(HttpRuntime.AppDomainAppPath, "Aspose.Total.lic"); license.SetLicense(licenseFile); foreach (var operationNumber in operationNumbers) { var reportCognos = new CognosReportBuilder(); var reportParameter = new GenerationParameter { OutputFormat = CognosGlobalValues.FORMAT_PDF, ReportParameters = new Dictionary <string, string> { { CognosGlobalValues.P_OPER_NUMBER, operationNumber }, { CognosGlobalValues.P_CYCLE, pmrCycleId.ToString() }, { CognosGlobalValues.P_SECTION, CognosGlobalValues.ALL_SECTIONS } } }; reportResponse = reportCognos.Generate(reportParameter); if (!reportResponse.IsValid) { throw new Exception(reportResponse.ErrorMessage); } reportName = operationNumber + " " + pmrCycleName + "-Public Report.pdf"; if (operationNumbers.Count == 1) { return(File( reportResponse.Data, FileContentTypeEnum.Pdf.GetEnumDescription(), reportName)); } MemoryStream str = new MemoryStream(reportResponse.Data); Document doc = new Document(str); fullDoc.Pages.Add(doc.Pages); } using (MemoryStream fullstr = new MemoryStream()) { fullDoc.Save(fullstr, SaveFormat.Pdf); return(File( fullstr.ToArray(), FileContentTypeEnum.Pdf.GetEnumDescription(), "PMR Public Composite.pdf")); } } catch (Exception ex) { Logger.GetLogger().WriteError( "PMRPublicController", "Error when generating Cognos report", ex); throw; } }
public void SetGenerationParameterValue(GenerationParameter p, Object value) { research.GenerationParameterValues[p] = value; }
private Type GetGenerationParameterType(GenerationParameter g) { GenerationParameterInfo gInfo = (GenerationParameterInfo)(g.GetType().GetField(g.ToString()).GetCustomAttributes(typeof(GenerationParameterInfo), false)[0]); return(gInfo.Type); }
public static void SetGenerationParameterValue(GenerationParameter p, object value) { existingResearch.GenerationParameterValues[p] = value; }
private string GetDefaultValueForGenerationParameter(GenerationParameter g) { GenerationParameterInfo gInfo = (GenerationParameterInfo)(g.GetType().GetField(g.ToString()).GetCustomAttributes(typeof(GenerationParameterInfo), false)[0]); return(gInfo.DefaultValue); }
private Type GetGenerationParameterType(GenerationParameter g) { GenerationParameterInfo gInfo = (GenerationParameterInfo)(g.GetType().GetField(g.ToString()).GetCustomAttributes(typeof(GenerationParameterInfo), false)[0]); return gInfo.Type; }
private string GetDefaultValueForGenerationParameter(GenerationParameter g) { GenerationParameterInfo gInfo = (GenerationParameterInfo)(g.GetType().GetField(g.ToString()).GetCustomAttributes(typeof(GenerationParameterInfo), false)[0]); return gInfo.DefaultValue; }
private void generateBtn_Click(object sender, EventArgs e) { if (!this.CheckParameters()) return; var generationObjects = GenerationHelper.GetGenerationObjects(this.treeView); int genObjectCount = generationObjects.Sum(x => x.Value.Count); if (genObjectCount == 0) { MessageBoxHelper.DisplayInfo("You should checked a tables or views treenode"); return; } int fileCount = genObjectCount * this.templateListBox.SelectedItems.Count; this.generateBtn.Enabled = false; this.completedLbl.Visible = false; this.totalFileCountLbl.Text = fileCount.ToString(); this.genProgressBar.Maximum = fileCount; GenerationParameter parameter = new GenerationParameter( ModelManager.Clone(), GenerationHelper.GetGenerationObjects(this.treeView), this.GetGenerationSettings()); try { this.codeGeneration.GenerateAsync(parameter, Guid.NewGuid().ToString()); } catch (Exception ex) { logger.Error("Generate", ex); } }
/// <summary> /// Sets value of specified generation parameter for specified research. /// </summary> /// <param name="id">ID of research.</param> /// <param name="p">Generation parameter.</param> /// <param name="value">Value to set.</param> public static void SetGenerationParameterValue(Guid id, GenerationParameter p, object value) { try { if (existingResearches[id].Status == ResearchStatus.NotStarted) existingResearches[id].GenerationParameterValues[p] = value; else throw new CoreException("Unable to modify research after start."); } catch (KeyNotFoundException) { throw new CoreException("Specified research does not exists."); } }