Ejemplo n.º 1
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";
     }
 }
Ejemplo n.º 2
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;
                }
            }
        }