|
|
|
|
100
|
return new SelectResponse() { Result = json };
|
100
|
return new SelectResponse() { Result = json };
|
101
|
}
|
101
|
}
|
102
|
#endregion
|
102
|
#endregion
|
103
|
-
|
|
|
|
|
103
|
+
|
104
|
#region Get Visitors html
|
104
|
#region Get Visitors html
|
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.
|
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
|
[SelectMethod(ApiName = "Get visitors Html", AppName = "crm", Description = "Get visitors Html", UniqueName = "bizgaze_transact_visitors_GetvisitorsHtml", MethodName = "getvisitorshtml", ModuleName = "visitors", PackageName = "bizgaze", ParamName1 = "visitorid")]
|
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
|
public async Task<SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>> GetVisitorshtmlAsync(SelectRequest srequest, long VisitorId)
|
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
|
long templateid = 0;
|
109
|
long templateid = 0;
|
|
|
110
|
+ //var appManager = Unibase.Dependency.DependencyConfig.Resolve<Unibase.Platform.Apps.Managers.IAppManager>();
|
114
|
var templateManager = Unibase.Dependency.DependencyConfig.Resolve<Unibase.Platform.Templates.Managers.ITemplateManager>();
|
111
|
var templateManager = Unibase.Dependency.DependencyConfig.Resolve<Unibase.Platform.Templates.Managers.ITemplateManager>();
|
115
|
var templateInfos = await templateManager.GetTemplatesAsync(srequest, "Bizgaze_Extension_CRM_CRM_TemplateProvider_Visitors");
|
112
|
var templateInfos = await templateManager.GetTemplatesAsync(srequest, "Bizgaze_Extension_CRM_CRM_TemplateProvider_Visitors");
|
116
|
if (templateInfos.Result != null && templateInfos.Result.Count > 0)
|
113
|
if (templateInfos.Result != null && templateInfos.Result.Count > 0)
|
117
|
{
|
114
|
{
|
118
|
templateid = templateInfos.Result[0].TemplateId;
|
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
|
var result = new SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>();
|
117
|
var result = new SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>();
|
129
|
var printTemplate = new Unibase.Platform.Templates.Infos.PrintTemplate();
|
118
|
var printTemplate = new Unibase.Platform.Templates.Infos.PrintTemplate();
|
|
|
119
|
+ //var templateManager = //Unibase.Dependency.DependencyConfig.Resolve<Unibase.Platform.Templates.Managers.ITemplateManager>();
|
130
|
var _dbContext = DependencyConfig.Resolve<Unibase.Data.IDbContext>();
|
120
|
var _dbContext = DependencyConfig.Resolve<Unibase.Data.IDbContext>();
|
131
|
Unibase.Platform.Templates.Helpers.TemplateHelper helper = new Unibase.Platform.Templates.Helpers.TemplateHelper(_dbContext);
|
121
|
Unibase.Platform.Templates.Helpers.TemplateHelper helper = new Unibase.Platform.Templates.Helpers.TemplateHelper(_dbContext);
|
132
|
var VisitorInfo_ = await GetVisitorByIdAsync(srequest, VisitorId);
|
122
|
var VisitorInfo_ = await GetVisitorByIdAsync(srequest, VisitorId);
|
|
|
|
|
138
|
{
|
128
|
{
|
139
|
return SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>.CreateErrorResponse("1", "Template Not Found");
|
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
|
var template = System.Web.HttpUtility.UrlDecode(templateInfo.TemplateText.ToString());
|
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
|
string multiTemplateText = "";
|
133
|
string multiTemplateText = "";
|
153
|
if (template.Contains("{{fullname}}"))
|
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
|
if (template.Contains("{{cityname}}"))
|
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
|
if (template.Contains("{{purposeofvisit}}"))
|
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
|
if (template.Contains("{{phonenumber}}"))
|
146
|
if (template.Contains("{{phonenumber}}"))
|
166
|
{
|
147
|
{
|
167
|
- template = template.Replace("{{phonenumber}}", mobilenumber);
|
|
|
|
|
148
|
+ template = template.Replace("{{phonenumber}}", VisitorInfo_.Result.MobileNumber);
|
168
|
}
|
149
|
}
|
169
|
if (template.Contains("{{code}}"))
|
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
|
if (template.Contains("{{createddate}}"))
|
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
|
if (template.Contains("{{photourl}}"))
|
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
|
if (template.Contains("{{HostName}}"))
|
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
|
if (template.Contains("{{imageurl}}"))
|
166
|
if (template.Contains("{{imageurl}}"))
|
186
|
{
|
167
|
{
|
187
|
template = template.Replace("{{imageurl}}", VisitorInfo_.Result.ImageUrl);
|
168
|
template = template.Replace("{{imageurl}}", VisitorInfo_.Result.ImageUrl);
|
188
|
}
|
169
|
}
|
|
|
170
|
+
|
189
|
multiTemplateText = template;
|
171
|
multiTemplateText = template;
|
|
|
172
|
+
|
190
|
printTemplate.PrintHTML = multiTemplateText;
|
173
|
printTemplate.PrintHTML = multiTemplateText;
|
191
|
printTemplate.FileName = "Visitors";
|
174
|
printTemplate.FileName = "Visitors";
|
192
|
printTemplate.PkId = VisitorId;
|
175
|
printTemplate.PkId = VisitorId;
|
|
|
|
|
200
|
|
183
|
|
201
|
}
|
184
|
}
|
202
|
#endregion
|
185
|
#endregion
|
203
|
-
|
|
|
204
|
/* #region Get Pre_Visitors
|
186
|
/* #region Get Pre_Visitors
|
205
|
/***/
|
187
|
/***/
|
206
|
|
188
|
|
207
|
|
189
|
|
208
|
-
|
|
|
|
|
190
|
+
|
209
|
|
191
|
|
210
|
#region Visitor Agreement
|
192
|
#region Visitor Agreement
|
211
|
/*
|
193
|
/*
|