Esempio n. 1
0
            public AssignmentStream(string name, RelevantAssignment parent, bool parseOriginalUserID,
                                    bool isOriginalForReview) : base()
            {
                m_name = name;
                m_isOriginalForReview = isOriginalForReview;

                if (parseOriginalUserID)
                {
                    // At the time of this writing, the file names for critical reviews are of the
                    // form: "#;UserName", where # is the user ID
                    int i = name.IndexOf(';');
                    if (i > 0)
                    {
                        int ID;
                        if (int.TryParse(name.Substring(0, i), out ID))
                        {
                            m_originalAuthorID = ID;

                            // Take only what's after the ';' for the name
                            m_name = name.Substring(i + 1);
                        }
                    }
                }

                m_parent = parent;
            }
Esempio n. 2
0
        public void SaveAssignmentAsync(RelevantAssignment a, byte[] assignmentData)
        {
            // When we save to an assignment, it becomes the "current" assignment
            m_currentAssignment = a;

            // Call the method to save to the current
            SaveCurrentAssignmentAsync(assignmentData);
        }
Esempio n. 3
0
        public static string GetDeliverableFileName(RelevantAssignment assignment)
        {
            foreach (Deliverable d in assignment.Deliverables)
            {
                if (DeliverableType.ChemProV == d.DeliverableType)
                {
                    return(d.Name + ".cpml");
                }
            }

            return(assignment.Name + ".cpml");
        }
Esempio n. 4
0
        private void OsbleClient_GetAssignmentSubmissionCompleted(object sender,
                                                                  GetAssignmentSubmissionCompletedEventArgs e)
        {
            if (e.Cancelled || null != e.Error)
            {
                m_currentAssignment = null;

                OnDownloadComplete(this, new OSBLEStateEventArgs(false,
                                                                 "Could not download the specified assignment file"));

                return;
            }

            // If there hasn't been any submission for this assignment yet then it may be 0 bytes in size
            if (0 == e.Result.Length)
            {
                OnDownloadComplete(this, new OSBLEStateEventArgs(true,
                                                                 "Assignment has yet to be submitted. You may save your work to OSBLE to submit " +
                                                                 "the first version for this assignment.", null));
                return;
            }

            // Make a memory stream for the byte array
            System.IO.MemoryStream ms = new System.IO.MemoryStream(e.Result);

            // Create the zip file
            ICSharpCode.SharpZipLib.Zip.ZipFile zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(ms);

            // If there are 0 files in the zip, then let the user know that nothing has been submitted
            if (0 == zf.Count)
            {
                OnDownloadComplete(this, new OSBLEStateEventArgs(true,
                                                                 "Assignment has yet to be submitted. You may save your work to OSBLE to submit " +
                                                                 "the first version for this assignment.", null));
                return;
            }

            // Go through the files within the zip looking for the .cpml
            foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry ze in zf)
            {
                if (ze.Name.ToLower().EndsWith(".cpml"))
                {
                    // We need a stream that is seekable and the Zip streams don't guarantee this. Thus
                    // we'll read the whole thing into a memory stream.
                    MemoryStream msUncompressed;
                    using (Stream tempStream = zf.GetInputStream(ze))
                    {
                        msUncompressed = new MemoryStream();
                        tempStream.CopyTo(msUncompressed);
                    }

                    OnDownloadComplete(this, new OSBLEStateEventArgs(true, null, msUncompressed));
                    return;
                }
            }

            // This means we didn't find a .cpml in the zip
            m_currentAssignment = null;
            OnDownloadComplete(this, new OSBLEStateEventArgs(false,
                                                             "Could not download the specified assignment file"));
        }
Esempio n. 5
0
 public AssignmentStream(string name, RelevantAssignment parent, bool parseOriginalUserID)
     : this(name, parent, parseOriginalUserID, false)
 {
 }
Esempio n. 6
0
 public AssignmentStream(string name, RelevantAssignment parent)
     : this(name, parent, false)
 {
 }