This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
BrowseRepository.ascx.cs
146 lines (114 loc) · 3.3 KB
/
BrowseRepository.ascx.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using System;
using System.Web.UI.WebControls;
using System.Xml;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Common;
namespace DNNStuff.SQLViewPro
{
public partial class BrowseRepository : PortalModuleBase
{
#region Web Form Designer Generated Code
//This call is required by the Web Form Designer.
[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
{
}
private void Page_Init(Object sender, EventArgs e)
{
//CODEGEN: This method call is required by the Web Form Designer
//Do not modify it using the code editor.
InitializeComponent();
HelpURL = "http://www.dnnstuff.com/";
}
#endregion
#region Page Level
private void Page_Load(Object sender, EventArgs e)
{
DNNUtilities.InjectCSS(Page, ResolveUrl("Resources/Support/edit.css"));
try
{
cmdImport.Attributes.Add("onclick", "return confirm(\'Importing will overwrite the current reportset associated with this module. Are you sure?\');");
if (Page.IsPostBack == false)
{
LoadSettings();
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
cmdCancel.Click += cmdCancel_Click;
cmdImport.Click += cmdImport_Click;
}
protected void cmdCancel_Click(object sender, EventArgs e)
{
try
{
ReturnToPage();
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
protected void cmdImport_Click(object sender, EventArgs e)
{
try
{
if (Page.IsValid)
{
ImportTemplate();
ReturnToPage();
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
private void ReturnToPage()
{
// Redirect back to the portal home page
Response.Redirect((string) (Globals.NavigateURL()), true);
}
#endregion
#region Process
private void ImportTemplate()
{
ImportTemplate(cboRepository.SelectedValue);
}
private void ImportTemplate(string TemplateName)
{
var templateFile = new System.IO.FileInfo(System.IO.Path.Combine((string) (Server.MapPath(ResolveUrl("Repository"))), TemplateName));
if (templateFile != null)
{
var xmlData = new XmlDocument();
xmlData.Load(templateFile.FullName);
var strType = xmlData.DocumentElement.GetAttribute("type").ToString();
if (strType == StringHelpers.CleanName((string) ModuleConfiguration.DesktopModule.ModuleName) || strType == StringHelpers.CleanName((string) ModuleConfiguration.DesktopModule.FriendlyName))
{
var strVersion = xmlData.DocumentElement.GetAttribute("version").ToString();
var ctrl = new SQLViewProController();
ctrl.ImportModule(ModuleId, xmlData.DocumentElement.InnerXml, strVersion, UserId);
}
}
}
#endregion
#region Settings
private void LoadSettings()
{
// repository
BindRepository(cboRepository);
}
private void BindRepository(ListControl o)
{
var repositoryFolder = new System.IO.DirectoryInfo((string) (Server.MapPath(ResolveUrl("Repository"))));
o.Items.Clear();
foreach (var fi in repositoryFolder.GetFiles("content.*.xml"))
{
o.Items.Add(fi.Name);
}
}
#endregion
}
}