Ejemplo n.º 1
0
        private List<FileShared> getSharedDocsModel()
        {
            List<FileShared> docs = new List<FileShared>();
            try
            {
                var files = from privilegetable in db.DX_PRIVILEGE
                            join filetable in db.DX_FILES
                            on new { key1 = privilegetable.userid, key2 = privilegetable.fileid, key3 = false }
                                equals new { key1 = SessionKeyMgmt.UserId, key2 = filetable.fileid, key3 = filetable.isarchived }
                            join versiontable in db.DX_FILEVERSION on filetable.fileid equals versiontable.fileid
                            select new { filetable, privilegetable, versiontable };

                if (files != null && files.ToList().Count > 0)
                {

                    foreach (var sharedfile in files)
                    {
                        if (sharedfile.filetable.islocked != true)
                        {
                            if (sharedfile.filetable.ownerid != SessionKeyMgmt.UserId)
                            {
                                FileShared share = new FileShared();
                                share.FileID = (sharedfile.filetable.fileid).ToString();
                                share.FileName = sharedfile.filetable.filename;
                                share.Description = sharedfile.versiontable.description;
                                share.FileVersion = sharedfile.versiontable.versionnumber;
                                share.CreationDate = (sharedfile.filetable.creationdate).ToString();
                                share.Owner = sharedfile.filetable.ownerid;
                                share.read = sharedfile.privilegetable.read;
                                share.delete = sharedfile.privilegetable.delete;
                                share.update = sharedfile.privilegetable.update;
                                share.check = sharedfile.privilegetable.check;
                                docs.Add(share);
                            }
                        }
                    }

                }
            }
            catch
            {
                ModelState.AddModelError("", "Error while getting Shared Documents");
            }
            return docs;
        }
Ejemplo n.º 2
0
        public ActionResult SharedFiles()
        {
            var files = from privilegetable in db.DX_PRIVILEGE
                        join filetable in db.DX_FILES
                        on new { key1 = privilegetable.userid, key2 = privilegetable.fileid,key3=false }
                            equals new { key1 = SessionKeyMgmt.UserId, key2 = filetable.fileid, key3=filetable.isarchived }
                        join versiontable in db.DX_FILEVERSION on filetable.fileid equals versiontable.fileid
                        select new { filetable, privilegetable, versiontable };

            List<FileShared> docs = new List<FileShared>();

            if (files != null && files.ToList().Count > 0)
            {
                foreach(var sharedfile in files)
                {
                    if (sharedfile.filetable.isarchived == true)
                    {
                        ModelState.AddModelError("", "Permission Denied: The file is in archived state");
                    }
                    if (sharedfile.filetable.ownerid != SessionKeyMgmt.UserId && sharedfile.filetable.latestversion==sharedfile.versiontable.versionnumber && sharedfile.privilegetable.reason=="shared")
                    {
                        FileShared share = new FileShared();
                        share.FileID = (sharedfile.filetable.fileid).ToString();
                        share.FileName = sharedfile.filetable.filename;
                        share.Description = sharedfile.versiontable.description;
                        share.FileVersion = sharedfile.filetable.latestversion;
                        share.CreationDate = (sharedfile.filetable.creationdate).ToString();
                        share.Owner = sharedfile.filetable.ownerid;
                        share.read = sharedfile.privilegetable.read;
                        share.delete = sharedfile.privilegetable.delete;
                        share.update = sharedfile.privilegetable.update;
                        share.check = sharedfile.privilegetable.check;
                        share.islocked = Convert.ToBoolean(sharedfile.filetable.islocked);
                        share.lockedby = sharedfile.filetable.lockedby;
                        docs.Add(share);
                     }
                }
                return View("SharedFiles",docs);
            }
            else
            {
                ModelState.AddModelError("", "No files have been shared with you");
                return View("SharedFiles",docs);
            }
        }