Example #1
0
        public ActionResult ShowAdvanceFilter(string previousFilters = "")
        {
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_FormatApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Formats = _ISpartan_FormatApiConsumer.SelAll(true);

            if (Spartan_Formats != null && Spartan_Formats.Resource != null)
            {
                ViewBag.Spartan_Formats = Spartan_Formats.Resource.Select(m => new SelectListItem
                {
                    Text = m.Format_Name.ToString(), Value = Convert.ToString(m.FormatId)
                }).ToList();
            }


            var previousFiltersObj = new Spartan_Format_FieldAdvanceSearchModel();

            if (previousFilters != "")
            {
                previousFiltersObj = (Spartan_Format_FieldAdvanceSearchModel)(Session["AdvanceSearch"] ?? new Spartan_Format_FieldAdvanceSearchModel());
            }

            ViewBag.Filter = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = Resources.Resources.BeginWith, Value = "1"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.EndWith, Value = "2"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Contains, Value = "4"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Exact, Value = "3"
                },
            };

            return(View(previousFiltersObj));
        }
Example #2
0
        public ActionResult ShowAdvanceFilter(Spartan_Format_FieldAdvanceSearchModel model)
        {
            if (ModelState.IsValid)
            {
                Session["AdvanceSearch"] = model;
                return(RedirectToAction("Index"));
            }
            ViewBag.Filter = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = Resources.Resources.BeginWith, Value = "1"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.EndWith, Value = "2"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Contains, Value = "4"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Exact, Value = "3"
                },
            };
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_FormatApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Formats = _ISpartan_FormatApiConsumer.SelAll(true);

            if (Spartan_Formats != null && Spartan_Formats.Resource != null)
            {
                ViewBag.Spartan_Formats = Spartan_Formats.Resource.Select(m => new SelectListItem
                {
                    Text = m.Format_Name.ToString(), Value = Convert.ToString(m.FormatId)
                }).ToList();
            }


            return(View(model));
        }
Example #3
0
        public string GetAdvanceFilter(Spartan_Format_FieldAdvanceSearchModel filter)
        {
            var where = "";
            if (!string.IsNullOrEmpty(filter.FromFormatFieldId) || !string.IsNullOrEmpty(filter.ToFormatFieldId))
            {
                if (!string.IsNullOrEmpty(filter.FromFormatFieldId))
                {
                    where += " AND Spartan_Format_Field.FormatFieldId >= " + filter.FromFormatFieldId;
                }
                if (!string.IsNullOrEmpty(filter.ToFormatFieldId))
                {
                    where += " AND Spartan_Format_Field.FormatFieldId <= " + filter.ToFormatFieldId;
                }
            }

            if (!string.IsNullOrEmpty(filter.AdvanceFormat))
            {
                switch (filter.FormatFilter)
                {
                case Models.Filters.BeginWith:
                    where += " AND Spartan_Format.Format_Name LIKE '" + filter.AdvanceFormat + "%'";
                    break;

                case Models.Filters.EndWith:
                    where += " AND Spartan_Format.Format_Name LIKE '%" + filter.AdvanceFormat + "'";
                    break;

                case Models.Filters.Exact:
                    where += " AND Spartan_Format.Format_Name = '" + filter.AdvanceFormat + "'";
                    break;

                case Models.Filters.Contains:
                    where += " AND Spartan_Format.Format_Name LIKE '%" + filter.AdvanceFormat + "%'";
                    break;
                }
            }
            else if (filter.AdvanceFormatMultiple != null && filter.AdvanceFormatMultiple.Count() > 0)
            {
                var FormatIds = string.Join(",", filter.AdvanceFormatMultiple);

                where += " AND Spartan_Format_Field.Format In (" + FormatIds + ")";
            }

            if (!string.IsNullOrEmpty(filter.Field_Path))
            {
                switch (filter.Field_PathFilter)
                {
                case Models.Filters.BeginWith:
                    where += " AND Spartan_Format_Field.Field_Path LIKE '" + filter.Field_Path + "%'";
                    break;

                case Models.Filters.EndWith:
                    where += " AND Spartan_Format_Field.Field_Path LIKE '%" + filter.Field_Path + "'";
                    break;

                case Models.Filters.Exact:
                    where += " AND Spartan_Format_Field.Field_Path = '" + filter.Field_Path + "'";
                    break;

                case Models.Filters.Contains:
                    where += " AND Spartan_Format_Field.Field_Path LIKE '%" + filter.Field_Path + "%'";
                    break;
                }
            }

            if (!string.IsNullOrEmpty(filter.Physical_Field_Name))
            {
                switch (filter.Physical_Field_NameFilter)
                {
                case Models.Filters.BeginWith:
                    where += " AND Spartan_Format_Field.Physical_Field_Name LIKE '" + filter.Physical_Field_Name + "%'";
                    break;

                case Models.Filters.EndWith:
                    where += " AND Spartan_Format_Field.Physical_Field_Name LIKE '%" + filter.Physical_Field_Name + "'";
                    break;

                case Models.Filters.Exact:
                    where += " AND Spartan_Format_Field.Physical_Field_Name = '" + filter.Physical_Field_Name + "'";
                    break;

                case Models.Filters.Contains:
                    where += " AND Spartan_Format_Field.Physical_Field_Name LIKE '%" + filter.Physical_Field_Name + "%'";
                    break;
                }
            }

            if (!string.IsNullOrEmpty(filter.Logical_Field_Name))
            {
                switch (filter.Logical_Field_NameFilter)
                {
                case Models.Filters.BeginWith:
                    where += " AND Spartan_Format_Field.Logical_Field_Name LIKE '" + filter.Logical_Field_Name + "%'";
                    break;

                case Models.Filters.EndWith:
                    where += " AND Spartan_Format_Field.Logical_Field_Name LIKE '%" + filter.Logical_Field_Name + "'";
                    break;

                case Models.Filters.Exact:
                    where += " AND Spartan_Format_Field.Logical_Field_Name = '" + filter.Logical_Field_Name + "'";
                    break;

                case Models.Filters.Contains:
                    where += " AND Spartan_Format_Field.Logical_Field_Name LIKE '%" + filter.Logical_Field_Name + "%'";
                    break;
                }
            }

            if (!string.IsNullOrEmpty(filter.FromCreation_Date) || !string.IsNullOrEmpty(filter.ToCreation_Date))
            {
                var Creation_DateFrom = DateTime.ParseExact(filter.FromCreation_Date, ConfigurationProperty.DateFormat,
                                                            CultureInfo.InvariantCulture as IFormatProvider);
                var Creation_DateTo = DateTime.ParseExact(filter.ToCreation_Date, ConfigurationProperty.DateFormat,
                                                          CultureInfo.InvariantCulture as IFormatProvider);

                if (!string.IsNullOrEmpty(filter.FromCreation_Date))
                {
                    where += " AND Spartan_Format_Field.Creation_Date >= '" + Creation_DateFrom.ToString("MM-dd-yyyy") + "'";
                }
                if (!string.IsNullOrEmpty(filter.ToCreation_Date))
                {
                    where += " AND Spartan_Format_Field.Creation_Date <= '" + Creation_DateTo.ToString("MM-dd-yyyy") + "'";
                }
            }

            if (!string.IsNullOrEmpty(filter.FromCreation_Hour) || !string.IsNullOrEmpty(filter.ToCreation_Hour))
            {
                if (!string.IsNullOrEmpty(filter.FromCreation_Hour))
                {
                    where += " AND Convert(TIME,Spartan_Format_Field.Creation_Hour) >='" + filter.FromCreation_Hour + "'";
                }
                if (!string.IsNullOrEmpty(filter.ToCreation_Hour))
                {
                    where += " AND Convert(TIME,Spartan_Format_Field.Creation_Hour) <='" + filter.ToCreation_Hour + "'";
                }
            }

            if (!string.IsNullOrEmpty(filter.FromCreation_User) || !string.IsNullOrEmpty(filter.ToCreation_User))
            {
                if (!string.IsNullOrEmpty(filter.FromCreation_User))
                {
                    where += " AND Spartan_Format_Field.Creation_User >= " + filter.FromCreation_User;
                }
                if (!string.IsNullOrEmpty(filter.ToCreation_User))
                {
                    where += " AND Spartan_Format_Field.Creation_User <= " + filter.ToCreation_User;
                }
            }

            if (!string.IsNullOrEmpty(filter.Properties))
            {
                switch (filter.PropertiesFilter)
                {
                case Models.Filters.BeginWith:
                    where += " AND Spartan_Format_Field.Properties LIKE '" + filter.Properties + "%'";
                    break;

                case Models.Filters.EndWith:
                    where += " AND Spartan_Format_Field.Properties LIKE '%" + filter.Properties + "'";
                    break;

                case Models.Filters.Exact:
                    where += " AND Spartan_Format_Field.Properties = '" + filter.Properties + "'";
                    break;

                case Models.Filters.Contains:
                    where += " AND Spartan_Format_Field.Properties LIKE '%" + filter.Properties + "%'";
                    break;
                }
            }


            where = new Regex(Regex.Escape("AND ")).Replace(where, "", 1);
            return(where);
        }