Пример #1
0
        public ProjectFileViewModel(ProjectFilePath path, ShqContext db)
        {
            this.Name = System.IO.Path.GetFileName(path.Path);
            this.Path = path.Path;

            FileInfo fi = new FileInfo(path.FullPath);

            this.Size            = fi.Length;
            this.CreatedTime     = fi.CreationTime.ToString();
            this.LastModfiedTime = fi.LastWriteTime.ToString();

            Id = ShqConstants.GetPathId(path.Path);
            if (Id > 0)
            {
                this.Name = System.IO.Path.GetFileNameWithoutExtension(this.Name);

                var f = db.ProjectFiles.FirstOrDefault(item => item.Id == Id);
                if (f == null)
                {
                    this.Name = "";
                }
                else
                {
                    this.Privilege = f.Privilege;

                    CreatedBy   = new ShqUserRequestViewModel(db.ShqUsers.Where(u => u.IdentityUser.Id == db.ProjectFiles.FirstOrDefault(item => item.Id == Id).CreatedById).FirstOrDefault(), db);
                    CreatedTime = f.CreatedTime.ToString();

                    LastModifiedBy  = new ShqUserRequestViewModel(db.ShqUsers.Where(u => u.IdentityUser.Id == db.ProjectFiles.FirstOrDefault(item => item.Id == Id).LastModifiedById).FirstOrDefault(), db);
                    LastModfiedTime = f.LastModfiedTime.ToString();

                    this.Level = f.Level;
                }
            }
        }
Пример #2
0
        public ProjectViewModel(Project project, ShqContext db)
        {
            if (project == null)
            {
                return;
            }

            Id          = project.Id;
            Name        = project.ProjectName;
            Description = project.Description;
            Type        = project.Type;
            Tag         = project.Tag;
            Status      = project.Status;

            if (project.Type == "WorkProject")
            {
                Level = db.WorkProjects.FirstOrDefault(item => item.ProjectId == project.Id).Level;
            }

            var ps = db.ProjectShqUsers.Include("ShqUser").Where(item => item.ProjectId == project.Id).ToList();

            foreach (var item in ps)
            {
                this.UsersPrivileges.Add(new ViewModels.UsersPrivileges()
                {
                    RealName = item.ShqUser.RealName, EmailAddress = item.ShqUser.EmailAddress, Privilege = item.Privilege
                });
            }

            CreatedBy   = new ShqUserRequestViewModel(db.ShqUsers.Where(u => u.IdentityUser.Id == project.CreatedById).FirstOrDefault(), db);
            CreatedTime = project.CreatedTime.ToString();

            LastModifiedBy  = new ShqUserRequestViewModel(db.ShqUsers.Where(u => u.IdentityUser.Id == project.LastModifiedById).FirstOrDefault(), db);
            LastModfiedTime = project.LastModfiedTime.ToString();
        }
Пример #3
0
        public ShqUserRespondViewModel(ShqUser shqUser, ShqContext db) : base(shqUser, db)
        {
            CreatedBy   = new ShqUserRequestViewModel(db.ShqUsers.Where(u => u.IdentityUser.Id == shqUser.CreatedById).FirstOrDefault(), db);
            CreatedTime = shqUser.CreatedTime.ToString();

            LastModifiedBy  = new ShqUserRequestViewModel(db.ShqUsers.Where(u => u.IdentityUser.Id == shqUser.LastModifiedById).FirstOrDefault(), db);
            LastModfiedTime = shqUser.LastModfiedTime.ToString();
        }
Пример #4
0
 public FTATreeViewModel(FTATree tree, ShqContext db)
 {
     Id          = tree.Id;
     Content     = tree.Content;
     ProjectId   = tree.FTAProject.ProjectId;
     CreatedBy   = new ShqUserRequestViewModel(db.ShqUsers.Where(u => u.IdentityUser.Id == tree.CreatedById).FirstOrDefault(), db);
     CreatedTime = tree.CreatedTime.ToString();
 }
Пример #5
0
        public ProjectFolderViewModel(ProjectFilePath path, SearchOption searchOption, ShqContext db, int folderLevel = 1)
        {
            this.Path = path.Path;
            this.Name = System.IO.Path.GetFileName(path.Path);

            Id = ShqConstants.GetPathId(path.Path);
            if (Id > 0)
            {
                this.Name = System.IO.Path.GetFileNameWithoutExtension(this.Name);
                var f = db.ProjectFiles.FirstOrDefault(item => item.Id == Id);
                if (f == null)
                {
                    this.Name = "";
                }
                else
                {
                    CreatedBy   = new ShqUserRequestViewModel(db.ShqUsers.Where(u => u.IdentityUser.Id == db.ProjectFiles.FirstOrDefault(item => item.Id == Id).CreatedById).FirstOrDefault(), db);
                    CreatedTime = f.CreatedTime.ToString();

                    LastModifiedBy  = new ShqUserRequestViewModel(db.ShqUsers.Where(u => u.IdentityUser.Id == db.ProjectFiles.FirstOrDefault(item => item.Id == Id).LastModifiedById).FirstOrDefault(), db);
                    LastModfiedTime = f.LastModfiedTime.ToString();

                    this.Privilege = f.Privilege;
                    this.Level     = f.Level;
                }
            }

            if (this.Name == "")
            {
                return;
            }

            if ((searchOption == SearchOption.TopDirectoryOnly && folderLevel == 1) || searchOption == SearchOption.AllDirectories)
            {
                string[] directory, files;
                directory = Directory.GetDirectories(path.FullPath);
                files     = Directory.GetFiles(path.FullPath);

                if (directory != null && directory.Length > 0)
                {
                    foreach (var d in directory)
                    {
                        var pf = new ProjectFolderViewModel(new ProjectFilePath {
                            FullPath = d, Path = System.IO.Path.Combine(path.Path, System.IO.Path.GetFileName(d))
                        }, searchOption, db, folderLevel);
                        if (pf.Name != "")
                        {
                            this.SubFolders.Add(pf);
                        }
                    }

                    if (this.SubFolders != null && this.SubFolders.Count > 0)
                    {
                        this.SubFolders.Sort((x, y) => x.Name.CompareTo(y.Name));
                    }
                }

                if (files != null && files.Length > 0)
                {
                    foreach (var f in files)
                    {
                        var ff = new ProjectFileViewModel(new ProjectFilePath {
                            FullPath = f, Path = System.IO.Path.Combine(path.Path, System.IO.Path.GetFileName(f))
                        }, db);
                        if (ff.Name != "")
                        {
                            this.Files.Add(ff);
                        }
                    }

                    if (this.Files != null && this.Files.Count > 0)
                    {
                        this.Files.Sort((x, y) => x.Name.CompareTo(y.Name));
                    }
                }

                folderLevel--;
            }
        }