void addElement(bool replaceSelected) { if (elementTreeView.SelectedNode != null && elementTreeView.SelectedNode.Tag is MetaColumn) { //If an element is already selected, try to insert the new one just after... ElementPanel panel = RowPanel; if (SelectedButton != null && SelectedButton.Parent is ElementPanel) { panel = SelectedButton.Parent as ElementPanel; } int newIndex = -1; ReportElement element = null; if (SelectedButton != null && SelectedButton.Tag is ReportElement && panel.Controls.Contains(SelectedButton)) { element = SelectedButton.Tag as ReportElement; if (element.PivotPosition == PivotPosition.Data) { panel = DataPanel; } if (element.PivotPosition == PivotPosition.Column) { panel = ColumnPanel; } if (element.PivotPosition == PivotPosition.Page) { panel = PagePanel; } newIndex = panel.Controls.GetChildIndex(SelectedButton) + 1; if (replaceSelected) { panel.Controls.Remove(SelectedButton); Model.Elements.Remove(element); newIndex--; } } //For aggregate force data panel if (!replaceSelected && ((MetaColumn)elementTreeView.SelectedNode.Tag).IsAggregate) { panel = DataPanel; } Button button = AddElement(panel, (MetaColumn)elementTreeView.SelectedNode.Tag, true); //move position to the next button if (newIndex != -1) { panel.Controls.SetChildIndex(button, newIndex); } if (replaceSelected && element != null) { //copy interesting properties ReportElement newElement = button.Tag as ReportElement; newElement.AggregateFunction = element.AggregateFunction; newElement.CalculationOption = element.CalculationOption; newElement.Nvd3Serie = element.Nvd3Serie; newElement.SerieDefinition = element.SerieDefinition; newElement.SerieSortOrder = element.SerieSortOrder; newElement.SerieSortType = element.SerieSortType; newElement.SerieType = element.SerieType; newElement.TotalAggregateFunction = element.TotalAggregateFunction; newElement.ShowTotal = element.ShowTotal; newElement.SortOrder = element.SortOrder; newElement.XAxisType = element.XAxisType; newElement.YAxisType = element.YAxisType; } MainForm.IsModified = true; MainForm.CannotRenderAnymore(); PanelsToElements(); panel.RedrawPanel(); button.Focus(); } }
public ImageDataHandler(ReportElement reportElement, IBaseImage image) { m_reportElement = reportElement; m_image = image; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (svc != null) { var frm = new TemplateTextEditorForm(); string template = ""; string valueToEdit = (value == null ? "" : value.ToString()); if (context.Instance is ReportView) { frm.View = context.Instance as ReportView; if (context.PropertyDescriptor.Name == "CustomTemplate") { if (string.IsNullOrEmpty(valueToEdit)) { valueToEdit = frm.View.ViewTemplateText; } template = frm.View.Template.Text.Trim(); frm.Text = "Edit custom template"; frm.TypeForCheckSyntax = typeof(Report); frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "CustomConfiguration") { if (string.IsNullOrEmpty(valueToEdit)) { valueToEdit = frm.View.Template.Configuration; } template = frm.View.Template.Configuration.Trim(); frm.Text = "Edit template configuration"; frm.TypeForCheckSyntax = typeof(ReportViewTemplate); frm.textBox.ConfigurationManager.Language = "cs"; } } else if (context.Instance is ReportViewPartialTemplate) { var pt = context.Instance as ReportViewPartialTemplate; frm.View = pt.View; var templateText = frm.View.Template.GetPartialTemplateText(pt.Name); if (string.IsNullOrEmpty(valueToEdit)) { valueToEdit = templateText; } template = templateText; frm.Text = "Edit custom partial template"; frm.TypeForCheckSyntax = frm.View.Template.ForReportModel ? typeof(ReportModel) : typeof(ReportView); frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.Instance is ReportTask) { template = razorTaskTemplate; frm.TypeForCheckSyntax = typeof(ReportTask); frm.Text = "Edit task script"; frm.textBox.ConfigurationManager.Language = "cs"; frm.TextToAddForCheck = ((ReportTask)context.Instance).ScriptHeader; List <string> samples = new List <string>(); foreach (var sample in tasksSamples) { samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@using System.Data\r\n@{\r\n\t//" + sample.Item1 + "\r\n\t" + sample.Item2 + "}\r\n|" + sample.Item1); } frm.SetSamples(samples); } else if (context.Instance is ReportOutput) { if (context.PropertyDescriptor.Name == "PreScript") { template = razorPreOutputTemplate; } else if (context.PropertyDescriptor.Name == "PostScript") { template = razorPostOutputTemplate; } frm.TypeForCheckSyntax = typeof(ReportOutput); frm.Text = "Edit output script"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.Instance is Parameter || context.Instance is ParametersEditor) { Parameter parameter = context.Instance is Parameter ? context.Instance as Parameter : ((ParametersEditor)context.Instance).GetParameter(context.PropertyDescriptor.Name); if (parameter != null) { template = parameter.ConfigValue; frm.Text = parameter.DisplayName; frm.textBox.ConfigurationManager.Language = (string.IsNullOrEmpty(parameter.EditorLanguage) ? "" : parameter.EditorLanguage); if (parameter.TextSamples != null) { frm.SetSamples(parameter.TextSamples.ToList()); } } } else if (context.Instance.GetType().ToString() == "SealPdfConverter.PdfConverter") { string language = "cs"; SealPdfConverter converter = SealPdfConverter.Create(""); converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language); frm.textBox.ConfigurationManager.Language = language; } else if (context.Instance.GetType().ToString() == "SealExcelConverter.ExcelConverter") { string language = "cs"; SealExcelConverter converter = SealExcelConverter.Create(""); converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language); frm.textBox.ConfigurationManager.Language = language; } else if (context.Instance is ViewFolder) { if (context.PropertyDescriptor.Name == "DisplayName") { template = displayNameTemplate; frm.TypeForCheckSyntax = typeof(Report); frm.Text = "Edit display name script"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "InitScript") { template = razorInitScriptTemplate; frm.TypeForCheckSyntax = typeof(Report); frm.Text = "Edit the script executed when the report is initialized"; frm.textBox.ConfigurationManager.Language = "cs"; } } else if (context.Instance is ReportElement) { ReportElement element = context.Instance as ReportElement; if (context.PropertyDescriptor.Name == "CellScript") { frm.Text = "Edit custom script for the cell"; template = razorCellScriptTemplate; List <string> samples = new List <string>(); foreach (var sample in razorCellScriptSamples) { samples.Add("@using Seal.Model\r\n@{\r\n\t//" + sample.Item1 + "\r\n\tResultCell cell=Model;\r\n\tReportElement element = cell.Element;\r\n\tReportModel reportModel = element.Model;\r\n\tReport report = reportModel.Report;\r\n\t" + sample.Item2 + "}\r\n|" + sample.Item1); } frm.SetSamples(samples); frm.TypeForCheckSyntax = typeof(ResultCell); frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "SQL") { frm.Text = "Edit custom SQL"; frm.textBox.ConfigurationManager.Language = "sql"; template = element.RawSQLColumn; List <string> samples = new List <string>(); samples.Add(element.RawSQLColumn); if (!string.IsNullOrEmpty(element.SQL) && !samples.Contains(element.SQL)) { samples.Add(element.SQL); } frm.SetSamples(samples); frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word; } else if (context.PropertyDescriptor.Name == "CellCss") { frm.Text = "Edit custom CSS"; frm.textBox.ConfigurationManager.Language = "css"; List <string> samples = new List <string>(); samples.Add("text-align:right;"); samples.Add("text-align:center;"); samples.Add("text-align:left;"); samples.Add("font-style:italic;"); samples.Add("font-weight:bold;color:red;background-color:yellow;"); samples.Add("color:green;text-align:right;|color:black;|font-weight:bold;color:red;text-align:right;"); samples.Add("white-space: nowrap;"); frm.SetSamples(samples); frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word; } } else if (context.Instance is MetaColumn) { if (context.PropertyDescriptor.Name == "Name") { frm.Text = "Edit column name"; frm.textBox.ConfigurationManager.Language = "sql"; frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word; } } else if (context.Instance is SealSecurity) { if (context.PropertyDescriptor.Name == "Script" || context.PropertyDescriptor.Name == "ProviderScript") { template = ((SealSecurity)context.Instance).ProviderScript; frm.TypeForCheckSyntax = typeof(SecurityUser); frm.Text = "Edit security script"; frm.textBox.ConfigurationManager.Language = "cs"; } } else if (context.Instance is MetaTable) { if (context.PropertyDescriptor.Name == "DefinitionScript") { template = razorTableDefinitionScriptTemplate; frm.TypeForCheckSyntax = typeof(MetaTable); frm.Text = "Edit the script to define the table"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "LoadScript") { template = razorTableLoadScriptTemplate; frm.TypeForCheckSyntax = typeof(MetaTable); frm.Text = "Edit the default script to load the table"; frm.textBox.ConfigurationManager.Language = "cs"; } } else if (context.Instance is ReportModel) { if (context.PropertyDescriptor.Name == "PreLoadScript") { template = razorModelPreLoadScriptTemplateNoSQL; frm.TypeForCheckSyntax = typeof(ReportModel); frm.Text = "Edit the script executed before table load"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "FinalScript") { template = razorTableFinalScriptTemplate; frm.TypeForCheckSyntax = typeof(ReportModel); frm.Text = "Edit the final script executed for the model"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "LoadScript") { if (((ReportModel)context.Instance).Source.IsNoSQL) { frm.Text = "Edit the script executed after table load"; template = razorModelLoadScriptTemplateNoSQL; } else { frm.Text = "Edit the script to load the table"; template = razorModelLoadScriptTemplate; } frm.TypeForCheckSyntax = typeof(ReportModel); frm.textBox.ConfigurationManager.Language = "cs"; } } else if (context.Instance is MetaSource && context.PropertyDescriptor.Name == "InitScript") { template = razorSourceInitScriptTemplate; frm.TypeForCheckSyntax = typeof(MetaSource); frm.Text = "Edit the init script of the source"; frm.textBox.ConfigurationManager.Language = "cs"; } else if ((context.Instance is TasksFolder || context.Instance is MetaSource) && context.PropertyDescriptor.Name == "TasksScript") { template = razorTasksTemplate; frm.TextToAddForCheck = ((ReportComponent)context.Instance).Report.Repository.Configuration.TasksScript + "\r\n"; frm.TypeForCheckSyntax = typeof(ReportTask); frm.Text = "Edit the script that will be added to all task scripts"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.Instance is SealServerConfiguration) { if (context.PropertyDescriptor.Name == "InitScript") { template = razorConfigurationInitScriptTemplate; frm.TypeForCheckSyntax = typeof(Report); frm.Text = "Edit the root init script"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "TasksScript") { template = razorTasksTemplate; frm.TypeForCheckSyntax = typeof(ReportTask); frm.Text = "Edit the script that will be added to all task scripts"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "ReportCreationScript") { template = razorConfigurationReportCreationScriptTemplate; frm.TypeForCheckSyntax = typeof(Report); frm.Text = "Edit the script executed when a new report is created"; frm.textBox.ConfigurationManager.Language = "cs"; } } if (!string.IsNullOrEmpty(template) && string.IsNullOrWhiteSpace(valueToEdit) && !context.PropertyDescriptor.IsReadOnly) { valueToEdit = template; } //Reset button if (!string.IsNullOrEmpty(template) && !context.PropertyDescriptor.IsReadOnly) { frm.SetResetText(template); } frm.textBox.Text = valueToEdit.ToString(); if (context.PropertyDescriptor.IsReadOnly) { frm.textBox.IsReadOnly = true; frm.okToolStripButton.Visible = false; frm.cancelToolStripButton.Text = "Close"; } frm.checkSyntaxToolStripButton.Visible = (frm.TypeForCheckSyntax != null); if (svc.ShowDialog(frm) == DialogResult.OK) { if (string.IsNullOrEmpty(template)) { template = ""; } if (frm.textBox.Text.Trim() != template.Trim() || string.IsNullOrEmpty(template)) { value = frm.textBox.Text; } else if (frm.textBox.Text.Trim() == template.Trim() && !string.IsNullOrEmpty(template)) { value = ""; } } } return(value); }
void btn_MouseDown(object sender, MouseEventArgs e) { Button button = (Button)sender; //set property grid ElementGrid.PropertyValueChanged -= Grid_PropertyValueChanged; ReportElement element = null; if (button.Tag != null) { element = button.Tag as ReportElement; } if (element != null) { element.InitEditor(); bool collapseCategories = (ElementGrid.SelectedObject == null); ElementGrid.SelectedObject = button.Tag; //Collapse Advanced categories if (collapseCategories && !collapseElementCategoriesDone) { CollapseCategories(ElementGrid); collapseElementCategoriesDone = true; } } ElementGrid.PropertyValueChanged += Grid_PropertyValueChanged; if (e != null) { DragDropEffects dde1 = DoDragDrop(sender, DragDropEffects.Move); } if (button.Parent != null) { SelectedButton = button; redrawButtons(); } //select meta element in TreeView if (element != null) { SetMetaColumn(elementTreeView.Nodes, element); } if (e != null && e.Button == MouseButtons.Right) { ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem item = new ToolStripMenuItem("Remove"); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { removeElementFromPanel(button, false); }); menu.Items.Add(item); item = new ToolStripMenuItem("Remove all elements"); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { removeElementFromPanel(button, true); }); menu.Items.Add(item); item = new ToolStripMenuItem("Copy"); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { copyElementFromPanel(button); }); menu.Items.Add(item); item = new ToolStripMenuItem("Prompt at run-time"); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { if (element.MetaColumn.IsAggregate == true) { aggregateRestrictionsPanel.AddRestriction(element.MetaColumn, true); } else { restrictionsPanel.AddRestriction(element.MetaColumn, true); } }); menu.Items.Add(item); menu.Items.Add(new ToolStripSeparator()); item = new ToolStripMenuItem("Smart copy..."); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { SmartCopyForm form = new SmartCopyForm("Smart copy of " + element.DisplayNameEl, element, Model.Report); form.ShowDialog(); if (form.IsReportModified) { MainForm.IsModified = true; MainForm.CannotRenderAnymore(); ElementsToPanels(); } }); menu.Items.Add(item); //Display context menu menu.Show(button, e.Location); } }
protected abstract void Render(ReportElement element);
public void CreationAndExecution() { var repository = Repository.Create(); Report report = Report.Create(repository); report.DisplayName = "Sample Report"; var source = report.Sources.FirstOrDefault(i => i.Name.StartsWith("Northwind")); source.MetaData.Tables.Clear(); //Update the data source with a new table var table = source.AddTable(true); table.DynamicColumns = true; table.Name = "products"; //Instead of the name, could be a direct SQL statement: //table.Sql = "select * from products"; table.Refresh(); //Set the source of the default model report.Models[0].SourceGUID = source.GUID; //Add elements to the reports model foreach (var column in table.Columns) { var element = ReportElement.Create(); element.MetaColumnGUID = column.GUID; element.Name = column.Name; element.PivotPosition = PivotPosition.Row; element.Source = source; report.Models[0].Elements.Add(element); } //Add a restriction to the model var restriction = ReportRestriction.CreateReportRestriction(); restriction.Source = report.Models[0].Source; restriction.Model = report.Models[0]; restriction.MetaColumnGUID = table.Columns.FirstOrDefault(i => i.Name == "products.ProductName").GUID; restriction.SetDefaults(); restriction.Operator = Operator.Contains; restriction.Value1 = "er"; report.Models[0].Restrictions.Add(restriction); //Set the restriction text if (!string.IsNullOrEmpty(report.Models[0].Restriction)) { report.Models[0].Restriction = string.Format("({0}) AND ", report.Models[0].Restriction); } report.Models[0].Restriction += ReportRestriction.kStartRestrictionChar + restriction.GUID + ReportRestriction.kStopRestrictionChar; //Then execute it ReportExecution execution = new ReportExecution() { Report = report }; execution.Execute(); while (report.Status != ReportStatus.Executed) { System.Threading.Thread.Sleep(100); } string result = execution.GenerateHTMLResult(); Process.Start(result); }
public async Task Delete(ReportElement reportElement) { await unitOfWork.ReportElementRepo.Delete(reportElement); unitOfWork.Save(); }
public ReportElementVM() { _reportElement = new ReportElement(); }
public async Task <ReportElement> GetById(int id) { ReportElement reportElement = await unitOfWork.ReportElementRepo.GetById(id); return(reportElement); }
public async Task <ReportElementDto> GetColumnRangeById(int ReportElementId) { ReportElement reportElement = await unitOfWork.ReportElementRepo.GetById(ReportElementId); if (reportElement == null) { return new ReportElementDto { IsCorrect = false, Message = "Invalid report element" } } ; DateTime date = new DateTime(1970, 1, 1, 0, 0, 0); if (reportElement.Hours != 0) { date = DateTime.Now.AddHours(-(int)reportElement.Hours); } IEnumerable <History> histories = await unitOfWork.HistoryRepo.GetHistoriesBySensorIdAndDate(reportElement.SensorId.Value, date); if (!histories.Any()) { int hours = (int)reportElement.Hours; string strhours; if (hours == 0) { strhours = "all days"; } else if (hours == 1) { strhours = "1 hour"; } else if (hours <= 12) { strhours = $"{hours} hours"; } else if (hours / 24 == 1) { strhours = "1 day"; } else { strhours = $"{hours / 24} days"; } return(new ReportElementDto { Id = ReportElementId, IsCorrect = false, Message = $"No histories in this report element per {strhours}" }); } ReportElementDto columnRange = mapper.Map <Sensor, ReportElementDto>(reportElement.Sensor); columnRange.Id = ReportElementId; columnRange.Hours = reportElement.Hours; columnRange.Dates = new List <string>(); columnRange.MinValues = new List <dynamic>(); columnRange.MaxValues = new List <dynamic>(); IEnumerable <dynamic> values = null; switch (columnRange.MeasurementType) { case MeasurementType.Int: if ((int)reportElement.Hours == 1) { values = histories.OrderBy(p => p.Date.LocalDateTime).GroupBy(p => p.Date.LocalDateTime.Minute).Select(p => new { Min = p.Min(g => g.IntValue.GetValueOrDefault()), Max = p.Max(g => g.IntValue.GetValueOrDefault()), Date = p.Key.ToString() }).ToList(); break; } else if ((int)reportElement.Hours > 1 && (int)reportElement.Hours <= 24) { values = histories.OrderBy(p => p.Date.LocalDateTime).GroupBy(p => p.Date.LocalDateTime.Hour).Select(p => new { Min = p.Min(g => g.IntValue.GetValueOrDefault()), Max = p.Max(g => g.IntValue.GetValueOrDefault()), Date = p.Key.ToString() }).ToList(); break; } else { values = histories.OrderBy(p => p.Date.LocalDateTime).GroupBy(p => p.Date.LocalDateTime.Date).Select(p => new { Min = p.Min(g => g.IntValue.GetValueOrDefault()), Max = p.Max(g => g.IntValue.GetValueOrDefault()), Date = p.Key.ToString("d") }).ToList(); break; } case MeasurementType.Double: if ((int)reportElement.Hours == 1) { values = histories.OrderBy(p => p.Date.LocalDateTime).GroupBy(p => p.Date.LocalDateTime.Minute).Select(p => new { Min = p.Min(g => g.DoubleValue.GetValueOrDefault()), Max = p.Max(g => g.DoubleValue.GetValueOrDefault()), Date = p.Key.ToString() }).ToList(); break; } else if ((int)reportElement.Hours > 1 && (int)reportElement.Hours <= 24) { values = histories.OrderBy(p => p.Date.LocalDateTime).GroupBy(p => p.Date.LocalDateTime.Hour).Select(p => new { Min = p.Min(g => g.DoubleValue.GetValueOrDefault()), Max = p.Max(g => g.DoubleValue.GetValueOrDefault()), Date = p.Key.ToString() }).ToList(); break; } else { values = histories.OrderBy(p => p.Date.LocalDateTime).GroupBy(p => p.Date.LocalDateTime.Date).Select(p => new { Min = p.Min(g => g.DoubleValue.GetValueOrDefault()), Max = p.Max(g => g.DoubleValue.GetValueOrDefault()), Date = p.Key.ToString("d") }).ToList(); break; } default: return(new ReportElementDto { Id = ReportElementId, IsCorrect = false, Message = "Incorrect sensor type for this element" }); } List <dynamic> items = values.ToList(); for (int i = 0; i < items.Count(); i++) { if (values.Count() == 1 || i == 0) { columnRange.Dates.Add(items[i].Date); columnRange.MinValues.Add(items[i].Min); columnRange.MaxValues.Add(items[i].Max); continue; } if (i > 0 && !items[i].Equals(items[i - 1])) { columnRange.Dates.Add(items[i].Date); columnRange.MinValues.Add(items[i].Min); columnRange.MaxValues.Add(items[i].Max); } } return(columnRange); }
public async Task <BoolHeatmapDto> GetBoolHeatmapById(int reportElementId) { ReportElement reportElement = await unitOfWork.ReportElementRepo.GetById(reportElementId); if (reportElement == null) { return new BoolHeatmapDto { IsCorrect = false } } ; DateTime dateFrom = new DateTime(); DateTime dateTo = DateTime.Now.AddMinutes(1); if (reportElement.Hours != 0) { dateFrom = DateTime.Now.AddHours(-(int)reportElement.Hours); } int[] hoursArray = new int[(int)(dateTo - dateFrom).TotalHours]; string[] daysArray = new string[(int)(dateTo - dateFrom).TotalHours]; for (int i = 0; i < hoursArray.Length; i++) { hoursArray[i] = dateFrom.AddHours(i).Hour; daysArray[i] = dateFrom.AddHours(i).Date.ToString("dd.MM.yyyy"); } IEnumerable <BoolValuePercentagePerHour> boolValuePercentagesPerHours = await unitOfWork.HistoryRepo.GetBoolValuePercentagesPerHours(reportElement.SensorId.Value, dateFrom, dateTo); List <BoolValuePercentagePerHour> BoolValuePercentagesPerHours = new List <BoolValuePercentagePerHour>(); int w = 0; for (int j = 0; j < hoursArray.Length; j++) { if (!boolValuePercentagesPerHours.Any(a => a.HourTime == hoursArray[j] && a.DayDate.ToString().Contains(daysArray[j]))) { BoolValuePercentagesPerHours.Add( new BoolValuePercentagePerHour { DayDate = dateFrom, HourTime = hoursArray[j], TrueCount = null, TrueFalseCount = null, TruePercentage = null }); dateFrom = dateFrom.AddHours(1); } else { if (w != boolValuePercentagesPerHours.Count()) { BoolValuePercentagesPerHours.Add( new BoolValuePercentagePerHour { DayDate = dateFrom, HourTime = hoursArray[j], TrueCount = boolValuePercentagesPerHours.ElementAt(w).TrueCount, TrueFalseCount = boolValuePercentagesPerHours.ElementAt(w).TrueFalseCount, TruePercentage = boolValuePercentagesPerHours.ElementAt(w).TruePercentage }); w++; dateFrom = dateFrom.AddHours(1); } else { BoolValuePercentagesPerHours.Add( new BoolValuePercentagePerHour { DayDate = dateFrom, HourTime = hoursArray[j], TrueCount = null, TrueFalseCount = null, TruePercentage = null }); dateFrom = dateFrom.AddHours(1); } } } if (boolValuePercentagesPerHours.Count() == 0) { return new BoolHeatmapDto { Id = reportElementId, IsCorrect = false } } ; BoolHeatmapDto heatmap = mapper.Map <Sensor, BoolHeatmapDto>(reportElement.Sensor); heatmap.Id = reportElement.Id; heatmap.DashboardName = reportElement.Dashboard.Name; heatmap.DashboardId = reportElement.Dashboard.Id; heatmap.BoolValuePercentagesPerHours = BoolValuePercentagesPerHours; heatmap.Hours = reportElement.Hours; return(heatmap); }
public FormGPS(Context context, ReportElement element, int ownerID, int userID, int verifiedID, ReportStatus Reportstatus) : base(context) { resource = context.Resources; contextx = context; OwnerID = userID; VerifierID = verifiedID; theme = new FormTheme(context, element.Title); Orientation = Orientation.Vertical; RelativeLayout gpsHolder = new RelativeLayout(contextx); sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); sharedPreferencesEditor = sharedPreferences.Edit(); List <KeyValue> existingValue = element.Values; Popup = new InformationPopup(context); reportStatus = Reportstatus; editText = new EditText(context); Id = element.Id; isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false); if (existingValue != null) { foreach (var address in existingValue) { if (address.Name == "address") { editText.Text = address.Value; curaddress = address.Value; } if (address.Name == "longitude") { longtitude = address.Value; } if (address.Name == "latitude") { latitude = address.Value; } } } editText.SetBackgroundResource(Resource.Drawable.custom_edit_text_color); RelativeLayout.LayoutParams paramsForGPSHolder = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent); gpsHolder.LayoutParameters = paramsForGPSHolder; ImageButton locationBtn = new ImageButton(context); locationBtn.Id = 891; locationBtn.SetBackgroundResource(0); locationBtn.SetImageResource(Resource.Drawable.android_form_gps_icon); locationBtn.Click += (senderGPS, e) => AddressButton_OnClick(editText, this); RelativeLayout.LayoutParams paramsForlocationBtn = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForlocationBtn.AddRule(LayoutRules.AlignParentTop); paramsForlocationBtn.AddRule(LayoutRules.AlignParentEnd); locationBtn.LayoutParameters = paramsForlocationBtn; RelativeLayout.LayoutParams paramsForEditText = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForEditText.AddRule(LayoutRules.AlignParentTop); paramsForEditText.AddRule(LayoutRules.AlignParentStart); paramsForEditText.AddRule(LayoutRules.StartOf, locationBtn.Id); editText.LayoutParameters = paramsForEditText; //editText.Gravity = GravityFlags.CenterVertical; gpsHolder.AddView(editText); gpsHolder.AddView(locationBtn); ImageView indicatorImage = (ImageView)theme.GetChildAt(1); //activateElementInfo(element); Popup.activateElementInfo(theme, element); editText.TextChanged += (sender, e) => { if (!editText.Text.Equals("")) { indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); curaddress = editText.Text; } else { indicatorImage.SetImageResource(0); } }; //when opening a Draft or Archive if (!editText.Text.Equals("")) { indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } if (string.IsNullOrEmpty(element.FilledBy)) { //do nothing } else if (element.FilledBy == userID + "") { //do nothing } else { editText.Enabled = false; editText.SetTextColor(Resources.GetColor(Resource.Color.grey)); } TextView elementSplitLine = new TextView(context); elementSplitLine.TextSize = 0.5f; elementSplitLine.SetBackgroundColor(Color.ParseColor(resource.GetString(Resource.Color.grey))); if (OwnerID == 0 || OwnerID == userID) { if (VerifierID != 0) { editText.Enabled = false; editText.SetTextColor(Resources.GetColor(Resource.Color.grey)); locationBtn.Enabled = false; locationBtn.Click += null; if (reportStatus == ReportStatus.Rejected) { editText.Enabled = true; editText.SetTextColor(Resources.GetColor(Resource.Color.black)); locationBtn.Enabled = true; } } else { editText.Enabled = true; editText.SetTextColor(Resources.GetColor(Resource.Color.black)); locationBtn.Enabled = true; } } else { editText.Enabled = false; editText.SetTextColor(Resources.GetColor(Resource.Color.grey)); locationBtn.Enabled = false; locationBtn.Click += null; } if (isArcheived) { editText.Enabled = false; editText.SetTextColor(Resources.GetColor(Resource.Color.grey)); locationBtn.Enabled = false; locationBtn.Click += null; } AddView(theme); AddView(gpsHolder); SetPadding(45, 10, 45, 20); }
public FormIntEditText(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus) : base(context) { resource = context.Resources; contextx = context; OwnerID = ownerID; VerifierID = verifiedID; theme = new FormTheme(context, element.Title); Popup = new InformationPopup(context); reportStatus = Reportstatus; Orientation = Orientation.Vertical; sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); sharedPreferencesEditor = sharedPreferences.Edit(); isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false); SetPadding(45, 10, 45, 20); EditText intEditText = new EditText(context); intEditText.InputType = Android.Text.InputTypes.ClassNumber | Android.Text.InputTypes.TextFlagNoSuggestions; intEditText.Id = element.Id; intEditText.Text = element.Value; intEditText.SetBackgroundResource(Resource.Drawable.custom_edit_text_color); ImageView indicatorImageView = (ImageView)theme.GetChildAt(1); indicatorImageView.SetImageResource(0); //activateElementInfo(element); Popup.activateElementInfo(theme, element); intEditText.TextChanged += (sender, e) => { if (!intEditText.Text.Equals("")) { indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } else { indicatorImageView.SetImageResource(0); } sharedPreferencesEditor.PutBoolean("ReportEditFlag", true); sharedPreferencesEditor.Commit(); }; //when opening a Draft or Archive if (!intEditText.Text.Equals("")) { indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } if (OwnerID == 0 || OwnerID == userID) { if (VerifierID != 0) { intEditText.Enabled = false; intEditText.SetTextColor(Resources.GetColor(Resource.Color.grey)); if (reportStatus == ReportStatus.Rejected) { intEditText.Enabled = true; intEditText.SetTextColor(Resources.GetColor(Resource.Color.black)); } } else { intEditText.Enabled = true; intEditText.SetTextColor(Resources.GetColor(Resource.Color.black)); } } else { intEditText.Enabled = false; intEditText.SetTextColor(Resources.GetColor(Resource.Color.grey)); } if (isArcheived) { intEditText.Enabled = false; intEditText.SetTextColor(Resources.GetColor(Resource.Color.grey)); } AddView(theme); AddView(intEditText); }
internal void Finalizar(ReportElement rpt) { Finalizar(rpt._DIA_HORA); }
public async Task <ReportElementDto> GetStatusReport(int ReportElementId, string userid) { UserId = userid; ReportElement reportElement = await unitOfWork.ReportElementRepo.GetById(ReportElementId); if (reportElement == null) { return new ReportElementDto { IsCorrect = false, Message = "Invalid report element" } } ; IEnumerable <Sensor> sensors = await unitOfWork.SensorRepo.GetAllSensorsByUserId(UserId); ReportElementDto statusReport = new ReportElementDto { Dates = new List <string>(), Values = new List <dynamic>() }; foreach (Sensor sensor in sensors) { History history = unitOfWork.HistoryRepo.GetLastHistoryBySensorId(sensor.Id); if (history == null) { continue; } dynamic value = null; switch (sensor.SensorType.MeasurementType) { case MeasurementType.Int: value = history.IntValue.GetValueOrDefault(); break; case MeasurementType.Bool: value = history.BoolValue.GetValueOrDefault(); if (value == true) { value = "Active"; } else { value = "Inactive"; } break; case MeasurementType.Double: value = Math.Round(history.DoubleValue.GetValueOrDefault(), 2); break; case MeasurementType.String: value = history.StringValue; break; default: return(new ReportElementDto { Id = ReportElementId, IsCorrect = false, Message = "Incorrect sensor type for this element" }); } statusReport.Dates.Add(sensor.Name); statusReport.Values.Add(value); } return(statusReport); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (svc != null) { var frm = new TemplateTextEditorForm(); string template = ""; string valueToEdit = (value == null ? "" : value.ToString()); if (context.Instance is ReportView) { frm.View = context.Instance as ReportView; if (context.PropertyDescriptor.Name == "CustomTemplate") { if (string.IsNullOrEmpty(valueToEdit)) { valueToEdit = frm.View.ViewTemplateText; } template = frm.View.ViewTemplateText.Trim(); frm.Text = "Edit custom template"; frm.TypeForCheckSyntax = frm.View.Template.ForModel ? typeof(ReportModel) : typeof(Report); frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "CustomConfiguration") { if (string.IsNullOrEmpty(valueToEdit)) { valueToEdit = frm.View.Template.Configuration; } template = frm.View.Template.Configuration.Trim(); frm.Text = "Edit template configuration"; frm.TypeForCheckSyntax = typeof(ReportViewTemplate); frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "NVD3Configuration") { frm.Text = frm.View.NVD3ConfigurationParameter.DisplayName; var param = frm.View.Template.Parameters.FirstOrDefault(i => i.Name == Parameter.NVD3ConfigurationParameter); if (param != null) { template = param.TextValue; } frm.textBox.ConfigurationManager.Language = (string.IsNullOrEmpty(frm.View.NVD3ConfigurationParameter.EditorLanguage) ? "" : frm.View.NVD3ConfigurationParameter.EditorLanguage); } } else if (context.Instance is ReportTask) { template = razorTaskTemplate; frm.TypeForCheckSyntax = typeof(ReportTask); frm.Text = "Edit task script"; frm.textBox.ConfigurationManager.Language = "cs"; frm.TextToAddForCheck = ((ReportTask)context.Instance).Report.CommunTaskScript; List <string> samples = new List <string>(); samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Refresh Data Sources enumerated lists\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.RefreshRepositoryEnums();\r\n}"); samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Load a table from an Excel file, may need ODBC Office 2007 Drivers\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.LoadTableFromExcel(@\"c:\\temp\\loadFolder\", @\"c:\\temp\\excelFile.xlsx\", \"ExcelTabName\", \"DestinationTableName\", false /* true to load in all connections */);\r\n}"); samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Load a table from a CSV file\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.LoadTableFromCSV(@\"c:\\temp\\loadFolder\", @\"c:\\temp\\aCSVFile.csv\", \"DestinationTableName\", null /* separator may be specified here */, false /* true to load in all connections */);\r\n}"); samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Load a table from a source table located in an external data source\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.LoadTableFromExternalSource(\"SourceConnectionString\", \"SourceSelectStatement\", \"DestinationTableName\", false /* true to load in all connections */, \"OptionalSourceCheckSelect\", \"OptionalDestinationCheckSelect\");\r\n}"); samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Execute a program and display Standard Output and Errors\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.ExecuteProcess(@\"executablePath\");\r\n}"); frm.SetSamples(samples); } else if (context.Instance is ReportOutput) { if (context.PropertyDescriptor.Name == "PreScript") { template = razorPreOutputTemplate; } else if (context.PropertyDescriptor.Name == "PostScript") { template = razorPostOutputTemplate; } frm.TypeForCheckSyntax = typeof(ReportOutput); frm.Text = "Edit output script"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.Instance is Parameter) { Parameter parameter = context.Instance as Parameter; frm.Text = parameter.DisplayName; frm.textBox.ConfigurationManager.Language = (string.IsNullOrEmpty(parameter.EditorLanguage) ? "" : parameter.EditorLanguage); } else if (context.Instance.GetType().ToString() == "SealPdfConverter.PdfConverter") { string language = "cs"; SealPdfConverter converter = SealPdfConverter.Create(""); converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language); frm.textBox.ConfigurationManager.Language = language; } else if (context.Instance.GetType().ToString() == "SealExcelConverter.ExcelConverter") { string language = "cs"; SealExcelConverter converter = SealExcelConverter.Create(""); converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language); frm.textBox.ConfigurationManager.Language = language; } else if (context.Instance is ViewFolder) { if (context.PropertyDescriptor.Name == "DisplayName") { template = displayNameTemplate; frm.TypeForCheckSyntax = typeof(Report); frm.Text = "Edit display name script"; frm.textBox.ConfigurationManager.Language = "cs"; } } else if (context.Instance is ReportElement) { ReportElement element = context.Instance as ReportElement; if (context.PropertyDescriptor.Name == "CellScript") { frm.Text = "Edit custom script for the cell"; template = razorCellScriptTemplate; frm.TypeForCheckSyntax = typeof(ResultCell); frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "SQL") { frm.Text = "Edit custom SQL"; frm.textBox.ConfigurationManager.Language = "sql"; template = element.RawSQLColumn; List <string> samples = new List <string>(); samples.Add(element.RawSQLColumn); if (!string.IsNullOrEmpty(element.SQL) && !samples.Contains(element.SQL)) { samples.Add(element.SQL); } frm.SetSamples(samples); frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word; } else if (context.PropertyDescriptor.Name == "CellCss") { frm.Text = "Edit custom CSS"; frm.textBox.ConfigurationManager.Language = "css"; List <string> samples = new List <string>(); samples.Add("text-align:right;"); samples.Add("text-align:center;"); samples.Add("text-align:left;"); samples.Add("font-style:italic;"); samples.Add("font-weight:bold;color:red;background-color:yellow;"); samples.Add("color:green;text-align:right;|color:black;|font-weight:bold;color:red;text-align:right;"); samples.Add("white-space: nowrap;"); frm.SetSamples(samples); frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word; } } else if (context.Instance is MetaColumn) { if (context.PropertyDescriptor.Name == "Name") { frm.Text = "Edit column name"; frm.textBox.ConfigurationManager.Language = "sql"; frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word; } } else if (context.Instance is SealSecurity) { if (context.PropertyDescriptor.Name == "Script" || context.PropertyDescriptor.Name == "ProviderScript") { template = ((SealSecurity)context.Instance).ProviderScript; frm.TypeForCheckSyntax = typeof(SecurityUser); frm.Text = "Edit security script"; frm.textBox.ConfigurationManager.Language = "cs"; } } else if (context.Instance is MetaTable) { if (context.PropertyDescriptor.Name == "DefinitionScript") { template = razorTableDefinitionScriptTemplate; frm.TypeForCheckSyntax = typeof(MetaTable); frm.Text = "Edit the script to define the table"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "LoadScript") { template = razorTableLoadScriptTemplate; frm.TypeForCheckSyntax = typeof(MetaTable); frm.Text = "Edit the default script to load the table"; frm.textBox.ConfigurationManager.Language = "cs"; } } else if (context.Instance is ReportModel) { if (context.PropertyDescriptor.Name == "PreLoadScript") { template = razorModelPreLoadScriptTemplateNoSQL; frm.TypeForCheckSyntax = typeof(ReportModel); frm.Text = "Edit the script executed before table load"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "FinalScript") { template = razorTableFinalScriptTemplate; frm.TypeForCheckSyntax = typeof(ReportModel); frm.Text = "Edit the final script executed for the model"; frm.textBox.ConfigurationManager.Language = "cs"; } else if (context.PropertyDescriptor.Name == "LoadScript") { if (((ReportModel)context.Instance).Source.IsNoSQL) { frm.Text = "Edit the script executed after table load"; template = razorModelLoadScriptTemplateNoSQL; } else { frm.Text = "Edit the script to load the table"; template = razorModelLoadScriptTemplate; } frm.TypeForCheckSyntax = typeof(ReportModel); frm.textBox.ConfigurationManager.Language = "cs"; } } else if (context.Instance is TasksFolder) { template = razorCommunTasksTemplate; frm.TypeForCheckSyntax = typeof(ReportTask); frm.Text = "Edit the script that will be added to all task scripts"; frm.textBox.ConfigurationManager.Language = "cs"; } if (!string.IsNullOrEmpty(template) && string.IsNullOrWhiteSpace(valueToEdit)) { valueToEdit = template; } //Reset button if (!string.IsNullOrEmpty(template) && !context.PropertyDescriptor.IsReadOnly) { frm.SetResetText(template); } frm.textBox.Text = valueToEdit.ToString(); if (context.PropertyDescriptor.IsReadOnly) { frm.textBox.IsReadOnly = true; frm.okToolStripButton.Visible = false; frm.cancelToolStripButton.Text = "Close"; } frm.checkSyntaxToolStripButton.Visible = (frm.TypeForCheckSyntax != null); if (svc.ShowDialog(frm) == DialogResult.OK) { if (frm.textBox.Text.Trim() != template || string.IsNullOrEmpty(template)) { value = frm.textBox.Text; } else if (frm.textBox.Text.Trim() == template && !string.IsNullOrEmpty(template)) { value = ""; } } } return(value); }
public async Task <HeatmapDto> GetHeatmapById(int reportElementId) { ReportElement reportElement = await unitOfWork.ReportElementRepo.GetById(reportElementId); if (reportElement == null) { return new HeatmapDto { IsCorrect = false } } ; DateTime dateFrom = new DateTime(); DateTime dateTo = DateTime.Now.AddDays(1); if (reportElement.Hours != 0) { dateFrom = DateTime.Now.AddHours(-(int)reportElement.Hours).Date.AddDays(1); } DateTime[] daysArray = new DateTime[(int)(dateTo - dateFrom).TotalDays]; for (int i = 0; i < daysArray.Length; i++) { daysArray[i] = dateFrom.AddDays(i); } IEnumerable <AvgSensorValuePerDay> avgSensorValuesPerDays = await unitOfWork.HistoryRepo.GetAvgSensorsValuesPerDays(reportElement.SensorId.Value, dateFrom, dateTo); List <AvgSensorValuePerDay> AvgSensorValuesPerDays = avgSensorValuesPerDays.ToList(); for (int i = 0; i < daysArray.Length; i++) { if (!avgSensorValuesPerDays.Any(a => a.WeekDay.ToString("yyyy-MM-dd") == daysArray[i].ToString("yyyy-MM-dd"))) { AvgSensorValuesPerDays.Add(new AvgSensorValuePerDay { WeekDay = daysArray[i], AvgValue = null }); } } AvgSensorValuesPerDays = AvgSensorValuesPerDays.OrderBy(d => d.WeekDay).ToList(); if (avgSensorValuesPerDays.Count() == 0) { return new HeatmapDto { Id = reportElementId, IsCorrect = false } } ; HeatmapDto heatmap = mapper.Map <Sensor, HeatmapDto>(reportElement.Sensor); heatmap.Id = reportElement.Id; heatmap.DashboardName = reportElement.Dashboard.Name; heatmap.DashboardId = reportElement.Dashboard.Id; heatmap.AvgSensorValuesPerDays = AvgSensorValuesPerDays; heatmap.Hours = reportElement.Hours; return(heatmap); }
public FormSlider(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus) : base(context) { resource = context.Resources; contextx = context; OwnerID = ownerID; VerifierID = verifiedID; Popup = new InformationPopup(context); reportStatus = Reportstatus; if (element.Value == "") { element.Value = "0"; } theme = new FormTheme(context, element.Title); RelativeLayout countHolder = new RelativeLayout(context); Orientation = Orientation.Vertical; sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); sharedPreferencesEditor = sharedPreferences.Edit(); EditText counterEditText = new EditText(context); counterEditText.Text = element.Value; counterEditText.TextSize = 30; counterEditText.InputType = Android.Text.InputTypes.ClassNumber; counterEditText.SetTextColor(Color.ParseColor((resource.GetString(Resource.Color.green_primary)))); counterEditText.Gravity = GravityFlags.CenterHorizontal; counterEditText.SetPadding(10, 0, 10, 0); counterEditText.SetBackgroundResource(Resource.Drawable.back); counterEditText.SetWidth(200); RelativeLayout.LayoutParams paramsForSliderCounter = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); paramsForSliderCounter.AddRule(LayoutRules.CenterHorizontal); counterEditText.LayoutParameters = paramsForSliderCounter; //causes layout update counterEditText.SetPadding(20, 5, 20, 5); countHolder.AddView(counterEditText); ImageView indicatorImageView = (ImageView)theme.GetChildAt(1); indicatorImageView.SetImageResource(0); //activateElementInfo(element); Popup.activateElementInfo(theme, element); SeekBar slider = new SeekBar(context); slider.Progress = Integer.ParseInt(element.Value); slider.SetPadding(45, 15, 45, 20); slider.Id = element.Id; slider.Max = 31; isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false); slider.ProgressChanged += (sender, e) => { if (e.FromUser) { counterEditText.Text = $"{e.Progress}"; if (counterEditText.Text.Equals("0")) { indicatorImageView.SetImageResource(0); } else { indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); sharedPreferencesEditor.PutBoolean("ReportEditFlag", true); sharedPreferencesEditor.Commit(); } } }; counterEditText.TextChanged += (sender, e) => { if (!counterEditText.Text.Equals("0")) { indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); if (Integer.ParseInt(counterEditText.Text) > 31 || Integer.ParseInt(counterEditText.Text) < 0) { sliderValuePopUp(context); counterEditText.Text = "0"; slider.Progress = 0; } slider.Progress = Integer.ParseInt(counterEditText.Text); } else { indicatorImageView.SetImageResource(0); } }; //when opening a Draft or Archive if (!counterEditText.Text.Equals("0")) { indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } if (OwnerID == 0 || OwnerID == userID) { if (VerifierID != 0) { slider.Enabled = false; counterEditText.Enabled = false; if (reportStatus == ReportStatus.Rejected) { slider.Enabled = true; counterEditText.Enabled = true; } } else { slider.Enabled = true; counterEditText.Enabled = true; } } else { slider.Enabled = false; counterEditText.Enabled = false; } if (isArcheived) { slider.Enabled = false; counterEditText.Enabled = false; } AddView(theme); AddView(countHolder); AddView(slider); SetPadding(45, 10, 45, 20); }
public FormTime(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus) : base(context) { resource = context.Resources; contextx = context; OwnerID = ownerID; VerifierID = verifiedID; theme = new FormTheme(context, element.Title); Orientation = Orientation.Vertical; sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); sharedPreferencesEditor = sharedPreferences.Edit(); Popup = new InformationPopup(context); reportStatus = Reportstatus; isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false); timeFrame = new RelativeLayout(context); RelativeLayout.LayoutParams parms2 = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); timeFrame.LayoutParameters = parms2; ImageView indicatorImage = (ImageView)theme.GetChildAt(1); //activateElementInfo(element); Popup.activateElementInfo(theme, element); RelativeLayout.LayoutParams paramsOfTimeDisplay = new RelativeLayout.LayoutParams(500, RelativeLayout.LayoutParams.WrapContent); paramsOfTimeDisplay.AddRule(LayoutRules.CenterVertical); paramsOfTimeDisplay.AddRule(LayoutRules.AlignParentLeft); timeDisplay = new EditText(context); timeDisplay.Id = element.Id; timeDisplay.SetTextColor(Color.Black); timeDisplay.LayoutParameters = paramsOfTimeDisplay; timeDisplay.Focusable = false; timeDisplay.SetBackgroundResource(Resource.Drawable.custom_edit_text_color); timeDisplay.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; RelativeLayout.LayoutParams paramsOfClearButton = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsOfClearButton.AddRule(LayoutRules.RightOf, timeDisplay.Id); timeDisplay.Touch += (s, e) => { var handled = false; if (e.Event.Action == MotionEventActions.Down) { createTimeDialog(context); handled = true; } else if (e.Event.Action == MotionEventActions.Up) { handled = true; } e.Handled = handled; }; clearTimeButton = new Button(context); clearTimeButton.Text = "Clear"; clearTimeButton.TextSize = 12; clearTimeButton.SetTextColor(Resources.GetColor(Resource.Color.theme_color)); clearTimeButton.SetBackgroundResource(0); clearTimeButton.LayoutParameters = paramsOfClearButton; clearTimeButton.Click += delegate { clearTime(); }; hour = DateTime.Now.Hour; minute = DateTime.Now.Minute; if (string.IsNullOrEmpty(element.Value)) { timeDisplay.Text = ""; indicatorImage.SetImageResource(0); clearTimeButton.Visibility = ViewStates.Gone; } else { indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); timeDisplay.Text = element.Value; } timeDisplay.TextChanged += (sender, e) => { if (!timeDisplay.Text.Equals("")) { indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); clearTimeButton.Visibility = ViewStates.Visible; } else { indicatorImage.SetImageResource(0); clearTimeButton.Visibility = ViewStates.Gone; } sharedPreferencesEditor.PutBoolean("ReportEditFlag", true); sharedPreferencesEditor.Commit(); }; if (OwnerID == 0 || OwnerID == userID) { if (VerifierID != 0) { clearTimeButton.Enabled = false; clearTimeButton.Visibility = ViewStates.Gone; timeDisplay.Enabled = false; timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey)); if (reportStatus == ReportStatus.Rejected) { clearTimeButton.Enabled = true; clearTimeButton.Visibility = ViewStates.Gone; timeDisplay.Enabled = true; timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.black)); } } else { clearTimeButton.Enabled = true; clearTimeButton.Visibility = ViewStates.Gone; timeDisplay.Enabled = true; timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.black)); } } else { clearTimeButton.Enabled = false; clearTimeButton.Visibility = ViewStates.Gone; timeDisplay.Enabled = false; timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey)); } if (isArcheived) { timeDisplay.Enabled = false; clearTimeButton.Visibility = ViewStates.Gone; timeDisplay.Enabled = false; timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey)); } timeFrame.AddView(timeDisplay); timeFrame.AddView(clearTimeButton); AddView(theme); AddView(timeFrame); SetPadding(45, 10, 45, 20); }
public static void CreationAndExecution() { var repository = Repository.Create(); Report report = Report.Create(repository); report.DisplayName = "Meetings Report : Creation an Execution"; var source = report.Sources.FirstOrDefault(i => i.Name.StartsWith("StatisticsDataSource")); source.MetaData.Tables.Clear(); //Update the data source with the table dbo.Rooms var table = source.AddTable(true); table.Name = "t"; table.Sql = "select r.ID_ROOM as Id, r.ROOM_NAME as Name, m.MEETINGS_COUNT as NumberOfMeetings, " + "m.OCCUPATION_RATE as OccupationRate, m.NUMBER_OF_ATTENDEES as NumberOfAttendees " + "from dbo.Rooms r inner join dbo.Meetings m on r.ID_ROOM = m.ID_ROOM"; table.Refresh(); //Set the source of the default model report.Models[0].SourceGUID = source.GUID; //Add elements to the reports model foreach (var column in table.Columns) { var element = ReportElement.Create(); element.MetaColumnGUID = column.GUID; element.Name = column.Name.Replace("t.", ""); switch (element.Name) { case "Id": element.PivotPosition = PivotPosition.Hidden; break; case "Name": { element.PivotPosition = PivotPosition.Row; element.SerieDefinition = SerieDefinition.Axis; } break; default: { element.PivotPosition = PivotPosition.Data; element.ChartJSSerie = ChartJSSerieDefinition.Bar; } break; } element.Source = source; report.Models[0].Elements.Add(element); } var view = report.Views.Find(x => x.ViewName == "View"); var model = view.Views.Find(x => x.ViewName == "Model"); var container = model.Views.Find(x => x.ViewName == "Model Container"); var chartJS = container.Views.Find(x => x.ViewName == "Chart JS"); chartJS.InitParameters(false); var paramTitle = chartJS.Parameters.Find(x => x.Name == "chartjs_title"); paramTitle.TextValue = "Number of meetings by room"; var paramBarH = chartJS.Parameters.Find(x => x.Name == "chartjs_bar_horizontal"); paramBarH.BoolValue = true; //Then execute it ReportExecution execution = new ReportExecution() { Report = report }; execution.Execute(); while (report.IsExecuting) { System.Threading.Thread.Sleep(100); } string result = execution.GenerateHTMLResult(); Process.Start(result); }
public Rows(XmlNode node, ReportElement parent) : base(node, parent) { }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { MetaColumn column = context.Instance as MetaColumn; ReportElement element = context.Instance as ReportElement; ReportOutput output = context.Instance as ReportOutput; SealServerConfiguration config = context.Instance as SealServerConfiguration; List <string> choices = new List <string>(); choices.Add(""); if (element != null) { if (element.IsNumeric) { addNumericChoices(choices); } else if (element.IsDateTime) { addDateTimeChoices(choices); } else { addStringChoices(choices); } if (!string.IsNullOrEmpty(element.FormatEl) && !choices.Contains(element.FormatEl)) { choices.Add(element.FormatEl); } } else if (column != null) { if (column.Type == ColumnType.Numeric) { addNumericChoices(choices); } else if (column.Type == ColumnType.DateTime) { addDateTimeChoices(choices); } else { addStringChoices(choices); } if (!string.IsNullOrEmpty(column.Format) && !choices.Contains(column.Format)) { choices.Add(column.Format); } } else if (output != null) { choices.Clear(); choices.Add(Repository.SealReportDisplayNameKeyword); choices.Add(Repository.SealReportDisplayNameKeyword + "_{0:yyyy_MM_dd}"); choices.Add(Repository.SealReportDisplayNameKeyword + "_{0:yyyy_MM_dd HH_mm_ss}"); choices.Add(output.Report.ExecutionName); choices.Add(output.Report.ExecutionName + "_{0:yyyy_MM_dd}"); choices.Add(output.Report.ExecutionName + "_{0:yyyy_MM_dd HH_mm_ss}"); choices.Add(output.Name); choices.Add(output.Name + "_{0:yyyy_MM_dd}"); choices.Add(output.Name + "_{0:yyyy_MM_dd HH_mm_ss}"); if (!string.IsNullOrEmpty(output.FileName) && !choices.Contains(output.FileName)) { choices.Add(output.FileName); } } else if (config != null) { if (context.PropertyDescriptor.Name == "NumericFormat") { addNumericChoices(choices); } else if (context.PropertyDescriptor.Name == "DateTimeFormat") { addDateTimeChoices(choices); } else { addStringChoices(choices); } } return(new StandardValuesCollection(choices.ToArray())); }
public Marker(XmlNode node, ReportElement parent) : base(node, parent) { }
public ExternalImageDataHandler(ReportElement reportElement, IBaseImage image) : base(reportElement, image) { }
public DynamicColumns(XmlNode node, ReportElement parent) : base(node, parent) { _container = true; _cell = true; }
public void SetMetaColumn(ReportElement element) { SetMetaColumn(elementTreeView.Nodes, element); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Cursor.Current = Cursors.WaitCursor; try { setContext(context); if (_emailDevice != null) { if (context.PropertyDescriptor.Name == "HelperTestEmail") { _emailDevice.SendTestEmail(); } } else if (_metaConnection != null) { if (context.PropertyDescriptor.Name == "HelperCheckConnection") { _metaConnection.CheckConnection(); } if (context.PropertyDescriptor.Name == "HelperCreateFromExcelAccess") { string accessDriver = "Microsoft Access Driver (*.mdb)"; string excelDriver = "Microsoft Excel Driver (*.xls)"; try { List <string> drivers = Helper.GetSystemDriverList(); string accessDriver2 = "Microsoft Access Driver (*.mdb, *.accdb)"; if (drivers.Contains(accessDriver2)) { accessDriver = accessDriver2; } string excelDriver2 = "Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)"; if (drivers.Contains(excelDriver2)) { excelDriver = excelDriver2; } } catch { } OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Open an Excel or an MS Access File"; dlg.CheckFileExists = true; dlg.CheckPathExists = true; dlg.InitialDirectory = _metaConnection.Source.Repository.RepositoryPath; if (dlg.ShowDialog() == DialogResult.OK) { string ext = Path.GetExtension(dlg.FileName); string driver = ""; if (ext == ".xls" || ext == ".xlsx" || ext == ".xlsm" || ext == ".xlsb") { _metaConnection.DatabaseType = DatabaseType.MSExcel; driver = excelDriver; } else if (ext == ".mdb" || ext == ".accdb") { _metaConnection.DatabaseType = DatabaseType.MSAccess; driver = accessDriver; } else { throw new Exception("Please select an Excel or MS Access file"); } string path = dlg.FileName.Replace(_metaConnection.Source.Repository.RepositoryPath, Repository.SealRepositoryKeyword); _metaConnection.ConnectionString = string.Format(@"Provider=MSDASQL.1;Extended Properties=""DBQ={0};Driver={{{1}}};""", path, driver); setModified(); MessageBox.Show("The connection has been created successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else if (_metaTable != null) { if (context.PropertyDescriptor.Name == "HelperRefreshColumns") { _metaTable.Refresh(); setModified(); initEntity(_metaTable); } if (context.PropertyDescriptor.Name == "HelperCheckTable") { _metaTable.CheckTable(null); } } else if (_metaEnum != null) { if (context.PropertyDescriptor.Name == "HelperRefreshEnum") { _metaEnum.RefreshEnum(); setModified(); } } else if (_metaColumn != null) { if (context.PropertyDescriptor.Name == "HelperCheckColumn") { _metaColumn.MetaTable.CheckTable(_metaColumn); } else if (context.PropertyDescriptor.Name == "HelperCreateEnum") { MetaEnum result = _metaColumn.Source.CreateEnumFromColumn(_metaColumn); _metaColumn.EnumGUID = result.GUID; initEntity(result); setModified(); } else if (context.PropertyDescriptor.Name == "HelperShowValues") { try { Cursor.Current = Cursors.WaitCursor; string result = _metaColumn.MetaTable.ShowValues(_metaColumn); ExecutionForm frm = new ExecutionForm(null); frm.Text = "Show values"; frm.cancelToolStripButton.Visible = false; frm.pauseToolStripButton.Visible = false; frm.logTextBox.Text = result; frm.logTextBox.SelectionStart = 0; frm.logTextBox.SelectionLength = 0; frm.ShowDialog(); } finally { Cursor.Current = Cursors.Default; } } else if (context.PropertyDescriptor.Name == "HelperCreateDrillDates") { var year = _metaColumn.MetaTable.Source.AddColumn(_metaColumn.MetaTable); year.DisplayName = _metaColumn.DisplayName + " Year"; year.Type = ColumnType.DateTime; year.DateTimeStandardFormat = DateTimeStandardFormat.Custom; year.Format = "yyyy"; var month = _metaColumn.MetaTable.Source.AddColumn(_metaColumn.MetaTable); month.DisplayName = _metaColumn.DisplayName + " Month"; month.Type = ColumnType.DateTime; month.DateTimeStandardFormat = DateTimeStandardFormat.Custom; month.Format = "MM/yyyy"; if (_metaColumn.MetaTable.Source.Connection.DatabaseType == DatabaseType.Oracle) { year.Name = string.Format("trunc({0},'year')", _metaColumn.Name); month.Name = string.Format("trunc({0},'month')", _metaColumn.Name); } else if (_metaColumn.MetaTable.Source.Connection.DatabaseType == DatabaseType.MSSQLServer) { year.Name = string.Format("select dateadd(dd, -day({0}) + 1, dateadd(mm, -month({0}) + 1, cast({0} as Date)))", _metaColumn.Name); month.Name = string.Format("select dateadd(dd, -day({0}) + 1, cast({0} as Date))", _metaColumn.Name); } else if (_metaColumn.MetaTable.Source.Connection.DatabaseType == DatabaseType.MSAccess) { year.Name = string.Format("DateSerial(DatePart('yyyy',{0}), 1, 1)", _metaColumn.Name); month.Name = string.Format("DateSerial(DatePart('yyyy',{0}), DatePart('m',{0}), 1)", _metaColumn.Name); } year.DrillChildren.Add(month.GUID); month.DrillChildren.Add(_metaColumn.GUID); initEntity(_metaColumn.MetaTable); setModified(); MessageBox.Show("A 'Year' column and a 'Month' column have been added to the table with a drill hierarchy.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (context.PropertyDescriptor.Name == "HelperCreateSubReport") { Report report = Report.Create(Repository.Create()); //Only on detail view report.Views.Clear(); report.AddView(ReportViewTemplate.ModelDetailName); report.Views[0].InitParameters(true); report.Views[0].Parameters.First(i => i.Name == "restriction_button").BoolValue = false; report.Sources.RemoveAll(i => i.MetaSourceGUID != _metaColumn.Source.GUID); if (report.Sources.Count == 0) { throw new Exception("Unable to create the detail report. Please save the Data Source first..."); } //And one model ReportModel model = report.Models[0]; model.SourceGUID = _metaColumn.Source.GUID; //Add all the element of the table foreach (var el in _metaColumn.MetaTable.Columns.OrderBy(i => i.DisplayOrder)) { ReportElement element = ReportElement.Create(); element.MetaColumnGUID = el.GUID; element.Name = el.Name; element.PivotPosition = (el == _metaColumn ? PivotPosition.Page : PivotPosition.Row); model.Elements.Add(element); } string entityName = _metaColumn.MetaTable.Name; if (entityName.EndsWith("s")) { entityName = entityName.Substring(0, entityName.Length - 1); } string path = Path.Combine(_metaColumn.MetaTable.Source.Repository.SubReportsFolder, Helper.CleanFileName(entityName + " Detail.") + Repository.SealReportFileExtension); path = FileHelper.GetUniqueFileName(path); var sr = new SubReport() { Path = path.Replace(_metaColumn.Source.Repository.RepositoryPath, Repository.SealRepositoryKeyword), Name = entityName + " Detail" }; //And the restriction, try to find out the table primary keys try { DataTable schemaTables = ((OleDbConnection)_metaColumn.Source.GetOpenConnection()).GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, null); Helper.DisplayDataTable(schemaTables); foreach (DataRow row in schemaTables.Rows) { string schema = ""; if (schemaTables.Columns.Contains("TABLE_SCHEMA")) { schema = row["TABLE_SCHEMA"].ToString(); } else if (schemaTables.Columns.Contains("TABLE_SCHEM")) { schema = row["TABLE_SCHEM"].ToString(); } string fullName = (!string.IsNullOrEmpty(schema) ? _metaColumn.Source.GetTableName(schema) + "." : "") + _metaColumn.Source.GetTableName(row["TABLE_NAME"].ToString()); if (row["TABLE_NAME"].ToString() == _metaColumn.MetaTable.Name || fullName == _metaColumn.MetaTable.Name) { var col = _metaColumn.MetaTable.Columns.FirstOrDefault(i => i.Name.ToLower() == row["COLUMN_NAME"].ToString().ToLower() || i.Name.ToLower().EndsWith("." + row["COLUMN_NAME"].ToString().ToLower())); if (col != null) { sr.Restrictions.Add(col.GUID); } else { //not all pk available.... sr.Restrictions.Clear(); break; } } } } catch { } string message = ""; if (sr.Restrictions.Count == 0) { //no PK found, we add the value itself... sr.Restrictions.Add(_metaColumn.GUID); message = "The Sub-Report restriction is based on the Column."; } else { message = "The Sub-Report restrictions are based on the table Primary Keys."; } foreach (var guid in sr.Restrictions) { ReportRestriction restriction = ReportRestriction.CreateReportRestriction(); restriction.MetaColumnGUID = guid; restriction.PivotPosition = PivotPosition.Row; restriction.Prompt = PromptType.Prompt; restriction.Operator = Operator.Equal; model.Restrictions.Add(restriction); if (!string.IsNullOrEmpty(model.Restriction)) { model.Restriction += "\r\nAND "; } model.Restriction += ReportRestriction.kStartRestrictionChar + restriction.GUID + ReportRestriction.kStopRestrictionChar; } model.InitReferences(); report.SaveToFile(path); _metaColumn.SubReports.Add(sr); if (MessageBox.Show(string.Format("A Sub-Report named '{0}' has been created in the dedicated Repository folder.\r\n{1}\r\nDo you want to edit it using a new Report Designer ?", Path.GetFileName(path), message), "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Process.Start(path); } ; _metaColumn.UpdateEditor(); setModified(); } else if (context.PropertyDescriptor.Name == "HelperAddSubReport") { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = string.Format(Repository.SealRootProductName + " Reports files (*.{0})|*.{0}|All files (*.*)|*.*", Repository.SealReportFileExtension); dlg.Title = "Select a Sub-Report having prompted restrictions"; dlg.CheckFileExists = true; dlg.CheckPathExists = true; dlg.InitialDirectory = _metaColumn.Source.Repository.SubReportsFolder; if (dlg.ShowDialog() == DialogResult.OK) { Report report = Report.LoadFromFile(dlg.FileName, _metaColumn.Source.Repository); var sr = new SubReport() { Path = report.FilePath.Replace(_metaColumn.Source.Repository.RepositoryPath, Repository.SealRepositoryKeyword), Name = Path.GetFileNameWithoutExtension(dlg.FileName) }; bool tableOk = false; foreach (var model in report.Models.Where(i => i.Source.MetaSourceGUID == _metaColumn.Source.GUID)) { foreach (var restriction in model.Restrictions.Where(i => i.Prompt != PromptType.None)) { var col = _metaColumn.MetaTable.Columns.FirstOrDefault(i => i.GUID == restriction.MetaColumnGUID); if (col != null) { tableOk = true; } sr.Restrictions.Add(col.GUID); } } if (!tableOk) { throw new Exception("Unable to add this Sub-Report:\r\nThe report does no contain any prompted restriction belonging to the table..."); } _metaColumn.SubReports.Add(sr); MessageBox.Show(string.Format("The Sub-Report named '{0}' has been added with {1} restriction(s).", Path.GetFileName(dlg.FileName), sr.Restrictions.Count), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); _metaColumn.UpdateEditor(); setModified(); } } else if (context.PropertyDescriptor.Name == "HelperOpenSubReportFolder") { Process.Start(_metaColumn.Source.Repository.SubReportsFolder); } } else if (_metaJoin != null) { if (context.PropertyDescriptor.Name == "HelperCheckJoin") { _metaJoin.CheckJoin(); } } else if (_reportView != null) { if (context.PropertyDescriptor.Name == "HelperReloadConfiguration") { _reportView.ReloadConfiguration(); } else if (context.PropertyDescriptor.Name == "HelperResetParameters") { _reportView.InitParameters(true); setModified(); } else if (context.PropertyDescriptor.Name == "HelperResetPDFConfigurations") { _reportView.PdfConfigurations = new List <string>(); _reportView.PdfConverter = null; _reportView.Information = Helper.FormatMessage("The PDF configuration values have been reset"); setModified(); } else if (context.PropertyDescriptor.Name == "HelperResetExcelConfigurations") { _reportView.ExcelConfigurations = new List <string>(); _reportView.ExcelConverter = null; _reportView.Information = Helper.FormatMessage("The Excel configuration values have been reset"); setModified(); } } else if (_reportSchedule != null) { if (HandlerInterface != null && context.PropertyDescriptor.Name == "HelperEditProperties") { HandlerInterface.EditSchedule(_reportSchedule); } else if (context.PropertyDescriptor.Name == "HelperRunTaskScheduler") { Process.Start(Path.Combine(Environment.SystemDirectory, "taskschd.msc"), "/s"); } } else if (_parameter != null) { if (context.PropertyDescriptor.Name == "HelperResetParameterValue") { _parameter.Value = _parameter.ConfigValue; setModified(); } } else if (_security != null) { if (context.PropertyDescriptor.Name == "HelperSimulateLogin") { SecurityUser user = new SecurityUser(_security); user.WebUserName = _security.TestUserName; user.WebPassword = _security.TestPassword; if (_security.TestCurrentWindowsUser) { user.WebPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); } user.Authenticate(); try { Cursor.Current = Cursors.WaitCursor; ExecutionForm frm = new ExecutionForm(null); frm.Text = "Test a login"; frm.cancelToolStripButton.Visible = false; frm.pauseToolStripButton.Visible = false; frm.logTextBox.Text = user.AuthenticationSummary; frm.logTextBox.SelectionStart = 0; frm.logTextBox.SelectionLength = 0; frm.ShowDialog(); } finally { Cursor.Current = Cursors.Default; } } } } finally { Cursor.Current = Cursors.Default; } return(value); }
public GridLines(XmlNode node, ReportElement parent) : base(node, parent) { }
public FormCamera(Context contxt, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus reportStatus, string typeFlag, string type, List <ReportElement> elementList) : base(contxt) { imageDownloadArray = new List <string>(); if (cameraPreviewView == null) { cameraPreviewView = new List <GridView>(); } else { for (int i = 0; i < cameraPreviewView.Count; i++) { if (IMAGE_PREVIEW_Header_ID + element.Id == cameraPreviewView[i].Id || IMAGE_PREVIEW_Info_ID + element.Id == cameraPreviewView[i].Id) { cameraPreviewView.RemoveAt(i); } } } if (cameraIndicatorView == null) { cameraIndicatorView = new List <ImageView>(); } else { for (int i = 0; i < cameraIndicatorView.Count; i++) { if (IMAGE_INDICATOR_ID + element.Id == cameraIndicatorView[i].Id) { cameraIndicatorView.RemoveAt(i); } } } imageJPGFile = new ImageFile(); context = contxt; resource = context.Resources; sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); sharedPreferencesEditor = sharedPreferences.Edit(); InitImageLoader(); LinearLayout imageLay = new LinearLayout(context); imageLay.Orientation = Orientation.Vertical; var addImageButton = new ImageButton(context); addImageButton.Id = element.Id; addImageButton.SetPadding(20, 5, 5, 5); RelativeLayout.LayoutParams paramsForImageButton = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForImageButton.AddRule(LayoutRules.AlignParentLeft); addImageButton.LayoutParameters = paramsForImageButton; GridView gridGallery = new ExpandingGrid(context); RelativeLayout.LayoutParams paramsForgridGallery = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent); paramsForgridGallery.AddRule(LayoutRules.Above, addImageButton.Id); gridGallery.LayoutParameters = paramsForgridGallery; gridGallery.SetNumColumns(6); List <CustomGallery> dataT = new List <CustomGallery>(); string sdCardPath2 = Environment.ExternalStorageDirectory.AbsolutePath; foreach (var VARIABLE in element.Values) { CustomGallery item = new CustomGallery(); item.SdCardPath = "/storage/emulated/0/Checkd/" + VARIABLE.Value; dataT.Add(item); String fileExist = Path.Combine(sdCardPath2, "Checkd/" + VARIABLE.Value); File existFile = new File(fileExist); if (!existFile.Exists()) { imageDownloadArray.Add(VARIABLE.Value); } } MultipleImageDownloader(imageDownloadArray); MiniGallerAdapter adapter = new MiniGallerAdapter(Application.Context, imageLoader); if (dataT.Count != 0) { adapter.AddAll(dataT); } gridGallery.Adapter = adapter; if (typeFlag == "Info") { int artificial_Preview_ID = IMAGE_PREVIEW_Info_ID + element.Id; gridGallery.Id = artificial_Preview_ID; cameraPreviewView.Add(gridGallery); } else { int artificial_header_Preview_ID = IMAGE_PREVIEW_Header_ID + element.Id; gridGallery.Id = artificial_header_Preview_ID; cameraPreviewView.Add(gridGallery); } gridGallery.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args) { List <CustomGallery> items = new List <CustomGallery>(); MiniGallerAdapter adapter3 = (MiniGallerAdapter)gridGallery.Adapter; items = adapter3.getList(); Object obj = items[args.Position].SdCardPath; String value = obj.ToString().Substring(obj.ToString().LastIndexOf('/') + 1); GalleryImagePreview(value); }; imageLay.AddView(gridGallery); imageLay.AddView(addImageButton); RelativeLayout theme = new FormTheme(context, element.Title); LinearLayout btnLayer = new LinearLayout(context); btnLayer.Orientation = Orientation.Vertical; String img = element.Value; String sdCardPath = Environment.ExternalStorageDirectory.AbsolutePath; String filePath = Path.Combine(sdCardPath, "Checkd/" + img); File file = new File(filePath); addImageButton.SetImageResource(Resource.Drawable.android_camera_grey); addImageButton.SetBackgroundResource(0); ImageView indicatorImage = (ImageView)theme.GetChildAt(1); activateElementInfo(element, theme); int artificial_ID = IMAGE_INDICATOR_ID + element.Id; indicatorImage.Id = artificial_ID; cameraIndicatorView.Add(indicatorImage); addImageButton.Click += (sender2, e) => ImageSelectionChoiceDialog(sender2, e, element.Id + "", type); if (!element.Value.Equals("")) { indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } if (ownerID == 0 || ownerID == userID) { if (verifiedID != 0) { addImageButton.Enabled = false; addImageButton.Clickable = false; if (reportStatus == ReportStatus.Rejected) { addImageButton.Enabled = true; addImageButton.Clickable = true; } } else { addImageButton.Enabled = true; addImageButton.Clickable = true; } } else { addImageButton.Enabled = false; addImageButton.Clickable = false; } isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false); if (isArcheived) { addImageButton.Clickable = false; addImageButton.Enabled = false; addImageButton.Click += null; } btnLayer.AddView(theme); btnLayer.AddView(imageLay); btnLayer.SetPadding(45, 10, 45, 20); AddView(btnLayer); }
private void AddToList(List<ReportElement> lista, System.Data.DataRow row) { ReportElement last = null; ReportElement rpt = new ReportElement(); rpt.ID = (long)row["ID"]; rpt.IDElemento = row["IDElemento"].ToString(); rpt.IDTransponder = row["IDTransponder"].ToString(); rpt.Latitud = (double)row["Latitud"]; rpt.Longitud = (double)row["Longitud"]; rpt.NOM_AREA = row["NOM_AREA"].ToString(); rpt.NOM_CAMINO = row["NOM_CAMINO"].ToString(); rpt.NOM_FRENTE = row["NOM_FRENTE"].ToString(); rpt.NOM_PUNTO = row["NOM_PUNTO"].ToString(); rpt.SENTIDO = row["SENTIDO"].ToString(); rpt.TAG_EQUIPO = row["TAG_EQUIPO"].ToString(); rpt.TRANSP_TEMP = (short)row["TRANSP_TEMP"]; rpt.TRANSP_VOLT = (double)row["TRANSP_VOLT"]; rpt.Velocidad = (double)row["Velocidad"]; rpt.DIA_HORA = DateTimeNOMilliseconds((System.DateTime)row["DIA_HORA"]); rpt.Categoria = (short)row["Categoria"]; rpt.Equipo = row["Equipo"].ToString(); rpt.Curso = (double)row["Curso"]; // Determino el estado en funcion de la velocidad rpt.DeterminarEstado(); rpt.ActualizarCamposEnFuncionEstado(); if (lista.Count > 0) last = lista[lista.Count - 1]; else last = null; if (last == null) { lista.Add(rpt); return; } else { if (last.Estado == rpt.Estado) { // Los estados son iguales, por lo tanto añado a este elemento // la informacion de este registro. last.AddInformation(rpt); } else { // Los estados son distintos. Finalizo la informacion del ultimo // elemento y añado el rpt a la lista. last.Finalizar(rpt); lista.Add(rpt); } } // Obtengo el ultimo elemento de la lista. if (lista.Count > 0) { last = lista[lista.Count - 1]; // aca debo determinar si la fila continua permaneciendo en el estado igual al anterior. // si es asi -> if (last.Velocidad != rpt.Velocidad) { if ((last.Velocidad != 0) && (rpt.Velocidad != 0)) { } else { last.DIA_HORA_Final = rpt.DIA_HORA; last = null; } } // si no -> seteo la fecha de fin del estado anterior y add una nueva fila } if (last == null) { lista.Add(rpt); } }
public ReportElementVM(ReportElement element) { _reportElement = element; }
internal void AddInformation(ReportElement rpt) { // la idea es aproximar el esquema de velocidades por trapecios. if (rpt._VelocidadMaxima > _VelocidadMaxima) { _VelocidadMaxima = rpt._VelocidadMaxima; } if (_Estado == EstadosPosibles.Transito) { PuntoActual = ProyectarPunto(rpt.Longitud, rpt.Latitud); ActualizarDistanciaRecorrida(); /*System.Diagnostics.Debug.WriteLine(this.PuntoActual); System.Diagnostics.Debug.WriteLine(this.UltimoPunto); System.Diagnostics.Debug.WriteLine(this.DistanciaRecorrida);*/ } }
public FormPlusMinusCounter(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus) : base(context) { resource = context.Resources; contextx = context; OwnerID = ownerID; VerifierID = verifiedID; Popup = new InformationPopup(context); reportStatus = Reportstatus; if (element.Value == "") { element.Value = "0"; } theme = new FormTheme(context, element.Title); RelativeLayout countHolder = new RelativeLayout(context); Orientation = Orientation.Vertical; sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); sharedPreferencesEditor = sharedPreferences.Edit(); RelativeLayout stepperlayout = new RelativeLayout(context); stepperlayout.FocusableInTouchMode = true; stepperlayout.Focusable = true; stepperlayout.SetPadding(0, 5, 0, 5); RelativeLayout.LayoutParams paramsForStepperLayout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent); paramsForStepperLayout.AddRule(LayoutRules.CenterHorizontal); stepperlayout.LayoutParameters = paramsForStepperLayout; //causes layout update ImageButton negativeButton = new ImageButton(context); negativeButton.SetImageResource(0); negativeButton.SetBackgroundResource(Resource.Drawable.decrement); ImageButton positiveButton = new ImageButton(context); positiveButton.SetImageResource(0); positiveButton.SetBackgroundResource(Resource.Drawable.increment); negativeButton.Click += (sender3, e) => decreaseCount(sender3, e, element.Info); positiveButton.Click += (sender4, e) => increaseCount(sender4, e, element.Info); counterEditText = new EditText(context); counterEditText.Id = element.Id; counterEditText.Text = element.Value; counterEditText.TextSize = 25; counterEditText.InputType = Android.Text.InputTypes.ClassNumber; counterEditText.SetTextColor(Color.ParseColor((resource.GetString(Resource.Color.green_primary)))); counterEditText.Gravity = GravityFlags.Center; counterEditText.SetBackgroundResource(Resource.Drawable.back); counterEditText.SetPadding(10, 15, 10, 10); counterEditText.SetMaxWidth(350); counterEditText.SetMinWidth(220); counterEditText.SetMinimumWidth(220); counterEditText.SetMaxHeight(200); counterEditText.SetMinHeight(100); counterEditText.SetMinimumHeight(100); //counterEditText.Focusable = false; RelativeLayout.LayoutParams paramsForSliderCounter = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForSliderCounter.AddRule(LayoutRules.CenterInParent); counterEditText.LayoutParameters = paramsForSliderCounter; RelativeLayout.LayoutParams paramsForNegative = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForNegative.AddRule(LayoutRules.LeftOf, counterEditText.Id); paramsForNegative.AddRule(LayoutRules.AlignBottom, counterEditText.Id); paramsForNegative.AddRule(LayoutRules.AlignTop, counterEditText.Id); negativeButton.LayoutParameters = paramsForNegative; negativeButton.SetMinimumHeight(100); negativeButton.SetMaxHeight(150); negativeButton.SetMinimumWidth(200); negativeButton.SetMaxHeight(100); RelativeLayout.LayoutParams paramsForPositive = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForPositive.AddRule(LayoutRules.RightOf, counterEditText.Id); paramsForPositive.AddRule(LayoutRules.AlignBottom, counterEditText.Id); paramsForPositive.AddRule(LayoutRules.AlignTop, counterEditText.Id); positiveButton.LayoutParameters = paramsForPositive; positiveButton.SetMinimumHeight(100); positiveButton.SetMaxHeight(150); positiveButton.SetMinimumWidth(200); positiveButton.SetMaxHeight(100); ImageView indicatorImageView = (ImageView)theme.GetChildAt(1); indicatorImageView.SetImageResource(0); Popup.activateElementInfo(theme, element); isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false); counterEditText.TextChanged += (sender, e) => { if (!counterEditText.Text.Equals("0")) { indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); sharedPreferencesEditor.PutBoolean("ReportEditFlag", true); sharedPreferencesEditor.Commit(); } else { indicatorImageView.SetImageResource(0); } }; //when opening a Draft or Archive if (!counterEditText.Text.Equals("0")) { indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } if (OwnerID == 0 || OwnerID == userID) { if (VerifierID != 0) { negativeButton.Enabled = false; positiveButton.Enabled = false; counterEditText.Enabled = false; if (reportStatus == ReportStatus.Rejected) { negativeButton.Enabled = true; positiveButton.Enabled = true; counterEditText.Enabled = true; } } else { negativeButton.Enabled = true; positiveButton.Enabled = true; counterEditText.Enabled = true; } } else { negativeButton.Enabled = false; positiveButton.Enabled = false; counterEditText.Enabled = false; } if (isArcheived) { negativeButton.Enabled = false; positiveButton.Enabled = false; counterEditText.Enabled = false; } stepperlayout.AddView(negativeButton); stepperlayout.AddView(counterEditText); stepperlayout.AddView(positiveButton); AddView(theme); AddView(stepperlayout); SetPadding(45, 10, 45, 20); }