~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to src/webaccess/.svn/text-base/Quota.ascx.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.Data;
26
 
using System.Drawing;
27
 
using System.Web;
28
 
using System.Web.UI;
29
 
using System.Web.UI.WebControls;
30
 
using System.Web.UI.HtmlControls;
31
 
using System.Web.Security;
32
 
using System.Threading;
33
 
using System.Resources;
34
 
 
35
 
namespace Novell.iFolderApp.Web
36
 
{
37
 
        /// <summary>
38
 
        ///     Quota Control
39
 
        /// </summary>
40
 
        public class QuotaControl : UserControl
41
 
        {
42
 
                /// <summary>
43
 
                /// Log
44
 
                /// </summary>
45
 
                private static readonly WebLogger log = new WebLogger(
46
 
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
47
 
 
48
 
                /// <summary>
49
 
                /// Title
50
 
                /// </summary>
51
 
                protected Literal Title;
52
 
 
53
 
                /// <summary>
54
 
                /// Space Used
55
 
                /// </summary>
56
 
                protected Literal SpaceUsed;
57
 
 
58
 
                /// <summary>
59
 
                /// Space Available
60
 
                /// </summary>
61
 
                protected Literal SpaceAvailable;
62
 
 
63
 
                /// <summary>
64
 
                /// Resource Manager
65
 
                /// </summary>
66
 
                private ResourceManager rm;
67
 
 
68
 
                /// <summary>
69
 
                /// iFolder Connection
70
 
                /// </summary>
71
 
                private iFolderWeb web;
72
 
        
73
 
                /// <summary>
74
 
                /// iFolder ID
75
 
                /// </summary>
76
 
                private string ifolderID;
77
 
 
78
 
                /// <summary>
79
 
                /// Page Load
80
 
                /// </summary>
81
 
                /// <param name="sender"></param>
82
 
                /// <param name="e"></param>
83
 
                private void Page_Load(object sender, System.EventArgs e)
84
 
                {
85
 
                        // query
86
 
                        ifolderID = Request.QueryString.Get("iFolder");
87
 
 
88
 
                        // localization
89
 
                        rm = (ResourceManager) Application["RM"];
90
 
 
91
 
                        // check connection
92
 
                        web = (iFolderWeb)Session["Connection"];
93
 
                        
94
 
                        if (!IsPostBack)
95
 
                        {
96
 
                        }
97
 
                }
98
 
 
99
 
                /// <summary>
100
 
                /// Bind the Data to the Page.
101
 
                /// </summary>
102
 
                private void BindData()
103
 
                {
104
 
                        long used;
105
 
                        long limit;
106
 
 
107
 
                        if ((ifolderID != null) && (ifolderID.Length != 0))
108
 
                        {
109
 
                                // ifolder
110
 
                                iFolderPolicy policy = web.GetiFolderPolicy(ifolderID);
111
 
                                used = policy.SpaceUsed;
112
 
                                limit = policy.SpaceLimitEffective;
113
 
 
114
 
                                Title.Text = GetString("IFOLDERQUOTA");
115
 
                        }
116
 
                        else
117
 
                        {
118
 
                                // global
119
 
                                UserPolicy policy = web.GetAuthenticatedUserPolicy();
120
 
                                used = policy.SpaceUsed;
121
 
                                limit = policy.SpaceLimitEffective;
122
 
 
123
 
                                Title.Text = GetString("HOMEQUOTA");
124
 
                        }
125
 
 
126
 
                        // used
127
 
                        SpaceUsed.Text = WebUtility.FormatSize(used, rm);
128
 
                        
129
 
                        // limit
130
 
                        if (limit == 0)
131
 
                        {
132
 
                                // no limit
133
 
                                SpaceAvailable.Text = GetString("NOLIMIT");
134
 
                        }
135
 
                        else
136
 
                        {
137
 
                                // limit
138
 
                                SpaceAvailable.Text = WebUtility.FormatSize(limit, rm);
139
 
                        }
140
 
                }
141
 
                
142
 
                /// <summary>
143
 
                /// Get a Localized String
144
 
                /// </summary>
145
 
                /// <param name="key"></param>
146
 
                /// <returns></returns>
147
 
                protected string GetString(string key)
148
 
                {
149
 
                        return WebUtility.GetString(key, rm);
150
 
                }
151
 
 
152
 
                #region Web Form Designer
153
 
                
154
 
                /// <summary>
155
 
                /// On Intialize
156
 
                /// </summary>
157
 
                /// <param name="e"></param>
158
 
                override protected void OnInit(EventArgs e)
159
 
                {
160
 
                        InitializeComponent();
161
 
                        base.OnInit(e);
162
 
                }
163
 
                
164
 
                /// <summary>
165
 
                /// Initialize Components
166
 
                /// </summary>
167
 
                private void InitializeComponent()
168
 
                {
169
 
                        this.Load += new System.EventHandler(this.Page_Load);
170
 
                        this.PreRender += new EventHandler(Quota_PreRender);
171
 
                }
172
 
                
173
 
                #endregion
174
 
 
175
 
                /// <summary>
176
 
                /// Quota Pre-Render
177
 
                /// </summary>
178
 
                /// <param name="sender"></param>
179
 
                /// <param name="e"></param>
180
 
                private void Quota_PreRender(object sender, EventArgs e)
181
 
                {
182
 
                        // bind
183
 
                        // NOTE: bind the footer late so modifications can be shown
184
 
                        BindData();
185
 
                }
186
 
        }
187
 
}