コード例 #1
0
        public List <RiskMitigationFormStub> GetRiskMitigations(int?riskId)
        {
            List <RiskMitigationFormStub> riskMitigations = new List <RiskMitigationFormStub>();

            var filters = new Business.Infrastructure.FilterInfo
            {
                Logic   = "and",
                Filters = new List <Business.Infrastructure.FilterInfo>()
            };

            if (riskId != null)
            {
                filters.Filters.Add(new Business.Infrastructure.FilterInfo
                {
                    Field    = "RiskId",
                    Operator = "eq",
                    Value    = riskId.ToString()
                });
            }
            foreach (Business.Entities.RiskMitigation riskMitigation in RiskMitigationRepo.Find(null, null, null, filters, false))
            {
                riskMitigations.Add(new RiskMitigationFormStub(riskMitigation));
            }
            return(riskMitigations);
        }
コード例 #2
0
        public List<Module> Find(int skip = 0, int? take = null, List<SortingInfo> sortings = null, FilterInfo filters = null, string filterLogic = null)
        {
            IQueryable<Module> modules = context.Modules;

            if (filters != null && (filters.Filters != null && filters.Filters.Count > 0))
            {
                filters.FormatFieldToUnderscore();
                GridHelper.ProcessFilters<Business.Entities.Module>(filters, ref modules);
            }

            if (sortings != null && sortings.Count > 0)
            {
                foreach (var s in sortings)
                {
                    string sortOn = this.MapSort(s.SortOn);
                    modules = modules.OrderBy(sortOn + " " + s.SortOrder);
                }
            }
            else
            {
                modules = modules.OrderBy("ModuleName asc");
            }

            var takeModules = modules;
            if (take != null)
            {
                takeModules = modules.Skip(skip).Take((int)take);
            }

            List<Module> moduleList = takeModules.ToList();

            return moduleList;
        }
コード例 #3
0
        public List <RiskImpactFormStub> GetRiskImpacts(int?riskId)
        {
            List <RiskImpactFormStub> riskImpacts = new List <RiskImpactFormStub>();

            var filters = new Business.Infrastructure.FilterInfo
            {
                Logic   = "and",
                Filters = new List <Business.Infrastructure.FilterInfo>()
            };

            if (riskId != null)
            {
                filters.Filters.Add(new Business.Infrastructure.FilterInfo
                {
                    Field    = "RiskId",
                    Operator = "eq",
                    Value    = riskId.ToString()
                });
            }
            List <SortingInfo> sortings = new List <SortingInfo>();

            sortings.Add(new SortingInfo
            {
                SortOn    = "Type",
                SortOrder = "ASC"
            });
            foreach (Business.Entities.RiskImpact riskImpact in RiskImpactRepo.Find(null, null, sortings, filters, false))
            {
                riskImpacts.Add(new RiskImpactFormStub(riskImpact));
            }

            return(riskImpacts);
        }
コード例 #4
0
        public ActionResult EditRiskImpact(int riskId)
        {
            var filters = new Business.Infrastructure.FilterInfo
            {
                Logic   = "and",
                Filters = new List <Business.Infrastructure.FilterInfo>()
            };

            filters.Filters.Add(new Business.Infrastructure.FilterInfo
            {
                Field    = "RiskId",
                Operator = "eq",
                Value    = riskId.ToString()
            });
            var sortings = new List <SortingInfo>();

            sortings.Add(new SortingInfo
            {
                SortOn    = "Type",
                SortOrder = "ASC"
            });
            List <RiskImpactFormStub> models = makeListRiskImpactFormStub(RiskImpactRepo.Find(null, null, sortings, filters, false));
            string riskEvent = RiskRepo.FindByPk(riskId).RiskEvent;

            foreach (RiskImpactFormStub model in models)
            {
                model.RiskEvent = riskEvent;
            }
            ViewBag.Title = "Ubah Dampak";

            return(View("_FormRiskImpact", models));
        }
コード例 #5
0
        /// <summary>
        /// count where !is_delete
        /// </summary>
        /// <param name="filters"></param>
        /// <returns></returns>
        public int Count(FilterInfo filters = null)
        {
            IQueryable<currency> list = IQCurrency(null, filters);

            int count = list.Count();

            return count;
        }
コード例 #6
0
        public int Count(FilterInfo filters = null)
        {
            IQueryable<company> items = context.companies;

            if (filters != null && (filters.Filters != null && filters.Filters.Count > 0))
            {
                GridHelper.ProcessFilters<company>(filters, ref items);
            }

            return items.Count();
        }
コード例 #7
0
        public int Count(FilterInfo filters = null)
        {
            IQueryable<tbKaryawan> items = context.tbKaryawans;

            if (filters != null && (filters.Filters != null && filters.Filters.Count > 0))
            {
                GridHelper.ProcessFilters<tbKaryawan>(filters, ref items);
            }

            return items.Count();
        }
コード例 #8
0
        public int Count(FilterInfo filters = null)
        {
            IQueryable<m_project> items = context.m_project;

            if (filters != null && (filters.Filters != null && filters.Filters.Count > 0))
            {
                GridHelper.ProcessFilters<m_project>(filters, ref items);
            }

            return items.Count();
        }
コード例 #9
0
        public int Count(FilterInfo filters = null)
        {
            IQueryable<Crew_Whitelist> items = context.Crew_Whitelist;

            if (filters != null && (filters.Filters != null && filters.Filters.Count > 0))
            {
                GridHelper.ProcessFilters<Crew_Whitelist>(filters, ref items);
            }

            return items.Count();
        }
コード例 #10
0
        //public bank FindByPk(int id)
        //{
        //    return context.banks.Where(m => (m.id == id)).FirstOrDefault();
        //}
        /// <summary>
        /// </summary>
        /// <param name="filters"></param>
        /// <returns></returns>
        public int Count(FilterInfo filters = null)
        {
            IQueryable<log> items = context.logs;

            if (filters != null && (filters.Filters != null && filters.Filters.Count > 0))
            {
                GridHelper.ProcessFilters<log>(filters, ref items);
            }

            int count = items.Count();

            return count;
        }
コード例 #11
0
        public string Binding()
        {
            GridRequestParameters param = GridRequestParameters.Current;

            Business.Infrastructure.FilterInfo filters = new Business.Infrastructure.FilterInfo
            {
                Field = "Action",
                Operator = "startswith",
                Value = "/Log"
            };
            //param.Filters = filters;
            List<log> items = RepoLog.Find(param.Skip, param.Take, (param.Sortings != null ? param.Sortings.ToList() : null), (param.Filters != null ? param.Filters : null));
            int total = RepoLog.Count(param.Filters);

            return new JavaScriptSerializer().Serialize(new { total = total, data = new LogPresentationStub().MapList(items) });
        }
コード例 #12
0
        public string Binding()
        {
            GridRequestParameters param = GridRequestParameters.Current;

            Business.Infrastructure.FilterInfo filters = new Business.Infrastructure.FilterInfo
            {
                Field    = "Action",
                Operator = "startswith",
                Value    = "/Log"
            };
            //param.Filters = filters;
            List <log> items = RepoLog.Find(param.Skip, param.Take, (param.Sortings != null ? param.Sortings.ToList() : null), (param.Filters != null ? param.Filters : null));
            int        total = RepoLog.Count(param.Filters);

            return(new JavaScriptSerializer().Serialize(new { total = total, data = new LogPresentationStub().MapList(items) }));
        }
コード例 #13
0
        private List <RiskPresentationStub> GoToIndex(int?year)
        {
            //kamus
            Session["target"] = "target125";
            List <RiskPresentationStub> risks = new List <RiskPresentationStub>();

            EnumHelper         eh       = new EnumHelper();
            List <SortingInfo> sortings = new List <SortingInfo>();

            //algoritma
            //if (year != null) risk.Year = year.Value;

            var filters = new Business.Infrastructure.FilterInfo
            {
                Logic   = "and",
                Filters = new List <Business.Infrastructure.FilterInfo>()
            };

            filters.Filters.Add(new Business.Infrastructure.FilterInfo
            {
                Field    = "Year",
                Operator = "eq",
                Value    = year.Value.ToString()
            });

            var sorting = new Business.Infrastructure.SortingInfo
            {
                SortOn    = "RiskId",
                SortOrder = "DESC"
            };

            sortings.Add(sorting);

            List <Business.Entities.Risk> risks_temp = RiskRepo.Find(null, null, sortings, filters, false);

            foreach (Business.Entities.Risk risk in risks_temp)
            {
                RiskPresentationStub riskPresentationStub = new RiskPresentationStub(risk);

                riskPresentationStub.RiskImpacts     = GetRiskImpacts(risk.RiskId);
                riskPresentationStub.RiskMitigations = GetRiskMitigations(risk.RiskId);

                risks.Add(riskPresentationStub);
            }

            return(risks);
        }
コード例 #14
0
        /// <summary>
        /// find where !is_delete
        /// </summary>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <param name="sortings"></param>
        /// <param name="filters"></param>
        /// <returns></returns>
        public List<currency> Find(int? skip = null, int? take = null, List<SortingInfo> sortings = null, FilterInfo filters = null)
        {
            IQueryable<currency> list = IQCurrency(sortings, filters);

            //take & skip
            var takeList = list;
            if (skip != null)
            {
                takeList = takeList.Skip(skip.Value);
            }
            if (take != null)
            {
                takeList = takeList.Take(take.Value);
            }

            //return result
            List<currency> result = takeList.ToList();
            return result;
        }
コード例 #15
0
        public async Task <JsonResult> GetJsonTopRiskDetailIndex(string riskIdList)
        {
            //ambil2in risk
            var filters = new Business.Infrastructure.FilterInfo
            {
                Logic   = "and",
                Filters = new List <Business.Infrastructure.FilterInfo>()
            };

            filters.Filters.Add(new Business.Infrastructure.FilterInfo
            {
                Logic   = "or",
                Filters = new List <Business.Infrastructure.FilterInfo>()
            });

            int riskId = 0;

            foreach (string riskIdStr in riskIdList.Split(','))
            {
                if (int.TryParse(riskIdStr, out riskId))
                {
                    filters.Filters[0].Filters.Add(new Business.Infrastructure.FilterInfo
                    {
                        Field    = "RiskId",
                        Operator = "eq",
                        Value    = riskId.ToString()
                    });
                }
            }

            List <RiskPresentationStub>   listRisk = new List <RiskPresentationStub>();
            List <Business.Entities.Risk> risks    = await RiskRepo.FindAsync(null, null, null, filters, false);

            foreach (Business.Entities.Risk risk in risks)
            {
                listRisk.Add(new RiskPresentationStub(risk));
            }

            return(Json(listRisk, JsonRequestBehavior.AllowGet));
        }
コード例 #16
0
        public List<Crew_Whitelist> FindAll(int? skip = null, int? take = null, List<SortingInfo> sortings = null, FilterInfo filters = null)
        {
            IQueryable<Crew_Whitelist> list = context.Crew_Whitelist;

            if (filters != null && (filters.Filters != null && filters.Filters.Count > 0))
            {
                filters.FormatFieldToUnderscore();
                GridHelper.ProcessFilters<Crew_Whitelist>(filters, ref list);
            }

            if (sortings != null && sortings.Count > 0)
            {
                foreach (var s in sortings)
                {
                    s.FormatSortOnToUnderscore();
                    list = list.OrderBy<Crew_Whitelist>(s.SortOn + " " + s.SortOrder);
                }
            }
            else
            {
                list = list.OrderBy<Crew_Whitelist>("id desc"); //default, wajib ada atau EF error
            }

            //take & skip
            var takeList = list;
            if (skip != null)
            {
                takeList = takeList.Skip(skip.Value);
            }
            if (take != null)
            {
                takeList = takeList.Take(take.Value);
            }

            //return result
            //var sql = takeList.ToString();
            List<Crew_Whitelist> result = takeList.ToList();
            return result;
        }
コード例 #17
0
        /// <summary>
        /// </summary>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <param name="sortings"></param>
        /// <param name="filters"></param>
        /// <returns></returns>
        public List<log> Find(int? skip = null, int? take = null, List<SortingInfo> sortings = null, FilterInfo filters = null)
        {
            IQueryable<log> list = context.logs;

            if (filters != null && ((filters.Filters != null && filters.Filters.Count > 0) || (filters.Operator != null && filters.Operator != "")))
            {
                filters.FormatFieldToUnderscore();
                GridHelper.ProcessFilters<log>(filters, ref list);
            }

            if (sortings != null && sortings.Count > 0)
            {
                GridHelper.ProcessSorts<log>(sortings, ref list);
            }
            else
            {
                list = list.OrderByDescending(m => m.id); //default, wajib ada atau EF error
            }

            //filter
            //list = list.Where(i => i.show == 1);

            //take & skip
            var takeList = list;
            if (skip != null)
            {
                takeList = takeList.Skip(skip.Value);
            }
            if (take != null)
            {
                takeList = takeList.Take(take.Value);
            }

            //return result
            List<log> result = takeList.ToList();
            return result;
        }
コード例 #18
0
        public FilterInfo Clone()
        {
            FilterInfo clone = new FilterInfo { Field = this.Field, Logic = this.Logic, Operator = this.Operator, Value = this.Value };

            if (Filters != null)
            {
                clone.Filters = new List<FilterInfo>();
                foreach (var f in Filters)
                {
                    clone.Filters.Add(f.Clone());
                }
            }

            return clone;
        }
コード例 #19
0
        private IQueryable<currency> IQCurrency(List<SortingInfo> sortings = null, FilterInfo filters = null)
        {
            //kamus
            IQueryable<currency> list = context.currency;
            string sort = "";
            List<string> sortArr = new List<string>();

            //algoritma
            if (filters != null)
            {
                filters.FormatFieldToUnderscore();
                GridHelper.ProcessFilters<currency>(filters, ref list);
            }

            if (sortings != null && sortings.Count > 0)
            {
                foreach (var s in sortings)
                {
                    s.FormatSortOnToUnderscore();
                    sortArr.Add(s.SortOn + " " + s.SortOrder);
                }

                sort = string.Join(",", sortArr);
                list = list.OrderBy<currency>(sort);
            }
            else
            {
                list = list.OrderByDescending(m => m.id); //default, wajib ada atau EF error
            }

            list = list.Where(i => i.is_delete == false);

            return list;
        }
コード例 #20
0
        //TODO: pull default values from config
        internal void Populate()
        {
            if (HttpContext.Current != null)
            {
                HttpRequest curRequest = HttpContext.Current.Request;
                if (curRequest["page"] != null)
                    this.Page = int.Parse(curRequest["page"]);
                if (curRequest["pageSize"] != null)
                    this.PageSize = int.Parse(curRequest["pageSize"]);
                if (curRequest["skip"] != null)
                    this.Skip = int.Parse(curRequest["skip"]);
                if (curRequest["take"] != null)
                    this.Take = int.Parse(curRequest["take"]);
                //this.FilterLogic = curRequest["filter[logic]"];

                //build sorting objects
                var sorts = new List<SortingInfo>();
                var x = 0;
                while (x < 20)
                {
                    var sortDirection = curRequest["sort[" + x + "][dir]"];
                    if (sortDirection == null)
                    {
                        break;
                    }
                    var sortOn = curRequest["sort[" + x + "][field]"];
                    if (sortOn != null)
                    {
                        sorts.Add(new SortingInfo { SortOn = sortOn, SortOrder = sortDirection });
                    }
                    x++;
                }
                Sortings = sorts;

                //build filter objects
                var filters = new FilterInfo();
                var logic = curRequest["filter[logic]"];
                filters.Logic = logic;

                bool stopLevel1 = false; int level1 = 0;
                while (!stopLevel1)
                {
                    FilterInfo fi = new FilterInfo();
                    var field1 = curRequest["filter[filters][" + level1 + "][field]"];
                    if (field1 == null)
                    {
                        field1 = curRequest["filter[filters][" + level1 + "][filters][0][field]"];
                        if (field1 == null)
                            stopLevel1 = true;
                        else //level 1
                        {
                            fi.Logic = curRequest["filter[filters][" + level1 + "][logic]"];

                            bool stopLevel2 = false; int level2 = 0;
                            while (!stopLevel2)
                            {
                                var field2 = curRequest["filter[filters][" + level1 + "][filters][" + level2 + "][field]"];
                                if (field2 == null)
                                    stopLevel2 = true;
                                else
                                {
                                    var fi2 = new FilterInfo();
                                    fi2.Field = curRequest["filter[filters][" + level1 + "][filters][" + level2 + "][field]"];
                                    fi2.Operator = curRequest["filter[filters][" + level1 + "][filters][" + level2 + "][operator]"];
                                    fi2.Value = curRequest["filter[filters][" + level1 + "][filters][" + level2 + "][value]"];

                                    if (fi.Filters == null)
                                        fi.Filters = new List<FilterInfo>();
                                    fi.Filters.Add(fi2);

                                    ++level2;
                                }
                            }
                        }
                    }
                    else
                    {
                        fi.Field = field1;
                        fi.Operator = curRequest["filter[filters][" + level1 + "][operator]"];
                        fi.Value = curRequest["filter[filters][" + level1 + "][value]"];
                    }

                    if (!stopLevel1)
                    {
                        if (filters.Filters == null)
                            filters.Filters = new List<FilterInfo>();
                        filters.Filters.Add(fi);

                        ++level1;
                    }
                }

                Filters = filters;
            }
        }