ソースを参照

added comments and remove unnecessary code

Narmada 2年前
コミット
c68c5c0584
1個のファイルの変更84行の追加61行の削除
  1. 84
    61
      CRM.Visitors/Managers/VisitorManager.Async.cs

+ 84
- 61
CRM.Visitors/Managers/VisitorManager.Async.cs ファイルの表示

@@ -19,6 +19,7 @@ namespace Bizgaze.CRM.Visitors.Managers
19 19
     internal partial class VisitorManager : BaseManager, IVisitorManager
20 20
     {
21 21
         #region Getting data By VisitorId
22
+        // This method gets a visitor record with the given VisitorId. It takes a SelectRequest as parameter and returns a SelectResponse<Infos.Visitor> object.
22 23
         public async Task<SelectResponse<Infos.Visitor>> GetVisitorByIdAsync(SelectRequest request, long VisitorId)
23 24
         {
24 25
             var exp = request.Filter();
@@ -30,7 +31,7 @@ namespace Bizgaze.CRM.Visitors.Managers
30 31
         #endregion
31 32
 
32 33
         #region Get Visitors html
33
-
34
+        //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.
34 35
         [SelectMethod(ApiName = "Get visitors Html", AppName = "crm", Description = "Get visitors Html", UniqueName = "bizgaze_transact_visitors_GetvisitorsHtml", MethodName = "getvisitorshtml", ModuleName = "visitors", PackageName = "bizgaze", ParamName1 = "visitorid")]
35 36
         public async Task<SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>> GetVisitorshtmlAsync(SelectRequest srequest, long VisitorId)
36 37
         {
@@ -46,90 +47,75 @@ namespace Bizgaze.CRM.Visitors.Managers
46 47
             var result = new SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>();
47 48
             var printTemplate = new Unibase.Platform.Templates.Infos.PrintTemplate();
48 49
             //var templateManager = //Unibase.Dependency.DependencyConfig.Resolve<Unibase.Platform.Templates.Managers.ITemplateManager>();
49
-            var VisitorInfo_ = await GetVisitorByIdAsync(srequest, VisitorId);
50
-            var visitor = VisitorInfo_.Result.VisitorId;
51 50
             var _dbContext = DependencyConfig.Resolve<Unibase.Data.IDbContext>();
52 51
             Unibase.Platform.Templates.Helpers.TemplateHelper helper = new Unibase.Platform.Templates.Helpers.TemplateHelper(_dbContext);
53
-            List<Parameter> param = new List<Parameter>();
54
-            var select = new Unibase.Data.Sql.Select().AllColumns().From("bizgazecrm_visitors").Where("visitorid", visitor);
55
-            param.Add(new Parameter("visitorid", visitor));
56
-            var dt = await GetDataTableAsync(srequest, select, param);
57
-            var exp = srequest.Filter();
58
-            exp = exp & Unibase.Data.Expressions.Exp.Eq(Infos.Visitor.Property.VisitorId.ToString(), visitor);
59
-            srequest.Filter(exp);
60
-            var data = await GetSingleAsync<Infos.Visitor>(srequest);
61
-            if (data.Result == null)
62
-            {
63
-                return SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>.CreateErrorResponse("1", "visitor  Not Found");
64
-            }
65
-            // var templateId = 0;  
66
-            srequest.Filter(null);
67
-            var tInfo = await templateManager.GetTemplateAsync(srequest, templateid);
68
-            var templateInfo = tInfo.Result;
69
-            if (templateInfo == null)
70
-                return SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>.CreateErrorResponse("1", "Template Not Found");
71
-            var DefaultTokens = new Dictionary<string, string>();
72
-            var template = System.Web.HttpUtility.UrlDecode(templateInfo.TemplateText.ToString());
73
-            // var template = helper.GetTemplatedText(srequest, templateText, DefaultTokens, dt.Rows[0]);
74
-            string multiTemplateText = "";
75
-            var tabletemp = "";
76
-            foreach (DataRow row in dt.Rows)
52
+            var VisitorInfo_ = await GetVisitorByIdAsync(srequest, VisitorId);
53
+            if (VisitorInfo_.Result != null)
77 54
             {
78
-                var Name = row["fullname"].ToString();
79
-                var ComingFrom = row["ComingFrom"].ToString();
80
-                //var Purposeofvisit = row["PurposeOfVisit"].ToString();
81
-                var MobileNumber = row["MobileNumber"].ToString();
82
-                var HostPerson = data.Result.HostName;
83
-                var photoUrl = row["PhotoUrl"].ToString();
84
-                var Code = row["Code"];
85
-                var CreatedDate = row["CreatedDate"].ToString();
86
-                var Purposeofvisit = data.Result.PurposeOfVisitType;
55
+                var tInfo = await templateManager.GetTemplateAsync(srequest, templateid);
56
+                var templateInfo = tInfo.Result;
57
+                if (templateInfo == null)
58
+                {
59
+                    return SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>.CreateErrorResponse("1", "Template Not Found");
60
+                }
61
+                var template = System.Web.HttpUtility.UrlDecode(templateInfo.TemplateText.ToString());
62
+                string multiTemplateText = "";
87 63
                 if (template.Contains("{{fullname}}"))
88 64
                 {
89
-                    template = template.Replace("{{fullname}}", Name.ToString());
65
+                    template = template.Replace("{{fullname}}", VisitorInfo_.Result.FullName);
90 66
                 }
91 67
                 if (template.Contains("{{comingfrom}}"))
92 68
                 {
93
-                    template = template.Replace("{{comingfrom}}", ComingFrom.ToString());
69
+                    template = template.Replace("{{comingfrom}}", VisitorInfo_.Result.ComingFrom);
94 70
                 }
95 71
                 if (template.Contains("{{purposeofvisit}}"))
96 72
                 {
97
-                    template = template.Replace("{{purposeofvisit}}", Purposeofvisit.ToString());
73
+                    template = template.Replace("{{purposeofvisit}}", VisitorInfo_.Result.PurposeOfVisitType);
98 74
                 }
99 75
                 if (template.Contains("{{phonenumber}}"))
100 76
                 {
101
-                    template = template.Replace("{{phonenumber}}", MobileNumber.ToString());
77
+                    template = template.Replace("{{phonenumber}}", VisitorInfo_.Result.MobileNumber);
102 78
                 }
103 79
                 if (template.Contains("{{code}}"))
104 80
                 {
105
-                    template = template.Replace("{{code}}", Code.ToString());
81
+                    template = template.Replace("{{code}}", VisitorInfo_.Result.Code);
106 82
                 }
107 83
                 if (template.Contains("{{createddate}}"))
108 84
                 {
109
-                    template = template.Replace("{{createddate}}", CreatedDate.ToString());
85
+                    template = template.Replace("{{createddate}}", VisitorInfo_.Result.CreatedDate.ToString());
110 86
                 }
111
-                if(template.Contains("{{photourl}}"))
87
+                if (template.Contains("{{photourl}}"))
112 88
                 {
113
-                    template = template.Replace("{{photourl}}", photoUrl.ToString());
89
+                    template = template.Replace("{{photourl}}", VisitorInfo_.Result.PhotoUrl);
114 90
                 }
115 91
                 if (template.Contains("{{HostName}}"))
116 92
                 {
117
-                    template = template.Replace("{{HostName}}", HostPerson.ToString());
93
+                    template = template.Replace("{{HostName}}", VisitorInfo_.Result.HostName);
118 94
                 }
119 95
                 multiTemplateText = template;
96
+
97
+                printTemplate.PrintHTML = multiTemplateText;
98
+                printTemplate.FileName = "Visitors";
99
+                printTemplate.PkId = VisitorId;
100
+                result.Result = printTemplate;
101
+                return result;
102
+            }
103
+            else
104
+            {
105
+                return SelectResponse<Unibase.Platform.Templates.Infos.PrintTemplate>.CreateErrorResponse("1", "visitor  Not Found");
120 106
             }
121
-            printTemplate.PrintHTML = multiTemplateText;
122
-            printTemplate.FileName = "Visitors";
123
-            printTemplate.PkId = VisitorId;
124
-            result.Result = printTemplate;
125
-            return result;
126
-            //return await GetSingleAsync<Infos.Visitor>(srequest);
127 107
 
128 108
         }
129 109
         #endregion
130 110
 
131 111
         #region Get Pre_Visitors
132
-
112
+        /** 
113
+         * This method is used to get the pre-visitors with the specified code.  
114
+         * If the visitor with the given code is present, it returns the visitor data else it returns an error. 
115
+         * @param srequest The select request object 
116
+         * @param code The code of the visitor 
117
+         * @return The select response object containing the visitor data or the error. 
118
+         */
133 119
         [SelectMethod(ApiName = "Get  pre visitors", AppName = "crm", Description = "Get pre visitors", UniqueName = "bizgaze_transact_visitors_Getprevisitors", MethodName = "Getprevisitors", ModuleName = "visitors", PackageName = "bizgaze", ParamName1 = "code")]
134 120
         public async Task<SelectResponse<Bizgaze.CRM.Visitors.Infos.Visitor>> GetpreVisitorsAsync(SelectRequest srequest, string code)
135 121
         {
@@ -158,6 +144,12 @@ namespace Bizgaze.CRM.Visitors.Managers
158 144
         #endregion
159 145
 
160 146
         #region Visitor Agreement
147
+        /* 
148
+         Action Method Name: visitoragreement 
149
+         Description: This action method is used to update the agreement status of the visitors in the bizgazecrm_visitors table. 
150
+         Parameters: visitorid - The ID of the visitor whose status is to be updated. 
151
+         Return: ActionResponse - Returns success or error response based on the success of the query. 
152
+         */
161 153
         [ActionMethod(ApiName = "visitor agreement", AppName = "crm", Description = "visitor agreement", UniqueName = "bizgaze_transact_visitors_visitoragreement", MethodName = "visitoragreement", ModuleName = "visitors", PackageName = "bizgaze", ParamName1 = "visitorid")]
162 154
         public async Task<ActionResponse<Bizgaze.CRM.Visitors.Infos.Visitor>> VisitorAgreementAsync(ActionRequest arequest, long VisitorId)
163 155
         {
@@ -175,27 +167,45 @@ namespace Bizgaze.CRM.Visitors.Managers
175 167
             {
176 168
                 return ActionResponse<Bizgaze.CRM.Visitors.Infos.Visitor>.CreateErrorResponse("", "Visitor Not Found");
177 169
             }
178
-            
170
+
179 171
         }
180 172
 
181 173
         #endregion
182 174
 
183 175
         #region check Mobile Number
176
+        /** 
177
+        * Api Name: check Mobile Number 
178
+        * App Name: crm 
179
+        * Description: check Mobile Numbert 
180
+        * Unique Name: bizgaze_transact_visitors_checkMobileNumber 
181
+        * Method Name: checkmobilenumber 
182
+        * Module Name: visitors 
183
+        * Package Name: bizgaze 
184
+        * Param Name1: mobilenumber 
185
+        * Param Name2: emailid   
186
+        * This method is used to check the existing mobile number and email id in the Visitors table and return an error response. 
187
+        */
184 188
 
185
-        [ActionMethod(ApiName = "check Mobile Number", AppName = "crm", Description = "check Mobile Numbert", UniqueName = "bizgaze_transact_visitors_checkMobileNumber", MethodName = "checkmobilenumber", ModuleName = "visitors", PackageName = "bizgaze", ParamName1 = "mobilenumber",ParamName2 ="emailid")]
186
-        public async Task<ActionResponse<Bizgaze.CRM.Visitors.Infos.Visitor>>checkMobileNumberAsync(ActionRequest arequest, string mobileNumber ,string emailId)
189
+        [ActionMethod(ApiName = "check Mobile Number", AppName = "crm", Description = "check Mobile Numbert", UniqueName = "bizgaze_transact_visitors_checkMobileNumber", MethodName = "checkmobilenumber", ModuleName = "visitors", PackageName = "bizgaze", ParamName1 = "mobilenumber", ParamName2 = "emailid")]
190
+        public async Task<ActionResponse<Bizgaze.CRM.Visitors.Infos.Visitor>> checkMobileNumberAsync(ActionRequest arequest, string mobileNumber, string emailId)
187 191
         {
188 192
             var srequest = SelectRequest.FromRequest(arequest);
189 193
             var parameters = new List<Unibase.Data.Parameter>();
190 194
             var connection = GetConnection(srequest);
191 195
             var sql = new Unibase.Data.Sql.Select("bizgazecrm_visitors").AllColumns();
192 196
             List<Unibase.Data.Parameter> viparam = new List<Unibase.Data.Parameter>();
193
-            return ActionResponse<Bizgaze.CRM.Visitors.Infos.Visitor>.CreateErrorResponse("", "Mobile Number And Email Id Alredy Exit");          
197
+            return ActionResponse<Bizgaze.CRM.Visitors.Infos.Visitor>.CreateErrorResponse("", "Mobile Number And Email Id Alredy Exit");
194 198
         }
195 199
 
196 200
         #endregion
197 201
 
198 202
         #region  Getting data from Visitors by Mobile Number
203
+        /** 
204
+         * Get a single visitor record by mobile number 
205
+         * @param SelectRequest srequest - the filer criteria 
206
+         * @param string MobileNumber - the mobile number of the visitor that needs to be retrieved 
207
+         * @return SelectResponse<Bizgaze.CRM.Visitors.Infos.Visitor> - the response containing visitor information 
208
+         */
199 209
         [SelectMethod(ApiName = "getvisitorsbymobilenumber", AppName = "crm", Description = "getvisitorsbymobilenumber", UniqueName = "bizgaze_transact_visitors_getvisitorsbymobilenumber", MethodName = "visitorsbymobilenumber", ModuleName = "visitors", PackageName = "bizgaze", ParamName1 = "mobilenumber")]
200 210
         public async Task<SelectResponse<Bizgaze.CRM.Visitors.Infos.Visitor>> VisitorsbyMobileNumberAsync(SelectRequest srequest, string MobileNumber)
201 211
         {
@@ -207,6 +217,10 @@ namespace Bizgaze.CRM.Visitors.Managers
207 217
         #endregion
208 218
 
209 219
         #region  Get installedAppId Async
220
+        /*  
221
+         This method is used to get the install app id based on the visitorid.  
222
+         The method takes the select request and visitorid as parameters and returns a select response of type Bizgaze.CRM.Visitors.Infos.Visitor.  
223
+         */
210 224
 
211 225
         [SelectMethod(ApiName = "getinstallappid", AppName = "crm", Description = "getinstallappid", UniqueName = "bizgaze_crm_visitors_getinstallappid", MethodName = "getinstallappid", ModuleName = "visitors", PackageName = "bizgaze", ParamName1 = "visitorid")]
212 226
         public async Task<SelectResponse<Bizgaze.CRM.Visitors.Infos.Visitor>> GetInstallappAsync(SelectRequest srequest, long VisitorId)
@@ -219,7 +233,7 @@ namespace Bizgaze.CRM.Visitors.Managers
219 233
         #endregion
220 234
 
221 235
         #region Get Visitor INformation
222
-
236
+        // Gets Visitors information with the given Visitor Id.
223 237
         public async Task<SelectResponse<Bizgaze.CRM.Visitors.Infos.Visitor>> GetVisitorsAsync(SelectRequest srequest, long VisitorId)
224 238
         {
225 239
             var exp = srequest.Filter();
@@ -231,10 +245,19 @@ namespace Bizgaze.CRM.Visitors.Managers
231 245
         #endregion
232 246
 
233 247
         #region Save Visitor Image
248
+        /* 
249
+         *  ActionMethod Name: SaveVisitorImage 
250
+         *  ApiName: Bizgaze_crm_Visitor_Capture 
251
+         *  Description: This method is used for capturing the image of the visitor. 
252
+         *  AppName: crm 
253
+         *  ModuleName: visitors 
254
+         *  PackageName: bizgaze 
255
+        *  UniqueName: Bizgaze_crm_Visitor_Capture 
256
+       */
234 257
         [ActionMethod(ApiName = "VisitorCapture ", AppName = "crm", Description = "image Capture ", UniqueName = "Bizgaze_crm_Visitor_Capture", MethodName = "SaveVisitorImage", ModuleName = "visitors", PackageName = "bizgaze")]
235 258
         public async Task<ActionResponse> SaveVisitorImageAsync(ActionRequest request, ExpandoObject obj)
236 259
         {
237
-            using (var requestTrans =await request.BeginTransactionAsync())
260
+            using (var requestTrans = await request.BeginTransactionAsync())
238 261
             {
239 262
                 {
240 263
                     SelectRequest rrequest = new SelectRequest(request.Transaction)
@@ -248,11 +271,11 @@ namespace Bizgaze.CRM.Visitors.Managers
248 271
                     var Update = new Update("bizgazecrm_visitors");
249 272
                     parameters.Add("photourl", Photourl);
250 273
                     Update.Values(parameters).Where(Exp.Eq("visitorid", visitorid));
251
-                    var ds = await _repository.ExecuteAsync(request, Update); 
274
+                    var ds = await _repository.ExecuteAsync(request, Update);
252 275
                     if (requestTrans.StartedLocal) await request.CommitTransactionAsync();
253
-                    return  ActionResponse.CreateSuccessResponse("Your Image Saved Successfully", ds.Result);                   
276
+                    return ActionResponse.CreateSuccessResponse("Your Image Saved Successfully", ds.Result);
254 277
                 }
255
-                
278
+
256 279
             }
257 280
         }
258 281
 

読み込み中…
キャンセル
保存