private void Initialization() { if (tableDataSource == null) { DataTable filterRefTable = DataSourceHelper.GetDataTable(DataSource); // Initialization SessionWorker if (SessionWorker == null) { var sw = new SessionWorker { Key = Guid.NewGuid().ToString() }; sw.SetSession(HttpContext.Current.Session); sw.Object = filterRefTable.DataSet; SessionWorker = sw; } // Initialization tableDataSource Type tableAdapterType = TableAdapterTools.GetTableAdapterType(filterRefTable.GetType()); tableDataSource = new TableDataSource { ID = "tableDataSource_ID", TypeName = tableAdapterType.FullName, SelectMethod = this._storage.SelectMethod, FillType = TableDataSourceFillType.ParametersNotChanged, SessionWorker = this.SessionWorker, SetFilterByCustomConditions = false, }; tableDataSource.View.CustomConditions.AddRange(_storage.CustomConditions); } }
private void Page_OnPreLoad(object sender, EventArgs e) { if (clearSessionOnNotIsPostBack && !Page.IsPostBack) { SessionWorker.RemoveObject(); sessionWorker = null; } }
protected override void AddControls(BaseReportCondition[] conditions) { foreach (var condition in conditions) { var supportSessionWorker = condition.ColumnFilter as ISupportSessionWorker; if (supportSessionWorker == null) { continue; } var dataSource = GetDataTable(condition.ColumnFilter.GetStorage()); if (dataSource == null || _session == null) { supportSessionWorker.SessionWorker = _sessionWorker; } else { if (_dataSetSessions.ContainsKey(dataSource.DataSet)) { supportSessionWorker.SessionWorker = _dataSetSessions[dataSource.DataSet]; } else { string key = Plugin.GetType().Name + "_" + dataSource.DataSet.DataSetName; int i = 0; while (_sessionKeys.Contains(key)) { key = Plugin.GetType().Name + "_" + dataSource.DataSet.DataSetName + i++; } var sWorker = new SessionWorker(); sWorker.SetSession(_session); sWorker.Key = key; if (sWorker.Object == null || sWorker.Object.GetType() != dataSource.DataSet.GetType()) { sWorker.Object = dataSource.DataSet; } _sessionKeys.Add(key); _dataSetSessions.Add(dataSource.DataSet, sWorker); supportSessionWorker.SessionWorker = sWorker; } } } // _filters.AddRange(conditions); _requireNewControls = true; }
public async Task <IActionResult> Post() { FileInfo source = null; FileInfo filter = null; repository = WorkSessionRepository.GetRepo(); try { FileInfo[] fileInfos = await ReadFileStream(); if (fileInfos.Length == 0) { return(new NoContentResult()); } source = fileInfos[0]; if (fileInfos.Length == 1) { return(new NoContentResult()); } filter = fileInfos[1]; ModelService environment = SessionWorker.GetNewEnvironment(); IWorkSession sessionResult = environment .GetNew <ISessionWorker>(environment) .Run(source.FullName, filter.FullName) .GetResult(); IWorkSession result = repository.InsertNew(sessionResult); FileInfo resultFileInfo = new FileInfo(result.ResultFileName); List <string[]> content = Consume(resultFileInfo); CleanUploads(fileInfos); return(new OkObjectResult(content.ToArray())); } catch (HttpRequestException) { return(new NoContentResult()); } }
protected void swReport_SessionWorkerInit(object sender, SessionWorkerArgs e) { Type type = null; if (webReportManager.Plugin != null && webReportManager.Plugin.Table != null) { type = webReportManager.Plugin.Table.DataSet.GetType(); } var sessionWorker = new SessionWorker(Page, swReport.Key); var obj = sessionWorker.Object; if (type == null) { sessionWorker.RemoveObject(); } if (((obj != null && obj.GetType() != type) || obj == null) && type != null) { sessionWorker.Object = Activator.CreateInstance(type); } e.SessionWorker = sessionWorker; }
//static string DefaultOutputFile = "output.csv"; static void Main(string[] args) { //Il primo file CSV conterrà il dataset con le informazioni relative ad una serie di accrediti, //Il file CSV del dataset avrà N righe, puoi supporre N < 1000. if (args.Length > 0) { System.Console.WriteLine("File accrediti: " + args[0]); } //Il secondo file CSV avrà un unico campo: //Il file CSV con le estrazioni avrà M righe, puoi supporre M < 100. if (args.Length > 1) { System.Console.WriteLine("File elaborazioni: " + args[1]); } if (args.Length < 2) { System.Console.WriteLine("Previsti due file in input come parametri, forniti: " + args.Length); return; } // Il software dovrà aiutare l'utente a processare una serie di dati derivanti da alcune // transazioni bancarie; in particolare, sarà necessario leggere alcuni file contenenti // i riepiloghi giornalieri dei bonifici effettuati in alcune banche, e creare alcuni dati // a partire da questi. ModelService environment = SessionWorker.GetNewEnvironment(); IWorkSession result = environment .GetNew <ISessionWorker>(environment) .Run(args[0], args[1]) .GetResult(); FileInfo fileInfo = new FileInfo(result.ResultFileName); System.Console.WriteLine("File disponibile: " + fileInfo.FullName); }
protected SessionWorker InitSessionWorker() { SessionWorkerArgs args = new SessionWorkerArgs(); OnSessionWorkerInit(args); if (args.SessionWorker == null) { SessionWorker worker = new SessionWorker(Page, Key); if (!string.IsNullOrEmpty(typeName)) { Type type = BuildManager.GetType(typeName, false, true); if (type != null) { ConstructorInfo info = type.GetConstructor(new Type[] {}); if (info == null) { throw new Exception(string.Format("“ип '{0}' не содержит пустого конструктора. ({1})", type.FullName, ID)); } worker.Object = info.Invoke(new object[0]); } } else { throw new Exception("SessionWorker не инициализирован"); } return(worker); } if (string.IsNullOrEmpty(args.SessionWorker.Key)) { args.SessionWorker.Key = Key; } if (args.SessionWorker.Session == null) { args.SessionWorker.SetSession(Page.Session); } return(args.SessionWorker); }
public void RefreshSessionWorker() { sessionWorker = null; InitSessionWorker(); }
protected override void CreateChildControls() { base.CreateChildControls(); // Ensure ColumnFilterStorage if (ColumnFilterStorage == null) { throw new NullReferenceException("ColumnFilterStorage must be specified"); } // Create controls hierarchy table = new Table(); Controls.Add(table); table.Width = Width != Unit.Empty ? Width : Unit.Percentage(100); table.Style["table-layout"] = "fixed"; //table.CssClass = "ms-gridtext"; filterRow = new TableRow(); filterRow.Cells.Add(new TableCell()); filterRow.Cells.Add(new TableCell()); int countItems; if ((ColumnFilterStorage.IsRefBound && ((ColumnFilterStorage.AvailableFilters & ColumnFilterType.Between) == 0)) || ColumnFilterStorage.DataType == typeof(String)) { countItems = 1; filterRow.Cells.Add(new TableCell { ColumnSpan = 2, Width = Unit.Percentage(100) }); filterRow.Cells.Add(new TableCell { ID = "fillEmpty" }); } else { countItems = 2; filterRow.Cells.Add(new TableCell { Width = Unit.Pixel(150) }); filterRow.Cells.Add(new TableCell { Width = Unit.Pixel(150) }); filterRow.Cells.Add(new TableCell { ID = "fillEmpty" }); } dropDownList = new DropDownList(); dropDownList.ID = "dropDownListID"; filterRow.Cells[1].Controls.Add(dropDownList); controls = new WebControl[2]; for (int i = 0; i != countItems; i++) { if (ColumnFilterStorage.IsRefBound) { DataTable filterRefTable = DataSourceHelper.GetDataTable(ColumnFilterStorage.RefDataSource); if (filterRefTable != null) { Type tableAdapterType = TableAdapterTools.GetTableAdapterType(filterRefTable.GetType()); tableDataSource = new TableDataSource(); tableDataSource.ID = String.Format("tableDataSource{0}_ID", i); tableDataSource.TypeName = tableAdapterType.FullName; tableDataSource.SelectMethod = ColumnFilterStorage.SelectMethod; tableDataSource.FillType = TableDataSourceFillType.ParametersNotChanged; if (SessionWorker == null) { SessionWorker sw = new SessionWorker(this.Page, Guid.NewGuid().ToString()); sw.Object = filterRefTable.DataSet; SessionWorker = sw; } tableDataSource.SessionWorker = SessionWorker; tableDataSource.SetFilterByCustomConditions = false; tableDataSource.View.CustomConditions.AddRange(ColumnFilterStorage.CustomConditions); tableDataSource.HistoricalCountKeys = 0; if (filterRefTable.Columns.IndexOf("dateEnd") != -1 && filterRefTable.Columns.IndexOf("dateStart") != -1) { tableDataSource.ShowHistoricalData = true; } filterRow.Cells[2 + i].Controls.Add(tableDataSource); // This is only for compability with SMSES ColumnFilterStorage.RefTableRolledIn = (bool)(DataSetResourceManager.GetTableExtProperty(filterRefTable, TableExtProperties.ROLLED_IN) ?? false); } else { ColumnFilterStorage.RefTableRolledIn = false; } if (String.IsNullOrEmpty(ColumnFilterStorage.ValueColumn) || String.IsNullOrEmpty(ColumnFilterStorage.DisplayColumn)) { throw new Exception("FILTER_REF_DISPLAY_COLUMN and FILTER_REF_VALUE_COLUMN attribute must be specified"); } if (!string.IsNullOrEmpty(CheckedFilterCondition)) { checkBoxForFilterCondition = new CheckBox { ID = "checkBoxForFilter", Text = CheckedFilterConditionTooltip, AutoPostBack = true, TextAlign = TextAlign.Right, }; checkBoxForFilterCondition.CheckedChanged += OnCheckBoxForFilterConditionOnCheckedChanged; } if (ColumnFilterStorage.RefTableRolledIn) { LookupTextBox lookupTextBox = new LookupTextBox(); lookupTextBox.DataSource = tableDataSource; lookupTextBox.DataTextField = ColumnFilterStorage.DisplayColumn; lookupTextBox.DataValueField = ColumnFilterStorage.ValueColumn; String Relation = (String)(DataSetResourceManager.GetTableExtProperty(filterRefTable, TableExtProperties.TREE_REF_RELATION) ?? ""); if (!String.IsNullOrEmpty(Relation)) { String dataDisableRowField = (String)(DataSetResourceManager.GetTableExtProperty(filterRefTable, TableExtProperties.TREE_ALLOW_FIELD)); lookupTextBox.GridTreeMode = true; if (!string.IsNullOrEmpty(dataDisableRowField)) { lookupTextBox.DataDisableRowField = dataDisableRowField; } } controls[i] = lookupTextBox; } else { var lookupList = new DropDownListExt(); if (tableDataSource != null) { lookupList.DataSource = tableDataSource; tableDataSource.FillType = TableDataSourceFillType.Always; } else { lookupList.DataSource = ColumnFilterStorage.RefDataSource; } lookupList.DataTextField = ColumnFilterStorage.DisplayColumn; lookupList.DataValueField = ColumnFilterStorage.ValueColumn; lookupList.IncludeNullItem = true; lookupList.DataBind(); controls[i] = lookupList; } } else if (ColumnFilterStorage.DataType == typeof(Int64) || ColumnFilterStorage.DataType == typeof(Int32) || ColumnFilterStorage.DataType == typeof(Int16) || ColumnFilterStorage.DataType == typeof(Byte) || ColumnFilterStorage.DataType == typeof(Double) || ColumnFilterStorage.DataType == typeof(Decimal) || ColumnFilterStorage.DataType == typeof(Single) || ColumnFilterStorage.DataType == typeof(String)) { var textBox = new TextBox(); controls[i] = textBox; if (new Type[] { typeof(Int64), typeof(Int32), typeof(Int16) }.Contains(ColumnFilterStorage.DataType)) { textBox.Attributes["type"] = "number"; } if (TextBoxHeight != null) { textBox.Height = TextBoxHeight.Value; textBox.TextMode = TextBoxMode.MultiLine; } } else if (ColumnFilterStorage.DataType == typeof(DateTime)) { DatePicker datePicker = new DatePicker(); switch (ColumnFilterStorage.DateTimeFormat) { case "{0:d}": datePicker.Mode = DatePickerMode.Date; break; case "{0:t}": datePicker.Mode = DatePickerMode.Time; break; case "{0:f}": datePicker.Mode = DatePickerMode.DateTime; break; } datePicker.PopupBehaviorParentNode = PopupBehaviorParentNode; datePicker.Width = Unit.Pixel(150); controls[i] = datePicker; ((DatePicker)controls[i]).AutoPostBack = postBack; } else if (ColumnFilterStorage.DataType == typeof(Boolean)) { DropDownList list = new DropDownList(); list.Items.Add(new ListItem(LookupControlsResources.STrue, true.ToString().ToLower())); list.Items.Add(new ListItem(LookupControlsResources.SFalse, false.ToString().ToLower())); controls[i] = list; } else { throw new Exception(String.Format("Data type not supported: {0}", ColumnFilterStorage.DataType.Name)); } controls[i].ID = String.Format("control{0}ID", i); filterRow.Cells[2 + i].Controls.Add(controls[i]); controls[i].Width = Unit.Percentage(100); } // Setup controls' properties filterRow.Cells[0].Text = ColumnFilterStorage.Caption; //filterRow.Cells[0].BackColor = Color.DarkTurquoise; //filterRow.Cells[1].BackColor = Color.DarkSeaGreen; //filterRow.Cells[2].BackColor = Color.Salmon; //filterRow.Cells[3].BackColor = Color.DodgerBlue; filterRow.Cells[0].Style["padding-right"] = "6px"; filterRow.Cells[1].Style["padding-right"] = "6px"; filterRow.Cells[2].Style["padding-right"] = "6px"; filterRow.Cells[2].Style["display"] = "none"; if (filterRow.Cells.Count > 3 && filterRow.Cells[3].ID != "fillEmpty") { filterRow.Cells[3].Style["padding-right"] = "6px"; filterRow.Cells[3].Style["display"] = "none"; } filterRow.Cells[0].Width = Unit.Pixel(170); filterRow.Cells[1].Width = Unit.Pixel(140); filterRow.Cells[0].HorizontalAlign = HorizontalAlign.Right; dropDownList.Width = Unit.Percentage(100); dropDownList.AutoPostBack = postBack; dropDownList.EnableViewState = false; foreach (ColumnFilterType columnFilterType in Enum.GetValues(typeof(ColumnFilterType))) { if (EnumHelper.Contains(columnFilterType, ColumnFilterStorage.AvailableFilters)) { ListItem ListItem = new ListItem(); ListItem.Value = Convert.ToInt64(columnFilterType).ToString(); if (CustomColumnFilterTypeCaptions != null && CustomColumnFilterTypeCaptions.ContainsKey(columnFilterType)) { ListItem.Text = CustomColumnFilterTypeCaptions[columnFilterType]; } else { ListItem.Text = columnFilterType.GetFilterTypeCaption(); } dropDownList.Items.Add(ListItem); } } dropDownList.Enabled = dropDownList.Items.Count > 1; if (checkBoxForFilterCondition != null) { var tableRow = new TableRow(); table.Rows.Add(tableRow); tableRow.Cells.Add(new TableCell { Width = filterRow.Cells[0].Width, Height = new Unit(24, UnitType.Pixel), }); tableRow.Cells.Add(new TableCell { Width = filterRow.Cells[1].Width, Height = new Unit(24, UnitType.Pixel), }); var tableCell = new TableCell { Width = filterRow.Cells[2].Width, ColumnSpan = 2, Height = new Unit(24, UnitType.Pixel), }; tableRow.Cells.Add(tableCell); tableCell.Controls.Add(checkBoxForFilterCondition); checkBoxForFilterCondition.Style["position"] = "relative"; checkBoxForFilterCondition.Style["top"] = "6px"; tableRow.Cells[0].Style["padding-right"] = "6px"; tableRow.Cells[1].Style["padding-right"] = "6px"; tableRow.Cells[2].Style["padding-right"] = "6px"; } table.Rows.Add(filterRow); }