Example #1
0
        private FilterParameterCollection GetFilters()
        {
            Type modelType = this.FilteredModelType;

            if (modelType == null)
            {
                var dobj = this.DataContext as DataObj;
                if (dobj != null)
                {
                    modelType = dobj.Model.GetType();
                }
            }

            if (modelType != null)
            {
                FilterParameterCollection fc = new FilterParameterCollection(modelType);
                foreach (FilterCC f in DispatcherHelper.FindVisualChildren <FilterCC>(this).Where(f => f.IsEnabled))
                {
                    if (f.Value != null)
                    {
                        if (f.Value.GetType() == typeof(string))
                        {
                            string s = f.Value as string;
                            if (string.IsNullOrEmpty(s) == false)
                            {
                                Type targtType = typeof(string);
                                var  fiedInfo  = modelType.GetProperty(f.FieldName);
                                if (fiedInfo != null && fiedInfo.PropertyType != targtType)
                                {
                                    targtType = fiedInfo.PropertyType;
                                    var val = Convert.ChangeType(f.Value, targtType);
                                    f.Value = val;
                                }

                                if (f.OperatorType == OperatorType.Equals && targtType == typeof(string))
                                {
                                    if (s.Contains("?") || s.Contains("*"))
                                    {
                                        f.OperatorType = OperatorType.Like;
                                    }
                                }
                                fc.Add(f.FieldName, f.Value, f.OperatorType);
                            }
                        }
                        else
                        {
                            fc.Add(f.FieldName, f.Value, f.OperatorType);
                        }
                    }
                    else if (f.OperatorType == OperatorType.IsNull || f.OperatorType == OperatorType.IsNotNull)
                    {
                        fc.Add(f.FieldName, f.Value, f.OperatorType);
                    }
                }
                return(fc);
            }

            return(null);
        }
Example #2
0
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            string condition = HttpUtility.ParseQueryString(actionExecutedContext.Request.RequestUri.Query).Get("rf.condition");

            if (condition == "IsHoliday")
            {
                //bug in HttpRequestMessage : RequestUri setter not change Properties. Do it manually.
                //if (request.Properties.ContainsKey(System.Web.Http.Hosting.HttpPropertyKeys.RequestQueryNameValuePairsKey))
                //{
                //    request.Properties.Remove(System.Web.Http.Hosting.HttpPropertyKeys.RequestQueryNameValuePairsKey);
                //    request.GetQueryNameValuePairs();
                //}

                ObjectContent             responseContent = actionExecutedContext.Response.Content as ObjectContent;
                IQueryable <WorkCalendar> query           = null;
                if (responseContent != null)
                {
                    query = responseContent.Value as IQueryable <WorkCalendar>;
                }

                if (query != null)
                {
                    FilterParameterCollection fc = new FilterParameterCollection(typeof(WorkCalendar));
                    fc.Add("IsWorkingDay", false, OperatorType.Condition);
                    fc.OperatorActionResolver = new ConditionOpRes();
                    responseContent.Value     = query.Filtering(fc);
                }
            }

            base.OnActionExecuted(actionExecutedContext);
        }
Example #3
0
        public static int IndexOf <TElement>(this DataServiceQuery <TElement> q, Guid key)
        {
            var condition = new FilterParameterCollection();

            condition.Add("Id", key);
            return(IndexOf <TElement>(q, condition));
        }
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            string condition = HttpUtility.ParseQueryString(actionExecutedContext.Request.RequestUri.Query).Get("rf.condition");
            if (condition == "IsHoliday")
            {
                //bug in HttpRequestMessage : RequestUri setter not change Properties. Do it manually.
                //if (request.Properties.ContainsKey(System.Web.Http.Hosting.HttpPropertyKeys.RequestQueryNameValuePairsKey))
                //{
                //    request.Properties.Remove(System.Web.Http.Hosting.HttpPropertyKeys.RequestQueryNameValuePairsKey);
                //    request.GetQueryNameValuePairs();
                //}

                ObjectContent responseContent = actionExecutedContext.Response.Content as ObjectContent;
                IQueryable<WorkCalendar> query = null;
                if (responseContent != null)
                    query = responseContent.Value as IQueryable<WorkCalendar>;

                if (query != null)
                {
                    FilterParameterCollection fc = new FilterParameterCollection(typeof(WorkCalendar));
                    fc.Add("IsWorkingDay", false, OperatorType.Condition);
                    fc.OperatorActionResolver = new ConditionOpRes();
                    responseContent.Value = query.Filtering(fc);
                }
            }

            base.OnActionExecuted(actionExecutedContext);
        }
 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);
 }
Example #6
0
        private FilterParameterCollection GetFilters()
        {
            Type modelType = this.FilteredModelType;
            if (modelType == null)
            {
                var dobj = this.DataContext as DataObj;
                if (dobj != null)
                {
                    modelType = dobj.Model.GetType();
                }
            }

            if (modelType != null)
            {
                FilterParameterCollection fc = new FilterParameterCollection(modelType);
                foreach (FilterCC f in DispatcherHelper.FindVisualChildren<FilterCC>(this).Where(f => f.IsEnabled))
                {
                    if (f.Value != null)
                    {
                        if (f.Value.GetType() == typeof(string))
                        {
                            string s = f.Value as string;
                            if (string.IsNullOrEmpty(s) == false)
                            {
                                Type targtType = null;
                                var fiedInfo = modelType.GetProperty(f.FieldName);
                                if (fiedInfo != null)
                                {
                                    targtType = fiedInfo.PropertyType;
                                    var val = Convert.ChangeType(f.Value, targtType);
                                    OperatorType op = f.OperatorType;
                                    if (op == OperatorType.Equals && targtType == typeof(string))
                                    {
                                        if (s.Contains("?") || s.Contains("*"))
                                        {
                                            op = OperatorType.Like;
                                        }
                                    }
                                    fc.Add(f.FieldName, val, op);
                                }
                            }
                        }
                        else
                        {
                            fc.Add(f.FieldName, f.Value, f.OperatorType);
                        }
                    }
                    else if (f.OperatorType == OperatorType.IsNull || f.OperatorType == OperatorType.IsNotNull)
                    {
                        fc.Add(f.FieldName, f.Value, f.OperatorType);
                    }
                }
                return fc;
            }

            return null;
        }
Example #7
0
        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));
        }
Example #8
0
        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();
        }
Example #9
0
        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();
        }