-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.cs
85 lines (73 loc) · 3.06 KB
/
Config.cs
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
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
namespace Microsoft.LiveMeeting.RecordingExporter
{
class Config
{
public static string ConfCenterName { get; set; }
public static string PostingURL { get; set; }
public static string Username { get; set; }
public static string Password { get; set; }
public static string RecViewerEmail { get; set; }
public static string RecViewerName { get; set; }
public static string RecViewerCompany { get; set; }
public static bool IsValidPostingUrl { get; set; }
public static void LoadSettings()
{
Username = Properties.Settings.Default.Username;
ConfCenterName = Properties.Settings.Default.ConfCenter;
RecViewerCompany = Properties.Settings.Default.RecViewerCompany;
RecViewerEmail = Properties.Settings.Default.RecViewerEmail;
RecViewerName = Properties.Settings.Default.RecViewerName;
if (!string.IsNullOrWhiteSpace(ConfCenterName))
UpdatePostingURL();
else
IsValidPostingUrl = false;
}
public static bool IsConfigValid()
{
return Config.IsValidPostingUrl &&
!String.IsNullOrWhiteSpace(Config.Username) &&
!string.IsNullOrWhiteSpace(Password);
}
public static void UpdatePostingURL()
{
IsValidPostingUrl = false;
PostingURL = string.Empty;
XmlDocument xmldoc = new XmlDocument();
string getPostingUrl = String.Format("https://www.livemeeting.com/cc/{0}/xml/4.0/GetPostingURLRequest", ConfCenterName);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(getPostingUrl);
request.Method = "GET";
// Get the response from the conference center
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
try
{
using (Stream responseStream = response.GetResponseStream())
{
if (response.ContentType == "application/xml")
{
StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
xmldoc.Load(responseStream);
// Retrieve the url attribute of <GetPostingURLReply>
XmlNode attrUrl = xmldoc.SelectSingleNode("/PlaceWareConfCenter/GetPostingURLReply/@url");
if (attrUrl != null)
{
IsValidPostingUrl = true;
PostingURL = attrUrl.Value;
}
}
}
}
catch (Exception e)
{
Debug.WriteLine("Exception: {0}\nTrace: {1}", e.Message, e.StackTrace);
}
}
}
}
}