Component Page /Profile.cs (C#)
1: using System;  
2: using System.Text;  
3: using Microsoft.ApplicationBlocks.Data;  
4: using System.Data.SqlClient;  
5: using System.Data;  
6: using System.Collections.Generic;  
7:   
8: namespace QuizNetOnline.Logic  
9: {  
10:     public class Profile : IProfile  
11:     {  
12:         public Profile(string username,IProfile profile)  
13:         {  
14:             ISqlWrapper isqlwrapper = new SqlWrapper();  
15:             try  
16:             {  
17:                 Profile _profile = profile.GetProfile(username, isqlwrapper);  
18:                 City = _profile.City;  
19:                 Country = _profile.Country;  
20:                 GetNewsletter = _profile.GetNewsletter;  
21:                 HowDidYouFindSite = _profile.HowDidYouFindSite;  
22:                 NickName = _profile.NickName;  
23:                 State = _profile.State;  
24:                 LastLoginDate = _profile.LastLoginDate;  
25:                 CreateDate = _profile.CreateDate;  
26:                 LastActivityDate = _profile.LastActivityDate;  
27:                 UserName = username;  
28:             }  
29:             catch (Exception ex)  
30:             {  
31:                 ErrorLog errorLog = new ErrorLog();  
32:                 errorLog.LogException("Profile", ex, isqlwrapper);  
33:                 throw;  
34:             }  
35:         }  
36:   
37:         public Profile()  
38:         {  
39:         }  
40:   
41:         public string NickName { get; set; }  
42:   
43:         public string Country { get; set; }  
44:   
45:         public string State { get; set; }  
46:   
47:         public string City { get; set; }  
48:   
49:         public string HowDidYouFindSite { get; set; }  
50:   
51:         public bool GetNewsletter { get; set; }  
52:   
53:         public string UserName { get; set; }  
54:   
55:         public DateTime CreateDate { get; set; }  
56:   
57:         public DateTime LastLoginDate { get; set; }  
58:   
59:         public DateTime LastActivityDate { get; set; }  
60:           
61:   
62:         public bool Save(ISqlWrapper iSqlWrapper)  
63:         {  
64:             var propertyNames = new StringBuilder();  
65:             var propertyValuesString = new StringBuilder();  
66:   
67:             propertyNames.Append("UserDetails.Country:S:0:");  
68:             propertyNames.Append(Country.Length.ToString());  
69:   
70:             propertyNames.Append(":UserDetails.GetNewsletter:S:");  
71:             propertyNames.Append(Country.Length + ":");  
72:             propertyNames.Append(GetNewsletter.ToString().Length.ToString());  
73:   
74:             int startPos = Country.Length + GetNewsletter.ToString().Length;  
75:             propertyNames.Append(":UserDetails.State:S:");  
76:             propertyNames.Append(startPos + ":");  
77:             propertyNames.Append(State.Length.ToString());  
78:   
79:             startPos = Country.Length + GetNewsletter.ToString().Length + State.Length;  
80:             propertyNames.Append(":UserDetails.NickName:S:");  
81:             propertyNames.Append(startPos + ":");  
82:             propertyNames.Append(NickName.Length.ToString());  
83:   
84:             startPos = Country.Length + GetNewsletter.ToString().Length + State.Length + City.Length;  
85:             propertyNames.Append(":UserDetails.City:S:");  
86:             propertyNames.Append(startPos + ":");  
87:             propertyNames.Append(City.Length.ToString());  
88:   
89:             propertyValuesString.Append(Country);  
90:             propertyValuesString.Append(GetNewsletter.ToString());  
91:             propertyValuesString.Append(State);  
92:             propertyValuesString.Append(NickName);  
93:             propertyValuesString.Append(City);  
94:   
95:             var encoding = new ASCIIEncoding();  
96:             byte[] binaryData = encoding.GetBytes(propertyValuesString.ToString());  
97:   
98:             const string sproc = "aspnet_Profile_SetProperties";  
99:             var parameters = new SqlParameter[7];  
100:             parameters[0] = new SqlParameter("@ApplicationName", "/");  
101:             parameters[1] = new SqlParameter("@UserName", UserName);  
102:             parameters[2] = new SqlParameter("@PropertyNames", propertyNames.ToString());  
103:             parameters[3] = new SqlParameter("@PropertyValuesString", propertyValuesString.ToString());  
104:             parameters[4] = new SqlParameter("@PropertyValuesBinary", binaryData);  
105:             parameters[5] = new SqlParameter("@IsUserAnonymous", false);  
106:             parameters[6] = new SqlParameter("@CurrentTimeUtc", DateTime.Now);  
107:   
108:             try  
109:             {  
110:                 string connStr = iSqlWrapper.GetConnectionString();  
111:   
112:                 iSqlWrapper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, sproc, parameters);  
113:                 return true;  
114:             }  
115:             catch (Exception ex)  
116:             {  
117:                 ErrorLog errorLog = new ErrorLog();  
118:                 errorLog.LogException("Profile.Save", ex, iSqlWrapper);  
119:                 throw;  
120:             }  
121:         }  
122:   
123:         public Profile GetProfile(string username,ISqlWrapper isqlWrapper)  
124:         {  
125:             List<Profile> profiles = GetProfiles(username, isqlWrapper);  
126:             if (profiles.Count > 0)  
127:                 return profiles[0];  
128:             return null;  
129:         }  
130:   
131:         public int Delete(string username, ISqlWrapper isqlWrapper)  
132:         {  
133:             const string sproc = "DeleteUser";  
134:             var parameters = new SqlParameter[1];  
135:             parameters[0] = new SqlParameter("@Email", username);  
136:   
137:             try  
138:             {  
139:                 string connStr = isqlWrapper.GetConnectionString();  
140:                 return isqlWrapper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, sproc, parameters);  
141:             }  
142:             catch (Exception ex)  
143:             {  
144:                 ErrorLog errorLog = new ErrorLog();  
145:                 errorLog.LogException("DeleteUser", ex, isqlWrapper);  
146:                 throw;  
147:             }  
148:         }  
149:   
150:         public List<Profile> GetProfiles(string username, ISqlWrapper isqlWrapper)  
151: There is a limit of 150 source code lines in the evaluation version
152: There is a limit of 150 source code lines in the evaluation version
153: There is a limit of 150 source code lines in the evaluation version
154: There is a limit of 150 source code lines in the evaluation version
155: There is a limit of 150 source code lines in the evaluation version
156: There is a limit of 150 source code lines in the evaluation version
157: There is a limit of 150 source code lines in the evaluation version
158: There is a limit of 150 source code lines in the evaluation version
159: There is a limit of 150 source code lines in the evaluation version
160: There is a limit of 150 source code lines in the evaluation version
161: There is a limit of 150 source code lines in the evaluation version
162: There is a limit of 150 source code lines in the evaluation version
163: There is a limit of 150 source code lines in the evaluation version
164: There is a limit of 150 source code lines in the evaluation version
165: There is a limit of 150 source code lines in the evaluation version
166: There is a limit of 150 source code lines in the evaluation version
167: There is a limit of 150 source code lines in the evaluation version
168: There is a limit of 150 source code lines in the evaluation version
169: There is a limit of 150 source code lines in the evaluation version
170: There is a limit of 150 source code lines in the evaluation version
171: There is a limit of 150 source code lines in the evaluation version
172: There is a limit of 150 source code lines in the evaluation version
173: There is a limit of 150 source code lines in the evaluation version
174: There is a limit of 150 source code lines in the evaluation version
175: There is a limit of 150 source code lines in the evaluation version
176: There is a limit of 150 source code lines in the evaluation version
177: There is a limit of 150 source code lines in the evaluation version
178: There is a limit of 150 source code lines in the evaluation version
179: There is a limit of 150 source code lines in the evaluation version
180: There is a limit of 150 source code lines in the evaluation version
181: There is a limit of 150 source code lines in the evaluation version
182: There is a limit of 150 source code lines in the evaluation version
183: There is a limit of 150 source code lines in the evaluation version
184: There is a limit of 150 source code lines in the evaluation version
185: There is a limit of 150 source code lines in the evaluation version
186: There is a limit of 150 source code lines in the evaluation version
187: There is a limit of 150 source code lines in the evaluation version
188: There is a limit of 150 source code lines in the evaluation version
189: There is a limit of 150 source code lines in the evaluation version
190: There is a limit of 150 source code lines in the evaluation version

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.