public int GetIndexOf(BLL.WorkCalendar o, FilterParameterCollection filters, SortParameterCollection orderBy) { var condition = new FilterParameterCollection(); condition.Add("Date", o.Date); if (filters != null) filters.OperatorActionResolver = opResolver; return _db.Holidays.AddFilters(filters).AddOrders(orderBy).IndexOf(condition); }
public int GetIndexOf(BLL.AssetValue o, FilterParameterCollection filters, SortParameterCollection orderBy) { orderBy.DefaultOrder = defaultSorting; orderBy.PropertyNameResolver = propResolver; if (filters != null) filters.PropertyNameResolver = propResolver; return _db.Assets.AddFilters(filters).AddOrders(orderBy).IndexOf(o.Id); }
public IEnumerable<WorkCalendar> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; var list = _db.Holidays.Filtering(filters, opResolver).Sorting(orderBy).Paging(pageIndex, pageSize); foreach (var m in list) yield return m; } }
public IEnumerable<BLL.Governor> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; int skip = pageIndex * pageSize; var list = _db.Governors.AddFilters(filters).AddOrders(orderBy).Skip(skip).Take(pageSize); foreach (var m in list) yield return ProxyActivator.CreateProxy<Governor, BLL.Governor>(m); } }
public int GetIndexOf(AssetValue o, FilterParameterCollection filters, SortParameterCollection orderBy) { orderBy.DefaultOrder = defaultSorting; orderBy.PropertyNameResolver = propResolver; if (filters != null) { filters.OperatorActionResolver = opResolver; filters.PropertyNameResolver = propResolver; } return(_db.Assets.GetIndexOf(filters, orderBy, poco => poco.Id == o.Id)); }
public IEnumerable<BLL.WorkCalendar> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; int skip = pageIndex * pageSize; if (filters != null) filters.OperatorActionResolver = opResolver; var list = _db.Holidays.AddFilters(filters).AddOrders(orderBy).Skip(skip).Take(pageSize); foreach (var m in list) yield return ProxyActivator.CreateProxy<WorkCalendar, BLL.WorkCalendar>(m); } }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { try { JObject jObject = JObject.Load(reader); SortParameterCollection result = null; IFilterSortPropResolver props = null; SortParameterCollection defaultSort = null; foreach (var prop in jObject.Properties()) { if (prop.Name == "params") { var st = new JsonSerializerSettings(); st.Converters.Add(new SortParameterJsonConverter()); result = JsonConvert.DeserializeObject <SortParameterCollection>((string)prop.Value, st); } else if (prop.Name == typeof(IFilterSortPropResolver).Name) { Type propsType = Type.GetType((string)prop.Value); props = Activator.CreateInstance(propsType) as IFilterSortPropResolver; } else if (prop.Name == "default") { defaultSort = JsonSerialization.SortParameterCollectionJsonDeserialize((string)prop.Value); } } if (result != null) { if (props != null) { result.PropertyNameResolver = props; } if (defaultSort != null) { result.DefaultOrder = defaultSort; } } return(result); } catch (Exception ex) { throw ex; } }
public IEnumerable<BLL.AssetValue> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; orderBy.PropertyNameResolver = propResolver; if (filters != null) filters.PropertyNameResolver = propResolver; int skip = pageIndex * pageSize; var list = _db.Assets.AddFilters(filters).AddOrders(orderBy).Skip(skip).Take(pageSize); var govCtx = _db.Governors; foreach (var m in list) { //provide action like '$expand' for Governors var gov = govCtx.GetById(m.GovernorId); if (gov == null) gov = govCtx.ToList().FirstOrDefault(g => g.Id == m.GovernorId); m.Governor = gov; yield return ProxyActivator.CreateProxy<AssetValue, BLL.AssetValue>(m); } } }
public IEnumerable <BLL.AssetValue> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; orderBy.PropertyNameResolver = propResolver; if (filters != null) { filters.PropertyNameResolver = propResolver; } int skip = pageIndex * pageSize; var list = _db.Assets.AddFilters(filters).AddOrders(orderBy).Skip(skip).Take(pageSize); var govCtx = _db.Governors; foreach (var m in list) { //provide action like '$expand' for Governors var gov = govCtx.GetById(m.GovernorId); if (gov == null) { gov = govCtx.ToList().FirstOrDefault(g => g.Id == m.GovernorId); } m.Governor = gov; yield return(ProxyActivator.CreateProxy <AssetValue, BLL.AssetValue>(m)); } } }
public IEnumerable<object> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { return _rep.GetList(filters, pageIndex, pageSize, orderBy).Cast<object>().ToList(); }
public int GetIndexOf(object o, FilterParameterCollection filters, SortParameterCollection orderBy) { throw new NotImplementedException(); }
public IEnumerable <object> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { return(Addr.GetList(filters, pageIndex, pageSize)); }
public int GetIndexOf(object o, FilterParameterCollection filters, SortParameterCollection orderBy) { return(_rep.GetIndexOf((WorkCalendar)o, filters, orderBy)); }
public int GetIndexOf(BLL.Governor o, FilterParameterCollection filters, SortParameterCollection orderBy) { return _db.Governors.AddFilters(filters).AddOrders(orderBy).IndexOf(o.Id); }
public IEnumerable <AssetValue> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; orderBy.PropertyNameResolver = propResolver; if (filters != null) { filters.PropertyNameResolver = propResolver; } var list = _db.Assets.Include("Governor").Include("Governor.Company").Filtering(filters, opResolver).Sorting(orderBy).Paging(pageIndex, pageSize); foreach (var m in list) { yield return(m); } } }
public int GetIndexOf(object o, FilterParameterCollection filters, SortParameterCollection orderBy) { return _rep.GetIndexOf((AssetValue)o, filters, orderBy); }
public IEnumerable <object> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { return(_rep.GetList(filters, pageIndex, pageSize, orderBy).Cast <object>().ToList()); }
public static DataServiceQuery <TElement> AddOrders <TElement>(this DataServiceQuery <TElement> q, SortParameterCollection sc) { return(q.AddQueryOption("rf.orderby", HttpUtility.UrlEncode(sc.JsonSerialize(), Encoding.GetEncoding(1251)))); }
public static int GetIndexOf <T>(this DbSet <T> dbset, FilterParameterCollection filters, SortParameterCollection orderBy, Expression <Func <T, bool> > findCondition) where T : class, new() { return(dbset.Filtering(filters).Sorting(orderBy).GetIndexOf(findCondition)); }
public int GetIndexOf(object o, FilterParameterCollection filters, SortParameterCollection orderBy) { return _rep.GetIndexOf((WorkCalendar)o, filters, orderBy); }
public int GetIndexOf(BLL.Governor o, FilterParameterCollection filters, SortParameterCollection orderBy) { return(_db.Governors.AddFilters(filters).AddOrders(orderBy).IndexOf(o.Id)); }
public IEnumerable <BLL.Governor> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; int skip = pageIndex * pageSize; var list = _db.Governors.AddFilters(filters).AddOrders(orderBy).Skip(skip).Take(pageSize); foreach (var m in list) { yield return(ProxyActivator.CreateProxy <Governor, BLL.Governor>(m)); } } }
static void Main(string[] args) { OAuthProvider.Behavior = Activator.CreateInstance(OAuthConfiguration.Configuration.ClientSettings.WcfDSBehaviorType) as IOAuthBehavior; Logon.Page = new LogonProc(); var ctx = new WebApiCtx(); FilterParameterCollection fc = new FilterParameterCollection(); fc.Add("ShortName", "магомед ук"); SortParameterCollection sc = new SortParameterCollection(); sc.Add(null, "Company.Name", System.ComponentModel.ListSortDirection.Ascending); sc.Add(null, "Id", System.ComponentModel.ListSortDirection.Ascending); //var val = ctx.Governors.AddFilters(fc).AddOrders(sc).First(); //var val = ctx.Governors.First(); //val.Company.lawFormValue = 6; Guid g = new Guid("CEB5254F-5FFE-469B-ABC5-09AB388E6505"); //var val = ctx.Governors.Where(gov => gov.Id == g).FirstOrDefault(); Guid g2 = new Guid("CEB5254F-5FFE-469B-ABC5-09AB388E6505"); Governor val2 = null; //ctx.TryGetEntity(new Uri("http://localhost:555/Governors(guid'ceb5254f-5ffe-469b-abc5-09ab388e6505')"), out val2); //Governor val2 = ctx.Governors.Where(gov => gov.Id == g2).FirstOrDefault(); //val2 = ctx.Entities.FirstOrDefault(e => e.Identity.Contains("Governors(guid'ceb5254f-5ffe-469b-abc5-09ab388e6505')")).Entity as Governor; //val2 = ctx.Governors.GetById(g); ctx.Governors.ToList(); //Console.WriteLine(ctx.Governors.TotalCount()); //var ass = ctx.Assets.Where(a => a.Id == new Guid("D3B67671-87C5-4B33-8DF1-7D83947E5FB8")).First(); var ass = new AssetValue(); ass.Id = Guid.NewGuid(); ass.InsuranceTypeValue = 1; ass.TakingDate = DateTime.Today; ass.Value = 3344434.56m; ass.GovernorId = g2; string s = JsonConvert.SerializeObject(ass); var list = new List<string>(); list.Add(s); UriBuilder urib = new UriBuilder(ctx.BaseUri); //urib.Path = string.Format("{0}/CreateBatch", ctx.Assets.RequestUri.PathAndQuery); //var r = ctx.Execute<bool>(urib.Uri, "POST", true, new BodyOperationParameter("Values", list)).FirstOrDefault(); //ctx.AddToAssets(ass); //ctx.SetLink(ass, "Governor", val2); //ctx.SaveChanges(); //ctx.AttachLink(ass, "Governor", val2); //Guid g = new Guid("32D3F7C1-97E1-4A69-8C8A-E3706490329E"); //var val = ctx.Holidays.Where(h => h.Id == g).FirstOrDefault(); //val.Comment = "Test Comment"; var newc = new Company(); newc.Id = Guid.NewGuid(); newc.Name = "Test Governor Company Name"; var newg = new Governor(); newg.Id = Guid.NewGuid(); newg.ShortName = "Test Governor Name"; newg.Company = newc; ctx.AddToGovernors(newg); ctx.SaveChanges(); newg.ShortName = "Test Governor Name Updated"; ctx.UpdateObject(newg); //ctx.SaveChanges(SaveChangesOptions.PatchOnUpdate); System.Threading.Thread.Sleep(1000); ctx.SaveChanges(SaveChangesOptions.ReplaceOnUpdate); ctx.DeleteObject(newg); ctx.SaveChanges(); //var serviceCreds = new NetworkCredential("Administrator", "SecurePassword"); //var cache = new CredentialCache(); //var serviceUri = new Uri("http://ipv4.fiddler:333/api/issue"); //cache.Add(serviceUri, "Basic", serviceCreds); //ctx.Credentials = cache; //var r = ctx.Execute(new Uri("http://ipv4.fiddler:333/api/issue"), "POST", new BodyOperationParameter("rst", new TokenRequest() { GrantType = "client_credentials", Scope = "http://localhost" })); Console.ReadLine(); }
public int GetIndexOf(WorkCalendar o, FilterParameterCollection filters, SortParameterCollection orderBy) { orderBy.DefaultOrder = defaultSorting; if (filters != null) filters.OperatorActionResolver = opResolver; return _db.Holidays.GetIndexOf(filters, orderBy, poco => poco.Date == o.Date); }
public int GetIndexOf(object o, FilterParameterCollection filters, SortParameterCollection orderBy) { throw new NotImplementedException(); }
public IEnumerable <BLL.WorkCalendar> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; int skip = pageIndex * pageSize; if (filters != null) { filters.OperatorActionResolver = opResolver; } var list = _db.Holidays.AddFilters(filters).AddOrders(orderBy).Skip(skip).Take(pageSize); foreach (var m in list) { yield return(ProxyActivator.CreateProxy <WorkCalendar, BLL.WorkCalendar>(m)); } } }
public IEnumerable<object> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { return Addr.GetList(filters, pageIndex, pageSize); }
public int GetIndexOf(object o, FilterParameterCollection filters, SortParameterCollection orderBy) { return(_rep.GetIndexOf((AssetValue)o, filters, orderBy)); }
static void Main(string[] args) { OAuthProvider.Behavior = Activator.CreateInstance(OAuthConfiguration.Configuration.ClientSettings.WcfDSBehaviorType) as IOAuthBehavior; Logon.Page = new LogonProc(); var ctx = new WebApiCtx(); FilterParameterCollection fc = new FilterParameterCollection(); fc.Add("ShortName", "магомед ук"); SortParameterCollection sc = new SortParameterCollection(); sc.Add(null, "Company.Name", System.ComponentModel.ListSortDirection.Ascending); sc.Add(null, "Id", System.ComponentModel.ListSortDirection.Ascending); //var val = ctx.Governors.AddFilters(fc).AddOrders(sc).First(); //var val = ctx.Governors.First(); //val.Company.lawFormValue = 6; Guid g = new Guid("CEB5254F-5FFE-469B-ABC5-09AB388E6505"); //var val = ctx.Governors.Where(gov => gov.Id == g).FirstOrDefault(); Guid g2 = new Guid("CEB5254F-5FFE-469B-ABC5-09AB388E6505"); Governor val2 = null; //ctx.TryGetEntity(new Uri("http://localhost:555/Governors(guid'ceb5254f-5ffe-469b-abc5-09ab388e6505')"), out val2); //Governor val2 = ctx.Governors.Where(gov => gov.Id == g2).FirstOrDefault(); //val2 = ctx.Entities.FirstOrDefault(e => e.Identity.Contains("Governors(guid'ceb5254f-5ffe-469b-abc5-09ab388e6505')")).Entity as Governor; //val2 = ctx.Governors.GetById(g); ctx.Governors.ToList(); //Console.WriteLine(ctx.Governors.TotalCount()); //var ass = ctx.Assets.Where(a => a.Id == new Guid("D3B67671-87C5-4B33-8DF1-7D83947E5FB8")).First(); var ass = new AssetValue(); ass.Id = Guid.NewGuid(); ass.InsuranceTypeValue = 1; ass.TakingDate = DateTime.Today; ass.Value = 3344434.56m; ass.GovernorId = g2; string s = JsonConvert.SerializeObject(ass); var list = new List <string>(); list.Add(s); UriBuilder urib = new UriBuilder(ctx.BaseUri); //urib.Path = string.Format("{0}/CreateBatch", ctx.Assets.RequestUri.PathAndQuery); //var r = ctx.Execute<bool>(urib.Uri, "POST", true, new BodyOperationParameter("Values", list)).FirstOrDefault(); //ctx.AddToAssets(ass); //ctx.SetLink(ass, "Governor", val2); //ctx.SaveChanges(); //ctx.AttachLink(ass, "Governor", val2); //Guid g = new Guid("32D3F7C1-97E1-4A69-8C8A-E3706490329E"); //var val = ctx.Holidays.Where(h => h.Id == g).FirstOrDefault(); //val.Comment = "Test Comment"; var newc = new Company(); newc.Id = Guid.NewGuid(); newc.Name = "Test Governor Company Name"; var newg = new Governor(); newg.Id = Guid.NewGuid(); newg.ShortName = "Test Governor Name"; newg.Company = newc; ctx.AddToGovernors(newg); ctx.SaveChanges(); newg.ShortName = "Test Governor Name Updated"; ctx.UpdateObject(newg); //ctx.SaveChanges(SaveChangesOptions.PatchOnUpdate); System.Threading.Thread.Sleep(1000); ctx.SaveChanges(SaveChangesOptions.ReplaceOnUpdate); ctx.DeleteObject(newg); ctx.SaveChanges(); //var serviceCreds = new NetworkCredential("Administrator", "SecurePassword"); //var cache = new CredentialCache(); //var serviceUri = new Uri("http://ipv4.fiddler:333/api/issue"); //cache.Add(serviceUri, "Basic", serviceCreds); //ctx.Credentials = cache; //var r = ctx.Execute(new Uri("http://ipv4.fiddler:333/api/issue"), "POST", new BodyOperationParameter("rst", new TokenRequest() { GrantType = "client_credentials", Scope = "http://localhost" })); Console.ReadLine(); }
public IEnumerable <Governor> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; var list = _db.Governors.Filtering(filters, opResolver).Sorting(orderBy).Paging(pageIndex, pageSize); foreach (var m in list) { yield return(m); } } }
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { //HttpConfiguration configuration = request.GetConfiguration(); //HttpActionDescriptor actionDescriptor = actionExecutedContext.ActionContext.ActionDescriptor; //IEnumerable query = responseContent.Value as IEnumerable; //TypeHelper.GetImplementedIEnumerableType(originalQueryType); //IEdmModel model = configuration.GetEdmModel(); //if (model == null || model.GetEdmType(elementClrType) == null) model = actionDescriptor.GetEdmModel(elementClrType); //ODataQueryContext queryContext = new ODataQueryContext(model, elementClrType); //ODataQueryOptions queryOptions = new ODataQueryOptions(queryContext, request); //var RawValues = new ODataRawQueryOptions(); if (actionExecutedContext.Response == null) { return; } ObjectContent responseContent = actionExecutedContext.Response.Content as ObjectContent; string filter = HttpUtility.ParseQueryString(actionExecutedContext.Request.RequestUri.Query, System.Text.Encoding.GetEncoding(1251)).Get("rf.filter"); if (string.IsNullOrWhiteSpace(filter) == false) { FilterParameterCollection fc = JsonSerialization.FilterParameterCollectionJsonDeserialize(filter); IQueryable q = responseContent.Value as IQueryable; responseContent.Value = q.Filtering(fc, q.ElementType); } string sort = HttpUtility.ParseQueryString(actionExecutedContext.Request.RequestUri.Query).Get("rf.orderby"); if (string.IsNullOrWhiteSpace(sort) == false) { SortParameterCollection sc = JsonSerialization.SortParameterCollectionJsonDeserialize(sort); IQueryable q = responseContent.Value as IQueryable; responseContent.Value = q.Sorting(sc, q.ElementType); base.EnsureStableOrdering = false; } base.OnActionExecuted(actionExecutedContext); IQueryable query = responseContent.Value as IQueryable; if (query != null && ResponseIsValid(actionExecutedContext.Response)) { //visit to make parametrized EF queries //var modifier = new RF.LinqExt.ConstantModifier(); //modifier.StayConstants = new string[] { "dw" }; //Expression expr = modifier.Visit(query.Expression); //IQueryable ret = query.Provider.CreateQuery(expr); //responseContent.Value = ret; //actionExecutedContext.Response.TryGetContentValue(out responseObject); string indexofcond = HttpUtility.ParseQueryString(actionExecutedContext.Request.RequestUri.Query).Get("rf.indexof"); if (string.IsNullOrWhiteSpace(indexofcond) == false) { FilterParameterCollection fc = JsonSerialization.FilterParameterCollectionJsonDeserialize(indexofcond); var q = PrepareInlineResult(responseContent); var val = q.GetIndexOf(fc, q.ElementType); actionExecutedContext.Response.Headers.Add("Index-Of-Model", val.ToString()); } string inlinecountval = HttpUtility.ParseQueryString(actionExecutedContext.Request.RequestUri.Query).Get("rf.inlinecount"); if (inlinecountval == "allpages") { var q = PrepareInlineResult(responseContent); var minfo = typeof(Queryable).GetGenericMethod("Count", new Type[] { typeof(IQueryable <>) }); var val = minfo.MakeGenericMethod(q.ElementType).Invoke(null, new object[] { q }); actionExecutedContext.Response.Headers.Add("Total-Inline-Count", val.ToString()); } //break further processing UriBuilder builder = new UriBuilder(actionExecutedContext.Request.RequestUri.GetLeftPart(UriPartial.Authority)); builder.Path = VirtualPathUtility.ToAbsolute(actionExecutedContext.Request.RequestUri.AbsolutePath); actionExecutedContext.Request.RequestUri = builder.Uri; } }