/
ReportModel.cs
79 lines (65 loc) · 2.67 KB
/
ReportModel.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
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections;
using xcControlPoint.Model.ListTypes;
using Newtonsoft.Json;
using System.IO;
namespace xcControlPoint.Model
{
public static class Operations
{
public static string xcrStorageByFileType = "XCRSTORAGEBYFILETYPE";
public static string xcrSiteActivityAnalysis = "XCRSITEACTIVITYANALYSIS";
public static string xcrSitesMostActive = "XCRSITESMOSTACTIVE";
public static string xcrPagesMostActive = "XCRPAGESMOSTACTIVE";
public static string xcrDocumentsMostActive = "XCRDOCUMENTSMOSTACTIVE";
}
public class ReportModel
{
static xcrFileTypeStorageResult cList;
public static void ReportData(string rptType)
{
string url = GetRESTUrl(rptType);
System.Net.HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.CookieContainer = App.CookieJar;
request.Accept = @"application/json";
request.Method = "GET";
request.BeginGetResponse(new AsyncCallback(ListCallBack), request);
}
private static void ListCallBack(IAsyncResult asyncResult)
{
HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult);
using (Stream content = response.GetResponseStream())
{
if (request != null && response != null && response.StatusCode == HttpStatusCode.OK)
{
using (StreamReader reader = new StreamReader(content))
{
string responseString = reader.ReadToEnd();
cList = JsonConvert.DeserializeObject<xcrFileTypeStorageResult>(responseString);
//Dispatcher.BeginInvoke(() =>
//{
//chart.Series[0].ItemsSource = cList.d.results;
//});
}
}
}
}
static string GetRESTUrl(string rptType)
{
string baseRelURL = "/_vti_bin/ListData.svc/";
if (rptType == Operations.xcrStorageByFileType)
return baseRelURL + "XcrFileTypeStorageReport_m_Storage_VirtualServersDS";
return null;
}
}
}