internal void SendActionToQueue(bool build, bool check) { try { // at least one action must be true if (!build && !check) { throw new ApplicationException(SharedSupport.GetLocalizedString("StudentAssignment_Must_Choose_Action")); } // validate userAssignmentId if (_userAssignmentID <= 0) { throw new ApplicationException(SharedSupport.GetLocalizedString("StudentAssignment_InvalidUserAssignmentId")); } // generate the xml System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.Xml.XmlTextWriter xmlwriter = new System.Xml.XmlTextWriter(ms, System.Text.Encoding.ASCII); xmlwriter.Formatting = System.Xml.Formatting.Indented; xmlwriter.WriteStartDocument(false); xmlwriter.WriteStartElement("serverActions"); // build requested? if (build) { // update auto build status - set to pending this._autoCompileStatus = Constants.AUTOCOMPILE_PENDING_STATUS; } // include serverAction element for auto build xmlwriter.WriteStartElement("serverAction"); xmlwriter.WriteAttributeString("name", "AutoBuild"); xmlwriter.WriteElementString("userAssignmentID", this.UserAssignmentID.ToString()); xmlwriter.WriteEndElement(); // check requested? if (check) { // update auto check status - set to pending this._autoGradeStatus = Constants.AUTOGRADE_PENDING_STATUS; // include serverAction element for auto build xmlwriter.WriteStartElement("serverAction"); xmlwriter.WriteAttributeString("name", "AutoCheck"); xmlwriter.WriteElementString("userAssignmentID", this.UserAssignmentID.ToString()); xmlwriter.WriteEndElement(); } xmlwriter.WriteEndElement(); xmlwriter.Flush(); //read all of the stream and convert to a string string msg = System.Text.Encoding.ASCII.GetString(ms.GetBuffer()); // close xmlwriter.Close(); ms.Close(); try { SharedSupport.SendMessageToQueue(Constants.ACTION_QUEUE_PATH, Constants.ACTION_QUEUE_NAME, Constants.AM_SUBMIT_ACTION, msg); } catch (Exception e) { SharedSupport.HandleError(e, "ServerAction_InvalidQueue"); } // update the status of the userAssignments this.LastUpdatedDate = DateTime.Now; this.Update(); } catch (Exception ex) { SharedSupport.HandleError(ex); } }