public static void Save(string filename, ResearchOutput Output) { SavableOutput objectToSerialize = new SavableOutput(Output); Stream stream = File.Open(filename, FileMode.Create); BinaryFormatter bFormatter = new BinaryFormatter(); bFormatter.Serialize(stream, objectToSerialize); stream.Close(); }
public SavableOutput(SerializationInfo info, StreamingContext context) { Type = (String)info.GetString("Type"); // chapters will not be handled here as they will be saved and loaded from their Book Class if (Type.StartsWith("J")) Output = (JournalArticle)info.GetValue("Output", typeof(JournalArticle)); else if (Type.StartsWith("B")) Output = (Book)info.GetValue("Output", typeof(Book)); else if (Type.StartsWith("C")) Output = (ConferencePaper)info.GetValue("Output", typeof(ConferencePaper)); else throw new Exception("Data Corrupted."); try { VNum = (String)info.GetString("VNum"); } catch (Exception ex) { VNum = "v0.30b"; } }
public void TreeViewItem_Selected(Object sender, RoutedEventArgs e) { TreeViewItem item = sender as TreeViewItem; String Header = item.Header.ToString(); try { if (!curDoc.isXPSFormat) curDoc.CaptureDraft(); if (item.IsSelected) { //if (item.Items.IsEmpty) if (!Header.Substring(0, 5).Equals("Chapt")) { int pos = trvDrafts.Items.IndexOf(item); curDoc = (ResearchOutput)OutputDrafts[pos]; curDoc.DisplayDraft(); this.Title = "Research Information System: " + curDoc.Title; } else { TreeViewItem parent = (TreeViewItem)item.Parent; int pos = trvDrafts.Items.IndexOf(parent); int pos2 = parent.Items.IndexOf(item); curDoc = ((Book)OutputDrafts[pos]).getChapter(pos2); curDoc.DisplayDraft(); this.Title = "Research Information System: " + curDoc.Title; } ShowRich(); SwitchRODetails(); setRODataSource(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
public ResearchOutput LoadRO() { //get the address to load from OpenFileDialog open = new OpenFileDialog(); open.DefaultExt = "rod"; // Research Output Draft open.AddExtension = true; open.FileName = ""; open.Title = "Open Research Output"; open.ValidateNames = true; this.IsEnabled = false; open.Filter = "Research Output Drafts (.rod)|*.rod"; try { if (open.ShowDialog().Value) { ResearchOutput cur = Serializer.Load(open.FileName); curDoc = cur; curDoc.PushRTB(this.rtbDocument); curDoc.DisplayDraft(); OutputDrafts.Add(curDoc); ListRODrafts(); this.Title = "Research Information System: " + curDoc.Title; ShowRich(); setRODataSource(); } } catch (Exception e) { MessageBox.Show("Loading Error: Save file corrupted or outdated.", "Error"); } finally { this.IsEnabled = true; } return null; }
public void SaveRO(ResearchOutput RO) { RO.CaptureDraft(); SaveFileDialog save = new SaveFileDialog(); save.DefaultExt = "rod"; save.AddExtension = true; save.FileName = RO.Title; save.OverwritePrompt = true; save.Title = "Save Research Output"; save.ValidateNames = true; this.IsEnabled = false; save.Filter = "Research Output Drafts (.rod)|*.rod"; try { if (save.ShowDialog().Value) { Serializer.Save(save.FileName,RO); } } catch (Exception e) { MessageBox.Show("Saving Error: Please remove illegal characters from the title.", "Error"); } finally { this.IsEnabled = true; } }
public void AddROMyPublished(ResearchOutput output) { TreeViewItem cur = output.AddToTree(trvMyResearch); cur.Selected += new RoutedEventHandler(TreeViewItem_myPublishedSelected); }
public void addExample() { curDoc = new JournalArticle("Example Article", new RichTextBox(), curUser); curDoc.PushRTB(rtbDocument); curDoc.CaptureDraft(); OutputDrafts.Add(curDoc); ListRODrafts(); ShowRich(); setRODataSource(); }
private void mitOpen_Click(object sender, RoutedEventArgs e) { ResearchOutput cur = LoadRO(); if (cur != null) curDoc = cur; ListRODrafts(); setRODataSource(); SwitchRODetails(); }
private void GetPendingRO() { int outputID = curNoti.OutputID; if (outputID == -1) return; ResearchOutput cur = ResearchOutput.getPendingRO(outputID, this.docView); if (cur == null) return; curDoc = cur; PendingDrafts.Add(curDoc); curDoc.AddNotification(curNoti); this.AddROPending(); this.Title = "Research Information System: " + curDoc.Title; ShowDoc(); setRODataSource(); SwitchRODetails(); lsbNotifications.Items.Clear(); tabDisplay.Focus(); }
private void lsbROChChapters_SelectionChanged(object sender, SelectionChangedEventArgs e) { selchapter = lsbROChChapters.SelectedIndex; if (selchapter != -1) { if (curDoc is Book) { grbROChapter.DataContext = ((Book)curDoc).getChapter(selchapter); lsbROChChapters.DataContext = curDoc; } else if (curDoc is Chapter) { Book cur = ((Chapter)curDoc).getBook(); if (((Book)cur).getChapter(selchapter) != null) curDoc = ((Book)cur).getChapter(selchapter); grbROChapter.DataContext = curDoc; lsbROChChapters.DataContext = cur; } } }
public SavableOutput(ResearchOutput Output) { this.Output = Output; this.Type = Output.getType; VNum = "v0.30b"; }
public void Publish(ResearchOutput cur) { cur.RequestForPublishing(); Main.PublishComplete(); }
public void PushRO(ResearchOutput RO) { curRO = RO; this.DataContext = curRO; }
public void sendApproveRejectNotification(ResearchOutput RO) { try { ToUser = RO.AuthorID; Message += " Title: " + RO.Title +". "; if (MSGType == 4) Message += "Reason for rejection: " + RO.RejectReason; String sql = String.Format("Insert Into Notification (FromUser, ToUser, Message, BTNMessage, Action, OutputID, MsgType)" + "VALUES('{0}','{1}','{2}','{3}','{4}','{5}', '{6}')", FromUser, ToUser, Message, BTNMessage, Action, RO.OutputID, MSGType); RISWriter.Execute(sql); } catch (Exception e) { MessageBox.Show(e.Message.ToString(), "Send Notification Failed"); } }
private void TRVI_Selected(Object sender, ArrayList Outputs, TreeViewItem treeviewitem) { try { TreeViewItem item = sender as TreeViewItem; int pos = treeviewitem.Items.IndexOf(item); curDoc = (ResearchOutput)Outputs[pos]; curDoc.DisplayDraft(); if (!curDoc.isXPSFormat) { MessageBox.Show("Document is not XPS.", "Display Error"); return; } ShowDoc(); this.Title = "Research Information System: " + curDoc.Title; SwitchRODetails(); setRODataSource(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void mitSave_Click(object sender, RoutedEventArgs e) { if (curDoc != null) { if (!curDoc.isXPSFormat) { if (curDoc is Chapter) { curDoc.CaptureDraft(); curDoc = ((Chapter)curDoc).getBook(); curDoc.DisplayDraft(); ShowRich(); SwitchRODetails(); setRODataSource(); } SaveRO(curDoc); } else { MessageBox.Show("Cannot save XPS documents", "Save failed"); } } else MessageBox.Show("No current research output selected"); }
private void btnROSAddSelected_Click(object sender, RoutedEventArgs e) { if (SelectedSeachRO == null) return; int outputID = SelectedSeachRO.OutputID; if (outputID == -1) return; ResearchOutput cur = ResearchOutput.getPublishedRO(outputID, this.docView); if (cur == null) return; curDoc = cur; PublishedOutputs.Add(curDoc); this.AddROPublished(); this.Title = "Research Information System: " + curDoc.Title; ShowDoc(); setRODataSource(); SwitchRODetails(); }
public void getCur(ResearchOutput cur, MainUI main) { this.cur = cur; Main = main; }