예제 #1
0
 public ActionResult UploadLargeImage(FormCollection form)
 {
     try
     {
         HttpPostedFileBase file     = Request.Files["file"];
         string             tempPath = functionHelper.GetFromConfig("TempFolder");
         if (file != null && file.ContentLength > 0)
         {
             UploadView _uploadView = functionHelper.UploadFile(file, tempPath, functionHelper.GetFromConfig("CarLargeImagePrefix"));
             if (_uploadView.Success)
             {
                 dataHelper.Car_LargeImage = _uploadView.UploadedFilePath;
                 TempData["CarMessage"]    = "Large Image Uploaded Successfully";
             }
             else
             {
                 dataHelper.Car_LargeImage = null;
                 TempData["CarMessage"]    = String.Concat("Error occured: ", _uploadView.ErrorMessage);
             }
         }
     }
     catch (Exception ex)
     {
         functionHelper.InsertErrorLog(ex, "UploadLargeImage", "CarManagement");
         TempData["CarMessage"] = String.Concat("Error occured: ", ex.Message);
     }
     return(RedirectToAction("NewCar", "CarManagement"));
 }
예제 #2
0
        public String UploadCarImages(FormCollection form)
        {
            string uploadedImages = "";

            try
            {
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFileBase file     = Request.Files[i];
                    string             tempPath = functionHelper.GetFromConfig("TempFolder");
                    if (file != null && file.ContentLength > 0)
                    {
                        UploadView _uploadView = functionHelper.UploadFile(file, tempPath);
                        if (_uploadView.Success)
                        {
                            uploadedImages += String.Concat(_uploadView.UploadedFilePath, "|");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                functionHelper.InsertErrorLog(ex, "UploadCarImages", "CarManagement");
            }
            return(uploadedImages);
        }
예제 #3
0
        public static ContentView AsView(this PageType type)
        {
            ContentView view = null;

            switch (type)
            {
            case PageType.Analysis:
                view = new AnalysisView();
                break;

            case PageType.Favorites:
                view = new FavoritesView();
                break;

            case PageType.Gallery:
                view = new GalleryView();
                break;

            case PageType.Home:
                view = new UploadView();
                break;

            case PageType.Search:
                view = new SearchResultsView();
                break;

            case PageType.Timeline:
                view = new TimelineView();
                break;
            }

            return(view);
        }
        /// <summary>
        /// Command method
        /// </summary>
        public void Execute()
        {
            Validation = string.Empty;

            //Check Internet Availability
            if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() == true)
            {
                bool approved = _model.Authenticate(this.Username, this.Password);
                if (approved == true)
                {
                    UploadView _view = new UploadView();
                    _view.ShowDialog();
                    var mainWindow = (Application.Current.MainWindow as LoginView);
                    if (mainWindow != null)
                    {
                        mainWindow.Close();
                    }
                }
                else
                {
                    Validation = "Invalid Username Password !!";
                }
            }
            else
            {
                Validation = "Check Your Internet Connection !!";
            }
        }
예제 #5
0
 public ActionResult Forward(int id, UploadView coreFileUpload, FormCollection Form)
 {
     if (ModelState.IsValid)
     {
         helper.ForwardDocument(id, coreFileUpload, Form);
         return(RedirectToAction("Index"));
     }
     return(View(coreFileUpload));
 }
예제 #6
0
        public FileResult DownLoad(int id)
        {
            UploadView file     = helper.FindById(id);
            string     fileName = file.FileNames;
            string     fileType = file.CoreFileTypeId.ToString();

            byte[] contents = file.FileContent;
            return(File(contents, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
        }
예제 #7
0
 public void ArchiveDocument(UploadView upload)
 {
     using (JazMax.DataAccess.JazMaxDBProdContext db = new JazMax.DataAccess.JazMaxDBProdContext())
     {
         DataAccess.CoreFileUpload UploadDocument = new DataAccess.CoreFileUpload();
         UploadDocument          = db.CoreFileUploads.FirstOrDefault(x => x.FileUploadId == upload.FileUploadId);
         UploadDocument.IsActive = false;
         db.SaveChanges();
     }
 }
예제 #8
0
 public void RecievedDocuments(UploadView upload)
 {
     using (JazMax.DataAccess.JazMaxDBProdContext db = new JazMax.DataAccess.JazMaxDBProdContext())
     {
         DataAccess.CoreFileUpload UploadDocument = new DataAccess.CoreFileUpload();
         UploadDocument            = db.CoreFileUploads.FirstOrDefault(x => x.FileUploadId == upload.FileUploadId);
         UploadDocument.IsRecieved = true;
         db.SaveChanges();
     }
 }
예제 #9
0
파일: TabHost.cs 프로젝트: ltreze/Cf
        public TabHost()
        {
            Explorar = new ExplorarView();
            Upload   = new UploadView(this);
            Perfil   = new PerfilView();

            Children.Add(Explorar);
            Children.Add(Upload);
            Children.Add(Perfil);
        }
예제 #10
0
        public ActionResult CreateForUser(UploadView coreFileUpload)
        {
            if (ModelState.IsValid)
            {
                helper.UploadToUser(coreFileUpload);
                return(RedirectToAction("Index"));
            }

            return(View(coreFileUpload));
        }
예제 #11
0
 private void OnUploadCommand()
 {
     try
     {
         UploadView view = container.Resolve <UploadView>();
         ChangeContent(view);
     }
     catch (Exception ex)
     {
         Utility.DisplayMessage(ex.Message);
     }
 }
예제 #12
0
        public int Upload(UploadView coreFileUpload)
        {
            using (DataAccess.JazMaxDBProdContext db = new DataAccess.JazMaxDBProdContext())
            {
                var context = HttpContext.Current;
                for (int i = 0; i < context.Request.Files.Count; i++)
                {
                    var file = context.Request.Files[i];
                    #region Content Length
                    if (file != null && file.ContentLength > 0)
                    {
                        #region CoreFIleUpload
                        DataAccess.CoreFileUpload fileUpload = new DataAccess.CoreFileUpload()
                        {
                            FileUploadId       = coreFileUpload.FileUploadId,
                            FileNames          = System.IO.Path.GetFileName(file.FileName),
                            CoreUserId         = JazMaxIdentityHelper.GetCoreUserId(),
                            CoreUserTypeId     = JazMaxIdentityHelper.GetCoreUserId(),
                            DateCreated        = DateTime.Now,
                            DeletedBy          = "None",
                            DeletedDate        = DateTime.Now,
                            BranchId           = (int)JazMaxIdentityHelper.GetUserInformationNew().BranchId,
                            ProvinceId         = (int)JazMaxIdentityHelper.GetUserInformationNew().ProvinceId,
                            CoreFileTypeId     = coreFileUpload.CoreFileTypeId,
                            FileDescription    = coreFileUpload.FileDescription,
                            CoreFileCategoryId = coreFileUpload.CoreFileCategoryId,
                            LastUpdated        = DateTime.Now,
                            IsActive           = true,
                            IsSent             = true,
                            IsRecieved         = true,
                            FileContent        = coreFileUpload.FileContent,
                            SentFrom           = JazMaxIdentityHelper.UserName,
                            SentTo             = "Document Directory"
                        };
                        #endregion

                        #region Binary Reader
                        using (var reader = new System.IO.BinaryReader(file.InputStream))
                        {
                            fileUpload.FileContent = reader.ReadBytes(file.ContentLength);
                        }
                        #endregion

                        db.CoreFileUploads.Add(fileUpload);
                    }
                    #endregion
                    db.SaveChanges();
                }
                return(coreFileUpload.FileUploadId);
            }
        }
예제 #13
0
 // Insert Comment
 public void submitComment(string _documentid, string _comment, string _studentid)
 {
     if (_documentid != string.Empty && _comment != string.Empty)
     {
         UserDetails _user = (UserDetails)HttpContext.Current.Session["User"];
         model.insertComment(_documentid, _user.UserID, _comment);
         UserDetails _student = model.selectUserDetailsById(_studentid);
         general_functions.Instance.email(_student.EmailAddress, "You have received feedback from your tutor (" + _user.UserID + ").\n Please Log into the eTutor system to view it.\n- eTutor System", "eTutor:- You have received feedback!");
         UploadView.resetUploadView();
         displayUploads();
     }
     else
     {
         UploadView.error = "Please ensure you have entered a comment before submitting";
     }
 }
예제 #14
0
        public int ForwardDocument(int id, UploadView coreFileUpload, FormCollection Form)
        {
            using (DataAccess.JazMaxDBProdContext db = new DataAccess.JazMaxDBProdContext())
            {
                string[] ids = Form["SentTo"].Split(new char[] { ',' });
                //Find Document Id That i Want to forward
                var FindContent = FindById(id);
                //get All contents of that particular file
                //Move Document to User Email Thats been Selected
                #region Database Upload object
                foreach (var item in ids)
                {
                    DataAccess.CoreFileUpload upload = new DataAccess.CoreFileUpload()
                    {
                        FileUploadId       = FindContent.FileUploadId,
                        FileNames          = FindContent.FileNames,
                        CoreUserId         = JazMaxIdentityHelper.GetCoreUserId(),
                        CoreUserTypeId     = FindContent.CoreUserTypeId,
                        DateCreated        = DateTime.Now,
                        DeletedBy          = "None",
                        DeletedDate        = DateTime.Now,
                        BranchId           = (int)JazMaxIdentityHelper.GetUserInformationNew().BranchId,
                        ProvinceId         = (int)JazMaxIdentityHelper.GetUserInformationNew().ProvinceId,
                        CoreFileTypeId     = FindContent.CoreFileTypeId,
                        FileDescription    = coreFileUpload.FileDescription,
                        CoreFileCategoryId = FindContent.CoreFileCategoryId,
                        LastUpdated        = DateTime.Now,
                        IsActive           = true,
                        IsSent             = true,
                        IsRecieved         = false,
                        FileContent        = FindContent.FileContent,
                        SentFrom           = JazMaxIdentityHelper.UserName,
                        SentTo             = item.ToString()
                    };

                    #endregion

                    //SaveChanges To Database
                    db.CoreFileUploads.Add(upload);
                    db.SaveChanges();
                }
                return(FindContent.FileUploadId);
            }
        }
예제 #15
0
        // Display student uploads
        public void displayUploads()
        {
            UserDetails         _user        = (UserDetails)HttpContext.Current.Session["User"];
            List <UserDocument> _uploadsList = new List <UserDocument>();

            if (_user.UserType == 1)
            {
                _uploadsList = model.selectUploadFiles(_user.UserID);
            }
            else if (_user.UserType == 2)
            {
                string _studentID = UploadView.studentID;
                _uploadsList = model.selectUploadFiles(_studentID);
            }

            Hashtable _formattedMessageData = new Hashtable();
            int       _counter = 1;

            if (_uploadsList.Count > 0)
            {
                string   _sender  = string.Empty;
                string[] _headers = { "Date", "Time", "File", "Comment" };
                _formattedMessageData.Add(0, _headers);
                foreach (UserDocument _doc in _uploadsList)
                {
                    string[]        _fileUploadSegments = _doc.UploadPath.Split('/');
                    string          _file       = _fileUploadSegments[4];
                    DocumentComment _comment    = model.selectComment(_doc.DocumentID.ToString());
                    string          _commentStr = (_comment == null) ? "n/a" : _comment.DocumentComments;
                    string[]        _tempArray  = { _doc.DocumentID.ToString(), _doc.Date.ToShortDateString(), _doc.Time.ToShortTimeString(), _file, _commentStr };
                    _formattedMessageData.Add(_counter, _tempArray);
                    _counter++;
                }
                UploadView.setUploadTable(_formattedMessageData);
            }
            else
            {
                UploadView.noMessages = "No Upload History Found.";
            }
        }
 public void UploadView()
 {
     try
     { UploadView upload = new UploadView(); }
     catch { }
 }
예제 #17
0
 public ActionResult Recover(UploadView upload)
 {
     helper.RecoverDocument(upload);
     return(RedirectToAction("Index"));
 }
예제 #18
0
 public ActionResult Archive(UploadView upload)
 {
     helper.ArchiveDocument(upload);
     return(RedirectToAction("Index"));
 }
예제 #19
0
 public ActionResult MarkAsRead(UploadView upload)
 {
     helper.RecievedDocuments(upload);
     return(RedirectToAction("IncomingDocuments"));
 }
예제 #20
0
        // Process Upload
        public void processUpload()
        {
            FileUpload _fileUpload = UploadView.fileUpload;

            if (_fileUpload.HasFile)
            {
                try
                {
                    if (_fileUpload.PostedFile.ContentType == "application/pdf" ||
                        _fileUpload.PostedFile.ContentType == "application/doc" ||
                        _fileUpload.PostedFile.ContentType == "application/docx" ||
                        _fileUpload.PostedFile.ContentType == "application/vnd.msword" ||
                        _fileUpload.PostedFile.ContentType == "application/vnd.ms-word" ||
                        _fileUpload.PostedFile.ContentType == "application/winword" ||
                        _fileUpload.PostedFile.ContentType == "application/word" ||
                        _fileUpload.PostedFile.ContentType == "application/msword" ||
                        _fileUpload.PostedFile.ContentType == "application/x-msw6" ||
                        _fileUpload.PostedFile.ContentType == "application/x-msword" ||
                        _fileUpload.PostedFile.ContentType == "application/pdf" ||
                        _fileUpload.PostedFile.ContentType == "application/x-pdf" ||
                        _fileUpload.PostedFile.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
                        _fileUpload.PostedFile.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.template")
                    {
                        if (_fileUpload.PostedFile.ContentLength < 2.097e+7)
                        {
                            UploadView.error = string.Empty;
                            UserDetails _user     = (UserDetails)HttpContext.Current.Session["User"];
                            UserDetails _tutor    = model.selectUserDetailsById(_user.SupervisorID);
                            string      _filename = Path.GetFileName(_fileUpload.FileName);

                            string _appDomain        = HttpRuntime.AppDomainAppPath.Replace("\\", "/");
                            string _userUploadFolder = _appDomain + "Storage/Files/" + _user.UserID;
                            if (!Directory.Exists(_userUploadFolder))
                            {
                                Directory.CreateDirectory(_userUploadFolder);
                            }

                            List <string> _fileNamesRecursive = general_functions.Instance.generateFileNameRecursively(_filename, _userUploadFolder, 1, new List <string>());

                            string _path = "Storage/Files/" + _user.UserID + "/" + _fileNamesRecursive[(_fileNamesRecursive.Count - 1)];
                            string _date = DateTime.Now.ToString("yyy-MM-dd");
                            string _time = DateTime.Now.ToString("HH:mm:ss");
                            byte[] data  = _fileUpload.FileBytes;

                            using (WebClient client = new WebClient())
                            {
                                client.Credentials = new NetworkCredential("lj048", "Garentee12");                          // Jon, place your account password here
                                model.insertUploadFileDetails(_user.UserID, _date, _time, ("~/" + _path));
                                client.UploadData(@"ftp://cms-stu-iis.gre.ac.uk/eTutorSystem/eTutorSystem/" + _path, data); // Jon, i think your ftp path might be: ftp://cms-stu-iis.gre.ac.uk/eTutorSystem/eTutorSystem/   but double check before you use it

                                general_functions.Instance.email(_tutor.EmailAddress, "Your tutee (" + _user.UserID + ") has uploaded a file.\n Please Log into the eTutor system to view it.\n- eTutor System", "eTutor:- One of your tutees has uploaded a file!");
                                UploadView.resetUploadView();
                                displayUploads();
                            }
                        }
                        else
                        {
                            UploadView.error = "Upload status: The file has to be less than 20MB!";
                        }
                    }
                    else
                    {
                        UploadView.error = "Upload status: Only PDF, DOCX & DOC files are accepted!";
                    }
                }
                catch (Exception ex)
                {
                    UploadView.error = "Upload status: The file could not be uploaded. The following error occured:\n" + ex.Message;
                }
            }
        }