-
Notifications
You must be signed in to change notification settings - Fork 0
/
View.ascx.cs
368 lines (334 loc) · 18.8 KB
/
View.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/*
' Copyright (c) 2011 DevPCI
' All rights reserved.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
*/
using System;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Services.Localization;
using DotNetNuke.Security;
using System.Data;
using Telerik.Web.UI;
using DotNetNuke.UI;
using System.Web.UI;
using System.Linq;
using DotNetNuke.Security.Permissions;
namespace DevPCI.Modules.DDT_Org_Chart
{
/// -----------------------------------------------------------------------------
/// <summary>
/// The ViewDDT_Org_Chart class displays the content
/// </summary>
/// -----------------------------------------------------------------------------
public partial class View : DDT_Org_ChartModuleBase, IActionable
{
#region Event Handlers
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
/// -----------------------------------------------------------------------------
/// <summary>
/// Page_Load runs when the control is loaded
/// </summary>
/// -----------------------------------------------------------------------------
private void Page_Load(object sender, System.EventArgs e)
{
try
{
//get the moduleconfiguration
ModuleInfo conf = this.ModuleConfiguration;
ModulePermissionCollection myPermissionCollection = ModuleConfiguration.ModulePermissions;
//read out the custom data editright of the global constant
bool bCustomEditDataRights = ModulePermissionController.HasModulePermission(myPermissionCollection, "EDIT");
//DDT_Org_Chart_Simple.NodeDataBound += new Telerik.Web.UI.OrgChartNodeDataBoundEventHandler(DDT_Org_Chart_Simple_NodeDataBound);
DDT_Org_Chart_WithGroup.NodeDataBound += new Telerik.Web.UI.OrgChartNodeDataBoundEventHandler(DDT_Org_Chart_WithGroup_NodeDataBound);
DDT_Org_Chart_WithGroup.NodeDrop += new Telerik.Web.UI.OrgChartNodeDropEventHandler(DDT_Org_Chart_WithGroup_NodeDrop);
DDT_Org_Chart_WithGroup.GroupItemDrop += new Telerik.Web.UI.OrgChartGroupItemDropEventHandler(DDT_Org_Chart_WithGroup_GroupItemDrop);
lblPortalID.Text = PortalId.ToString();
lblModuleID.Text = ModuleId.ToString();
DDT_Org_Chart_Div.Attributes.Add("class", "DDT_Org_Chart_Class");
string mode = Convert.ToString(Settings["Mode"]);
if (string.IsNullOrEmpty(mode))
{
phInit.Visible = true;
}
if (string.IsNullOrEmpty(mode)==false)
{
if (mode == "Simple") // Mode Simple Without Team
{
PHSimple.Visible = true;
PHWithGroup.Visible = false;
DDT_Org_Chart_Simple.DataSourceID = "LDS_Org_Chart_Items_Simple";
DDT_Org_Chart_Simple.DataTextField = "ItemName_Org_Chart";
DDT_Org_Chart_Simple.DataFieldID = "ID_Org_Chart_Item";
DDT_Org_Chart_Simple.DataFieldParentID = "ID_Org_Chart_Node";
DDT_Org_Chart_Simple.DataImageUrlField = "MyBuildImageUrl";
DDT_Org_Chart_Simple.EnableDragAndDrop = bCustomEditDataRights;
DDT_Org_Chart_Simple.DataCollapsedField = "Collapsed";
}
else if (mode == "WithGroup") // Mode With Team
{
PHSimple.Visible = false;
PHWithGroup.Visible = true;
DDT_Org_Chart_WithGroup.GroupEnabledBinding.NodeBindingSettings.DataFieldID = "ID_Org_Chart_Node";
DDT_Org_Chart_WithGroup.GroupEnabledBinding.NodeBindingSettings.DataFieldParentID = "ParentID_Org_Chart_Node";
DDT_Org_Chart_WithGroup.GroupEnabledBinding.NodeBindingSettings.DataSourceID = "LDS_Org_Chart_Nodes";
DDT_Org_Chart_WithGroup.GroupEnabledBinding.NodeBindingSettings.DataCollapsedField = "Collapsed";
DDT_Org_Chart_WithGroup.GroupEnabledBinding.NodeBindingSettings.DataGroupCollapsedField = "GroupCollapsed";
DDT_Org_Chart_WithGroup.GroupEnabledBinding.GroupItemBindingSettings.DataFieldNodeID = "ID_Org_Chart_Node";
DDT_Org_Chart_WithGroup.GroupEnabledBinding.GroupItemBindingSettings.DataFieldID = "ID_Org_Chart_Item";
DDT_Org_Chart_WithGroup.GroupEnabledBinding.GroupItemBindingSettings.DataTextField = "ItemName_Org_Chart";
DDT_Org_Chart_WithGroup.GroupEnabledBinding.GroupItemBindingSettings.DataSourceID = "LDS_Org_Chart_Items_WithGroup";
DDT_Org_Chart_WithGroup.GroupEnabledBinding.GroupItemBindingSettings.DataImageUrlField = "MyBuildImageUrl";
DDT_Org_Chart_WithGroup.EnableDragAndDrop = bCustomEditDataRights;
//DDT_Org_Chart_WithGroup.DataBind();
}
}
if (Settings["Skin"] != null)
{
DDT_Org_Chart_Simple.Skin = Convert.ToString(Settings["Skin"]);
DDT_Org_Chart_WithGroup.Skin = Convert.ToString(Settings["Skin"]);
}
else { DDT_Org_Chart_Simple.Skin = "Default";}
string s = Convert.ToString(Settings["GroupColumnCount"]);
if (string.IsNullOrEmpty(s) == false)
{
DDT_Org_Chart_Simple.GroupColumnCount = Convert.ToInt32(s);
DDT_Org_Chart_WithGroup.GroupColumnCount = Convert.ToInt32(s);
}
if (Settings["DisableDefaultImage"] != null)
{
DDT_Org_Chart_Simple.DisableDefaultImage = Convert.ToBoolean(Settings["DisableDefaultImage"]);
DDT_Org_Chart_WithGroup.DisableDefaultImage = Convert.ToBoolean(Settings["DisableDefaultImage"]);
}
if (Settings["DefaultImageUrl"] != null)
{
DDT_Org_Chart_Simple.DefaultImageUrl = Convert.ToString(Settings["DefaultImageUrl"]);
DDT_Org_Chart_WithGroup.DefaultImageUrl = Convert.ToString(Settings["DefaultImageUrl"]);
}
if (Settings["EnableCollapsing"] != null)
{
DDT_Org_Chart_Simple.EnableCollapsing = Convert.ToBoolean(Settings["EnableCollapsing"]);
DDT_Org_Chart_WithGroup.EnableCollapsing = Convert.ToBoolean(Settings["EnableCollapsing"]);
}
if (Settings["EnableGroupCollapsing"] != null)
{
DDT_Org_Chart_Simple.EnableGroupCollapsing = Convert.ToBoolean(Settings["EnableGroupCollapsing"]);
DDT_Org_Chart_WithGroup.EnableGroupCollapsing = Convert.ToBoolean(Settings["EnableGroupCollapsing"]);
}
if (Settings["LoadOnDemand"] != null)
{
lblLoadOnDemand.Text = Convert.ToString(Settings["LoadOnDemand"]);
if (lblLoadOnDemand.Text == "None")
{
DDT_Org_Chart_Simple.LoadOnDemand = OrgChartLoadOnDemand.None;
DDT_Org_Chart_WithGroup.LoadOnDemand = OrgChartLoadOnDemand.None;
}
if (lblLoadOnDemand.Text == "Nodes")
{
DDT_Org_Chart_Simple.LoadOnDemand = OrgChartLoadOnDemand.Nodes;
DDT_Org_Chart_WithGroup.LoadOnDemand = OrgChartLoadOnDemand.Nodes;
}
if (lblLoadOnDemand.Text == "Groups")
{
DDT_Org_Chart_Simple.LoadOnDemand = OrgChartLoadOnDemand.Groups;
DDT_Org_Chart_WithGroup.LoadOnDemand = OrgChartLoadOnDemand.Groups;
}
if (lblLoadOnDemand.Text == "NodesAndGroups")
{
DDT_Org_Chart_Simple.LoadOnDemand = OrgChartLoadOnDemand.NodesAndGroups;
DDT_Org_Chart_WithGroup.LoadOnDemand = OrgChartLoadOnDemand.NodesAndGroups;
}
}
if (Settings["EnableDrillDown"] != null)
{
DDT_Org_Chart_Simple.EnableDrillDown = Convert.ToBoolean(Settings["EnableDrillDown"]);
DDT_Org_Chart_WithGroup.EnableDrillDown = Convert.ToBoolean(Settings["EnableDrillDown"]);
}
if (Settings["ExpandCollapseAllNodes"] != null)
{
if ((string)Settings["ExpandCollapseAllNodes"] == "Expand All Nodes")
{
DDT_Org_Chart_Simple.ExpandAllNodes();
DDT_Org_Chart_WithGroup.ExpandAllNodes();
}
else if ((string)Settings["ExpandCollapseAllNodes"] == "Collapse All Nodes")
{
DDT_Org_Chart_Simple.CollapseAllNodes();
DDT_Org_Chart_WithGroup.CollapseAllNodes();
}
}
if ((string)Settings["ExpandCollapseAllGroups"] != null)
{
if ((string)Settings["ExpandCollapseAllGroups"] == "Expand All Groups")
{
DDT_Org_Chart_Simple.ExpandAllGroups();
DDT_Org_Chart_WithGroup.ExpandAllGroups();
}
else if ((String)Settings["ExpandCollapseAllGroups"] == "Collapse All Groups")
{
DDT_Org_Chart_Simple.CollapseAllGroups();
DDT_Org_Chart_WithGroup.CollapseAllGroups();
}
if (Settings["NodeLabel"] != null)
{
DDT_Org_Chart_WithGroup.RenderedFields.NodeFields.First().Label = Convert.ToString(Settings["NodeLabel"]);
}
if (Settings["ItemLabel"] != null)
{
DDT_Org_Chart_WithGroup.RenderedFields.ItemFields.First().Label = Convert.ToString(Settings["ItemLabel"]);
}
if (Settings["ItemTitle"] != null)
{
DDT_Org_Chart_Simple.RenderedFields.ItemFields.First().Label = Convert.ToString(Settings["ItemTitle"]);
DDT_Org_Chart_WithGroup.RenderedFields.ItemFields.First().Label = Convert.ToString(Settings["ItemTitle"]);
}
}
if (Settings["ReductSize25"] != null)
{
string tt = Convert.ToString(Settings["ReductSize25"]);
if (tt == "true")
{phReductSize25.Visible = true; }
else
{ phReductSize25.Visible = false; }
}
if (Settings["ShowExpandCollapseNodeButton"] != null)
{
string tt = Convert.ToString(Settings["ShowExpandCollapseNodeButton"]);
if (tt == "true")
{ phShowExpandCollapseNodeButton.Visible = true; }
else
{ phShowExpandCollapseNodeButton.Visible = false; }
}
if (Settings["ShowExpandCollapseGroupButton"] != null)
{
string tt = Convert.ToString(Settings["ShowExpandCollapseGroupButton"]);
if (tt == "true")
{ phShowExpandCollapseGroupButton.Visible = true; }
else
{ phShowExpandCollapseGroupButton.Visible = false; }
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
private void SynchronizeModuleLastContentModifiedOnDate()
{
//Synchronise module (update Modules LastContentModifiedOnDate)
ModuleController.SynchronizeModule(this.ModuleId);
//clear page cache
ModuleController modules = new ModuleController();
modules.ClearCache(TabId);
}
//manage individual column count
void DDT_Org_Chart_WithGroup_NodeDataBound(object sender, Telerik.Web.UI.OrgChartNodeDataBoundEventArguments e)
{
DDT_Org_Chart_LinqDataContext linqContext = new DDT_Org_Chart_LinqDataContext();
var nodeid = from DDT_Org_Chart_Node tmp in linqContext.DDT_Org_Chart_Nodes
where tmp.ID_Org_Chart_Node == Convert.ToInt32(e.Node.ID)
select new { IDCC=tmp.ID_Org_Chart_Node, CC=tmp.ColumnCount };
if (nodeid.Count() > 0)
{
if (nodeid.First().CC != null)
{
string idcc = Convert.ToString(nodeid.First().IDCC);
int cc = Convert.ToInt32(nodeid.First().CC);
if (e.Node.ID == idcc)
e.Node.ColumnCount = cc;
}
}
}
#endregion
#region Optional Interfaces
public ModuleActionCollection ModuleActions
{
get
{
ModuleActionCollection Actions = new ModuleActionCollection();
Actions.Add(GetNextActionID(), Localization.GetString("EditModule", this.LocalResourceFile), "", "", "", EditUrl(), false, SecurityAccessLevel.Edit, true, false);
return Actions;
}
}
#endregion
protected void DDT_Org_Chart_Simple_NodeDrop(object sender, OrgChartNodeDropEventArguments e)
{
DDT_Org_Chart_LinqDataContext linqContext = new DDT_Org_Chart_LinqDataContext();
var rows = from DDT_Org_Chart_Item myRow in linqContext.DDT_Org_Chart_Items
where myRow.ID_Org_Chart_Item == Convert.ToInt32(e.SourceNode.ID)
select new { values = myRow };
foreach (var row in rows)
{
row.values.ID_Org_Chart_Node = Convert.ToInt32(e.DestinationNode.ID);
linqContext.SubmitChanges();
DDT_Org_Chart_Simple.DataBind();
}
SynchronizeModuleLastContentModifiedOnDate();
}
protected void DDT_Org_Chart_WithGroup_GroupItemDrop(object sender, OrgChartGroupItemDropEventArguments e)
{
DDT_Org_Chart_LinqDataContext linqContext = new DDT_Org_Chart_LinqDataContext();
var rows = from DDT_Org_Chart_Item myRow in linqContext.DDT_Org_Chart_Items
where myRow.ID_Org_Chart_Item == Convert.ToInt32(e.SourceGroupItem.ID)
select new { values = myRow };
foreach (var row in rows)
{
row.values.ID_Org_Chart_Node = Convert.ToInt32(e.DestinationNode.ID);
linqContext.SubmitChanges();
DDT_Org_Chart_WithGroup.DataBind();
}
SynchronizeModuleLastContentModifiedOnDate();
}
protected void DDT_Org_Chart_WithGroup_NodeDrop(object sender, OrgChartNodeDropEventArguments e)
{
DDT_Org_Chart_LinqDataContext linqContext = new DDT_Org_Chart_LinqDataContext();
var rows = from DDT_Org_Chart_Node myRow in linqContext.DDT_Org_Chart_Nodes
where myRow.ID_Org_Chart_Node == Convert.ToInt32(e.SourceNode.ID)
select new { values = myRow };
foreach (var row in rows)
{
row.values.ParentID_Org_Chart_Node = Convert.ToInt32(e.DestinationNode.ID);
linqContext.SubmitChanges();
DDT_Org_Chart_WithGroup.DataBind();
}
SynchronizeModuleLastContentModifiedOnDate();
}
protected void LDS_Org_Chart_Items_Simple_Selecting(object sender, System.Web.UI.WebControls.LinqDataSourceSelectEventArgs e)
{
DDT_Org_Chart_LinqDataContext linqContext = new DDT_Org_Chart_LinqDataContext();
var XItem = from DDT_Org_Chart_Item tmp in linqContext.DDT_Org_Chart_Items
where tmp.PortalID == PortalId && tmp.ModuleID == ModuleId && tmp.IsActive == true && tmp.IsDeleted == false
orderby tmp.ItemOrder_Org_Chart
select new { tmp.ID_Org_Chart_Item, tmp.ID_Org_Chart_Node, tmp.IsActive, tmp.IsDeleted, tmp.ItemName_Org_Chart, tmp.ItemOrder_Org_Chart, tmp.ItemTitle_Org_Chart, tmp.LastModifiedByUserID, tmp.LastModifiedOnDate, tmp.ModuleID, tmp.PortalID, tmp.Collapsed, tmp.CreatedByUserID, tmp.CreatedOnDate, MyBuildImageUrl = "/Portals/" + tmp.PortalID + "/" + tmp.ItemImageUrl_Org_Chart.Replace("//", "/"), tmp.ItemImageUrl_Org_Chart };
e.Result = XItem;
}
protected void LDS_Org_Chart_Items_WithGroup_Selecting(object sender, System.Web.UI.WebControls.LinqDataSourceSelectEventArgs e)
{
DDT_Org_Chart_LinqDataContext linqContext = new DDT_Org_Chart_LinqDataContext();
var XItem = from DDT_Org_Chart_Item tmp in linqContext.DDT_Org_Chart_Items
where tmp.ID_Org_Chart_Node > 0 && tmp.PortalID == PortalId && tmp.ModuleID == ModuleId && tmp.IsActive == true && tmp.IsDeleted == false
orderby tmp.ItemOrder_Org_Chart
select new { tmp.ID_Org_Chart_Item, tmp.ID_Org_Chart_Node, tmp.IsActive, tmp.IsDeleted, tmp.ItemName_Org_Chart, tmp.ItemOrder_Org_Chart, tmp.ItemTitle_Org_Chart, tmp.LastModifiedByUserID, tmp.LastModifiedOnDate, tmp.ModuleID, tmp.PortalID, tmp.Collapsed, tmp.CreatedByUserID, tmp.CreatedOnDate, MyBuildImageUrl = "/Portals/" + tmp.PortalID + "/" + tmp.ItemImageUrl_Org_Chart.Replace("//", "/"), tmp.ItemImageUrl_Org_Chart };
e.Result = XItem;
}
protected void GetBuildImageUrl(string ImageUrlToBuild)
{
ImageUrlToBuild = "/Portals/" + PortalId + "/" + ImageUrlToBuild.Replace("//", "/");
}
}
}