-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathWebFormServices.cs
More file actions
3178 lines (2942 loc) · 169 KB
/
WebFormServices.cs
File metadata and controls
3178 lines (2942 loc) · 169 KB
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using ExpressBase.Common;
using ExpressBase.Common.Constants;
using ExpressBase.Common.Data;
using ExpressBase.Common.Extensions;
using ExpressBase.Common.LocationNSolution;
using ExpressBase.Common.Objects;
using ExpressBase.Common.Structures;
using ExpressBase.Security;
using ExpressBase.Objects;
using ExpressBase.Objects.Objects;
using ExpressBase.Objects.Objects.DVRelated;
using ExpressBase.Objects.ServiceStack_Artifacts;
using ExpressBase.Objects.WebFormRelated;
using Jurassic;
using Jurassic.Library;
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using Newtonsoft.Json;
using ServiceStack;
using ServiceStack.Messaging;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Net;
using System.Globalization;
using ExpressBase.Objects.Helpers;
using Newtonsoft.Json.Linq;
using System.IO;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using ServiceStack.Text;
using System.Text;
using ServiceStack.Redis;
namespace ExpressBase.ServiceStack.Services
{
[Authenticate]
public class WebFormServices : EbBaseService
{
public WebFormServices(IEbConnectionFactory _dbf, IMessageProducer _mqp, PooledRedisClientManager pooledRedisManager) : base(_dbf, _mqp, pooledRedisManager) { }
//========================================== FORM TABLE CREATION ==========================================
public CreateWebFormTableResponse Any(CreateWebFormTableRequest request)
{
if (request.WebObj is EbWebForm)
{
EbWebForm Form = request.WebObj as EbWebForm;
Form.AfterRedisGet_All(this);
if (Form.EnableSqlRetriver)
{
Form.SolutionObj = request.SoluObj ?? this.GetSolutionObject(request.SolnId);
CreateFormDataSqlRetrival(Form);
}
if (Form.DataPushers.Count > 0)
{
foreach (EbDataPusher pusher in Form.DataPushers)
{
if (pusher is EbApiDataPusher)
continue;
EbWebForm _form = this.GetWebFormObject(pusher.FormRefId, null, null);
TableSchema _tableDest = _form.FormSchema.Tables.Find(e => e.TableName.Equals(_form.FormSchema.MasterTable));
//_table.Columns.Add(new ColumnSchema { ColumnName = "eb_push_id", EbDbType = (int)EbDbTypes.String, Control = new EbTextBox { Name = "eb_push_id", Label = "Push Id" } });// multi push id
//_table.Columns.Add(new ColumnSchema { ColumnName = "eb_src_id", EbDbType = (int)EbDbTypes.Decimal, Control = new EbNumeric { Name = "eb_src_id", Label = "Source Id" } });// source master table id
if (_tableDest != null)
{
if (pusher is EbBatchFormDataPusher batchDp)
{
TableSchema _tableSrc = Form.FormSchema.Tables.Find(e => e.ContainerName == batchDp.SourceDG);
if (_tableSrc != null)
{
string cName = _tableSrc.TableName + FormConstants._id;
if (!_tableDest.Columns.Exists(e => e.ColumnName == cName))
{
_tableDest.Columns.Add(new ColumnSchema
{
ColumnName = cName,
EbDbType = (int)EbDbTypes.Int32,
Control = new EbNumeric { Name = cName }
});
}
cName = _tableDest.TableName + FormConstants._id;
if (!_tableSrc.Columns.Exists(e => e.ColumnName == cName))
{
_tableSrc.Columns.Add(new ColumnSchema
{
ColumnName = cName,
EbDbType = (int)EbDbTypes.Int32,
Control = new EbNumeric { Name = cName }
});
}
}
}
Form.FormSchema.Tables.Add(_tableDest);
}
}
}
CreateWebFormTables(Form, request);
InsertDataIfRequired(Form.FormSchema, Form.RefId);
}
return new CreateWebFormTableResponse { };
}
private void CreateFormDataSqlRetrival(EbWebForm Form)
{
(string srcTableQuery, string destTableQuery) = Form.GetFormDataQueries(this.EbConnectionFactory.DataDB, this);
string[] ref_id_parts = Form.RefId.Split("-");
string[] queries4PriTable = srcTableQuery.Trim().TrimEnd(';').Split(';');
string[] queries4DataPushers = destTableQuery.Trim().Length > 0 ? destTableQuery.Trim().TrimEnd(';').Split(';') : new string[0];
string[] queries4PowSelect = Form.GetFormDataPsSelectQueries(this);
string FnString = GetFunctionString_4_FormDataRetrieval(Form.DisplayName, Convert.ToInt32(ref_id_parts[3]), Convert.ToInt32(ref_id_parts[4]), Form.TableName, queries4PriTable, queries4DataPushers, queries4PowSelect);
this.EbConnectionFactory.DataDB.DoNonQuery(FnString);
}
static string GetFunctionString_4_FormDataRetrieval(string form_displayname, int form_id, int form_ver_id, string primaryTableName,
string[] queries4PriTable, string[] queries4DataPushers, string[] queries4PowSelect)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append($@"
CREATE OR REPLACE FUNCTION public.eb_udf_{form_displayname.ToLower().Replace(" ", "_").Replace("-", "_").Replace("&", "_")}_{form_id}_{form_ver_id}_get_form_data(id__in integer, include_datapusher__in boolean)
RETURNS SETOF refcursor
LANGUAGE plpgsql
AS $$
DECLARE");
for (int i = 0; i < queries4PriTable.Length; i++)
stringBuilder.Append($@"
ref{i} refcursor:= 'ref{i}';");
for (int i = queries4PriTable.Length; i < queries4PriTable.Length + queries4PowSelect.Length; i++)
stringBuilder.Append($@"
ref{i} refcursor:= 'ref{i}';");
for (int i = queries4PriTable.Length + queries4PowSelect.Length; i < queries4PriTable.Length + queries4PowSelect.Length + queries4DataPushers.Length; i++)
stringBuilder.Append($@"
ref{i} refcursor:= 'ref{i}';");
stringBuilder.Append(@"
BEGIN");
for (int i = 0; i < queries4PriTable.Length; i++)
{
stringBuilder.Append($@"
OPEN ref{i} FOR
{queries4PriTable[i].Replace($"@{primaryTableName}_id", "id__in")};
RETURN NEXT ref{i};
");
}
for (int i = queries4PriTable.Length; i < queries4PriTable.Length + queries4PowSelect.Length; i++)
{
stringBuilder.Append($@"
OPEN ref{i} FOR
{queries4PowSelect[i - queries4PriTable.Length]};
RETURN NEXT ref{i};
");
}
for (int i = queries4PriTable.Length + queries4PowSelect.Length; i < queries4PriTable.Length + queries4PowSelect.Length + queries4DataPushers.Length; i++)
{
stringBuilder.Append($@"
IF include_datapusher__in THEN
OPEN ref{i} FOR
{queries4DataPushers[i - queries4PriTable.Length - queries4PowSelect.Length].Replace($"@{primaryTableName}_id", "id__in")};
RETURN NEXT ref{i};
END IF;
");
}
stringBuilder.Append(@"
END;
$$");
return stringBuilder.ToString();
}
public CreateMyProfileTableResponse Any(CreateMyProfileTableRequest request)
{
List<TableColumnMeta> listNamesAndTypes = new List<TableColumnMeta>
{
new TableColumnMeta { Name = "eb_users_id", Type = this.EbConnectionFactory.DataDB.VendorDbTypes.Int32 }
};
if (request.UserTypeForms != null)
{
foreach (EbProfileUserType eput in request.UserTypeForms)
{
if (string.IsNullOrEmpty(eput.RefId))
continue;
EbWebForm _form = EbFormHelper.GetEbObject<EbWebForm>(eput.RefId, null, this.Redis, this, this.PooledRedisManager);
string Msg = string.Empty;
CreateOrAlterTable(_form.TableName, listNamesAndTypes, ref Msg);
Console.WriteLine("CreateMyProfileTableRequest - WebForm Resp msg: " + Msg);
}
}
if (request.UserTypeMobPages != null)
{
foreach (EbProfileUserType eput in request.UserTypeMobPages)
{
if (string.IsNullOrEmpty(eput.RefId))
continue;
EbMobilePage _mobPage = EbFormHelper.GetEbObject<EbMobilePage>(eput.RefId, null, this.Redis, this, this.PooledRedisManager);
if (!(_mobPage.Container is EbMobileForm))
continue;
string Msg = string.Empty;
CreateOrAlterTable((_mobPage.Container as EbMobileForm).TableName, listNamesAndTypes, ref Msg);
Console.WriteLine("CreateMyProfileTableRequest - MobileForm Resp msg: " + Msg);
}
}
return new CreateMyProfileTableResponse { };
}
//Review control related data
private void InsertDataIfRequired(WebFormSchema _schema, string _refId)
{
EbReview reviewCtrl = (EbReview)_schema.ExtendedControls.Find(e => e is EbReview);
if (reviewCtrl == null || _refId == null)
return;
int[] stageIds = new int[reviewCtrl.FormStages.Count];
string selQ = @"SELECT id FROM eb_stages WHERE form_ref_id = @form_ref_id AND COALESCE(eb_del, 'F') = 'F' ORDER BY id; ";
EbDataTable dt = this.EbConnectionFactory.DataDB.DoQuery(selQ, new DbParameter[] { this.EbConnectionFactory.DataDB.GetNewParameter("form_ref_id", EbDbTypes.String, _refId) });
for (int i = 0; i < dt.Rows.Count && i < stageIds.Length; i++)
{
int.TryParse(dt.Rows[i][0].ToString(), out stageIds[i]);
}
string fullQ = $@"UPDATE eb_stage_actions SET eb_del = 'T' WHERE COALESCE(eb_del, 'F') = 'F' AND eb_stages_id IN (SELECT id FROM eb_stages WHERE form_ref_id = @form_ref_id AND COALESCE(eb_del, 'F') = 'F');
UPDATE eb_stages SET eb_del = 'T' WHERE form_ref_id = @form_ref_id AND COALESCE(eb_del, 'F') = 'F' AND id NOT IN ({stageIds.Join(",")}); ";
List<DbParameter> param = new List<DbParameter>();
param.Add(this.EbConnectionFactory.DataDB.GetNewParameter("form_ref_id", EbDbTypes.String, _refId));
for (int i = 0; i < stageIds.Length; i++)
{
EbReviewStage reviewStage = reviewCtrl.FormStages[i] as EbReviewStage;
string stageid = "(SELECT eb_currval('eb_stages_id_seq'))";
if (stageIds[i] == 0)
{
fullQ += $@"INSERT INTO eb_stages(stage_name, stage_unique_id, form_ref_id, eb_del)
VALUES (@stage_name_{i}, @stage_unique_id_{i}, @form_ref_id, 'F'); ";
if (this.EbConnectionFactory.DataDB.Vendor == DatabaseVendors.MYSQL)
fullQ += $"SELECT eb_persist_currval('eb_stages_id_seq'); ";
}
else
{
fullQ += $@"UPDATE eb_stages SET stage_name = @stage_name_{i}, stage_unique_id = @stage_unique_id_{i}
WHERE form_ref_id = @form_ref_id AND id = {stageIds[i]}; ";
stageid = stageIds[i].ToString();
}
param.Add(this.EbConnectionFactory.DataDB.GetNewParameter($"stage_name_{i}", EbDbTypes.String, reviewStage.Name));
param.Add(this.EbConnectionFactory.DataDB.GetNewParameter($"stage_unique_id_{i}", EbDbTypes.String, reviewStage.EbSid));
for (int j = 0; j < reviewStage.StageActions.Count; j++)
{
EbReviewAction reviewAction = reviewStage.StageActions[j] as EbReviewAction;
fullQ += $@"INSERT INTO eb_stage_actions(action_name, action_unique_id, eb_stages_id, eb_del)
VALUES (@action_name_{i}_{j}, @action_unique_id_{i}_{j}, {stageid}, 'F'); ";
param.Add(this.EbConnectionFactory.DataDB.GetNewParameter($"action_name_{i}_{j}", EbDbTypes.String, reviewAction.Name));
param.Add(this.EbConnectionFactory.DataDB.GetNewParameter($"action_unique_id_{i}_{j}", EbDbTypes.String, reviewAction.EbSid));
}
}
this.EbConnectionFactory.DataDB.DoNonQuery(fullQ, param.ToArray());
}
private void CreateWebFormTables(EbWebForm Form, CreateWebFormTableRequest request)
{
WebFormSchema _schema = Form.FormSchema;
Form.SolutionObj = request.SoluObj ?? this.GetSolutionObject(request.SolnId);
EbSystemColumns ebs = Form.SolutionObj.SolutionSettings?.SystemColumns ?? new EbSystemColumns(EbSysCols.Values);// Solu Obj is null
IVendorDbTypes vDbTypes = this.EbConnectionFactory.DataDB.VendorDbTypes;
string Msg = string.Empty;
foreach (TableSchema _table in _schema.Tables.FindAll(e => !e.DoNotPersist))
{
List<TableColumnMeta> _listNamesAndTypes = new List<TableColumnMeta>();
if (_table.Columns.Count > 0 && _table.TableType != WebFormTableTypes.Review)
{
bool CurrencyCtrlFound = false;
foreach (ColumnSchema _column in _table.Columns)
{
if (_column.Control is EbAutoId)
{
_listNamesAndTypes.Add(new TableColumnMeta { Name = _column.ColumnName, Type = vDbTypes.GetVendorDbTypeStruct((EbDbTypes)_column.EbDbType), Unique = true, Control = _column.Control, Label = _column.Control.Label });
_listNamesAndTypes.Add(new TableColumnMeta { Name = _column.ColumnName + "_ebbkup", Type = vDbTypes.GetVendorDbTypeStruct((EbDbTypes)_column.EbDbType), Label = _column.Control.Label + "_ebbkup" });
}
else if (_column.Control.DoNotPersist || _column.Control.IsSysControl)
continue;
else
{
_listNamesAndTypes.Add(new TableColumnMeta { Name = _column.ColumnName, Type = vDbTypes.GetVendorDbTypeStruct((EbDbTypes)_column.EbDbType), Label = _column.Control.Label, Control = _column.Control });
if (_column.Control is EbPhone _ebPhCtrl && _ebPhCtrl.Sendotp)
_listNamesAndTypes.Add(new TableColumnMeta { Name = _column.ColumnName + FormConstants._verified, Type = vDbTypes.Boolean, Default = "F", Label = _column.Control.Label + "_verified" });
else if (_column.Control is EbEmailControl _ebEmCtrl && _ebEmCtrl.Sendotp)
_listNamesAndTypes.Add(new TableColumnMeta { Name = _column.ColumnName + FormConstants._verified, Type = vDbTypes.Boolean, Default = "F", Label = _column.Control.Label + "_verified" });
if ((_column.Control is EbNumeric numCtrl && numCtrl.InputMode == NumInpMode.Currency) ||
(_column.Control is EbDGNumericColumn numCol && numCol.InputMode == NumInpMode.Currency))
CurrencyCtrlFound = true;
}
}
if (_table.TableName == _schema.MasterTable)
{
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_ver_id], Type = vDbTypes.Int32 });// id refernce to the parent table will store in this column - foreignkey
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_lock], Type = vDbTypes.GetVendorDbTypeStruct(ebs.GetDbType(SystemColumns.eb_lock)), Default = ebs.GetBoolFalse(SystemColumns.eb_lock, false), Label = "Lock ?" });// lock to prevent editing
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_push_id], Type = vDbTypes.String, Label = "Multi push id" });// multi push id - for data pushers
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_src_id], Type = vDbTypes.Int32, Label = "Source id" });// source id - for data pushers
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_src_ver_id], Type = vDbTypes.Int32, Label = "Source version id" });// source version id - for data pushers
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_ro], Type = vDbTypes.GetVendorDbTypeStruct(ebs.GetDbType(SystemColumns.eb_ro)), Default = ebs.GetBoolFalse(SystemColumns.eb_ro, false), Label = "Read Only?" });// Readonly
}
else
_listNamesAndTypes.Add(new TableColumnMeta { Name = _schema.MasterTable + "_id", Type = vDbTypes.Int32 });// id refernce to the parent table will store in this column - foreignkey
if (_table.TableType == WebFormTableTypes.Grid)
{
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_row_num], Type = vDbTypes.Int32 });// data grid row number
}
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_created_by], Type = vDbTypes.Int32, Label = "Created By" });
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_created_at], Type = vDbTypes.DateTime, Label = "Created At" });
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_lastmodified_by], Type = vDbTypes.Int32, Label = "Last Modified By" });
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_lastmodified_at], Type = vDbTypes.DateTime, Label = "Last Modified At" });
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_del], Type = vDbTypes.GetVendorDbTypeStruct(ebs.GetDbType(SystemColumns.eb_del)), Default = ebs.GetBoolFalse(SystemColumns.eb_del, false) });// delete
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_void], Type = vDbTypes.GetVendorDbTypeStruct(ebs.GetDbType(SystemColumns.eb_void)), Default = ebs.GetBoolFalse(SystemColumns.eb_void, false), Label = "Void ?" });// cancel //only ?
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_loc_id], Type = vDbTypes.Int16, Label = "Location" });// location id //only ?
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_signin_log_id], Type = vDbTypes.Int32, Label = "Log Id" });
//_listNamesAndTypes.Add(new TableColumnMeta { Name = "eb_default", Type = vDbTypes.Boolean, Default = "F" });
if (Form.CancelReason)
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_void_reason], Type = vDbTypes.String, Label = "Cancel Reason" });
if (CurrencyCtrlFound)
{
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_currency_id], Type = vDbTypes.Int32, Label = "Currency Id" });
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_currency_xid], Type = vDbTypes.String, Label = "Currency Xid" });
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_xrate1], Type = vDbTypes.Decimal, Label = "Xrate1" });
_listNamesAndTypes.Add(new TableColumnMeta { Name = ebs[SystemColumns.eb_xrate2], Type = vDbTypes.Decimal, Label = "Xrate1" });
}
int _rowaff = CreateOrAlterTable(_table.TableName, _listNamesAndTypes, ref Msg);
if (_table.TableName == _schema.MasterTable && !request.IsImport && (request.WebObj as EbWebForm).AutoDeployTV)
{
if (_schema.ExtendedControls.Find(e => e is EbReview) != null)
_listNamesAndTypes.Add(new TableColumnMeta { Name = "eb_approval", Label = "Approval" });
if (!request.IsImport)
CreateOrUpdateDsAndDv(request, _listNamesAndTypes);
}
}
}
if (!request.DontThrowException && !Msg.IsEmpty())
throw new FormException(Msg);
}
public int CreateOrAlterTable(string tableName, List<TableColumnMeta> listNamesAndTypes, ref string Msg)
{
int status = -1;
//checking for space in column name, table name
if (string.IsNullOrWhiteSpace(tableName) || tableName.Contains(CharConstants.SPACE))
throw new FormException("Table creation failed - Invalid table name: " + tableName);
foreach (TableColumnMeta entry in listNamesAndTypes)
if (entry.Name.Contains(CharConstants.SPACE))
throw new FormException("Table creation failed : Invalid column name" + entry.Name);
var isTableExists = this.EbConnectionFactory.DataDB.IsTableExists(this.EbConnectionFactory.DataDB.IS_TABLE_EXIST, new DbParameter[] { this.EbConnectionFactory.DataDB.GetNewParameter("tbl", EbDbTypes.String, tableName) });
if (!isTableExists)
{
string cols = string.Join(CharConstants.COMMA + CharConstants.SPACE.ToString(), listNamesAndTypes.Select(x => x.Name + CharConstants.SPACE + x.Type.VDbType.ToString() + (x.Default.IsNullOrEmpty() ? "" : (" DEFAULT '" + x.Default + "'"))).ToArray());
string sql = string.Empty;
if (this.EbConnectionFactory.DataDB.Vendor == DatabaseVendors.ORACLE)////////////
{
sql = "CREATE TABLE @tbl(id NUMBER(10), @cols)".Replace("@cols", cols).Replace("@tbl", tableName);
this.EbConnectionFactory.DataDB.CreateTable(sql);//Table Creation
CreateSquenceAndTrigger(tableName);
}
else if (this.EbConnectionFactory.DataDB.Vendor == DatabaseVendors.PGSQL)
{
sql = "CREATE TABLE @tbl( id SERIAL PRIMARY KEY, @cols)".Replace("@cols", cols).Replace("@tbl", tableName);
this.EbConnectionFactory.DataDB.CreateTable(sql);
}
else if (this.EbConnectionFactory.DataDB.Vendor == DatabaseVendors.MYSQL)
{
sql = "CREATE TABLE @tbl( id INTEGER AUTO_INCREMENT PRIMARY KEY, @cols)".Replace("@cols", cols).Replace("@tbl", tableName);
this.EbConnectionFactory.DataDB.CreateTable(sql);
}
status = 0;
}
else
{
var colSchema = this.EbConnectionFactory.DataDB.GetColumnSchema(tableName);
string sql = string.Empty;
foreach (TableColumnMeta entry in listNamesAndTypes)
{
bool isFound = false;
foreach (EbDataColumn dr in colSchema)
{
if (entry.Name.ToLower() == (dr.ColumnName.ToLower()))
{
if (entry.Type.EbDbType != dr.Type && !(
(entry.Type.EbDbType.ToString().Equals("Boolean") && dr.Type.ToString().Equals("String")) ||
(entry.Type.EbDbType.ToString().Equals("BooleanOriginal") && dr.Type.ToString().Equals("Boolean")) ||
(entry.Type.EbDbType.ToString().Equals("Decimal") && (dr.Type.ToString().Equals("Int32") || dr.Type.ToString().Equals("Int64"))) ||
(entry.Type.EbDbType.ToString().Equals("Int32") && dr.Type.ToString().Equals("Decimal")) ||
(entry.Type.EbDbType.ToString().Equals("Int16") && dr.Type.ToString().Equals("Int32")) ||
(entry.Type.EbDbType.ToString().Equals("DateTime") && dr.Type.ToString().Equals("Date")) ||
(entry.Type.EbDbType.ToString().Equals("Date") && dr.Type.ToString().Equals("DateTime")) ||
(entry.Type.EbDbType.ToString().Equals("Time") && dr.Type.ToString().Equals("DateTime"))
))
Msg += $"Type mismatch found '{dr.Type}' instead of '{entry.Type.EbDbType}' for {tableName}.{entry.Name}; ";
//Msg += string.Format("Already exists '{0}' Column for {1}.{2}({3}); ", dr.Type.ToString(), tableName, entry.Name, entry.Type.EbDbType);
isFound = true;
break;
}
}
if (!isFound)
{
sql += entry.Name + " " + entry.Type.VDbType.ToString() + " " + (entry.Default.IsNullOrEmpty() ? "" : (" DEFAULT '" + entry.Default + "'")) + ",";
}
}
bool appendId = false;
var existingIdCol = colSchema.FirstOrDefault(o => o.ColumnName.ToLower() == "id");
if (existingIdCol == null)
appendId = true;
if (!sql.IsEmpty() || appendId)
{
if (this.EbConnectionFactory.DataDB.Vendor == DatabaseVendors.ORACLE)/////////////////////////
{
sql = (appendId ? "id NUMBER(10)," : "") + sql;
if (!sql.IsEmpty())
{
sql = "ALTER TABLE @tbl ADD (" + sql.Substring(0, sql.Length - 1) + ")";
sql = sql.Replace("@tbl", tableName);
int _aff = this.EbConnectionFactory.DataDB.UpdateTable(sql);
if (appendId)
CreateSquenceAndTrigger(tableName);
}
}
else if (this.EbConnectionFactory.DataDB.Vendor == DatabaseVendors.PGSQL)
{
sql = (appendId ? "id SERIAL PRIMARY KEY," : "") + sql;
if (!sql.IsEmpty())
{
sql = "ALTER TABLE @tbl ADD COLUMN " + (sql.Substring(0, sql.Length - 1)).Replace(",", ", ADD COLUMN ");
sql = sql.Replace("@tbl", tableName);
this.EbConnectionFactory.DataDB.UpdateTable(sql);
}
}
else if (this.EbConnectionFactory.DataDB.Vendor == DatabaseVendors.MYSQL)
{
sql = (appendId ? "id INTEGER AUTO_INCREMENT PRIMARY KEY," : "") + sql;
if (!sql.IsEmpty())
{
sql = "ALTER TABLE @tbl ADD COLUMN " + (sql.Substring(0, sql.Length - 1)).Replace(",", ", ADD COLUMN ");
sql = sql.Replace("@tbl", tableName);
this.EbConnectionFactory.DataDB.UpdateTable(sql);
}
}
status = 1;
}
}
return status;
//throw new FormException("Table creation failed - Table name: " + tableName);
}
private void CreateSquenceAndTrigger(string tableName)
{
string sqnceSql = "CREATE SEQUENCE @name_sequence".Replace("@name", tableName);
string trgrSql = string.Format(@"CREATE OR REPLACE TRIGGER {0}_on_insert
BEFORE INSERT ON {0}
FOR EACH ROW
BEGIN
SELECT {0}_sequence.nextval INTO :new.id FROM dual;
END;", tableName);
this.EbConnectionFactory.DataDB.CreateTable(sqnceSql);//Sequence Creation
this.EbConnectionFactory.DataDB.CreateTable(trgrSql);//Trigger Creation
}
private void CreateOrUpdateDsAndDv(CreateWebFormTableRequest request, List<TableColumnMeta> listNamesAndTypes)
{
IEnumerable<TableColumnMeta> _list = listNamesAndTypes.Where(x => x.Name != "eb_del" && x.Name != "eb_ver_id" && !(x.Name.Contains("_ebbkup")) && x.Name != "eb_push_id" && x.Name != "eb_src_id" && x.Name != "eb_lock" && x.Name != "eb_signin_log_id" && !(x.Control is EbFileUploader) && x.Name != "eb_approval");
string cols = string.Join(CharConstants.COMMA + "\n \t ", _list.Select(x => x.Name).ToArray());
EbTableVisualization dv = null;
string AutogenId = (request.WebObj as EbWebForm).AutoGeneratedVizRefId;
if (AutogenId.IsNullOrEmpty())
{
var dsid = CreateDataReader(request, cols);
var dvrefid = CreateDataDataVisualization(request, listNamesAndTypes, dsid);
(request.WebObj as EbWebForm).AutoGeneratedVizRefId = dvrefid;
SaveFormObject(request);
}
else
{
dv = EbFormHelper.GetEbObject<EbTableVisualization>(AutogenId, null, Redis, this, this.PooledRedisManager);
UpdateDataReader(request, cols, dv, AutogenId);
UpdateDataVisualization(request, listNamesAndTypes, dv, AutogenId);
}
}
private string CreateDataReader(CreateWebFormTableRequest request, string cols)
{
EbDataReader drObj = new EbDataReader();
drObj.Sql = "SELECT \n \t id,@colname@ FROM @tbl \n WHERE eb_del='F'".Replace("@tbl", request.WebObj.TableName).Replace("@colname@", cols);
drObj.FilterDialogRefId = "";
drObj.Name = request.WebObj.Name + "_AutoGenDR";
drObj.DisplayName = request.WebObj.DisplayName + "_AutoGenDR";
drObj.Description = request.WebObj.Description;
return CreateNewObjectRequest(request, drObj);
}
private string CreateDataDataVisualization(CreateWebFormTableRequest request, List<TableColumnMeta> listNamesAndTypes, string dsid)
{
DVColumnCollection columns = GetDVColumnCollection(listNamesAndTypes, request);
var dvobj = new EbTableVisualization();
dvobj.Name = request.WebObj.Name + "_AutoGenDV";
dvobj.DisplayName = request.WebObj.DisplayName + " List";
dvobj.Description = request.WebObj.Description;
dvobj.DataSourceRefId = dsid;
dvobj.Columns = columns;
dvobj.DSColumns = columns;
dvobj.ColumnsCollection.Add(columns);
dvobj.NotVisibleColumns = columns.FindAll(x => !x.bVisible);
dvobj.AutoGen = true;
dvobj.OrderBy = new List<DVBaseColumn>();
dvobj.RowGroupCollection = new List<RowGroupParent>();
dvobj.OrderBy.Add(columns.Get("eb_created_at"));
SingleLevelRowGroup _rowgroup = new SingleLevelRowGroup();
_rowgroup.DisplayName = "By Location";
_rowgroup.Name = "groupbylocation";
_rowgroup.RowGrouping.Add(columns.Get("eb_loc_id"));
dvobj.RowGroupCollection.Add(_rowgroup);
_rowgroup = new SingleLevelRowGroup();
_rowgroup.DisplayName = "By Created By";
_rowgroup.Name = "groupbycreatedby";
_rowgroup.RowGrouping.Add(columns.Get("eb_created_by"));
dvobj.RowGroupCollection.Add(_rowgroup);
dvobj.BeforeSave(this, Redis);
return CreateNewObjectRequest(request, dvobj);
}
private string CreateNewObjectRequest(CreateWebFormTableRequest request, EbObject dvobj)
{
string _rel_obj_tmp = string.Join(",", dvobj.DiscoverRelatedRefids());
EbObject_Create_New_ObjectRequest ds1 = (new EbObject_Create_New_ObjectRequest
{
Name = dvobj.Name,
Description = dvobj.Description,
Json = EbSerializers.Json_Serialize(dvobj),
Status = ObjectLifeCycleStatus.Live,
IsSave = false,
Tags = "",
Apps = request.Apps,
SolnId = request.SolnId,
WhichConsole = request.WhichConsole,
UserId = request.UserId,
SourceObjId = "0",
SourceVerID = "0",
DisplayName = dvobj.DisplayName,
SourceSolutionId = request.SolnId,
Relations = _rel_obj_tmp
});
var myService = base.ResolveService<EbObjectService>();
var res = myService.Post(ds1);
return res.RefId;
}
private void UpdateDataReader(CreateWebFormTableRequest request, string cols, EbTableVisualization dv, string AutogenId)
{
dv.AfterRedisGet(Redis, this);
EbDataReader drObj = dv.EbDataSource;
drObj.Sql = "SELECT \n \t id,@colname@ FROM @tbl \n WHERE eb_del='F'".Replace("@tbl", request.WebObj.TableName).Replace("@colname@", cols);
drObj.FilterDialogRefId = "";
drObj.Name = request.WebObj.Name + "_AutoGenDR";
drObj.DisplayName = request.WebObj.DisplayName + "_AutoGenDR";
drObj.Description = request.WebObj.Description;
SaveObjectRequest(request, drObj);
}
private void UpdateDataVisualization(CreateWebFormTableRequest request, List<TableColumnMeta> listNamesAndTypes, EbTableVisualization dvobj, string AutogenId)
{
DVColumnCollection columns = UpdateDVColumnCollection(listNamesAndTypes, request, dvobj);
dvobj.Name = request.WebObj.Name + "_AutoGenDV";
dvobj.DisplayName = request.WebObj.DisplayName + " List";
dvobj.Description = request.WebObj.Description;
dvobj.Columns = columns;
dvobj.DSColumns = columns;
dvobj.ColumnsCollection[0] = columns;
dvobj.NotVisibleColumns = columns.FindAll(x => !x.bVisible);
UpdateOrderByObject(ref dvobj);
UpdateRowGroupObject(ref dvobj);
UpdateInfowindowObject(ref dvobj);
//notchecked for formlink, treeview, customcolumn
dvobj.BeforeSave(this, Redis);
SaveObjectRequest(request, dvobj);
}
private void SaveFormObject(CreateWebFormTableRequest request)
{
EbWebForm obj = request.WebObj as EbWebForm;
obj.BeforeSave(this);
SaveObjectRequest(request, obj);
}
private void SaveObjectRequest(CreateWebFormTableRequest request, EbObject obj)
{
string _rel_obj_tmp = string.Join(",", obj.DiscoverRelatedRefids());
EbObject_SaveRequest ds = new EbObject_SaveRequest
{
RefId = obj.RefId,
Name = obj.Name,
Description = obj.Description,
Json = EbSerializers.Json_Serialize(obj),
Relations = _rel_obj_tmp,
Tags = "",
Apps = request.Apps,
DisplayName = obj.DisplayName,
SolnId = request.SolnId
};
var myService = base.ResolveService<EbObjectService>();
EbObject_SaveResponse res = myService.Post(ds);
}
private DVColumnCollection GetDVColumnCollection(List<TableColumnMeta> listNamesAndTypes, CreateWebFormTableRequest request)
{
IVendorDbTypes vDbTypes = this.EbConnectionFactory.DataDB.VendorDbTypes;
var Columns = new DVColumnCollection();
int index = 0;
DVBaseColumn col = new DVNumericColumn { Data = index, Name = "id", sTitle = "id", Type = EbDbTypes.Decimal, bVisible = false, sWidth = "100px", ClassName = "tdheight" };
Columns.Add(col);
foreach (TableColumnMeta column in listNamesAndTypes)
{
if (column.Name != "eb_del" && column.Name != "eb_ver_id" && !(column.Name.Contains("_ebbkup")) && column.Name != "eb_push_id" && column.Name != "eb_src_id" && column.Name != "eb_lock" && column.Name != "eb_signin_log_id" && !(column.Control is EbFileUploader))
{
DVBaseColumn _col = null;
ControlClass _control = null;
bool _autoresolve = false;
Align _align = Align.Auto;
int charlength = 0;
index++;
EbDbTypes _RenderType = column.Type.EbDbType;
if (column.Control is EbPowerSelect)
{
_control = new ControlClass
{
DataSourceId = (column.Control as EbPowerSelect).DataSourceId,
ValueMember = (column.Control as EbPowerSelect).ValueMember
};
if ((column.Control as EbPowerSelect).RenderAsSimpleSelect)
{
_control.DisplayMember.Add((column.Control as EbPowerSelect).DisplayMember);
}
else
{
_control.DisplayMember = (column.Control as EbPowerSelect).DisplayMembers;
}
_autoresolve = true;
_align = Align.Center;
_RenderType = EbDbTypes.String;
}
else if (column.Control is EbTextBox)
{
if ((column.Control as EbTextBox).TextMode == TextMode.MultiLine)
{
charlength = 20;
}
}
else if (column.Name == "eb_void")
{
column.Type = vDbTypes.String;//T or F
_RenderType = EbDbTypes.Boolean;
}
else if (column.Name == "eb_created_by" || column.Name == "eb_lastmodified_by" || column.Name == "eb_loc_id")
{
_RenderType = EbDbTypes.String;
}
if (column.Name == "eb_approval")
{
_col = new DVApprovalColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = EbDbTypes.String,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
RenderType = EbDbTypes.String,
IsCustomColumn = true,
FormRefid = request.WebObj.RefId,
FormDataId = new List<DVBaseColumn> { col }
};
}
else if (_RenderType == EbDbTypes.String)
_col = new DVStringColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = column.Type.EbDbType,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
ColumnQueryMapping = _control,
AutoResolve = _autoresolve,
Align = _align,
AllowedCharacterLength = charlength,
RenderType = _RenderType
};
else if (_RenderType == EbDbTypes.Int16 || _RenderType == EbDbTypes.Int32 || _RenderType == EbDbTypes.Int64 || _RenderType == EbDbTypes.Double || _RenderType == EbDbTypes.Decimal || _RenderType == EbDbTypes.VarNumeric)
_col = new DVNumericColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = column.Type.EbDbType,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
ColumnQueryMapping = _control,
AutoResolve = _autoresolve,
Align = _align,
AllowedCharacterLength = charlength,
RenderType = _RenderType
};
else if (_RenderType == EbDbTypes.Boolean || _RenderType == EbDbTypes.BooleanOriginal)
_col = new DVBooleanColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = column.Type.EbDbType,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
Align = _align,
AllowedCharacterLength = charlength,
RenderType = _RenderType
};
else if (_RenderType == EbDbTypes.DateTime || _RenderType == EbDbTypes.Date || _RenderType == EbDbTypes.Time)
{
_col = new DVDateTimeColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = column.Type.EbDbType,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
Align = _align,
AllowedCharacterLength = charlength,
RenderType = _RenderType
};
if (_RenderType == EbDbTypes.Time)
(_col as DVDateTimeColumn).Format = DateFormat.Time;
else if (_RenderType == EbDbTypes.DateTime)
(_col as DVDateTimeColumn).Format = DateFormat.DateTime;
}
Columns.Add(_col);
}
}
List<DVBaseColumn> _formid = new List<DVBaseColumn>() { col };
Columns.Add(new DVActionColumn
{
Data = (index + 1),//index+1 for serial column in datavis service
Name = "eb_action",
sTitle = "Action",
Type = EbDbTypes.String,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
LinkRefId = request.WebObj.RefId,
LinkType = LinkTypeEnum.Popout,
FormMode = WebFormDVModes.View_Mode,
FormId = _formid,
Align = Align.Center,
IsCustomColumn = true
});
return Columns;
}
private DVColumnCollection UpdateDVColumnCollection(List<TableColumnMeta> listNamesAndTypes, CreateWebFormTableRequest request, EbTableVisualization dv)
{
IVendorDbTypes vDbTypes = this.EbConnectionFactory.DataDB.VendorDbTypes;
var Columns = new DVColumnCollection();
int index = 0;
foreach (TableColumnMeta column in listNamesAndTypes)
{
DVBaseColumn _col = dv.Columns.Find(x => x.Name == column.Name);
if (_col == null && column.Name != "eb_del" && column.Name != "eb_ver_id" && !(column.Name.Contains("_ebbkup")) && column.Name != "eb_push_id" && column.Name != "eb_src_id" && column.Name != "eb_lock" && column.Name != "eb_signin_log_id" && !(column.Control is EbFileUploader))
{
index++;
ControlClass _control = null;
bool _autoresolve = false;
Align _align = Align.Auto;
int charlength = 0;
EbDbTypes _RenderType = column.Type.EbDbType;
if (column.Control is EbPowerSelect)
{
_control = new ControlClass
{
DataSourceId = (column.Control as EbPowerSelect).DataSourceId,
ValueMember = (column.Control as EbPowerSelect).ValueMember
};
if ((column.Control as EbPowerSelect).RenderAsSimpleSelect)
{
_control.DisplayMember.Add((column.Control as EbPowerSelect).DisplayMember);
}
else
{
_control.DisplayMember = (column.Control as EbPowerSelect).DisplayMembers;
}
_autoresolve = true;
_align = Align.Center;
_RenderType = EbDbTypes.String;
}
else if (column.Control is EbTextBox)
{
if ((column.Control as EbTextBox).TextMode == TextMode.MultiLine)
{
charlength = 20;
}
}
if (column.Name == "eb_approval")
{
_col = new DVApprovalColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = EbDbTypes.String,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
RenderType = EbDbTypes.String,
IsCustomColumn = true,
FormRefid = request.WebObj.RefId,
FormDataId = new List<DVBaseColumn> { dv.Columns.Get("id") }
};
}
else if (_RenderType == EbDbTypes.String)
_col = new DVStringColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = column.Type.EbDbType,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
ColumnQueryMapping = _control,
AutoResolve = _autoresolve,
Align = _align,
AllowedCharacterLength = charlength,
RenderType = _RenderType
};
else if (_RenderType == EbDbTypes.Int16 || _RenderType == EbDbTypes.Int32 || _RenderType == EbDbTypes.Int64 || _RenderType == EbDbTypes.Double || _RenderType == EbDbTypes.Decimal || _RenderType == EbDbTypes.VarNumeric)
_col = new DVNumericColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = column.Type.EbDbType,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
ColumnQueryMapping = _control,
AutoResolve = _autoresolve,
Align = _align,
AllowedCharacterLength = charlength,
RenderType = _RenderType
};
else if (_RenderType == EbDbTypes.Boolean || _RenderType == EbDbTypes.BooleanOriginal)
_col = new DVBooleanColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = column.Type.EbDbType,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
Align = _align,
AllowedCharacterLength = charlength,
RenderType = _RenderType
};
else if (_RenderType == EbDbTypes.DateTime || _RenderType == EbDbTypes.Date || _RenderType == EbDbTypes.Time)
{
_col = new DVDateTimeColumn
{
Data = index,
Name = column.Name,
sTitle = column.Label,
Type = column.Type.EbDbType,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
Align = _align,
AllowedCharacterLength = charlength,
RenderType = _RenderType
};
if (_RenderType == EbDbTypes.Time)
(_col as DVDateTimeColumn).Format = DateFormat.Time;
else if (_RenderType == EbDbTypes.DateTime)
(_col as DVDateTimeColumn).Format = DateFormat.DateTime;
}
Columns.Add(_col);
}
else
{
if (_col != null)
{
if (column.Name == "eb_void")
{
column.Type = vDbTypes.String;//T or F
_col.RenderType = EbDbTypes.Boolean;
}
else if (column.Name == "eb_created_by" || column.Name == "eb_lastmodified_by" || column.Name == "eb_loc_id")
{
_col.RenderType = EbDbTypes.String;
}
else
{
if (_col.RenderType == EbDbTypes.Time)
(_col as DVDateTimeColumn).Format = DateFormat.Time;
else if (_col.RenderType == EbDbTypes.DateTime)
(_col as DVDateTimeColumn).Format = DateFormat.DateTime;
_col.RenderType = column.Type.EbDbType;
_col.Type = column.Type.EbDbType;
}
if (column.Control is EbPowerSelect)
{
var _control = new ControlClass
{
DataSourceId = (column.Control as EbPowerSelect).DataSourceId,
ValueMember = (column.Control as EbPowerSelect).ValueMember
};
if ((column.Control as EbPowerSelect).RenderAsSimpleSelect)
{
_control.DisplayMember.Add((column.Control as EbPowerSelect).DisplayMember);
}
else
{
_control.DisplayMember = (column.Control as EbPowerSelect).DisplayMembers;
}
_col.ColumnQueryMapping = _control;
_col.AutoResolve = true;
_col.Align = Align.Center;
_col.RenderType = EbDbTypes.String;
}
else if (column.Control is EbTextBox)
{
if ((column.Control as EbTextBox).TextMode == TextMode.MultiLine)
{
_col.AllowedCharacterLength = 20;
}
}
_col.Data = ++index;
Columns.Add(_col);
}
}
}
Columns.Add(dv.Columns.Get("id"));
DVBaseColumn Col = dv.Columns.Get("eb_action");
DVBaseColumn actcol = null;
if (Col == null || Col is DVStringColumn)
{
actcol = new DVActionColumn
{
Name = "eb_action",
sTitle = "Action",
Type = EbDbTypes.String,
bVisible = true,
sWidth = "100px",
ClassName = "tdheight",
LinkRefId = request.WebObj.RefId,
LinkType = LinkTypeEnum.Popout,
FormMode = WebFormDVModes.View_Mode,
FormId = new List<DVBaseColumn> { dv.Columns.Get("id") },
Align = Align.Center,
IsCustomColumn = true
};
}
else
actcol = Col;