-
Notifications
You must be signed in to change notification settings - Fork 0
/
Default.aspx.vb
3084 lines (2740 loc) · 153 KB
/
Default.aspx.vb
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
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Globalization
Imports System.Drawing
Imports OfficeOpenXml
Imports System.Web.Script.Serialization
Public Class _Default
Inherits System.Web.UI.Page
#Region " Class Variables "
Public sAction, sPostBackArgument, sPostBackArgumentEnding, sInfoDiv1, sFileNametbl, sRawDataVisualization, sBleachingParameters, sNormalization, sCurveFitting, sCurveFittingtbl, sDataForCurveGraph, Guid, sNormType, sDataForCurveFittingDots, sLabelsForCurveFittingDots, sDataForResiduals, sDataForKernelDensityThalf, sLabelsForResiduals, sDeleteSessionButton, sSaveResultsSession As String
Public sCurrentSession As String = ""
Public sBleachingDepthScore As String = "N/A"
Public sGapRatioScore As String = "N/A"
Public sMobileFractionScore As String = "N/A"
Public sThalfScore As String = "N/A"
Public sRsquareScore As String = "N/A"
Public sDataForROI1Graph As String = "[ , ]"
Public sLabelsForROI1Graph As String = "[ , ]"
Public sDataForROI2Graph As String = "[ , ]"
Public sLabelsForROI2Graph As String = "[ , ]"
Public sDataForROI3Graph As String = "[ , ]"
Public sLabelsForROI3Graph As String = "[ , ]"
Public sDataForNormalizationGraph As String = "[ , ]"
Public sLabelsForNormalizationGraph As String = ""
Public sLabelsForStandardDevNormalizationGraph As String = "[ , ]"
Public sDataForStandardDevNormalizationGraph As String = "[ , ]"
Public sBooleanChecker As Boolean = False
Public ROI1DataTable, ROI2DataTable, ROI3DataTable, DoubleNormDataTable, FullScaleDataTable, StandardDevDoubleNormDataTable, StandardDevFullScaleNormDataTable, CurveFitDataTable As DataTable
#End Region
#Region " Page Events "
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SaveFinalDataToExcelbtn.Style.Add("display", "none")
If Not Page.IsPostBack Then
Initialization()
If Not IsNothing(Session("GUID")) Then
Session.Remove("GUID")
End If
Else
sPostBackArgument = Request.Item("__EVENTARGUMENT")
If sPostBackArgument.Contains("_") Then
Dim splitter As String() = sPostBackArgument.Split("_")
sPostBackArgument = splitter(0)
sPostBackArgumentEnding = splitter(1)
End If
Select Case sPostBackArgument
Case "DeleteSession"
DeleteSession()
Initialization()
If Not IsNothing(Session("GUID")) Then
Session.Remove("GUID")
End If
Case "Reset"
DeleteSession()
Initialization()
If Not IsNothing(Session("GUID")) Then
Session.Remove("GUID")
End If
Case "UploadFiles"
HideFileNameTable()
HideRawDataVisualization()
HideBleachingParameters()
HideNormalization()
HideCurveFitting()
HideDeleteSessionButton()
UploadButtonClicked(sPostBackArgumentEnding)
ClearBleachingFieldSetValues()
ClearNormalizationFieldset()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
Case "ExportFinalParameters"
GoToCurveFittingAnchor()
DrawRawDataGraphs()
EstimateBleachingDepthAndGapRatio()
DrawNormalizationGraphs()
ExportFinalData()
ClearCurveFittingFieldset()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
'ScriptManager.RegisterStartupScript(Me, Page.GetType, "ShowMessageForNewWorker", "ShowMessageForNewWorker();", True)
Case "ClearNormalize"
GoToNormalizationAnchor()
ClearNormalizationFieldset()
EstimateBleachingDepthAndGapRatio()
DrawRawDataGraphs()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
Case "ClearCurve"
GoToCurveFittingAnchor()
ClearCurveFittingFieldset()
EstimateBleachingDepthAndGapRatio()
DrawRawDataGraphs()
DrawNormalizationGraphs()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
Case "BleachingParametersReset"
GoToBD_GRAnchor()
ResetBD_GP_Parameters()
RestoreInitialValues()
DrawRawDataGraphs()
ClearNormalizationFieldset()
ClearCurveFittingFieldset()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Select
End If
'''TODELETE WITH SESSION DIV
'If Not IsNothing(Session("GUID")) Then
' sCurrentSession = "There's an active session with ID: " + Session("GUID").ToString
'Else
' sCurrentSession = "No active session found."
'End If
End Sub
Protected Sub ExportRoiDatabtn_Click(ByVal sender As Object, ByVal e As EventArgs)
ExportROIData()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Sub
Protected Sub SaveFinalDataToExcelFilebtn_Click(ByVal sender As Object, ByVal e As EventArgs)
SaveToExcel()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Sub
Protected Sub ExportNormDatabtn_Click(ByVal sender As Object, ByVal e As EventArgs)
ExportNormData()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Sub
Protected Sub RemoveAllbtn_Click(ByVal sender As Object, ByVal e As EventArgs)
RemoveAll()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Sub
Protected Sub RestoreAllbtn_Click(ByVal sender As Object, ByVal e As EventArgs)
RestoreAll()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Sub
Protected Sub Normalizebtn_Click(ByVal sender As Object, ByVal e As EventArgs)
If NormalizationRadioButtonList.SelectedValue = "Double" Then
RestoreInitialValues()
DiscardInitialValues(DiscardValuestxtbox.Text.ToString)
EstimateBleachingDepthAndGapRatio()
DrawRawDataGraphs()
DrawNormalizationGraphs(sPostBackArgumentEnding)
ClearCurveFittingFieldset()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
ElseIf NormalizationRadioButtonList.SelectedValue = "FullScale" Then
RestoreInitialValues()
DiscardInitialValues(DiscardValuestxtbox.Text.ToString)
EstimateBleachingDepthAndGapRatio()
DrawRawDataGraphs()
DrawNormalizationGraphs(sPostBackArgumentEnding)
ClearCurveFittingFieldset()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End If
End Sub
Protected Sub BleachingParametersCompute_Click(ByVal sender As Object, ByVal e As EventArgs)
RestoreInitialValues()
DiscardInitialValues(DiscardValuestxtbox.Text.ToString)
EstimateBleachingDepthAndGapRatio("BleachingParametersCompute_Click")
DrawRawDataGraphs()
DrawNormalizationGraphs()
ClearCurveFittingFieldset()
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Sub
Protected Sub grdFiles_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles grdFiles.RowDataBound
If (e.Row.Cells.Item(4).Text.ToString = "Enabled") Then
e.Row.Cells.Item(4).ForeColor = Color.Green
Dim linkbutton As LinkButton
linkbutton = e.Row.Controls(0).Controls(0)
linkbutton.Text = "Remove"
ElseIf (e.Row.Cells.Item(4).Text.ToString = "Disabled") Then
e.Row.Cells.Item(4).ForeColor = Color.Red
Dim linkbutton As LinkButton
linkbutton = e.Row.Controls(0).Controls(0)
linkbutton.Text = "Restore"
End If
End Sub
Protected Sub grdFiles_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles grdFiles.SelectedIndexChanged
Dim index As Integer = grdFiles.SelectedIndex
UpdateFileNameTable(grdFiles.DataKeys(index).Value.ToString())
FillFileNameTable(grdFiles.DataKeys(index).Value.ToString())
FillCurveFittingTableAndExpFinalDataTable(grdFiles.DataKeys(index).Value.ToString())
DrawRawDataGraphs()
ShowBleachingParameters()
ShowInfoMessage(grdFiles.DataKeys(index).Value.ToString())
For Each li As ListItem In NormalizationRadioButtonList.Items
If li.Value = "Double" And li.Selected = True Then
DrawNormalizationGraphs("Double")
ElseIf li.Value = "FullScale" And li.Selected = True Then
DrawNormalizationGraphs("FullScale")
End If
Next
If (PreBleachValuestxtbox.Text <> "" And BleachValuestxtbox.Text <> "" And PostBleachValuestxtbox.Text <> "") Then
EstimateBleachingDepthAndGapRatio()
Else
ClearBleachingFieldSetValues()
End If
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Sub
Protected Sub grdFitCurve_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles grdFitCurve.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
e.Row.Cells(0).Attributes.Add("onclick", "return DoActions('FitCurve');")
End If
End Sub
Protected Sub grdFitCurve_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles grdFitCurve.SelectedIndexChanged
Dim index As Integer = grdFitCurve.SelectedIndex
RestoreInitialValues()
DiscardInitialValues(DiscardValuestxtbox.Text.ToString)
EstimateBleachingDepthAndGapRatio()
DrawRawDataGraphs()
DrawNormalizationGraphs()
EstimateMobFractionThalfRsquareDrawCurves("FitSelectedCurve_Click", grdFiles.DataKeys(index).Value.ToString())
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Sub
Protected Sub FitAllCurve_Click(ByVal sender As Object, ByVal e As EventArgs)
RestoreInitialValues()
DiscardInitialValues(DiscardValuestxtbox.Text.ToString)
EstimateBleachingDepthAndGapRatio()
DrawRawDataGraphs()
DrawNormalizationGraphs()
EstimateMobFractionThalfRsquareDrawCurves("FitAllCurve_Click")
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designRawGraphs", "designRawGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designNormGraphs", "designNormGraphs();", True)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "designCurveFittingGraphs", "designCurveFittingGraphs();", True)
End Sub
Protected Sub RemoveAll()
UpdateAllFileNameTable("Remove")
FillFileNameTable()
FillCurveFittingTableAndExpFinalDataTable()
DrawRawDataGraphs()
ShowBleachingParameters()
ShowInfoMessage("Remove")
If (PreBleachValuestxtbox.Text <> "" And BleachValuestxtbox.Text <> "" And PostBleachValuestxtbox.Text <> "") Then
EstimateBleachingDepthAndGapRatio()
Else
ClearBleachingFieldSetValues()
End If
For Each li As ListItem In NormalizationRadioButtonList.Items
If li.Value = "Double" And li.Selected = True Then
DrawNormalizationGraphs("Double")
ElseIf li.Value = "FullScale" And li.Selected = True Then
DrawNormalizationGraphs("FullScale")
End If
Next
End Sub
Private Sub RestoreAll()
UpdateAllFileNameTable("Restore")
FillFileNameTable()
FillCurveFittingTableAndExpFinalDataTable()
DrawRawDataGraphs()
ShowBleachingParameters()
ShowInfoMessage("Restore")
For Each li As ListItem In NormalizationRadioButtonList.Items
If li.Value = "Double" And li.Selected = True Then
DrawNormalizationGraphs("Double")
ElseIf li.Value = "FullScale" And li.Selected = True Then
DrawNormalizationGraphs("FullScale")
End If
Next
If (PreBleachValuestxtbox.Text <> "" And BleachValuestxtbox.Text <> "" And PostBleachValuestxtbox.Text <> "") Then
EstimateBleachingDepthAndGapRatio()
Else
ClearBleachingFieldSetValues()
End If
End Sub
Private Sub UploadButtonClicked(ByVal columnOrder As String)
Dim checkOK As Boolean = False
Dim fileExtension As String = ""
Dim fileNameArray As String() = New String(0) {}
Dim successtext = String.Empty
If Not IsNothing(Session("GUID")) Then
Session.Remove("GUID")
End If
fileNameArray = New String(FileUpload1.PostedFiles.Count - 1) {}
''CHECK IF ALL FILES HAVE THE SAME EXTENSION (FILETYPE)
Dim counter As Integer = 0
For Each postedFile As HttpPostedFile In FileUpload1.PostedFiles
fileNameArray(counter) = Path.GetFileName(postedFile.FileName)
counter += 1
If counter > 100 Then
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowErrorMessage('You are trying to upload more than 100 files that is not allowed in this version of easyFRAP. For batch-file mode please try the standalone version.');", True)
Return
End If
fileExtension = Path.GetExtension(postedFile.FileName)
If fileExtension <> FileExtensionList1.SelectedValue Then
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowErrorMessage('Invalid file type detected. All files should have the declared extention. Please try uploading the proper files.');", True)
Return
End If
If counter > 100 Then
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowErrorMessage('You have exceeded the limit of 100 files per dataset. Please try uploading less files.');", True)
Return
End If
Next
checkOK = InsertIntoDB(fileExtension, columnOrder)
If checkOK = True Then
checkOK = CheckRowsOfFiles(Session("GUID"))
Else
Return
End If
If checkOK = True Then
FillFileNameTable()
FillCurveFittingTableAndExpFinalDataTable()
If FileUpload1.PostedFiles.Count = 1 Then
successtext = String.Format("Well done! {0} file has been successfully uploaded.", FileUpload1.PostedFiles.Count)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowSuccessMessage('" + successtext + "');", True)
Else
successtext = String.Format("Well done! {0} files have been successfully uploaded.", FileUpload1.PostedFiles.Count)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowSuccessMessage('" + successtext + "');", True)
End If
DrawRawDataGraphs()
ShowSections()
Else
Return
End If
End Sub
#End Region
#Region " Private Functions "
Private Sub ResetButtonClicked()
ExpName.Text = ""
FileExtensionList1.SelectedIndex = 0
If Not IsNothing(Session("GUID")) Then
Session.Remove("GUID")
End If
End Sub
Private Sub FillFileNameTable(Optional ByVal RowFileID As String = "")
Dim sSQL As String
Dim dtData As DataTable
Dim dbHandler As New DALDBHandler
Dim RowFilesGuid As String = Session("GUID")
If (RowFileID <> "") Then
RowFilesGuid = GetRowFilesGuid(RowFileID)
Session("GUID") = RowFilesGuid 'Refresh Session
End If
sSQL = "Select RF_ID, RF_FileName,
case when RF_IsEnabled = 1 then 'Enabled'
else 'Disabled'
end as RF_IsEnabled,
count([vw_Raw_Data].RD_ID) as RD_RowCounter
from [dbo].[vw_Imported_Files]
inner join [dbo].[vw_Raw_Data]
ON [vw_Imported_Files].RF_ID = [vw_Raw_Data].RD_RF_ID
where [vw_Imported_Files].RF_GUID_ID = " & RowFilesGuid & "
GROUP BY RF_FileName, RF_IsEnabled, RF_ID
order by RF_ID "
dtData = dbHandler.FillTable("", sSQL)
If IsNothing(dtData) Then
Exit Sub
End If
grdFiles.DataSource = dtData
grdFiles.DataBind()
ShowFileNameTable()
End Sub
Private Sub FillCurveFittingTableAndExpFinalDataTable(Optional ByVal RowFileID As String = "")
Dim sSQL As String
Dim dtData As DataTable
Dim dbHandler As New DALDBHandler
Dim RowFilesGuid As String = Session("GUID")
If (RowFileID <> "") Then
RowFilesGuid = GetRowFilesGuid(RowFileID)
Session("GUID") = RowFilesGuid 'Refresh Session
End If
sSQL = "Select RF_ID, RF_FileName
from [dbo].[vw_Imported_Files]
where [vw_Imported_Files].RF_GUID_ID = " & RowFilesGuid & "
and RF_IsEnabled = 1
order by RF_ID "
dtData = dbHandler.FillTable("", sSQL)
If IsNothing(dtData) Then
Exit Sub
End If
If dtData.Rows.Count = 0 Then
''Create datatable and columns
Dim dtable As New DataTable
dtable.Columns.Add(New DataColumn("RF_ID"))
dtable.Columns.Add(New DataColumn("RF_FileName"))
'Create object for RowValues
Dim RowValues As Object() = {"", "There is no file to select."}
'create new data row
Dim dRow As DataRow
dRow = dtable.Rows.Add(RowValues)
dtable.AcceptChanges()
'Now bind datatable to gridview...
grdFitCurve.DataSource = dtable
grdFitCurve.DataBind()
grdFitCurve.Columns(0).Visible = False
grdFitCurve.Columns(2).ItemStyle.ForeColor = Color.Red
'
grdExportFinalData.DataSource = dtable
grdExportFinalData.DataBind()
'grdExportFinalData.Columns(0).Visible = False
'grdExportFinalData.Columns(2).ItemStyle.ForeColor = Color.Red
Else
grdFitCurve.DataSource = dtData
grdFitCurve.DataBind()
grdFitCurve.Columns(0).Visible = True
grdFitCurve.Columns(2).ItemStyle.ForeColor = ColorTranslator.FromHtml("#717171")
'
grdExportFinalData.DataSource = dtData
grdExportFinalData.DataBind()
'grdExportFinalData.Columns(0).Visible = True
'grdExportFinalData.Columns(2).ItemStyle.ForeColor = ColorTranslator.FromHtml("#717171")
End If
End Sub
Private Function InsertIntoDB(ByVal filetype As String, ByVal fourcolumnorder As String) As Boolean
Dim sep As String = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator
Dim NewFileID As String = String.Empty
Dim filename As String = String.Empty
Dim FirstColumnName As String = String.Empty
Dim SecondColumnName As String = String.Empty
Dim ThirdColumnName As String = String.Empty
Dim FourthColumnName As String = String.Empty
'Dim xlApp As Excel.Application
'Dim xlWorkBook As Excel.Workbook
'Dim xlWorkSheet As Excel.Worksheet
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn(8) {New DataColumn("RD_ID", GetType(Integer)), New DataColumn("RD_GUID_ID", GetType(Integer)), New DataColumn("RD_RF_ID", GetType(Integer)), New DataColumn("RD_Axis", GetType(String)), New DataColumn("RD_ROI1", GetType(String)), New DataColumn("RD_ROI2", GetType(String)), New DataColumn("RD_ROI3", GetType(String)), New DataColumn("RD_DTInserted", GetType(DateTime)), New DataColumn("RD_IsEnabled", GetType(Integer))})
Guid = GenerateGUID()
Session("GUID") = Guid
''INSERT RAW DATA INTO DB BY READING ONE FILE PER TIME
Try
Dim hfc As HttpFileCollection = Request.Files
For j As Integer = 0 To hfc.Count - 1
Dim hpf As HttpPostedFile = hfc(j)
'get the file name
filename = Path.GetFileName(hpf.FileName)
'Generate New File ID - concerns Row_File table
NewFileID = CreateNewFileID(Guid, filename)
If NewFileID = 0 Then
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowErrorMessage('Something went wrong while uploading your data. Please try again. - (ErrorCode003)');", True)
Return False
End If
Select Case filetype
Case ".csv"
Dim str As String = New StreamReader(hpf.InputStream).ReadToEnd()
For Each row As String In str.Split(ControlChars.Lf)
If Not (row.Contains("Channel") Or row.Contains("ROI")) Then
If Not String.IsNullOrEmpty(row) Then
dt.Rows.Add()
dt.Rows(dt.Rows.Count - 1)(1) = Convert.ToInt32(Guid)
dt.Rows(dt.Rows.Count - 1)(2) = Convert.ToInt32(NewFileID)
Dim i As Integer = 3
For Each cell As String In row.Split(","c)
dt.Rows(dt.Rows.Count - 1)(i) = GetDoubleNullable(cell)
i += 1
Next
dt.Rows(dt.Rows.Count - 1)(7) = DateTime.Now
dt.Rows(dt.Rows.Count - 1)(8) = 1
End If
End If
Next
Case ".txt"
Dim str As String = New StreamReader(hpf.InputStream).ReadToEnd()
For Each row As String In str.Split(ControlChars.Lf)
If Not (row.Contains("Time") Or row.Contains("Region") Or row.Contains("Intensity")) Then
If Not String.IsNullOrEmpty(row) Then
dt.Rows.Add()
dt.Rows(dt.Rows.Count - 1)(1) = Convert.ToInt32(Guid)
dt.Rows(dt.Rows.Count - 1)(2) = Convert.ToInt32(NewFileID)
Dim i As Integer = 3
For Each cell As String In row.Split(ControlChars.Tab)
dt.Rows(dt.Rows.Count - 1)(i) = GetDoubleNullable(cell)
i += 1
Next
dt.Rows(dt.Rows.Count - 1)(7) = DateTime.Now
dt.Rows(dt.Rows.Count - 1)(8) = 1
End If
End If
Next
Case ".xlsx"
Using excel = New ExcelPackage(hpf.InputStream)
Dim ws = excel.Workbook.Worksheets.First()
For rowNum = 1 To ws.Dimension.End.Row
Dim wsRow = ws.Cells(rowNum, 1, rowNum, ws.Dimension.End.Column)
For Each cell In wsRow
If Not IsNumeric(cell.Value) Then
GoTo SkipRow
End If
Next
Dim row As DataRow = dt.Rows.Add()
dt.Rows(dt.Rows.Count - 1)(1) = Convert.ToInt32(Guid)
dt.Rows(dt.Rows.Count - 1)(2) = Convert.ToInt32(NewFileID)
Dim i As Integer = 3
For Each cell In wsRow
dt.Rows(dt.Rows.Count - 1)(i) = GetDoubleNullable(cell.Value)
i += 1
Next
dt.Rows(dt.Rows.Count - 1)(7) = DateTime.Now
dt.Rows(dt.Rows.Count - 1)(8) = 1
SkipRow: Next
End Using
Case ".xls"
Dim wb As Net.SourceForge.Koogra.Excel.Workbook = New Net.SourceForge.Koogra.Excel.Workbook(hpf.InputStream)
Dim ws As Net.SourceForge.Koogra.Excel.Worksheet = wb.Sheets(0)
ws = wb.Sheets.First()
Dim rowNum = ws.Rows.MinRow
For rowNum = 0 To ws.Rows.MaxRow
Dim row As Net.SourceForge.Koogra.Excel.Row = ws.Rows(rowNum)
Dim colNum = row.Cells.MinCol
If Not IsNumeric(row.Cells(colNum).Value) Then
GoTo SkipRow2
End If
Dim row2 As DataRow = dt.Rows.Add()
dt.Rows(dt.Rows.Count - 1)(1) = Convert.ToInt32(Guid)
dt.Rows(dt.Rows.Count - 1)(2) = Convert.ToInt32(NewFileID)
Dim i As Integer = 3
For colNum = 0 To row.Cells.MaxCol
'Console.WriteLine(row.Cells(colNum).Value)
dt.Rows(dt.Rows.Count - 1)(i) = GetDoubleNullable(row.Cells(colNum).Value)
i += 1
Next
dt.Rows(dt.Rows.Count - 1)(7) = DateTime.Now
dt.Rows(dt.Rows.Count - 1)(8) = 1
SkipRow2: Next
End Select
Dim consString As String = ConfigurationManager.ConnectionStrings("sConnectionStringName").ConnectionString
Using con As New SqlConnection(consString)
Using sqlBulkCopy As New SqlBulkCopy(con)
'Set the database table name
sqlBulkCopy.DestinationTableName = "dbo.Raw_Data"
sqlBulkCopy.BulkCopyTimeout = 3500
Select Case fourcolumnorder
Case "1234"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(3, 3)
sqlBulkCopy.ColumnMappings.Add(4, 4)
sqlBulkCopy.ColumnMappings.Add(5, 5)
sqlBulkCopy.ColumnMappings.Add(6, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "1243"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(3, 3)
sqlBulkCopy.ColumnMappings.Add(4, 4)
sqlBulkCopy.ColumnMappings.Add(6, 5)
sqlBulkCopy.ColumnMappings.Add(5, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "1324"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(3, 3)
sqlBulkCopy.ColumnMappings.Add(5, 4)
sqlBulkCopy.ColumnMappings.Add(4, 5)
sqlBulkCopy.ColumnMappings.Add(6, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "1342"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(3, 3)
sqlBulkCopy.ColumnMappings.Add(5, 4)
sqlBulkCopy.ColumnMappings.Add(6, 5)
sqlBulkCopy.ColumnMappings.Add(4, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "1423"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(3, 3)
sqlBulkCopy.ColumnMappings.Add(6, 4)
sqlBulkCopy.ColumnMappings.Add(4, 5)
sqlBulkCopy.ColumnMappings.Add(5, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "1432"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(3, 3)
sqlBulkCopy.ColumnMappings.Add(6, 4)
sqlBulkCopy.ColumnMappings.Add(5, 5)
sqlBulkCopy.ColumnMappings.Add(4, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "2134"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(4, 3)
sqlBulkCopy.ColumnMappings.Add(3, 4)
sqlBulkCopy.ColumnMappings.Add(5, 5)
sqlBulkCopy.ColumnMappings.Add(6, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "2143"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(4, 3)
sqlBulkCopy.ColumnMappings.Add(3, 4)
sqlBulkCopy.ColumnMappings.Add(6, 5)
sqlBulkCopy.ColumnMappings.Add(5, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "2314"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(4, 3)
sqlBulkCopy.ColumnMappings.Add(5, 4)
sqlBulkCopy.ColumnMappings.Add(3, 5)
sqlBulkCopy.ColumnMappings.Add(6, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "2341"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(4, 3)
sqlBulkCopy.ColumnMappings.Add(5, 4)
sqlBulkCopy.ColumnMappings.Add(6, 5)
sqlBulkCopy.ColumnMappings.Add(3, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "2431"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(4, 3)
sqlBulkCopy.ColumnMappings.Add(6, 4)
sqlBulkCopy.ColumnMappings.Add(5, 5)
sqlBulkCopy.ColumnMappings.Add(3, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "2413"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(4, 3)
sqlBulkCopy.ColumnMappings.Add(6, 4)
sqlBulkCopy.ColumnMappings.Add(3, 5)
sqlBulkCopy.ColumnMappings.Add(5, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "3124"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(5, 3)
sqlBulkCopy.ColumnMappings.Add(3, 4)
sqlBulkCopy.ColumnMappings.Add(4, 5)
sqlBulkCopy.ColumnMappings.Add(6, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "3142"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(5, 3)
sqlBulkCopy.ColumnMappings.Add(3, 4)
sqlBulkCopy.ColumnMappings.Add(6, 5)
sqlBulkCopy.ColumnMappings.Add(4, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "3214"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(5, 3)
sqlBulkCopy.ColumnMappings.Add(4, 4)
sqlBulkCopy.ColumnMappings.Add(3, 5)
sqlBulkCopy.ColumnMappings.Add(6, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "3241"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(5, 3)
sqlBulkCopy.ColumnMappings.Add(4, 4)
sqlBulkCopy.ColumnMappings.Add(6, 5)
sqlBulkCopy.ColumnMappings.Add(3, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "3412"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(5, 3)
sqlBulkCopy.ColumnMappings.Add(6, 4)
sqlBulkCopy.ColumnMappings.Add(3, 5)
sqlBulkCopy.ColumnMappings.Add(4, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "3421"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(5, 3)
sqlBulkCopy.ColumnMappings.Add(6, 4)
sqlBulkCopy.ColumnMappings.Add(4, 5)
sqlBulkCopy.ColumnMappings.Add(3, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "4123"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(6, 3)
sqlBulkCopy.ColumnMappings.Add(3, 4)
sqlBulkCopy.ColumnMappings.Add(4, 5)
sqlBulkCopy.ColumnMappings.Add(5, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "4132"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(6, 3)
sqlBulkCopy.ColumnMappings.Add(3, 4)
sqlBulkCopy.ColumnMappings.Add(5, 5)
sqlBulkCopy.ColumnMappings.Add(4, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "4213"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(6, 3)
sqlBulkCopy.ColumnMappings.Add(4, 4)
sqlBulkCopy.ColumnMappings.Add(3, 5)
sqlBulkCopy.ColumnMappings.Add(5, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "4231"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(6, 3)
sqlBulkCopy.ColumnMappings.Add(4, 4)
sqlBulkCopy.ColumnMappings.Add(5, 5)
sqlBulkCopy.ColumnMappings.Add(3, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "4312"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(6, 3)
sqlBulkCopy.ColumnMappings.Add(5, 4)
sqlBulkCopy.ColumnMappings.Add(3, 5)
sqlBulkCopy.ColumnMappings.Add(4, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
Case "4321"
sqlBulkCopy.ColumnMappings.Add(0, 0)
sqlBulkCopy.ColumnMappings.Add(1, 1)
sqlBulkCopy.ColumnMappings.Add(2, 2)
sqlBulkCopy.ColumnMappings.Add(6, 3)
sqlBulkCopy.ColumnMappings.Add(5, 4)
sqlBulkCopy.ColumnMappings.Add(4, 5)
sqlBulkCopy.ColumnMappings.Add(3, 6)
sqlBulkCopy.ColumnMappings.Add(7, 7)
sqlBulkCopy.ColumnMappings.Add(8, 8)
End Select
con.Open()
sqlBulkCopy.WriteToServer(dt)
con.Close()
End Using
End Using
dt.Clear()
Next
Return True
Catch ex As Exception
LogToFile("InsertIntoDB()", ex.Message)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowErrorMessage('Something went wrong while uploading your data. Please check your files. They probably contain either more than 4 colums or more than 3 delimiters in certain lines. Please try again. - (ErrorCode001)');", True)
Return False
End Try
Return False
End Function
Public Shared Function GetDoubleNullable(ByVal doublestring As String) As Double
Dim retval As Double
Dim sep As String = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator
If Double.TryParse(Replace(Replace(doublestring, ".", sep), ",", sep), retval) Then
Return retval
Else
Return Nothing
End If
End Function
Private Function GenerateGUID() As String
Dim textGUID As String = String.Empty
Dim ExperimentName As String = String.Empty
Dim query As String = String.Empty
query &= "INSERT INTO [dbo].[GUID] ([GUID_Text], [GUID_ExperimentName], [GUID_DTCreated]) OUTPUT INSERTED.GUID_ID "
query &= "VALUES (@GUID_Text, @GUID_ExperimentName, @GUID_DTCreated) "
textGUID = System.Guid.NewGuid.ToString()
ExperimentName = ExpName.Text
Try
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("sConnectionStringName").ConnectionString)
Using comm As New SqlCommand()
With comm
.Connection = conn
.CommandType = CommandType.Text
.CommandText = query
.Parameters.AddWithValue("@GUID_Text", textGUID)
.Parameters.AddWithValue("@GUID_ExperimentName", ExperimentName)
.Parameters.AddWithValue("@GUID_DTCreated", DateTime.Now)
End With
conn.Open()
Guid = comm.ExecuteScalar()
End Using
End Using
Catch ex As Exception
LogToFile("GenerateGUID() - " + query, ex.Message)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowErrorMessage('Something went wrong while uploading your data. Please try again. - (ErrorCode002)');", True)
Return Nothing
End Try
Return Guid
End Function
Private Function CreateNewFileID(ByVal guid As String, ByVal filename As String) As String
Dim FileID As String = String.Empty
Dim query As String = String.Empty
query &= "INSERT INTO [dbo].[Imported_Files] ([RF_GUID_ID], [RF_FileName], [RF_DTCreated], [RF_IsEnabled]) OUTPUT INSERTED.RF_ID "
query &= "VALUES (@RF_GUID_ID, @RF_FileName, @RF_DTCreated, @RF_IsEnabled) "
Try
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("sConnectionStringName").ConnectionString)
Using comm As New SqlCommand()
With comm
.Connection = conn
.CommandType = CommandType.Text
.CommandText = query
.Parameters.AddWithValue("@RF_GUID_ID", guid)
.Parameters.AddWithValue("@RF_FileName", filename)
.Parameters.AddWithValue("@RF_DTCreated", DateTime.Now)
.Parameters.AddWithValue("@RF_IsEnabled", 1)
End With
conn.Open()
FileID = comm.ExecuteScalar()
End Using
End Using
Catch ex As Exception
LogToFile("CreateNewFileID() " + query, ex.Message)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowErrorMessage('Something went wrong while uploading your data. Please try again. - (ErrorCode011)');", True)
FileID = "0"
End Try
Return FileID
End Function
Private Sub UpdateFileNameTable(ByVal RowFileID As String)
Dim query As String = String.Empty
Dim ExecID As String = String.Empty
Dim Param As String = String.Empty
Param = CheckIfActiveOrInactive(RowFileID)
Select Case Param
Case "True"
Param = "0"
Case "False"
Param = "1"
End Select
query &= "UPDATE [dbo].[Imported_Files] Set RF_IsEnabled = @RF_IsEnabled WHERE RF_ID = @RF_ID"
Try
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("sConnectionStringName").ConnectionString)
Using comm As New SqlCommand()
With comm
.Connection = conn
.CommandType = CommandType.Text
.CommandText = query
.Parameters.AddWithValue("@RF_IsEnabled", Param)
.Parameters.AddWithValue("@RF_ID", RowFileID)
End With
conn.Open()
comm.ExecuteScalar()
End Using
End Using
Catch ex As Exception
LogToFile("UpdateFileNameTable() " + query, ex.Message)
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowErrorMessage('Something went wrong while processing your data. Please try again. - (ErrorCode004)');", True)
End Try
End Sub
Private Sub UpdateAllFileNameTable(ByVal sCommand As String)
Dim query As String = String.Empty
Dim ExecID As String = String.Empty
Dim Param As String = String.Empty
Dim nGuid As String = String.Empty
If IsNothing(Session("GUID")) Then
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "ShowErrorMessage('Your session has expired. Please restart your analysis by uploading your files again.');", True)
Initialization()
Return
Else
nGuid = Session("GUID").ToString
End If
If sCommand = "Remove" Then
Param = 0
ElseIf sCommand = "Restore" Then
Param = 1
End If
query &= "UPDATE [dbo].[Imported_Files] Set RF_IsEnabled = @RF_IsEnabled WHERE RF_GUID_ID = @RF_GUID_ID"
Try
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("sConnectionStringName").ConnectionString)
Using comm As New SqlCommand()
With comm
.Connection = conn
.CommandType = CommandType.Text
.CommandText = query
.Parameters.AddWithValue("@RF_IsEnabled", Param)
.Parameters.AddWithValue("@RF_GUID_ID", nGuid)
End With
conn.Open()
comm.ExecuteScalar()
End Using
End Using
Catch ex As Exception
LogToFile("UpdateAllFileNameTable() " + query, ex.Message)