-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera.ascx.cs
200 lines (159 loc) · 7.18 KB
/
Camera.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
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Framework.JavaScriptLibraries;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Abstractions;
using GIBS.FBClients.Components;
using System;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace GIBS.Modules.FBClients
{
public partial class Camera : PortalModuleBase
{
public int clientId = 0;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
JavaScript.RequestRegistration(CommonJs.jQuery);
// JavaScript.RequestRegistration(CommonJs.jQueryUI);
// JavaScript.RequestRegistration(CommonJs.DnnPlugins);
Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "CameraScript", (this.TemplateSourceDirectory + "/JavaScript/Camera.js"));
}
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["cid"] != null)
{
clientId = Int32.Parse(Request.QueryString["cid"]);
}
FillClientRecord(clientId);
SetMakeIDLink();
}
public void SaveImageToDatabase(string imageData)
{
try
{
FBClientsController controller = new FBClientsController();
FBClientsInfo item = new FBClientsInfo();
byte[] imageBytes = Convert.FromBase64String(imageData.Replace("data:image/png;base64,", String.Empty));
item.ClientID = clientId;
item.IDPhoto = imageBytes;
item.CreatedByUserID = this.UserId;
controller.FBClients_IDPhoto_Insert(item);
FillClientRecord(clientId);
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
//public void UploadImage(string imageData)
//{
// try
// {
// if (clientId > 0)
// {
// string fname = clientId.ToString() + ".png";
// string fileNameWitPath = HttpContext.Current.Server.MapPath("/Portals/0/" + fname);
// using (FileStream fs = new FileStream(fileNameWitPath, FileMode.Create, FileAccess.Write))
// {
// using (BinaryWriter bw = new BinaryWriter(fs))
// {
// byte[] data = Convert.FromBase64String(imageData.Replace("data:image/png;base64,", String.Empty));
// bw.Write(data);
// bw.Flush();
// bw.Close();
// }
// }
// FillClientRecord(clientId);
// }
// }
// catch (Exception ex)
// {
// Exceptions.ProcessModuleLoadException(this, ex);
// }
//}
protected void ButtonSaveImage_Click(object sender, EventArgs e)
{
try
{
// UploadImage(HiddenFieldImage.Value);
SaveImageToDatabase(HiddenFieldImage.Value);
HyperLinkMakeID.Visible = true;
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
public void FillClientRecord(int clientID)
{
try
{
//load the item
FBClientsController controller = new FBClientsController();
FBClientsInfo item = controller.FBClients_GetByID(this.PortalId, clientID);
if (item != null)
{
LabelClientInfo.Text = item.ClientFirstName + ' ' + item.ClientLastName + " - ";
LabelClientInfo.Text += item.ClientAddress + ", " + item.ClientTown + ", " + item.ClientState + " " + item.ClientZipCode;
Session["ClientID"] = clientID.ToString();
var queryString = "?ClientID=" + Session["ClientID"].ToString() + "&contactname=" + item.ClientFirstName.ToString() + " " + item.ClientLastName.ToString();
if (item.IDPhoto != null)
{
ImageIDClient.Visible = true;
byte[] imagem = (byte[])(item.IDPhoto);
string PROFILE_PIC = Convert.ToBase64String(imagem);
ImageIDClient.ImageUrl = String.Format("data:image/png;base64,{0}", PROFILE_PIC);
ImageIDClient.AlternateText = item.ClientFirstName + ' ' + item.ClientLastName;
HyperLinkMakeID.Visible = true;
}
else
{
ImageIDClient.Visible = false;
HyperLinkMakeID.Visible = false;
}
}
else
{
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
}
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
public void SetMakeIDLink()
{
//HyperLinkPhotoID
try
{
string myLink = DotNetNuke.Common.Globals.NavigateURL("MakeID", "mid=" + this.ModuleId);
//myLink += "?cid=" + clientId.ToString() + "&SkinSrc=[G]" + DotNetNuke.Common.Globals.QueryStringEncode(DotNetNuke.UI.Skins.SkinController.RootSkin + "/" + DotNetNuke.Common.Globals.glbHostSkinFolder + "/" + "popUpSkin");
myLink += "?cid=" + clientId.ToString();
myLink += "&SkinSrc=[G]" + DotNetNuke.Common.Globals.QueryStringEncode(DotNetNuke.UI.Skins.SkinController.RootSkin + "/" + DotNetNuke.Common.Globals.glbHostSkinFolder + "/" + "popUpSkin");
myLink += "&ContainerSrc=";
myLink += DotNetNuke.Common.Globals.QueryStringEncode("/Portals/_default/Containers/_default/No Container");
string redirectUrl = UrlUtils.PopUpUrl(myLink, this, PortalSettings, false, true);
HyperLinkMakeID.NavigateUrl = redirectUrl.ToString();
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
protected void ButtonReturnToClientManager_Click(object sender, EventArgs e)
{
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "EditClient", "mid=" + ModuleId.ToString() + "&cid=" + clientId.ToString()));
// object p = DependencyProvider.GetRequiredService( INavigationManager).NavigateURL(PortalSettings.ActiveTab.TabID, "Edit", "mid=" + ModuleId.ToString());
// object p = DependencyProvider.GetRequiredService(INavigationManager).NavigateURL(PortalSettings.ActiveTab.TabID, "Edit", "mid=" + ModuleId.ToString());
}
}
}