Exemplo n.º 1
0
 public Models.StructureUnit GetUser(string id, string filialCode)
 {
     Models.StructureUnit ret = new Models.StructureUnit();
     using (Models.PhonesDataContext model = new Models.PhonesDataContext())
     {
         ret = model.Phones.Where(x => x.Code == id.Replace("-", ".") && x.Dep == null)
               .ToList()
               .Select(x => new Models.StructureUnit()
         {
             Code                = x.Code.Replace(".", "-"),
             Level               = id.Trim().Split('.').Count() + 1,
             Current             = false,
             Name                = x.PIB,
             Type                = "user",
             FunctionDescription = x.Function,
             BirthDate           = x.Birthday,
             Email               = x.Email,
             Mobile              = x.Mobile,
             Phones              = x.Phone1,
             Post                = GetFullPost(x.Code),
             //Photo = Photo(x.Email),
             PhotoFileName = PhotoName(x.Email)
         }).ToList().First();
     }
     return(ret);
 }
Exemplo n.º 2
0
        private List <Models.StructureUnit> BuilAUTree(Models.StructureUnit item)
        {
            List <Models.StructureUnit> ret = new List <Models.StructureUnit>();

            using (Models.PhonesDataContext model = new Models.PhonesDataContext())
            {
                if (model.Phones.ToList().Count(x => x.Code != null &&
                                                x.Code.StartsWith(item.Code + ".") &&
                                                x.Code.Split('.').Count() == (item.Code.Split('.').Count() + 1) &&
                                                x.Dep != null
                                                ) > 0)
                {
                    foreach (var subItem in model.Phones.ToList().Where(x => x.Code != null &&
                                                                        x.Code.StartsWith(item.Code + ".") &&
                                                                        x.Code.Split('.').Count() == (item.Code.Split('.').Count() + 1) &&
                                                                        x.Dep != null))
                    {
                        Models.StructureUnit su = new Models.StructureUnit();
                        su.Code     = subItem.Code;
                        su.Name     = subItem.Dep;
                        su.Children = BuilAUTree(su);
                        ret.Add(su);
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 3
0
        public Models.StructureUnit GetUserInfo(string CodeId)
        {
            Models.StructureUnit user = new Models.StructureUnit();
            string Id = CodeId.Replace("-", ".").Trim();

            using (Models.PhonesDataContext model = new Models.PhonesDataContext())
            {
                if (model.Phones.Count(x => x.Code == Id && x.PIB != null) > 0)
                {
                    var u = model.Phones.First(x => x.Code == Id);
                    user.Code          = u.Code;
                    user.Name          = u.PIB;
                    user.Post          = u.Post;
                    user.Email         = u.Email;
                    user.Phones        = u.Phone1;
                    user.Mobile        = u.Mobile;
                    user.PhotoFileName = DepController.PhotoName(u.Email);

                    string currDepId = "";
                    user.FullPost = "";
                    foreach (var depId in u.Code.Split('.').ToList())
                    {
                        currDepId += depId;
                        if (model.Phones.Count(x => x.Dep != null && x.Code == currDepId) > 0)
                        {
                            user.FullPost += model.Phones.First(x => x.Dep != null && x.Code == currDepId).Dep + " ";
                        }
                        currDepId += ".";
                    }
                }
            }
            return(user);
        }
Exemplo n.º 4
0
        public List <Models.StructureUnit> GetAUTree(string function)
        {
            List <Models.StructureUnit> ret = new List <Models.StructureUnit>();

            Models.StructureUnit su = new Models.StructureUnit();
            su.Code = function;
            ret     = BuilAUTree(su);
            //using (Models.PhonesDataContext model = new Models.PhonesDataContext())
            //{
            //        ///---Добавляю дочерние элементы-подразделения
            //        if (model.Phones.Where(x => x.Code.StartsWith(id.Trim() + ".") && x.Dep != null).Count() > 0)
            //        {
            //            foreach (var dep in model.Phones.Where(x => x.Code.StartsWith(id.Trim() + ".") && x.Dep != null)
            //                .ToList()
            //                .Select(x => new Models.StructureUnit()
            //                {
            //                    Code = x.Code,
            //                    Level = x.Code.Trim().Split('.').Count(),
            //                    Current = false,
            //                    Name = x.Dep,
            //                    Type = "dep",
            //                    FunctionDescription = x.Function
            //                }).ToList())
            //            {
            //                ret.Add(dep);
            //            }
            //        }

            //        ///---Добавляю дочерние элементы-сотрудники
            //        if (model.Phones.Where(x => x.Code.StartsWith(id.Trim() + ".") && x.PIB != null).Count() > 0)
            //        {
            //            string startWith = id.Trim() + ".";
            //            var users = model.Phones.Where(x => x.Code.StartsWith(startWith) && x.PIB != null).ToList();

            //            foreach (var user in users
            //                .Select(x => new Models.StructureUnit()
            //                {
            //                    Code = x.Code.Replace(".", "-"),
            //                    Level = id.Trim().Split('.').Count() + 1,
            //                    Current = false,
            //                    Name = x.PIB,
            //                    Type = "user",
            //                    FunctionDescription = x.Function,
            //                    BirthDate = x.Birthday,
            //                    Email = x.Email,
            //                    Mobile = x.Mobile,
            //                    Phones = x.Phone1,
            //                    Post = GetFullPost(x.Code),
            //                    //Photo = Photo(x.Email),
            //                    PhotoFileName = PhotoName(x.Email)
            //                }).ToList())
            //            {
            //                ret.Add(user);
            //            }
            //        }
            //}
            return(ret);
        }