public void GetProducts_Should_GetNameColumnOnly() { var allTableColumns = _productTableColumnRepository.GetAllViewColumns(); var nameTableColumn = allTableColumns.FirstOrDefault( tc => tc.Identifier.AdditionalData.Contains("Name")); nameTableColumn.ShouldNotBeNull(); var nameIdentifier = nameTableColumn.Identifier; var pageNumber = 1; var pageSize = 10; var tableInput = new TableInput { ColumnsRequested = new List <TableColumnIdentifier> { nameIdentifier }, PageNumber = pageNumber, PageSize = pageSize }; var tableOutput = _productService.GetProducts(tableInput); tableOutput.Columns.Count.ShouldBe(1); tableOutput.Columns[0].Identifier.AdditionalData.ShouldContain("Name"); }
public TableOutput GetProducts(TableInput input) { return(_productTableBuilder .ColumnRequested(input.ColumnsRequested) .FilterBy(input.Filters) .PageNumber(input.PageNumber) .PageSize(input.PageSize) .IsSortAscending(input.SortDirectionAsc) .SortBy(input.SortBy) .Build()); }
public IActionResult Courses(TableInput option) { var offset = option.start; var alldata = _courseService.GetAllCourses(offset); var count = alldata.Count; List <Object[]> result = alldata.CourseList.Select(x => { return(new Object[] { x.Author, x.Name, x.Duration, x.Id }); }).ToList(); return(Json(new { draw = option.draw, data = result, recordsTotal = count, recordsFiltered = count })); }
// Use this for initialization void Start() { nowTime = limitTime; score = 0; _sectionDetectore = GameObject.Find("Detectore").GetComponent <SectionDetectore>(); _tableInput = GameObject.Find("Input").GetComponent <TableInput>(); _displayManager = GameObject.Find("Canvas").GetComponent <DisplayManager>(); _soundManager = GameObject.Find("SoundManager").GetComponent <SoundManager>(); _soundManager.PlayBGM(); isUpdate = true; StartCoroutine("sleep", 1); BeginQuiz(); }
public void GetProducts_Should_SortNameDirectionAsc() { var pageNumber = 1; var pageSize = 10; var tableInput = new TableInput { SortBy = new TableColumnIdentifier("Name", TableColumnType.Property), SortDirectionAsc = true, PageNumber = pageNumber, PageSize = pageSize }; var tableOutput = _productService.GetProducts(tableInput); var firstRowName = tableOutput.Rows.First().Cells[0]; var lastRowName = tableOutput.Rows.Last().Cells[0]; lastRowName.ShouldBeGreaterThan(firstRowName); }
public void GetProducts_Should_GetProductsTableOutput() { var pageNumber = 1; var pageSize = 10; var tableInput = new TableInput { PageNumber = pageNumber, PageSize = pageSize }; var tableOutput = _productService.GetProducts(tableInput); tableOutput.ShouldNotBeNull(); tableOutput.Rows.Count.ShouldBeLessThanOrEqualTo(pageSize); tableOutput.Rows.Count.ShouldBeGreaterThan(0); tableOutput.Columns.Count.ShouldBeGreaterThan(0); tableOutput.TotalProductOffersCount.ShouldBeGreaterThan(0); }
protected void initcontrol() { for (int i = 0; i < dtparam.Rows.Count; i++) { string FieldNm = dtparam.Rows[i]["FIELDNM"].ToString(); string FieldType = dtparam.Rows[i]["FIELDTYPE"].ToString(); string FieldReff = dtparam.Rows[i]["FIELDREFF"].ToString(); WebControl oCtrl = (WebControl)TableInput.FindControl(FieldNm); if (FieldType == "auto") { oCtrl.BorderStyle = BorderStyle.None; } else { staticFramework.retrieveschema(dtparamschema, FieldNm, oCtrl); } if (oCtrl is DevExpress.Web.ASPxComboBox) { reffcascade((DevExpress.Web.ASPxComboBox)oCtrl, FieldReff); } } }
/// <summary> /// Landing Page /// </summary> /// <returns></returns> public ActionResult Index(string sortBy, string sortDirection, string pageNumber, string pageSize) { TableColumnIdentifier sortByidentifier = null; var sortDirectionAsc = true; var allProductViewColumns = _productColumnRepository.GetAllViewColumns(); if (!string.IsNullOrEmpty(sortBy)) { sortByidentifier = allProductViewColumns .First( col => col.GetColumnDefinition().Identifier.AdditionalData == sortBy) .GetColumnDefinition().Identifier; } if (sortDirection != null) { sortDirectionAsc = String.CompareOrdinal(sortDirection, "Desc") != 0; } pageNumber = pageNumber ?? "1"; pageSize = pageSize ?? "5"; var tableInput = new TableInput { PageNumber = int.Parse(pageNumber), PageSize = int.Parse(pageSize), SortDirectionAsc = sortDirectionAsc, SortBy = sortByidentifier }; var tableOutput = _productService.GetProducts(tableInput); var productOutput = new ProductOutput() { Input = tableInput, Output = tableOutput, AllColumns = allProductViewColumns }; return(View(productOutput)); }
public void GetProducts_Should_FilterName(string nameToFilter) { var allTableColumns = _productTableColumnRepository.GetAllViewColumns(); var nameTableColumn = allTableColumns.FirstOrDefault( tc => tc.Identifier.AdditionalData.Contains("Name")); nameTableColumn.ShouldNotBeNull(); var nameIdentifier = nameTableColumn.Identifier; var nameAvedaFilter = new TableColumnFilter { FilterFreeText = new FilterFreeText { StringValue = nameToFilter, Type = FilterFreeTextType.Contains }, ColumnIdentifier = nameIdentifier }; var pageNumber = 1; var pageSize = 10; var tableInput = new TableInput { Filters = new List <TableColumnFilter> { nameAvedaFilter }, PageNumber = pageNumber, PageSize = pageSize }; var tableOutput = _productService.GetProducts(tableInput); tableOutput.Rows.Count.ShouldBe(1); var avedaRow = tableOutput.Rows.First(); avedaRow.Cells[0].ShouldBe(nameToFilter); }
public void retrievepending(string TemporaryID) { DataTable dtretrieve = conn.GetDataTable( sqlpending1 + " AND Y.TEMPORARYID=@1" , new object[] { TemporaryID }, dbtimeout); for (int i = 0; i < dtparam.Rows.Count; i++) { string FieldNm = dtparam.Rows[i]["FIELDNM"].ToString(); string FieldReff = dtparam.Rows[i]["FIELDREFF"].ToString(); bool FieldKey = false; if (dtparam.Rows[i]["FIELDKEY"].ToString() != "") { FieldKey = (bool)dtparam.Rows[i]["FIELDKEY"]; } bool isAuto = dtparam.Rows[i]["FIELDAUTO"].ToString().Trim() != ""; string AutoPrefix = "", AutoSufix = ""; if (dtparamschema.Columns[FieldNm].DataType.ToString() == "System.String" && //autoprefix and autosuffix must not be used to a non string fieldtype isAuto == false && FieldReff == "") //and non-auto and non refferential field { AutoPrefix = dtparam.Rows[i]["AUTOPREFIX"].ToString(); AutoSufix = dtparam.Rows[i]["AUTOSUFIX"].ToString(); } bool locked = false; if (dtparam.Rows[i]["LOCKED"].ToString() != "") { locked = (bool)dtparam.Rows[i]["LOCKED"]; } WebControl oCtrl = (WebControl)TableInput.FindControl(FieldNm); if (oCtrl is ASPxComboBox) { reffcascade((ASPxComboBox)oCtrl, FieldReff); } if (AutoPrefix.Length > 0 || AutoSufix.Length > 0) { string value = null; if (dtretrieve.Rows.Count > 0) { value = dtretrieve.Rows[0][FieldNm].ToString(); } if (value.Length > AutoPrefix.Length + AutoSufix.Length) { value = value.Substring(AutoPrefix.Length, value.Length - AutoSufix.Length - AutoPrefix.Length); } staticFramework.retrieve(value, oCtrl); } else { staticFramework.retrieve(dtretrieve, FieldNm, oCtrl); } if (FieldKey) { HtmlInputHidden hCtrl = (HtmlInputHidden)TableInput.FindControl("h_" + FieldNm); staticFramework.retrieve(dtretrieve, FieldNm, hCtrl); } if (locked) { HtmlInputHidden lCtrl = (HtmlInputHidden)TableInput.FindControl("l_" + FieldNm); staticFramework.retrieve(dtretrieve, FieldNm, lCtrl); } } }
/// <summary> /// Creates or updates a glue table for the new CUR files. This makes sure any changes in the columns are captured /// and applied to the table. This will end up creating a new table for each billing period. /// </summary> /// <param name="manifest"></param> /// <param name="context"></param> /// <returns>The table name</returns> private static async Task <string> CreateOrUpdateGlueTable(Manifest manifest, ILambdaContext context) { if (String.IsNullOrEmpty(_GlueDatabaseName)) { string Message = "No Glue database name defined, cannot create a table."; context.LogWarning(Message); await SNSNotify(Message, context); return(String.Empty); } string Date = manifest.BillingPeriod.Start.ToString("yyyy-MM-dd"); string Format = manifest.ContentType.ToLower().Substring(manifest.ContentType.LastIndexOf("/") + 1); Dictionary <string, string> Parameters; StorageDescriptor Descriptor; switch (Format) { case "csv": { Parameters = new Dictionary <string, string>() { { "EXTERNAL", "TRUE" }, { "skip.header.line.count", "1" }, { "columnsOrdered", "true" }, { "compressionType", manifest.Compression.ToString().ToLower() }, { "classification", manifest.ContentType.ToLower().Substring(manifest.ContentType.LastIndexOf("/") + 1) } }; Descriptor = new StorageDescriptor() { Columns = manifest.Columns.Select(x => new Amazon.Glue.Model.Column() { Name = $"{x.Category}/{x.Name}", Type = "string" }).ToList(), InputFormat = "org.apache.hadoop.mapred.TextInputFormat", OutputFormat = "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", Location = $"s3://{_DestinationBucket}/{GetDestinationPrefix(manifest)}", SerdeInfo = new SerDeInfo() { Name = "OpenCSVSerde", SerializationLibrary = "org.apache.hadoop.hive.serde2.OpenCSVSerde", Parameters = new Dictionary <string, string>() { { "escapeChar", "\\" }, { "quoteChar", "\"" }, { "separatorChar", "," } } } }; break; } case "parquet": { Parameters = new Dictionary <string, string>() { { "EXTERNAL", "TRUE" }, { "compressionType", manifest.Compression.ToString().ToLower() }, { "classification", manifest.ContentType.ToLower().Substring(manifest.ContentType.LastIndexOf("/") + 1) } }; Descriptor = new StorageDescriptor() { Columns = manifest.Columns.Select(x => new Amazon.Glue.Model.Column() { Name = x.Name, Type = (!String.IsNullOrEmpty(x.Type) ? x.Type.ToLower() : "string") }).ToList(), InputFormat = "org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat", OutputFormat = "org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat", Location = $"s3://{_DestinationBucket}/{GetDestinationPrefix(manifest)}", SerdeInfo = new SerDeInfo() { Name = "ParquetHiveSerDe", SerializationLibrary = "org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe", Parameters = new Dictionary <string, string>() { { "serialization.format", "1" } } } }; break; } default: { string Message = $"Failed to create or update the database {_GlueDatabaseName} table. Unknown format type ${manifest.ContentType}."; await SNSNotify(Message, context); return(String.Empty); } } // The updated table input for this particular CUR TableInput TblInput = new TableInput() { Description = Date, Name = Date, TableType = "EXTERNAL_TABLE", Parameters = Parameters, StorageDescriptor = Descriptor }; // Make sure the database exists GetDatabaseRequest GetDb = new GetDatabaseRequest() { Name = _GlueDatabaseName }; try { await _GlueClient.GetDatabaseAsync(GetDb); context.LogInfo($"Database {_GlueDatabaseName} already exists."); } catch (EntityNotFoundException) { try { CreateDatabaseRequest DbRequest = new CreateDatabaseRequest() { DatabaseInput = new DatabaseInput() { Name = _GlueDatabaseName } }; CreateDatabaseResponse Response = await _GlueClient.CreateDatabaseAsync(DbRequest); if (Response.HttpStatusCode == HttpStatusCode.OK) { context.LogInfo($"Successfully CREATED database {_GlueDatabaseName}."); } else { context.LogError($"Failed to CREATE database with status code {(int)Response.HttpStatusCode}."); } } catch (Exception ex) { string Message = $"Failed to create the database {_GlueDatabaseName}."; context.LogError(Message, ex); await SNSNotify(Message + $" {ex.Message}", context); return(String.Empty); } } // Make sure the table exists GetTableRequest GetTable = new GetTableRequest() { DatabaseName = _GlueDatabaseName, Name = Date }; try { GetTableResponse TableResponse = await _GlueClient.GetTableAsync(GetTable); UpdateTableRequest UpdateReq = new UpdateTableRequest() { TableInput = TblInput, DatabaseName = _GlueDatabaseName }; UpdateTableResponse Response = await _GlueClient.UpdateTableAsync(UpdateReq); if (Response.HttpStatusCode == HttpStatusCode.OK) { context.LogInfo($"Successfully UPDATED table {TblInput.Name} in database {_GlueDatabaseName}."); return(TblInput.Name); } else { string Message = $"Failed to UPDATE table with status code {(int)Response.HttpStatusCode}."; context.LogError(Message); await SNSNotify(Message, context); return(String.Empty); } } catch (EntityNotFoundException) // This means the table does not exist { CreateTableRequest CreateReq = new CreateTableRequest() { TableInput = TblInput, DatabaseName = _GlueDatabaseName }; CreateTableResponse Response = await _GlueClient.CreateTableAsync(CreateReq); if (Response.HttpStatusCode == HttpStatusCode.OK) { context.LogInfo($"Successfully CREATED table {TblInput.Name} in database {_GlueDatabaseName}."); return(TblInput.Name); } else { string Message = $"Failed to CREATE table with status code {(int)Response.HttpStatusCode}."; context.LogError(Message); await SNSNotify(Message, context); return(String.Empty); } } }