|
@@ -100,33 +100,23 @@ namespace Bizgaze.CRM.Visitors.Managers
|
100
|
100
|
return new SelectResponse() { Result = json };
|
101
|
101
|
}
|
102
|
102
|
#endregion
|
103
|
|
-
|
|
103
|
+
|
104
|
104
|
#region Get Visitors html
|
105
|
105
|
//This method is used to get the html of a visitor. It takes a Visitor ID as an argument, then gets the related templates from Unibase.Platform.Templates.Managers.ITemplateManager, if the templates are found the id is assigned to the variable "templateid" and the information from GetVisitorByIdAsync is used to populate the fields in the template. In the end, the PrintTemplate object is returned with the PrintHTML.
|
106
|
106
|
[SelectMethod(ApiName = "Get visitors Html", AppName = "crm", Description = "Get visitors Html", UniqueName = "bizgaze_transact_visitors_GetvisitorsHtml", MethodName = "getvisitorshtml", ModuleName = "visitors", PackageName = "bizgaze", ParamName1 = "visitorid")]
|
107
|
107
|
public async Task<SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>> GetVisitorshtmlAsync(SelectRequest srequest, long VisitorId)
|
108
|
108
|
{
|
109
|
|
- var exp = srequest.Filter();
|
110
|
|
- exp = exp & Unibase.Data.Expressions.Exp.Eq(Infos.Visitor.Property.VisitorId.ToString(), VisitorId);
|
111
|
|
- srequest.Filter(exp);
|
112
|
|
- var data = await GetSingleAsync<Infos.Visitor>(srequest);
|
113
|
109
|
long templateid = 0;
|
|
110
|
+ //var appManager = Unibase.Dependency.DependencyConfig.Resolve<Unibase.Platform.Apps.Managers.IAppManager>();
|
114
|
111
|
var templateManager = Unibase.Dependency.DependencyConfig.Resolve<Unibase.Platform.Templates.Managers.ITemplateManager>();
|
115
|
112
|
var templateInfos = await templateManager.GetTemplatesAsync(srequest, "Bizgaze_Extension_CRM_CRM_TemplateProvider_Visitors");
|
116
|
113
|
if (templateInfos.Result != null && templateInfos.Result.Count > 0)
|
117
|
114
|
{
|
118
|
115
|
templateid = templateInfos.Result[0].TemplateId;
|
119
|
116
|
}
|
120
|
|
- var sql = "select code from bizgazecrm_visitors where visitorid=" + VisitorId;
|
121
|
|
- var selectSQL = new Unibase.Data.Sql.Select().FromQuery(sql).AllColumns();
|
122
|
|
- var dt = await GetDataTableAsync(srequest, selectSQL, null);
|
123
|
|
- var code = dt.Rows[0]["code"].ToString();
|
124
|
|
- var sql1 = "select visitorid from bizgazecrm_visitors where code='" + code + "' order by createddate desc";
|
125
|
|
- var selectSQL1 = new Unibase.Data.Sql.Select().FromQuery(sql1).AllColumns();
|
126
|
|
- var dt1 = await GetDataTableAsync(srequest, selectSQL1, null);
|
127
|
|
- var id = Convert.ToInt64 (dt1.Rows[0]["visitorid"]);
|
128
|
117
|
var result = new SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>();
|
129
|
118
|
var printTemplate = new Unibase.Platform.Templates.Infos.PrintTemplate();
|
|
119
|
+ //var templateManager = //Unibase.Dependency.DependencyConfig.Resolve<Unibase.Platform.Templates.Managers.ITemplateManager>();
|
130
|
120
|
var _dbContext = DependencyConfig.Resolve<Unibase.Data.IDbContext>();
|
131
|
121
|
Unibase.Platform.Templates.Helpers.TemplateHelper helper = new Unibase.Platform.Templates.Helpers.TemplateHelper(_dbContext);
|
132
|
122
|
var VisitorInfo_ = await GetVisitorByIdAsync(srequest, VisitorId);
|
|
@@ -138,55 +128,48 @@ namespace Bizgaze.CRM.Visitors.Managers
|
138
|
128
|
{
|
139
|
129
|
return SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>.CreateErrorResponse("1", "Template Not Found");
|
140
|
130
|
}
|
|
131
|
+ string CreatedDate = VisitorInfo_.Result.CheckInDate.ToString("dd-MM-yyyy hh:mm:ss tt");
|
141
|
132
|
var template = System.Web.HttpUtility.UrlDecode(templateInfo.TemplateText.ToString());
|
142
|
|
- //var code = VisitorInfo_.Result.Code;
|
143
|
|
- var mobilenumber = VisitorInfo_.Result.MobileNumber;
|
144
|
|
- //var visitorcard = await GetVisitorsIDAsync(srequest, code);
|
145
|
|
- //var purposeofvisit = await VisitorsbyMobileNumberAsync(srequest, mobilenumber);
|
146
|
|
- // var purposeofvisittype = purposeofvisit.Result.PurposeOfVisitType;
|
147
|
|
- var visitordata = await GetVisitordataByIdAsync(srequest, id);
|
148
|
|
- var scanobj = System.Text.Json.JsonSerializer.Deserialize<List<ExpandoObject>>(visitordata.Result);
|
149
|
|
- var _Obj = scanobj[0] as IDictionary<string, dynamic>;
|
150
|
|
- //string checkindate = _Obj["checkindate"].ToString();
|
151
|
|
- string Checkindate = VisitorInfo_.Result.CheckInDate.ToString("dd-MM-yyyy hh:mm:ss tt");
|
152
|
133
|
string multiTemplateText = "";
|
153
|
134
|
if (template.Contains("{{fullname}}"))
|
154
|
135
|
{
|
155
|
|
- template = template.Replace("{{fullname}}", _Obj["fullname"].ToString());
|
|
136
|
+ template = template.Replace("{{fullname}}", VisitorInfo_.Result.FullName);
|
156
|
137
|
}
|
157
|
138
|
if (template.Contains("{{cityname}}"))
|
158
|
139
|
{
|
159
|
|
- template = template.Replace("{{cityname}}", _Obj["cityname"].ToString());
|
|
140
|
+ template = template.Replace("{{cityname}}", VisitorInfo_.Result.CityName);
|
160
|
141
|
}
|
161
|
142
|
if (template.Contains("{{purposeofvisit}}"))
|
162
|
143
|
{
|
163
|
|
- template = template.Replace("{{purposeofvisit}}", _Obj["purposeofvisittype"].ToString());
|
|
144
|
+ template = template.Replace("{{purposeofvisit}}", VisitorInfo_.Result.PurposeOfVisitType);
|
164
|
145
|
}
|
165
|
146
|
if (template.Contains("{{phonenumber}}"))
|
166
|
147
|
{
|
167
|
|
- template = template.Replace("{{phonenumber}}", mobilenumber);
|
|
148
|
+ template = template.Replace("{{phonenumber}}", VisitorInfo_.Result.MobileNumber);
|
168
|
149
|
}
|
169
|
150
|
if (template.Contains("{{code}}"))
|
170
|
151
|
{
|
171
|
|
- template = template.Replace("{{code}}", _Obj["code"].ToString());
|
|
152
|
+ template = template.Replace("{{code}}", VisitorInfo_.Result.Code);
|
172
|
153
|
}
|
173
|
154
|
if (template.Contains("{{createddate}}"))
|
174
|
155
|
{
|
175
|
|
- template = template.Replace("{{createddate}}", _Obj["datetime"].ToString());
|
|
156
|
+ template = template.Replace("{{createddate}}", CreatedDate.ToString());
|
176
|
157
|
}
|
177
|
158
|
if (template.Contains("{{photourl}}"))
|
178
|
159
|
{
|
179
|
|
- template = template.Replace("{{photourl}}", _Obj["photourl"].ToString());
|
|
160
|
+ template = template.Replace("{{photourl}}", VisitorInfo_.Result.PhotoUrl);
|
180
|
161
|
}
|
181
|
162
|
if (template.Contains("{{HostName}}"))
|
182
|
163
|
{
|
183
|
|
- template = template.Replace("{{HostName}}", _Obj["contactname"].ToString());
|
|
164
|
+ template = template.Replace("{{HostName}}", VisitorInfo_.Result.HostName);
|
184
|
165
|
}
|
185
|
166
|
if (template.Contains("{{imageurl}}"))
|
186
|
167
|
{
|
187
|
168
|
template = template.Replace("{{imageurl}}", VisitorInfo_.Result.ImageUrl);
|
188
|
169
|
}
|
|
170
|
+
|
189
|
171
|
multiTemplateText = template;
|
|
172
|
+
|
190
|
173
|
printTemplate.PrintHTML = multiTemplateText;
|
191
|
174
|
printTemplate.FileName = "Visitors";
|
192
|
175
|
printTemplate.PkId = VisitorId;
|
|
@@ -200,12 +183,11 @@ namespace Bizgaze.CRM.Visitors.Managers
|
200
|
183
|
|
201
|
184
|
}
|
202
|
185
|
#endregion
|
203
|
|
-
|
204
|
186
|
/* #region Get Pre_Visitors
|
205
|
187
|
/***/
|
206
|
188
|
|
207
|
189
|
|
208
|
|
-
|
|
190
|
+
|
209
|
191
|
|
210
|
192
|
#region Visitor Agreement
|
211
|
193
|
/*
|