Beispiel #1
0
        public static IList <SelectProject> GetProject(string userCode, IList <string> stateList, string code, string name)
        {
            IList <string>       busiDataId = PrivHelper.GetBusiDataId("project", userCode);
            PTPrjInfoService     service    = new PTPrjInfoService();
            List <SelectProject> first      = new List <SelectProject>();
            int num = (busiDataId.Count / 0x5dc) + 1;

            for (int i = 0; i < num; i++)
            {
                List <string>        theIdList = busiDataId.Skip <string>((i * 0x5dc)).Take <string>(0x5dc).ToList <string>();
                List <SelectProject> second    = (from p in service
                                                  where (((stateList.Contains(p.PrjState.ToString()) && theIdList.Contains(p.PrjGuid.ToString())) && (p.IsValid == "1")) && p.PrjCode.Contains(code)) && p.PrjName.Contains(name)
                                                  select new SelectProject {
                    Id = p.PrjGuid.Value.ToString(), Code = p.PrjCode, Name = p.PrjName, TypeCode = p.TypeCode, OwnerCode = p.OwnerCode.ToString(), Place = p.PrjPlace, State = p.PrjState.Value, Order = p.StartDate.Value.ToString("yyyyMMdd"), IsParent = true
                }).ToList <SelectProject>();
                first = first.Union <SelectProject>(second).ToList <SelectProject>();
            }
            for (int j = 0; j < first.Count; j++)
            {
                SelectProject project = first[j];
                if (project.TypeCode.Length == 10)
                {
                    // PTPrjInfo parent = service.GetParent(project.Id);
                    //if (parent != null)
                    //{
                    //    project.Order = parent.StartDate.Value.ToString("yyyyMMdd") + project.Order;
                    //}
                    DataSet ds = service.GetParentDS(project.Id);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string str = Convert.ToDateTime(ds.Tables[0].Rows[0]["StartDate"]).ToString("yyyyMMdd");
                        project.Order = project.TypeCode + str;//ds.Tables[0].Rows[0]["StartDate"].ToString("yyyyMMdd") + project.Order;
                    }
                    if (ExistParent(project.TypeCode, first))
                    {
                        project.IsParent = false;
                    }
                }
                else
                {
                    project.Order = project.TypeCode + "99999999";
                }
            }
            return((from p in first
                    orderby p.Order descending
                    select p).ToList <SelectProject>());
        }