public void TableRequest_Defaults() { var r = new TableRequest(); Assert.IsNotNull(r.Sources); Assert.IsNotNull(r.Destinations); }
private void Write(IDictionary <string, object> entity, string uri, string method) { if (entity == null) { throw new ArgumentNullException("entity"); } if (!entity.ContainsKey("PartitionKey")) { throw new ArgumentException("Entity has no PartitionKey"); } if (!entity.ContainsKey("RowKey")) { throw new ArgumentException("Entity has no RowKey"); } var webRequest = BuildRequest(uri, method); webRequest.ContentType = @"application/atom+xml"; if (!entity.ContainsKey("Timestamp")) { entity.Add("Timestamp", "0001-01-01T00:00:00"); } TableRequest.SignRequestForSharedKeyLite(webRequest, credentials); WriteToRequestStream(entity, uri, webRequest); using (var response = webRequest.GetResponse()) { } }
public void TableRequest_Url() { var r = new TableRequest { Coordinates = locations }; Assert.IsTrue(r.CoordinatesUrlPart.Contains("13.420526,52.503033")); Assert.IsTrue(r.CoordinatesUrlPart.Contains("13.429290,52.516582")); r.Sources = new uint[1] { 0 }; var srcParams = ParamValues(r.UrlParams, "sources"); Assert.AreEqual <int>(1, srcParams.Length); Assert.IsTrue(srcParams.Contains("0")); r.Destinations = new uint[1] { 1 }; var dstParams = ParamValues(r.UrlParams, "destinations"); Assert.AreEqual <int>(1, dstParams.Length); Assert.IsTrue(dstParams.Contains("1")); }
public override async Task <BaseReply> DeleteTable(TableRequest request, ServerCallContext context) { try { await _databaseService.DeleteTable(request.DbName, request.TableName); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("***************************************************************************************************************"); Console.WriteLine("Table deleted: " + request.TableName); Console.WriteLine("***************************************************************************************************************"); return(new BaseReply() { Code = 200 }); } catch (Exception ex) { return(new BaseReply() { Code = 400, Message = ex.Message, StackTrace = ex.StackTrace }); } }
/// <summary> /// Generates a task sequence for getting the properties of the table service. /// </summary> /// <param name="setResult">A delegate to receive the service properties.</param> /// <returns>A task sequence that gets the properties of the table service.</returns> private TaskSequence GetServicePropertiesImpl(Action <ServiceProperties> setResult) { HttpWebRequest request = TableRequest.GetServiceProperties(this.BaseUri, this.Timeout.RoundUpToSeconds()); CommonUtils.ApplyRequestOptimizations(request, -1); this.Credentials.SignRequestLite(request); // Get the web response. Task <WebResponse> responseTask = request.GetResponseAsyncWithTimeout(this, this.Timeout); yield return(responseTask); using (HttpWebResponse response = responseTask.Result as HttpWebResponse) using (Stream responseStream = response.GetResponseStream()) using (MemoryStream memoryStream = new MemoryStream()) { // Download the service properties. Task <NullTaskReturn> downloadTask = new InvokeTaskSequenceTask(() => { return(responseStream.WriteTo(memoryStream)); }); yield return(downloadTask); // Materialize any exceptions. NullTaskReturn scratch = downloadTask.Result; // Get the result from the memory stream. memoryStream.Seek(0, SeekOrigin.Begin); setResult(TableResponse.ReadServiceProperties(memoryStream)); } }
public async System.Threading.Tasks.Task CheckRequestTestAsync() { var options = new DbContextOptionsBuilder <CoffeeDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new CoffeeDbContext(options)) { var service = new TableRepository(context); TableRequest table = new TableRequest { Id = 1, FirstName = "FirstName", LastName = "LastName", Date = DateTime.Now.ToString(), Status = "Waiting", Note = "Test", PhoneNumber = "123456", Time = DateTime.Now.AddDays(2).ToString() }; await service.AddRequestAsync(table); } using (var context = new CoffeeDbContext(options)) { Assert.AreEqual(1, context.TableRequests.Count()); var service = new TableRepository(context); await service.CheckRequest(1, "Done"); Assert.AreEqual("Done", context.TableRequests.Single().Status); } }
public TableItems <UserListViewModel[]> Search(TableRequest request, UserListViewModel searchModel) { var query = _repository.TableAsNoTracking; IQueryable <TEntity> GetOrderedQuery <TEntity, TKey>(IQueryable <TEntity> loccalQuery, System.Linq.Expressions.Expression <Func <TEntity, TKey> > expression, string sortOrder) { return(sortOrder == "desc" ? loccalQuery.OrderByDescending(expression) : loccalQuery.OrderBy(expression)); } switch (request.sidx) { case nameof(User.Login): query = GetOrderedQuery(query, q => q.Login, request.sord); break; case nameof(User.PasswordHash): query = GetOrderedQuery(query, q => q.PasswordHash, request.sord); break; case nameof(User.Salt): query = GetOrderedQuery(query, q => q.Salt, request.sord); break; case nameof(User.Id): query = GetOrderedQuery(query, q => q.Id, request.sord); break; default: query = GetOrderedQuery(query, q => q.Login, request.sord); break; } if (!string.IsNullOrEmpty(searchModel.Login)) { query = query.Where(w => w.Login.Contains(searchModel.Login)); } if (searchModel.Id.HasValue) { query = query.Where(w => w.Id == searchModel.Id.Value); } var rows = query.Select(s => new UserListViewModel { Login = s.Login, Id = s.Id, }); var total = rows.Count(); var toTake = request.rows; if (request.includePrevousPages) { toTake = request.page * request.rows; } else { rows = rows.Skip((request.page - 1) * request.rows); } var data = rows.Take(toTake).ToArray(); return(new TableItems <UserListViewModel[]>(data, total, request.page, (int)Math.Ceiling((decimal)total / request.rows))); }
public TableExtractorFrame(AxMODI.AxMiDocView documentViewer, TableRequest request) { InitializeComponent(); _documentViewer = documentViewer; _request = request; // Synchronize transparent color this.TransparencyKey = TransparentListView.TransparentColor; }
public void Table_Response_DurationAndDistanceAnnotation() { var locations = new Location[] { new Location(52.554070m, 13.160621m), new Location(52.431272m, 13.720654m), new Location(52.554070m, 13.720654m), new Location(52.554070m, 13.160621m), }; var tableRequest = new TableRequest() { Coordinates = locations, Annotations = TableRequestAnnotation.DistancesAndDurations }; var result = osrm.Table(tableRequest).GetAwaiter().GetResult(); // check distances Assert.AreEqual <string>("Ok", result.Code); Assert.AreEqual <int>(4, result.Distances.Length); Assert.AreEqual <int>(4, result.Distances[0].Length); Assert.AreEqual <int>(4, result.Distances[1].Length); Assert.AreEqual <int>(4, result.Distances[2].Length); Assert.AreEqual <int>(4, result.Distances[3].Length); // check durations Assert.AreEqual <int>(4, result.Durations.Length); Assert.AreEqual <int>(4, result.Durations[0].Length); Assert.AreEqual <int>(4, result.Durations[1].Length); Assert.AreEqual <int>(4, result.Durations[2].Length); Assert.AreEqual <int>(4, result.Durations[3].Length); var srcAndDests = new Location[] { new Location(52.554070m, 13.160621m), new Location(52.431272m, 13.720654m), new Location(52.554070m, 13.720654m), new Location(52.554070m, 13.160621m), }; var result2 = osrm.Table(new TableRequest() { Coordinates = srcAndDests, Annotations = TableRequestAnnotation.DistancesAndDurations, Sources = new uint[] { 0 }, Destinations = new uint[] { 1, 2, 3 } }).GetAwaiter().GetResult(); // check durations Assert.AreEqual <string>("Ok", result.Code); Assert.AreEqual <int>(1, result2.Durations.Length); Assert.AreEqual <int>(3, result2.Durations[0].Length); // check distances Assert.AreEqual <string>("Ok", result.Code); Assert.AreEqual <int>(1, result2.Distances.Length); Assert.AreEqual <int>(3, result2.Distances[0].Length); }
public TableRequest TableRequestByName(string tableName, out int urlId) { try { TableRequest obj = db.TableRequests.Where(v => v.TableName == tableName).First(); urlId = db.Urls.Where(v => v.TableId == obj.Id).First().Id; return(obj); } catch (Exception) { urlId = -1; return(null); } }
public override IActionResult ApplyFilters([FromBody] TableRequest request) { if (!ModelState.IsValid) { return(BadRequest($"Model is not Valid: {string.Join(" ;", ModelState.Values.SelectMany(x => x.Errors.Select(y => y.ErrorMessage)))}")); } SaveToSession(SessionKeys.TableRequest, request); return(RedirectToAction(nameof(Table), new { page = 1 })); }
public Table MapEntity(TableRequest request) { Table table = new Table(request.Id, request.Number); UpdateOrder(table); UpdateOrderItem(table); return(table); }
public async Task <IEnumerable <TablesResponse> > TablesAsync(TableRequest request, CancellationToken token = default) { Guard.Against.Null(request, nameof(request)); var response = await this .PostAsync <IEnumerable <TablesResponse>, TableRequest>(request, token); return(response ?? Enumerable.Empty <TablesResponse>()); }
public TableResultJson <ReplyCommentViewModel> GetReplyCommentPaged(TableRequest request) { var dataSource = replyCommentRepository.GetAll().OrderByDescending(x => x.CreatedDate).ToList(); var dataSourceViewModel = (mapper.Map <List <ReplyCommentViewModel> >(dataSource)).AsEnumerable(); if (request.columns[1].search != null) { var _value1 = request.columns[1].search.value; if (!string.IsNullOrEmpty(_value1)) { dataSourceViewModel = dataSourceViewModel.Where(x => x.OId.Contains(_value1)); } } if (request.columns[2].search != null) { var _value2 = request.columns[2].search.value; if (!string.IsNullOrEmpty(_value2)) { dataSourceViewModel = dataSourceViewModel.Where(x => x.AuthorName.Contains(_value2)); } } if (request.columns[3].search != null) { if (!string.IsNullOrEmpty(request.columns[3].search.value)) { var dt = DateTime.TryParseExact(request.columns[3].search.value, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var datetime); if (dt) { dataSourceViewModel = dataSourceViewModel.Where(x => x.CreatedDate.Value.Date == datetime); } } } if (request.columns[8].search != null) { var _value4 = request.columns[8].search.value; if (!string.IsNullOrEmpty(_value4)) { dataSourceViewModel = dataSourceViewModel.Where(x => x.Content.Contains(_value4)); } } var response = new TableResultJson <ReplyCommentViewModel>(); response.draw = request.draw; response.recordsFiltered = dataSourceViewModel.Count(); dataSourceViewModel = dataSourceViewModel.Skip(request.start).Take(request.length); response.data = dataSourceViewModel.ToList(); response.data.ForEach(x => { x.Index = response.data.IndexOf(x) + request.start + 1; }); return(response); }
public IActionResult TableAdd(TableRequest user) { var userAdd = new Tablenya() { Id = user.Id, Name = user.Name, Description = user.Description }; Tables.Add(userAdd); return(Ok(userAdd)); }
public async Task <IActionResult> RequestTable(TableRequest request) { if (ModelState.IsValid) { await _unitOfWork.TableRepository.AddRequestAsync(request); await _unitOfWork.SaveAsync(); return(View("RequestComplete")); } return(RedirectToAction("Index", "Home")); }
public IActionResult Menu() { var drinks = _unitOfWork.DrinkRepository.GetDrinks(); var request = new TableRequest(); var indexViewModel = new IndexViewModel { Drinks = drinks, Request = request }; return(View(indexViewModel)); }
public JsonResult SelectCooperContents(TableRequest request) { var data = _db.CooperationContents.Include(x => x.CooperationTitle).WhereIf(request.KeyWord != null, x => x.Name.Contains(request.KeyWord)); TableResponse tableResponse = new TableResponse(); tableResponse.Total = data.Count(); tableResponse.Data = data.Skip((request.Page - 1) * request.Limit).Take(request.Limit).Select(x => new { x.ID, CooperationTitleName = x.CooperationTitle.Name, x.Name }); return(Json(tableResponse)); }
public JsonResult SelectClients(TableRequest request) { var datas = _db.Clients.WhereIf(request.KeyWord != null, x => x.Name.Contains(request.KeyWord)).Select(c => new { c.ID, c.Name }); TableResponse tableResponse = new TableResponse(); tableResponse.Total = datas.Count(); tableResponse.Data = datas.Skip((request.Page - 1) * request.Limit).Take(request.Limit).OrderBy(x => x.ID).ToList(); return(Json(tableResponse)); }
public async System.Threading.Tasks.Task GetRequestsTestAsync() { var options = new DbContextOptionsBuilder <CoffeeDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new CoffeeDbContext(options)) { var service = new TableRepository(context); TableRequest table1 = new TableRequest { Id = 1, FirstName = "FirstName", LastName = "LastName", Date = DateTime.Now.ToString(), Status = "Waiting", Note = "Test", PhoneNumber = "123456", Time = DateTime.Now.AddDays(2).ToString() }; TableRequest table2 = new TableRequest { Id = 2, FirstName = "FirstName1", LastName = "LastName1", Date = DateTime.Now.ToString(), Status = "Waiting1", Note = "Test1", PhoneNumber = "123456", Time = DateTime.Now.AddDays(2).ToString() }; await service.AddRequestAsync(table1); await service.AddRequestAsync(table2); } using (var context = new CoffeeDbContext(options)) { Assert.AreEqual(2, context.TableRequests.Count()); var service = new TableRepository(context); var result = service.GetRequests(); Assert.AreEqual(2, result.Count()); } }
public TableResultJson <FieldViewModel> GetAllField(TableRequest request) { var dataSource = fieldRepository.GetAll().OrderByDescending(x => x.CreatedDate); var dataSourceViewModel = mapper.Map <List <FieldViewModel> >(dataSource).AsEnumerable(); var response = new TableResultJson <FieldViewModel> { draw = request.draw, recordsFiltered = dataSourceViewModel.Count() }; dataSourceViewModel = dataSourceViewModel.Skip(request.start).Take(request.length); response.data = dataSourceViewModel.ToList(); response.data.ForEach(x => { x.Index = response.data.IndexOf(x) + request.start + 1; }); return(response); }
public TableResultJson <LevelViewModel> GetAllLevel(TableRequest request) { var dataSource = levelRepository.GetAll(); var dataSourceViewModel = mapper.Map <List <LevelViewModel> >(dataSource).AsEnumerable(); var response = new TableResultJson <LevelViewModel> { draw = request.draw, recordsFiltered = dataSourceViewModel.Count() }; dataSourceViewModel = dataSourceViewModel.Skip(request.start).Take(request.length); response.data = dataSourceViewModel.ToList(); response.data.ForEach(x => { x.Index = response.data.IndexOf(x) + request.start + 1; }); return(response); }
public IEnumerable <dynamic> Query(string queryString) { var webRequest = BuildRequest(string.Format(@"http://{0}.table.core.windows.net/{1}()?$filter={2}", credentials.AccountName, tableName, queryString.Replace(' ', '+'))); TableRequest.SignRequestForSharedKeyLite(webRequest, credentials); using (var response = webRequest.GetResponse()) { foreach (var item in ParseResponse(response)) { yield return(item); } } yield break; }
private TableRequest GetPropertyValues(TableRequest request, ValueProviderResult filtersValueResult) { var filters = (string)filtersValueResult.ConvertTo(typeof(string)); var appliedFilters = JObject.Parse(filters); var tokens = appliedFilters.Children(); var Name = ""; var Surname = ""; var Role = Roles.All; int? Id = null; var index = 0; foreach (var token in tokens) { if (index != 0) { for (var j = 0; j < token.First.Count(); j++) { var currentToken = token.First[j]; if (currentToken.Value<string>("field").Equals("Name")) { Name = currentToken["data"].ToString().Trim(); } if (currentToken.Value<string>("field").Equals("Surname")) { Surname = currentToken["data"].ToString().Trim(); } if (currentToken.Value<string>("field").Equals("Position")) { Role = (Roles)(Enum.Parse(typeof(Roles), currentToken["data"].ToString().Trim())); } if (currentToken.Value<string>("field").Equals("Id")) { Id = Convert.ToInt32(currentToken["data"].ToString().Trim()); } } } index++; } request.Name = Name.Trim(); request.Surname = Surname.Trim(); request.Role = Role; request.Id = Id; return request; }
private TableRequest GetPropertyValues(TableRequest request, ValueProviderResult filtersValueResult) { var filters = (string)filtersValueResult.ConvertTo(typeof(string)); var appliedFilters = JObject.Parse(filters); var tokens = appliedFilters.Children(); var Name = ""; var Surname = ""; var Role = Roles.All; int?Id = null; var index = 0; foreach (var token in tokens) { if (index != 0) { for (var j = 0; j < token.First.Count(); j++) { var currentToken = token.First[j]; if (currentToken.Value <string>("field").Equals("Name")) { Name = currentToken["data"].ToString().Trim(); } if (currentToken.Value <string>("field").Equals("Surname")) { Surname = currentToken["data"].ToString().Trim(); } if (currentToken.Value <string>("field").Equals("Position")) { Role = (Roles)(Enum.Parse(typeof(Roles), currentToken["data"].ToString().Trim())); } if (currentToken.Value <string>("field").Equals("Id")) { Id = Convert.ToInt32(currentToken["data"].ToString().Trim()); } } } index++; } request.Name = Name.Trim(); request.Surname = Surname.Trim(); request.Role = Role; request.Id = Id; return(request); }
public string TableNameByUrl(int urlId, string dbName) { try { int tableId = db.Urls.Where(v => v.Id == urlId).First().TableId.Value; TableRequest obj = db.TableRequests.Where(v => v.Id == tableId).First(); if (dbName != obj.DBName) { return(null); } else { return(obj.TableName); } } catch (Exception) { return(null); } }
/// <summary> /// Generates a task sequence for setting the properties of the table service. /// </summary> /// <param name="properties">The table service properties to set.</param> /// <returns>A task sequence that sets the properties of the table service.</returns> private TaskSequence SetServicePropertiesImpl(ServiceProperties properties) { CommonUtils.AssertNotNull("properties", properties); HttpWebRequest request = TableRequest.SetServiceProperties(this.BaseUri, this.Timeout.RoundUpToSeconds()); using (MemoryStream memoryStream = new MemoryStream()) { try { TableRequest.WriteServiceProperties(properties, memoryStream); } catch (InvalidOperationException invalidOpException) { throw new ArgumentException(invalidOpException.Message, "properties"); } memoryStream.Seek(0, SeekOrigin.Begin); CommonUtils.ApplyRequestOptimizations(request, memoryStream.Length); this.Credentials.SignRequestLite(request); // Get the request stream Task <Stream> getStreamTask = request.GetRequestStreamAsync(); yield return(getStreamTask); using (Stream requestStream = getStreamTask.Result) { // Upload the service properties. Task <NullTaskReturn> uploadTask = new InvokeTaskSequenceTask(() => { return((memoryStream as Stream).WriteTo(requestStream)); }); yield return(uploadTask); // Materialize any exceptions. NullTaskReturn scratch = uploadTask.Result; } } // Get the web response. Task <WebResponse> responseTask = request.GetResponseAsyncWithTimeout(this, this.Timeout); yield return(responseTask); // Materialize any exceptions. using (HttpWebResponse response = responseTask.Result as HttpWebResponse) { } }
/***************************************************/ /**** Request Methods ****/ /***************************************************/ public static string ToSqlCommand(this TableRequest request) { string select = "*"; if (request.Columns != null && request.Columns.Count > 0) { select = request.Columns.Aggregate((a, b) => a + ", " + b); } string where = ""; if (!string.IsNullOrWhiteSpace(request.Filter)) { where = "WHERE " + request.Filter; } return($"SELECT {select} FROM {request.Table} {where}"); }
public int TableAdd(string tableName, bool isDaily) { //check duplicated TableRequest obj; try { obj = (from t in db.TableRequests where t.TableName == tableName select t).First(); } catch (Exception) { obj = new TableRequest(); } obj.TableName = tableName; obj.IsDaily = isDaily; db.TableRequests.InsertOnSubmit(obj); db.SubmitChanges(); return(obj.Id); }
public TableResultJson <ViolenceWordViewModel> GetViolenceWordPaged(TableRequest request) { var dataSource = violenceWordRepository.GetAll(); var dataSourceViewModel = mapper.Map <IEnumerable <ViolenceWordViewModel> >(dataSource); var response = new TableResultJson <ViolenceWordViewModel>(); response.draw = request.draw; response.recordsFiltered = dataSourceViewModel.Count(); dataSourceViewModel = dataSourceViewModel.Skip(request.start).Take(request.length); response.data = dataSourceViewModel.ToList(); foreach (var item in response.data) { item.Index = response.data.IndexOf(item) + request.start + 1; } return(response); }
public JsonResult SelectCoopers(TableRequest request) { var data = _db.Coopers.WhereIf(request.KeyWord != null, x => x.Company.Contains(request.KeyWord) || x.Contact.Contains(request.KeyWord) || x.Detail.Contains(request.KeyWord) || x.Email.Contains(request.KeyWord) || x.LinkMan.Contains(request.KeyWord)); TableResponse response = new TableResponse(); response.Total = data.Count(); response.Data = data.OrderByDescending(x => x.CommitDateTime).Skip((request.Page - 1) * request.Limit).Take(request.Limit).Select(x => new { x.ID, ReadStatus = x.AlreadyRead.GetDescription(), x.Company, x.CommitDateTime, x.Contact, x.Detail, x.Email, x.LinkMan }).ToList(); return(Json(response)); }
public EmployeePagedCollection Create(TableRequest request) { IEnumerable<SimplifiedEmployeeViewModel> toTransfer; var totalCount = 0; var queryResult = employeeDataAccessObject.GetNextPage(request, gridPageSize); totalCount = queryResult.ResultQuantity; toTransfer = employeeService.SimplifyCollection(queryResult.Employees); return new EmployeePagedCollection() { Employees = toTransfer, Page = request.Page, TotalPages = employeeService.CalculatePages(gridPageSize, totalCount), SortColumn = request.SortingProperty, SortOrder = request.SortOrder, TotalRecords = totalCount }; }
public PagingQueryResult GetNextPage(TableRequest request, int pageSize) { var projectId = request.ProjectId; var id = request.Id; var role = request.Role; var name = request.Name; var surname = request.Surname; var property = request.SortingProperty; var sortingOrder = request.SortOrder; var pageNumber = request.Page; var result = DirectSearch(name, surname, id, role, projectId) .OrderBy(property + (sortingOrder.Equals(SortEnum.asc) ? " descending" : "")); return new PagingQueryResult() { Employees = result .Skip((pageNumber - 1)*pageSize) .Take(pageSize), ResultQuantity = result.Count() }; }
private TableRequest Bind(ModelBindingContext bindingContext) { var searchValueResult = bindingContext.ValueProvider.GetValue(keySearch); var pageValueResult = bindingContext.ValueProvider.GetValue(keyPage); var rowsValueResult = bindingContext.ValueProvider.GetValue(keyRows); var sortProperyValueResult = bindingContext.ValueProvider.GetValue(keySortProperty); var sortValueResult = bindingContext.ValueProvider.GetValue(keySortingOrder); var filtersValueResult = bindingContext.ValueProvider.GetValue(filters); var projectIdValueResult = bindingContext.ValueProvider.GetValue(projectId); var request = new TableRequest() { IsSearch = (bool)searchValueResult.ConvertTo(typeof(bool)), Page = (int)pageValueResult.ConvertTo(typeof(int)), Rows = (int)rowsValueResult.ConvertTo(typeof(int)), SortingProperty = (string)sortProperyValueResult.ConvertTo(typeof(string)), SortOrder = (SortEnum)Enum.Parse(typeof(SortEnum),(string)sortValueResult.ConvertTo(typeof(string))), ProjectId = ToNullableInt32((string)projectIdValueResult.ConvertTo(typeof(string))) }; return filtersValueResult == null ? request : GetPropertyValues(request, filtersValueResult); }