示例#1
0
 public static FunctionReportViewModel RecursiveLimited(FunctionReportViewModel function, List <FunctionReportViewModel> functList)
 {
     if (function == null)
     {
         return(null);
     }
     if (functList.Where(c => c.FUNCCODE == function.FUNCPARENT).Count() < 1)
     {
         //if (string.IsNullOrEmpty(function.FUNCPORTCD))
         //    return null;
         return(function);
     }
     else
     {
         List <FunctionReportViewModel> newList = new List <FunctionReportViewModel>();
         foreach (FunctionReportViewModel ca in functList.Where(c => c.FUNCCODE == function.FUNCPARENT))
         {
             FunctionReportViewModel org = RecursiveLimited(ca, functList);
             if (org != null)
             {
                 if (newList.Where(p => p.FUNCCODE == org.FUNCCODE).FirstOrDefault() == null)
                 {
                     newList.Add(org);
                 }
             }
         }
         function.FunctionReportViewModels = newList;
         return(function);
     }
 }
示例#2
0
        public static FunctionReportViewModel FunctRecursive(FunctionReportViewModel org, List <FunctionReportViewModel> list)
        {
            var objects = list.Where(c => c.FUNCPARENT == org.FUNCCODE);

            if (objects.Count() < 1)
            {
                return(org);
            }
            else
            {
                List <FunctionReportViewModel> newList = new List <FunctionReportViewModel>();
                foreach (FunctionReportViewModel ca in objects)
                {
                    FunctionReportViewModel child = FunctRecursive(ca, list);
                    if (child != null)
                    {
                        if (newList.Where(p => p.FUNCCODE == child.FUNCCODE).FirstOrDefault() == null)
                        {
                            newList.Add(child);
                        }
                    }
                }
                org.FunctionReportViewModels = newList;
                return(org);
            }
        }
示例#3
0
        public static List <FunctionReportViewModel> getTreeFunctionReports(int?deptFunction)
        {
            var data = getTreeFunctionReports();
            List <FunctionReportViewModel> functReportList = new List <FunctionReportViewModel>();
            FunctionReportViewModel        functReport     = data.Where(p => p.FUNCPARENT == null || p.FUNCPARENT == string.Empty).FirstOrDefault();
            FunctionReportViewModel        root            = Recursive(functReport, data);

            if (root != null)
            {
                functReportList.Add(root);
            }
            return(functReportList);
        }
示例#4
0
        //Version 2.0 for improving performance.
        public static List <FunctionReportViewModel> getTreeFunctionDepts()
        {
            var functReports = getFunctReportsRegistered();//Lay all GeoReport.

            if (functReports == null || functReports.Count == 0)
            {
                return(new List <FunctionReportViewModel>());
            }
            var data = getTreeFunctionReports();

            List <FunctionReportViewModel> result = new List <FunctionReportViewModel>();
            FunctionReportViewModel        root   = new FunctionReportViewModel();

            foreach (FunctionReportViewModel funct in functReports)
            {
                FunctionReportViewModel functTemp = funct;
                funct.isChild = false;
                while (functTemp != null && functTemp.FUNCPARENT != null && !string.IsNullOrEmpty(functTemp.FUNCPARENT))
                {
                    if (result.Where(r => r.FUNCCODE == functTemp.FUNCCODE).FirstOrDefault() == null)
                    {
                        result.Add(functTemp);
                    }
                    functTemp = data.Where(g => g.FUNCCODE == functTemp.FUNCPARENT).FirstOrDefault();
                    if (functTemp != null)
                    {
                        functTemp.isChild = true;
                        root = functTemp;
                    }
                }
            }
            if (result.Where(r => r.FUNCCODE == root.FUNCCODE).FirstOrDefault() == null)
            {
                result.Add(root);
            }
            List <FunctionReportViewModel> finalResult = new List <FunctionReportViewModel>();
            FunctionReportViewModel        functRoot   = FunctRecursive(root, result);

            if (functRoot != null)
            {
                finalResult.Add(functRoot);
            }
            return(finalResult);
        }
示例#5
0
        public static List <FunctionReportViewModel> getTreeFunctionReports()
        {
            List <FunctionReportViewModel> functionReports = new List <FunctionReportViewModel>();
            FunctionReportAccess           access          = new FunctionReportAccess();
            DataTable dtResult = access.GetTreeFunctionReports();

            foreach (DataRow dtr in dtResult.Rows)
            {
                FunctionReportViewModel item = new FunctionReportViewModel
                {
                    FUNCPORTCD = dtr["FUNCPORTCD"].ToString(),
                    FUNCNAME   = dtr["FUNCNAME"].ToString(),
                    FUNCCODE   = dtr["FUNCCODE"].ToString(),
                    FUNCPARENT = dtr["FUNCPARENT"].ToString()
                };
                functionReports.Add(item);
            }
            return(functionReports);
        }
示例#6
0
        /*
         * Process for FunctionUser.
         */
        public static List <FunctionReportViewModel> getTreeLimitedFunctionReports(string deptFunction)
        {
            var data = getTreeFunctionReports();
            List <FunctionReportViewModel> functReportList = new List <FunctionReportViewModel>();
            FunctionReportViewModel        functReport     = data.Where(p => p.FUNCCODE == deptFunction).FirstOrDefault();
            FunctionReportViewModel        root            = RecursiveLimited(functReport, data);

            if (root != null)
            {
                functReportList.Add(root);
            }

            FunctionReportViewModel        current       = root;
            List <FunctionReportViewModel> result        = new List <FunctionReportViewModel>();
            List <FunctionReportViewModel> usergeoreport = new List <FunctionReportViewModel>();

            if (current != null)
            {
                result.Add(current);

                while (current.FunctionReportViewModels.Count() > 0)
                {
                    current = current.FunctionReportViewModels[0];
                    result.Add(current);
                }
                result.Reverse();
                for (int i = 0; i < result.Count; i++)
                {
                    result[i].FunctionReportViewModels.Clear();
                }
                for (int i = 0; i < result.Count - 1; i++)
                {
                    result[i].FunctionReportViewModels.Add(result[i + 1]);
                }
                usergeoreport.Add(result[0]);
            }
            return(usergeoreport);

            //return functReportList;
        }