|
@@ -0,0 +1,148 @@
|
|
1
|
+using Bizgaze.CRM;
|
|
2
|
+using System;
|
|
3
|
+using System.Collections.Generic;
|
|
4
|
+using System.Dynamic;
|
|
5
|
+using System.Linq;
|
|
6
|
+using System.Text;
|
|
7
|
+using System.Text.Json;
|
|
8
|
+using System.Threading.Tasks;
|
|
9
|
+using Unibase.Data;
|
|
10
|
+using Unibase.Data.Expressions;
|
|
11
|
+using Unibase.Data.Sql;
|
|
12
|
+using Unibase.Dependency;
|
|
13
|
+using Unibase.Platform.Apps.Managers;
|
|
14
|
+using Unibase.Platform.Data;
|
|
15
|
+using Unibase.Platform.Forms.Providers;
|
|
16
|
+using Unibase.Platform.Keys;
|
|
17
|
+
|
|
18
|
+namespace CRM.Visitors.ActionProviders
|
|
19
|
+{
|
|
20
|
+ class FeedBackPostActionProvider : BaseFormActionProvider, IFormActionProvider
|
|
21
|
+ {
|
|
22
|
+ public string ControllerClass
|
|
23
|
+ {
|
|
24
|
+ get
|
|
25
|
+ {
|
|
26
|
+ return "Bizgaze.CRM.Visitors.ActionProviders.FeedBackPostActionProvider";
|
|
27
|
+
|
|
28
|
+ }
|
|
29
|
+ }
|
|
30
|
+ public string FormActionName
|
|
31
|
+ {
|
|
32
|
+ get
|
|
33
|
+ {
|
|
34
|
+ return "FeedBack";
|
|
35
|
+ }
|
|
36
|
+ }
|
|
37
|
+ public string Description
|
|
38
|
+ {
|
|
39
|
+ get
|
|
40
|
+ {
|
|
41
|
+ return "Feed Back Pos tAction Provider";
|
|
42
|
+ }
|
|
43
|
+ }
|
|
44
|
+ public UniqueKey UniqueId
|
|
45
|
+ {
|
|
46
|
+ get
|
|
47
|
+ {
|
|
48
|
+ return Bizgaze.CRM.Actions.FeedBack;
|
|
49
|
+ }
|
|
50
|
+ }
|
|
51
|
+ public int ActionType
|
|
52
|
+ {
|
|
53
|
+ get
|
|
54
|
+ {
|
|
55
|
+ return (int)Unibase.Platform.Forms.Enums.FormActionProvider.PostAction;
|
|
56
|
+ }
|
|
57
|
+ }
|
|
58
|
+ public ActionResponse<ExpandoObject> Execute(ActionRequest request, object IdValue, ExpandoObject obj, List<Unibase.Platform.Forms.Requests.DocParameter> docParametersList, ref long defaultPKValue)
|
|
59
|
+ {
|
|
60
|
+ return null;
|
|
61
|
+
|
|
62
|
+ }
|
|
63
|
+ public async Task<ActionResponse<FormActionResponse>> ExecuteAsync(ActionRequest request, FormActionProviderObject providerObject)
|
|
64
|
+ {
|
|
65
|
+ using (var requestTrans = await request.BeginTransactionAsync())
|
|
66
|
+ {
|
|
67
|
+ var IdValue = providerObject.IdValue;
|
|
68
|
+ var srequest = SelectRequest.FromRequest(request);
|
|
69
|
+ var obj = providerObject.RequestObject;
|
|
70
|
+ var docParametersList = providerObject.DocParametersList;
|
|
71
|
+ dynamic visitorparam = new Dictionary<string, object>();
|
|
72
|
+ var defaultPKValue = providerObject.DefaultPKValue;
|
|
73
|
+ var stageManager = Unibase.Dependency.DependencyConfig.Resolve<IStageManager>();
|
|
74
|
+ var visitorManager = Unibase.Dependency.DependencyConfig.Resolve<Bizgaze.CRM.Visitors.Managers.IVisitorManager>();
|
|
75
|
+ var dictObj = obj as IDictionary<string, dynamic>;
|
|
76
|
+ var connection = GetConnection(request);
|
|
77
|
+ ExpandoObject obj1 = dictObj["RequestObj"];
|
|
78
|
+ var req = obj1 as IDictionary<string, object>;
|
|
79
|
+ var code = Convert.ChangeType(req["uniqueid"].ToString(), typeof(object)).ToString();
|
|
80
|
+ var feedBackJson = Convert.ChangeType(req["feedbackrating"].ToString(), typeof(object)).ToString();
|
|
81
|
+ var feedBackObj = JsonSerializer.Deserialize<Request.VisitorRequest>(feedBackJson);
|
|
82
|
+ var comments = feedBackObj.Comments;
|
|
83
|
+ var rating = feedBackObj.Rating;
|
|
84
|
+ var visitorInfo = await visitorManager.GetpreVisitorsAsync(srequest, code);
|
|
85
|
+ if (visitorInfo != null)
|
|
86
|
+ {
|
|
87
|
+ var visitorId = Convert.ToInt64(visitorInfo.Result.VisitorId);
|
|
88
|
+ var sql = new Unibase.Data.Sql.Select("bizgazecrm_visitors").Columns("bizgazecrm_visitors.installedappid", "bizgazecrm_visitors.fullname", "bizgazecrm_visitors.mobilenumber", "bizgazecrm_visitors.emailid", "bizgazecrm_visitors.photourl", "unibase_stagestatus.stageStatusName", "unibase_stagestatus.RefStatusId").InnerJoin("unibase_stages", Exp.EqColumns("unibase_stages.stageid", "bizgazecrm_visitors.stageid")).InnerJoin("unibase_stagestatus", Exp.EqColumns("unibase_stagestatus.stagestatusid", "unibase_stages.stagestatusid")).Where("bizgazecrm_visitors.visitorid", visitorId);
|
|
89
|
+ List<Parameter> param = new List<Parameter>();
|
|
90
|
+ param.Add(new Parameter("@bizgazecrm_visitors.visitorid", visitorId));
|
|
91
|
+ var dt = GetDataTable(srequest, sql, param);
|
|
92
|
+ var stageStatusName = "";
|
|
93
|
+ if (dt.Rows.Count > 0)
|
|
94
|
+ {
|
|
95
|
+ stageStatusName = "CheckOut";
|
|
96
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
97
|
+ {
|
|
98
|
+ var installedAppId = Convert.ToInt64(dt.Rows[i]["installedAppId"]);
|
|
99
|
+ var stage = stageManager.GetStageByStageStatus(srequest, installedAppId, stageStatusName);
|
|
100
|
+ var NewStageId = stage.Result.StageId;
|
|
101
|
+ var UpdateStage = new Update("bizgazecrm_visitors").Value("stageid", NewStageId).Where(Exp.Eq("visitorId", visitorId));
|
|
102
|
+ _repository.Execute(request, UpdateStage);
|
|
103
|
+ }
|
|
104
|
+ var options = new EntityOptions()
|
|
105
|
+ {
|
|
106
|
+ IsIdentity = true,
|
|
107
|
+ IsNewEntity = true,
|
|
108
|
+ TableName = "bizgazecrm_visitorcheckout",
|
|
109
|
+ PkColumn = "visitorcheckoutid",
|
|
110
|
+ IsExcludeFromAudit = false,
|
|
111
|
+ Id = 0,
|
|
112
|
+ };
|
|
113
|
+ dynamic visitor = new Dictionary<string, object>();
|
|
114
|
+ visitor.Add("createdby", srequest.Identity.UserId);
|
|
115
|
+ visitor.Add("createddate", DateTime.Now);
|
|
116
|
+ visitor.Add("checkoutdate", DateTime.Now);
|
|
117
|
+ visitor.Add("comments", comments);
|
|
118
|
+ visitor.Add("rating", Convert.ToInt32(rating));
|
|
119
|
+ visitor.Add("versionguid", Guid.NewGuid());
|
|
120
|
+ visitor.Add("uniqueid", code);
|
|
121
|
+ visitor.Add("statusid", (int)RowStatus.Active);
|
|
122
|
+ visitor.Add("installedappid", visitorInfo.Result.Installedappid);
|
|
123
|
+ visitor.Add("visitorid", visitorInfo.Result.VisitorId);
|
|
124
|
+ var responses = await _repository.SaveAsync(request, options, visitor);
|
|
125
|
+ if (responses.Status == ResponseStatus.Error)
|
|
126
|
+ {
|
|
127
|
+ if (requestTrans.StartedLocal) await request.RollbackTransactionAsync();
|
|
128
|
+ return ActionResponse<FormActionResponse>.CreateErrorResponse("1", "Visitor Check Out Data Not Saved");
|
|
129
|
+ }
|
|
130
|
+ }
|
|
131
|
+ }
|
|
132
|
+ var returnresponse = new FormActionResponse();
|
|
133
|
+ returnresponse.Obj = dictObj as ExpandoObject;
|
|
134
|
+ returnresponse.PkValue = defaultPKValue;
|
|
135
|
+ return ActionResponse<FormActionResponse>.CreateSuccessResponse("success", returnresponse);
|
|
136
|
+ }
|
|
137
|
+ }
|
|
138
|
+ public List<UniqueKey> AppliedApps
|
|
139
|
+ {
|
|
140
|
+ get
|
|
141
|
+ {
|
|
142
|
+ return new List<UniqueKey>() {
|
|
143
|
+ Bizgaze.CRM.Actions.FeedBack,
|
|
144
|
+ };
|
|
145
|
+ }
|
|
146
|
+ }
|
|
147
|
+ }
|
|
148
|
+}
|