public ActionResult Details(int id)
        {
            FileBusinessLayer fbl  = new FileBusinessLayer();
            FileDB            file = fbl.GetFile(id);

            if (file == null)
            {
                return(HttpNotFound());
            }

            FileViewModel fvm = new FileViewModel();

            fvm.FileId       = file.FileId;
            fvm.FileName     = file.FileName;
            fvm.Creater      = file.Creater;
            fvm.Version      = file.Version;
            fvm.UploadTime   = file.UploadTime;
            fvm.ModifiedTime = file.ModifiedTime;
            if (file.FilePath != "")
            {
                fvm.FileContent = System.IO.File.ReadAllText(Path.Combine(_uploadsFolder, file.FilePath));
            }
            else
            {
                fvm.FileContent = "File content is empty. Please check the file path!";
            }
            return(View("Details", fvm));
        }
        public ActionResult History(int id)
        {
            FileListViewModel    flvm    = new FileListViewModel();
            FileBusinessLayer    fbl     = new FileBusinessLayer();
            List <FileDB>        files   = fbl.GetFiles();
            List <FileViewModel> evmlist = new List <FileViewModel>();

            FileDB filenow = fbl.GetFile(id);

            while (filenow != null)
            {
                FileViewModel fvm = new FileViewModel();
                fvm.FileId      = filenow.FileId;
                fvm.FileName    = filenow.FileName;
                fvm.Creater     = filenow.Creater;
                fvm.UploadTime  = filenow.UploadTime;
                fvm.Version     = filenow.Version;
                fvm.FileContent = filenow.FilePath;
                evmlist.Add(fvm);
                filenow = filenow.FormerId;
            }

            flvm.FileList   = evmlist;
            flvm.Permission = Convert.ToString(Session["Permission"]);
            return(View("Historys", flvm));
        }
Beispiel #3
0
        public ActionResult Edit(int id = 0)
        {
            FileBusinessLayer fbl  = new FileBusinessLayer();
            FileDB            file = fbl.GetFile(id);

            return(View("Edit", new CreateFileViewModel()));
        }
Beispiel #4
0
        public ActionResult Details(int id)
        {
            FileBusinessLayer fbl  = new FileBusinessLayer();
            FileDB            file = fbl.GetFile(id);

            if (file == null)
            {
                return(JavaScript("Error" + id));
            }

            DisplayFileViewModel pfvm = new DisplayFileViewModel();

            pfvm.FileName     = file.FileName;
            pfvm.Creater      = file.Creater;
            pfvm.Version      = file.Version;
            pfvm.UploadTime   = file.UploadTime;
            pfvm.ModifiedTime = file.ModifiedTime;
            if (file.FilePath != "")
            {
                pfvm.FileContent = System.IO.File.ReadAllText(file.FilePath);
            }
            else
            {
                pfvm.FileContent = "File content is empty. Please check the file path!";
            }
            return(View("Details", pfvm));
        }
        public ActionResult ConfirmDelete(FormCollection fcNotUsed, int id)
        {
            FileBusinessLayer fbl  = new FileBusinessLayer();
            FileDB            file = fbl.GetFile(id);

            if (file == null)
            {
                return(HttpNotFound());
            }
            //System.IO.File.Delete(file.FilePath);
            fbl.SaveFile(file, "delete");
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(FormCollection fcNotUsed, int id)
        {
            FileBusinessLayer fbl  = new FileBusinessLayer();
            FileDB            file = fbl.GetFile(id);

            if (file == null)
            {
                return(HttpNotFound());
            }

            fbl.SaveFile(file, "mark delete");
            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        public ActionResult Delete(FormCollection fcNotUsed, int id)
        {
            FileBusinessLayer fbl  = new FileBusinessLayer();
            FileDB            file = fbl.GetFile(id);

            if (file == null)
            {
                return(HttpNotFound());
            }

            file.ModifiedTime = DateTime.Now;
            file.isDelete     = true;

            fbl.SaveFile(file);

            return(RedirectToAction("Index"));
        }
        public ActionResult VersionCompare()
        {
            int v1 = int.Parse(Request["v1"]);
            int v2 = int.Parse(Request["v2"]);
            FileBusinessLayer fbl = new FileBusinessLayer();
            FileDB            f1  = fbl.GetFile(v1);
            FileDB            f2  = fbl.GetFile(v2);

            FileStream   fs1      = new FileStream(Path.Combine(_uploadsFolder, f1.FilePath), FileMode.Open);
            FileStream   fs2      = new FileStream(Path.Combine(_uploadsFolder, f2.FilePath), FileMode.Open);
            StreamReader sr1      = new StreamReader(fs1);
            StreamReader sr2      = new StreamReader(fs2);
            string       content1 = sr1.ReadLine();

            while (content1.Trim() == null || content1.Trim().Equals(""))
            {
                content1 = sr1.ReadLine();
            }

            string content2 = sr2.ReadLine();

            while (content2.Trim() == null || content2.Trim().Equals(""))
            {
                content2 = sr2.ReadLine();
            }

            string DiffContent = "\n";
            int    line        = 1;

            while (!sr1.EndOfStream || !sr2.EndOfStream)
            {
                System.Diagnostics.Debug.Write(content1);
                System.Diagnostics.Debug.Write(content2);

                if (sr1.EndOfStream)
                {
                    DiffContent += "In Line No." + line + ": " + "\n"
                                   + "         Version" + f1.Version + ": " + "File End." + "\n"
                                   + "         Version" + f2.Version + ": " + content2 + "\n\n";
                }
                else if (sr2.EndOfStream)
                {
                    DiffContent += "In Line No." + line + ": " + "\n"
                                   + "         Version" + f1.Version + ": " + content1 + "\n"
                                   + "         Version" + f2.Version + ": " + "File End." + "\n\n";
                }
                else if (!content1.Equals(content2))
                {
                    DiffContent += "In Line No." + line + ": " + "\n"
                                   + "         Version" + f1.Version + ": " + content1 + "\n"
                                   + "         Version" + f2.Version + ": " + content2 + "\n\n";
                }

                if (!sr1.EndOfStream)
                {
                    content1 = sr1.ReadLine();
                }
                if (!sr2.EndOfStream)
                {
                    content2 = sr2.ReadLine();
                }
                line++;
            }

            sr1.Close();
            sr2.Close();
            fs1.Close();
            fs2.Close();

            VersionViewModel vvm = new VersionViewModel();

            vvm.FirstVersion  = f1;
            vvm.SecondVersion = f2;
            vvm.DiffContent   = DiffContent;

            return(View("Versions", vvm));
        }