-
Notifications
You must be signed in to change notification settings - Fork 1
/
Service.cs
124 lines (108 loc) · 3.14 KB
/
Service.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Http;
using System.IO;
using Newtonsoft.Json;
namespace Rennder
{
public enum enumInjectTypes
{
replace = 0,
append = 1,
before = 2,
after = 3
}
public class PageComponent
{
public string panelClassId = "";
public string itemId = "";
public string html = "";
public string css = "";
[JsonIgnore]
public Component Component;
}
public class PageRequest
{
public string pageTitle = "";
public List<PageComponent> components = new List<PageComponent>();
public List<string> @remove = new List<string>();
public string js = "";
public string css = "";
public string editor = "";
}
public class Inject
{
public string element = "";
public string html = "";
public string js = "";
public string css = "";
public enumInjectTypes inject = 0;
}
public class WebRequest
{
public string html = "";
public string contentType = "text/html";
}
public class Service
{
protected Core R;
protected string[] Paths;
public Dictionary<string, string> Form = new Dictionary<string, string>();
public IFormFileCollection Files;
public Service(Core RennderCore, string[] paths) {
R = RennderCore;
Paths = paths;
}
public struct structResponse
{
public string html;
public string js;
public string window;
}
protected structResponse lostResponse()
{
//if session is lost, reload the page
structResponse response = new structResponse();
response.js = "R.lostSession();";
return response;
}
protected Inject lostInject()
{
//if session is lost, reload the page
Inject response = new Inject();
response.js = "R.lostSession();";
return response;
}
protected PageRequest lostPageRequest()
{
//if session is lost, reload the page
PageRequest response = new PageRequest();
response.js = "R.lostSession();";
return response;
}
protected string CompileJs()
{
if (R.Page.postJScode != null)
{
R.Page.postJS += string.Join("\n", R.Page.postJScode) + R.Page.postJSLast;
}
return R.Page.postJS;
}
protected string RenderHelpColumn(string filename)
{
if(R.Server.Cache.ContainsKey(filename) == false || R.isLocal == true)
{
string htm = "<div class=\"column-help dashboard-only\"><div>" + File.ReadAllText(R.Server.MapPath(filename)) + "</div></div>";
R.Server.Cache[filename] = htm;
return htm;
}else
{
return (string)R.Server.Cache[filename];
}
}
public void Unload()
{
R.Unload();
}
}
}