-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
109 lines (85 loc) · 3.43 KB
/
Program.cs
File metadata and controls
109 lines (85 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using System.IO;
namespace ResearchPaperManagementSystem
{
class Program
{
public static ResearchPaper rPaper = new ResearchPaper();
public static AllResearchPaper allResPaper = new AllResearchPaper();
static void Main(string[] args)
{
Console.WriteLine("This program is to store and maintain info related to resesrch publications");
bool flag = true;
while(flag)
{
Console.WriteLine("Enter\n1. Add publication\n2.Get All Paper Details\n0. Exit");
int choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
AddResearchPaperDetails();
break;
case 2:
GetAllPaperDetails();
break;
case 0:
Console.WriteLine("Thanks For Using");
flag = false;
break;
}
}
return;
}
public static void AddResearchPaperDetails()
{
try
{
XmlDeserializationPaper(ref allResPaper);
}
catch(Exception ex)
{
Console.WriteLine("1st Entry "+ex.Message);
}
Console.WriteLine("Add ID, Author Name, Publication Title, Department, Date of Publication");
ResearchPaper rPaper = new ResearchPaper();
rPaper.Id = int.Parse(Console.ReadLine());
rPaper.Author = Console.ReadLine();
rPaper.Title = Console.ReadLine();
rPaper.Department = Console.ReadLine();
rPaper.DateOfPublication = Console.ReadLine();
allResPaper.AddPaper(rPaper);
XMLSerializationPaper(ref allResPaper);
}
public static void GetAllPaperDetails()
{
Console.WriteLine("ID\tAuthor\tPaper Title\tDepartment\tPublication Date");
XmlDeserializationPaper(ref allResPaper);
allResPaper.GetResearchPapers();
/*
Console.WriteLine(rPaper.Id + "\t" + rPaper.Author + "\t" + rPaper.Title + "\t" + rPaper.Department + "\t" + rPaper.DateOfPublication);
*/
return;
}
public static void XmlDeserializationPaper(ref AllResearchPaper allresPaper)
{
//Console.WriteLine("Using Deserialization");
XmlSerializer xsObj = new XmlSerializer(typeof(AllResearchPaper));
FileStream fsObj = new FileStream("AllResearchPaperInfo.xml", FileMode.Open, FileAccess.Read);
allResPaper = xsObj.Deserialize(fsObj) as AllResearchPaper;
fsObj.Close();
}
public static void XMLSerializationPaper(ref AllResearchPaper allresPaper)
{
//Console.WriteLine("Saving Employee Details using XML serialization");
XmlSerializer xsObj = new XmlSerializer(typeof(AllResearchPaper));
FileStream fsObj = new FileStream("AllResearchPaperInfo.xml", FileMode.Create, FileAccess.Write);
xsObj.Serialize(fsObj, allResPaper);
fsObj.Close();
}
}
}