~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to src/webaccess/.svn/text-base/Details.aspx.cs.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
 |
3
 
 | Copyright (c) 2007 Novell, Inc.
4
 
 | All Rights Reserved.
5
 
 |
6
 
 | This program is free software; you can redistribute it and/or
7
 
 | modify it under the terms of version 2 of the GNU General Public License as
8
 
 | published by the Free Software Foundation.
9
 
 |
10
 
 | This program is distributed in the hope that it will be useful,
11
 
 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 | GNU General Public License for more details.
14
 
 |
15
 
 | You should have received a copy of the GNU General Public License
16
 
 | along with this program; if not, contact Novell, Inc.
17
 
 |
18
 
 | To contact Novell about this file by physical or electronic mail,
19
 
 | you may find current contact information at www.novell.com
20
 
 |
21
 
 | Author: Rob
22
 
 |***************************************************************************/
23
 
 
24
 
using System;
25
 
using System.Collections;
26
 
using System.ComponentModel;
27
 
using System.Data;
28
 
using System.Drawing;
29
 
using System.Web;
30
 
using System.Web.SessionState;
31
 
using System.Web.UI;
32
 
using System.Web.UI.WebControls;
33
 
using System.Web.UI.HtmlControls;
34
 
using System.Resources;
35
 
using System.Web.Services.Protocols;
36
 
using System.Net;
37
 
 
38
 
namespace Novell.iFolderApp.Web
39
 
{
40
 
        /// <summary>
41
 
        /// Details Page
42
 
        /// </summary>
43
 
        public class DetailsPage : Page
44
 
        {
45
 
                /// <summary>
46
 
                /// Property Actions Container
47
 
                /// </summary>
48
 
                protected HtmlContainerControl PropertyActions;
49
 
 
50
 
                /// <summary>
51
 
                /// Property Data
52
 
                /// </summary>
53
 
                protected DataGrid PropertyData;
54
 
 
55
 
                /// <summary>
56
 
                /// Property Edit Link
57
 
                /// </summary>
58
 
                protected HyperLink PropertyEditLink;
59
 
 
60
 
                /// <summary>
61
 
                /// Policy Actions Container
62
 
                /// </summary>
63
 
                protected HtmlContainerControl PolicyActions;
64
 
 
65
 
                /// <summary>
66
 
                /// Policy Data
67
 
                /// </summary>
68
 
                protected DataGrid PolicyData;
69
 
 
70
 
                /// <summary>
71
 
                /// Policy Edit Link
72
 
                /// </summary>
73
 
                protected HyperLink PolicyEditLink;
74
 
 
75
 
                /// <summary>
76
 
                /// Message Box
77
 
                /// </summary>
78
 
                protected MessageControl Message;
79
 
                
80
 
                /// <summary>
81
 
                /// Header page
82
 
                /// </summary>
83
 
                protected HeaderControl Head;
84
 
                
85
 
                /// <summary>
86
 
                /// Different Tabs
87
 
                /// </summary>
88
 
                protected TabControl Tabs;
89
 
 
90
 
                /// <summary>
91
 
                /// iFolder Connection
92
 
                /// </summary>
93
 
                private iFolderWeb web;
94
 
 
95
 
                /// <summary>
96
 
                /// Resource Manager
97
 
                /// </summary>
98
 
                private ResourceManager rm;
99
 
 
100
 
                /// <summary>
101
 
                /// iFolder ID
102
 
                /// </summary>
103
 
                private string ifolderID;
104
 
 
105
 
                /// <summary>
106
 
                /// Page Load
107
 
                /// </summary>
108
 
                /// <param name="sender"></param>
109
 
                /// <param name="e"></param>
110
 
                private void Page_Load(object sender, EventArgs e)
111
 
                {
112
 
                        // query
113
 
                        ifolderID = Request.QueryString.Get("iFolder");
114
 
 
115
 
                        // connection
116
 
                        web = (iFolderWeb) Session["Connection"];
117
 
 
118
 
                        // localization
119
 
                        rm = (ResourceManager) Application["RM"];
120
 
 
121
 
                        if (!IsPostBack)
122
 
                        {
123
 
                        
124
 
                                iFolder ifolder = web.GetiFolder(ifolderID);
125
 
                                
126
 
                                //Load this page only if passphrase was provided for the encrypted iFolder
127
 
                                if(! IfDetailsEnabled())
128
 
                                {
129
 
                                        // Return to Browse page, if passphrase was not provided for that encrypted ifolder.
130
 
                                
131
 
                                        Response.Redirect(String.Format("Browse.aspx?iFolder={0}", ifolderID));
132
 
                                }
133
 
                                
134
 
                                string EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
135
 
                                if(!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
136
 
                                {
137
 
                                        // It is an encrypted ifolder , Make the Members tab invisible
138
 
                                        Tabs.MakeMembersLinkInvisible();
139
 
                                }
140
 
                        
141
 
                                // data
142
 
                                BindData();
143
 
 
144
 
                                // strings
145
 
                                PropertyEditLink.Text = GetString("EDIT");
146
 
                                PolicyEditLink.Text = GetString("EDIT");
147
 
 
148
 
                                // links
149
 
                                PropertyEditLink.NavigateUrl = "iFolderEdit.aspx?iFolder=" + ifolderID;
150
 
                                PolicyEditLink.NavigateUrl = "iFolderPolicyEdit.aspx?iFolder=" + ifolderID;
151
 
                        }
152
 
                }
153
 
 
154
 
                /// <summary>
155
 
                /// Determine to show the details tab or not for encrypted folders
156
 
                /// </summary>
157
 
                private bool IfDetailsEnabled()
158
 
                {
159
 
                        string PassPhrase = Session["SessionPassPhrase"] as string;
160
 
                        ifolderID = Request.QueryString.Get("iFolder");
161
 
                        iFolder ifolder = web.GetiFolder(ifolderID);
162
 
                        string EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
163
 
                        return web.ShowTabDetails(PassPhrase, EncryptionAlgorithm);     
164
 
                }       
165
 
 
166
 
                /// <summary>
167
 
                /// Bind the Data to the Page.
168
 
                /// </summary>
169
 
                private void BindData()
170
 
                {
171
 
                        BindPropertyData();
172
 
                        BindPolicyData();
173
 
                        // Pass this page information to create the help link
174
 
                        Head.AddHelpLink(GetString("DETAILS"));
175
 
                }
176
 
 
177
 
                /// <summary>
178
 
                /// Bind the Data to the Page.
179
 
                /// </summary>
180
 
                private void BindPropertyData()
181
 
                {
182
 
                        // table
183
 
                        DataTable propertyTable = new DataTable();
184
 
                        propertyTable.Columns.Add("Label");
185
 
                        propertyTable.Columns.Add("Value");
186
 
 
187
 
                        try
188
 
                        {
189
 
                                // ifolder
190
 
                                iFolderDetails ifolder = web.GetiFolderDetails(ifolderID);
191
 
 
192
 
                                // rights
193
 
                                PropertyActions.Visible = (ifolder.MemberRights == Rights.Admin);
194
 
 
195
 
                                propertyTable.Rows.Add(new object[] { GetString("NAME"), ifolder.Name });
196
 
                                propertyTable.Rows.Add(new object[] { GetString("DESCRIPTION"), ifolder.Description });
197
 
                                propertyTable.Rows.Add(new object[] { GetString("LASTMODIFIED"), WebUtility.FormatDate(ifolder.LastModified, rm) });
198
 
                                propertyTable.Rows.Add(new object[] { GetString("CREATED"), WebUtility.FormatDate(ifolder.Created, rm) });
199
 
                                propertyTable.Rows.Add(new object[] { GetString("RIGHTS"), ifolder.MemberRights });
200
 
                                propertyTable.Rows.Add(new object[] { GetString("OWNER"), ifolder.OwnerFullName });
201
 
                                propertyTable.Rows.Add(new object[] { GetString("SIZE"), WebUtility.FormatSize(ifolder.Size, rm) });
202
 
                                propertyTable.Rows.Add(new object[] { GetString("MEMBERS"), ifolder.MemberCount.ToString() });
203
 
                                propertyTable.Rows.Add(new object[] { GetString("FILES"), ifolder.FileCount.ToString() });
204
 
                                propertyTable.Rows.Add(new object[] { GetString("FOLDERS"), ifolder.DirectoryCount.ToString() });
205
 
                                propertyTable.Rows.Add(new object[] { GetString("LOCKED"), WebUtility.FormatYesNo(!ifolder.Enabled, rm) });
206
 
                        }
207
 
                        catch(SoapException ex)
208
 
                        {
209
 
                                if (!HandleException(ex)) throw;
210
 
                        }
211
 
 
212
 
                        // data grid
213
 
                        PropertyData.DataSource = propertyTable;
214
 
                        PropertyData.DataBind();
215
 
                }
216
 
 
217
 
                /// <summary>
218
 
                /// Bind the Data to the Page.
219
 
                /// </summary>
220
 
                private void BindPolicyData()
221
 
                {
222
 
                        // table
223
 
                        DataTable policyTable = new DataTable();
224
 
                        policyTable.Columns.Add("Label");
225
 
                        policyTable.Columns.Add("Value");
226
 
 
227
 
                        try
228
 
                        {
229
 
                                // ifolder
230
 
                                iFolderPolicy policy = web.GetiFolderPolicy(ifolderID);
231
 
 
232
 
                                // rights
233
 
                                //PolicyActions.Visible = (ifolder.Rights == Rights.Admin);
234
 
                                PolicyActions.Visible = false;
235
 
 
236
 
                                policyTable.Rows.Add(new object[] { GetString("SYNCINTERVAL"), policy.SyncIntervalEffective });
237
 
                        }
238
 
                        catch(SoapException ex)
239
 
                        {
240
 
                                if (!HandleException(ex)) throw;
241
 
                        }
242
 
 
243
 
                        // data grid
244
 
                        PolicyData.DataSource = policyTable;
245
 
                        PolicyData.DataBind();
246
 
                }
247
 
 
248
 
                /// <summary>
249
 
                /// Handle Exceptions
250
 
                /// </summary>
251
 
                /// <param name="e"></param>
252
 
                /// <returns></returns>
253
 
                private bool HandleException(Exception e)
254
 
                {
255
 
                        bool result = true;
256
 
 
257
 
                        string type = WebUtility.GetExceptionType(e);
258
 
 
259
 
                        // types
260
 
                        switch(type)
261
 
                        {
262
 
                                case "AccessException":
263
 
                                        Message.Text = GetString("ENTRY.ACCESSEXCEPTION");
264
 
                                        break;
265
 
 
266
 
                                default:
267
 
                                        result = false;
268
 
                                        break;
269
 
                        }
270
 
 
271
 
                        return result;
272
 
                }
273
 
 
274
 
                /// <summary>
275
 
                /// Get a Localized String
276
 
                /// </summary>
277
 
                /// <param name="key"></param>
278
 
                /// <returns></returns>
279
 
                protected string GetString(string key)
280
 
                {
281
 
                        return WebUtility.GetString(key, rm);
282
 
                }
283
 
 
284
 
                #region Web Form Designer
285
 
 
286
 
                /// <summary>
287
 
                /// On Initialize
288
 
                /// </summary>
289
 
                /// <param name="e"></param>
290
 
                override protected void OnInit(EventArgs e)
291
 
                {
292
 
                        InitializeComponent();
293
 
                        base.OnInit(e);
294
 
                }
295
 
                
296
 
                /// <summary>
297
 
                /// Initialize Components
298
 
                /// </summary>
299
 
                private void InitializeComponent()
300
 
                {    
301
 
                        this.Load += new System.EventHandler(this.Page_Load);
302
 
                }
303
 
 
304
 
                #endregion
305
 
        }
306
 
}