System.Collections.Generic.List.Add(resource)

Here are the examples of the csharp api System.Collections.Generic.List.Add(resource) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

19 View Source File : roleResourceEx.cs
License : MIT License
Project Creator : ecjtuseclab

public List<resource> getRoleAllResource(int roleid, string owner = "")
        {
            List<resource> rr = new List<resource>();
            if (owner == "")//不指定属主则获取全部,否则获取指定属主的
            {
                rr = db.Queryable<resource>()
                       .JoinTable<role_resource>((s1, s2) => s1.id == s2.resoureceid)
                       .Where<role_resource>((s1, s2) => s2.roleid == roleid)
                    // .Where<resource>((s1, s2) => s1.resourcetype == type)
                       .Select("s1.*")
                       .ToList();
            }
            else
            {
                rr = db.Queryable<resource>()
                       .JoinTable<role_resource>((s1, s2) => s1.id == s2.resoureceid)
                       .Where<role_resource>((s1, s2) => s2.roleid == roleid)
                    //.Where<resource>((s1, s2) => s1.resourcetype == type)
                       .Where<resource>((s1, s2) => s1.resourceowner == owner)
                       .Select("s1.*")
                       .ToList();

            }
            List<resource> Irr=new List<resource>();
            foreach(resource r in rr)
            {
                Irr.Add(r as resource);
            }
            return Irr;
        }

19 View Source File : resourceEx.cs
License : MIT License
Project Creator : ecjtuseclab

public override bool copyAndPaste(string ids)
        {
            try
            {
                string[] id = ids.Split(',');
                List<resource> table = new List<resource>();

                for (int i = 0; i < id.Length; i++)
                {
                    table.Add(getEnreplacedyById(int.Parse(id[i])));
                    //copyAndPasteInert(table);                    
                }

                if (table.Count > 0)
                {
                    copyAndPasteInert(table);
                }

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

19 View Source File : resourceEx.cs
License : MIT License
Project Creator : ecjtuseclab

public List<resource> getResourceListByresourcename(string resourcename, List<resource> resourcelist)
        {
            List<resource> allresourcelist = getEnreplacedyList();
            resource reso = getSuperiorNode(resourcename);
            resourcelist.Add(reso);
            if (reso.resourceowner != "0")
                getResourceListByresourcename(reso.resourcename, resourcelist);
            return resourcelist;
        }

19 View Source File : roleResourceEx.cs
License : MIT License
Project Creator : ecjtuseclab

public List<resource> getRoleResource(int roleid, int type, string owner = "")
        {
            List<resource> rr = new List<resource>();
            if (owner == "")//不指定属主则获取全部,否则获取指定属主的
            {
                rr = db.Queryable<resource>()
                       .JoinTable<role_resource>((s1, s2) => s1.id == s2.resoureceid)
                       .Where<role_resource>((s1, s2) => s2.roleid == roleid)
                       .Where<resource>((s1, s2) => s1.resourcetype == type)
                       .Select("s1.*")
                       .ToList();
            }
            else
            {
                rr = db.Queryable<resource>()
                       .JoinTable<role_resource>((s1, s2) => s1.id == s2.resoureceid)
                       .Where<role_resource>((s1, s2) => s2.roleid == roleid)
                       .Where<resource>((s1, s2) => s1.resourcetype == type)
                       .Where<resource>((s1, s2) => s1.resourceowner == owner)
                       .Select("s1.*")
                       .ToList();

            }
            List<resource> Irr = new List<resource>();
            foreach (resource r in rr)
            {
                Irr.Add(r as resource);
            }
            return Irr;
        }

19 View Source File : roleResourceEx.cs
License : MIT License
Project Creator : ecjtuseclab

public List<resource> getRoleAllResource(int roleid, string owner = "")
        {
            List<resource> rr = new List<resource>();
            if (owner == "")//不指定属主则获取全部,否则获取指定属主的
            {
                rr = db.Queryable<resource>()
                       .JoinTable<role_resource>((s1, s2) => s1.id == s2.resoureceid)
                       .Where<role_resource>((s1, s2) => s2.roleid == roleid)
                    // .Where<resource>((s1, s2) => s1.resourcetype == type)
                       .Select("s1.*")
                       .ToList();
            }
            else
            {
                rr = db.Queryable<resource>()
                       .JoinTable<role_resource>((s1, s2) => s1.id == s2.resoureceid)
                       .Where<role_resource>((s1, s2) => s2.roleid == roleid)                    
                       .Where<resource>((s1, s2) => s1.resourceowner == owner)
                       .Select("s1.*")
                       .ToList();

            }
            List<resource> Irr = new List<resource>();
            foreach (resource r in rr)
            {
                Irr.Add(r as resource);
            }
            return Irr;
        }

19 View Source File : ResourceController.cs
License : MIT License
Project Creator : ecjtuseclab

public ActionResult GetTreeGridJson(Pagination pagination, string keyword, string _search, string filters)
        {
            try
            {
                string strValue = "";
                List<resource> data = IdalCommon.IresourceEx.getEnreplacedyList();
                List<resource> resourcelist = null;
                pagination.records = data.Count();
                var treeList = new List<TreeGridModel>();
                var p = (pagination.page - 1) * pagination.rows;
                List<resource> dlist = new List<resource>();
                if (_search == "true")
                {
                    strValue = JqGridHandler.getWhere(filters);
                    if (strValue != "")
                    {
                        strValue = "select * from role where" + "  " + strValue;
                        data = IdalCommon.IresourceEx.getSearch(strValue);
                        pagination.records = data.Count();
                        resourcelist = IdalCommon.IresourceEx.getPaginationEnreplacedyList(pagination.page, pagination.rows, data);
                    }
                }
                else
                {
                    data=IdalCommon.IresourceEx.getResourceList(keyword);
                    pagination.records = data.Count();
                    resourcelist = data.Skip(p).Take(pagination.rows).ToList();
                }
                /**************判断当前页的数据的父节点都包含在当前页中,不是则把父节点存入当前页*******************/
                
                foreach (resource re in resourcelist)
                {
                    if (!string.IsNullOrEmpty(re.resourceowner) && re.resourceowner != "0")
                    {
                        int count = resourcelist.Where(d => d.id.ToString() == re.resourceowner).Count();
                        if (count == 0)
                        {
                            resource rr = data.Where(d => d.id.ToString() == re.resourceowner).FirstOrDefault();
                            if (rr != null)
                                dlist.Add(rr);
                        }
                    }
                }
                if (dlist.Count() > 0 && dlist != null)
                {
                    dlist = dlist.Where((x, i) => dlist.FindIndex(z => z.id == x.id) == i).ToList();
                    resourcelist.AddRange(dlist);
                }
                /*************获取当前页需要显示的数据********************/
                foreach (resource item in resourcelist)
                {
                    TreeGridModel treeModel = new TreeGridModel();
                    bool hasChildren = data.Count(t => t.resourceowner == item.id.ToString()) == 0 ? false : true;
                    treeModel.id = item.id.ToString();
                    treeModel.isLeaf = hasChildren;
                    if (item.resourceowner == null)
                    {
                        treeModel.parentId = "0";
                    }
                    else
                    {
                        treeModel.parentId = item.resourceowner;
                    }
                    treeModel.expanded = hasChildren;
                    treeModel.enreplacedyJson = item.ToJson();
                    treeList.Add(treeModel);
                }
                string str = treeList.TreeGridJson().Substring(0, treeList.TreeGridJson().Length - 1) + ",\"total\":" + pagination.total + ",\"page\":" + pagination.page + ",\"records\":" + pagination.records + "}";
                return Content(str);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            
        }