Example #1
0
 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();
 }
Example #2
0
        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";
            }

        }
Example #3
0
        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());
            }
        }
Example #4
0
        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;
        }
Example #5
0
        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;
            }
        }
Example #6
0
 public void AddROMyPublished(ResearchOutput output)
 {
     TreeViewItem cur = output.AddToTree(trvMyResearch);
     cur.Selected += new RoutedEventHandler(TreeViewItem_myPublishedSelected);
 }
Example #7
0
        public void addExample()
        {
            
            
            curDoc = new JournalArticle("Example Article", new RichTextBox(), curUser);
            curDoc.PushRTB(rtbDocument);
            curDoc.CaptureDraft();

            OutputDrafts.Add(curDoc);
            ListRODrafts();
            ShowRich();
            setRODataSource();
        }
Example #8
0
 private void mitOpen_Click(object sender, RoutedEventArgs e)
 {
     ResearchOutput cur = LoadRO();
     if (cur != null)
         curDoc = cur;
     ListRODrafts();
     setRODataSource();
     SwitchRODetails();
 }
Example #9
0
        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();
        }
Example #10
0
        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;
                }
            }
        }
Example #11
0
 public SavableOutput(ResearchOutput Output)
 {
     this.Output = Output;
     this.Type = Output.getType;
     VNum = "v0.30b";
 }
Example #12
0
 public void Publish(ResearchOutput cur)
 {
     cur.RequestForPublishing();
     Main.PublishComplete();
 }
Example #13
0
 public void PushRO(ResearchOutput RO)
 {
     curRO = RO;
     this.DataContext = curRO;
 }
Example #14
0
 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");
     }
 }
Example #15
0
        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());
            }
        }
Example #16
0
        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");

        }
Example #17
0
        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();
        }
Example #18
0
 public void getCur(ResearchOutput cur, MainUI main)
 {
     this.cur = cur;
     Main = main;
 }