From 949f78f6d000a67e51c1cfc39378a76b7b605815 Mon Sep 17 00:00:00 2001 From: Suriyakumarvijayanayagam Date: Fri, 25 Sep 2026 16:21:08 +0530 Subject: [PATCH] Initial import: Axpert 11.2 reference material and platform blueprint - TECH_ARCHITECTURE.md: technical blueprint for the new platform - AI_LAYER_DESIGN_NOTES.md: AI agent, event/action, SQL and audit design - Axpert 11.2 web runtime source, structure exports and release notes (reference) Co-Authored-By: Claude Opus 5.5 --- .gitignore | 2 + AI_LAYER_DESIGN_NOTES.md | 219 + AW_11.2.0.0_release1/App_Code/Constants.cs | 269 + AW_11.2.0.0_release1/App_Code/DBContext.cs | 1026 ++ AW_11.2.0.0_release1/App_Code/TStructData.cs | 8187 +++++++++ AW_11.2.0.0_release1/App_Code/TStructDef.cs | 13158 +++++++++++++++ AW_11.2.0.0_release1/App_Code/WebService.cs | 7132 ++++++++ AW_11.2.0.0_release1/Js/AxInterface.js | 861 + AW_11.2.0.0_release1/Js/axpertUI.js | 2793 +++ AW_11.2.0.0_release1/Js/axpertUI.min.js | 1 + AW_11.2.0.0_release1/Js/common.js | 1660 ++ AW_11.2.0.0_release1/Js/common.min.js | 1 + AW_11.2.0.0_release1/Js/expressions_config.js | 470 + .../Js/expressions_config.min.js | 1 + AW_11.2.0.0_release1/Js/iview.js | 10185 +++++++++++ AW_11.2.0.0_release1/Js/iview.min.js | 1 + AW_11.2.0.0_release1/Js/jsclient.js | 3377 ++++ AW_11.2.0.0_release1/Js/jsclient.min.js | 1 + AW_11.2.0.0_release1/Js/login.js | 1260 ++ AW_11.2.0.0_release1/Js/login.min.js | 1 + AW_11.2.0.0_release1/Js/main-tstruct.js | 8511 ++++++++++ AW_11.2.0.0_release1/Js/main-tstruct.min.js | 1 + AW_11.2.0.0_release1/Js/main.js | 5233 ++++++ AW_11.2.0.0_release1/Js/main.min.js | 1 + AW_11.2.0.0_release1/Js/process.js | 6113 +++++++ AW_11.2.0.0_release1/Js/process.min.js | 1 + AW_11.2.0.0_release1/Js/smartViews.js | 9713 +++++++++++ AW_11.2.0.0_release1/Js/smartViews.min.js | 1 + AW_11.2.0.0_release1/Js/tstruct.js | 13995 ++++++++++++++++ AW_11.2.0.0_release1/Js/tstruct.min.js | 1 + .../UI/axpertUI/datatables.bundle.js.map | 1 + .../UI/axpertUI/style.bundle.css | 2 + .../UI/axpertUI/style.bundle.css.map | 1 + .../UI/axpertUI/style.bundle.rtl.css | 2 + .../UI/axpertUI/style.bundle.rtl.css.map | 1 + .../compiler/src/sass/components/_extras.scss | 47 + .../src/sass/components/helpers/_text.scss | 175 + AW_11.2.0.0_release1/aspx/AboutUs.aspx | 117 + .../aspx/AddEditResponsibility.aspx | 137 + AW_11.2.0.0_release1/aspx/AppDownload.aspx | 174 + AW_11.2.0.0_release1/aspx/AppSettings.aspx | 152 + AW_11.2.0.0_release1/aspx/AutoComplete.aspx | 204 + AW_11.2.0.0_release1/aspx/AxMPage.master | 180 + AW_11.2.0.0_release1/aspx/AxManager.aspx | 111 + AW_11.2.0.0_release1/aspx/AxpertLogs.aspx | 83 + AW_11.2.0.0_release1/aspx/Comments.aspx | 107 + AW_11.2.0.0_release1/aspx/Complaint.aspx | 75 + AW_11.2.0.0_release1/aspx/Config.aspx | 918 + AW_11.2.0.0_release1/aspx/Configuration.aspx | 1242 ++ AW_11.2.0.0_release1/aspx/Drafts.aspx | 73 + AW_11.2.0.0_release1/aspx/ExportNew.aspx | 819 + .../aspx/FastDataUtility.aspx | 308 + AW_11.2.0.0_release1/aspx/Forgotpassword.aspx | 217 + AW_11.2.0.0_release1/aspx/HomeBuilder.aspx | 614 + AW_11.2.0.0_release1/aspx/HomePage.aspx | 101 + AW_11.2.0.0_release1/aspx/ImageUpload.aspx | 85 + AW_11.2.0.0_release1/aspx/ImportNew.aspx | 760 + AW_11.2.0.0_release1/aspx/Mainnew.aspx | 874 + AW_11.2.0.0_release1/aspx/Mainnew.aspx.cs | 4141 +++++ AW_11.2.0.0_release1/aspx/Message.aspx | 169 + AW_11.2.0.0_release1/aspx/OpenFiles.aspx | 71 + AW_11.2.0.0_release1/aspx/OpenLogFile.aspx | 96 + AW_11.2.0.0_release1/aspx/Page.aspx | 105 + AW_11.2.0.0_release1/aspx/ParamsTstruct.aspx | 844 + AW_11.2.0.0_release1/aspx/ResetPassword.aspx | 134 + .../aspx/Responsibilities.aspx | 231 + AW_11.2.0.0_release1/aspx/Roles.aspx | 295 + AW_11.2.0.0_release1/aspx/SaveAs.aspx | 99 + AW_11.2.0.0_release1/aspx/Signin.aspx | 419 + AW_11.2.0.0_release1/aspx/Signin.aspx.cs | 1551 ++ AW_11.2.0.0_release1/aspx/Support.aspx | 86 + AW_11.2.0.0_release1/aspx/UserManual.aspx | 68 + AW_11.2.0.0_release1/aspx/Users.aspx | 407 + AW_11.2.0.0_release1/aspx/ViewHistory.aspx | 44 + AW_11.2.0.0_release1/aspx/WizardPage.aspx | 350 + AW_11.2.0.0_release1/aspx/Wizardsetting.aspx | 728 + .../aspx/WorkFlowDelegation.aspx | 251 + AW_11.2.0.0_release1/aspx/Workflow.aspx | 277 + AW_11.2.0.0_release1/aspx/WorkflowNew.aspx | 757 + AW_11.2.0.0_release1/aspx/WorkflowScript.aspx | 910 + .../aspx/Workflownotification.aspx | 159 + AW_11.2.0.0_release1/aspx/adminconsole.aspx | 330 + AW_11.2.0.0_release1/aspx/axpfileupload.aspx | 104 + AW_11.2.0.0_release1/aspx/cancel.aspx | 88 + AW_11.2.0.0_release1/aspx/cpwd.aspx | 362 + AW_11.2.0.0_release1/aspx/cpwd.aspx.vb | 347 + AW_11.2.0.0_release1/aspx/dashBoard.aspx | 167 + AW_11.2.0.0_release1/aspx/emailaxpdocs.aspx | 67 + AW_11.2.0.0_release1/aspx/err.aspx | 119 + .../aspx/excelimportgrid.aspx | 76 + AW_11.2.0.0_release1/aspx/fileupload.aspx | 93 + AW_11.2.0.0_release1/aspx/gridfileupload.aspx | 106 + AW_11.2.0.0_release1/aspx/iview.aspx | 906 + AW_11.2.0.0_release1/aspx/ivpicklist.aspx | 120 + AW_11.2.0.0_release1/aspx/ivtoivload.aspx | 36 + AW_11.2.0.0_release1/aspx/ivtstload.aspx | 47 + .../aspx/mainPageTemplate.html | 1261 ++ AW_11.2.0.0_release1/aspx/pdfparams.aspx | 100 + AW_11.2.0.0_release1/aspx/sess.aspx | 219 + AW_11.2.0.0_release1/aspx/sess.aspx.vb | 186 + AW_11.2.0.0_release1/aspx/signout.aspx | 144 + AW_11.2.0.0_release1/aspx/srchComponent.aspx | 309 + AW_11.2.0.0_release1/aspx/tstruct.aspx | 775 + AW_11.2.0.0_release1/aspx/tstruct.aspx.cs | 5421 ++++++ AW_11.2.0.0_release1/aspx/tstructhtml.aspx | 137 + AW_11.2.0.0_release1/aspx/tsttable.aspx | 40 + AW_11.2.0.0_release1/aspx/updateWizard.aspx | 109 + AW_11.2.0.0_release1/aspx/useraccess.aspx | 329 + AW_11.2.0.0_release1/aspx/useracciview.aspx | 130 + AW_11.2.0.0_release1/versionInfo.json | 12 + .../Export/AX_LAYOUTDESIGN_SAVED_ad__t.fld | Bin 0 -> 1233 bytes .../Export/AX_LAYOUTDESIGN_SAVED_ad__t.tab | Bin 0 -> 5364 bytes .../Export/AX_LAYOUTDESIGN_SAVED_ad_af.fld | Bin 0 -> 1065 bytes .../Export/AX_LAYOUTDESIGN_SAVED_ad_af.tab | Bin 0 -> 3940 bytes .../Export/AX_LAYOUTDESIGN_SAVED_ad_nf.fld | Bin 0 -> 1233 bytes .../Export/AX_LAYOUTDESIGN_SAVED_ad_nf.tab | Bin 0 -> 3646 bytes .../Export/AX_LAYOUTDESIGN_SAVED_ad_tb.fld | Bin 0 -> 1065 bytes .../Export/AX_LAYOUTDESIGN_SAVED_ad_tb.tab | Bin 0 -> 6090 bytes .../Export/AX_LAYOUTDESIGN_SAVED_mntss.fld | Bin 0 -> 1233 bytes .../Export/AX_LAYOUTDESIGN_SAVED_mntss.tab | Bin 0 -> 16748 bytes .../Export/AX_LAYOUTDESIGN_SAVED_nf_ag.fld | Bin 0 -> 1233 bytes .../Export/AX_LAYOUTDESIGN_SAVED_nf_ag.tab | Bin 0 -> 10474 bytes .../Export/AX_LAYOUTDESIGN_ad__t.fld | Bin 0 -> 897 bytes .../Export/AX_LAYOUTDESIGN_ad__t.tab | Bin 0 -> 5166 bytes .../Export/AX_LAYOUTDESIGN_ad_af.fld | Bin 0 -> 851 bytes .../Export/AX_LAYOUTDESIGN_ad_af.tab | Bin 0 -> 3760 bytes .../Export/AX_LAYOUTDESIGN_ad_nf.fld | Bin 0 -> 897 bytes .../Export/AX_LAYOUTDESIGN_ad_nf.tab | Bin 0 -> 3448 bytes .../Export/AX_LAYOUTDESIGN_ad_tb.fld | Bin 0 -> 851 bytes .../Export/AX_LAYOUTDESIGN_ad_tb.tab | Bin 0 -> 5892 bytes .../Export/AX_LAYOUTDESIGN_mntss.fld | Bin 0 -> 897 bytes .../Export/AX_LAYOUTDESIGN_mntss.tab | Bin 0 -> 16550 bytes .../Export/AX_LAYOUTDESIGN_nf_ag.fld | Bin 0 -> 897 bytes .../Export/AX_LAYOUTDESIGN_nf_ag.tab | Bin 0 -> 10270 bytes .../AxpertDeveloper/Export/c__NF_AG.trn | Bin 0 -> 15807 bytes .../Export/c__PageIvivad_af.pge | Bin 0 -> 288 bytes .../AxpertDeveloper/Export/c__PageTsad__t.pge | Bin 0 -> 404 bytes .../AxpertDeveloper/Export/c__PageTsad_af.pge | Bin 0 -> 301 bytes .../AxpertDeveloper/Export/c__ad__t.trn | Bin 0 -> 8247 bytes .../AxpertDeveloper/Export/c__ad_af.trn | Bin 0 -> 5264 bytes .../AxpertDeveloper/Export/c__ad_nf.trn | Bin 0 -> 6183 bytes .../AxpertDeveloper/Export/c__ad_tb.lvw | Bin 0 -> 1447 bytes .../AxpertDeveloper/Export/c__ad_tb.trn | Bin 0 -> 4328 bytes .../AxpertDeveloper/Export/c__ivad_af.ivw | Bin 0 -> 1731 bytes .../AxpertDeveloper/Export/c__mntss.trn | Bin 0 -> 17214 bytes Axpert Structures/AxpertDeveloper/Script.txt | 990 ++ Axpert Structures/AxpertRun/Script.txt | 1 + README.md | 14 + Release Notes.txt | 68 + TECH_ARCHITECTURE.md | 349 + 150 files changed, 127509 insertions(+) create mode 100644 .gitignore create mode 100644 AI_LAYER_DESIGN_NOTES.md create mode 100644 AW_11.2.0.0_release1/App_Code/Constants.cs create mode 100644 AW_11.2.0.0_release1/App_Code/DBContext.cs create mode 100644 AW_11.2.0.0_release1/App_Code/TStructData.cs create mode 100644 AW_11.2.0.0_release1/App_Code/TStructDef.cs create mode 100644 AW_11.2.0.0_release1/App_Code/WebService.cs create mode 100644 AW_11.2.0.0_release1/Js/AxInterface.js create mode 100644 AW_11.2.0.0_release1/Js/axpertUI.js create mode 100644 AW_11.2.0.0_release1/Js/axpertUI.min.js create mode 100644 AW_11.2.0.0_release1/Js/common.js create mode 100644 AW_11.2.0.0_release1/Js/common.min.js create mode 100644 AW_11.2.0.0_release1/Js/expressions_config.js create mode 100644 AW_11.2.0.0_release1/Js/expressions_config.min.js create mode 100644 AW_11.2.0.0_release1/Js/iview.js create mode 100644 AW_11.2.0.0_release1/Js/iview.min.js create mode 100644 AW_11.2.0.0_release1/Js/jsclient.js create mode 100644 AW_11.2.0.0_release1/Js/jsclient.min.js create mode 100644 AW_11.2.0.0_release1/Js/login.js create mode 100644 AW_11.2.0.0_release1/Js/login.min.js create mode 100644 AW_11.2.0.0_release1/Js/main-tstruct.js create mode 100644 AW_11.2.0.0_release1/Js/main-tstruct.min.js create mode 100644 AW_11.2.0.0_release1/Js/main.js create mode 100644 AW_11.2.0.0_release1/Js/main.min.js create mode 100644 AW_11.2.0.0_release1/Js/process.js create mode 100644 AW_11.2.0.0_release1/Js/process.min.js create mode 100644 AW_11.2.0.0_release1/Js/smartViews.js create mode 100644 AW_11.2.0.0_release1/Js/smartViews.min.js create mode 100644 AW_11.2.0.0_release1/Js/tstruct.js create mode 100644 AW_11.2.0.0_release1/Js/tstruct.min.js create mode 100644 AW_11.2.0.0_release1/UI/axpertUI/datatables.bundle.js.map create mode 100644 AW_11.2.0.0_release1/UI/axpertUI/style.bundle.css create mode 100644 AW_11.2.0.0_release1/UI/axpertUI/style.bundle.css.map create mode 100644 AW_11.2.0.0_release1/UI/axpertUI/style.bundle.rtl.css create mode 100644 AW_11.2.0.0_release1/UI/axpertUI/style.bundle.rtl.css.map create mode 100644 AW_11.2.0.0_release1/UI/compiler/src/sass/components/_extras.scss create mode 100644 AW_11.2.0.0_release1/UI/compiler/src/sass/components/helpers/_text.scss create mode 100644 AW_11.2.0.0_release1/aspx/AboutUs.aspx create mode 100644 AW_11.2.0.0_release1/aspx/AddEditResponsibility.aspx create mode 100644 AW_11.2.0.0_release1/aspx/AppDownload.aspx create mode 100644 AW_11.2.0.0_release1/aspx/AppSettings.aspx create mode 100644 AW_11.2.0.0_release1/aspx/AutoComplete.aspx create mode 100644 AW_11.2.0.0_release1/aspx/AxMPage.master create mode 100644 AW_11.2.0.0_release1/aspx/AxManager.aspx create mode 100644 AW_11.2.0.0_release1/aspx/AxpertLogs.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Comments.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Complaint.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Config.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Configuration.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Drafts.aspx create mode 100644 AW_11.2.0.0_release1/aspx/ExportNew.aspx create mode 100644 AW_11.2.0.0_release1/aspx/FastDataUtility.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Forgotpassword.aspx create mode 100644 AW_11.2.0.0_release1/aspx/HomeBuilder.aspx create mode 100644 AW_11.2.0.0_release1/aspx/HomePage.aspx create mode 100644 AW_11.2.0.0_release1/aspx/ImageUpload.aspx create mode 100644 AW_11.2.0.0_release1/aspx/ImportNew.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Mainnew.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Mainnew.aspx.cs create mode 100644 AW_11.2.0.0_release1/aspx/Message.aspx create mode 100644 AW_11.2.0.0_release1/aspx/OpenFiles.aspx create mode 100644 AW_11.2.0.0_release1/aspx/OpenLogFile.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Page.aspx create mode 100644 AW_11.2.0.0_release1/aspx/ParamsTstruct.aspx create mode 100644 AW_11.2.0.0_release1/aspx/ResetPassword.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Responsibilities.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Roles.aspx create mode 100644 AW_11.2.0.0_release1/aspx/SaveAs.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Signin.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Signin.aspx.cs create mode 100644 AW_11.2.0.0_release1/aspx/Support.aspx create mode 100644 AW_11.2.0.0_release1/aspx/UserManual.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Users.aspx create mode 100644 AW_11.2.0.0_release1/aspx/ViewHistory.aspx create mode 100644 AW_11.2.0.0_release1/aspx/WizardPage.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Wizardsetting.aspx create mode 100644 AW_11.2.0.0_release1/aspx/WorkFlowDelegation.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Workflow.aspx create mode 100644 AW_11.2.0.0_release1/aspx/WorkflowNew.aspx create mode 100644 AW_11.2.0.0_release1/aspx/WorkflowScript.aspx create mode 100644 AW_11.2.0.0_release1/aspx/Workflownotification.aspx create mode 100644 AW_11.2.0.0_release1/aspx/adminconsole.aspx create mode 100644 AW_11.2.0.0_release1/aspx/axpfileupload.aspx create mode 100644 AW_11.2.0.0_release1/aspx/cancel.aspx create mode 100644 AW_11.2.0.0_release1/aspx/cpwd.aspx create mode 100644 AW_11.2.0.0_release1/aspx/cpwd.aspx.vb create mode 100644 AW_11.2.0.0_release1/aspx/dashBoard.aspx create mode 100644 AW_11.2.0.0_release1/aspx/emailaxpdocs.aspx create mode 100644 AW_11.2.0.0_release1/aspx/err.aspx create mode 100644 AW_11.2.0.0_release1/aspx/excelimportgrid.aspx create mode 100644 AW_11.2.0.0_release1/aspx/fileupload.aspx create mode 100644 AW_11.2.0.0_release1/aspx/gridfileupload.aspx create mode 100644 AW_11.2.0.0_release1/aspx/iview.aspx create mode 100644 AW_11.2.0.0_release1/aspx/ivpicklist.aspx create mode 100644 AW_11.2.0.0_release1/aspx/ivtoivload.aspx create mode 100644 AW_11.2.0.0_release1/aspx/ivtstload.aspx create mode 100644 AW_11.2.0.0_release1/aspx/mainPageTemplate.html create mode 100644 AW_11.2.0.0_release1/aspx/pdfparams.aspx create mode 100644 AW_11.2.0.0_release1/aspx/sess.aspx create mode 100644 AW_11.2.0.0_release1/aspx/sess.aspx.vb create mode 100644 AW_11.2.0.0_release1/aspx/signout.aspx create mode 100644 AW_11.2.0.0_release1/aspx/srchComponent.aspx create mode 100644 AW_11.2.0.0_release1/aspx/tstruct.aspx create mode 100644 AW_11.2.0.0_release1/aspx/tstruct.aspx.cs create mode 100644 AW_11.2.0.0_release1/aspx/tstructhtml.aspx create mode 100644 AW_11.2.0.0_release1/aspx/tsttable.aspx create mode 100644 AW_11.2.0.0_release1/aspx/updateWizard.aspx create mode 100644 AW_11.2.0.0_release1/aspx/useraccess.aspx create mode 100644 AW_11.2.0.0_release1/aspx/useracciview.aspx create mode 100644 AW_11.2.0.0_release1/versionInfo.json create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_ad__t.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_ad__t.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_ad_af.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_ad_af.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_ad_nf.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_ad_nf.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_ad_tb.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_ad_tb.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_mntss.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_mntss.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_nf_ag.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_SAVED_nf_ag.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_ad__t.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_ad__t.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_ad_af.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_ad_af.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_ad_nf.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_ad_nf.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_ad_tb.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_ad_tb.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_mntss.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_mntss.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_nf_ag.fld create mode 100644 Axpert Structures/AxpertDeveloper/Export/AX_LAYOUTDESIGN_nf_ag.tab create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__NF_AG.trn create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__PageIvivad_af.pge create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__PageTsad__t.pge create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__PageTsad_af.pge create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__ad__t.trn create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__ad_af.trn create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__ad_nf.trn create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__ad_tb.lvw create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__ad_tb.trn create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__ivad_af.ivw create mode 100644 Axpert Structures/AxpertDeveloper/Export/c__mntss.trn create mode 100644 Axpert Structures/AxpertDeveloper/Script.txt create mode 100644 Axpert Structures/AxpertRun/Script.txt create mode 100644 README.md create mode 100644 Release Notes.txt create mode 100644 TECH_ARCHITECTURE.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f074fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +**/.DS_Store diff --git a/AI_LAYER_DESIGN_NOTES.md b/AI_LAYER_DESIGN_NOTES.md new file mode 100644 index 0000000..ab48839 --- /dev/null +++ b/AI_LAYER_DESIGN_NOTES.md @@ -0,0 +1,219 @@ +# AI Layer & Event/Audit Design Notes + +These notes keep the useful ideas from an earlier ChatGPT brainstorm. They have been corrected against the real Axpert 11.2 code and the krishtech database. The rest of that conversation is no longer needed. + +- **Scope:** the AI agent, the event/action engine, the SQL layer and the audit engine. +- **Out of scope:** the platform spec itself (forms, grids, reports, security, workflow). That comes from the code analysis. + +--- + +## 1. Guiding principles + +1. **Don't clone the software.** Work out the behaviour, the metadata and the database, then build a clean web engine. Write all code from scratch; never copy Axpert code, SQL or assets. +2. **Replace the runtime first, then grow into a low-code platform.** First run existing Axpert apps (forms, reports, workflow) against the existing database. Then add the designer and the AI-driven app building. +3. **The agent defines, the runtime enforces, the database stores.** The AI never runs anything directly. It produces application definitions, which are validated, previewed and then run by the runtime. + +## 2. Event → Action model + +Events are stored as **structured actions (JSON)**, not raw SQL or script text. + +```json +{ + "trigger": "FIELD_CHANGE", + "field": "customer_code", + "actions": [ + { + "type": "LOOKUP", + "source": "customer", + "where": { "customer_code": "$field.customer_code" }, + "select": ["customer_name", "credit_limit"], + "map": { "customer_name": "$field.customer_name", + "credit_limit": "$field.credit_limit" } + } + ] +} +``` + +**Triggers** map to Axpert's `apply` values: + +| Trigger | Axpert `apply` value | +|---|---| +| `FORM_LOAD` | On Form Load | +| `DATA_LOAD` | On Data Load | +| `FIELD_ENTER` | On Field Enter | +| `FIELD_CHANGE` | On Field Exit | +| `BEFORE_SAVE` | (new) | +| `AFTER_SAVE` | After save transaction | +| `BEFORE_DELETE` | (new) | +| `BUTTON_CLICK` | (new) | + +**Action types:** + +| Group | Actions | +|---|---| +| UI | `SHOW`, `HIDE`, `ENABLE`, `DISABLE`, `REQUIRE`, `SET_VALUE`, `MESSAGE`, `ADD_ROW` | +| Data | `LOOKUP` (preferred), `SQL_QUERY`, `SQL_INSERT`, `SQL_UPDATE`, `SQL_DELETE`, `PROCEDURE_CALL`, `FUNCTION_CALL` | +| Flow | `IF` / `ELSE_IF` / `ELSE` (condition = expression in the shared expression language) | +| Navigation | `OPEN_FORM`, `OPEN_FORM_WITH_DATA`, `OPEN_REPORT`, `OPEN_PAGE` (Axpert: `LoadForm`, `LoadFormAndData`, `LoadIView`, `LoadPage`, `OpenPage`) | +| Other | `FILL_GRID`, `SAVE`, `PRINT`, `CALL_API` | + +**Rule example**, written the way a user would say it: + +``` +WHEN customer_type changes +IF customer_type = "CREDIT" +THEN show credit_limit, enable credit_days, require credit_limit +``` + +### Converting old Axpert events + +Old events are **parsed and converted, never executed** as raw code: + +``` +Axpert XML / formcontrol tokens / expressions + ↓ parser + syntax tree + ↓ converter + structured actions (above) +``` + +The Axpert format is already known from the code analysis: + +- `` holds named actions with `apply="On Field Exit|…"`. Each action contains steps: + - `op=0` if (with an `iif` expression in `exprset`) + - `op=1` else + - `op=5` task (Field Access, Save, Open TStruct/Iview) + - `op=8` end +- `` holds token lists: + - Triggers: `f` / `f_On Form Load`. + - Control words: `cif`, `celseif`, `celse`, `cend`, `cand`, with `et`/`net` for equals / not equals. + - Target prefixes: `8` hide, `9` show, `1`/`2` enable/disable, `3` set value. +- Advanced users can still hand-write events in an **Advanced Event Editor** (Monaco). + +## 3. SQL layer + +``` +Event → Action Engine → Query Compiler → SQL Executor → DB adapter → Postgres + ↓ + result mapping → form fields +``` + +1. **The agent prefers `LOOKUP`**, a high-level description of the query. The **Query Compiler** turns it into SQL for the target database, so the agent doesn't have to think about database-specific syntax. +2. **Raw SQL is allowed for complex cases**: aggregates, joins, updates and stored procedures. +3. **Every query is parameterized.** Queries use `:customer_code` placeholders that are bound at run time, and are never built by pasting strings together. Axpert does exactly that, and it is a weakness you can sell against. +4. **Axpert's SQL placeholders must be supported:** + - `:fieldname` binds to the current field's value. + - `{field*}` expands to an IN-list over all grid rows. + - Parent values come from the current row or DC context. +5. **No endpoint ever runs SQL sent by the client.** Axpert's `callExecuteSQL` does, and it must not be copied. Named SQL is kept server-side and allow-listed, the equivalent of Axpert's `axdirectsql`. +6. **Database adapter:** support Postgres first, because the krishtech customer runs PostgreSQL 16. Add MSSQL or Oracle only if a paying customer needs one. + +## 4. AI agent: writing SQL and definitions automatically + +The user describes what they want in business terms and never has to write SQL. + +``` +User: "When I select a customer, show their name and credit limit." + ↓ intent FIELD_CHANGE on customer_code + ↓ schema agent read metadata: Customer form → customer_code, customer_name, credit_limit + ↓ query planner LOOKUP customer WHERE customer_code = current RETURN name, credit_limit + ↓ SQL generator parameterized SQL (only for complex cases) + ↓ validation schema check + test run (EXPLAIN) + ↓ event definition attached to the field + ↓ preview the user sees it working before publishing +``` + +Complex example: "Average monthly sales for the last 6 months, excluding cancelled orders." The agent reads the schema and writes the aggregate SQL itself. The SQL is hidden unless the user opens the advanced details. + +**Safety limits:** + +- The agent works only from **your metadata and schema** (the metadata tables, `information_schema`). It never guesses table names. +- Every definition the agent produces is **validated against the metadata schema** (Zod or JSON Schema) before it is saved. +- AI-generated **reads** run under a **read-only database role** with row-level permissions applied. +- AI-generated **writes** (`SQL_UPDATE`/`INSERT`/`DELETE`, procedures) **always need a human to approve** them before publishing. +- Every AI change is versioned and shows a diff, so it can be rolled back. + +**Other agent features to build on the same pipeline:** + +- Build an app from a description, e.g. "Create a GRN form with a PO lookup and item grid." +- Ask a question in plain language and get a report. +- Explain and write expressions. +- Fill a form from a document, e.g. an invoice PDF becomes a purchase bill with its item grid filled. +- Workflow insights and anomaly flags. + +## 5. Audit engine + +**Axpert today:** one `history` table per form, with 81 of them in krishtech. Columns: `recordid, fieldname, oldvalue, newvalue, rowno, modno, frameno, …`. Each form can track all fields or selected fields, and optionally only some users. + +**Design:** a separate **Audit Engine module**, stored **in the same database** for V1. + +``` +Save / Delete Engine + → capture OLD values → write data → capture NEW values + → Audit Engine (policy + change capture) + → audit tables ← all in ONE database transaction (consistent) +``` + +**Tables:** + +``` +audit_transaction -- one row per save or delete + audit_id, app, form (transid), record_id, action (INSERT/UPDATE/DELETE/CANCEL), + user_id, at (timestamptz), ip, device, source (form/api/agent/import), + definition_version + +audit_change -- one row per field changed + audit_id, dc, row_no, row_key, field, old_value, new_value +``` + +`dc`, `row_no` and `row_key` are needed so that changes to **grid rows** can be traced. ChatGPT's version left these out. + +**Audit policy lives in the form definition**, and the agent sets it: + +```json +"audit": { "enabled": true, "mode": "selected_fields", + "fields": ["salary", "designation"], "users": "all" } +``` + +"Track changes to salary and designation" → the agent writes this policy, and the runtime does the rest. + +**Compatibility:** per-form views (`history`) built on the new tables, so Axpert-style history screens keep working. + +**Scaling path** (not needed for the first version). The rough load: 5,000 stores × 100 transactions × 20 fields is about 10M change rows a day. + +``` +V1: same Postgres, audit written in the same transaction (partition audit_change by month) +V2: outbox table → NATS JetStream → audit store (Postgres, or ClickHouse for analytics) +``` + +The application model does not change between V1 and V2; only the storage behind the Audit Engine does. + +## 6. Overall runtime shape + +``` +User ──► Conversational Agent ──► Application Definition (forms, events, rules, audit policy) + │ validate + preview + publish + ▼ + RUNTIME + ┌──────────────┬──────────────┼──────────────┬──────────────┐ + Form Engine Event/Action Rule/Expr Security Workflow + Engine (shared) Engine Engine + │ + ┌──────────────┼──────────────┐ + UI actions DB actions Mapping + │ + Query Compiler → SQL Executor → DB adapter + │ + Save Engine ──► Audit Engine + │ + Postgres (business data + new metadata schema + audit) +``` + +## 7. Open decision + +**Go vs TypeScript for the backend.** The expression engine must run in both the browser and the server. + +- **TypeScript everywhere:** one codebase, the simplest option. +- **Go backend:** the expression engine is written in Go and compiled to WASM for the browser. + +Decide this before starting the metadata schema and the expression engine. diff --git a/AW_11.2.0.0_release1/App_Code/Constants.cs b/AW_11.2.0.0_release1/App_Code/Constants.cs new file mode 100644 index 0000000..0c0afbb --- /dev/null +++ b/AW_11.2.0.0_release1/App_Code/Constants.cs @@ -0,0 +1,269 @@ +using System; +using System.Collections.Generic; +using System.Web; + +/// +/// Summary description for Constants +/// +public class Constants +{ + public Constants() + { + // + // TODO: Add constructor logic here + // + } + public const string vbCrLf = ""; + + #region Error messages for culture + public const string ERROR = ""; + public const string ERRORCLOSE = ""; + public const string REC_NOT_FOUND = "No data found."; + public const string SEL_ROWS_FOUND = "All rows are already selected."; + public const string SESSIONERROR = "invalid sessionid"; + public const string CUSTOMERROR = "Server error. Please try again.If the problem continues, please contact your administrator."; + public const string SUCCESS = ""; + public const string SUCCESSCLOSE = ""; + public const string SESSIONEXPMSG = "Disconnected because you have logged into another session."; + public const string EMPTYOPTION = "-- Select --"; + public const string PARAMERR = "err.aspx?errmsg=Invalid parameter"; + public const string LOGINERR = "signin.aspx?msg=Invalid Username or Password."; + public const string LOGINPAGE = "signin.aspx"; + public const string ERRPATH = "../aspx/err.aspx?errmsg="; + public const string ERAUTHENTICATION = "Session Authentication failed..."; + public const string DUPLICATESESS = "Duplicate_session"; + public const string INVALIDURL = "Requested Page cannot be loaded as the URL contains invalid character."; + public const string MALICIOUSNPUTDETECTED = "Invalid input detected, Please try again."; + public const string SESSIONTIMEOUT = "SESSION_TIMEOUT"; + #endregion + + public const string IMGPrefix = "nodb_"; + public const string AXPIMAGEPATH = "axpimagepath"; + public const string TRACESPLITSTR2 = "♦♦"; + public const string TRACESPLITSTR1 = "♦"; + public const string IMGSRCPrefix = "nodbsrc_"; + public const string PROGRESS = "InProgress"; + public const string INIT = "INIT"; + public const string AOWE = "AOWE"; + public const string APPEND = "APPEND"; + public const string BACKIMG = "../AxpImages/icons/24X24/backbutton.png"; + public const string FORWARDIMG = "../AxpImages/icons/24X24/forwardbutton.png"; + public const string TILE = "tile"; + public const string DEFAULT = "default"; + public const string DOUBLE = "double"; + public const string SINGLE = "single"; + public const string ACPICKPAGESIZE = "50"; + public const string TABBED = "tabbed"; + public const string AXPISROWVALID = "axp__isGrdVld"; + public const string GeneralLog = "GeneralLog"; + public const string structHTML = "TSTHTML"; + public const string tstHeaderHTML = "TSTHDRHTML"; + public const string toolbarBtnIcons = "TOOLBTNS"; + public const string modernToolbarBtnOpen = "MODERNTOOLBTNS"; + public const string attachHTML = "ATTHTML"; + public const string taskBtns = "TSKBTNS"; + public const string structScript = "TSTSCRIPT"; + public const string structBtns = "TSTBTNS"; + public const string structCaption = "TSTCAPTION"; + public const string strSubmitCancel = "TSTFOOTER"; + public const string strDesign = "TSTDESIGN"; + public static string[] fileTypes = { ".bmp", ".jpg", ".jpeg", ".pjpeg", ".png", ".gif", ".doc", ".docx", ".xml", ".xlsx", ".ppt", ".pdf", ".txt", ".xls", ".pwd", ".tiff", ".tif", ".dib", ".jfif", ".heic", ".xlxs", ".csv", ".html", ".css", ".js", "htm", ".eml", ".msg", ".pptx" }; + public static string fileExtensionImage = ".gif,.png,.jpg,.jpeg,.bmp,.tiff,.tif,.heic,.jfif"; + public const string NO_DRAFTS = "No Drafts"; + public const string DRAFT_REFRESH = "refresh"; + public const string NO_DRAFT_HTML = ""; + public const string EX_DRAFT_HTML = ""; + + + public const string ORCL_QRY_PRPS_DSGN = "declare cnt int; val varchar2(31000); begin val := '$VALUE$'; select count(*) into cnt from axpCloudDevSettings where TranID='$TRANID$' and type='$TYPE$'; if (cnt>0) then UPDATE axpCloudDevSettings SET value = val where TranID='$TRANID$' and type='$TYPE$'; else insert into axpCloudDevSettings (USERID,tranid,type,value) Values ('$USERID$','$TRANID$','$TYPE$',val) ; END IF; end; "; + public const string ORCL_QRY_PRPS_USER = "declare cnt int; begin select count(*) into cnt from axpCloudUserSettings where userid = '$USERID$' and TranID='$TRANID$' and type='$TYPE$'; if (cnt>0) then UPDATE axpCloudUserSettings SET value = '$VALUE$' where userid = '$USERID$' and TranID='$TRANID$' and type='$TYPE$'; else insert into axpCloudUserSettings (userid,tranid,type,value) Values ('$USERID$','$TRANID$','$TYPE$','$VALUE$') ; END IF; end;"; + + public const string MYSQL_QRY_PRPS_DSGN = "INSERT INTO axpCloudDevSettings (userid,TranID,Type,Value) values ('$USERID$','$TRANID$','$TYPE$','$VALUE$') ON DUPLICATE KEY UPDATE Value= values(Value);"; + + public const string MYSQL_QRY_PRPS_USER = "INSERT INTO axpCloudUserSettings (userid,TranID,Type,Value) values ('$USERID$','$TRANID$','$TYPE$','$VALUE$') ON DUPLICATE KEY UPDATE Value= values(Value);"; + + public const string SQL_QRY_PRPS_USER = "if exists(select * from axpCloudUserSettings where userid='$USERID$' and Type='$TYPE$' and TranID='$TRANID$') update axpCloudUserSettings set Value ='$VALUE$' where userid='$USERID$' and Type='$TYPE$' and TranID='$TRANID$' else insert into axpCloudUserSettings (userid,TranID,Type,Value) values ('$USERID$','$TRANID$','$TYPE$','$VALUE$')"; + public const string SQL_QRY_PRPS_DSGN = "if exists(select * from axpCloudDevSettings where Type='$TYPE$' and TranID='$TRANID$') update axpCloudDevSettings set Value ='$VALUE$' where Type='$TYPE$' and TranID='$TRANID$' else insert into axpCloudDevSettings (userid,TranID,Type,Value) values ('$USERID$','$TRANID$','$TYPE$','$VALUE$')"; + + + public const string QUERY_GET_PRPS_STATUS = "Select ( CASE WHEN (Select Value from axpCloudDevSettings where userid='$USERID$' and type='$TYPE$' and TranID='$TRANID$') IS NULL THEN to_clob('0') else (Select Value from axpCloudDevSettings where userid='$USERID$' and type='$TYPE$' and TranID='$TRANID$') end ) AS admn,(CASE WHEN (Select Value from axpCloudUserSettings where USERID='$USERID$' and type ='$TYPE$' and TranID='$TRANID$') IS NULL THEN to_clob('0') else (Select Value from axpCloudUserSettings where USERID='$USERID$' and type='$TYPE$' and TranID='$TRANID$')end ) AS usr from dual"; //from dual, to_clob + + public const string MYSQL_QUERY_GET_PRPS_STATUS = "Select ( CASE WHEN (Select Value from axpCloudDevSettings where userid='$USERID$' and type='$TYPE$' and TranID='$TRANID$') IS NULL THEN '0' else (Select Value from axpCloudDevSettings where userid='$USERID$' and type='$TYPE$' and TranID='$TRANID$') end ) AS admn,(CASE WHEN (Select Value from axpCloudUserSettings where USERID='$USERID$' and type ='$TYPE$' and TranID='$TRANID$') IS NULL THEN '0' else (Select Value from axpCloudUserSettings where USERID='$USERID$' and type='$TYPE$' and TranID='$TRANID$')end ) AS usr "; + + public const string SQL_CHECK_USER = "SELECT USERNAME FROM AX_USER_SETTINGS WHERE USERNAME = '$USERID$'"; + public const string SQL_LOAD_USER_APPSETTINGS = "SELECT APPSETTINGS FROM AX_USER_SETTINGS WHERE USERNAME = '$USERID$'"; + public const string SQL_SAVE_USER_APPSETTINGS = "UPDATE AX_USER_SETTINGS SET APPSETTINGS = '$VALUE$' WHERE USERNAME = '$USERID$'"; + public const string SQL_INSERT_USER_APPSETTINGS = "INSERT INTO AX_USER_SETTINGS (USERNAME, APPSETTINGS) VALUES ('$USERID$', '$VALUE$')"; + public const string DEFAULT_USER_APPSETTINGS = "{\"sabrnig\":false}"; + + public const string MYSQL_QUERY_IVIR_SAVE_JSON = "update AX_USER_SETTINGS set IR_CONFIG = '$VALUE$' where USERNAME = '$USERID$'"; + public const string MYSQL_QUERY_IVIR_GET_JSON = "select IR_CONFIG from AX_USER_SETTINGS where USERNAME = '$USERID$'"; + + public const string UPDATE_PRIVATE_SSO_TOKEN_IN_DB = "update axusers set singleloginkey = '$VALUE$' where USERNAME = '$USERID$'"; + + public const string GET_TST_CUSTOM_ACTIONS = "Select configname,cvalue from axpconfigs_$TRANSID$"; + public const string RAPID_FORMLOAD_TBL = "Axp_formload"; + public const string RAPID_DEPENDENCY_TBL = "Axp_Dependents"; + public const string GET_RAPID_DEF_SP = "SP_RAPIDDEFINITION"; + + public const string GET_IV_GROUPED_BUTTONS = "Select cvalue from axpconfigsiv_$IVNAME$ where configname='groupbtns'"; + + public const string GET_IV_TEMPLETE = "select cvalue, elements from templates where type='Iview' and iviewid='$IVNAME$'"; + + public const string VAR_TRANSID = "$TRANSID$"; + public const string VAR_IVNAME = "$IVNAME$"; + + + public const string IVIEWSTRUCT = "ivewstruct"; + public const string IVIEWPARAM = "ivewsparam"; + public const string REDISXML = "

TESTING

axrowtypeaxp__fontdetailsTypeNameCaptionkeysizeTotal keyskeys
"; + + public const string CACMENU = "CACMENU"; + public const string REDISTSTRUCT = "Tstruct"; + public const string REDISTSTRUCTMOB = "TstructMob"; + public const string REDISTSTRUCTTABLE = "TstDcTable"; + public const string REDISTSTRUCTDOFORM = "TstructDoForm"; + public const string REDISTSTRUCTDESIGN = "TstDsgn"; + public const string REDISTSTRUCTAXDESIGN = "axTstDsgn"; + public const string REDISTSTRUCTAXCUSTHTML = "axTstCustomHtml"; + public const string REDISTSTRUCTAXDESIGNTABLE = "axTstDsgnTbl"; + public const string REDISTSTRUCTALL = "axTstAll"; + public const string REDISTSTRUCTDTLS = "TstructDtls"; + public const string REDISTSTRUCTDTLSMOB = "TstructDtlsMob"; + public const string REDISTSTRUCTDESIGNDTLS = "TstDsgnDtls"; + public const string DEPFLDARRAY = "depFldArray"; + public const string FIELDNAME = "fieldName"; + public const string FIELDINDEX = "fieldIndex"; + public const string FORMLOADARRAY = "FormLoadArray"; + public const string FORMLOADINDEX = "FormLoadIndex"; + + public const string FORMLOADRES = "FormLoadRes"; + + public const string CLOUD_HOME_API = "api/Session/IsValidSession/{0}/{1}"; + public const string REDISMENUDATA = "MenuData"; + public const string REDISCARDSDATA = "CardsData"; + public const string REDISCARDKEYS = "CardKeys"; + public const string REDISCARDPARAMS = "CardsParams"; + public const string REDISCARDROLES = "CardsRoles"; + public const string REDISAPIKEYS = "ApiKeys"; + public const string REDISGLOBALVARS = "GlobalVars"; + public const string REDISAXUSEROPTIONS = "axUserOptions"; + public const string REDISLVRECORDLISTING = "lvRecordListing"; + public const string REDISHYBRIDINFO = "mobilehybridinfo"; + public const string REDISKEEPWEBINFO = "keepaliveweb"; + + public const string ListViewFieldsInfo = "ListFldsInfo"; + + public const string RedisIviewObjList = "IviewObjList"; + + public const string RedisIviewObj = "IviewObj"; + + public const string RedisListviewObjList = "ListviewObjList"; + + public const string RedisListviewObj = "ListviewObj"; + + public const string RedisIviewBuilderObj = "IviewBuildObj"; + + public const string RedisIviewSettings = "IviewSettings"; + + public const string RedisListviewSettings = "ListviewSettings"; + + public const string RedisIviewBuilderSettingsObj = "IviewBuildSetingsObj"; + + public const string RedisOldIviewSettings = "IviewOldSettings"; + + public const string RedisOldListviewSettings = "ListviewOldSettings"; + + public const string RedisOldIviewTemplates = "IviewOldTemplates"; + + public const string RedisOldListviewTemplates = "ListviewOldTemplates"; + + public const string IviewNavigationData = "IviewNavigationData"; + + //public const string GET_SEARCH_DATA = "select SEARCHTEXT,HLTYPE,STRUCTNAME,PARAMS from axp_appsearch where username=:username"; + public const string GET_SEARCH_DATA = "select SEARCHTEXT,HLTYPE,STRUCTNAME,PARAMS from axp_appsearch where username=:username and lower(searchtext) like $KEYWORD$"; + public const string COLLAPSEMENU = "Collapse"; + + public const string CFG_CONFIG_FILE = "generic_config"; + public const string GET_DASHBOARD_FILTERDATA = "select * from axp_fparamvalues where username=:username";// columns will be adding dynamically + + //Note: While changing 'DEFAULT_CONFIGSTR', verify the 'AppConfiguration.cs' scenarios as well. No spaces should be used before and after in Key Names. + + public const string DEFAULT_CONFIGSTR = "{\"configStr\": [{\"AxLoginTrace\": \"false\"},{\"AxAlertTimeout\": \"3\"},{\"AxSessionExpiryDays\": \"5\"},{\"AxBreadCrumb\": \"false\"},{\"AxEnableCards\": \"true\"},{\"AxExportTallyTid\": \"\"},{\"AxCPWDOnLogin\": \"true\"},{\"AxHelpIview\": \"\"},{\"AxSessionExtend\": \"true\"},{\"AxDisableSplit\":\"false\"},{\"AxGlobalSrchLimit\":\"10000\"},{\"AxErrorMsg\": \"false\"},{\"AxErrorMsgTimeout\": \"0\"},{\"AxShowLoggedinUsersCount\": \"false\"},{\"AxImpExpTemptPath\": \"\"},{\"AxLanguages\": \"english\"},{\"AxUSCulture\": \"false\"},{\"AxDevInstance\": \"false\"},{\"AxDisplayAutoGenVal\": \"false\"},{\"AxIsPerfCode\": \"true\"},{\"AxDcGridOnSave\": \"true\"},{\"AxAttachmentSize\": \"1\"},{\"AxImagePath\": \"\"},{\"AxAttachFilePath\": \"\"},{\"AxGridAttachPath\": \"\"},{\"AxShowSubmitCancel\": \"false\"},{\"AxDesignerAccess\": \"designer\"},{\"AxIsPrintExe\": \"true\"},{\"AxPrintExePath\": \"\"},{\"AxHtmlPath\": \"\"},{\"AxPrintMargins\": \"50,50,200,100\"},{\"AxPrintTitleAlign\": \"center\"},{\"AxIviewcelltextwrap\": \"true\"},{\"AxMergeRowIviews\": \"\"},{\"AxPrintRowsMaxLimit\": \"10000\"},{\"AxDbPagination\": \"true\"},{\"AxDefaultPageSize\": \"30\"},{\"AxShowAppTitle\": \"true\"},{\"AxGetIviewRowCount\": \"false\"},{\"AxIviewDataWSRows\": \"1000\"},{\"AxInlineGridEdit\": \"true\"},{\"AxHomeBuildAccess\": \"default\"},{\"AxMaxNumOfWidgets\": \"99\"},{\"AxMenuStyle\": \"default\"},{\"AxMenuColumns\": \"3\"},{\"AxSubmenuPerView\": \"6\"},{\"AxMenuWordWrap\": \"false\"},{\"AxSubMenuCount\": \"4\"},{\"AxDirectSubMenuCount\": \"6\"},{\"AxWizardType\": \"classic\"},{\"AxDrafts\": \"false\"},{\"AxAutoPurge\": \"true\"},{\"AxMaxDraftsCount\": \"1\"},{\"AutoSavePublish\" : \"false\"}],\"configLangKeys\": [{\"AxAppTitle_ENG\": \"\"},{\"AxCopyRightText_ENG\": \"Powered by Axpert\"},{\"AxPrintTitle_ENG\": \"\"}]}"; + + + #region Fast Data + public const string FD_TBL_DEFINITION = "select * from axp_FastDataDefinition"; + public const string FD_TBL_ASSOCIATION = "select * from axp_fastdataassociation"; + public const string FD_DT_DEFINITION = "FdDtDefinition"; + public const string FD_DT_ASSOCIATION = "FdDtAssociation"; + public const string RS_FD_DEFINITION = "RsFdDefinition"; + public const string FD_REFRESH_DT = "FDRefreshDT"; + #endregion + + //public const string IMPEXP_GETTSTUCTS = "select name,caption from tstructs where blobno=1 and name in (SELECT SNAME FROM AXUSERACCESS WHERE STYPE = 't' AND RNAME IN (select userroles from axuserlevelgroups ul join axusergroups ug on ul.usergroup= ug.groupname where ul.username = '{0}')) order by lower(caption)"; + + public const string IMPEXP_GETTSTRUCTS = "select distinct t.name, t.caption from tstructs t left outer join AXUSERACCESS a on a.sname=t.name and a.stype='t' where (('default' in (select userroles from axuserlevelgroups ul join axusergroups ug on ul.usergroup=ug.groupname where ul.username = '{0}')) or a.rname in (select userroles from axuserlevelgroups ul join axusergroups ug on ul.usergroup=ug.groupname where ul.username = '{0}')) order by 2"; + public const string SQL_GET_AXLANGSOURCE = "Select distinct langname from axlangsource order by langname asc"; + + public const string AXPATTACHMENTPATH = "axpattachmentpath"; + public const string DESIGN_MODE_BTN_HTML = "
  • Design Mode
  • "; + public const string DESIGN_MODE_BTN_HTML_NEW = "
  • domainDesign Mode
  • "; + + + public const string WIZARD_TEMPLATE = "
    "; + + public const string TBL_AXRELATIONS = "select mstruct,dstruct,mfield,dfield from axrelations where rtype='sp' or rtype='md'"; + public const string RS_AXRELATIONS = "RS_AxRelations"; + public const int DEFAULT_DRAFTS_RETAIN_COUNT = 3; + public const string UNIQUE_DRAFT_KEY_PHRASE = "-sad-"; + + //Config Page + public const string CONFIG_LOCK_KEY = "ConfigLock"; + public const string CONFIGAPP_JSON_KEY = "ConfigAppJSON"; + public const string AXAPPS_XML_KEY = "AxAppsXML"; + + //Axpert Web Logs + public const string SQL_GET_AXPWEBLOGS = "SELECT USERNAME, LOGTIME, SESSIONID, IPADDRESS, LOGDETAILS FROM AXPWEBLOGS WHERE TYPE = '$Type$'"; + public const string SQL_SET_AXPWEBLOGS = "INSERT INTO AXPWEBLOGS(USERNAME, LOGTIME, TYPE, SESSIONID, IPADDRESS, LOGDETAILS) VALUES ('$Username$', '$Logtime$', '$Type$', '$Sessionid$', '$Ipaddress$', '$Logdetails$')"; + + // public const string SQL_GET_AXPCONFIGS = "select * from (select A.STYPE, A.STRUCTNAME, A.CONTEXT, A.SFIELD, A.ICOLUMN, A.SBUTTON, A.HLINK, A.PROPS, A.PROPSVAL from axpstructconfig a, axuserlevelgroups b where A.USERROLES = axusergroup and B.AXUSERNAME = '$username$' union all select A.STYPE, A.STRUCTNAME, A.CONTEXT, A.SFIELD, A.ICOLUMN, A.SBUTTON, A.HLINK, A.PROPS, A.PROPSVAL from axpstructconfig a where nvl( USERROLES,'default')= 'default') where stype = '$stype$' and structname = '$transid$'"; + //public const string SQL_GET_AXPCONFIGS = "select * from (select A.STYPE,A.STRUCTNAME, A.CONTEXT, A.SFIELD,A.PROPS, A.PROPSVAL from axpstructconfig a, axuserlevelgroups b where A.USERROLES = axusergroup and B.AXUSERNAME = '$username$' union all select A.STYPE,A.STRUCTNAME, A.CONTEXT, A.SFIELD,A.PROPS, A.PROPSVAL from axpstructconfig a where upper(nvl( USERROLES,'ALL'))= 'ALL') where stype = '$stype$' and structname = '$transid$'"; + public const string SQL_GET_AXPCONFIGS = "SELECT A.STYPE,A.STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a, axuserlevelgroups b WHERE A.USERROLES = axusergroup AND B.AXUSERNAME = '$username$' AND stype = '$stype$' AND structname = '$transid$' AND A.STRUCTNAME NOT LIKE 'ALL%' UNION SELECT A.STYPE,A.STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a WHERE NVL (USERROLES, 'ALL') = 'ALL' AND stype = '$stype$' AND structname = '$transid$' AND A.STRUCTNAME NOT LIKE 'ALL%' UNION SELECT A.STYPE, '$transid$' STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a, axuserlevelgroups b WHERE A.USERROLES = axusergroup AND B.AXUSERNAME = '$username$' AND stype = '$stype$' AND A.STRUCTNAME LIKE 'ALL%' UNION SELECT A.STYPE,'$transid$' STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a WHERE NVL(USERROLES, 'ALL') = 'ALL' AND stype = '$stype$' AND A.STRUCTNAME LIKE 'ALL%'"; + public const string SQL_GET_AXPCONFIGS_MYSQL = "SELECT A.STYPE,A.STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a, axuserlevelgroups b WHERE A.USERROLES = axusergroup AND B.AXUSERNAME = '$username$' AND stype = '$stype$' AND structname = '$transid$' AND A.STRUCTNAME NOT LIKE 'ALL%' UNION SELECT A.STYPE,A.STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a WHERE ifnull(USERROLES, 'ALL') = 'ALL' AND stype = '$stype$' AND structname = '$transid$' AND A.STRUCTNAME NOT LIKE 'ALL%' UNION SELECT A.STYPE, '$transid$' STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a, axuserlevelgroups b WHERE A.USERROLES = axusergroup AND B.AXUSERNAME = '$username$' AND stype = '$stype$' AND A.STRUCTNAME LIKE 'ALL%' UNION SELECT A.STYPE,'$transid$' STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a WHERE ifnull(USERROLES, 'ALL') = 'ALL' AND stype = '$stype$' AND A.STRUCTNAME LIKE 'ALL%'"; + public const string SQL_GET_AXPCONFIGS_MSSQL = "SELECT A.STYPE,A.STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a, axuserlevelgroups b WHERE A.USERROLES = axusergroup AND B.AXUSERNAME = '$username$' AND stype = '$stype$' AND structname = '$transid$' AND A.STRUCTNAME NOT LIKE 'ALL%' UNION SELECT A.STYPE,A.STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a WHERE isnull(USERROLES, 'ALL') = 'ALL' AND stype = '$stype$' AND structname = '$transid$' AND A.STRUCTNAME NOT LIKE 'ALL%' UNION SELECT A.STYPE, '$transid$' STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a, axuserlevelgroups b WHERE A.USERROLES = axusergroup AND B.AXUSERNAME = '$username$' AND stype = '$stype$' AND A.STRUCTNAME LIKE 'ALL%' UNION SELECT A.STYPE,'$transid$' STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a WHERE isnull(USERROLES, 'ALL') = 'ALL' AND stype = '$stype$' AND A.STRUCTNAME LIKE 'ALL%'"; + public const string SQL_GET_AXPCONFIGS_POSTGRESQL = "SELECT A.STYPE,A.STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a, axuserlevelgroups b WHERE A.USERROLES = axusergroup AND B.AXUSERNAME = '$username$' AND stype = '$stype$' AND structname = '$transid$' AND A.STRUCTNAME NOT LIKE 'ALL%' UNION SELECT A.STYPE,A.STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a WHERE COALESCE(USERROLES, 'ALL') = 'ALL' AND stype = '$stype$' AND structname = '$transid$' AND A.STRUCTNAME NOT LIKE 'ALL%' UNION SELECT A.STYPE, '$transid$' STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a, axuserlevelgroups b WHERE A.USERROLES = axusergroup AND B.AXUSERNAME = '$username$' AND stype = '$stype$' AND A.STRUCTNAME LIKE 'ALL%' UNION SELECT A.STYPE,'$transid$' STRUCTNAME,A.CONTEXT,A.SFIELD,A.ICOLUMN,A.SBUTTON,A.HLINK,A.PROPS,A.PROPSVAL FROM axpstructconfig a WHERE COALESCE(USERROLES, 'ALL') = 'ALL' AND stype = '$stype$' AND A.STRUCTNAME LIKE 'ALL%'"; + public const string SQL_GET_TSTRUCTDESIGN = "select * from $tblname$ where lower(transid)=lower('$transid$') and module='$mod$' order by created_on desc"; + public const string SQL_GET_OLDTSTRUCTDESIGN = "select value from axpclouddevsettings where type='axDesign' and lower(TRANID)=lower('$transid$')"; + public const string SQL_GET_AXPGENCONFIGS = "select props,asprops,propsval,structname,stype,userroles,propvalue2 from axpstructconfig where props='General'"; + //Adding for App config + public const string STRUCTTYPE_TSTRUCT = "Tstruct"; + public const string STRUCTTYPE_IVIEW = "Iview"; + public const string CONFIGTYPE_DESIGN = "design"; + public const string CONFIGTYPE_CONFIGS = "configs"; + public const string AXCONFIGURATIONS = "axpconfigurations"; + public const string AXCONFIGURATIONTABLE = "axpConfigTable"; + public const string AXOLDDESIGN = "axOldDesign"; + public const string AXLOGGEDUSER = "axloggedUser"; + public const string AXPAGETITLE = "PageTitle"; + public const string AXHYBRIDINFO = "GetHybridInfo"; + public const string AXHYBRIDNOTIFIINFO = "GetHybridNotifiInfo"; + public const string AXHYBRIDWEIGHTSCALEINFO = "HybridWeightScaleInfo"; + public const string AXCONFIGTSTRUCT = "Tstruct"; + public const string AXCONFIGIVIEW = "Iview"; + public const string AXCONFIGGENERAL = "General"; + public const string AXNODATACONFIGTSTRUCT = "Tstruct"; + public const string AXNODATACONFIGIVIEW = "Iview"; + public const string AXNODATACONFIGGENERAL = "General"; + public const string NOTIFICATION_PHASE = "-notify-"; + public const string SQL_GET_WFPDCOMMENTS = "select wfcomments from ax_wfcomments where wfid='$wfid$' and wfaction='$actiontype$' and stransid='$tid$'"; + public const string SQL_GET_EMAIL = "select EMAIL from axusers where USERNAME ='$USERNAME$'"; + + public const string LBLHL_GETTSTRUCTS = "select caption,ntransid as name from axpdef_tstruct order by caption"; + public const string LBLHL_GETIVIEWS = "select name,caption from dwb_iviews order by caption"; + public const string LBLHL_GETPAGES = "select pageno as name,caption from htmlsections";//"select name,caption from axpages"; + public const string LBLHL_GETTSTRUCTFIELDS = "select caption,name from coretstructhdr where STRANSID=$stransid$"; + public const string LBLHL_GETIVIEWPARAMS = "select pname from dwb_iviewparams where iname=$iname$"; + + public const string AXHYBRID_GETUSERDEVICEID = "select imei_no as deviceid from ax_mobilenotify where username = '$USERNAME$' and projectname = '$PROJECTNAME$'"; +} diff --git a/AW_11.2.0.0_release1/App_Code/DBContext.cs b/AW_11.2.0.0_release1/App_Code/DBContext.cs new file mode 100644 index 0000000..7f8bcdc --- /dev/null +++ b/AW_11.2.0.0_release1/App_Code/DBContext.cs @@ -0,0 +1,1026 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Data; +using System.Configuration; +using System.Security.Cryptography; +using System.Text; +using System.Xml; +using Oracle.DataAccess.Client; +using System.Collections; +using System.Text.RegularExpressions; +using System.Globalization; + +/// +/// Summary description for Iviewdb +/// +public class DBContext +{ + private string db_type = String.Empty; + private string _connectionString = String.Empty; + LogFile.Log logobj = new LogFile.Log(); + FDR objfd; + + public DBContext() + { + + db_type = HttpContext.Current.Session["axdb"].ToString(); + _connectionString = HttpContext.Current.Session["axconstr"].ToString(); + } + + + + public DataTable GetDataTableInline(string query) + { + DataTable dt = new DataTable(); + try + { + Ihelper _helper = new Helper().SetDatabase(db_type, _connectionString); + dt = _helper.ExecuteDataSetSqlInline(query).Tables[0]; + return dt; + } + catch (Exception ex) + { + throw ex; + } + return dt; + } + + public DataSet GetMainPageDataDB(string query) // using for stored procedure call with multi select queries + { + Ihelper _helper = new Helper().SetDatabase(db_type, _connectionString); + DataSet ds = new DataSet(); + try + { + if (db_type.ToLower() == "oracle") + { + logobj.CreateLog("Dashboard ,oracledb-User:" + HttpContext.Current.Session["user"], HttpContext.Current.Session.SessionID, "dashBoard-db", "new"); + _helper.AddInParameter("@IUser", HttpContext.Current.Session["user"], DbType.String); + _helper.AddOutParameter("ORes1", DbType.Object); + _helper.AddOutParameter("ORes2", DbType.Object); + _helper.AddOutParameter("ORes3", DbType.Object); + _helper.AddOutParameter("ORes4", DbType.Object); + _helper.AddOutParameter("ORes5", DbType.Object); + _helper.AddOutParameter("ORes6", DbType.Object); + ds = _helper.ExecuteDataSet("sp_dashboardmultisql"); + } + else if (db_type.ToLower() == "ms sql") + { + logobj.CreateLog("Dashboard mssqldb-User:" + HttpContext.Current.Session["user"], HttpContext.Current.Session.SessionID, "dashBoard-db", "new"); + _helper.AddInParameter("@IUser", HttpContext.Current.Session["user"], DbType.String); + ds = _helper.ExecuteDataSet("sp_dashboardmultisql"); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb") + { + logobj.CreateLog("Dashboard mysqldb-User:" + HttpContext.Current.Session["user"], HttpContext.Current.Session.SessionID, "dashBoard-db", "new"); + _helper.AddInParameter("IUser", HttpContext.Current.Session["user"], DbType.String); + ds = _helper.ExecuteDataSet("sp_dashboardmultisql"); + } + + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + logobj.CreateLog("Dashboard Postgresdb-User:" + HttpContext.Current.Session["user"], HttpContext.Current.Session.SessionID, "dashBoard-db", "new"); + _helper.AddInParameter("IUser", HttpContext.Current.Session["user"], DbType.String); + ds = _helper.ExecuteDataSet("sp_dashboardmultisql"); + + + } + } + + + catch (Exception ex) + { + throw ex; + } + return ds; + } + + public DataSet GetRapidDefData(string procName, string transId) // using for stored procedure call with multi select queries + { + Ihelper _helper = new Helper().SetDatabase(db_type, _connectionString); + DataSet ds = new DataSet(); + try + { + if (db_type.ToLower() == "oracle") + { + logobj.CreateLog("GetRapidDef ,oracledb-Transid:" + transId, HttpContext.Current.Session.SessionID, "GetRapidDefSP-db", "new"); + _helper.AddInParameter("@ITid", transId, DbType.String); + _helper.AddOutParameter("ORes1", DbType.Object); + _helper.AddOutParameter("ORes2", DbType.Object); + ds = _helper.ExecuteDataSet(procName); + } + else if (db_type.ToLower() == "ms sql") + { + _helper.AddInParameter("@ITid", transId, DbType.String); + ds = _helper.ExecuteDataSet(procName); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb") + { + _helper.AddInParameter("ITid", transId, DbType.String); + ds = _helper.ExecuteDataSet(procName); + } + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + + _helper.AddInParameter("ITid", transId, DbType.String); + ds = _helper.ExecuteDataSet(procName); + } + } + catch (Exception ex) + { + throw ex; + } + return ds; + } + public DataSet GetMainPageDBInline(string type) // for inline query call with multi select queries + { + DataSet ds = new DataSet(); + try + { + if (type == "dashboard") + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + string quickl = "select * from axquicklinks where name='" + HttpContext.Current.Session["user"] + "' order by AXQUICKLINKSID asc"; + ds = _helper1.ExecuteDataSetSqlInline(quickl); + + string task = "select * from axtasks where sname='" + HttpContext.Current.Session["user"] + "'"; + ds.Tables.Add("Table1"); + ds.Tables["Table1"].Merge(_helper1.ExecuteDataSetSqlInline(task).Tables[0]); + + string mess = "select * from axmessages where mname='" + HttpContext.Current.Session["user"] + "'"; + ds.Tables.Add("Table2"); + ds.Tables["Table2"].Merge(_helper1.ExecuteDataSetSqlInline(mess).Tables[0]); + + string dbwdetails = "select axp_dbwdetailsid,username,title,widgettype,sqltext,tablehlinks from axp_dbwdetails where username='" + HttpContext.Current.Session["user"] + "'"; + ds.Tables.Add("Table3"); + ds.Tables["Table3"].Merge(_helper1.ExecuteDataSetSqlInline(dbwdetails).Tables[0]); + + string srparams = "select s.* from axp_searchparams s,axp_dbwdetails m where s.WIDGETNAME=m.title and m.username='" + HttpContext.Current.Session["user"] + "'"; + ds.Tables.Add("Table4"); + ds.Tables["Table4"].Merge(_helper1.ExecuteDataSetSqlInline(srparams).Tables[0]); + } + else + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + //string mess = "select * from axmessages where mname='" + HttpContext.Current.Session["user"] + "'"; + //ds = _helper1.ExecuteDataSetSqlInline(mess); + + //string dbwdetails = "select count(*) as rcount from axp_dbwdetails where uname='" + HttpContext.Current.Session["user"] + "'"; + //string dbwdetails = "SELECT count(*) as rcount from axugwidgets u join axp_chartconfig d on u.widgetname = d.axp_chartconfigid where u.axugwidgetsid in (SELECT u.axugwidgetsid from axusers a join axuserlevelgroups b on a.axusersid = b.axusersid join axusergroups c on b.usergroup = c.groupname join axugwidgets u on c.axusergroupsid = u.axusergroupsId where a.username = '" + HttpContext.Current.Session["user"] + "' group by u.axugwidgetsid)"; + string dbwdetails = "SELECT count(*) as rcount from AX_WIDGET ax join AX_WIDGET_ROLE ar on ax.WIDGET_ID = ar.WIDGET_ID WHERE ar.ROLENAME IN(SELECT distinct c.groupname from axusers a join axuserlevelgroups b on a.username = b.username join axusergroups c on b.usergroup = c.groupname where a.username = '" + HttpContext.Current.Session["user"] + "')"; + + //ds.Tables.Add("Table1"); + try + { + ds = _helper1.ExecuteDataSetSqlInline(dbwdetails); + } + catch (Exception ex) + { + return ds; + } + } + } + catch (Exception ex) + { + throw ex; + } + return ds; + } + + public DataSet GetMainPageDBTableInline(string querys, string fltParams, string widgetId) // single select query call + { + if (HttpContext.Current.Session["FDR"] != null) + objfd = (FDR)HttpContext.Current.Session["FDR"]; + else + objfd = new FDR(); + DataSet ds = new DataSet(); + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + List widgets = widgetId.Split(';').ToList(); + string uName = "username:" + HttpContext.Current.Session["user"]; + if (fltParams != "") + fltParams = uName + "~" + fltParams; + else + fltParams = uName; + for (int i = 0; i < widgets.Count; i++) + { + DataTable dt = new DataTable(); + dt = objfd.GetDashBoardData(widgets[i].ToString(), fltParams); + if (dt == null || dt.Rows.Count == 0) + { + string subQuery = querys.Split(';')[i]; + subQuery = subQuery.Replace(":username", "'" + HttpContext.Current.Session["user"] + "'").ToString(); + subQuery = subQuery.Replace(":USERNAME", "'" + HttpContext.Current.Session["user"] + "'").ToString(); + if (!string.IsNullOrEmpty(fltParams)) + { + try + { + for (int prCount = 0; prCount < fltParams.Split('~').Length; prCount++) + { + string paramValue = fltParams.Split('~')[prCount]; + subQuery = subQuery.Replace(":" + paramValue.Split(':')[0].ToLower(), "'" + paramValue.Split(':')[1].ToString() + "'").ToString(); + subQuery = subQuery.Replace(":" + paramValue.Split(':')[0].ToUpper(), "'" + paramValue.Split(':')[1].ToString() + "'").ToString(); + } + } + catch (Exception ex) + { + logobj.CreateLog("filter params " + ex.Message, "dashBoard-filter", "filter-exception", "new"); + } + } + subQuery = Regex.Replace(subQuery, @"(:)\w+", "''").ToString(); + if (subQuery != "") + { + string query = subQuery.Replace(" ", " "); + ds.Tables.Add("Table" + i + ""); + try + { + ds.Tables["Table" + i + ""].Merge(_helper1.ExecuteDataSetSqlInline(query).Tables[0]); + } + catch (Exception ex) + { + logobj.CreateLog("Dashboard-sql " + ex.Message, query, "sqlquery-exception", "new"); + } + } + } + else + { + ds.Tables.Add("Table" + i + ""); + ds.Tables["Table" + i + ""].Merge(dt); + } + } + } + catch (Exception ex) + { + logobj.CreateLog("Dashboard " + ex.Message, HttpContext.Current.Session.SessionID, "dashBoard-exception", "new"); + } + return ds; + } + + public DataSet GetSearchData(string querys, int limit) // single select query call + { + DataSet ds = new DataSet(); + try + { + querys = querys.Replace(":username", "'" + HttpContext.Current.Session["user"] + "'").ToString(); + querys = querys.Replace(":USERNAME", "'" + HttpContext.Current.Session["user"] + "'").ToString(); + + if (db_type.ToLower() == "oracle") + { + querys = querys + "and rownum <= " + limit.ToString(); + } + else if (db_type.ToLower() == "ms sql") + { + querys = querys.Replace("select", "select TOP " + limit.ToString()); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb") + { + querys = querys.Replace(@"\", "\\\\"); + querys = querys + " limit " + limit.ToString(); + } + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + querys = querys.Replace(@"\", "\\\\"); + querys = querys + " limit " + limit.ToString(); + + } + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + ds = _helper1.ExecuteDataSetSqlInline(querys); + if (HttpContext.Current.Session["AxDirectDBException"] != null) + { + string exMSg = HttpContext.Current.Session["AxDirectDBException"].ToString(); + HttpContext.Current.Session.Remove("AxDirectDBException"); + //ds.Tables.Add(CreateExcTable(exMSg)); + } + } + catch (Exception ex) + { + logobj.CreateLog("SearchData " + ex.Message, HttpContext.Current.Session.SessionID, "SearchData-exception", "new"); + } + + return ds; + } + + private DataTable CreateExcTable(string excMessage) + { + DataTable dt = new DataTable(); + dt.TableName = "AxException"; + dt.Columns.Add("exp"); + DataRow dr = dt.NewRow(); + dr[0] = excMessage; + dt.Rows.Add(dr); + dt.AcceptChanges(); + return dt; + } + + public bool ExecuteSqlQueryInline(string query) // insert, update & delete query call + { + bool flagcount = false; + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + flagcount = _helper1.ExecuteNonQuerySqlinline(query) == 1 ? true : false; + } + catch (Exception ex) + { + throw ex; + } + return flagcount; + } + + private static void SessExpires() + { + string url = Convert.ToString(HttpContext.Current.Application["SessExpiryPath"]); + HttpContext.Current.Response.Write(""); + } + + public DataSet InsertMainPageDBTableInline(string linkName, string linkUrl) // insert, update & delete query call + { + DataSet ds = new DataSet(); + try + { + if (HttpContext.Current.Session["user"] != null) + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + var query = ""; + if (db_type.ToLower() == "oracle") + query = "insert into axquicklinks(axquicklinksid,name,linkname,linkurl) values(axquicklinks_seq.NEXTVAL,'" + HttpContext.Current.Session["user"] + "','" + linkName + "','" + linkUrl + "')"; + else + query = "insert into axquicklinks(name,linkname,linkurl) values('" + HttpContext.Current.Session["user"] + "','" + linkName + "','" + linkUrl + "')"; + + if (_helper1.ExecuteNonQuerySqlinline(query) == 1) + { + ds = _helper1.ExecuteDataSetSqlInline("select max(AXQUICKLINKSID) AS ID from axquicklinks"); + } + } + else + { + SessExpires(); + } + } + catch (Exception ex) + { + throw ex; + } + return ds; + } + + public DataSet GetChoices(string sql, string session) + { + Ihelper _helper = new Helper().SetDatabase(db_type, _connectionString); + DataSet Ds = new DataSet(); + try + { + if (db_type.ToLower() == "oracle") + { + + _helper.AddInParameter("Isql", sql, DbType.String); + _helper.AddInParameter("IsessionID", session, DbType.String); + _helper.AddInOutParameter("p_return_cur", DbType.Object); + } + else + { + _helper.AddInParameter("@Isql", sql, DbType.String); + _helper.AddInParameter("@IsessionID", session, DbType.String); + } + + Ds = _helper.ExecuteDataSet("sp_getchoices"); + + //if(db_type.ToLower() == "mysql") + //{ + // Ds = GetResultXML(Ds); + //} + } + catch (Exception ex) + { + throw ex; + } + return Ds; + } + + //private DataSet GetResultXML(DataSet Ds) + //{ + // if (Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0) + // { + // if (Ds.Tables[0].Rows[0][0].ToString() != "done" && !Ds.Tables[0].Rows[0][0].ToString().Trim().StartsWith("")) + // { + // Ds.DataSetName = "response"; + // Ds.Tables[0].TableName = "row"; + // string xmlRes = Ds.GetXml(); + // xmlRes = "" + xmlRes + ""; + // DataTable table = Ds.Tables[0]; + // if (Ds.Tables.CanRemove(table)) + // { + // Ds.Tables.Remove(table); + // } + // // create new table + // DataTable newDT = new DataTable("row"); + // newDT.Columns.Add("result", typeof(string)); + // Ds.Tables.Add(newDT); + // DataRow row = newDT.NewRow(); + // newDT.Rows.Add(row); + // Ds.Tables[0].Rows[0][0] = xmlRes; + + // } + // } + // return Ds; + //} + + + + public DataSet GetIviewStructure(string iviewname) + { + + Ihelper _helper = new Helper().SetDatabase(db_type, _connectionString); + DataSet ds = new DataSet(); + try + { + string lang = string.IsNullOrEmpty(HttpContext.Current.Session["language"].ToString()) ? string.Empty : + (HttpContext.Current.Session["language"].ToString()); + _helper.AddInParameter("@Iiviewname", iviewname, DbType.String); + _helper.AddInParameter("@ILanguage", lang, DbType.String); + + + if (db_type.ToLower() == "oracle") + _helper.AddOutParameter("Ocur1", DbType.Object); + + ds = _helper.ExecuteDataSet("sp_GetIviewStructure"); + } + catch (Exception ex) + { + logobj.CreateLog("call get Iview structure Direct -" + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "directDB", string.Empty); + throw ex; + } + return ds; + } + + + public DataSet GetIviewDataDB(string query, string pageno, string pageSize, bool isGrandtol) + { + Ihelper _helper = new Helper().SetDatabase(db_type, _connectionString); + DataSet ds = new DataSet(); + try + { + _helper.AddInParameter("@ISql", query, DbType.String); + _helper.AddInParameter("@INoofRec", pageSize, DbType.String); + _helper.AddInParameter("@IpageNo", pageno, DbType.String); + + //New parameters added + isGrandtol = true; + _helper.AddInParameter("@ICountFlag", isGrandtol == false ? 0 : 1, DbType.String); + + if (db_type.ToLower() == "oracle") + { + _helper.AddOutParameter("OIviewCount", DbType.Object); + _helper.AddOutParameter("OResult", DbType.Object); + } + ds = _helper.ExecuteDataSet("GetIview"); + } + catch (Exception ex) + { + throw ex; + } + return ds; + } + + + public DataSet GetIviewDataDBInline(string query, string pageno, string pageSize, bool isGrandtol) + { + DataSet ds = new DataSet(); + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + string pagination = "select a.* from (select rownum as rowno, '' as axrowtype, a.* from ( " + query + ")a )a "; + pagination += " where rowno between " + ((int.Parse(pageno) - 1) * (int.Parse(pageSize)) + 1) + " and " + (int.Parse(pageno) * int.Parse(pageSize)); + + ds = _helper1.ExecuteDataSetSqlInline(pagination); + if (isGrandtol == true) + { + string count = "select count(*) as IVIEWCOUNT from (" + query + ")a "; + ds.Tables.Add("Table1"); + ds.Tables["Table1"].Merge(_helper1.ExecuteDataSetSqlInline(count).Tables[0]); + } + } + catch (Exception ex) + { + throw ex; + } + return ds; + } + //Added on 15-07-2016 for direct db call to get pdflist values for tstruct + + public string GetPDFList(string trasnsid, string sessionid) + { + Ihelper _helper = new Helper().SetDatabase(db_type, _connectionString); + DataSet ds = new DataSet(); + try + { + _helper.AddInParameter("@p_Itid", trasnsid, DbType.String); + _helper.AddInParameter("@IsessionID", sessionid, DbType.String); + if (db_type.ToLower() == "oracle") + _helper.AddOutParameter("p_return_cur", DbType.Object); + ds = _helper.ExecuteDataSet("sp_GetPDFList"); + } + catch (Exception ex) + { + throw ex; + } + + if ((ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0)) + return ds.Tables[0].Rows[0][0].ToString(); + else + return string.Empty; + } + + public DataSet GetAxConfigurations(string transid, string structType, bool tstDesing, string configType) + { + DataSet ds = new DataSet(); + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + string sqlTstDesign = string.Empty; + string SqlQuery = string.Empty; + string username = string.Empty; + if (HttpContext.Current.Session["user"] != null) + username = HttpContext.Current.Session["user"].ToString(); + if (configType == "" || configType == "configs") + { + if (db_type.ToLower() == "oracle") + SqlQuery = Constants.SQL_GET_AXPCONFIGS; + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb") + SqlQuery = Constants.SQL_GET_AXPCONFIGS_MYSQL; + else if (db_type.ToLower() == "ms sql") + SqlQuery = Constants.SQL_GET_AXPCONFIGS_MSSQL; + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + SqlQuery = Constants.SQL_GET_AXPCONFIGS_POSTGRESQL; + + SqlQuery = SqlQuery.Replace("$username$", username); + SqlQuery = SqlQuery.Replace("$stype$", structType); + SqlQuery = SqlQuery.Replace("$transid$", transid); + } + if (structType == "Tstruct" && (configType == "design" || configType == "")) + { + sqlTstDesign = Constants.SQL_GET_TSTRUCTDESIGN; + if (tstDesing) + sqlTstDesign = sqlTstDesign.Replace("$tblname$", "AX_LAYOUTDESIGN_SAVED"); + else + sqlTstDesign = sqlTstDesign.Replace("$tblname$", "AX_LAYOUTDESIGN"); + sqlTstDesign = sqlTstDesign.Replace("$transid$", transid); + sqlTstDesign = sqlTstDesign.Replace("$mod$", "TSTRUCT"); + if (SqlQuery != "") + SqlQuery += ";" + sqlTstDesign; + else + SqlQuery = sqlTstDesign; + } + + try + { + ds = _helper1.ExecuteDataSetSqlConfig(SqlQuery); + } + catch (Exception ex) + { + logobj.CreateLog("Get AxConfigurations DB Exception - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "GetAxConfigurations-db", string.Empty, "true"); + return ds; + } + } + catch (Exception ex) + { + logobj.CreateLog("Get AxConfigurations - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "GetAxConfigurations", string.Empty, "true"); + throw ex; + } + return ds; + } + + public string GetAxOldDesign(string transid) + { + string oldDesign = string.Empty; + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + string SqlQuery = Constants.SQL_GET_OLDTSTRUCTDESIGN; + SqlQuery = SqlQuery.Replace("$transid$", transid); + try + { + DataSet dsOldDesing = new DataSet(); + dsOldDesing = _helper1.ExecuteDataSetSqlConfig(SqlQuery); + if (dsOldDesing.Tables[0].Rows.Count > 0) + oldDesign = dsOldDesing.Tables[0].Rows[0][0].ToString(); + } + catch (Exception ex) + { + logobj.CreateLog("Get AxOldDesign DB Exception - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "GetAxOldDesign-db", string.Empty, "true"); + return oldDesign; + } + } + catch (Exception ex) + { + logobj.CreateLog("Get AxOldDesign - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "GetAxOldDesign", string.Empty, "true"); + throw ex; + } + return oldDesign; + } + + public string GetAxNewDesign(string transid) + { + string newDesign = string.Empty; + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + string SqlQuery = Constants.SQL_GET_TSTRUCTDESIGN; + SqlQuery = SqlQuery.Replace("$tblname$", "AX_LAYOUTDESIGN"); + SqlQuery = SqlQuery.Replace("$transid$", transid); + SqlQuery = SqlQuery.Replace("$mod$", "TSTRUCT"); + try + { + DataSet dsNewDesing = new DataSet(); + dsNewDesing = _helper1.ExecuteDataSetSqlConfig(SqlQuery); + if (dsNewDesing.Tables[0].Rows.Count > 0) + newDesign = dsNewDesing.Tables[0].Rows[0]["CONTENT"].ToString(); + } + catch (Exception ex) + { + logobj.CreateLog("Get GetAxNewDesign DB Exception - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "GetAxNewDesign-db", string.Empty, "true"); + return newDesign; + } + } + catch (Exception ex) + { + logobj.CreateLog("Get GetAxNewDesign - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "GetAxNewDesign", string.Empty, "true"); + throw ex; + } + return newDesign; + } + + public string SaveDesignJson(string transid, string designContent) + { + string SaveId = string.Empty; + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + string SqlQuery = string.Empty; + string username = string.Empty; + if (HttpContext.Current.Session["user"] != null) + username = HttpContext.Current.Session["user"].ToString(); + SqlQuery = "select DESIGN_ID from AX_LAYOUTDESIGN_SAVED where transid='" + transid + "'"; + DataSet dsNewDesing = new DataSet(); + dsNewDesing = _helper1.ExecuteDataSetSqlInline(SqlQuery); + if (dsNewDesing.Tables[0].Rows.Count > 0 && dsNewDesing.Tables[0].Rows[0]["DESIGN_ID"].ToString() != "") + { + Ihelper _helper2 = new Helper().SetDatabase(db_type, _connectionString); + if (db_type.ToLower() == "oracle") + { + SqlQuery = "update AX_LAYOUTDESIGN_SAVED SET CONTENT=:CONTENT,MODULE='TSTRUCT',UPDATED_BY='" + username + "',is_deleted='N',is_publish='N',updated_on=CURRENT_TIMESTAMP where transid='" + transid + "'"; + _helper2.AddInParameter(":CONTENT", designContent, DbType.String); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb" || db_type.ToLower() == "ms sql") + { + SqlQuery = "update AX_LAYOUTDESIGN_SAVED SET CONTENT=@CONTENT,MODULE='TSTRUCT',UPDATED_BY='" + username + "',is_deleted='N',is_publish='N',updated_on=CURRENT_TIMESTAMP where transid='" + transid + "'"; + _helper2.AddInParameter("@CONTENT", designContent, DbType.String); + } + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + SqlQuery = "update AX_LAYOUTDESIGN_SAVED SET CONTENT=:CONTENT,MODULE='TSTRUCT',UPDATED_BY='" + username + "',is_deleted='N',is_publish='N',updated_on=CURRENT_TIMESTAMP where transid='" + transid + "'"; + _helper2.AddInParameter(":CONTENT", designContent, DbType.String); + } + + if (_helper2.ExecuteNonQuerySqlinline(SqlQuery) == 1) + SaveId = dsNewDesing.Tables[0].Rows[0]["DESIGN_ID"].ToString(); + } + else + { + Ihelper _helper2 = new Helper().SetDatabase(db_type, _connectionString); + if (db_type.ToLower() == "oracle") + { + SqlQuery = "insert into AX_LAYOUTDESIGN_SAVED (TRANSID,CONTENT,MODULE,CREATED_BY) values ('" + transid + "',:CONTENT,'TSTRUCT','" + username + "')"; + _helper2.AddInParameter(":CONTENT", designContent, DbType.String); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb" || db_type.ToLower() == "ms sql") + { + SqlQuery = "insert into AX_LAYOUTDESIGN_SAVED (TRANSID,CONTENT,MODULE,CREATED_BY) values ('" + transid + "',@CONTENT,'TSTRUCT','" + username + "')"; + _helper2.AddInParameter("@CONTENT", designContent, DbType.String); + } + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + SqlQuery = "insert into AX_LAYOUTDESIGN_SAVED (TRANSID,CONTENT,MODULE,CREATED_BY) values ('" + transid + "',:CONTENT,'TSTRUCT','" + username + "')"; + _helper2.AddInParameter(":CONTENT", designContent, DbType.String); + } + if (_helper2.ExecuteNonQuerySqlinline(SqlQuery) == 1) + { + SqlQuery = "select DESIGN_ID from AX_LAYOUTDESIGN_SAVED where transid='" + transid + "'"; + Ihelper _helper3 = new Helper().SetDatabase(db_type, _connectionString); + dsNewDesing = _helper3.ExecuteDataSetSqlInline(SqlQuery); + if (dsNewDesing.Tables[0].Rows.Count > 0 && dsNewDesing.Tables[0].Rows[0]["DESIGN_ID"].ToString() != "") + SaveId = dsNewDesing.Tables[0].Rows[0]["DESIGN_ID"].ToString(); + } + } + } + catch (Exception ex) + { + logobj.CreateLog("Get SaveDesignJson - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "SaveDesignJson", string.Empty, "true"); + } + return SaveId; + } + + public string PublishDesignJson(string transid, string SavedId) + { + string PublishId = string.Empty; + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + string SqlQuery = string.Empty; + string username = string.Empty; + if (HttpContext.Current.Session["user"] != null) + username = HttpContext.Current.Session["user"].ToString(); + SqlQuery = "select DESIGN_ID,TRANSID,CONTENT,MODULE,CREATED_BY,RESPONSIBILITY,PARENT_DESIGN_ID from AX_LAYOUTDESIGN_SAVED where TRANSID='" + transid + "';select DESIGN_ID from AX_LAYOUTDESIGN where TRANSID='" + transid + "';"; + DataSet dsNewDesing = new DataSet(); + dsNewDesing = _helper1.ExecuteDataSetSqlConfig(SqlQuery); + if (dsNewDesing.Tables.Count > 0) + { + string Content = string.Empty, Module = string.Empty, Created_by = string.Empty, Updated_by = string.Empty, P_Design_Id = string.Empty; + if (dsNewDesing.Tables["Table0"].Rows.Count > 0) + { + if (SavedId == "") + SavedId = dsNewDesing.Tables["Table0"].Rows[0]["DESIGN_ID"].ToString(); + Content = dsNewDesing.Tables["Table0"].Rows[0]["CONTENT"].ToString(); + Module = dsNewDesing.Tables["Table0"].Rows[0]["MODULE"].ToString(); + Updated_by = Created_by = dsNewDesing.Tables["Table0"].Rows[0]["CREATED_BY"].ToString(); + P_Design_Id = dsNewDesing.Tables["Table0"].Rows[0]["PARENT_DESIGN_ID"].ToString(); + + if (dsNewDesing.Tables["Table1"].Rows.Count > 0 && dsNewDesing.Tables["Table1"].Rows[0]["DESIGN_ID"].ToString() != "") + { + Ihelper _helper2 = new Helper().SetDatabase(db_type, _connectionString); + if (db_type.ToLower() == "oracle") + { + SqlQuery = "update AX_LAYOUTDESIGN SET CONTENT=:CONTENT,MODULE='" + Module + "',UPDATED_BY='" + Updated_by + "',UPDATED_ON=CURRENT_TIMESTAMP where TRANSID='" + transid + "'"; + _helper2.AddInParameter(":CONTENT", Content, DbType.String); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb" || db_type.ToLower() == "ms sql") + { + SqlQuery = "update AX_LAYOUTDESIGN SET CONTENT=@CONTENT,MODULE='" + Module + "',UPDATED_BY='" + Updated_by + "',UPDATED_ON=CURRENT_TIMESTAMP where TRANSID='" + transid + "'"; + _helper2.AddInParameter("@CONTENT", Content, DbType.String); + } + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + SqlQuery = "update AX_LAYOUTDESIGN SET CONTENT=:CONTENT,MODULE='" + Module + "',UPDATED_BY='" + Updated_by + "',UPDATED_ON=CURRENT_TIMESTAMP where TRANSID='" + transid + "'"; + _helper2.AddInParameter(":CONTENT", Content, DbType.String); + } + + + if (_helper2.ExecuteNonQuerySqlinline(SqlQuery) == 1) + { + SqlQuery = "select DESIGN_ID from AX_LAYOUTDESIGN where TRANSID='" + transid + "'"; + Ihelper _helper3 = new Helper().SetDatabase(db_type, _connectionString); + dsNewDesing = _helper3.ExecuteDataSetSqlInline(SqlQuery); + if (dsNewDesing.Tables[0].Rows.Count > 0 && dsNewDesing.Tables[0].Rows[0]["DESIGN_ID"].ToString() != "") + P_Design_Id = PublishId = dsNewDesing.Tables[0].Rows[0]["DESIGN_ID"].ToString(); + } + } + else + { + Ihelper _helper2 = new Helper().SetDatabase(db_type, _connectionString); + if (db_type.ToLower() == "oracle") + { + SqlQuery = "insert into AX_LAYOUTDESIGN (TRANSID,CONTENT,MODULE,CREATED_BY) values ('" + transid + "',:CONTENT,'" + Module + "','" + Created_by + "')"; + _helper2.AddInParameter(":CONTENT", Content, DbType.String); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb" || db_type.ToLower() == "ms sql") + { + SqlQuery = "insert into AX_LAYOUTDESIGN (TRANSID,CONTENT,MODULE,CREATED_BY) values ('" + transid + "',@CONTENT,'" + Module + "','" + Created_by + "')"; + _helper2.AddInParameter("@CONTENT", Content, DbType.String); + } + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + SqlQuery = "insert into AX_LAYOUTDESIGN (TRANSID,CONTENT,MODULE,CREATED_BY) values ('" + transid + "',:CONTENT,'" + Module + "','" + Created_by + "')"; + _helper2.AddInParameter(":CONTENT", Content, DbType.String); + } + + + if (_helper2.ExecuteNonQuerySqlinline(SqlQuery) == 1) + { + SqlQuery = "select DESIGN_ID from AX_LAYOUTDESIGN where TRANSID='" + transid + "'"; + Ihelper _helper3 = new Helper().SetDatabase(db_type, _connectionString); + dsNewDesing = _helper3.ExecuteDataSetSqlInline(SqlQuery); + if (dsNewDesing.Tables[0].Rows.Count > 0 && dsNewDesing.Tables[0].Rows[0]["DESIGN_ID"].ToString() != "") + P_Design_Id = PublishId = dsNewDesing.Tables[0].Rows[0]["DESIGN_ID"].ToString(); + } + } + + if (PublishId != string.Empty) + { + Ihelper _helper4 = new Helper().SetDatabase(db_type, _connectionString); + SqlQuery = "update AX_LAYOUTDESIGN_SAVED SET PARENT_DESIGN_ID='" + P_Design_Id + "',IS_PUBLISH='Y' where DESIGN_ID='" + SavedId + "'"; + if (_helper4.ExecuteNonQuerySqlinline(SqlQuery) == 1) + return PublishId; + } + } + } + } + catch (Exception ex) + { + logobj.CreateLog("Get PublishDesignJson - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "PublishDesignJson", string.Empty, "true"); + } + return PublishId; + } + + public string ResetDesignJson(string transid, string SavedId) + { + string Reset = string.Empty; + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + string SqlQuery = string.Empty; + string username = string.Empty; + if (HttpContext.Current.Session["user"] != null) + username = HttpContext.Current.Session["user"].ToString(); + SqlQuery = "select DESIGN_ID from AX_LAYOUTDESIGN_SAVED where TRANSID='" + transid + "'"; + DataSet dsNewDesing = new DataSet(); + dsNewDesing = _helper1.ExecuteDataSetSqlInline(SqlQuery); + if (dsNewDesing.Tables[0].Rows.Count > 0 && dsNewDesing.Tables[0].Rows[0]["DESIGN_ID"].ToString() != "") + { + SqlQuery = "DELETE from AX_LAYOUTDESIGN_SAVED where transid='" + transid + "'"; + _helper1.ExecuteNonQuerySqlinline(SqlQuery); + Ihelper _helper2 = new Helper().SetDatabase(db_type, _connectionString); + SqlQuery = "DELETE from AX_LAYOUTDESIGN where transid='" + transid + "'"; + _helper2.ExecuteNonQuerySqlinline(SqlQuery); + Reset = "reseted"; + } + else + Reset = "500"; + } + catch (Exception ex) + { + logobj.CreateLog("Get ResetDesignJson - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "ResetDesignJson", string.Empty, "true"); + } + return Reset; + } + + public string SavePublishDesign(string transid, string designContent, string SavedId) + { + string SaveId = string.Empty, PublishId = string.Empty; + try + { + SaveId = SaveDesignJson(transid, designContent); + PublishId = PublishDesignJson(transid, SavedId); + } + catch (Exception ex) + { + logobj.CreateLog("Get SavePublishDesign - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "SavePublishDesign", string.Empty, "true"); + } + return SaveId + "~" + PublishId; + } + + public void SaveExecutionTrace(string logtext) + { + try + { + string SqlQuery = string.Empty; + string userName = string.Empty; + if (HttpContext.Current.Session["username"] != null) + userName = HttpContext.Current.Session["username"].ToString(); + string sessId = HttpContext.Current.Session.SessionID; + Ihelper _helper2 = new Helper().SetDatabase(db_type, _connectionString); + if (db_type.ToLower() == "oracle") + { + SqlQuery = "insert into axp_webtrace (USERNAME,SESSIONID,DATETIME,LOGTEXT) values ('" + userName + "','" + sessId + "',CURRENT_TIMESTAMP,:LOGTEXT)"; + _helper2.AddInParameter(":LOGTEXT", logtext, DbType.String); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb" || db_type.ToLower() == "ms sql") + { + SqlQuery = "insert into axp_webtrace (USERNAME,SESSIONID,DATETIME,LOGTEXT) values ('" + userName + "','" + sessId + "',CURRENT_TIMESTAMP,@LOGTEXT)"; + _helper2.AddInParameter("@LOGTEXT", logtext, DbType.String); + } + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + SqlQuery = "insert into axp_webtrace (USERNAME,SESSIONID,DATETIME,LOGTEXT) values ('" + userName + "','" + sessId + "',CURRENT_TIMESTAMP,:LOGTEXT)"; + _helper2.AddInParameter(":LOGTEXT", logtext, DbType.String); + } + _helper2.ExecuteNonQuerySqlinline(SqlQuery); + } + catch (Exception ex) + { + logobj.CreateLog("SaveExecutionTrace - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "SaveExecutionTrace", string.Empty, "true"); + } + } + + public void SaveMobileNotification(string guid, string fb_Id, string imei_no, string status) + { + try + { + string SqlQuery = string.Empty; + string userName = string.Empty; + if (HttpContext.Current.Session["username"] != null) + userName = HttpContext.Current.Session["username"].ToString(); + string projectName = HttpContext.Current.Session["project"].ToString(); + string sessId = HttpContext.Current.Session.SessionID; + SqlQuery = "select * from ax_mobilenotify where username='" + userName + "' and projectname='" + projectName + "'"; + DataSet dtMn = new DataSet(); + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + dtMn = _helper1.ExecuteDataSetSqlInline(SqlQuery); + if (dtMn.Tables[0].Rows.Count > 0) + { + Ihelper _helper2 = new Helper().SetDatabase(db_type, _connectionString); + SqlQuery = "update ax_mobilenotify SET GUID='" + guid + "',FIREBASE_ID='" + fb_Id + "',IMEI_NO='" + imei_no + "',STATUS='" + (status == "true" ? "t" : "f") + "' where username='" + userName + "' and projectname='" + projectName + "'"; + _helper2.ExecuteNonQuerySqlinline(SqlQuery); + } + else + { + Ihelper _helper2 = new Helper().SetDatabase(db_type, _connectionString); + SqlQuery = "insert into ax_mobilenotify (USERNAME,PROJECTNAME,GUID,FIREBASE_ID,IMEI_NO,STATUS) values ('" + userName + "','" + HttpContext.Current.Session["project"].ToString() + "','" + sessId + "','" + fb_Id + "','" + imei_no + "','" + (status == "true" ? "t" : "f") + "')"; + _helper2.ExecuteNonQuerySqlinline(SqlQuery); + } + } + catch (Exception ex) + { + logobj.CreateLog("SaveMobileNotification - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "SaveMobileNotification", string.Empty, "true"); + } + } + + public string GetSearchViewColumns(string transId) + { + string vcSelected = string.Empty; + try + { + Ihelper _helper1 = new Helper().SetDatabase(db_type, _connectionString); + string SqlQuery = string.Empty; + string username = string.Empty; + if (HttpContext.Current.Session["user"] != null) + username = HttpContext.Current.Session["user"].ToString(); + SqlQuery = "Select PROPS from searchdef where transid='" + transId + "' and username='" + username + "' order by userlevel desc"; + DataSet tblVCS = new DataSet(); + tblVCS = _helper1.ExecuteDataSetSqlInline(SqlQuery); + if (tblVCS.Tables[0].Rows.Count > 0 && tblVCS.Tables[0].Rows[0]["PROPS"].ToString() != "") + { + vcSelected = tblVCS.Tables[0].Rows[0]["PROPS"].ToString(); + } + } + catch (Exception ex) + { + logobj.CreateLog("GetSearchViewColumns - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "GetSearchViewColumns", string.Empty, "true"); + } + return vcSelected; + } + + public void SaveSearchViewColumns(string transId, string selectedFlds, bool isViewColUpdate) + { + try + { + string SqlQuery = string.Empty; + string userName = string.Empty; + if (HttpContext.Current.Session["username"] != null) + userName = HttpContext.Current.Session["username"].ToString(); + string sessId = HttpContext.Current.Session.SessionID; + Ihelper _helper2 = new Helper().SetDatabase(db_type, _connectionString); + //selectedFlds = "189,388,350,590,1~~~~" + selectedFlds; + selectedFlds = selectedFlds.Replace("~", "\r\n"); + if (isViewColUpdate) + { + if (db_type.ToLower() == "oracle") + { + SqlQuery = "update searchdef SET PROPS=:PROPS,USERLEVEL=3 where TRANSID='" + transId + "' and USERNAME='" + userName + "'"; + _helper2.AddInParameter(":PROPS", selectedFlds, DbType.String); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb" || db_type.ToLower() == "ms sql") + { + SqlQuery = "update searchdef SET PROPS=@PROPS,USERLEVEL=3 where TRANSID='" + transId + "' and USERNAME='" + userName + "'"; + _helper2.AddInParameter("@PROPS", selectedFlds, DbType.String); + } + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + SqlQuery = "update searchdef SET PROPS=:PROPS,USERLEVEL=3 where TRANSID='" + transId + "' and USERNAME='" + userName + "'"; + _helper2.AddInParameter(":PROPS", selectedFlds, DbType.String); + } + } + else + { + if (db_type.ToLower() == "oracle") + { + SqlQuery = "insert into searchdef (TRANSID, USERNAME, PROPS, USERLEVEL, SMODE) values ('" + transId + "','" + userName + "',:PROPS,3,'c')"; + _helper2.AddInParameter(":PROPS", selectedFlds, DbType.String); + } + else if (db_type.ToLower() == "mysql" || db_type.ToLower() == "mariadb" || db_type.ToLower() == "ms sql") + { + SqlQuery = "insert into searchdef (TRANSID, USERNAME, PROPS, USERLEVEL, SMODE) values ('" + transId + "','" + userName + "',@PROPS,3,'c')"; + _helper2.AddInParameter("@PROPS", selectedFlds, DbType.String); + } + else if (db_type.ToLower() == "postgresql" || db_type.ToLower() == "postgre") + { + SqlQuery = "insert into searchdef (TRANSID, USERNAME, PROPS, USERLEVEL, SMODE) values ('" + transId + "','" + userName + "',:PROPS,3,'c')"; + _helper2.AddInParameter(":PROPS", selectedFlds, DbType.String); + } + } + _helper2.ExecuteNonQuerySqlinline(SqlQuery); + } + catch (Exception ex) + { + logobj.CreateLog("SaveSearchViewColumns - " + ex.Message + "", HttpContext.Current.Session["nsessionid"].ToString(), "SaveSearchViewColumns", string.Empty, "true"); + } + } +} + + + + + diff --git a/AW_11.2.0.0_release1/App_Code/TStructData.cs b/AW_11.2.0.0_release1/App_Code/TStructData.cs new file mode 100644 index 0000000..9d66f36 --- /dev/null +++ b/AW_11.2.0.0_release1/App_Code/TStructData.cs @@ -0,0 +1,8187 @@ +#region NameSpaces + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Web; +using System.Xml; +#endregion + +#region TstructData Class +/// +/// TstructData class stores all the field related data like, field Name,value,oldvalue,componentname +/// rowno,frameno. Using this fieldvaluexml is constructed and stored in a string. +/// +[Serializable()] +public class TStructData +{ + #region Attributes + /// + /// Declaration of all attributes related to Tstruct Data Class + /// + public ArrayList fieldIndexArray = new ArrayList(); + public ArrayList fieldName = new ArrayList(); + public ArrayList fieldFrameNo = new ArrayList(); + public ArrayList fieldControlName = new ArrayList(); + public ArrayList fieldRowNo = new ArrayList(); + public ArrayList fieldValue = new ArrayList(); + public ArrayList fieldOldValue = new ArrayList(); + public ArrayList fieldIdValue = new ArrayList(); + public ArrayList fieldOldIdValue = new ArrayList(); + public ArrayList dcRowCntVals = new ArrayList(); + public ArrayList fieldRowValues = new ArrayList(); + public ArrayList fldIdCol = new ArrayList(); + public ArrayList fldMasterRow = new ArrayList(); + public ArrayList fieldDPMVals = new ArrayList(); + public ArrayList fieldDPVals = new ArrayList(); + public ArrayList ChangedDcs = new ArrayList(); + public ArrayList DelRowFldsXml = new ArrayList(); + public ArrayList newRowNos = new ArrayList(); + public ArrayList oldRowNos = new ArrayList(); + // TODO: Get the attachment files from the client and update the attachment array in the object. + public ArrayList attachArray = new ArrayList(); + public String fieldValueXml = string.Empty; + private StringBuilder dsDataXML = new StringBuilder(); + public String fgFieldValueXml = string.Empty; + public String popFGFieldValueXml = string.Empty; + public String transactionID = string.Empty; + public String recordID = string.Empty; + private string jsonString = string.Empty; + private string defaultDateStr = "dd/mm/yyyy"; + public ArrayList imageFldNames = new ArrayList(); + public ArrayList imageFldSrc = new ArrayList(); + ArrayList depFormatDcs = new ArrayList(); + public StringBuilder tabJson = new StringBuilder(); + public ArrayList AxMasterRowFlds = new ArrayList(); + public StringBuilder AxDepArrays = new StringBuilder(); + public string project = string.Empty; + public string user = string.Empty; + public string AxRole = string.Empty; + public string sessionid = string.Empty; + public string errlog = string.Empty; + public string filename = string.Empty; + public DataSet dsData; + public string ires = string.Empty; + public string serviceInputXml = string.Empty; + public string result = string.Empty; + public string axpert = "Axpert\\"; + public string transID = ""; + public string rid = string.Empty; + private int deletedCount = -1; + public bool IsDraftObj = false; + public string AxActDepField = ""; + public string TabDcStatus = string.Empty; + ArrayList AxSubGridRows = new ArrayList(); + ArrayList AxDelDcNo = new ArrayList(); + ArrayList AxDelRecIds = new ArrayList(); + ArrayList subWsRows = new ArrayList(); + ArrayList subDsRows = new ArrayList(); + public string AxActiveDc = string.Empty; + public ArrayList removeFiles = new ArrayList(); + //Variables to store the memVars details + ArrayList memVarNames = new ArrayList(); + ArrayList memVarValues = new ArrayList(); + ArrayList memVarTypes = new ArrayList(); + public string memVarsData = string.Empty; + bool hasMemVars = false; + public string strServerTime = string.Empty; + public double webTime1; + public double webTime2; + public double asbTime; + //public DateTime asbTime2; + public bool logTimeTaken = false; + public bool hasImagePath = false; + string scriptsPath = HttpContext.Current.Application["ScriptsPath"].ToString(); + + public string attachDirPath = ""; + public string imgAttachPath = ""; + + public string AxActiveAction = string.Empty; + List deletedRowCount = new List(); + bool isDeletedRow = false; + public ArrayList AxGridAttNotExistList = new ArrayList(); + + [NonSerialized] + public ASBExt.WebServiceExt objWebServiceExt = new ASBExt.WebServiceExt(); + + LogFile.Log logobj = new LogFile.Log(); + Util.Util util = new Util.Util(); + CacheMgr.CacheManager cm = new CacheMgr.CacheManager(""); + Boolean isDebugFileCreated = false; + public TStructDef tstStrObj; + public bool attachDir = false; + public Dictionary fastDDL = new Dictionary(); + + int DeleteRowTopNo = 0; + #endregion + + #region Attributes with get,set properties. + /// + /// Attributes with get, set properties. + /// + public ArrayList fldNames + { + get { return fieldName; } + set { fieldName = value; } + } + + public ArrayList fldFrameNos + { + get { return fieldFrameNo; } + set { fieldFrameNo = value; } + } + + public ArrayList fldControlNames + { + get { return fieldControlName; } + set { fieldControlName = value; } + } + + public ArrayList fldRowNos + { + get { return fieldRowNo; } + set { fieldRowNo = value; } + } + + public ArrayList fldValues + { + get { return fieldValue; } + set { fieldValue = value; } + } + + public ArrayList fldOldValues + { + get { return fieldOldValue; } + set { fieldOldValue = value; } + } + + public ArrayList fldIdValues + { + get { return fieldIdValue; } + set { fieldIdValue = value; } + } + + public ArrayList fldOldIdValues + { + get { return fieldOldIdValue; } + set { fieldOldIdValue = value; } + } + + public ArrayList attachments + { + get { return attachArray; } + set { attachArray = value; } + } + + public String fldValueXml + { + get { return fieldValueXml; } + set { fieldValueXml = value; } + } + + public String fgFldValueXml + { + get { return fgFieldValueXml; } + set { fgFieldValueXml = value; } + } + + public String transid + { + get { return transactionID; } + set { transactionID = value; } + } + + public String recordid + { + get { return recordID; } + set { recordID = value; } + } + + public string newJson + { + get { return jsonString; } + set { jsonString = value; } + } + public DataSet dsDataSet + { + get { return dsData; } + set { dsData = value; } + } + + public bool isSaveCalled = false; + public bool isAxpImagePath = false; + #endregion + + #region Constructor which parses the jsonData. + /// + /// Constructor which gets the JsonData from the service and updates all the field related information + /// to the array list by parsing through json data. + /// + /// + public TStructData(string jsonData, string transId, string recId, TStructDef strObj) + { + if (HttpContext.Current.Session["AxLogging"] != null) + { + if (Convert.ToString(HttpContext.Current.Session["AxLogging"]).ToLower() == "true") + logTimeTaken = true; + } + + tstStrObj = strObj; + CreateDataSets(strObj); + + this.rid = recId; + transID = transId; + + if (HttpContext.Current.Session["AxAttachFilePath"] != null) + attachDirPath = HttpContext.Current.Session["AxAttachFilePath"].ToString(); + + if (HttpContext.Current.Session["AxpAttachmentPathGbl"] != null) + attachDirPath = HttpContext.Current.Session["AxpAttachmentPathGbl"].ToString(); + + if (attachDirPath != string.Empty) + attachDir = true; + + + if (HttpContext.Current.Session["AxImagePath"] != null && HttpContext.Current.Session["AxImagePath"].ToString() != "") + { + imgAttachPath = HttpContext.Current.Session["AxImagePath"].ToString(); + //CommonDir directory creation taken back due to application server memory usage. + //if (!imgAttachPath.Contains(":\\") && !imgAttachPath.StartsWith("\\")) + //{ + // CreateDirectoryInCommonDir(ref imgAttachPath); + //} + } + if (HttpContext.Current.Session["AxpImagePathGbl"] != null && HttpContext.Current.Session["AxpImagePathGbl"].ToString() != "") + { + imgAttachPath = HttpContext.Current.Session["AxpImagePathGbl"].ToString(); + imgAttachPath = imgAttachPath.Replace(";bkslh", "\\"); + } + if (HttpContext.Current.Session["AxpSaveImageDb"] != null && HttpContext.Current.Session["AxpSaveImageDb"].ToString() == "true") + imgAttachPath = ""; + + ArrayList imageFlds = new ArrayList(); + ArrayList imageSrc = new ArrayList(); + GetGlobalVars(); + + + jsonData = jsonData.Replace("*$*", "♦"); + jsonData = jsonData.Replace("\\", ";bkslh"); + string[] resval = jsonData.Split('♦'); + StringBuilder dataJson = new StringBuilder(); + + for (int j = 0; j < resval.Length; j++) + { + //TODO: all other json nodes should be handled in the json parsing + JArray Data = null; + try + { + if (resval[j] != "") + { + JObject tstData = JObject.Parse(resval[j]); + Data = (JArray)tstData["data"]; + jsonString = @"{""data"":["; + } + } + catch (Exception ex) + { + logobj.CreateLog("JsonToArray function - " + ex.Message, sessionid, "Exception-" + transid, "new"); + logobj.CreateLog("JsonData - " + jsonData, sessionid, "Exception-" + transid, ""); + + //throw ex; + } + + + if (Data != null) + { + string fName = string.Empty; + string fValue = string.Empty; + string delRows = string.Empty; + string rowNo = string.Empty; + string fDatatype = string.Empty; + string name = string.Empty; + string fldName = string.Empty; + string fldFrameNo = string.Empty; + string frmNum = string.Empty; + string frowValues = string.Empty; + string fldIdValues = string.Empty; + string idCol = string.Empty; + string masterRow = string.Empty; + string comboVal = string.Empty; + string comboIdCol = string.Empty; + string dcNo = "0"; + string dpmValue = string.Empty; + string dpValue = string.Empty; + string idVal = string.Empty; + string oldIdVal = string.Empty; + StringBuilder ddlVals = new StringBuilder(); + StringBuilder ddlDpVals = new StringBuilder(); + //TODO: Create a single function for parsing the json result- The same code is used in JsonToArray + for (int m = 0; m < Data.Count; m++) + { + Dictionary values = JsonConvert.DeserializeObject>(Data[m].ToString()); + + fDatatype = ""; + delRows = ""; + masterRow = string.Empty; + dpmValue = string.Empty; + dpValue = string.Empty; + string dcHasRows = string.Empty; + + if (values.ContainsKey("t")) + fDatatype = values["t"]; + if (values.ContainsKey("n")) + fName = values["n"]; + if (values.ContainsKey("v")) + fValue = values["v"]; + if (values.ContainsKey("cr")) + delRows = values["cr"]; + if (values.ContainsKey("mr")) + masterRow = values["mr"]; + if (values.ContainsKey("idcol")) + idCol = values["idcol"]; + if (values.ContainsKey("id")) + idVal = values["id"]; + if (values.ContainsKey("oldid")) + oldIdVal = values["oldid"]; + if (values.ContainsKey("dpm")) + dpmValue = values["dpm"]; + if (values.ContainsKey("dp")) + dpValue = values["dp"]; + if (values.ContainsKey("r")) + { + rowNo = values["r"]; + if (rowNo.Length == 1) + rowNo = "00" + rowNo; + else if (rowNo.Length == 2) + rowNo = "0" + rowNo; + } + + + + string rowValues = string.Empty; + + if (fName != string.Empty) + { + fValue = fValue.Replace("^^dq", "\""); + fValue = fValue.Replace(";bkslh", "\\"); + + if (fName.ToLower() == Constants.AXPATTACHMENTPATH && fValue.Trim() != String.Empty) + { + attachDirPath = fValue; + attachDir = true; + } + + ////TODO: The same code is there in the UpdateDataList, and Jsontoarray + //if (fName.ToLower() == "axpcurrencydec") + // CheckAxpCurrDec(fName, fValue); + + string rowVal = ""; + if (fDatatype == "i") + { + //On loading the data, if there is a image field whose image is stored in folders, + //Add it to the array to call the MoveImage function to move it to the scripts folder. + string fldId = string.Empty; + fldId = fName + rowNo + "F" + dcNo; + if (fName.StartsWith(Constants.IMGPrefix)) + { + imageFlds.Add(fldId); + fValue = string.Empty; + } + else if (fName.StartsWith(Constants.IMGSRCPrefix)) + { + imageSrc.Add(fValue); + } + } + else if (fDatatype == "c") + { + comboVal = fValue; + } + else if (fDatatype == "dv") + { + rowVal = fValue; + if (rowValues == "") + rowValues = rowVal; + else + rowValues += "" + rowVal; + + string[] temp = rowVal.Split('?'); + if (temp.Length <= 3 && comboVal == string.Empty && temp.Length > 1) + { + StringBuilder strVal = new StringBuilder(); + for (int i = 0; i < temp.Length; i++) + { + if (temp[i].ToString() != string.Empty) + strVal.Append(temp[i].ToString()); + } + if (strVal.ToString().ToLower() == "yesno" || strVal.ToString().ToLower() == "noyes") + { + //To set the default value of checkbox in the grid dc to "no". + fValue = "no"; + } + } + } + else if (fDatatype == "dc") + { + string dcRowCount = fName + "~" + fValue; + dcNo = fName.Substring(2); + + if (values.ContainsKey("hasdatarows")) + dcHasRows = values["hasdatarows"]; + + bool isGrid = IsDcGrid(dcNo, strObj); + + if (isGrid) + { + if (dcHasRows != "") + { + TStructDef.DcStruct dc = (TStructDef.DcStruct)strObj.dcs[Convert.ToInt32(dcNo) - 1]; + if (dcHasRows == "yes") + dc.DCHasDataRows = true; + else + dc.DCHasDataRows = false; + strObj.dcs[Convert.ToInt32(dcNo) - 1] = dc; + } + + //This condition is added to maintain the field array for all the dc fields. + //In case of index calculation if some dc's fields are not there then it throws error. + if (fValue == "0" && delRows == "") + { + fValue = "1"; + delRows = "i1"; + dcRowCount = fName + "~" + fValue; + } + } + UpdateRowCount(fName, dcRowCount); + } + + + if (idCol == "no" || idCol == "") + idCol = "0"; + else + idCol = "1"; + + if (fDatatype == "c") + comboIdCol = idCol; + + if (fDatatype == "dv") + { + ddlVals.Append(rowValues); + ddlVals.Append("♣"); + ddlDpVals.Append(dpValue); + ddlDpVals.Append("♣"); + DSUpdateRowValues(fName, Convert.ToInt32(rowNo), ddlVals.ToString(), ddlDpVals.ToString(), masterRow, comboIdCol); + } + else + { + ddlVals = new StringBuilder(); + if (fDatatype != "dc") + { + string rowFrmNo = string.Empty; + if (rowNo != "") + { + name = fName + rowNo + "F" + dcNo; + rowFrmNo = rowFrmNo + "F" + dcNo; + DSSubmitWithOld(fName, Convert.ToInt32(rowNo), fValue, idVal, oldIdVal); + } + } + } + } + } + CreateFieldValueXml("ALL", "", "LoadData"); + } + } + //Loop through the image fields and load the images in the scripts folder + for (int i = 0; i < strObj.AxImageFields.Count; i++) + { + if (imageSrc.Count != 0 && imageSrc.Count >= i) + { + if (imageSrc[i].ToString() != "") + { + string[] fvalues = imageSrc[i].ToString().Split('~'); + string recordId = fvalues[2].ToString(); + + LoadImageToFolder(strObj.AxImageFields[i].ToString(), recordId); + } + } + else if (recId != "0" && recId != "") + { + LoadImageToFolder(strObj.AxImageFields[i].ToString(), recId); + } + } + + //Load the grid attachments in the folder + if ((recId != "0" && recId != "" && tstStrObj.ContainsGridAttach) || (recId == "0" && tstStrObj.ContainsGridRefer)) + { + GetGlobalAttachPath(); + LoadGridAttsToFolder(recId, transID); + } + + //Call the function which parses thge memvar node and updates the arrays. + ParseMemVarNode(jsonData, "LoadData"); + } + + + #endregion + + #region Methods + + #region Public Methods + /// + /// This method is invoked by end user to update the list with new fieldnames and fieldvalues. + /// This method inturn calls other methods for updating the list and construct the new field value xml. + /// Here there is a assumption that fldArray and fldValueArray are consistent, means both has same number + /// of rows and maintain the index. + /// + /// + /// fldArray consists the updated/new component names. + /// + /// + /// fldValueArray consists the updated/new component values. + /// + /// + /// deletedArray is specific to grid fields , it consists the row no. which is deleted and frame no. + /// the particular dc no. from where the row is deleted. + /// + public void GetFieldValueXml(ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList deletedArray, string frameNo, string calledFrom, string condition, string includeDcs) + { + //first update the list with the new fldArray. + UpdateDataList(fldArray, fldDbRowNo, fldValueArray, deletedArray); + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + if (deletedRowCount.Count > 0) + { + deleteRowOnSave(); + } + //Create the xml from the updated list. + CreateFieldValueXml(condition, includeDcs, calledFrom); + } + + public void GetPerfFieldValueXml(ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList deletedArray, string frameNo, string calledFrom, string condition, string includeDcs) + { + //first update the list with the new fldArray. + UpdateDataList(fldArray, fldDbRowNo, fldValueArray, deletedArray); + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + + } + + + /// + /// This method is invoked by end user to update the list with new fieldnames and fieldvalues. + /// This method inturn calls other methods for updating the list and construct the new field value xml. + /// Here there is a assumption that fldArray and fldValueArray are consistent, means both has same number + /// of rows and maintain the index. + /// + /// + /// fldArray consists the updated/new component names. + /// + /// + /// fldValueArray consists the updated/new component values. + /// + /// + /// deletedArray is specific to grid fields , it consists the row no. which is deleted and frame no. + /// the particular dc no. from where the row is deleted. + /// + public void GetPopFieldValueXml(ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList deletedArray, string frameNo, string parDcNo, int parRowNo, string popDcNo, int popRowNo) + { + //first update the list with the new fldArray. + UpdateDataList(fldArray, fldDbRowNo, fldValueArray, deletedArray); + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + + // Create the xml from the updated list. + CreateFieldValueXml("-1", parDcNo, parRowNo, popDcNo, popRowNo); + } + + + public void UpdateAttachments(string attachFiles) + { + string[] attach = attachFiles.Split(','); + + for (int j = 0; j < attach.Length; j++) + attachArray.Add(attach[j].ToString()); + } + + private string GetDelRowDataIndex(string axpRecId) + { + string delXml = string.Empty; + for (int j = 0; j < DelRowFldsXml.Count; j++) + { + string[] strDelData = DelRowFldsXml[j].ToString().Split('♦'); + if (strDelData[0].ToString() == axpRecId) + { + delXml = strDelData[1].ToString(); + break; + } + } + return delXml; + } + + /// + /// Function to get the deleted row info from the server side deleted rows. + /// + /// + /// + private string GetDelRowsInServer(string delRows) + { + StringBuilder strDelDcData = new StringBuilder(); + //the delrows will be in the below format + //dc1-recid1,recid2~dc2-recid1,recid2 + if (delRows != string.Empty) + { + string[] delRowStr = delRows.Split('~'); + for (int i = 0; i < delRowStr.Length; i++) + { + string[] dcStr = delRowStr[i].ToString().Split('-'); + string recIds = string.Empty; + bool found = false; + for (int j = AxDelDcNo.Count - 1; j >= 0; j--) + { + if (AxDelDcNo[j].ToString() == dcStr[0]) + { + found = true; + recIds = AxDelRecIds[j].ToString(); + AxDelDcNo.RemoveAt(j); + AxDelRecIds.RemoveAt(j); + break; + } + } + + if (strDelDcData.ToString() != "") + strDelDcData.Append("~"); + + if (found) + strDelDcData.Append(dcStr[0] + "-" + dcStr[1] + "," + recIds); + else + strDelDcData.Append(dcStr[0] + "-" + dcStr[1]); + } + } + + for (int k = 0; k < AxDelDcNo.Count; k++) + { + if (strDelDcData.ToString() != "") + strDelDcData.Append("~"); + strDelDcData.Append(AxDelDcNo[k] + "-" + AxDelRecIds[k]); + } + + return strDelDcData.ToString(); + } + + public string GetDelRowsNode(string delRows) + { + //delrow format will be dcno~recid1,recid2-dcno~recid1,recid2.. + StringBuilder strRows = new StringBuilder(); + //hook to add deleted rows info from server side + delRows = GetDelRowsInServer(delRows); + + string[] delRowStr = delRows.Split('~'); + + if (delRows != "") + { + strRows.Append(""); + for (int i = 0; i < delRowStr.Length; i++) + { + string[] dcStr = delRowStr[i].ToString().Split('-'); + strRows.Append("<" + dcStr[0].ToString() + ">"); + string[] strRecIds = dcStr[1].ToString().Split(','); + for (int j = 0; j < strRecIds.Length; j++) + { + string axp_recId = strRecIds[j].ToString(); + string delXml = GetDelRowDataIndex(axp_recId); + + if (delXml != "") + strRows.Append(delXml); + } + + strRows.Append(""); + } + strRows.Append(""); + } + return strRows.ToString(); + } + + private string GetChangedRows(string changedRows) + { + StringBuilder strRows = new StringBuilder(); + + string[] chngRowStr = changedRows.Split('~'); + if (changedRows != "") + { + strRows.Append(""); + for (int i = 0; i < chngRowStr.Length; i++) + { + string[] dcStr = chngRowStr[i].ToString().Split('-'); + + strRows.Append("<" + dcStr[0].ToString() + ">"); + strRows.Append(dcStr[1].ToString()); + strRows.Append(""); + } + strRows.Append(""); + } + else if (recordID == "0") + strRows.Append("*"); + return strRows.ToString(); + } + + private string GetAttachTransid() + { + string tidValue = string.Empty; + int idx = tstStrObj.GetFieldIndex("axp_attachtransid"); + if (idx != -1) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[idx]; + tidValue = GetFieldValue(fld.fldframeno.ToString(), fld.name); + } + else + { + tidValue = tstStrObj.transId; + } + return tidValue; + } + + + + //save attached file into local + public void SaveAttached(string files, string RecordId) + { + //CommonDir directory creation taken back due to application server memory usage. + //if (!attachDirPath.Contains(":\\") && !attachDirPath.StartsWith("\\")) + //{ + // CreateDirectoryInCommonDir(ref attachDirPath); + //} + + DirectoryInfo srcDir = new DirectoryInfo(scriptsPath + "Axpert\\" + sessionid); + string tidValue = string.Empty; + //string schemaName = project; + tidValue = GetAttachTransid(); + + DirectoryInfo desDir = new DirectoryInfo(attachDirPath + "\\" + tidValue + "\\"); + if (files != string.Empty) + { + string[] fnames = files.Split(','); + string[] sFileName = new string[fnames.Length]; + for (int i = 0; i < fnames.Length; i++) + sFileName[i] = Directory.GetFiles(scriptsPath + "Axpert\\" + sessionid, fnames[i])[0]; + + string sFileDir = scriptsPath + "Axpert\\" + sessionid; + string desPath = attachDirPath + "\\" + tidValue + "\\"; + try + { + //Save File on disk + if (!desDir.Exists) + desDir.Create(); + } + catch (Exception ex) + { + throw ex; + } + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + foreach (var file in sFileName) + File.Copy(file, Path.Combine(desPath, RecordId + "-" + Path.GetFileName(file)), true); + } + } + //Delete the files from folder + if (removeFiles.Count > 0 && desDir.Exists) + { + for (int i = 0; i < removeFiles.Count; i++) + { + try + { + foreach (FileInfo fi in desDir.GetFiles(removeFiles[i].ToString().Replace("%20", " "))) + fi.Delete(); + } + catch { } + } + } + } + + protected void RemoveUnwantedAxpFiles(string transid, string recId, string delRows, TStructData tstData, ArrayList deletedFldArrayValues) + { + try + { + GetGlobalAttachPath(); + ArrayList lstAttFileServer = new ArrayList(); + if (HttpContext.Current.Session["AxpAttFileServer"] != null) + lstAttFileServer = (ArrayList)HttpContext.Current.Session["AxpAttFileServer"]; + + foreach (var axpFlds in tstStrObj.AxpFileUploadFields) + { + if (!axpFlds.ToString().ToLower().StartsWith("axpfilepath_")) + { + int idx = tstStrObj.GetFieldIndex(axpFlds.ToString()); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[idx]; + int axpFldDcNo = fld.fldframeno; + DataTable oldDcTable = dsDataSet.Tables["deldc" + axpFldDcNo]; + if (oldDcTable != null && oldDcTable.Rows.Count > 0) + RemoveDeletedRowAxpFiles(oldDcTable, axpFlds.ToString()); + + var axpFld = lstAttFileServer.Cast().Where(i => i.StartsWith(axpFlds + "~")).ToArray(); + if (axpFld.Count() == 0) + continue; + else + { + // Need to remove saved files from list. + DataTable dcTable = dsDataSet.Tables["dc" + axpFldDcNo]; + DataView dv = new DataView(dcTable); + dv.Sort = "axp__rowno ASC"; + dcTable = dv.ToTable(); + string axpGrAttPath = string.Empty; + for (int j = 0; j < dcTable.Rows.Count; j++) + { + string axpValues = string.Empty; + axpValues = dcTable.Rows[j][axpFlds.ToString()].ToString(); + foreach (var existFiles in axpValues.Split(',')) + { + var removeValue = lstAttFileServer.Cast().Where(i => i.StartsWith(axpFlds + "~") && i.EndsWith(existFiles)).ToArray(); + if (removeValue.Count() > 0) + lstAttFileServer.Remove(removeValue[0]); + } + } + } + } + } + if (deletedFldArrayValues.Count > 0) + { + foreach (var delFile in deletedFldArrayValues) + { + string[] dltfnameval = delFile.ToString().Split('~'); + string dlFName = dltfnameval[0].Substring(0, dltfnameval[0].LastIndexOf("F") - 3); + string dlRow = dltfnameval[0].Substring(dltfnameval[0].LastIndexOf("F") - 3, 3); + var dlFullname = lstAttFileServer.Cast().Where(i => i.StartsWith(dlFName + "~") && i.EndsWith(dltfnameval[1])).ToArray(); + // TO delete file from folder and remove from list which are deleted before save the transaction + if (dlFullname.Count() > 0) + { + lstAttFileServer.Remove(dlFullname[0]); + string dlFullPath = dlFullname[0].Replace(dlFName + "~", ""); + RemoveDeletedAxpFileFromFolder(dlFullPath); + } + else + { + // To delete file from folder after load transaction and delete files + var axpfilepath_ = tstStrObj.AxpFileUploadFields.Cast().Where(i => i.ToLower().StartsWith("axpfilepath") && i.EndsWith("_" + dlFName.ToString().Substring(8))).ToArray(); + int idx = tstStrObj.GetFieldIndex(dlFName.ToString()); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[idx]; + int axpFldDcNo = fld.fldframeno; + DataTable dcTable = dsDataSet.Tables["dc" + axpFldDcNo]; + bool isDcGrid = false; + isDcGrid = IsDcGrid(axpFldDcNo.ToString(), tstStrObj); + int rNo = 0; + if (isDcGrid) + rNo = int.Parse(dlRow) - 1; + else + rNo = int.Parse(dlRow); + string axpFPath = string.Empty; + if (dcTable.Rows.Count > 0) + axpFPath = dcTable.Rows[rNo][axpfilepath_[0]].ToString(); + if (axpFPath == string.Empty) + axpFPath = HttpContext.Current.Session["grdAttPath"].ToString(); + if (axpFPath.EndsWith("*")) + { + string axpFilePath = axpFPath.Substring(0, axpFPath.LastIndexOf('\\')) + "\\"; + string PrefixFilename = axpFPath.Substring(axpFPath.LastIndexOf("\\") + 1).Replace("*", ""); + string axpFileName = dltfnameval[1]; + if (PrefixFilename != string.Empty) + axpFileName = PrefixFilename + axpFileName; + RemoveDeletedAxpFileFromFolder(axpFilePath + axpFileName); + } + else + RemoveDeletedAxpFileFromFolder(axpFPath + dltfnameval[1]); + } + } + } + if (lstAttFileServer.Count > 0) + HttpContext.Current.Session["AxpAttFileServer"] = lstAttFileServer; + else + HttpContext.Current.Session["AxpAttFileServer"] = null; + } + catch (Exception ex) + { + logobj.CreateLog("Error while deleting-" + ex.Message, sessionid, "RemoveUnwantedAxpFiles", "new"); + } + } + + protected void RemoveDeletedRowAxpFiles(DataTable oldDcTable, string axpFld) + { + try + { + var axpfilepath_ = tstStrObj.AxpFileUploadFields.Cast().Where(i => i.ToLower().StartsWith("axpfilepath") && i.EndsWith("_" + axpFld.ToString().Substring(8))).ToArray(); + string axpFPath = string.Empty; + string axpValues = string.Empty; + for (int j = 0; j < oldDcTable.Rows.Count; j++) + { + axpFPath = oldDcTable.Rows[j][axpfilepath_[0]].ToString(); + axpValues = oldDcTable.Rows[j][axpFld].ToString(); + if (axpFPath == string.Empty) + axpFPath = HttpContext.Current.Session["grdAttPath"].ToString(); + foreach (var existFiles in axpValues.Split(',')) + { + if (axpFPath.EndsWith("*")) + { + string axpFilePath = axpFPath.Substring(0, axpFPath.LastIndexOf('\\')) + "\\"; + string PrefixFilename = axpFPath.Substring(axpFPath.LastIndexOf("\\") + 1).Replace("*", ""); + string existFile = existFiles; + if (PrefixFilename != string.Empty) + existFile = PrefixFilename + existFiles; + RemoveDeletedAxpFileFromFolder(axpFilePath + existFile); + } + else + RemoveDeletedAxpFileFromFolder(axpFPath + existFiles); + } + } + } + catch (Exception ex) + { + logobj.CreateLog("Error while deleting OldFiles-" + ex.Message, sessionid, "RemoveDeletedRowAxpFiles", "new"); + } + } + + protected void RemoveDeletedAxpFileFromFolder(string fullPath) + { + try + { + File.Delete(fullPath); + } + catch (Exception ex) + { + logobj.CreateLog("Error while RemoveDeletedAxpFileFromFolder-" + ex.Message, sessionid, "RemoveDeletedAxpFileFromFolder", "new"); + } + } + + + public string CallSaveDataWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, ArrayList deletedFldArrayValues, string files, string rid, string delRows, string changedRows) + { + + DateTime stTime = DateTime.Now; + string successMsg = string.Empty; + string gridAttSaveResult = string.Empty; + string AxRelKeys = string.Empty; + bool holdpopup = false; + if (!string.IsNullOrEmpty(files)) + UpdateAttachments(files); + string filesCpy = files; + if (attachDir) + files = ""; + + + string cngRows = GetChangedRows(changedRows); + + transid = tstData.transid.ToString(); + filename = "save-" + transid; + errlog = logobj.CreateLog("Saving Data", sessionid, filename, "new"); + string imagefromdb = "false"; + if (HttpContext.Current.Session["AxpSaveImageDb"] != null) + imagefromdb = HttpContext.Current.Session["AxpSaveImageDb"].ToString(); + serviceInputXml = " "; + result = string.Empty; + logobj.CreateLog("Cross checking field value xml length sent from client and received xml length", sessionid, filename, ""); + //call a function to delete the default row in pop grid + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + isSaveCalled = true; + tstData.GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "true", "ALL", ""); + delRows = GetDelRowsNode(delRows); + isSaveCalled = false; + if (tstData.fldValueXml.Contains("docid")) + { + holdpopup = true; + } + + serviceInputXml += tstData.fldValueXml + memVarsData + ""; + serviceInputXml += delRows + cngRows; + serviceInputXml += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + serviceInputXml += ""; + logobj.CreateLog("Call to SaveData Web Service", sessionid, filename, ""); + ires = tstStrObj.structRes; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + DateTime asStart = DateTime.Now; + result = objWebServiceExt.CallSaveDataWS(transid, serviceInputXml, ires); + string requestProcess_logtime = result.Split('♠')[0]; + result = result.Split('♠')[1]; + DateTime asEnd = DateTime.Now; + logobj.CreateLog("End Time : " + DateTime.Now.ToString(), sessionid, filename, ""); + + //{"message":[{"msg":"Master Saved,recordid=20054000000070"}]} + result = result.Replace("\\", ";bkslh"); + //To save the image fields in server folders, + //the below code checks if the record is saved and copies the images to the folders. + if (result.ToLower().Contains("ora-")) + { + result = result.Replace("ora-", ""); + result = result.Replace("ORA-", ""); + } + if (!result.StartsWith(Constants.ERROR)) + { + string returnStr = result.Replace("*$*", "¿"); + string[] newResult = returnStr.Split('¿'); + for (int i = 0; i < newResult.Length; i++) + { + JArray msg, rslt; + try + { + JObject message = JObject.Parse(newResult[i].ToString()); + msg = (JArray)message["message"]; + rslt = (JArray)message["result"]; + } + catch (Exception ex) + { + throw ex; + } + if (rslt != null) + { + string saveStatus = rslt[0].SelectToken("save").ToString(); + if (saveStatus == "success" && util.isRealTimeCacEnabled(transid, tstStrObj)) + AxRelKeys = util.GetAxRelations(tstData.transid); + if (saveStatus == "success" && transID == "axstc") + { + DataTable dt = tstData.dsDataSet.Tables["dc1"]; + if (dt != null && dt.Rows.Count > 0) + { + string props = dt.Rows[0]["PROPS"].ToString(); + if (props.ToLower() == "general") + util.ClearAxpStructConfigInRedis(Constants.AXCONFIGGENERAL, transID, GetFieldValue("1", "userroles"), "general", ""); + else + { + string stype = dt.Rows[0]["STYPE"].ToString(); + string sname = dt.Rows[0]["STRUCTNAME"].ToString(); + if (stype == "Tstruct") + util.ClearAxpStructConfigInRedis(Constants.AXCONFIGTSTRUCT, transID, GetFieldValue("1", "userroles"), "tstruct", sname); + if (stype == "Iview") + { + util.ClearAxpStructConfigInRedis(Constants.AXCONFIGTSTRUCT, transID, GetFieldValue("1", "userroles"), "iview", sname); + } + } + } + } + } + + if (msg != null) + { + string saveResult = msg[0].SelectToken("msg").ToString(); + + if (saveResult.IndexOf(',') != -1) + { + string recId = ""; + string[] resultData = saveResult.Split(','); + if (resultData.Length > 1) + { + successMsg = resultData[0]; + if (resultData[resultData.Length - 1].ToString().IndexOf("=") != -1 && resultData[resultData.Length - 1].ToString().IndexOf("recordid") != -1) + { + string[] recordDts = resultData[resultData.Length - 1].ToString().Split('='); + recId = recordDts[1].ToString(); + } + else if (resultData[resultData.Length - 1].ToString().IndexOf("=") == -1 && Array.FindIndex(resultData, x => x.Trim().Contains("recordid=")) > -1) + { + int recIdx = Array.FindIndex(resultData, x => x.Contains("recordid")); + if (resultData[recIdx].ToString().Contains("=")) + { + string[] recordDts = resultData[recIdx].ToString().Split('='); + recId = recordDts[1].ToString(); + } + } + else + { + continue; + } + } + + if (recId != string.Empty) + { + if (tstStrObj.AxpFileUploadFields.Count > 0) + RemoveUnwantedAxpFiles(transid, recId, delRows, tstData, deletedFldArrayValues); + + if (tstStrObj.ContainsGridAttach) + { + try + { + gridAttSaveResult = SaveGridAttachments(transid, sessionid, recId, delRows, tstData, changedRows, deletedFldArrayValues); + } + catch (Exception ex) + { + logobj.CreateLog("Error while SaveGridAttachments-" + ex.Message, sessionid, "SaveGridAttachments", "new", "true"); + } + } + + if (tstStrObj.ContainsImage) + { + string authenticationStatus = string.Empty; + bool isAuthenticated = util.GetAuthentication(ref authenticationStatus); + SaveImageToFolder(tstStrObj, transid, sessionid, recId, deletedFldArrayValues); + } + //Save the attach file into the dir + if (attachDir && (!string.IsNullOrEmpty(filesCpy) || removeFiles.Count > 0)) + SaveAttached(filesCpy, recId); + try + { + Custom custObj = Custom.Instance; + custObj.AxAfterAttSave(transid, sessionid, recId); + } + catch (Exception ex) + { + + } + RefFastDataOnSave("save"); + RefInMemOnSave(); + } + } + } + } + } + + if (logTimeTaken) + { + webTime1 = asStart.Subtract(stTime).TotalMilliseconds; + webTime2 = DateTime.Now.Subtract(asEnd).TotalMilliseconds; + asbTime = asEnd.Subtract(asStart).TotalMilliseconds; + } + if (AxRelKeys != string.Empty) + result = result + "*#*" + AxRelKeys; + if (holdpopup != false) + { + result = "{" + "\"holdpopup\"" + ":[{" + "\"hold\"" + ":\" " + holdpopup + "\"}]}" + "*$*" + result; + } + if (gridAttSaveResult != string.Empty) + { + result = "{" + "\"GridAttachments\"" + ":[{" + "\"Message\"" + ":\" Attachment is not Saved : " + gridAttSaveResult + "\"}]}" + "*$*" + result; + } + result = requestProcess_logtime + "♠" + result; + return result; + } + + private void ModifyAsNewRecord() + { + if (dsDataSet.Tables.Count > 0) + { + for (int i = 1; i <= tstStrObj.dcs.Count; i++) + { + DataTable dt = dsDataSet.Tables["dc" + i]; + if (dt.Rows.Count > 0) + { + if (((TStructDef.DcStruct)(tstStrObj.dcs[i - 1])).isgrid) + { + foreach (DataRow row in dt.Rows) + { + row["axp_recid" + i] = "0"; + } + } + else + { + dt.Rows[0]["axp_recid" + i] = "0"; + } + } + } + } + } + + public string CallWorkFlowActionWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string files, string rid, string inputXml) + { + if (!string.IsNullOrEmpty(files)) + { + UpdateAttachments(files); + } + //GetGlobalVars(); + transid = tstData.transid.ToString(); + filename = "WorkFlow-" + transid; + errlog = logobj.CreateLog("Saving Workflow Data", sessionid, filename, "new"); + result = string.Empty; + logobj.CreateLog("Cross checking field value xml length send from client and received xml length", sessionid, filename, ""); + //call a function to delete the default row in pop grid + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + + tstData.GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "true", "ALL", ""); + inputXml += "" + tstData.fldValueXml + ""; + inputXml += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString() + ""; + logobj.CreateLog("Call to WorkFlowAction Web Service", sessionid, filename, ""); + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallWorkFlowActionWS(transid, inputXml); + logobj.CreateLog("End Time : " + DateTime.Now.ToString(), sessionid, filename, ""); + return result; + } + + + public string GetErrorInResultJson(string result) + { + result = result.Replace("\\", ";bkslh"); + result = result.Replace("^^dq", "\""); + string returnStr = result.Replace("*$*", "¿"); + string[] newResult = returnStr.Split('¿'); + for (int i = 0; i < newResult.Length; i++) + { + JArray msg; + try + { + JObject message = JObject.Parse(newResult[i].ToString()); + msg = (JArray)message["error"]; + } + catch (Exception ex) + { + throw ex; + } + + if (msg != null) + { + string saveResult = msg[0].SelectToken("msg").ToString(); + saveResult = saveResult.Remove(0, 1); + saveResult = saveResult.Remove(saveResult.Length - 1, 1); + return saveResult; + } + } + return result; + } + + private string SaveGridAttachments(string transid, string sid, string recId, string delRows, TStructData tstData, string changedRows, ArrayList deletedFldArrayValues) + { + GetGlobalAttachPath(); + string saveResult = string.Empty; + + if (recId != "0") + { + string sourceFilePath = scriptsPath + "axpert\\" + sid; + string destFilePath = string.Empty; + string grdAttPath = string.Empty; + bool hasMultipleFiles = false; + bool isAxpAttachFld = false; + hasImagePath = false; + string fldName = string.Empty; + ArrayList attFldNames = new ArrayList(); + ArrayList attDestPath = new ArrayList(); + ArrayList attFileNames = new ArrayList(); + StringBuilder strFiles = new StringBuilder(); + ArrayList attWantToDelete = new ArrayList(); + //string schemaName = project; + string attachTid = GetAttachTransid(); + int attTotalFileCount = 0; + int attDelFileCount = 0; + int attSavedFileCount = 0; + ArrayList isRecordFile = new ArrayList(); + //bool isRecordFile = false; + if (HttpContext.Current.Session["attGridFileServer"] != null && HttpContext.Current.Session["attGridFileServer"].ToString() != string.Empty) + { + string attTotalFile = HttpContext.Current.Session["attGridFileServer"].ToString(); + string[] attTotalFiles = attTotalFile.Split('♦'); + attTotalFileCount = attTotalFiles.Length; + } + + bool deletedGridFilesExist = false; + foreach (var attFld in tstStrObj.AxAttachFields) + { + int idx = tstStrObj.GetFieldIndex(attFld.ToString()); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[idx]; + + if ((fld.name.StartsWith("dc") && fld.name.ToLower().EndsWith("_image") || fld.name.StartsWith("axp_gridattach_")) && IsDcGrid(fld.fldframeno.ToString(), tstStrObj)) + { + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[fld.fldframeno - 1]; + fldName = fld.name; + + //For all attachment fields now the global variables AxpImageServer and AxpImagePath will be used for destination path + // GetGlobalAttachPath(); + grdAttPath = HttpContext.Current.Session["grdAttPath"].ToString(); + DataTable dcTable = dsDataSet.Tables["dc" + dc.frameno]; + + DataTable dcDelRowTable = dsDataSet.Tables["deldc" + dc.frameno]; + + bool hasDcImagePath = false; + hasDcImagePath = dcTable.Columns.Contains("dc" + dc.frameno + "_imagepath"); + hasImagePath = hasDcImagePath; + + if (dc.DCHasDataRows && (grdAttPath != string.Empty || hasDcImagePath == true)) + { + if (!grdAttPath.EndsWith("\\")) + grdAttPath = grdAttPath + "\\"; + + string value = string.Empty; + string destFileName = string.Empty; + string sfileEx = string.Empty; + + + bool hasAxpAttachCol = false; + hasAxpAttachCol = dcTable.Columns.Contains("axp_gridattach_" + dc.frameno); + bool hasAxpAttFileName = false; + hasAxpAttFileName = dcTable.Columns.Contains("axpattach_filename" + dc.frameno); + + DataView dv = new DataView(dcTable); + dv.Sort = "axp__rowno ASC"; + dcTable = dv.ToTable(); + string axpGrAttPath = string.Empty; + int delRowCnt = 0; + for (int j = 0; j < dcTable.Rows.Count; j++) + { + //If dc_image is used for referimages, then don't add the referred files for saving, save only newly attached files + if (!hasAxpAttachCol) + value = GetFilesforSave(dcTable.Rows[j][fld.name].ToString()); + else + value = dcTable.Rows[j]["axp_gridattach_" + dc.frameno].ToString(); + + if (value == string.Empty && (changedRows != string.Empty || delRows == string.Empty) && !hasDcImagePath && !hasAxpAttachCol && (fld.name.StartsWith("dc" + dc.frameno + "_image"))) + { + try + { + DataTable oldDcTable = dsDataSet.Tables["dc_old" + dc.frameno]; + if (dsDataSet.Tables["dc_old" + dc.frameno].Rows[0]["old__" + fld.name].ToString() != string.Empty) + { + deletedGridFilesExist = true; + } + } + catch (Exception ex) { } + } + + if (value.Contains(",")) + hasMultipleFiles = true; + + if (value == string.Empty && HttpContext.Current.Session["attGridFileServer"] != null && HttpContext.Current.Session["attGridFileServer"].ToString() != string.Empty) + { + string attServerFiles = HttpContext.Current.Session["attGridFileServer"].ToString(); + string[] lstServerFiles = attServerFiles.Split('♦'); + int irow = j + 1; + var lstServerFile = lstServerFiles.AsEnumerable().Where(x => x.StartsWith(fldName + irow + "~") && x.Contains(HttpContext.Current.Session["username"].ToString() + "-")).ToList(); + string authenticationStatus = string.Empty; + if (lstServerFile.Count > 0 && util.GetAuthentication(ref authenticationStatus)) + { + foreach (var lst in lstServerFile) + { + string savedFileName = lst.Split('~')[1]; + File.Delete(savedFileName); + attDelFileCount++; + HttpContext.Current.Session["attGridFileServer"] = attServerFiles = attServerFiles.Replace(lst + "♦", "").Replace(lst, ""); + } + } + } + + if (value != string.Empty || deletedGridFilesExist) + { + //If axp_gridattach + if (hasAxpAttachCol) + { + if (hasAxpAttFileName && !hasMultipleFiles) + { + sfileEx = value.Substring(value.LastIndexOf(".")); + destFileName = dcTable.Rows[j]["axpattach_filename" + dc.frameno].ToString() + sfileEx; + } + isAxpAttachFld = true; + //destFilePath = grdAttPath + schemaName + "\\" + attachTid + "\\" + recId + "\\" + fld.name; + destFilePath = grdAttPath + "\\" + attachTid + "\\" + recId + "\\" + fld.name; + } + else if (fld.name.StartsWith("dc") && fld.name.ToLower().EndsWith("_image") && !hasDcImagePath) + { + //destFilePath = grdAttPath + schemaName + "\\" + attachTid + "\\" + fld.name; + destFilePath = grdAttPath + "\\" + attachTid + "\\" + fld.name; + } + else if (hasDcImagePath && !hasAxpAttachCol) + { + if (dcTable.Rows[j]["dc" + +dc.frameno + "_imagepath"].ToString() != string.Empty) + { + hasImagePath = true; + grdAttPath = GetdcImagePath(dcTable.Rows[j]["dc" + +dc.frameno + "_imagepath"].ToString()); + destFilePath = grdAttPath; + } + else + { + string errorLog = string.Empty; + string errMessage = "Value for dc_imagepath field is not specified"; + errorLog = logobj.CreateLog("Error in Saving Grid attachments - " + errMessage, sid, "GridAttachments", "new"); + saveResult = errMessage; + + } + } + } + + if ((value != string.Empty || deletedGridFilesExist) && destFilePath != string.Empty) + { + try + { + DirectoryInfo di = new DirectoryInfo(destFilePath); + if (!di.Exists) + di.Create(); + + } + catch (Exception ex) + { + saveResult = "Destination Path is empty"; + } + if (destFileName != "") value = destFileName; + string[] fileNames = value.Split(','); + //These arrays will be used to delete the deleted attachments + attFldNames.Add(fldName); + if (attDestPath.Count > 0) + { + if (attDestPath.IndexOf(destFilePath) == -1) + { + attDestPath.Add(destFilePath); + if (hasImagePath || hasAxpAttachCol) + isRecordFile.Add("false"); + else + isRecordFile.Add("true"); + } + } + else + { + attDestPath.Add(destFilePath); + if (hasImagePath || hasAxpAttachCol) + isRecordFile.Add("false"); + else + isRecordFile.Add("true"); + } + + for (int fIdx = 0; fIdx < fileNames.Length; fIdx++) + { + if (HttpContext.Current.Session["attGridFileServer"] != null && HttpContext.Current.Session["attGridFileServer"].ToString() != string.Empty) + { + int irow = j + delRowCnt + 1; + if (dcDelRowTable != null && dcDelRowTable.Rows.Count > 0) + { + int iDelrow = j + 1; + var delRowList = dcDelRowTable.AsEnumerable().Where(s => s.Field("axp__delrow") == iDelrow.ToString()).Select(s => s.Field("axp__delrow")).ToList(); + if (delRowList != null && delRowList.Count > 0) + { + string attServerFiless = HttpContext.Current.Session["attGridFileServer"].ToString(); + string[] lstServerFiless = attServerFiless.Split('♦'); + var lstMatchFiles = lstServerFiless.AsEnumerable().Where(x => x.StartsWith(fldName + irow + "~") && x.Contains(HttpContext.Current.Session["username"].ToString() + "-")).ToList(); + delRowCnt = delRowCnt + 1; + irow = irow + 1; + foreach (var lst in lstMatchFiles) + { + string savedFileName = lst.Split('\\').Last(); + string attdestFilePath = string.Empty; + attdestFilePath = destFilePath + "\\" + savedFileName; + // File.Delete(attdestFilePath); + attWantToDelete.Add(attdestFilePath); + HttpContext.Current.Session["attGridFileServer"] = attServerFiless.Replace(lst + "♦", "").Replace(lst, ""); + } + } + } + string attServerFiles = HttpContext.Current.Session["attGridFileServer"].ToString(); + string[] lstServerFiles = attServerFiles.Split('♦'); + + + var lstServerFile = lstServerFiles.AsEnumerable().Where(x => x.StartsWith(fldName + irow + "~") && x.Contains(HttpContext.Current.Session["username"].ToString() + "-")).ToList(); + string authenticationStatus = string.Empty; + if (lstServerFile.Count > 0 && util.GetAuthentication(ref authenticationStatus)) + { + foreach (var lst in lstServerFile) + { + string savedFileName = lst.Split('\\').Last();// lst.Split('~')[1]; + string attdestFilePath = string.Empty; + attdestFilePath = destFilePath + "\\" + savedFileName; + string atFileName = savedFileName.Replace(HttpContext.Current.Session["username"].ToString() + "-", ""); + var saveFileLst = fileNames.AsEnumerable().Where(x => x == atFileName).ToList(); + if (saveFileLst.Count > 0) + { + if (fileNames[fIdx] == atFileName) + { + if (hasAxpAttachCol) + { + string renameFilePath = grdAttPath + attachTid + "\\" + HttpContext.Current.Session["username"].ToString() + "\\" + fld.name; + axpGrAttPath = grdAttPath + attachTid + "\\" + HttpContext.Current.Session["username"].ToString(); + if (File.Exists(renameFilePath + "\\" + savedFileName)) + Microsoft.VisualBasic.FileIO.FileSystem.RenameFile(renameFilePath + "\\" + savedFileName, atFileName); + renameFilePath = renameFilePath + "\\" + atFileName; + destFilePath = destFilePath + "\\" + atFileName; + File.Move(@renameFilePath, @destFilePath); + attSavedFileCount++; + if (strFiles.ToString() == string.Empty) + strFiles.Append(atFileName); + else + strFiles.Append("," + atFileName); + + } + else if (hasImagePath) + { + File.Delete(destFilePath + "\\" + atFileName); + Microsoft.VisualBasic.FileIO.FileSystem.RenameFile(attdestFilePath, atFileName); + if (strFiles.ToString() == string.Empty) + strFiles.Append(atFileName); + else + strFiles.Append("," + atFileName); + attSavedFileCount++; + } + else + { + File.Delete(destFilePath + "\\" + recId + "-" + atFileName); + Microsoft.VisualBasic.FileIO.FileSystem.RenameFile(attdestFilePath, recId + "-" + atFileName); + if (strFiles.ToString() == string.Empty) + strFiles.Append(recId + "-" + atFileName); + else + strFiles.Append("," + recId + "-" + atFileName); + attSavedFileCount++; + } + HttpContext.Current.Session["attGridFileServer"] = attServerFiles = attServerFiles.Replace(lst + "♦", "").Replace(lst, ""); + } + else + { + if (hasImagePath || hasAxpAttachCol) + { + if (strFiles.ToString() == string.Empty) + strFiles.Append(fileNames[fIdx]); + else + strFiles.Append("," + fileNames[fIdx]); + } + else + { + if (strFiles.ToString() == string.Empty) + strFiles.Append(recId + "-" + fileNames[fIdx]); + else + strFiles.Append("," + recId + "-" + fileNames[fIdx]); + } + } + } + else + { + if (hasImagePath || hasAxpAttachCol) + { + if (strFiles.ToString() == string.Empty) + strFiles.Append(fileNames[fIdx]); + else + strFiles.Append("," + fileNames[fIdx]); + } + else + { + if (strFiles.ToString() == string.Empty) + strFiles.Append(recId + "-" + fileNames[fIdx]); + else + strFiles.Append("," + recId + "-" + fileNames[fIdx]); + } + attDelFileCount++; + File.Delete(attdestFilePath); + HttpContext.Current.Session["attGridFileServer"] = attServerFiles = attServerFiles.Replace(lst + "♦", "").Replace(lst, ""); + } + } + } + else + { + string fNames = fileNames[fIdx].ToString(); + if (fNames == "") continue; + if (!hasDcImagePath && !hasAxpAttachCol) + fNames = recId + "-" + fileNames[fIdx].ToString(); + if (strFiles.ToString() == string.Empty) + strFiles.Append(fNames); + else + strFiles.Append("," + fNames); + } + continue; + } + + string fName = fileNames[fIdx].ToString(); + if (fName == "") continue; + if (!hasDcImagePath && !hasAxpAttachCol) + fName = recId + "-" + fileNames[fIdx].ToString(); + if (strFiles.ToString() == string.Empty) + strFiles.Append(fName); + else + strFiles.Append("," + fName); + + CopyFiles(sourceFilePath, destFilePath, fileNames[fIdx], fName); + } + } + } + if (axpGrAttPath != string.Empty && Directory.Exists(axpGrAttPath)) + { + try + { + Directory.Delete(axpGrAttPath, true); + } + catch { } + } + } + } + } + + string attDelPath = ""; + if (attWantToDelete.Count > 0)//Delete and add same file in another row + { + attDelFileCount += attWantToDelete.Count; + foreach (string wtdFile in attWantToDelete) + { + string attFName = wtdFile.Split('\\').Last(); + attDelPath = wtdFile; + attDelPath = attDelPath.Replace("\\" + attFName, ""); + try + { + File.Delete(wtdFile); + } + catch (Exception ex) { } + } + } + + + if (changedRows != string.Empty || delRows != string.Empty)//Delete any file or load record and delete file + { + int delFcnt = DeleteGridAttachments(delRows, recId, grdAttPath, transid, isAxpAttachFld, fldName, attFldNames, attDestPath, strFiles, isRecordFile); + //attDelPath = attDelPath == "" ? attDestPath[0].ToString() : attDelPath; + if (attDelPath == "" && attDestPath.Count > 0) + attDelPath = attDestPath[0].ToString(); + if (delFcnt != 0) + attDelFileCount += delFcnt; + } + if (attDelPath != "" && attDelFileCount != 0) + { + AttDelLogFile(attDelPath, recId, attTotalFileCount, attSavedFileCount, attDelFileCount); + } + + } + return saveResult; + } + + private void AttDelLogFile(string attDelPath, string strRecId, int attTotalFileCount, int attSavedFileCount, int attDelFileCount) + { + // Total uploaded files: , Saved files: and deleted files : + // Log file recid-attdetails.txt + try + { + if (attDelPath != "") + { + //attTotalFileCount + //string attFName = attDelPath.Split('\\').Last(); + //attDelPath = attDelPath.Replace("\\" + attFName, ""); + attDelPath = attDelPath + "\\Temp"; + DirectoryInfo diDel = new DirectoryInfo(attDelPath); + if (!diDel.Exists) + diDel.Create(); + string attFPath = diDel + "\\" + strRecId + "-attdetails.txt"; + StreamWriter sw = default(StreamWriter); + if (File.Exists(attFPath)) + { + sw = new StreamWriter(attFPath, true); + sw.WriteLine("********** {0} **********", DateTime.Now.ToString()); + sw.Flush(); + sw.Close(); + sw = new StreamWriter(attFPath, true); + } + else + { + sw = new StreamWriter(attFPath, false); + sw.WriteLine("********** {0} **********", DateTime.Now.ToString()); + sw.Flush(); + sw.Close(); + sw = new StreamWriter(attFPath, true); + } + string text = "Total uploaded files:" + attTotalFileCount + " , saved files:" + attSavedFileCount + " and deleted files :" + attDelFileCount; + sw.WriteLine(text); + sw.Flush(); + sw.Close(); + } + } + catch (Exception exs) { } + } + + public string GetFilesforSave(string referredFiles) + { + string nonReferredFiles = referredFiles; + return nonReferredFiles; + + string[] refFiles = referredFiles.Split(')'); + + if (refFiles.Length > 1 && refFiles[1] != string.Empty) + nonReferredFiles = refFiles[1]; + else if (refFiles.Length > 1 && refFiles[1] == string.Empty) + nonReferredFiles = string.Empty; + + return nonReferredFiles; + } + //Get dc_imagepath field value + public string GetdcImagePath(string dcImagePath) + { + string grdAttPath = GetImgServerPath(); + + if (dcImagePath != string.Empty && dcImagePath.Contains(":")) + { + grdAttPath = dcImagePath; + } + else if (grdAttPath != string.Empty) + { + grdAttPath = grdAttPath + "\\" + dcImagePath; + + } + else if (dcImagePath == string.Empty) + { + string errorLog = string.Empty; + string errMessage = "Value for dc_imagepath field is not specified"; + errorLog = logobj.CreateLog("Error in loading Grid attachments - " + errMessage, sessionid, "GridAttachments", "new"); + grdAttPath = string.Empty; + } + + return grdAttPath; + } + + public void GetGlobalAttachPath() + { + bool isLocalFolder = false, isOnlyFolder = false; + bool isRemoteFolder = false; + string imagePath = string.Empty; + string imageServer = string.Empty; + string grdAttPath = string.Empty; + string errorMessage = string.Empty; + string mapUsername = string.Empty; + string mapPassword = string.Empty; + + if (HttpContext.Current.Session["AxpImageServerGbl"] != null) + { + imageServer = HttpContext.Current.Session["AxpImageServerGbl"].ToString(); + imageServer = imageServer.Replace(";bkslh", @"\"); + } + if (HttpContext.Current.Session["AxpImagePathGbl"] != null) + { + imagePath = HttpContext.Current.Session["AxpImagePathGbl"].ToString(); + imagePath = imagePath.Replace(";bkslh", @"\"); + + if (imagePath.IndexOf(":") > -1) + isLocalFolder = true; + else + if (imagePath.IndexOf(@"\") > -1) + isRemoteFolder = true; + else + isOnlyFolder = true; + } + + if (imagePath != string.Empty) + { + if (isLocalFolder || isRemoteFolder) + grdAttPath = imagePath; + else + grdAttPath = imageServer + @"\" + imagePath; + } + else if (imageServer != string.Empty) + { + grdAttPath = imageServer; + } + else + //If the global variables AxpimageServer and AxpImagePath is not defined + { + + if (HttpContext.Current.Session["AxGridAttachPath"] != null) + { + grdAttPath = HttpContext.Current.Session["AxGridAttachPath"].ToString(); + //CommonDir directory creation taken back due to application server memory usage. + //if (!grdAttPath.Contains(":\\")) + //{ + // // ftp server path + // if (!grdAttPath.Contains("\\\\")) + // { + // grdAttPath = AppDomain.CurrentDomain.BaseDirectory + "CommonDir\\" + grdAttPath; + // if (!Directory.Exists(grdAttPath)) + // { + // Directory.CreateDirectory(grdAttPath); + // } + // } + //} + } + } + HttpContext.Current.Session["grdAttPath"] = grdAttPath; + } + + private int DeleteGridAttachments(string delRows, string recId, string grdAttPath, string transId, bool isAxpAttachFld, string fld, ArrayList attFldNames, ArrayList attDestPath, StringBuilder attFileNames, ArrayList isRecordFile) + { + int DelfCnt = 0; + try + { + for (int i = 0; i < attDestPath.Count; i++) + { + //abc.txt,xyz.txt, + string isRecFile = isRecordFile[i].ToString(); + string attFiles = attFileNames.ToString() + ","; + DirectoryInfo di = new DirectoryInfo(attDestPath[i].ToString()); + if (di.Exists) + { + FileInfo[] files = isRecFile == "true" ? di.GetFiles(recId + "-*") : di.GetFiles(); + for (int j = 0; j < files.Length; j++) + { + FileInfo file = (FileInfo)files[j]; + string strFileName = file.Name + ","; + if (attFiles.IndexOf(strFileName) == -1 && (file.Name).IndexOf(recId) != -1) + { + file.Delete(); + DelfCnt++; + } + } + } + } + } + catch (Exception ex) + { + logobj.CreateLog("Error while deleting-" + ex.Message, sessionid, "DeleteGridAttachments", "new"); + } + return DelfCnt; + } + + //For deleting nongrid attachment files from file server + private void DeleteNonGridAttachments(string recId, string grdAttPath, string transId, string fieldName, ArrayList attFldNames, ArrayList nonGridAttDestPath, StringBuilder attFileNames) + { + try + { + for (int i = 0; i < nonGridAttDestPath.Count; i++) + { + //abc.txt,xyz.txt, + string attFiles = attFileNames.ToString() + ","; + DirectoryInfo di = new DirectoryInfo(nonGridAttDestPath[i].ToString()); + if (di.Exists) + { + FileInfo[] files = di.GetFiles(); + for (int j = 0; j < files.Length; j++) + { + FileInfo file = (FileInfo)files[j]; + string strFileName = file.Name + ","; + if (attFiles.IndexOf(strFileName) == -1 && (file.Name).IndexOf(recId) != -1) + file.Delete(); + + } + } + } + } + catch (Exception ex) + { + logobj.CreateLog("Error while deleting-" + ex.Message, sessionid, "DeleteGridAttachments", "new"); + } + } + + //Function to save the image in the server folder if the image starts with fld_ddo + private void SaveImageToFolder(TStructDef strObj, string transid, string sid, string recId, ArrayList deletedFldArrayValues) + { + + bool deletedGridFilesExist = false; + + if (recId != "0") + { + + foreach (var imgFld in tstStrObj.AxImageFields) + { + int idx = tstStrObj.GetFieldIndex(imgFld.ToString()); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)strObj.flds[idx]; + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[fld.fldframeno - 1]; + DataTable dcTable = dsDataSet.Tables["dc" + dc.frameno]; + + if (fld.fieldIsImage) + { + if (!IsDcGrid(fld.fldframeno.ToString(), strObj)) + { + + string value = string.Empty, destValue = string.Empty; + ArrayList nonGridAttDestPath = new ArrayList(); + ArrayList attFldNames = new ArrayList(); + StringBuilder nonGrdStrFiles = new StringBuilder(); + destValue = value = GetFieldValue(fld.fldframeno.ToString(), fld.name); + if (value == string.Empty && (fld.name.StartsWith("dc" + fld.fldframeno + "_image") || fld.name.StartsWith("axp_nga_"))) + { + try + { + DataTable oldDcTable = dsDataSet.Tables["dc_old" + fld.fldframeno]; + if (dsDataSet.Tables["dc_old" + fld.fldframeno].Rows[0]["old__" + fld.name].ToString() != string.Empty) + { + deletedGridFilesExist = true; + } + } + catch (Exception ex) { } + } + if (value != string.Empty || deletedGridFilesExist) + { + + string fieldName = fld.name;//fieldControlName[index].ToString(); + string strFile = ""; + if (!(fieldName.StartsWith("axp_nga_"))) + { + strFile = scriptsPath + "axpert\\" + sid + "\\" + fieldName; + if (!File.Exists(strFile + "\\" + value)) + { + string strFileNew = scriptsPath + "axpert\\" + sid; + if (File.Exists(strFileNew + "\\" + value)) + strFile = strFileNew; + } + + string strDest = ""; + if (imgAttachPath != "") + { + string imgName = destValue.Substring(0, destValue.LastIndexOf('.')); + destValue = destValue.Replace(imgName, recId); + //strDest = imgAttachPath + "\\axpert\\" + transid + "\\" + recId + "\\" + fieldName; + strDest = imgAttachPath + "\\" + transid + "\\" + fieldName; + } + else + { + //strDest = scriptsPath + "axpert\\" + transid + "\\" + recId + "\\" + fieldName; + strDest = scriptsPath + "axpert\\" + transid + "\\" + fieldName; + } + + //loop to check if multiple images exist for same field, if yes then delete all. + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + DirectoryInfo di = new DirectoryInfo(strDest); + if (!di.Exists) + { + di.Create(); + } + else if (imgAttachPath == "") + { + FileInfo[] files = di.GetFiles(); + for (int j = 0; j < files.Length; j++) + { + FileInfo file = (FileInfo)files[j]; + file.Delete(); + } + } + else if (imgAttachPath != "") + { + FileInfo[] files = di.GetFiles(); + if (files.Length > 0) + { + var ImgExist = files.Where(x => x.Name.Split('.')[0] == recId).ToList(); + if (ImgExist.Count > 0) + { + foreach (var lstImg in ImgExist) + { + FileInfo file = (FileInfo)lstImg; + file.Delete(); + } + } + } + } + if (value != string.Empty || deletedGridFilesExist) + { + CopyFiles(strFile, strDest, value, destValue); + } + } + } + else + { + + //strFile = scriptsPath + "axpert\\" + sid + "\\" + fieldName; + strFile = scriptsPath + "axpert\\" + sid; + if (!File.Exists(strFile + "\\" + value)) + { + string strFileNew = scriptsPath + "axpert\\" + sid; + if (File.Exists(strFileNew + "\\" + value)) + strFile = strFileNew; + } + + string strDest = ""; + if (imgAttachPath != "" && !(deletedGridFilesExist)) + { + string imgName = destValue.Substring(0, destValue.LastIndexOf('.')); + destValue = destValue.Replace(imgName, recId); + //strDest = imgAttachPath + "\\axpert\\" + transid + "\\" + recId + "\\" + fieldName; + strDest = imgAttachPath + "\\" + transid + "\\" + fieldName; + } + else if (!deletedGridFilesExist) + { + //strDest = scriptsPath + "axpert\\" + transid + "\\" + recId + "\\" + fieldName; + strDest = scriptsPath + "axpert\\" + transid + "\\" + fieldName; + } + else + { + strDest = imgAttachPath + "\\" + transid + "\\" + fieldName; + } + + //loop to check if multiple images exist for same field, if yes then delete all. + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + DirectoryInfo di = new DirectoryInfo(strDest); + if (!di.Exists) + { + di.Create(); + } + else if (imgAttachPath == "") + { + FileInfo[] files = di.GetFiles(); + for (int j = 0; j < files.Length; j++) + { + FileInfo file = (FileInfo)files[j]; + file.Delete(); + } + } + else if (imgAttachPath != "") + { + FileInfo[] files = di.GetFiles(); + if (files.Length > 0) + { + var ImgExist = files.Where(x => x.Name.Split('.')[0] == recId).ToList(); + if (ImgExist.Count > 0) + { + foreach (var lstImg in ImgExist) + { + FileInfo file = (FileInfo)lstImg; + file.Delete(); + } + } + } + } + if (value != string.Empty || deletedGridFilesExist) + { + string[] fileNames = value.Split(','); + nonGridAttDestPath.Add(strDest); + attFldNames.Add(fieldName); + for (int fIdx = 0; fIdx < fileNames.Length; fIdx++) + { + string fName = fileNames[fIdx].ToString(); + if (fName == "") continue; + fName = recId + "-" + fileNames[fIdx].ToString(); + CopyFiles(strFile, strDest, fileNames[fIdx], fName); + if (nonGrdStrFiles.ToString() == string.Empty) + nonGrdStrFiles.Append(fName); + else + nonGrdStrFiles.Append("," + fName); + } + } + } + + DeleteNonGridAttachments(recId, imgAttachPath, transid, fieldName, attFldNames, nonGridAttDestPath, nonGrdStrFiles); + + } + } + } + } + } + } + } + + /// + /// Function to get a non grid field's value. + /// + /// + /// + /// + public string GetFieldValue(string dcNo, string fldName) + { + string fldValue = string.Empty; + DataTable dcTable = dsDataSet.Tables["dc" + dcNo]; + if (dcTable.Rows.Count > 0) + { + try + { + fldValue = dcTable.Rows[0][fldName].ToString(); + } + catch (Exception ex) + { } + } + return fldValue; + } + + public string DeleteImages(TStructData tstData, string recId, string fieldName) + { + string res = ""; + transid = tstData.transid.ToString(); + fieldName = fieldName.Substring(0, fieldName.LastIndexOf("F") - 3); + int index = fldNames.IndexOf(fieldName); + string fldFrameNo = GetFrameNo(fieldName); + string value = GetFieldValue(fldFrameNo, fieldName); + + string strFile = ""; + strFile = scriptsPath + "axpert\\" + sessionid; + + string strDest = "", strDestNew = ""; + if (imgAttachPath != "") + { + strDest = imgAttachPath + "\\axpert\\" + transid + "\\" + fldNames[index].ToString(); + strDestNew = imgAttachPath + "\\" + transid + "\\" + fldNames[index].ToString(); + } + else + { + strDest = scriptsPath + "axpert\\" + sessionid + "\\" + fldNames[index].ToString(); + } + + //loop to check if multiple images exist for same field, if yes then delete all. + DirectoryInfo di = new DirectoryInfo(strDestNew); + try + { + if (di.Exists) + { + FileInfo[] files = di.GetFiles(); + for (int j = 0; j < files.Length; j++) + { + FileInfo file = (FileInfo)files[j]; + string[] fileStr = file.Name.Split('-'); + if (fileStr[0].ToString() == recId) + { + file.Delete(); + } + } + } + DirectoryInfo diNew = new DirectoryInfo(strDest); + if (diNew.Exists) + { + FileInfo[] files = diNew.GetFiles(); + for (int j = 0; j < files.Length; j++) + { + FileInfo file = (FileInfo)files[j]; + string[] fileStr = file.Name.Split('-'); + if (fileStr[0].ToString() == recId) + { + file.Delete(); + } + } + } + + } + catch (Exception ex) + { + res = ex.Message; + } + + return res; + } + + //Function to copy the image from the given source path to the destination path. + private void CopyFiles(string sourcePath, string destPath, string srcFileName, string desFileName) + { + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + DirectoryInfo sPath = new DirectoryInfo(sourcePath); + DirectoryInfo dPath = new DirectoryInfo(destPath); + + if (!dPath.Exists) + dPath.Create(); + + if (sPath.Exists) + { + BinaryReader brReader = default(BinaryReader); + BinaryWriter brWriter = default(BinaryWriter); + + string strFile = sourcePath + "\\" + srcFileName; + string strDest = destPath + "\\" + desFileName; + FileStream input = null; + try + { + input = new FileStream(strFile, FileMode.Open, FileAccess.Read); + } + catch (FileNotFoundException ex) + { + + } + if (input != null) + { + FileStream output = new FileStream(strDest, FileMode.Create, FileAccess.Write); + brReader = new System.IO.BinaryReader(input); + brWriter = new System.IO.BinaryWriter(output); + int bufsize = 30000; + // this is buffer size + int readcount = 0; + int bsize = 0; + + int indexer = 0; + FileInfo fileInfo = new FileInfo(strFile); + + int FileLen = Convert.ToInt32(fileInfo.Length); + while ((readcount < FileLen)) + { + if (bufsize < FileLen - readcount) + { + bsize = bufsize; + } + else + { + bsize = FileLen - readcount; + } + byte[] buffer = new byte[bsize]; + + brReader.Read(buffer, indexer, bsize); + brWriter.Write(buffer, indexer, bsize); + + readcount = readcount + bsize; + } + + brReader.Close(); + brWriter.Close(); + brReader.Dispose(); + brWriter.Dispose(); + output.Dispose(); + input.Dispose(); + } + } + } + } + #region GridAttachments + public void LoadGridAttsToFolder(string recId, string tid) + { + string destFilePath = scriptsPath + "axpert\\" + HttpContext.Current.Session["nsessionid"]; + string srcFilePath = string.Empty; + string srcpathValue = string.Empty; + string grdAttPath = string.Empty; + //string schemaName = project; + grdAttPath = HttpContext.Current.Session["grdAttPath"].ToString(); + string attachTid = GetAttachTransid(); + + ArrayList attFileNames = new ArrayList(); + bool hasGridAttachFld = false; + foreach (var attFld in tstStrObj.AxAttachFields) + { + int idx = tstStrObj.GetFieldIndex(attFld.ToString()); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[idx]; + + if ((fld.name.StartsWith("dc") && fld.name.ToLower().EndsWith("_imagepath")) && IsDcGrid(fld.fldframeno.ToString(), tstStrObj)) + hasImagePath = true; + + //If dc_referimages is defined for referring Attachments + if ((fld.name.StartsWith("dc") && fld.name.ToLower().EndsWith("_referimages")) && IsDcGrid(fld.fldframeno.ToString(), tstStrObj)) + { + TStructDef.DcStruct dc1 = (TStructDef.DcStruct)tstStrObj.dcs[fld.fldframeno - 1]; + + DataTable dcTable1 = dsDataSet.Tables["dc" + dc1.frameno]; + + string refVal1 = string.Empty; + for (int k = 0; k < dcTable1.Rows.Count; k++) + { + if (string.IsNullOrEmpty(Convert.ToString(dcTable1.Rows[k]["dc" + dc1.frameno + "_referimages"]))) + refVal1 = dcTable1.Rows[k]["dc" + dc1.frameno + "_referimages"].ToString(); + GetReferedFiles(refVal1, hasImagePath); + } + + } + if (((fld.name.StartsWith("axp_gridattach_")) || (fld.name.StartsWith("dc") && fld.name.ToLower().EndsWith("_image"))) && !(fld.name.StartsWith("axp_nga_")) && IsDcGrid(fld.fldframeno.ToString(), tstStrObj)) + { + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[fld.fldframeno - 1]; + if (dc.DCHasDataRows) + { + if (!(fld.name.StartsWith("axp_gridattach_"))) + srcFilePath = grdAttPath + "\\" + attachTid + "\\" + fld.name; + //srcFilePath = grdAttPath + "\\" + schemaName + "\\" + attachTid + "\\" + fld.name; + else + { + hasGridAttachFld = true; + srcFilePath = grdAttPath + "\\" + attachTid + "\\" + recId + "\\" + fld.name; + //srcFilePath = grdAttPath + "\\" + schemaName + "\\" + attachTid + "\\" + recId + "\\" + fld.name; + } + + string value = string.Empty; + DataTable dcTable = dsDataSet.Tables["dc" + dc.frameno]; + string sfileEx = string.Empty; + + for (int j = 0; j < dcTable.Rows.Count; j++) + { + attFileNames.Clear(); + value = dcTable.Rows[j][fld.name].ToString(); + string[] attFiles; + if (value != "") + sfileEx = value.Substring(value.LastIndexOf(".")); + //If axpattach_filename is defined + if (dcTable.Columns.Contains("axpattach_filename" + dc.frameno)) + { + if (value != string.Empty) + if (dcTable.Rows[j]["axpattach_filename" + dc.frameno].ToString() != string.Empty) + value = dcTable.Rows[j]["axpattach_filename" + dc.frameno].ToString() + sfileEx; + } + //If dc_imagepath is defined + if (dcTable.Columns.Contains("dc" + dc.frameno + "_imagepath")) + { + srcFilePath = GetdcImagePath(dcTable.Rows[j]["dc" + dc.frameno + "_imagepath"].ToString()); + + } + //If dc_image field is referring attachments + if (value.Contains("@")) + { + GetReferedFiles(value, hasImagePath); + } + if (value.Contains(",")) + { + attFiles = value.Split(','); + for (int attCount = 0; attCount < attFiles.Length; attCount++) + attFileNames.Add(recId + "-" + attFiles[attCount]); + } + else + attFileNames.Add(recId + "-" + value); + + LoadFilefromFolder(srcFilePath, destFilePath, attFileNames, recId); + } + + } + else + { + //If no DataRows are there, and the Tstruct is referring attachments through dc_image field + if (fld.name.StartsWith("dc") && fld.name.ToLower().EndsWith("_image")) + { + DataTable dcTableRef = dsDataSet.Tables["dc" + dc.frameno]; + for (int j = 0; j < dcTableRef.Rows.Count; j++) + { + string dcrefVal1 = dcTableRef.Rows[j]["dc" + dc.frameno + "_image"].ToString(); + if (dcrefVal1.Contains("@")) + { + GetReferedFiles(dcrefVal1, hasImagePath); + } + } + } + } + } + else if (fld.name.StartsWith("axp_nga_")) + { + sessionid = HttpContext.Current.Session["nsessionid"].ToString(); + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[fld.fldframeno - 1]; + DataTable dcTable = dsDataSet.Tables["dc" + dc.frameno]; + if (dcTable != null && dcTable.Rows.Count > 0) + { + string value = dcTable.Rows[0][fld.name].ToString(); + string[] attFiles; + attFileNames.Clear(); + if (value.Contains(",")) + { + attFiles = value.Split(','); + for (int attCount = 0; attCount < attFiles.Length; attCount++) + attFileNames.Add(recId + "-" + attFiles[attCount]); + } + else + attFileNames.Add(recId + "-" + value); + string scrPath = scriptsPath + "axpert\\" + sessionid; + string desFilePath = "", desFilePathOld = ""; + if (imgAttachPath != "") + { + desFilePathOld = imgAttachPath + "\\axpert\\" + transID + "\\" + recId + "\\" + fld.name; + desFilePath = imgAttachPath + "\\" + transID + "\\" + fld.name; + } + else + { + desFilePath = scriptsPath + "axpert\\" + transID + "\\" + fld.name; + } + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + DirectoryInfo di = new DirectoryInfo(desFilePath); + if (!di.Exists) + di.Create(); + + FileInfo[] fileEntries = di.GetFiles(); + //TODO: since the loop is breaking after the first loop, the i need not be incremented + for (int k = 0; k < fileEntries.Length; k++) + { + FileInfo file = (FileInfo)fileEntries[k]; + string imgName = file.Name.Substring(0, 13); + if (imgName == recId) + { + string destValue = file.Name.Replace(imgName, recId); + if (File.Exists(desFilePath + "\\" + destValue)) + { + imageFldSrc.Add(scrPath + "axpert\\" + sessionid + "\\" + destValue); + LoadFilefromFolder(desFilePath, scrPath, attFileNames, recId); + } + else + { + DirectoryInfo diOld = new DirectoryInfo(desFilePathOld); + if (diOld.Exists) + { + FileInfo[] fileEntriesOld = diOld.GetFiles(); + //TODO: since the loop is breaking after the first loop, the i need not be incremented + for (int j = 0; j < fileEntriesOld.Length; j++) + { + FileInfo fileOld = (FileInfo)fileEntriesOld[j]; + imageFldSrc.Add(scrPath + "axpert\\" + sessionid + "\\" + fileOld.Name); + LoadFilefromFolder(desFilePath, scrPath, attFileNames, recId); + } + } + } + break; + } + } + } + } + } + } + } + + private string GetImgServerPath() + { + + string grdAttPath = string.Empty; + string imageServer = string.Empty; + + if (HttpContext.Current.Session["AxpImageServerGbl"] != null) + { + imageServer = HttpContext.Current.Session["AxpImageServerGbl"].ToString(); + imageServer = imageServer.Replace(";bkslh", @"\"); + } + + return imageServer; + } + private void LoadFilefromFolder(string fPath, string destFilePath, ArrayList attFileNames, string recId) + { + if (fPath != string.Empty) + { + DirectoryInfo di = new DirectoryInfo(fPath); + if (!di.Exists) + di.Create(); + foreach (string fileName in attFileNames) + { + bool isFileCopied = false; + FileInfo[] fileEntries = di.GetFiles(fileName); + if (fileEntries != null && fileEntries.Length > 0) + { + FileInfo file = (FileInfo)fileEntries[0]; + string[] fileVal = file.Name.Split(new[] { '-' }, 2); + + if (attFileNames.IndexOf(file.Name) != -1 && fileVal.Length > 1) + { + CopyFiles(fPath, destFilePath, file.Name, fileVal[1].ToString()); + } + else + CopyFiles(fPath, destFilePath, file.Name, file.Name); + isFileCopied = true; + } + else + { + string[] fileVal = fileName.Split(new[] { '-' }, 2); + string worFlname = string.Empty; + if (fileVal.Length > 1 && fileVal[0] == recId) + worFlname = fileVal[1].ToString(); + else + worFlname = fileName; + FileInfo[] fileEntrie = di.GetFiles(worFlname); + if (fileEntrie != null && fileEntrie.Length > 0) + { + FileInfo file = (FileInfo)fileEntrie[0]; + CopyFiles(fPath, destFilePath, file.Name, file.Name); + isFileCopied = true; + } + } + if (isFileCopied == false) + { + string[] fileVal = fileName.Split(new[] { '-' }, 2); + string neFlname = string.Empty; + if (fileVal.Length > 1 && fileVal[0] == recId) + neFlname = fileVal[1].ToString(); + else + neFlname = fileName; + AxGridAttNotExistList.Add(neFlname); + } + } + } + } + private void GetReferedFiles(string dcfldValue, bool hasImagePath) + { + string destPath = scriptsPath + "axpert\\" + HttpContext.Current.Session["nsessionid"]; + string fldValue = string.Empty; + string folderPath = string.Empty; + string destFname = string.Empty; + string grdAttPath = string.Empty; + string referRecid = string.Empty; + string referfNames = string.Empty; + string[] referfNameOnebyOne; + try + { + string[] fldValues = dcfldValue.Split('@'); + if (hasImagePath) + { + grdAttPath = GetImgServerPath(); + for (int i = 0; i < fldValues.Length; i++) + { + //Eg:{@India\BLR\license.txt,release.txt} + + if (fldValues[i] != string.Empty) + { + string[] fValues = fldValues[i].Split('('); + for (int indx = 0; indx < fValues.Length; indx++) + { + if (fValues[indx].ToString() != String.Empty) + { + string[] fvalue = fValues[indx].Split(','); + } + } + folderPath = fldValues[i].Substring(0, fldValues[i].LastIndexOf("\\")); + referfNames = fldValues[i].Substring(fldValues[i].LastIndexOf("\\") + 1); + if (hasImagePath) + grdAttPath = grdAttPath + "\\" + folderPath; + } + } + + } + else + { + //Eg : {@MyDocs\transid\fieldname,recordid(filename1,f2,f3)} + + grdAttPath = HttpContext.Current.Session["grdAttPath"].ToString(); + + fldValue = dcfldValue.Substring(1, dcfldValue.Length - 1); + fldValues = fldValue.Split(new[] { ',' }, 2); + if (fldValues.Length > 1) + { + grdAttPath += "\\" + fldValues[0].ToString(); + int nFileSIndex = fldValues[1].IndexOf("("); + int nFileEIndex = fldValues[1].IndexOf(")") - 1; + + referfNames = fldValues[1].Substring(nFileSIndex + 1, nFileEIndex - nFileSIndex); + referRecid = fldValues[1].Substring(0, nFileSIndex); + } + + } + //Copying Files to Session folder + referfNameOnebyOne = referfNames.Split(','); + for (int k = 0; k < referfNameOnebyOne.Length; k++) + { + if (referfNameOnebyOne[k] != "") + if (hasImagePath) + CopyFiles(grdAttPath, destPath, referfNameOnebyOne[k], referfNameOnebyOne[k]); + else + { + destFname = referRecid + "-" + referfNameOnebyOne[k]; + CopyFiles(grdAttPath, destPath, destFname, destFname); + } + } + + + + } + catch (Exception ex) + { + } + } + + #endregion + //Function to check all images for the given record id and copy them to scripts folder. + private void LoadImageToFolder(string fldName, string recId) + { + string tmpFldName = fldName;//.Substring(0, fldName.LastIndexOf("F") - 3); + if (recId != "0") + { + sessionid = HttpContext.Current.Session["nsessionid"].ToString(); + //scriptsPath += "axpert\\" + sessionid + "\\" + fldName; + string scrPath = scriptsPath + "axpert\\" + sessionid + "\\" + fldName; + string desFilePath = "", desFilePathOld = ""; + if (imgAttachPath != "") + { + desFilePathOld = imgAttachPath + "\\axpert\\" + transID + "\\" + recId + "\\" + fldName; + desFilePath = imgAttachPath + "\\" + transID + "\\" + fldName; + } + else + { + desFilePath = scriptsPath + "axpert\\" + transID + "\\" + fldName; + //desFilePath = scriptsPath + "axpert\\" + transID + "\\" + recId + "\\" + fldName; + } + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + DirectoryInfo di = new DirectoryInfo(desFilePath); + if (!di.Exists) + di.Create(); + + FileInfo[] fileEntries = di.GetFiles(); + //TODO: since the loop is breaking after the first loop, the i need not be incremented + for (int i = 0; i < fileEntries.Length; i++) + { + FileInfo file = (FileInfo)fileEntries[i]; + //imageFldNames.Add(fldName); + string imgName = file.Name.Substring(0, file.Name.LastIndexOf('.')); + if (imgName == recId) + { + imageFldNames.Add(fldName); + string destValue = file.Name.Replace(imgName, recId); + if (File.Exists(desFilePath + "\\" + destValue)) + { + imageFldSrc.Add(scriptsPath + "axpert\\" + sessionid + "\\" + destValue); + CopyFiles(desFilePath, scrPath, destValue, destValue); + } + else + { + DirectoryInfo diOld = new DirectoryInfo(desFilePathOld); + if (diOld.Exists) + { + FileInfo[] fileEntriesOld = diOld.GetFiles(); + //TODO: since the loop is breaking after the first loop, the i need not be incremented + for (int j = 0; j < fileEntriesOld.Length; j++) + { + FileInfo fileOld = (FileInfo)fileEntriesOld[j]; + imageFldNames.Add(fldName); + imageFldSrc.Add(scriptsPath + "axpert\\" + sessionid + "\\" + fileOld.Name); + CopyFiles(desFilePathOld, scrPath, fileOld.Name, fileOld.Name); + } + } + } + break; + } + } + } + } + } + + //Get the row numbers for the given dc no from the field array + private ArrayList GetGridRowsFromArray(string frmNo) + { + ArrayList gridRows = new ArrayList(); + for (int k = 0; k < fieldControlName.Count; k++) + { + int fIndx = 0; + fIndx = fieldControlName[k].ToString().LastIndexOf("F"); + string frameNo = fieldControlName[k].ToString().Substring(fIndx + 1); + string rowNo = fieldControlName[k].ToString().Substring(fIndx - 3, 3); + if (frameNo == frmNo) + { + int index = -1; + index = gridRows.IndexOf(rowNo); + if (index == -1) + gridRows.Add(rowNo); + } + } + return gridRows; + } + + //Function to get the concatenated string of parent field values in the pop grid dc. + private string GetParentValues(string[] popParentFlds, string rowNo, string frmNo) + { + return DSGetParentValues(popParentFlds, rowNo, frmNo); + } + + //Function to get the concatenated string of parent field values in the pop grid dc. + private string DSGetParentValues(string[] popParentFlds, string rowNo, string frmNo) + { + string parFldVals = ""; + for (int j = 0; j < popParentFlds.Length; j++) + { + double fldNumber; + string popFielsName = "sub" + frmNo + "_" + popParentFlds[j].Trim(); + string popFldValue = string.Empty; + if (DSGetRow(rowNo, Convert.ToInt32(frmNo)).Table.Columns.Contains(popFielsName)) + popFldValue = DSGetRow(rowNo, Convert.ToInt32(frmNo))[popFielsName].ToString(); + else + { + popFielsName = "Sub" + frmNo + "_" + popParentFlds[j].Trim(); + popFldValue = DSGetRow(rowNo, Convert.ToInt32(frmNo))[popFielsName].ToString(); + } + + bool isNumber = double.TryParse(popFldValue, out fldNumber); + if (isNumber == true) + { + double popVal = double.Parse(popFldValue); + parFldVals += popVal.ToString(); + } + else + { + parFldVals += popFldValue; + } + } + return parFldVals; + } + + public DataRow DSGetRow(string rowNo, int dcNo) + { + if (dcNo == 0) return null; + DataTable dt = dsDataSet.Tables["dc" + dcNo]; + int rNo = Convert.ToInt32(rowNo); + if (rNo == 0) rNo = 1; + return dt.Rows.Find(rNo); + } + + public DataRow DsGetRow(string fldName, string rowNo) + { + return DSGetRow(rowNo, tstStrObj.GetFieldDc(fldName)); + } + + + public void GetKeyColValues(int dcNo, ArrayList arrKeyCols, ArrayList keyRowNos) + { + DSGetKeyColValues(dcNo, arrKeyCols, keyRowNos); + } + + private void DSGetKeyColValues(int dcNo, ArrayList arrKeyCols, ArrayList arrKeyRowNos) + { + DataTable dt = dsDataSet.Tables["dc" + dcNo]; + foreach (DataRow dr in dt.Rows) + { + string keyValue = string.Empty; + string keyRow = string.Empty; + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[dcNo - 1]; + keyValue = dr[dc.KeyColumn].ToString(); + keyRow = dr["axp__rowno"].ToString(); + int keyIndex = arrKeyCols.IndexOf(keyValue); + if (keyIndex == -1) + { + arrKeyCols.Add(keyValue); + arrKeyRowNos.Add(keyRow); + } + else + { + arrKeyRowNos[keyIndex] += "," + keyRow; + } + } + } + + private int GetFldArrayIndex(string fieldName) + { + int index = -1; + for (int cnt = 0; cnt < fieldControlName.Count; cnt++) + { + if (fieldControlName[cnt].ToString().ToLower() == fieldName.ToLower()) + index = cnt; + } + return index; + } + + private void DeleteDefaultRowInPopDc(string project, string user, string transid, string sessionId, string AxRole) + { + + ArrayList deleteRows = new ArrayList(); + bool isRowFound = false; + for (int i = 0; i < tstStrObj.popdcs.Count; i++) + { + TStructDef.PopDcStruct popDc = (TStructDef.PopDcStruct)tstStrObj.popdcs[i]; + string[] popParentFlds = popDc.pfields.Split(','); + + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[popDc.frameno - 1]; + + if (popDc.pFirm == "t" || !dc.DCHasDataRows) + continue; + + int rowCount = GetDcRowCount(dc.frameno.ToString()); + for (int k = 1; k < rowCount; k++) + { + for (int j = 0; j < popParentFlds.Length; j++) + { + string prefix = "sub"; + string popFielsName = prefix + popDc.frameno + "_" + popParentFlds[j].Trim() + GetRowNoHelper(k.ToString()) + "F" + popDc.frameno; + //int idx = GetFldIndex(dc.frameno, "sub" + popDc.frameno + "_" + popParentFlds[j].Trim(), k; + DataRow dr = DsGetRow(prefix + popDc.frameno + "_" + popParentFlds[j].Trim(), k.ToString()); + if (dr == null) + { + prefix = "Sub"; + DsGetRow(prefix + popDc.frameno + "_" + popParentFlds[j].Trim(), k.ToString()); + + } + if (dr != null) + { + string fldValue = dr[prefix + popDc.frameno + "_" + popParentFlds[j].Trim()].ToString(); + + if (fldValue == "" || fldValue == "***") + { + string rowNo = k.ToString(); + if (rowNo != "-1") + deleteRows.Add(rowNo + "F" + popDc.frameno); + isRowFound = true; + break; + } + } + } + if (isRowFound) + { + isRowFound = false; + break; + } + + } + for (int dCnt = 0; dCnt < deleteRows.Count; dCnt++) + { + int fIdx = deleteRows[dCnt].ToString().IndexOf("F"); + string delRowNo = deleteRows[dCnt].ToString().Substring(0, fIdx); + string delDcNo = deleteRows[dCnt].ToString().Substring(fIdx + 1); + if (GetDcRowCount(delDcNo) == 1 && delRowNo == "001") + { + TStructDef.DcStruct pdc = (TStructDef.DcStruct)tstStrObj.dcs[Convert.ToInt32(delDcNo) - 1]; + pdc.DCHasDataRows = false; + tstStrObj.dcs[Convert.ToInt32(delDcNo) - 1] = pdc; + break; + } + DeleteRowInFldArrays(delDcNo, delRowNo); + int tmpRowCnt = GetDcRowCount(delDcNo); + tmpRowCnt = tmpRowCnt - 1; + UpdateRowCount("DC" + delDcNo, "DC" + delDcNo + "~" + tmpRowCnt); + } + } + } + + /// + /// Function to be called to add group + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public string CallActionWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, ArrayList deletedFldArrayValues, string s, string f, string source, string delRows, string changedRows, string frameNo, string calledFrom = "false", bool isScript = false) + { + string news = GetTraceString(s); + if (news != "") s = news; + result = string.Empty; + //GetGlobalVars(); + + string cngRows = GetChangedRows(changedRows); + delRows = GetDelRowsNode(delRows); + transid = tstData.transid.ToString(); + ires = tstStrObj.structRes; + frameNo = (Convert.ToInt32(frameNo) - 1).ToString(); + + tstData.GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, frameNo, calledFrom, "ALL", ""); + + + s += tstData.fieldValueXml + memVarsData + "" + delRows + cngRows; + s += HttpContext.Current.Session["axApps"].ToString(); + s += HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString() + ""; + + + if (ires == null) + ires = ""; + + if (isScript) + { + filename = "Script-" + transid; + logobj.CreateLog("Call to RemoteDoScript Web Service", sessionid, filename, ""); + + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.callRemoteDoScriptWS(transid, s, ires, tstData.tstStrObj.WebServiceTimeout); + + } + else + { + filename = "Action-" + transid; + logobj.CreateLog("Call to RemoteDoAction Web Service", sessionid, filename, ""); + + + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallRemoteDoActionWS(transid, s, ires, tstData.tstStrObj.WebServiceTimeout); + + } + if (result != null) + result = result.Split('♠')[1]; + CheckSave(result, delRows, tstData, changedRows, deletedFldArrayValues); + logobj.CreateLog("End Time : " + DateTime.Now.ToString(), sessionid, filename, ""); + return result; + } + + public string CallActionWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, ArrayList deletedFldArrayValues, string s, string f, string source, string delRows, string changedRows, string calledFrom = "false", StringBuilder files = null, bool isScript = false) + { + string news = GetTraceString(s); + if (news != "") s = news; + result = string.Empty; + if (source == "t") + { + string imagefromdb = "false"; + if (HttpContext.Current.Session["AxpSaveImageDb"] != null) + imagefromdb = HttpContext.Current.Session["AxpSaveImageDb"].ToString(); + if (s != string.Empty) + s = s.Replace("" + delRows + cngRows; + s += HttpContext.Current.Session["axApps"].ToString(); + s += HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString() + ""; + } + else + ires = ""; + + XmlDocument xmlDoc = new XmlDocument(); + string newfilename = ""; + if (f != "" && f.Contains("&")) + { + + newfilename = f.Replace("&", "&"); + + s = s.Replace("__file=\"" + f.ToString() + "\"", "__file=\"" + newfilename.ToString() + "\"");//& + + } + xmlDoc.LoadXml(s); + XmlNode rootNode = xmlDoc.SelectSingleNode("//root"); + if (rootNode != null) + { + if (rootNode.Attributes["actname"].Value != string.Empty) + AxActiveAction = rootNode.Attributes["actname"].Value; + } + + if (ires == null) + ires = ""; + if (isScript) + { + filename = "Script-" + transid; + logobj.CreateLog("Call to RemoteDoScript Web Service", sessionid, filename, ""); + + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.callRemoteDoScriptWS(transid, s, ires, tstData.tstStrObj.WebServiceTimeout); + + } + else + { + filename = "Action-" + transid; + logobj.CreateLog("Call to RemoteDoAction Web Service", sessionid, filename, ""); + + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallRemoteDoActionWS(transid, s, ires, tstData.tstStrObj.WebServiceTimeout); + } + + string requestProcess_logtime = result.Split('♠')[0]; + result = result.Split('♠')[1]; + //avoid special chars in result DURING notify + if (result != "This proces taking time is more than expected. You will get a notification once completed") + CheckSave(result, delRows, tstData, changedRows, deletedFldArrayValues, (files != null ? files.ToString() : "")); + AxActiveAction = string.Empty; + logobj.CreateLog("End Time : " + DateTime.Now.ToString(), sessionid, filename, ""); + result = requestProcess_logtime + "♠" + result; + return result; + } + + private void CheckSave(string result, string delRows, TStructData tstData, string changedRows, ArrayList deletedFldArrayValues, string files = "") + { + if (result == "") return; + result = result.Replace("\\", ";bkslh"); + //To save the image fields in server folders, + //the below code checks if the action was 'save' and copies the images to the folders. + + string returnStr = result.Replace("*$*", "¿"); + string[] newResult = returnStr.Split('¿'); + for (int i = 0; i < newResult.Length; i++) + { + if (newResult[i].ToString() == "") + continue; + JArray action; + try + { + JObject actionresult = JObject.Parse(newResult[i].ToString()); + action = (JArray)actionresult["command"]; + } + catch (Exception ex) + { + throw ex; + } + + if (action != null) + { + string cmd = string.Empty; + string cmdVal = string.Empty; + string pname = string.Empty; + string pvalue = string.Empty; + string showin = string.Empty; + string recId = string.Empty; + string actionValue = string.Empty; + for (int m = 0; m < action.Count; m++) + { + cmd = (string)action[m]["cmd"].ToString().Trim('"'); + + cmdVal = (string)action[m]["cmdval"].ToString().Trim('"'); + + if (cmd == "openiview") + { + pname = (string)action[m]["pname"].ToString().Trim('"'); + pvalue = (string)action[m]["pvalue"].ToString().Trim('"'); + showin = (string)action[m]["showin"].ToString().Trim('"'); + AddParamsToSession(cmdVal, pname, pvalue, showin); + } + + + if (cmd == "action") + actionValue = cmdVal; + else if (cmd == "recid") + recId = cmdVal; + } + + + if (actionValue.ToLower() == "save") + { + if (HttpContext.Current.Session["AxReloadCloud"] != null) + { + if (HttpContext.Current.Session["AxReloadCloud"].ToString() == transid) + { + try + { + HttpContext.Current.Session["IscloudRelogin"] = "true"; + HttpContext.Current.Session["AxInternalRefresh"] = "true"; + util.ClearAxpStructConfigInRedis(Constants.AXCONFIGGENERAL, "", "", "general", ""); + } + catch (Exception ex) + { + HttpContext.Current.Session["IscloudRelogin"] = "true"; + HttpContext.Current.Session["AxInternalRefresh"] = "true"; + logobj.CreateLog("Main Page Reload-" + ex.Message, sessionid, "MainPageReload", "new", "true"); + } + } + } + + if (util.isRealTimeCacEnabled(transid, tstStrObj)) + HttpContext.Current.Session["AxRelKeys"] = util.GetAxRelations(tstData.transid); + else + HttpContext.Current.Session["AxRelKeys"] = null; + + if (recId != string.Empty) + { + if (tstStrObj.AxpFileUploadFields.Count > 0) + RemoveUnwantedAxpFiles(transid, recId, delRows, tstData, deletedFldArrayValues); + + //TStructDef strObj = cm.GetStructDef(project, sessionid, user, transid, AxRole); + if (tstStrObj.ContainsImage) + + SaveImageToFolder(tstStrObj, transid, sessionid, recId, deletedFldArrayValues); + + if (tstStrObj.ContainsGridAttach) + { + try + { + string gridAttSaveResult = SaveGridAttachments(transid, sessionid, recId, delRows, tstData, changedRows, deletedFldArrayValues); + } + catch (Exception ex) + { + logobj.CreateLog("Error while SaveGridAttachments-" + ex.Message, sessionid, "SaveGridAttachments", "new", "true"); + } + } + + if (attachDir && (!string.IsNullOrEmpty(files) || removeFiles.Count > 0)) + SaveAttached(files, recId); + } + RefFastDataOnSave(AxActiveAction); + RefInMemOnSave(); + } + } + } + } + + private void RefFastDataOnSave(string taskName) + { + //If fast data refresh events are not empty + FDW fobj = FDW.Instance; + for (int i = 0; i < tstStrObj.fastDataRefEvent.Count; i++) + { + if (tstStrObj.fastDataRefEvent[i].ToString().Contains(taskName)) + { + //TODO: Push refresh in Fastdata + string dsName = string.Empty; + dsName = tstStrObj.fastDataRefDSName[i].ToString(); + fobj.PushToDsRefresh(util.GetFastDataDSName(null, dsName)); + //objfd.RefreshFastDataset(dsName); + //Thread thread = new Thread(() => objfd.PushRefreshDs(dsName, user)); + //thread.Start(); + } + } + } + + private void AddParamsToSession(string ivName, string paramNames, string paramVals, string showIn) + { + + string customIv = GetFieldValue("1", "axp_ivname"); + if (customIv != "") + ivName = customIv; + + if (paramNames.IndexOf("###") != -1) + paramNames = paramNames.Replace("###", "¿"); + + if (paramVals.IndexOf("###") != -1) + paramVals = paramVals.Replace("###", "¿"); + + string[] strParams = paramNames.Split('¿'); + string[] strParamVals = paramVals.Split('¿'); + var paramsStr = ""; + int pCount = strParams.Length; + Util.Util utilObj = new Util.Util(); + + if (pCount != 0) + { + + var paraName = ""; var paraVal = ""; var fres = ""; + for (var cmp = 0; cmp < pCount; cmp++) + { + paraName = strParams[cmp]; + paraVal = strParamVals[cmp]; + //paraVal = utilObj.CheckUrlSpecialChars(paraVal); + paraVal = paraVal.Replace("=", "@eq@"); + fres = paraName + "=" + paraVal; + fres = fres.Replace("&", "--.--"); + paramsStr = paramsStr + "&" + fres; + } + + } + if (showIn != "" && showIn == "pop") + showIn = "&pop=true"; + paramsStr = paramsStr + showIn; + //HttpContext.Current.Session["AxActionParams" + ivName] = paramsStr; + //HttpContext.Current.Session["IviewNavigationData-" + ivName] = paramsStr; + + ASB.WebService webService = new ASB.WebService(); + + webService.SetIviewNavigationData(paramsStr, ivName); + } + + private string AddToken(string iXml) + { + string token = ""; + token = util.GetToken(); + HttpContext.Current.Session["axpToken"] = token; + iXml = iXml.Replace(" IncludeDcRows = new Dictionary(); + isDcGrid = IsDcGrid(frameNo, tstStrObj); + logobj.CreateLog("Constructing input xml GetRapidDepFLd-field" + fld.name, sessionid, "GetRapidDep-" + transid, "new"); + UpdateDataList(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray); + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + DSRapidFieldValueXML(frameNo, rowNo, fieldName, "RapidDep", fld); + if (fld.FldRapidAllParents != string.Empty) + inputXml += GetGlobalVarValues(fld.FldRapidAllParents); + inputXml += tstData.fieldValueXml + memVarsData; + inputXml += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + inputXml += ""; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + logobj.CreateLog("Input xml GetRapidDepFLd=" + inputXml, sessionid, "GetRapidDep-" + transid, ""); + DateTime asStart = DateTime.Now; + result = objWebServiceExt.CallGetRapidDepFldVals(transid, inputXml); + logobj.CreateLog("RapidGetDepentendFieldValues Result=" + result, sessionid, "GetRapidDep-" + transid, ""); + DateTime asEnd = DateTime.Now; + if (logTimeTaken) + { + webTime1 = asStart.Subtract(stTime).TotalMilliseconds; + webTime2 = DateTime.Now.Subtract(asEnd).TotalMilliseconds; + asbTime = asEnd.Subtract(asStart).TotalMilliseconds; + } + return result; + } + + private string GetGlobalVarValues(string parentFlds) + { + StringBuilder paramsNode = new StringBuilder(); + paramsNode.Append(""); + List paramFlds = parentFlds.Split(',').ToList(); + + for (int j = 0; j < paramFlds.Count; j++) + { + for (int i = 0; i < tstStrObj.lstGlobalParams.Count; i++) + { + string[] strVar = tstStrObj.lstGlobalParams[i].ToString().Split('='); + string value = CheckSpecialChars(strVar[1].ToString()); + string pName = paramFlds[j].ToString(); + if (strVar[0].ToString() == pName) + { + paramsNode.Append("<" + pName + ">" + value + ""); + } + } + } + + if (HttpContext.Current.Session["user"] != null) + paramsNode.Append("" + HttpContext.Current.Session["user"].ToString() + ""); + + paramsNode.Append(""); + return paramsNode.ToString(); + } + + public string CallGetDepFldWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string s, string frameNo, string rowNo, string fieldName, string subGridInfo, string parentInfo) + { + DateTime stTime = DateTime.Now; + string news = GetTraceString(s); + if (news != "") s = news; + string result = null; + transid = tstData.transid.ToString(); + ires = tstStrObj.structRes; + AxActDepField = fieldName; + int idx = tstStrObj.GetFieldIndex(fieldName); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[idx]; + ArrayList AxDepFields = new ArrayList(); + bool isDcGrid = false; + Dictionary IncludeDcRows = new Dictionary(); + isDcGrid = IsDcGrid(frameNo, tstStrObj); + + if (isDcGrid) + { + string DepFlds = fld.fieldSqlDepParents; + AxDepFields = GetParDepFlds(fld.fieldSqlDepParents); + } + + if (fld.fieldSqlGridDeps != string.Empty) + { + string[] strSDeps = fld.fieldSqlGridDeps.Split(','); + for (int i = 0; i < strSDeps.Length; i++) + { + AxDepFields.Add(strSDeps[i].ToString()); + } + + //The below statement will add the current field to the dependent fields if the current dc is a grid dc + //and it has dependents in other grid, then all the row values for the field should be sent in the input xml. + if (isDcGrid) + AxDepFields.Add(fld.name); + } + + + //If the field has non grid sql dependents, then send the parent values for that dep field also + if (IsDcGrid(frameNo, tstStrObj)) + { + + //If the call is made from a parent grid, then all its subgriud and their respective rows for the given parent row + //will be sent in the given format: dcno~rowno1,rowno2¿dcno~rowno1,rowno2... + if (subGridInfo != "") + { + if (subGridInfo.IndexOf("¿") != -1) + { + string[] subgridDcs = subGridInfo.Split('¿'); + for (int i = 0; i < subgridDcs.Length; i++) + { + if (subgridDcs[i] != string.Empty) + { + string[] dcInfo = subgridDcs[i].ToString().Split('~'); + IncludeDcRows.Add(dcInfo[0], dcInfo[1]); + } + } + } + else + { + IncludeDcRows.Add(subGridInfo.Substring(0, subGridInfo.IndexOf("~")), subGridInfo.Substring(subGridInfo.IndexOf("~") + 1)); + } + } + + //If the call is made from sub grid, then the parentinfo will contain the parent dc no and parent row no in the given format : dcno~rowno + if (parentInfo != "") + { + IncludeDcRows.Add(parentInfo.Substring(0, parentInfo.IndexOf("~")), parentInfo.Substring(parentInfo.IndexOf("~") + 1)); + } + + + //first update the list with the new fldArray. + UpdateDataList(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray); + + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + + CreateFieldValueXmlPerf(frameNo, rowNo, AxDepFields, fld.fieldDepGridDcs, IncludeDcRows, ""); + + //Refer bug - AGI003591 + //This function was converting the last invalid row to valid row + //UpdateGridDelRowVal(int.Parse(frameNo)); + + s += tstData.fieldValueXml; + } + else + { + + if (AxDepFields.Count > 0) + { + //if a non grid fields has dependent grid dc fields, then send that dc fields data also. + //first update the list with the new fldArray. + UpdateDataList(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray); + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + CreateFieldValueXmlPerf(frameNo, rowNo, AxDepFields, fld.fieldDepGridDcs, IncludeDcRows, ""); + s += tstData.fieldValueXml; + } + else + { + //if (fld.fieldDepFillDcs != string.Empty) + //{ + // string[] depFillDcs = fld.fieldDepFillDcs.Split(','); + // for (int dIdx = 0; dIdx < depFillDcs.Length; dIdx++) + // { + // TStructDef.DcStruct depDc = (TStructDef.DcStruct)tstStrObj.dcs[Convert.ToInt32(depFillDcs[dIdx].ToString()) - 1]; + + // } + //} + + + //if a non grid fields has dependent grid Fill grid dc, then send that dc data also. + //TODO: this condition should not send all the fillgrid dep dc data + tstData.GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "GetDependents", "NG", fld.fieldDepFillDcs); + s += tstData.fieldValueXml; + } + } + + s += memVarsData; + s += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + s += ""; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + + DateTime asStart = DateTime.Now; + result = objWebServiceExt.CallGetDepentendFieldValuesWS(transid, s, ires); + DateTime asEnd = DateTime.Now; + if (logTimeTaken) + { + webTime1 = asStart.Subtract(stTime).TotalMilliseconds; + webTime2 = DateTime.Now.Subtract(asEnd).TotalMilliseconds; + asbTime = asEnd.Subtract(asStart).TotalMilliseconds; + } + return result; + } + + public string CallGetDepFldPerfWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, ArrayList regVarFldList, string s, string frameNo, string rowNo, string perfDepFldName, string fieldName, string subGridInfo, string parentInfo) + { + DateTime stTime = DateTime.Now; + string news = GetTraceString(s); + if (news != "") s = news; + string result = null; + transid = tstData.transid.ToString(); + AxActDepField = fieldName; + ires = tstStrObj.structRes; + tstData.GetPerfFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "GetDependents", "NG", ""); + + string imagefromdb = "false"; + if (HttpContext.Current.Session["AxpSaveImageDb"] != null) + imagefromdb = HttpContext.Current.Session["AxpSaveImageDb"].ToString(); + if (s != string.Empty) + s = s.Replace(" 0) + { + string regVarXml = ""; + try + { + foreach (var varVal in regVarFldList) + { + regVarXml += "<" + varVal.ToString().Split(':')[0] + " t='" + varVal.ToString().Split(':')[1] + "'>" + varVal.ToString().Split(':')[2] + ""; + } + } + catch (Exception ex) { } + s += regVarXml; + } + s += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + s += ""; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + DateTime asStart = DateTime.Now; + result = objWebServiceExt.CallGetDepentendFieldValuesWS(transid, s, ires); + DateTime asEnd = DateTime.Now; + if (logTimeTaken) + { + webTime1 = asStart.Subtract(stTime).TotalMilliseconds; + webTime2 = DateTime.Now.Subtract(asEnd).TotalMilliseconds; + asbTime = asEnd.Subtract(asStart).TotalMilliseconds; + } + return result; + } + + + public string PerfGetDepFldInput(string fieldName, string perfDepFldName, string frameNo, string rowNo) + { + string inputFldXML = string.Empty; + try + { + int dfIndx = tstStrObj.GetFieldIndex(fieldName); + TStructDef.FieldStruct dfld = (TStructDef.FieldStruct)tstStrObj.flds[dfIndx]; + string[] parentFlds = dfld.fieldParents.Replace("~", ",").Split(',');// a66 node of dependent field + string[] parentDcFlds = new string[] { }; + if (perfDepFldName.StartsWith("dc")) + { + try + { + int dcFrame = int.Parse(perfDepFldName.Substring(2)); + TStructDef.DcStruct pfldDc = (TStructDef.DcStruct)tstStrObj.dcs[dcFrame - 1]; + if (pfldDc.dcPList != "") + parentDcFlds = pfldDc.dcPList.Replace("~", ",").Split(','); + } + catch (Exception ex) { } + } + string[] lstparentFlds = parentFlds.Union(parentDcFlds).ToArray(); + string globalVars = HttpContext.Current.Session["axGlobalVars"].ToString(); + string userVars = HttpContext.Current.Session["axUserVars"].ToString(); + TStructDef.DcStruct dfldDc = (TStructDef.DcStruct)tstStrObj.dcs[dfld.fldFrameNo - 1]; + for (int i = 0; i < lstparentFlds.Length; i++) + { + int arNumber = 0; + int pIndx = tstStrObj.GetFieldIndex(lstparentFlds[i]); + if (pIndx == -1) + { + if (globalVars.ToLower().IndexOf("<" + lstparentFlds[i].ToLower() + ">") > -1) + continue; + else if (userVars.ToLower().IndexOf("<" + lstparentFlds[i].ToLower() + ">") > -1) + continue; + else + continue; + } + TStructDef.FieldStruct pfld = (TStructDef.FieldStruct)tstStrObj.flds[pIndx]; + TStructDef.DcStruct pfldDc = (TStructDef.DcStruct)tstStrObj.dcs[pfld.fldFrameNo - 1]; + //if (pfld.fldFrameNo == dfld.fldFrameNo && dfldDc.isgrid) // Dependent & Parent fields both are in same dc and the dc is grid dc should take active row only + // arNumber = int.Parse(rowNo); + + if (pfldDc.isgrid && pfldDc.DCHasDataRows)// Grid dc field should have 1 row minimum else the field not required in input + inputFldXML += PerfGetDepFldValues(pfld.fldFrameNo, arNumber, "GetDep", pfld); + else if (!pfldDc.isgrid)// Should take all the non grid dc fields following teh parents. + inputFldXML += PerfGetDepFldValues(pfld.fldFrameNo, arNumber, "GetDep", pfld); + } + } + catch (Exception ex) + { + logobj.CreateLog("PerfGetDepFldInput function -" + ex.Message, sessionid, "Exception-" + transid, ""); + } + return inputFldXML; + } + + private string PerfGetDepFldValues(int dcNo, int arNumber, string calledFrom, TStructDef.FieldStruct fld = new TStructDef.FieldStruct()) + { + string iXml = string.Empty; + TStructDef.DcStruct pfldDc = (TStructDef.DcStruct)tstStrObj.dcs[dcNo - 1]; + DataTable thisDataTable = dsDataSet.Tables["dc" + dcNo]; + string dcNumber = dcNo.ToString(); + string isGrdVld = string.Empty; + foreach (DataRow dr in thisDataTable.Rows) + { + int rowNo = Convert.ToInt32(dr["axp__rowno"]); + if (pfldDc.isgrid)//Refer Bug:AGI004107 + isGrdVld = dr["axp__isGrdVld" + dcNo].ToString(); + if (isGrdVld != "false") + { + DataTable dtOld = dsDataSet.Tables["dc_old" + dcNo]; + DataRow drOld = dtOld.Rows.Find(rowNo); + string value = string.Empty; + string oldValue = string.Empty; + string idValue = string.Empty; + string oldIdValue = string.Empty; + value = dr[fld.name].ToString(); + if (fld.savenormal) + idValue = dr["id__" + fld.name].ToString(); + + if (drOld != null) + { + oldValue = drOld["old__" + fld.name].ToString(); + if (fld.savenormal) + oldIdValue = drOld["oldid__" + fld.name].ToString(); + } + iXml += WsPerfFieldToXML(fld.name, Convert.ToString(rowNo), value, oldValue, idValue, oldIdValue, dcNumber, fld.savenormal, fld); + } + } + return iXml; + } + + public string CallRefreshDc(ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string iXml, string frameNo, string includeDcs) + { + string strTrace = GetTraceString(iXml); + if (strTrace != "") iXml = strTrace; + string result = string.Empty; + ires = tstStrObj.structRes; + GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "RefreshDc", "NG", includeDcs); + iXml += fieldValueXml + memVarsData; + iXml += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + iXml += ""; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallRefreshDc(iXml, ires); + return result; + } + + private ArrayList GetParDepFlds(string depStr) + { + ArrayList arrDeps = new ArrayList(); + string[] depFlds = depStr.Split(','); + for (int i = 0; i < depFlds.Length; i++) + { + arrDeps.Add(depFlds[i].ToString()); + } + return arrDeps; + } + + public string GetVisibleFormatGridsHtml(TStructDef strObj, string visibleDCsStr) + { + string[] visibleDCs = visibleDCsStr.Split(','); + + StringBuilder strDcHtml = new StringBuilder(); + for (int i = 0; i < visibleDCs.Length; i++) + { + string dcStr = visibleDCs[i].ToString().Substring(2); + int dcNo = Convert.ToInt32(dcStr); + if (depFormatDcs.IndexOf(dcStr) != -1 && ChangedDcs.IndexOf(dcStr) != -1) + try + { + strDcHtml.Append(strObj.GetTabDcHTML(dcNo, this, "false")); + } + catch (Exception ex) + { + + } + } + + return strDcHtml.ToString(); + } + + public string CallMsFillGrid(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string frameNo, string s, string paramXml, string fgName) + { + string news = GetTraceString(s); + if (news != "") s = news; + string result = null; + //GetGlobalVars(); + transid = tstData.transid.ToString(); + ires = tstStrObj.structRes; + + tstData.GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "FillGrid", "NG", ""); + + s += tstData.fieldValueXml + memVarsData; + s += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + s += ""; + + #region Data cache in session + //var dcFsg = tstStrObj.fgs.Cast().Where(f => f.fgtargetdc == ("dc" + frameNo) && f.fgName == fgName).ToList(); + //string fgSqlParam = string.Empty, fgSqlParamVal = string.Empty; + //if (dcFsg.Count > 0) + //{ + // TStructDef.FGStruct fg = ((TStructDef.FGStruct)dcFsg[0]); + // fgSqlParam = fg.fgSqlParams; + // if (fgSqlParam != string.Empty) + // { + // XmlDocument xml = new XmlDocument(); + // xml.LoadXml(s.ToLower()); + // foreach (var name in fgSqlParam.Split(',')) + // { + // var xnList = xml.SelectNodes("/sqlresultset/" + name); + // foreach (XmlNode text in xnList) + // fgSqlParamVal += "~" + name + ":" + text.InnerText.ToLower(); + // } + // } + //} + //if (HttpContext.Current.Session["FillGrid-" + transid + "-" + fgName + "-" + fgSqlParamVal] != null) + // result = HttpContext.Current.Session["FillGrid-" + transid + "-" + fgName + "-" + fgSqlParamVal].ToString(); + //else + //{ + // //Call service + // objWebServiceExt = new ASBExt.WebServiceExt(); + // result = objWebServiceExt.CallGetFillGridValuesWS(transid, s, ires); + // HttpContext.Current.Session["FillGrid-" + transid + "-" + fgName + "-" + fgSqlParamVal] = result; + //} + #endregion + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallGetFillGridValuesWS(transid, s, ires); + return result; + } + + public string GetCacheFileRecId(string recId) + { + string recIddataJson = "{\"data\": ["; + + recIddataJson += "{\"n\":\"DC1\",\"v\":\"1\",\"t\":\"dc\"},{\"n\":\"recid\",\"v\":\"" + recId + "\",\"r\":\"0\",\"t\":\"s\"}]}"; + DSSubmit("recid", 0, recId, ""); + return recIddataJson; + } + + /// + /// Function to return the Fill pop up html for the format fill grid. + /// + /// + /// + /// + /// + /// + public string ConstructFormatFillGrid(string result, TStructDef strObj, string dcNo, string src) + { + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(result); + int m = 0; + string fgRows = ""; + string cRows = ""; + string headRow = ""; + string chkboxVal = ""; + int colcount = 0; + string fgHTML = string.Empty; + XmlNodeList headNodes; + int rowCnt = 0; + string firstColValue = string.Empty; + headNodes = xmlDoc.SelectNodes("//response/row"); + TStructDef.DcStruct dc = ((TStructDef.DcStruct)(strObj.dcs[Convert.ToInt32(dcNo) - 1])); + foreach (XmlNode resNode in headNodes) + { + colcount = 0; + rowCnt = rowCnt + 1; + XmlNodeList headers = resNode.ChildNodes; + foreach (XmlNode hdrNode in headers) + { + colcount = colcount + 1; + string selColName = hdrNode.Name.ToLower(); + int hIndex = dc.HideColumns.IndexOf(selColName); + + if (hIndex == -1 && selColName != "nselection" && selColName != "cselection" && selColName != "dselection") + { + if (rowCnt == 1) + { + headRow = headRow + "" + hdrNode.Name + ""; + } + cRows = cRows + ""; + } + + if (selColName.ToLower() == dc.MapColumn) + { + firstColValue = hdrNode.InnerText; + } + if (dc.Action != "") + { + if (selColName.Substring(1, selColName.Length - 1) == "selection") + { + if (chkboxVal == "") + chkboxVal = selColName + "♣" + hdrNode.InnerText; + else + chkboxVal += "¿" + selColName + "♣" + hdrNode.InnerText; + } + } + else + { + if (selColName == dc.KeyColumn) + { + if (chkboxVal == "") + chkboxVal = selColName + "♣" + hdrNode.InnerText; + else + chkboxVal += "¿" + selColName + "♣" + hdrNode.InnerText; + } + } + } + + string keyColName = dc.KeyColumn; + if (dc.MapParentCol != string.Empty) + keyColName = dc.MapParentCol; + else + keyColName = dc.KeyColumn; + + if (firstColValue != "" && IsDupKeyColValue(keyColName, dcNo, firstColValue)) + { + fgRows = fgRows + "" + cRows + ""; + } + else + fgRows = fgRows + "" + cRows + ""; + + cRows = ""; + chkboxVal = ""; + } + + if (fgRows.ToString() != "") + { + if (src == "add") + //fgHTML = "
    " + headRow + "" + fgRows + "
    "; + fgHTML = "
    " + headRow + "" + fgRows + "
    "; + else + //fgHTML = "
    " + headRow + "" + fgRows + "
    "; + fgHTML = "
    " + headRow + "" + fgRows + "
    "; + if (src == "add") + fgHTML += "
    "; + else + { + if (dc.Action == "") + fgHTML += "
    "; + else + fgHTML += "
    "; + } + } + else + fgHTML = ""; + + return fgHTML; + } + + /// + /// Function to check if the key column value already exists in the field arrays. + /// + /// + /// + /// + /// + public bool IsDupKeyColValue(string keyColName, string dcNo, string currFldvalue) + { + bool IsDupValue = false; + + int rCnt = GetDcRowCount(dcNo); + + for (int i = 1; i <= rCnt; i++) + { + string FldValue = string.Empty; + if (DSGetRow(i.ToString(), Convert.ToInt32(dcNo))[keyColName] != null) + FldValue = DSGetRow(i.ToString(), Convert.ToInt32(dcNo))[keyColName].ToString(); + + if (FldValue == currFldvalue) + { + IsDupValue = true; + break; + } + } + + return IsDupValue; + } + + /// + /// Function to return the index of the fill grid from the fill grid struct. + /// + /// + /// + private int GetDcFillGridIndex(string dcName, string fillGridName) + { + if (fillGridName == string.Empty) + { + for (int i = 0; i < tstStrObj.fgs.Count; i++) + { + TStructDef.FGStruct fg = (TStructDef.FGStruct)tstStrObj.fgs[i]; + if (fg.fgtargetdc.ToLower() == dcName.ToLower()) + { + return i; + } + } + } + else + { + for (int i = 0; i < tstStrObj.fgs.Count; i++) + { + TStructDef.FGStruct fg = (TStructDef.FGStruct)tstStrObj.fgs[i]; + if (fg.fgName.ToLower() == fillGridName.ToLower()) + { + return i; + } + } + } + return -1; + } + + /// + /// Function to construct the fill grid pop up html for the given dc. + /// + /// + /// + /// + /// + /// + /// + public string ConstructFillGrid(string iXml, string dcNo, string fgName, TStructDef strObj, TStructData tstData, string src, string expResult) + { + string fgHTML = ""; + expResult = expResult.ToLower(); + string chkChecked = string.Empty; + + if (expResult == "t" || expResult == "true") + //TODO: to avoid default selection of all items, we have made it unchecked always + //chkChecked = "checked"; + chkChecked = ""; + else + chkChecked = ""; + + if (iXml.Contains(Constants.ERROR)) + { + string errMsg = tstData.GetErrorInResultJson(iXml); + if (errMsg != "") + fgHTML = ""; + else + fgHTML = ""; + } + else + { + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(iXml); + int m = 0; + string fgRows = ""; + bool allrowSelected = false; + string cRows = ""; + string headRow = ""; + string chkboxVal = ""; + string fgtlhw = ""; + int colcount = 0; + XmlNodeList headNodes; + List headerCaption = new List(); + List headerNode = new List(); + int hdrCnt = 0; + headNodes = xmlDoc.SelectNodes("//response/headrow"); + foreach (XmlNode resNode in headNodes) + { + if (resNode.Attributes["tlhw"] != null) + { + fgtlhw = resNode.Attributes["tlhw"].Value; + } + XmlNodeList headers = resNode.ChildNodes; + foreach (XmlNode hdrNode in headers) + { + for (int i = 0; i < strObj.fgs.Count; i++) + { + TStructDef.FGStruct fg = (TStructDef.FGStruct)strObj.fgs[i]; + if (fg.fgtargetdc == "dc" + dcNo && fg.fgName == fgName) + { + string colWidth = "50"; + if (hdrNode.Attributes["width"] != null) + { + colWidth = hdrNode.Attributes["width"].Value; + } + // string colWidth = strObj.GetColumnWidth(dcNo, fg.fgDcFldName[j].ToString()); + //string colWidth = strObj.GetColumnWidth(dcNo, hdrNode.Name); + if (!string.IsNullOrEmpty(hdrNode.InnerText) && (hdrNode.InnerText.ToLower() == "hide" || hdrNode.InnerText.ToLower().StartsWith("hide_"))) + headRow = headRow + "" + hdrNode.InnerText + ""; + else + headRow = headRow + "" + hdrNode.InnerText + ""; + headerCaption.Add(hdrNode.InnerText); + headerNode.Add(hdrNode.Name); + hdrCnt++; + break; + } + } + } + } + + DataTable fgData = dsDataSet.Tables["dc" + dcNo]; + XmlNodeList dataNodes; + dataNodes = xmlDoc.SelectNodes("//response/row"); + string fgCondition = string.Empty; //APPEND + foreach (XmlNode dataNode in dataNodes) + { + XmlNodeList baseDataNodes = dataNode.ChildNodes; + ArrayList ExitFld = new ArrayList(); + ArrayList ExitFldVal = new ArrayList(); + foreach (XmlNode baseDataNode in baseDataNodes) + { + + colcount = colcount + 1; + + for (int i = 0; i < strObj.fgs.Count; i++) + { + TStructDef.FGStruct fg = (TStructDef.FGStruct)strObj.fgs[i]; + if (fg.fgtargetdc == "dc" + dcNo && fg.fgName == fgName) + { + fgCondition = fg.FGCondition; + string strVal = CheckSpecialChars(baseDataNode.InnerText); + for (int j = 0; j < fg.fgSqlFldName.Count; j++) + { + if (fg.fgSqlFldName[j].ToString().ToLower() == baseDataNode.Name.ToLower()) + { + ExitFld.Add(fg.fgDcFldName[j]); + ExitFldVal.Add(strVal); + break; + } + } + if (headerNode.IndexOf(baseDataNode.Name) != -1 && !string.IsNullOrEmpty(headerCaption[headerNode.IndexOf(baseDataNode.Name)]) && (headerCaption[headerNode.IndexOf(baseDataNode.Name)].ToLower() == "hide" || headerCaption[headerNode.IndexOf(baseDataNode.Name)].ToLower().StartsWith("hide_"))) + cRows = cRows + ""; + else + cRows = cRows + ""; + + if (fg.fgSqlFldName.IndexOf(baseDataNode.Name.ToLower()) != -1) + { + if (chkboxVal == "") + chkboxVal = baseDataNode.Name + "♣" + strVal; + else + chkboxVal += "¿" + baseDataNode.Name + "♣" + strVal; + } + } + } + } + + if (fgData.Rows.Count > 0 && fgCondition == "APPEND") + { + bool rowExit = false; + var fgData1 = fgData; + for (int i = 0; i < ExitFld.Count; i++) + { + try + { + fgData1 = fgData1.AsEnumerable().Where(r => r.Field(ExitFld[i].ToString()) == ExitFldVal[i].ToString()).CopyToDataTable(); + rowExit = true; + } + catch (Exception ex) + { + rowExit = false; + break; + } + } + if (!rowExit) + fgRows = fgRows + "" + cRows + ""; + else + allrowSelected = true; + } + else + fgRows = fgRows + "" + cRows + ""; + cRows = ""; + chkboxVal = ""; + + } + if (fgRows.ToString() != "") + { + //fgHTML = "
    " + headRow + "" + fgRows + "
    "; + fgHTML = "
    " + headRow + "" + fgRows + "
    "; + fgHTML += "
    "; + fgHTML += "*♠*" + fgtlhw; + } + else if (allrowSelected) + fgHTML = ""; + else + fgHTML = ""; + + } + return fgHTML; + } + + /// + /// Function to get the fill grid data for the selected rows in the fill grid pop up. + /// + /// + /// + /// + /// + /// + /// + /// + /// + public string CallGetFillGridWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string frameNo, string s) + { + DateTime stTime = DateTime.Now; + string result = null; + string dcNo = frameNo; + //GetGlobalVars(); + frameNo = Convert.ToString(Convert.ToInt32(frameNo) + 1); + transid = tstData.transid.ToString(); + ires = tstStrObj.structRes; + //tstData.GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, frameNo, "FillGrid", "NG", dcNo); + tstData.GetPerfFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, frameNo, "FillGrid", "NG", dcNo); + s += "" + WsPerfAddRowLoadDc(dcNo, "FillGrid") + memVarsData + "" + HttpContext.Current.Session["axApps"].ToString(); + s += HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString() + ""; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + DateTime asStart = DateTime.Now; + + string isRapidCall = "false"; + if ((HttpContext.Current.Session["RapidTsTruct"] != null && HttpContext.Current.Session["RapidTsTruct"].ToString() == "true") && (HttpContext.Current.Session["AxIsPerfCode"] != null && HttpContext.Current.Session["AxIsPerfCode"].ToString().ToLower() == "true")) + isRapidCall = "true"; + if (isRapidCall == "true") + { + s = AddToken(s); + result = objWebServiceExt.CallRapidDoFillGridValuesWS(transid, s); + } + else + { + result = objWebServiceExt.CallDoFillGridValuesWS(transid, s, ires); + } + + DateTime asEnd = DateTime.Now; + + if (logTimeTaken) + { + webTime1 = asStart.Subtract(stTime).TotalMilliseconds; + webTime2 = DateTime.Now.Subtract(asEnd).TotalMilliseconds; + asbTime = asEnd.Subtract(asStart).TotalMilliseconds; + } + return result; + } + + public string CallCreatePDFWS(string s) + { + string news = GetTraceString(s); + if (news != "") s = news; + s = s + HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString() + ""; + string result = null; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallCreatePDFWS(transid, s); + return result; + } + + public string CallCreateFastPDFWS(string s) + { + string news = GetTraceString(s); + if (news != "") s = news; + s += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString() + ""; + string result = null; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallCreateFastPDFWS(transid, s, tstStrObj.structRes); + return result; + } + + public string CallViewAttachWS(string s, string structXml) + { + string result = string.Empty; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + try + { + if (attachDir) + result = GetViewAttachment(s); + if (result == string.Empty) + result = objWebServiceExt.CallViewAttachmentsWS(transid, s, structXml); + + if (result != string.Empty) + { + JObject res = null; + JArray command = null; + try + { + res = JObject.Parse(result); + command = (JArray)res["command"]; + JObject item = (JObject)command[0]; + item.Add(new JProperty("isatt", "T")); + result = res.ToString(); + } + catch (Exception ex) + { + result = ex.Message; + } + } + } + catch (Exception ex) + { + result = ex.Message; + } + return result; + } + + //copy files from local to script + public string GetViewAttachment(string inputXML) + { + string result = string.Empty; + //CommonDir directory creation taken back due to application server memory usage. + //if (!attachDirPath.Contains(":\\") && !attachDirPath.StartsWith("\\")) + //{ + // CreateDirectoryInCommonDir(ref attachDirPath); + //} + + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(inputXML); + XmlNode rootNode = default(XmlNode); + rootNode = xmlDoc.SelectSingleNode("root"); + string fname = string.Empty; + if (rootNode.Attributes["filename"] != null) + fname = rootNode.Attributes["filename"].Value; + else + return result; + string srcPath = attachDirPath + "\\" + transid + "\\"; + DirectoryInfo tarDir = new DirectoryInfo(scriptsPath + "Axpert\\" + sessionid); + DirectoryInfo sPath = new DirectoryInfo(srcPath); + try + { + if (!tarDir.Exists) + tarDir.Create(); + if (sPath.Exists) + { + string[] sFileName = Directory.GetFiles(srcPath, recordid + "-" + fname); + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + foreach (var file in sFileName) + { + string fileName = Path.GetFileName(file); + File.Copy(file, Path.Combine(tarDir.ToString(), fileName.Substring(fileName.IndexOf("-") + 1)), true); + } + } + result = "{\"command\":[{\"cmd\":\"openfile\",\"cmdval\":\"" + fname + "\"}]}"; + } + } + catch (Exception ex) + { + result = ex.Message; + } + return result; + } + //Remove the file from dir + public string RemoveAttachFromDir(string inputXML) + { + string myPath = attachDirPath + "\\" + transid + "\\"; + string result = string.Empty; + DirectoryInfo dir = new DirectoryInfo(myPath); + if (inputXML != string.Empty) + { + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(inputXML); + XmlNode rootNode = default(XmlNode); + rootNode = xmlDoc.SelectSingleNode("root"); + string fname = string.Empty; + if (rootNode.Attributes["filename"] != null) + fname = rootNode.Attributes["filename"].Value; + else + return result; + if (dir.Exists && !string.IsNullOrEmpty(fname)) + { + removeFiles.Add(recordid + "-" + fname); + result = "{\"message\":[{\"msg\":\"done\"}]}"; + } + return result; + } + else + { + try + { + if (dir.Exists) + dir.Delete(true); + return result; + } + catch { return result; } + } + } + + public string RemoveAttachFromServer(string inputXML, string stransId) + { + string result = string.Empty; + XmlDocument xml = new XmlDocument(); + xml.LoadXml(inputXML); + XmlElement root = xml.DocumentElement; + string recordid = string.Empty; + if (root.HasAttribute("recordid")) + recordid = root.GetAttribute("recordid"); + if (imgAttachPath != "" && recordid != "0") + { + for (int i = 0; i < tstStrObj.flds.Count; i++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[i]; + if (fld.fieldIsImage) + { + if (!IsDcGrid(fld.fldframeno.ToString(), tstStrObj) && !fld.name.StartsWith("axp_nga_")) + { + string strDest = imgAttachPath + "\\" + transid + "\\" + fld.name; + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + DirectoryInfo di = new DirectoryInfo(strDest); + if (di.Exists) + { + FileInfo[] files = di.GetFiles(); + if (files.Length > 0) + { + var ImgExist = files.Where(x => x.Name.Split('.')[0] == recordid).ToList(); + if (ImgExist.Count > 0) + { + foreach (var lstImg in ImgExist) + { + FileInfo file = (FileInfo)lstImg; + file.Delete(); + } + } + } + } + } + } + else if (fld.name.StartsWith("axp_nga_")) + { + string strDest = imgAttachPath + "\\" + transid + "\\" + fld.name; + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + DirectoryInfo di = new DirectoryInfo(strDest); + if (di.Exists) + { + FileInfo[] files = di.GetFiles(); + if (files.Length > 0) + { + var ImgExist = files.Where(x => x.Name.StartsWith(recordid + "-")).ToList(); + if (ImgExist.Count > 0) + { + foreach (var lstImg in ImgExist) + { + FileInfo file = (FileInfo)lstImg; + file.Delete(); + } + } + } + } + } + } + } + if ((fld.name.StartsWith("dc") && fld.name.ToLower().EndsWith("_image") || fld.name.StartsWith("axp_gridattach_")) && IsDcGrid(fld.fldframeno.ToString(), tstStrObj)) + { + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[fld.fldframeno - 1]; + string fldName = fld.name; + string grdAttPath = HttpContext.Current.Session["grdAttPath"].ToString(); + + if (dc.DCHasDataRows && grdAttPath != string.Empty) + { + if (!grdAttPath.EndsWith("\\")) + grdAttPath = grdAttPath + "\\"; + + string destFilePath = destFilePath = grdAttPath + "\\" + stransId + "\\" + fld.name; + string authenticationStatus = string.Empty; + if (util.GetAuthentication(ref authenticationStatus)) + { + DirectoryInfo di = new DirectoryInfo(destFilePath); + if (di.Exists) + { + FileInfo[] files = di.GetFiles(); + if (files.Length > 0) + { + var ImgExist = files.Where(x => x.Name.StartsWith(recordid + "-")).ToList(); + if (ImgExist.Count > 0) + { + foreach (var lstImg in ImgExist) + { + FileInfo file = (FileInfo)lstImg; + file.Delete(); + } + } + } + } + } + } + } + } + } + if (attachDirPath != "" && recordid != "0") + { + string strDest = imgAttachPath + "\\" + stransId; + DirectoryInfo di = new DirectoryInfo(strDest); + if (di.Exists) + { + FileInfo[] files = di.GetFiles(); + if (files.Length > 0) + { + var ImgExist = files.Where(x => x.Name.StartsWith(recordid + "-")).ToList(); + if (ImgExist.Count > 0) + { + foreach (var lstImg in ImgExist) + { + FileInfo file = (FileInfo)lstImg; + file.Delete(); + } + } + } + } + } + return result; + } + + public string CallRemoveAttachWS(string s, string structXml) + { + string news = GetTraceString(s); + if (news != "") s = news; + s = s + HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString() + ""; + string result = null; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + s = util.CheckReverseUrlSpecialChars(s); + if (attachDir) + result = RemoveAttachFromDir(s); + if (string.IsNullOrEmpty(result)) + result = objWebServiceExt.CallRemoveAttachmentsWS(transid, s, structXml); + return result; + } + + //This function creates new directories inside the 'CommonDir' folder in web server. + public void CreateDirectoryInCommonDir(ref String dirPath) + { + dirPath = AppDomain.CurrentDomain.BaseDirectory + "CommonDir\\" + dirPath; + if (!Directory.Exists(dirPath)) + { + Directory.CreateDirectory(dirPath); + } + } + + private string GetTraceString(string currentXml) + { + string traceVal = string.Empty; + traceVal = currentXml; + if (currentXml.Contains("_#") == true) + { + currentXml = currentXml.Replace("_#", "~"); + } + + string filename = string.Empty; + int sindex = currentXml.IndexOf(Constants.TRACESPLITSTR2); + int eindex = currentXml.LastIndexOf(Constants.TRACESPLITSTR1); + + if (sindex != -1 && eindex != -1) + { + filename = currentXml.Substring(sindex + 2, eindex - sindex - 2); + sessionid = HttpContext.Current.Session["nsessionid"].ToString(); + errlog = logobj.CreateLog("Executing Action", sessionid, filename, "new"); + traceVal = currentXml.Replace(Constants.TRACESPLITSTR2 + filename + Constants.TRACESPLITSTR1, errlog); + } + + if (traceVal.Contains("~") == true) + { + traceVal = traceVal.Replace("~", "_#"); + } + if (scriptsPath != string.Empty) + { + traceVal = traceVal.Replace(""; + loadXml += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + loadXml += ""; + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallDoFormLoadWS(tstData.transid, loadXml, tstStrObj.structRes); + //requestProcess_logtime += loadRes.Split('♠')[0]; + result = result.Split('♠')[1]; + return result; + } + + public string CallGetLoadData(TStructData tstData, string recordid, string errorLog) + { + string result = null; + string visibleDCs = string.Empty; + visibleDCs = tstStrObj.GetVisibleDCs(); + string proj = HttpContext.Current.Session["project"].ToString(); + string imagefromdb = "false"; + if (HttpContext.Current.Session["AxpSaveImageDb"] != null) + imagefromdb = HttpContext.Current.Session["AxpSaveImageDb"].ToString(); + string loadXml = " "; + loadXml += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + loadXml += ""; + loadXml = util.ReplaceImagePath(loadXml); + string tsId = tstData.transid; + string sXml = tstStrObj.structRes; + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallLoadDataWS(tsId, loadXml, sXml, recordid, proj); + HttpContext.Current.Session["axp_lockonrecid"] = tsId + "~" + recordid; + return result; + } + #endregion + + #region Private Methods + + /// + /// Function to update the decimal value for the given field in the structure xml + /// + /// + /// + private void UpdateAxpCurrDec(string[] fieldNames, int dec) + { + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(tstStrObj.structRes); + XmlNodeList fieldNode; + //looping from i=1 as the first item is decimal + for (int i = 1; i < fieldNames.Length; i++) + { + fieldNode = xmlDoc.GetElementsByTagName(fieldNames[i].ToString().Trim()); + if (fieldNode.Count > 0) + { + foreach (XmlNode childNode in fieldNode[0].ChildNodes) + { + if (childNode.Name == "a5") + { + childNode.InnerText = dec.ToString(); + tstStrObj.structRes = xmlDoc.OuterXml; + break; + } + } + } + } + } + + /// + /// Function to check if the field is axpcurrencydec and call update struct xml + /// + /// + /// + private void CheckAxpCurrDec(string fldName, string fldVal) + { + string[] axpCurrDetails = new string[] { }; + axpCurrDetails = fldVal.Split(','); + if (axpCurrDetails.Length > 0 && fldVal != "") + { + int decNo = Convert.ToInt32(axpCurrDetails[0]); + UpdateAxpCurrDec(axpCurrDetails, decNo); + } + } + + + /// + /// Function which loads the given image from the image folder to scripts. + /// On change of the product, if the image should be replaced, this function is called. + /// + /// + /// + /// It returns the imagename along with the source value for the image, which is set in the client function + public string GetImageSource(string imageName, string imageSrc) + { + if (imageSrc != "") + { + string[] fvalues = imageSrc.ToString().Split('~'); + string recordId = fvalues[2].ToString(); + imageFldNames.Clear(); + imageFldSrc.Clear(); + LoadImageToFolder(imageName, recordId); + + + string imgSrc = ""; + for (int i = 0; i < imageFldNames.Count; i++) + { + if (imageFldNames[i].ToString() == imageName) + { + imgSrc = imageFldSrc[i].ToString(); + break; + } + } + + return imageName + "♣" + imgSrc; + } + return imageFldSrc + "♣" + ""; + } + + private void CreateFieldValueXmlLoadTab(string frameNo) + { + string fValue = string.Empty; + StringBuilder fldXml = new StringBuilder(); + string curFldFrmNo = "0"; + for (int i = 0; i < fieldName.Count; i++) + { + int fIndex = 0; + fIndex = fieldControlName[i].ToString().LastIndexOf("F"); + fIndex = fIndex + 1; + curFldFrmNo = fieldControlName[i].ToString().Substring(fIndex, fieldControlName[i].ToString().Length - fIndex); + + if (Convert.ToInt32(curFldFrmNo) <= Convert.ToInt32(frameNo)) + { + fldXml.Append("<" + fieldName[i] + ">"); + fValue = CheckSpecialChars(fieldValue[i].ToString()); + fldXml.Append(fValue); + fldXml.Append(""); + } + } + + fgFieldValueXml = fldXml.ToString(); + } + private void CreateFieldValueXmlPerf(string frameNum, string ActiveRowNo, ArrayList AxDepFields, string fldDepGridDcs, Dictionary includeDcRows, string includeDcs) + { + DSFieldValueXMLPerf(frameNum, ActiveRowNo, AxDepFields, fldDepGridDcs, includeDcRows, includeDcs); + } + + private void CreateFieldValueXml(string condition, string includeDcs, string calledFrom) + { + DSFieldValueXML(condition, includeDcs, calledFrom); + } + + private void FieldToXML(string fldName, string rowNo, string value, string oldValue, string idvalue, string oldIdValue, string dcNo, Boolean fldSaveNormal, bool isSubGrid, string subRowNo, TStructDef.FieldStruct fld = new TStructDef.FieldStruct()) + { + rowNo = GetRowNoHelper(rowNo.ToString()); + value = CheckSpecialChars(value); + oldValue = CheckSpecialChars(oldValue); + string oldVal = ""; + if (recordid != "0") + { + if (value != oldValue) + oldVal = "ov='" + oldValue + "'"; + else + oldVal = ""; + } + if (fldName.StartsWith(Constants.IMGPrefix)) + return; + if (fldName.ToLower() == (Constants.AXPIMAGEPATH)) + isAxpImagePath = true; + //if (fld.datatype != null && fld.datatype.ToLower() == "image" && imgAttachPath != "") + // return; + if (fldSaveNormal) + { + if (Convert.ToString(idvalue) == "") idvalue = "0"; + if (Convert.ToString(oldIdValue) == "") oldIdValue = "0"; + if (isSubGrid) + dsDataXML.Append("<" + fldName + " rowno='" + subRowNo + "' id='" + idvalue + "' oldid='" + oldIdValue + "' " + oldVal + ">" + value + ""); + else + dsDataXML.Append("<" + fldName + " rowno='" + rowNo + "' id='" + idvalue + "' oldid='" + oldIdValue + "' " + oldVal + ">" + value + ""); + } + else + { + if (isSubGrid) + dsDataXML.Append("<" + fldName + " rowno='" + subRowNo + "' " + oldVal + ">" + value + ""); + else if (fld.fldMultiSelect != null) + { + dsDataXML.Append("<" + fldName + " rowno='" + rowNo + "' " + oldVal + " multiselect='true' separator='" + fld.fldMultiSelectSep + "'>" + value + ""); + } + else + dsDataXML.Append("<" + fldName + " rowno='" + rowNo + "' " + oldVal + ">" + value + ""); + } + } + + private void DSFieldValueXML(string frameNum, string parDcNo, int ParRowNo, string popDcNo, int popRowNo) + { + int fNo = -1; + bool isNumber = false; + try + { + fNo = int.Parse(frameNum); + isNumber = true; + frameNum = "F" + frameNum; + } + catch + { + } + + dsDataXML.Length = 0; + + //loop for constructing the field value xml based on the frame no, row no and field order + foreach (TStructDef.DcStruct dc in tstStrObj.dcs) + { + string dcNo = Convert.ToString(dc.frameno); + + //This condition will construct xml till the given dc if the given number is a frame no, + //else it will continue and create the xml for all dc's. + if ((frameNum != "F-1") && (isNumber)) + { + if (dc.frameno > fNo) + break; + } + + if (dc.isgrid && dc.DCHasDataRows == false) + continue; + + DataTable thisDataTable = dsDataSet.Tables["dc" + dcNo]; + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + string subGridRow = string.Empty; + bool isSubGrid = false; + + foreach (DataRow dr in thisDataTable.Rows) + { + int rowNo = Convert.ToInt32(dr["axp__rowno"]); + if (dc.frameno.ToString() == parDcNo && rowNo != ParRowNo) + continue; + + //Sub-Grid - only the newly added row should be sent in the input xml. + if (dc.frameno.ToString() == popDcNo && rowNo != popRowNo) + { + continue; + } + else if (dc.frameno.ToString() == popDcNo) + { + subGridRow = "001"; + isSubGrid = true; + } + + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, isSubGrid, subGridRow); + } + } + + fieldValueXml = dsDataXML.ToString(); + } + + private void DSFieldValueXMLHelperPerf(string dcNo, int rowNo, int startIdx, int endIdx, DataRow dr, ArrayList depFields) + { + DataTable dtOld = dsDataSet.Tables["dc_old" + dcNo]; + DataRow drOld = dtOld.Rows.Find(rowNo); + + for (int j = startIdx; j <= endIdx; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[j]; + if (depFields.IndexOf(fld.name) == -1) + continue; + + string value = string.Empty; + string oldValue = string.Empty; + string idValue = string.Empty; + string oldIdValue = string.Empty; + + string FldValue = string.Empty; + + value = dr[fld.name].ToString(); + if (fld.savenormal) + idValue = dr["id__" + fld.name].ToString(); + + if (drOld != null) + { + oldValue = drOld["old__" + fld.name].ToString(); + if (fld.savenormal) + oldIdValue = drOld["oldid__" + fld.name].ToString(); + } + + FieldToXML(fld.name, Convert.ToString(rowNo), value, oldValue, idValue, oldIdValue, dcNo, fld.savenormal, false, ""); + } + } + + private void DSFieldValueXMLHelper(string dcNo, int rowNo, int startIdx, int endIdx, DataRow dr, bool isSubGrid, string subGridRowNo) + { + DataTable dtOld = dsDataSet.Tables["dc_old" + dcNo]; + DataRow drOld = dtOld.Rows.Find(rowNo); + + for (int j = startIdx; j <= endIdx; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[j]; + string value = string.Empty; + string oldValue = string.Empty; + string idValue = string.Empty; + string oldIdValue = string.Empty; + + string FldValue = string.Empty; + + value = dr[fld.name].ToString(); + if (fld.savenormal) + idValue = dr["id__" + fld.name].ToString(); + + if (drOld != null) + { + oldValue = drOld["old__" + fld.name].ToString(); + if (fld.savenormal) + oldIdValue = drOld["oldid__" + fld.name].ToString(); + } + ////// is save true and rtf check.. + if (isSaveCalled) + { + if ((fld.name.Contains("rtf_") || fld.name.Contains("rtfm_") || fld.name.Contains("fr_rtf_")) && fld.name.Contains("_printable")) + value = ReplaceRTFTagsForPrint(dr[fld.name.Replace("_printable", "")].ToString()); + } + + FieldToXML(fld.name, Convert.ToString(rowNo), value, oldValue, idValue, oldIdValue, dcNo, fld.savenormal, isSubGrid, subGridRowNo, fld); + } + } + + private void RapidFieldValueXML(string dcNo, int rowNo, int startIdx, int endIdx, DataRow dr, bool isSubGrid, string subGridRowNo, TStructDef.FieldStruct Parfld, string actRow, string calledFrom) + { + DataTable dtOld = dsDataSet.Tables["dc_old" + dcNo]; + DataRow drOld = dtOld.Rows.Find(rowNo); + string[] arrParams; + if (calledFrom == "Rapid") + arrParams = Parfld.FldRapidParents.Split(','); + else + arrParams = Parfld.FldRapidAllParents.Split(','); + List lstParams = new List(); + lstParams.AddRange(arrParams); + + string[] arrParAllRows = Parfld.FldRapidAllRows.Split(','); + List lstParAllRows = new List(); + lstParAllRows.AddRange(arrParAllRows); + + for (int j = startIdx; j <= endIdx; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[j]; + int dIdx = -1; + dIdx = lstParams.IndexOf(fld.name); + //If the field is not there in the params array, continue the loop + if (dIdx == -1 && !fld.name.StartsWith("axp_recid")) continue; + + //If the allrows for the current parent is false, then only if the current dc and parent dc are same row should be constructed for active row else continue + //arrParAllRows.Length > dIdx - this condition needs to be handled + if (IsDcGrid(fld.fldframeno.ToString(), tstStrObj) && dIdx != -1 && arrParAllRows.Length > dIdx) + { + if (!(fld.fldframeno == Parfld.fldframeno && arrParAllRows[dIdx] == "F" && rowNo.ToString() == actRow)) continue; + } + string value = string.Empty; + string oldValue = string.Empty; + string idValue = string.Empty; + string oldIdValue = string.Empty; + + string FldValue = string.Empty; + + value = dr[fld.name].ToString(); + if (fld.savenormal) + idValue = dr["id__" + fld.name].ToString(); + + if (drOld != null) + { + oldValue = drOld["old__" + fld.name].ToString(); + if (fld.savenormal) + oldIdValue = drOld["oldid__" + fld.name].ToString(); + } + ////// is save true and rtf check.. + if (isSaveCalled) + { + if ((fld.name.Contains("rtf_") || fld.name.Contains("rtfm_") || fld.name.Contains("fr_rtf_")) && fld.name.Contains("_printable")) + value = ReplaceRTFTagsForPrint(dr[fld.name.Replace("_printable", "")].ToString()); + } + + FieldToXML(fld.name, Convert.ToString(rowNo), value, oldValue, idValue, oldIdValue, dcNo, fld.savenormal, isSubGrid, subGridRowNo); + } + } + + + private string ReplaceRTFTagsForPrint(string inpStr) + { + // string[] rtfTags = new string[] { "", "", "
    ", "", "", "", "", "", "", "", "", "", "", "", "

    ", "", "
    " }; + + string[] rtfTags = new string[] { "", "", "
    ", "", "", "", "", "", "", "", "", "", "", "

    ", "", "
    " }; + + for (int i = 0; i < rtfTags.Length; i++) + while (inpStr.Contains(rtfTags[i])) + { + int startIdx = -1; + int endIdx = -1; + + startIdx = inpStr.IndexOf(rtfTags[i]); + endIdx = inpStr.IndexOf(">", startIdx); + + string replaceStr = string.Empty; + + string strNode = inpStr.Substring(startIdx, (endIdx - startIdx) + 1); + //Code to replace
    with new line in fast report + if (strNode == "
    " || strNode == "
  • ") + { + //replaceStr = "#13#10"; + inpStr = inpStr.Insert(endIdx + 1, "~"); + } + + inpStr = inpStr.Remove(startIdx, (endIdx + 1) - startIdx); + inpStr = inpStr.Replace(rtfEndTags[i], replaceStr); + } + + string[] rtfSupportedTags = new string[] { "", startIdx); + inpStr = inpStr.Remove(startIdx, (endIdx + 1) - startIdx); + inpStr = inpStr.Insert(startIdx, rtfSupportedTags[i] + ">"); + endIdx = endIdx - (endIdx - startIdx); + } + } + + inpStr = inpStr.Replace(" ", ""); + inpStr = inpStr.Replace("\n", "~"); + + return inpStr; + } + + private void DSFieldValueXML(string frameNum, string calledFrom) + { + int fNo = -1; + bool isNumber = true; + try + { + fNo = int.Parse(frameNum); + isNumber = true; + } + catch + { + isNumber = false; + } + + if (isNumber) + frameNum = "F" + frameNum; + + dsDataXML.Length = 0; + + //loop for constructing the field value xml based on the frame no, row no and field order + foreach (TStructDef.DcStruct dc in tstStrObj.dcs) + { + string dcNo = Convert.ToString(dc.frameno); + + //This condition will construct xml till the given dc if the given number is a frame no, + //else it will continue and create the xml for all dc's. + if ((frameNum != "F-1") && (isNumber)) + { + if (calledFrom == "FillGrid") + { + //– Only non grid data will be sent in input xml.For all grid dcs only row count will be sent. + if (dc.isgrid) + { + int rCnt = GetDcRowCount(dcNo); + dsDataXML.Append("" + rCnt + ""); + continue; + } + } + else if (calledFrom == "LoadDc") + { + //Only non grid data and this DC data will be sent as parameter + if (fNo != dc.frameno || dc.isgrid) + continue; + } + //TODO: why this is empty? + else if (calledFrom == "GetDep") + { + + } + else + { + //NOTE: for a webservice where the frame no is sent, all other grid dcs data should also be sent to the web service. + if (dc.frameno > fNo && dc.isgrid) + continue; + } + } + + int rowCnt = 0; + if (dc.isgrid) + { + rowCnt = GetDcRowCount(dcNo); + if (rowCnt == 0) rowCnt = 1; + if (calledFrom != "PickList" && dc.DCHasDataRows == false) + continue; + } + + DataTable thisDataTable = dsDataSet.Tables["dc" + dcNo]; + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + + foreach (DataRow dr in thisDataTable.Rows) + { + int rowNo = Convert.ToInt32(dr["axp__rowno"]); + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, false, ""); + } + } + if (frameNum == "F-1") + fieldValueXml = dsDataXML.ToString(); + else + fgFieldValueXml = dsDataXML.ToString(); + + } + + public void DSRapidFieldValueXML(string frameNo, string actRowNo, string fieldName, string calledFrom, TStructDef.FieldStruct fld) + { + dsDataXML = new StringBuilder(); + //loop for constructing the field value xml based on the frame no, row no and field order + foreach (TStructDef.DcStruct dc in tstStrObj.dcs) + { + string dcNo = Convert.ToString(dc.frameno); + + //This condition will construct xml for all the non grids in the given tstruct, + //if the includeDcs contains any grid dc then that dc also will be included in the xml construction. + //TODO:RAPID - Check allrows along with params + int rowCnt = 0; + if (dc.isgrid) + { + rowCnt = GetDcRowCount(dcNo); + if (rowCnt == 0) rowCnt = 1; + //if (calledFrom != "PickList" && dc.DCHasDataRows == false && calledFrom != "RefreshDc") + // continue; + } + + DataTable thisDataTable = dsDataSet.Tables["dc" + dcNo]; + try + { + if (calledFrom != "AutoComplete" && calledFrom != "axpbutton") + { + DataRow[] rows; + rows = thisDataTable.Select("axp__isGrdVld" + dcNo + " = 'false'"); // axp__isGrdVld is Column Name + foreach (DataRow r in rows) + thisDataTable.Rows.Remove(r); + } + } + catch (Exception ex) + { + //catch block is not handlink because - we are skipping the rows which does not contains axp__isGrdVld+dcno column + } + + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + + foreach (DataRow dr in thisDataTable.Rows) + { + int rowNo = Convert.ToInt32(dr["axp__rowno"]); + if (calledFrom != "AutoComplete" && calledFrom != "axpbutton" && thisDataTable.Columns.Contains(Constants.AXPISROWVALID + dcNo) && dr[Constants.AXPISROWVALID + dcNo].ToString() == "false") + continue; + + RapidFieldValueXML(dcNo, rowNo, startIdx, endIdx, dr, false, "", fld, actRowNo, calledFrom); + + } + } + + fieldValueXml = dsDataXML.ToString(); + } + + /// + /// + /// + /// NG + /// + /// + public void DSFieldValueXML(string condition, string includeDcs, string calledFrom) + { + dsDataXML.Length = 0; + + ArrayList incGridDcs = new ArrayList(); + if (!string.IsNullOrEmpty(includeDcs)) + { + string[] incDcs = includeDcs.Split(','); + for (int idx = 0; idx < incDcs.Length; idx++) + { + if (!string.IsNullOrEmpty(incDcs[idx].ToString())) + { + incGridDcs.Add(incDcs[idx].ToString()); + if (IsParentDc(incDcs[idx].ToString())) + { + ArrayList arrPopDcs = new ArrayList(); + arrPopDcs = GetPopDcsForParent(incDcs[idx].ToString()); + for (int pIdx = 0; pIdx < arrPopDcs.Count; pIdx++) + { + if (incGridDcs.IndexOf(arrPopDcs[pIdx].ToString()) == -1) + incGridDcs.Add(arrPopDcs[pIdx].ToString()); + } + } + } + } + } + string sourceDc = string.Empty; + ArrayList tabParentFlds = new ArrayList(); + if (calledFrom == "LoadTab" || calledFrom == "FillGrid" || calledFrom == "AutoComplete") + { + if (includeDcs != string.Empty) + { + TStructDef.DcStruct tabDc = (TStructDef.DcStruct)tstStrObj.dcs[Convert.ToInt32(includeDcs) - 1]; + tabParentFlds = tabDc.tabParentFields; + } + //incGridDcs.Clear(); + if (calledFrom == "FillGrid") + { + int idx = tstStrObj.GetFillGridIndex("dc" + includeDcs.ToString()); + includeDcs = ""; + if (idx != -1) + { + TStructDef.FGStruct fg = (TStructDef.FGStruct)tstStrObj.fgs[idx]; + if (fg.fgSourceDC != "") + sourceDc = fg.fgSourceDC.Substring(2); + } + } + } + + //loop for constructing the field value xml based on the frame no, row no and field order + foreach (TStructDef.DcStruct dc in tstStrObj.dcs) + { + string dcNo = Convert.ToString(dc.frameno); + + //This condition will construct xml for all the non grids in the given tstruct, + //if the includeDcs contains any grid dc then that dc also will be included in the xml construction. + if (condition == "NG") + { + //– Only non grid data will be sent in input xml.For all grid dcs only row count will be sent. + if (dc.isgrid) + { + //For getdep web service, the other grid dcs rowcount also should be sent. + //if ((calledFrom == "GetDep" || calledFrom == "GetDependents") && incGridDcs.IndexOf(dcNo) == -1) + if (calledFrom == "GetDep" && incGridDcs.IndexOf(dcNo) == -1) + { + int rCnt = GetDcRowCount(dcNo); + dsDataXML.Append("" + rCnt + ""); + } + + //Refer bug - IWA-C-0000024 + //Removed LoadData as current dc data should not be sent to webservice- This will result in tabdata bringing empty row. + if (calledFrom != "FillGrid" && calledFrom != "AutoComplete" && calledFrom != "axpbutton" && incGridDcs.IndexOf(dcNo) == -1) + continue; + } + } + + int rowCnt = 0; + if (dc.isgrid) + { + rowCnt = GetDcRowCount(dcNo); + if (rowCnt == 0) rowCnt = 1; + if (calledFrom != "PickList" && dc.DCHasDataRows == false && calledFrom != "RefreshDc") + continue; + } + + DataTable thisDataTable = dsDataSet.Tables["dc" + dcNo]; + try + { + if (calledFrom != "AutoComplete" && calledFrom != "axpbutton") + { + DataRow[] rows; + rows = thisDataTable.Select("axp__isGrdVld" + dcNo + " = 'false'"); // axp__isGrdVld is Column Name + foreach (DataRow r in rows) + thisDataTable.Rows.Remove(r); + } + } + catch (Exception ex) + { + //catch block is not handlink because - we are skipping the rows which does not contains axp__isGrdVld+dcno column + } + bool isAddRow = false; + + if (calledFrom == "RefreshDc" && thisDataTable.Rows.Count == 0) + { + DataRow newRow = thisDataTable.NewRow(); + newRow["axp__rowno"] = 1; + newRow["axp__delrow"] = 0; + thisDataTable.Rows.Add(newRow); + thisDataTable.AcceptChanges(); + isAddRow = true; + } + + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + + foreach (DataRow dr in thisDataTable.Rows) + { + + int rowNo = Convert.ToInt32(dr["axp__rowno"]); + + if (calledFrom != "AutoComplete" && calledFrom != "axpbutton" && thisDataTable.Columns.Contains(Constants.AXPISROWVALID + dcNo) && dr[Constants.AXPISROWVALID + dcNo].ToString() == "false") + continue; + + if (calledFrom == "LoadTab" && dcNo == includeDcs) + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, false, ""); + else if (calledFrom == "FillGrid" && dc.isgrid && dcNo == sourceDc) + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, false, ""); + else if (calledFrom == "LoadTab" && dc.isgrid && incGridDcs.IndexOf(dcNo) != -1) + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, false, ""); + else if ((calledFrom == "LoadTab" || calledFrom == "FillGrid" || calledFrom == "AutoComplete") && dc.isgrid && dcNo != includeDcs) + DSFieldValueXMLHelperPerf(dcNo, rowNo, startIdx, endIdx, dr, tabParentFlds); + else + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, false, ""); + + } + + if (isAddRow && calledFrom == "RefreshDc") + { + thisDataTable.Rows.RemoveAt(0); + isAddRow = false; + } + } + + fieldValueXml = dsDataXML.ToString(); + + } + private void DSFieldValueXMLPerf(string frameNum, string ActiveRowNo, ArrayList depFields, string fldDepGridDcs, Dictionary includeDcRows, string includeDcs) + { + int fNo = -1; + bool isNumber = true; + bool IsDcInclude = false; + string[] refreshdc = new string[10]; + if (includeDcs != string.Empty) + refreshdc = includeDcs.Split(','); + + try + { + fNo = int.Parse(frameNum); + isNumber = true; + } + catch + { + isNumber = false; + } + + if (isNumber) + frameNum = "F" + frameNum; + + dsDataXML.Length = 0; + + //loop for constructing the field value xml based on the frame no, row no and field order + foreach (TStructDef.DcStruct dc in tstStrObj.dcs) + { + string dcNo = Convert.ToString(dc.frameno); + + string incRowsStr = string.Empty; + ArrayList includeRows = new ArrayList(); + if (includeDcRows.ContainsKey(dcNo)) + { + IsDcInclude = true; + includeDcRows.TryGetValue(dcNo, out incRowsStr); + string[] incRows = incRowsStr.Split(','); + for (int j = 0; j < incRows.Length; j++) + { + if (incRows[j] != "") + includeRows.Add(Convert.ToInt32(incRows[j].ToString())); + } + } + else + { + IsDcInclude = false; + if (Array.IndexOf(refreshdc, dcNo) > -1) + IsDcInclude = true; + else if (!dc.isgrid) + IsDcInclude = true; + string[] depDcs = fldDepGridDcs.Split(','); + for (int dIdx = 0; dIdx < depDcs.Length; dIdx++) + { + if (depDcs[dIdx].ToString() == dcNo) + { + IsDcInclude = true; + break; + } + } + } + + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + + int rowCnt = 0; + if (dc.isgrid) + { + if (dc.frameno == fNo || IsDcInclude) + { + rowCnt = GetDcRowCount(dcNo); + if (rowCnt == 0) rowCnt = 1; + if (dc.DCHasDataRows == false) + continue; + } + else + continue; + } + + int ActRowNo = Convert.ToInt32(ActiveRowNo); + + DataTable thisDataTable = dsDataSet.Tables["dc" + dcNo]; + int subRowNo = 0; + //This loop will run through all the rows in the grid, if the given rowno is same as activerowno, then it will construct for all the fields + //Else it will construct xml only for the fields given in the depFields parameter. + foreach (DataRow dr in thisDataTable.Rows) + { + + + int rowNo = Convert.ToInt32(dr["axp__rowno"]); + + //If a non grid field is changed and a grid has record in add panel(Invalid row) it should not be sent to web-service + if (frameNum != "F" + dc.frameno.ToString() && dc.isgrid && dr[Constants.AXPISROWVALID + dcNo].ToString() == "false") + continue; + + if ((Array.IndexOf(refreshdc, dcNo) > -1) && (dc.frameno != fNo)) + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, false, ""); + else if (!dc.isgrid) + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, false, ""); + else if (dc.frameno == fNo && rowNo == ActRowNo) + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, false, ""); + else if (IsDcInclude && includeRows.IndexOf(rowNo) != -1) + { + if (dc.ispopgrid) + { + subRowNo++; + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, dc.ispopgrid, subRowNo.ToString()); + } + else + { + DSFieldValueXMLHelper(dcNo, rowNo, startIdx, endIdx, dr, false, ""); + } + } + else + DSFieldValueXMLHelperPerf(dcNo, rowNo, startIdx, endIdx, dr, depFields); + } + } + + fieldValueXml = dsDataXML.ToString(); + } + + private void CreateFieldValueXml(string frameNum, string parDcNo, int ParRowNo, string popDcNo, int popRowNo) + { + DSFieldValueXML(frameNum, parDcNo, ParRowNo, popDcNo, popRowNo); + return; + } + + public DataTable CreateDataTable() + { + return new DataTable(); + } + + /// + /// This method loops through the lists and construct the field value xml. + /// and updates the object variable “PopfieldValueXml”. + /// + private void CreatePopFieldValueXml(ArrayList fldArray, ArrayList fldValueArray, ArrayList fldDeletedArray, string frameNum, string pframeno, string maxRows, ArrayList popRows) + { + + string fValue = string.Empty; + frameNum = "F" + frameNum; + StringBuilder fldXml = new StringBuilder(); + StringBuilder popFldXml = new StringBuilder(); + string rnList = ""; + popFldXml.Append(""); + for (int i = 0; i < fieldName.Count; i++) + { + if (fieldControlName[i].ToString().IndexOf(frameNum.ToString()) == -1) + { + fldXml.Append("<" + fieldName[i] + ">"); + fValue = CheckSpecialChars(fieldValue[i].ToString()); + fldXml.Append(fValue); + fldXml.Append(""); + } + else + { + popFldXml.Append("<" + fieldName[i] + ">"); + fValue = CheckSpecialChars(fieldValue[i].ToString()); + popFldXml.Append(fValue); + popFldXml.Append(""); + } + } + + popFGFieldValueXml = ""; + if (popFldXml.ToString() == "") popFldXml.Append(""); + popFGFieldValueXml = "" + popFldXml.ToString() + "" + "" + fgFieldValueXml.ToString() + ""; + } + + /// + /// function for replacing the special characters in a given string. + /// + /// + /// + /// + private string CheckSpecialChars(string str) + { + //hack: The below line is used to make sure that the & in & is not converted inadvertantly + // for other chars this scenario will not come as it does not contains the same char. + str = Regex.Replace(str, "&", "&"); + str = Regex.Replace(str, """, "“"); + str = Regex.Replace(str, "\n", "
    "); + str = Regex.Replace(str, "&", "&"); + str = Regex.Replace(str, "<", "<"); + str = Regex.Replace(str, ">", ">"); + str = Regex.Replace(str, "'", "'"); + str = Regex.Replace(str, "\"", """); + str = Regex.Replace(str, "’", "'"); + str = Regex.Replace(str, "“", """); + str = Regex.Replace(str, "”", """); + str = Regex.Replace(str, "™", "™"); + str = Regex.Replace(str, "®", "®"); + + str = str.Replace((char)160, ' '); + + if (str == defaultDateStr) + str = ""; + return str; + } + + private string GetDbFieldName(string fieldCompName, string dbRowNo) + { + if (dbRowNo.Length == 1) + dbRowNo = "00" + dbRowNo; + else if (dbRowNo.Length == 2) + dbRowNo = "0" + dbRowNo; + + int fIndx = fieldCompName.LastIndexOf("F"); + if (fIndx != -1) + { + string fldDcNo = fieldCompName.Substring(fIndx + 1); + string dbFldName = fieldCompName.Substring(0, fIndx - 3); + string newCompName = dbFldName + dbRowNo + "F" + fldDcNo; + return newCompName; + } + else + { + if (fieldCompName.StartsWith("dc") && dbRowNo == "0-1") + return "dc"; + else + return fieldCompName; + } + } + + /// + /// This method for for updating the existing field values and adding any new values. + /// Note: Only grid field values can be added and deleted. + /// + /// + /// + /// + public void UpdateDataList(ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList deletedArray) + { + + for (int j = 0; j < fldArray.Count; j++) + { + if (fldArray[j] != null) + { + if (fldValueArray[j].ToString() == defaultDateStr) + fldValueArray[j] = ""; + + string fldname = string.Empty; string frmNum = string.Empty; string fldRowNo = string.Empty; + string newCompName = GetDbFieldName(fldArray[j].ToString(), fldDbRowNo[j].ToString()); + + if (newCompName == "dc") + { + string[] dcData = fldValueArray[j].ToString().Split('♦'); + string newRowCnt = dcData[0]; + string changedRows = dcData[1]; + if (changedRows != "") + { + SetDbRows(changedRows, fldArray[j].ToString().Substring(2), tstStrObj, ""); + } + + UpdateRowCount(fldArray[j].ToString(), newRowCnt); + continue; + } + + int lastIndex = newCompName.LastIndexOf('F'); + if (lastIndex != -1) + { + fldname = newCompName.Substring(0, lastIndex - 3); + fldRowNo = newCompName.Substring(lastIndex - 3, 3); + frmNum = newCompName.Substring(lastIndex + 1); + } + else + { + fldname = newCompName.Substring(0, newCompName.Length - 5); + fldRowNo = newCompName.Substring(lastIndex - 3, 3); + frmNum = newCompName.Substring(newCompName.Length - 2); + } + + //Update the dc dchasdatarowws property. + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[Convert.ToInt32(frmNum) - 1]; + if (dc.isgrid) + { + if (!dc.DCHasDataRows) + { + //Refer bugid- AXP-C-0000136 + //If the row comes from client due to expression eval for pop up grid row, do not mark it valid + var valIdx = fldArray.IndexOf("axp__isGrdVld" + frmNum + fldRowNo + "F" + frmNum); + if (valIdx != -1 && fldValueArray[valIdx].ToString() == "false") + { + //In case of grid(pop) a new row value will be sent after expression evaluation but the row is not valid. In this case the dchasDataRows should not be changed to true. + } + else + { + dc.DCHasDataRows = true; + tstStrObj.dcs[Convert.ToInt32(frmNum) - 1] = dc; + } + } + } + + //int index = fieldControlName.IndexOf(newCompName); + // int index = GetFldIndex(Convert.ToInt32(frmNum), fldname, Convert.ToInt32(fldDbRowNo[j])); + string newFldValue = fldValueArray[j].ToString(); + + //TODO: The same code is there in the TstructData constructor, and Jsontoarray + //if (fldname.ToLower() == "axpcurrencydec") + // CheckAxpCurrDec(fldname, newFldValue); + + if (newCompName.StartsWith("axp_recid") && newFldValue == "") newFldValue = "0"; + + string tmpFldVal = string.Empty; + string tmpFldIdVal = string.Empty; + + if (newCompName != string.Empty) + { + if (newFldValue.Contains("¿")) + { + string[] idVal = newFldValue.Split('¿'); + tmpFldVal = idVal[1]; + tmpFldIdVal = idVal[0]; + } + else + tmpFldVal = newFldValue.ToString(); + } + DSSubmit(fldname, Convert.ToInt32(fldDbRowNo[j].ToString()), tmpFldVal, tmpFldIdVal); + } + } + + // For deleting the fields from the list. + for (int k = 0; k < deletedArray.Count; k++) + { + int fIdx = deletedArray[k].ToString().IndexOf("F"); + string delRowNo = deletedArray[k].ToString().Substring(0, fIdx); + string delDcNo = deletedArray[k].ToString().Substring(fIdx + 1); + int tmpRowCnt = GetActualDcRowCount(delDcNo);//GetDcRowCount(delDcNo);//Refer Bug: AGI003750 + if (tmpRowCnt == 1 && (delRowNo == "001" || delRowNo == "1")) + { + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[Convert.ToInt32(delDcNo) - 1]; + dc.DCHasDataRows = false; + tstStrObj.dcs[Convert.ToInt32(delDcNo) - 1] = dc; + } + if (recordID != "0" && recordID != "") + DeleteRowInFldArrays(delDcNo, delRowNo); + else + DeleteRowInFldArrays(delDcNo, delRowNo); + + tmpRowCnt = tmpRowCnt - 1; + if (tmpRowCnt >= 0) + UpdateRowCount("DC" + delDcNo, "DC" + delDcNo + "~" + tmpRowCnt); + } + } + + private int GetActualDcRowCount(string dcNo) + { + int rowCount = 0; + DataTable dt = dsDataSet.Tables["dc" + dcNo]; + if (dt.Rows.Count > 0) + { + rowCount = dt.Select("axp__isGrdVld" + dcNo + " = ''").Count(); + } + return rowCount; + } + + private string GetFrameNo(string fieldId) + { + return fieldId.Substring(fieldId.LastIndexOf("F") + 1); + } + + private int GetDCRowCntIndex(string dcNo) + { + int index = -1; + for (int i = 0; i < dcRowCntVals.Count; i++) + { + string[] dcName = dcRowCntVals[i].ToString().Split('~'); + if (dcName[0] == dcNo) + index = i; + } + return index; + } + + private ArrayList GetSubGridDcsInTabDC(TStructDef strObj, string TabDcNo) + { + ArrayList subGridDcs = new ArrayList(); + for (int i = 0; i < strObj.popdcs.Count; i++) + { + if (TabDcNo == ((TStructDef.PopDcStruct)(strObj.popdcs[i])).pdcno.ToString()) + { + subGridDcs.Add(((TStructDef.PopDcStruct)(strObj.popdcs[i])).frameno); + } + } + return subGridDcs; + } + + /// + /// Function to parse the memvar node from the json and update the memvar arrays + /// + /// + /// + public void ParseMemVarNode(string jsonData, string calledFrom) + { + jsonData = jsonData.Replace("*$*", "♦"); + jsonData = jsonData.Replace("\\", ";bkslh"); + string[] resval = jsonData.Split('♦'); + StringBuilder dataJson = new StringBuilder(); + if (jsonData == string.Empty) + return; + + for (int j = 0; j < resval.Length; j++) + { + JArray memVarNode = null; + try + { + JObject tstData = JObject.Parse(resval[j]); + memVarNode = (JArray)tstData["memvar"]; + } + catch (Exception ex) + { + logobj.CreateLog("ParseMemVarNode function -" + ex.Message, sessionid, "Exception-" + transid, "new"); + } + + if (memVarNode != null) + { + for (int m = 0; m < memVarNode.Count; m++) + { + string memVarName = string.Empty; + string memVarValue = string.Empty; + string memVarType = string.Empty; + + Dictionary values = JsonConvert.DeserializeObject>(memVarNode[m].ToString()); + + if (values.ContainsKey("n")) + memVarName = values["n"]; + if (values.ContainsKey("v")) + memVarValue = values["v"]; + if (values.ContainsKey("t")) + memVarType = values["t"]; + + memVarValue = CheckSpecialChars(memVarValue); + int idx = memVarNames.IndexOf(memVarName); + if (idx == -1) + { + memVarNames.Add(memVarName); + memVarValues.Add(memVarValue); + memVarTypes.Add(memVarType); + } + else + { + memVarNames[idx] = memVarName; + memVarValues[idx] = memVarValue; + memVarTypes[idx] = memVarType; + } + } + + //Construct the fieldvaluexml for memvar node and update the global variable + ConstructMemVarNode(); + } + } + } + + /// + /// Function to construct the field value xml for memvar nodes from the arrays + /// + public void ConstructMemVarNode() + { + StringBuilder strXml = new StringBuilder(); + //strXml.Append(""); + for (int i = 0; i < memVarNames.Count; i++) + { + strXml.Append("<" + memVarNames[i].ToString() + " t='" + memVarTypes[i].ToString() + "'>" + memVarValues[i].ToString() + ""); + } + //strXml.Append(""); + memVarsData = strXml.ToString(); + + } + + public void JsonToArray(string jsonResult, TStructDef strObj, string tabDcNo, string calledFrom) + { + + + ChangedDcs.Clear(); + depFormatDcs.Clear(); + if (jsonResult == string.Empty) return; + ArrayList tabDcs = new ArrayList(); + AxDepArrays = new StringBuilder(); + + if (tabDcNo != "") + { + tabDcs = GetSubGridDcsInTabDC(strObj, tabDcNo); + tabDcs.Add(tabDcNo); + } + + //Get the non grid experssion dependent fields if the call is done from a grid field. + ArrayList fldExpDeps = new ArrayList(); + if (calledFrom == "GetDepPerf") + fldExpDeps = GetFldExpDependents(AxActDepField); + + // dcRowCntVals = new ArrayList(); + jsonResult = jsonResult.Replace("*$*", "♦"); + jsonResult = jsonResult.Replace("\\", ";bkslh"); + string[] resval = jsonResult.Split('♦'); + StringBuilder dataJson = new StringBuilder(); + tabJson = new StringBuilder(); + string dcHasDataRowsStr = string.Empty; + string tabJsonPrefix = "{\"data\": ["; + string timeTakenJson = string.Empty; + + //Sub grid for GetDep related variables. + bool isDcPopGrid = false; + int dsRowNo = 0; + + for (int j = 0; j < resval.Length; j++) + { + //TODO: all other json nodes should be handled in the json parsing + JArray Data = null; + try + { + JObject tstData = JObject.Parse(resval[j]); + Data = (JArray)tstData["data"]; + } + catch (Exception ex) + { + logobj.CreateLog("JsonToArray function -" + ex.Message, sessionid, "Exception-" + transid, "new"); + logobj.CreateLog("JsonData -" + jsonResult, sessionid, "Exception-" + transid, ""); + //throw ex; + } + + if (Data != null) + { + string fName = string.Empty; + string fValue = string.Empty; + string changedRows = string.Empty; + string delRows = string.Empty; + string rowNo = string.Empty; + string fDatatype = string.Empty; + string name = string.Empty; + string fldName = string.Empty; + string fldFrameNo = string.Empty; + string frmNum = string.Empty; + string frowValues = string.Empty; + string fldIdValues = string.Empty; + string idCol = string.Empty; + string masterRow = string.Empty; + string comboVal = string.Empty; + string comboFld = string.Empty; + string comboIdCol = "0"; + string dcNo = "0"; + string dpmStr = string.Empty; + string dpValues = string.Empty; + string idVal = string.Empty; + string oldIdVal = string.Empty; + string rowFromJson = string.Empty; + int DCPriorRowCount = 0; + string fillGridName = string.Empty; + StringBuilder ddlVals = new StringBuilder(); + StringBuilder ddlDpVals = new StringBuilder(); + bool isTabDc = false; + for (int m = 0; m < Data.Count; m++) + { + fDatatype = ""; + idCol = ""; + changedRows = string.Empty; + delRows = string.Empty; + masterRow = string.Empty; + + dpValues = ""; + string dcHasRows = string.Empty; + Dictionary values = JsonConvert.DeserializeObject>(Data[m].ToString()); + + + if (values.ContainsKey("t")) + fDatatype = values["t"]; + if (values.ContainsKey("n")) + fName = values["n"]; + if (values.ContainsKey("v")) + fValue = values["v"]; + if (values.ContainsKey("cr")) + changedRows = values["cr"]; + if (values.ContainsKey("fg")) + fillGridName = values["fg"]; + if (values.ContainsKey("dr")) + delRows = values["dr"]; + if (values.ContainsKey("mr")) + masterRow = values["mr"]; + if (values.ContainsKey("idcol")) + idCol = values["idcol"]; + if (values.ContainsKey("id")) + idVal = values["id"]; + if (values.ContainsKey("oldid")) + oldIdVal = values["oldid"]; + if (values.ContainsKey("r")) + { + rowNo = values["r"]; + if (rowNo.Length == 1) + rowNo = "00" + rowNo; + else if (rowNo.Length == 2) + rowNo = "0" + rowNo; + rowFromJson = rowNo; + } + if (values.ContainsKey("dp")) + dpValues = values["dp"]; + if (values.ContainsKey("dpm")) + dpmStr = values["dpm"]; + + + string rowValues = string.Empty; + if (idCol == "no" || idCol == "") + idCol = "0"; + else + idCol = "1"; + + if (fName != string.Empty) + { + //This condition will get the fields in the tab dc which have master row true. + if (masterRow == "1" && dcNo == tabDcNo) + { + if (AxMasterRowFlds.IndexOf(fName) == -1) + AxMasterRowFlds.Add(fName); + } + + fValue = fValue.Replace("^^dq", """); + fValue = fValue.Replace(";bkslh", "\\"); + + //To copy the dc2_referimage file from the given path to Axpert Session folder + if ((fName.StartsWith("dc") && fName.ToLower().EndsWith("_imagepath"))) + hasImagePath = true; + if (fName.ToLower().Contains("dc2_referimages") && fValue != string.Empty) + GetReferedFiles(fValue, hasImagePath); + + //TODO: Same code is available in TStructData constructor and UpdateDataList. + //if (fName.ToLower() == "axpcurrencydec") + // CheckAxpCurrDec(fName, fValue); + + if (fDatatype != "c" && fDatatype != "dv") + dpmStr = string.Empty; + + string rowVal = ""; + + if (fDatatype == "c" || fDatatype == "cl" || fDatatype == "rg") + { + comboVal = fValue; + comboFld = fName; + comboIdCol = idCol; + } + else if (fDatatype == "dv") + { + rowVal = fValue; + if (rowValues == "") + rowValues = rowVal; + else + rowValues += "" + rowVal; + + string[] temp = rowVal.Split('?'); + if (temp.Length <= 3 && comboVal == string.Empty) + { + StringBuilder strVal = new StringBuilder(); + for (int i = 0; i < temp.Length; i++) + { + if (temp[i].ToString() != string.Empty) + strVal.Append(temp[i].ToString()); + } + if (strVal.ToString().ToLower() == "yesno" || strVal.ToString().ToLower() == "noyes") + { + //To set the default value of checkbox in the grid dc to "no". + fValue = "no"; + } + } + + if (dpValues != string.Empty) + { + string[] dpVals = dpValues.Split('~'); + string[] depFlds = dpmStr.Split(','); + string cbVal = string.Empty; + if (comboIdCol == "1") + cbVal = fValue.Substring(fValue.IndexOf("~") + 1); + else + cbVal = fValue; + cbVal = CheckSpecialChars(cbVal); + for (int depIdx = 0; depIdx < depFlds.Length; depIdx++) + { + AxDepArrays.Append("ComboParentField.push(\"" + comboFld + "\");ComboParentValue.push(\"" + cbVal + "\");ComboDepField.push(\"" + depFlds[depIdx] + "\");ComboDepValue.push(\"" + dpVals[depIdx] + "\");"); + } + + } + } + else if (fDatatype == "dc") + { + if (values.ContainsKey("hasdatarows")) + dcHasRows = values["hasdatarows"]; + + comboFld = ""; + string dcRowCount = fName + "~" + fValue; + dcNo = fName.Substring(2); + DCPriorRowCount = 0; + //Code to avoid tabbed dc and its sub grid in the construction of json for GetTabData. + int tabIndx = tabDcs.IndexOf(dcNo); + if (tabIndx != -1) + isTabDc = true; + else + isTabDc = false; + + if (strObj.IsDcFormatGrid(Convert.ToInt32(dcNo))) + { + depFormatDcs.Add(dcNo); + isTabDc = true; + } + + if (isTabDc) + { + dcHasDataRowsStr = "{\"n\":\"DC" + dcNo + "\",\"v\":\"" + fValue + "\",\"t\":\"dc\",\"hasdatarows\":\"" + dcHasRows + "\"}"; + } + + bool dcOldHasRows = false; + bool isGrid = IsDcGrid(dcNo, strObj); + TStructDef.DcStruct dc = (TStructDef.DcStruct)tstStrObj.dcs[Convert.ToInt32(dcNo) - 1]; + if (dc.ispopgrid) + isDcPopGrid = true; + else + isDcPopGrid = false; + if (isGrid) + { + if (dcHasRows != "") + { + dcOldHasRows = dc.DCHasDataRows; + if (dcHasRows == "yes") + dc.DCHasDataRows = true; + else + dc.DCHasDataRows = false; + tstStrObj.dcs[Convert.ToInt32(dcNo) - 1] = dc; + } + } + + if (fValue == "0") + { + fValue = "1"; + dcRowCount = fName + "~" + fValue; + } + + if (isDcPopGrid && calledFrom == "GetDepPerf" && IsParentDc(AxActiveDc)) + { + //Code to add the dr attribute recids to deleted row information. + if (delRows != string.Empty) + SetPopDeletedRows(dcNo, delRows); + // delete the old subgrid rows sent to the webservice for the getdep call + DeletePopRowsAfterDep(); + AxSubGridRows = new ArrayList(); + subWsRows = new ArrayList(); + subDsRows = new ArrayList(); + dsRowNo = 1; + //Since the full sub grid data will not be sent to the webservice, + //the row numbers will always start from 1 hence appending the rows to the grid. + DCPriorRowCount = GetDcRowCount(dcNo); + } + + if (changedRows != "" && isGrid) + { + if (dcOldHasRows == false && dcHasRows == "yes") + changedRows = "d*," + changedRows; + if (ChangedDcs.IndexOf(dcNo) == -1) + ChangedDcs.Add(dcNo); + + //If the dc has fill grid, and if the fillgrid condition is INIT or AOWE + //then the existing rows should be cleared and added. + //The same condition is also added in ExecData in process.js + int fgIdx = GetDcFillGridIndex(fName, fillGridName); + if (fgIdx != -1 && calledFrom != "ExecAction" && calledFrom != "AddRow") + { + TStructDef.FGStruct fg = (TStructDef.FGStruct)tstStrObj.fgs[fgIdx]; + if (fg.FGCondition == Constants.INIT || fg.FGCondition == Constants.AOWE) + { + if (changedRows.IndexOf("d*") == -1) + changedRows = "d*," + changedRows; + if (IsParentDc(dcNo)) + { + ArrayList arrPopDcs = new ArrayList(); + arrPopDcs = GetPopDcsForParent(dcNo); + for (int pIdx = 0; pIdx < arrPopDcs.Count; pIdx++) + { + TStructDef.DcStruct pdc = (TStructDef.DcStruct)tstStrObj.dcs[Convert.ToInt32(arrPopDcs[pIdx].ToString()) - 1]; + if (pdc.DCHasDataRows) + SetDbRows("d*", pdc.frameno.ToString(), tstStrObj, ""); + + } + } + } + else if (fg.FGCondition == Constants.APPEND && dcHasRows == "yes" && calledFrom == "Action") + { + DCPriorRowCount = 0;// GetDcRowCount(dcNo); + if (changedRows.IndexOf("d*") != -1) + dcRowCount = fName + "~" + (Convert.ToInt32(fValue)); + else + dcRowCount = fName + "~" + (Convert.ToInt32(fValue) + GetDcRowCount(dcNo)); + } + else if (fg.FGCondition == Constants.APPEND && dcOldHasRows) + { + DCPriorRowCount = GetDcRowCount(dcNo); + dcRowCount = fName + "~" + (Convert.ToInt32(fValue) + GetDcRowCount(dcNo)); + } + } + + if (dcHasRows == "yes" || (dcOldHasRows && dcHasRows == "no")) + { + //The cr attribute from the getdep will be ignored for subgrid + if (isDcPopGrid && calledFrom == "GetDepPerf" && IsParentDc(AxActiveDc)) + continue; + SetDbRows(changedRows, dcNo, strObj, calledFrom); + } + } + else if (calledFrom == "FillGridMS" && isGrid && dcOldHasRows == false && dcHasRows == "yes")//Refer Bug: HEA000021-- Multy select fillgrid having hidden row its not adding based on srvice result. + { + SetDbRows("d*", dcNo, strObj, calledFrom); + } + UpdateRowCount(fName, dcRowCount); + } + else + { + //Code for setting default item value for auto select + comboFld = ""; + } + + //The isTabDc can be used for format grid dc, for returning the json without format grid data. + if (!isTabDc) + { + if (dataJson.ToString() == "") + dataJson.Append(Data[m].ToString()); + else + dataJson.Append("," + Data[m].ToString()); + } + else + { + + if (dcHasDataRowsStr != "") + { + if (dataJson.ToString() == "") + dataJson.Append(dcHasDataRowsStr); + else + dataJson.Append("," + dcHasDataRowsStr); + + dcHasDataRowsStr = string.Empty; + } + } + + if (fDatatype == "dv") + { + ddlVals.Append(rowValues); + ddlVals.Append("♣"); + ddlDpVals.Append(dpValues); + ddlDpVals.Append("♣"); + DSUpdateRowValues(fName, Convert.ToInt32(rowNo) + DCPriorRowCount, ddlVals.ToString(), ddlDpVals.ToString(), masterRow, comboIdCol); + } + else + { + ddlVals = new StringBuilder(); + if (fDatatype != "dc") + { + string rowFrmNo = string.Empty; + if (rowNo != "") + { + name = fName + rowNo + "F" + dcNo; + rowFrmNo = rowFrmNo + "F" + dcNo; + } + //If the get dependents is called on a grid field, then the below code will ignore all expression dependents in the non grid. + if (calledFrom == "GetDepPerf") + { + if (fldExpDeps.IndexOf(fName) != -1) + continue; + } + + if (isDcPopGrid && calledFrom == "GetDepPerf" && IsParentDc(AxActiveDc)) + { + dsRowNo = GetSubDsRowNo(Convert.ToInt32(rowNo), dcNo); + DSSubmit(fName, dsRowNo, fValue, idVal); + } + else + DSSubmit(fName, Convert.ToInt32(rowNo) + DCPriorRowCount, fValue, idVal); + } + } + } + } + } + else + { + + ParseJsonNodes(resval[j].ToString()); + JArray timeTaken = null; + try + { + JObject tstData = JObject.Parse(resval[j]); + timeTaken = (JArray)tstData["timetaken"]; + } + catch (Exception ex) + { + + } + + if (timeTaken != null) + { + timeTakenJson = resval[j].ToString() + "*$*"; + continue; + } + + if (dataJson.ToString() != "") + { + tabJson.Insert(0, tabJsonPrefix); + tabJson.Append(dataJson + "]}"); + dataJson.Remove(0, dataJson.ToString().Length); + } + tabJson.Append(resval[j].ToString()); + } + } + if (dataJson.ToString() != "") + { + tabJson.Insert(0, tabJsonPrefix); + tabJson.Append(dataJson + "]}"); + dataJson.Remove(0, dataJson.ToString().Length); + tabJson.Insert(0, timeTakenJson); + } + + //Call the function which parses thge memvar node and updates the arrays. + ParseMemVarNode(jsonResult, calledFrom); + } + + + //Function to get the exact rowno for the new row being added. + private int GetSubDsRowNo(int wsRowNo, string dcNo) + { + int dsRowNo = 0; + int idx = -1; + idx = subWsRows.IndexOf(wsRowNo); + if (idx == -1) + { + subWsRows.Add(wsRowNo); + dsRowNo = GetDcRowCount(dcNo) + 1; + subDsRows.Add(dsRowNo); + } + else + { + dsRowNo = (Int32)subDsRows[idx]; + } + + return dsRowNo; + } + + /// + /// Function return true if the given dc is a parent dc. + /// + /// + /// + private bool IsParentDc(string dcNo) + { + bool isParDc = false; + for (int i = 0; i < tstStrObj.popdcs.Count; i++) + { + if (dcNo == ((TStructDef.PopDcStruct)(tstStrObj.popdcs[i])).pdcno.ToString()) + { + isParDc = true; + break; + } + } + return isParDc; + } + + /// + /// Function returns array of popdcs defined for a given dc. + /// + /// + /// + public ArrayList GetPopDcsForParent(string dcNo) + { + ArrayList arrPopDcs = new ArrayList(); + for (int i = 0; i < tstStrObj.popdcs.Count; i++) + { + if (dcNo == ((TStructDef.PopDcStruct)(tstStrObj.popdcs[i])).pdcno.ToString()) + { + arrPopDcs.Add(((TStructDef.PopDcStruct)(tstStrObj.popdcs[i])).frameno); + } + } + return arrPopDcs; + } + + /// + /// Function to get the non grid expression dependents for a field. + /// + /// + /// + private ArrayList GetFldExpDependents(string fName) + { + int idx = tstStrObj.GetFieldIndex(fName); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[idx]; + ArrayList fldExpDep = new ArrayList(); + string[] fldDeps = fld.fieldDependents.Split(','); + for (int i = 0; i < fldDeps.Length; i++) + { + string depFldName = fldDeps[i].ToString(); + string prefix = depFldName.Substring(0, 1); + int depIdx = tstStrObj.GetFieldIndex(depFldName.Substring(1)); + if (depIdx != -1) + { + TStructDef.FieldStruct depFld = (TStructDef.FieldStruct)tstStrObj.flds[depIdx]; + if (prefix == "e" && fld.fldframeno > depFld.fldframeno && !IsDcGrid(depFld.fldframeno.ToString(), tstStrObj)) + { + fldExpDep.Add(fldDeps[i].ToString()); + } + } + } + return fldExpDep; + } + + /// + /// Function to get the dependent grid dc for a given field. + /// + /// + /// + public ArrayList GetGridDepForField(string fieldName) + { + int idx = tstStrObj.GetFieldIndex(fieldName); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[idx]; + ArrayList sqlDepDc = new ArrayList(); + string[] fldDeps = fld.fieldDependents.Split(','); + for (int i = 0; i < fldDeps.Length; i++) + { + string depFldName = fldDeps[i].ToString(); + string prefix = depFldName.Substring(0, 1); + int depIdx = tstStrObj.GetFieldIndex(depFldName.Substring(1)); + if (depIdx != -1) + { + TStructDef.FieldStruct depFld = (TStructDef.FieldStruct)tstStrObj.flds[depIdx]; + if (prefix != "e" && sqlDepDc.IndexOf(depFld.fldframeno) == -1 && IsDcGrid(depFld.fldframeno.ToString(), tstStrObj)) + { + sqlDepDc.Add(depFld.fldframeno); + } + } + } + return sqlDepDc; + } + + private void StringToFile(string strDebugText) + { + if (!isDebugFileCreated) + { + logobj.CreateLog(strDebugText, HttpContext.Current.Session["nsessionid"].ToString(), "DebugValues", "new"); + isDebugFileCreated = true; + } + logobj.CreateLog(strDebugText, HttpContext.Current.Session["nsessionid"].ToString(), "DebugValues", ""); + + } + + private void ParseJsonNodes(string result) + { + if (result == string.Empty) return; + JArray cmdNode = null; + try + { + JObject tstData = JObject.Parse(result); + cmdNode = (JArray)tstData["command"]; + } + catch (Exception ex) + { + logobj.CreateLog("ParseJsonNodes function -" + ex.Message, sessionid, "Exception-" + transid, "new"); + } + + if (cmdNode != null) + { + string cmdName = string.Empty; + string cmdVal = string.Empty; + for (int i = 0; i < cmdNode.Count; i++) + { + Dictionary values = JsonConvert.DeserializeObject>(cmdNode[i].ToString()); + + + for (int k = 0; k < values.Count; k++) + { + if (values.ContainsKey("cmd")) + cmdName = values["cmd"]; + if (values.ContainsKey("cmdval")) + cmdVal = values["cmdval"]; + + if (cmdName == "newtrans" || cmdName == "copytrans") + { + recordid = "0"; + recordID = "0"; + rid = "0"; + ModifyAsNewRecord(); + break; + } + } + } + } + } + + public string GetMasterRowFlds() + { + string AxFlds = string.Empty; + for (int i = 0; i < AxMasterRowFlds.Count; i++) + { + if (AxFlds == string.Empty) + AxFlds = AxMasterRowFlds[i].ToString(); + else + AxFlds += "," + AxMasterRowFlds[i].ToString(); + } + + return AxFlds == string.Empty ? "Ax-NA" : AxFlds; + } + + private void SetDbRowsOnLoad(string changedRows, string dcNo, TStructDef strObj) + { + int frameNo = Convert.ToInt32(dcNo); + string[] rowStr = changedRows.Split(','); + + for (int i = 0; i < rowStr.Length; i++) + { + string firstChar = rowStr[i].Substring(0, 1); + string rowNo = rowStr[i].Substring(1); + if (firstChar == "d") + { + if (rowNo == "*") + DeleteAllRowsInDc(dcNo); + else + DeleteRowInFldArrays(dcNo, rowNo); + } + } + } + + public void SetSubGridRows(string subGridRows) + {//The string will be in the format of popdc1~row1,row2,row3¿popdc2~row1,row2 + if (subGridRows != string.Empty) + { + string[] subrows = subGridRows.Split('¿'); + for (int i = 0; i < subrows.Length; i++) + { + if (subrows[i].ToString() != string.Empty) + { + AxSubGridRows.Add(subrows[i].ToString()); + } + } + } + } + + private void SetDbRows(string changedRows, string dcNo, TStructDef strObj, string calledFrom) + { + int frameNo = Convert.ToInt32(dcNo); + string[] rowStr = changedRows.Split(','); + + for (int i = 0; i < rowStr.Length; i++) + { + if (rowStr[i] == string.Empty) + continue; + try + { + string firstChar = rowStr[i].Substring(0, 1); + string rowNo = rowStr[i].Substring(1); + if (firstChar == "d") + { + if (rowNo == "*") + DeleteAllRowsInDc(dcNo); + else + DeleteRowInFldArrays(dcNo, rowNo); + } + } + catch (Exception ex) + { + logobj.CreateLog(ex.StackTrace, HttpContext.Current.Session["nsessionid"].ToString(), "Exception", "new"); + } + } + } + + private string GetMaxDcRowNo(string dcNo) + { + int rowNo = 0; + for (int i = 0; i < fieldControlName.Count; i++) + { + if (fieldFrameNo[i].ToString() == dcNo) + { + string rNo = fieldRowNo[i].ToString(); + if (Convert.ToInt32(rNo) > rowNo) + rowNo = Convert.ToInt32(rNo); + } + } + + return GetRowNoHelper(Convert.ToString(rowNo + 1)); + } + + private string GetFieldsRowNo(string fldId) + { + int idx = fldId.LastIndexOf("F"); + if (idx != -1) + return fldId.Substring(idx - 3, 3); + else + return "000"; + } + + private string GetRowNoHelper(string rowNo) + { + if (rowNo.Length == 1) + rowNo = "00" + rowNo; + else if (rowNo.Length == 2) + rowNo = "0" + rowNo; + return rowNo; + } + + private string CreateDataJson(Boolean IsDc, string dcNo, string Value, string rowCnt, string dataJson) + { + string dcDataRowsStr = string.Empty; + if (IsDc) + dcDataRowsStr = "{\"n\":\"DC" + dcNo + "\",\"v\":\"" + rowCnt + "\",\"t\":\"dc\"}"; + else + dcDataRowsStr = "{\"n\":\"axp_recid" + dcNo + "\",\"v\":\"0\",\"r\":\"" + rowCnt + "\",\"t\":\"s\"}"; + if (dataJson.ToString() != "") + dcDataRowsStr = "," + dcDataRowsStr; + + return dcDataRowsStr; + } + + public void UpdateRowCount(string dcNo, string newRowCnt) + { + int index = -1; + for (int i = 0; i < dcRowCntVals.Count; i++) + { + string[] dcRCnt = dcRowCntVals[i].ToString().Split('~'); + if (dcRCnt[0].ToString().ToLower() == dcNo.ToLower()) + { + index = i; + break; + } + } + + if (index == -1) + dcRowCntVals.Add(newRowCnt); + else + dcRowCntVals[index] = newRowCnt; + } + + /// + /// Function to get the fields index from the fieldControlName array. + /// + /// + /// + public int GetFieldIndex(string fldName) + { + for (int j = 0; j < fieldControlName.Count; j++) + { + if (fieldControlName[j] != null) + { + if (fieldControlName[j].ToString() == fldName) + { + return j; + } + } + } + + return -1; + } + + public string CallDeleteDataWS(string s) + { + DateTime stTime = DateTime.Now; + string news = GetTraceString(s); + if (news != "") s = news; + s = s + HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString() + ""; + string result = null; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + DateTime asStart = DateTime.Now; + result = objWebServiceExt.CallDeleteDataWS(transid, s); + DateTime asEnd = DateTime.Now; + if (result.ToLower().IndexOf("data deleted successfully") > -1) + RemoveAttachFromServer(s, transid); + //RemoveAttachFromDir(""); + if (logTimeTaken) + { + webTime1 = asStart.Subtract(stTime).TotalMilliseconds; + webTime2 = DateTime.Now.Subtract(asEnd).TotalMilliseconds; + asbTime = asEnd.Subtract(asStart).TotalMilliseconds; + } + return result; + } + + public string CallAddRowWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string s, string dcNo) + { + string news = GetTraceString(s); + if (news != "") s = news; + transid = tstData.transid.ToString(); + ires = tstStrObj.structRes; + tstData.GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "", "NG", dcNo); + s += tstData.fieldValueXml + memVarsData; + s += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + s += ""; + string result = string.Empty; + + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallAddRowWS(transid, s, ires); + return result; + } + + public string CallAddRowPerfWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string s, string dcNo) + { + string news = GetTraceString(s); + if (news != "") s = news; + transid = tstData.transid.ToString(); + ires = tstStrObj.structRes; + tstData.GetPerfFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "", "NG", dcNo); + s += WsPerfAddRowLoadDc(dcNo, "AddRow"); + s += memVarsData; + s += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + s += ""; + string result = string.Empty; + + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallAddRowWS(transid, s, ires); + return result; + } + + private string WsPerfAddRowLoadDc(string dcno, string calledFrom) + { + string iXml = string.Empty; + int dcFrame = int.Parse(dcno); + TStructDef.DcStruct pfldDc = (TStructDef.DcStruct)tstStrObj.dcs[dcFrame - 1]; + if (pfldDc.dcPList != "") + { + string[] parentFlds = pfldDc.dcPList.Replace("~", ",").Split(','); + string globalVars = HttpContext.Current.Session["axGlobalVars"].ToString(); + string userVars = HttpContext.Current.Session["axUserVars"].ToString(); + for (int i = 0; i < parentFlds.Length; i++) + { + int pIndx = tstStrObj.GetFieldIndex(parentFlds[i]); + if (pIndx == -1) + { + if (globalVars.ToLower().IndexOf("<" + parentFlds[i].ToLower() + ">") > -1) + continue; + else if (userVars.ToLower().IndexOf("<" + parentFlds[i].ToLower() + ">") > -1) + continue; + else + continue; + } + TStructDef.FieldStruct pfld = (TStructDef.FieldStruct)tstStrObj.flds[pIndx]; + if (calledFrom == "AddRow" || calledFrom == "DeleteRow") + iXml += PerfGetDepFldValues(pfld.fldFrameNo, 0, calledFrom, pfld); + else if ((calledFrom == "LoadDc" || calledFrom == "FillGrid") && pfld.fldFrameNo != dcFrame) + iXml += PerfGetDepFldValues(pfld.fldFrameNo, 0, calledFrom, pfld); + } + } + return iXml; + } + + private string WsPerfFieldToXML(string fldName, string rowNo, string value, string oldValue, string idvalue, string oldIdValue, string dcNo, Boolean fldSaveNormal, TStructDef.FieldStruct fld = new TStructDef.FieldStruct()) + { + string dsDataXML = string.Empty; + rowNo = GetRowNoHelper(rowNo.ToString()); + value = CheckSpecialChars(value); + oldValue = CheckSpecialChars(oldValue); + string oldVal = ""; + if (recordid != "0") + { + if (value != oldValue) + oldVal = "ov=\"" + oldValue + "\""; + else + oldVal = ""; + } + if (fldName.StartsWith(Constants.IMGPrefix)) + return dsDataXML; + if (fld.datatype != null && fld.datatype.ToLower() == "image" && imgAttachPath != "") + return dsDataXML; + if (fldSaveNormal) + { + if (Convert.ToString(idvalue) == "") idvalue = "0"; + if (Convert.ToString(oldIdValue) == "") oldIdValue = "0"; + dsDataXML += "<" + fldName + " rowno=\"" + rowNo + "\" id=\"" + idvalue + "\" oldid=\"" + oldIdValue + "\" " + oldVal + ">" + value + ""; + } + else + { + dsDataXML += "<" + fldName + " rowno=\"" + rowNo + "\" " + oldVal + ">" + value + ""; + } + return dsDataXML; + } + + public string CallDeleteRowWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string s, string dcNo) + { + string news = GetTraceString(s); + if (news != "") s = news; + transid = tstData.transid.ToString(); + ires = tstStrObj.structRes; + tstData.GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "", "NG", dcNo); + s += tstData.fieldValueXml + memVarsData; + s += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + s += ""; + string result = string.Empty; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallDeleteRowWS(transid, s, ires); + return result; + } + + public string CallDeleteRowPerfWS(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string s, string dcNo) + { + string news = GetTraceString(s); + if (news != "") s = news; + transid = tstData.transid.ToString(); + ires = tstStrObj.structRes; + tstData.GetPerfFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "", "NG", dcNo); + s += WsPerfAddRowLoadDc(dcNo, "DeleteRow"); + s += memVarsData; + s += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + s += ""; + string result = string.Empty; + bool callService = false; + if (tstStrObj.wsPerfEnabled == true) + { + if (tstStrObj.wsPerfGRDDcs != null && tstStrObj.wsPerfGRDDcs.IndexOf(dcNo) != -1) + callService = true; + } + else + callService = true; + if (callService) + { + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallDeleteRowWS(transid, s, ires); + } + return result; + } + + public string LoadComboValues(TStructData tstData, ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string iXml, string dcNo) + { + DateTime stTime = DateTime.Now; + string strTrace = GetTraceString(iXml); + if (strTrace != "") iXml = strTrace; + string result = string.Empty; + //GetGlobalVars(); + transid = tstData.transid.ToString(); + ires = tstStrObj.structRes; + //tstData.GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "LoadTab", "NG", dcNo); + //iXml += tstData.fieldValueXml + memVarsData; + tstData.GetPerfFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "LoadTab", "NG", dcNo); + iXml += WsPerfAddRowLoadDc(dcNo, "LoadDc"); + iXml += memVarsData; + iXml += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + iXml += ""; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + DateTime asStart = DateTime.Now; + + if (CallWsPerfLoadDc(dcNo)) + result = objWebServiceExt.CallLoadDCCombosWS(transid, iXml, ires); + DateTime asEnd = DateTime.Now; + if (logTimeTaken) + { + webTime1 = asStart.Subtract(stTime).TotalMilliseconds; + webTime2 = DateTime.Now.Subtract(asEnd).TotalMilliseconds; + asbTime = asEnd.Subtract(asStart).TotalMilliseconds; + } + return result; + } + + private bool CallWsPerfLoadDc(string dcNo) + { + bool isCallDcCombo = false; + //If dc has fillgrid + if (dcNo != "" && tstStrObj.wsPerfFGDcName != null && rid == "0") + { + string[] flGridDc = tstStrObj.wsPerfFGDcName; + var loaddcFG = flGridDc.Where(d => d.ToLower() == "dc" + dcNo).ToList(); + if (loaddcFG.Count > 0) + isCallDcCombo = true; + } + //Below condition not required to now becuse of accept sql field will take cae either doformload, addrow or getdependency + ////If dc has accept sql or select with auto select fields + //if (tstStrObj.wsPerfLDcName != null && isCallDcCombo == false && rid == "0") + //{ + // string[] fldldCall = tstStrObj.wsPerfLDcName; + // var loaddcFld = fldldCall.Where(fd => fd.ToLower() == "dc" + dcNo).ToList(); + // if (loaddcFld.Count > 0) + // isCallDcCombo = true; + //} + return isCallDcCombo; + } + + public string GetSubGridCombos(ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string iXml, string dcNo, string parDcNo, int popRowNo, int parRowNo) + { + string strTrace = GetTraceString(iXml); + if (strTrace != "") iXml = strTrace; + string result = string.Empty; + ires = tstStrObj.structRes; + GetPopFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", parDcNo, parRowNo, dcNo, popRowNo); + iXml += fieldValueXml + memVarsData; + iXml += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + iXml += ""; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + result = objWebServiceExt.CallGetSubGridCCombosWS(transid, iXml, ires); + return result; + } + + + #endregion + + #endregion + + private void UpdateRowValues(string fldName, string rowNo, string dcNo, string comboValues, string dpValues) + { + int idx = GetFldIndex(Convert.ToInt32(dcNo), fldName, Convert.ToInt32(rowNo)); + if (idx != -1) + { + fieldRowValues[idx] = comboValues; + fieldDPVals[idx] = dpValues; + } + } + + public bool IsDcGrid(string dcNo, TStructDef strObj) + { + bool isGrid = false; + for (int i = 0; i < strObj.dcs.Count; i++) + { + TStructDef.DcStruct dc = (TStructDef.DcStruct)strObj.dcs[i]; + if (dc.frameno.ToString() == dcNo && dc.isgrid == true) + { + isGrid = true; + break; + } + } + return isGrid; + } + + public int GetDcRowCount(string dcNo) + { + return dsDataSet.Tables["dc" + dcNo].Rows.Count; + } + + #region PickList Methods + /// + /// Function to call the webservice which returns the filtered value for the picklist field. + /// + /// + /// + public string GetPickListResult(ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string iXml, string structXml, string fldName, string frameNo, string parentInfo, string subGridInfo, string activeRow, string includeDcs) + { + string res = ""; + GetPicklistInputXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, fldName, frameNo, parentInfo, subGridInfo, activeRow); + iXml += this.fieldValueXml + memVarsData; + iXml += HttpContext.Current.Session["axApps"].ToString() + HttpContext.Current.Application["axProps"].ToString() + HttpContext.Current.Session["axGlobalVars"].ToString() + HttpContext.Current.Session["axUserVars"].ToString(); + iXml += ""; + //Call service + objWebServiceExt = new ASBExt.WebServiceExt(); + iXml = util.CheckSplChrInputXML(iXml); + res = objWebServiceExt.CallGetSearchResultWS(transid, iXml, structXml); + if (res != "done" && res != "" && !res.StartsWith(Constants.ERROR)) + { + res = ParsePickListJson(res); + } + return res; + } + + public void GetPicklistInputXml(ArrayList fldArray, ArrayList fldDbRowNo, ArrayList fldValueArray, ArrayList fldDeletedArray, string fldName, string frameNo, string parentInfo, string subGridInfo, string activeRow) + { + int idx = tstStrObj.GetFieldIndex(fldName); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[idx]; + ArrayList AxDepFields = new ArrayList(); + bool isDcGrid = false; + Dictionary IncludeDcRows = new Dictionary(); + isDcGrid = IsDcGrid(frameNo, tstStrObj); + + if (isDcGrid) + { + string DepFlds = fld.fieldSqlDepParents; + AxDepFields = GetParDepFlds(fld.fieldSqlDepParents); + } + + if (fld.fieldSqlGridDeps != string.Empty) + { + string[] strSDeps = fld.fieldSqlGridDeps.Split(','); + for (int i = 0; i < strSDeps.Length; i++) + { + AxDepFields.Add(strSDeps[i].ToString()); + } + + //The below statement will add the current field to the dependent fields if the current dc is a grid dc + //and it has dependents in other grid, then all the row values for the field should be sent in the input xml. + if (isDcGrid) + AxDepFields.Add(fld.name); + } + + + //If the field has non grid sql dependents, then send the parent values for that dep field also + if (IsDcGrid(frameNo, tstStrObj)) + { + //If the call is made from a parent grid, then all its subgriud and their respective rows for the given parent row + //will be sent in the given format: dcno~rowno1,rowno2¿dcno~rowno1,rowno2... + if (subGridInfo != "") + { + if (subGridInfo.IndexOf("¿") != -1) + { + string[] subgridDcs = subGridInfo.Split('¿'); + for (int i = 0; i < subgridDcs.Length; i++) + { + string[] dcInfo = subgridDcs[i].ToString().Split('~'); + IncludeDcRows.Add(dcInfo[0], dcInfo[1]); + } + } + else + { + IncludeDcRows.Add(subGridInfo.Substring(0, subGridInfo.IndexOf("~")), subGridInfo.Substring(subGridInfo.IndexOf("~") + 1)); + } + } + + //If the call is made from sub grid, then the parentinfo will contain the parent dc no and parent row no in the given format : dcno~rowno + if (parentInfo != "") + { + IncludeDcRows.Add(parentInfo.Substring(0, parentInfo.IndexOf("~")), parentInfo.Substring(parentInfo.IndexOf("~") + 1)); + } + + + //first update the list with the new fldArray. + UpdateDataList(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray); + + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + + CreateFieldValueXmlPerf(frameNo, activeRow, AxDepFields, fld.fieldDepGridDcs, IncludeDcRows, ""); + } + else + { + if (AxDepFields.Count > 0) + { + //if a non grid fields has dependent grid dc fields, then send that dc fields data also. + //first update the list with the new fldArray. + UpdateDataList(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray); + DeleteDefaultRowInPopDc(project, user, transid, sessionid, AxRole); + CreateFieldValueXmlPerf(frameNo, activeRow, AxDepFields, fld.fieldDepGridDcs, IncludeDcRows, ""); + } + else + { + //if a non grid fields has dependent grid Fill grid dc, then send that dc data also. + GetFieldValueXml(fldArray, fldDbRowNo, fldValueArray, fldDeletedArray, "-1", "GetDependents", "NG", fld.fieldDepFillDcs); + } + } + } + + /// + /// Function to parse the result of GetSearchResult service and construct the result string and return to the client. + /// + /// + /// + private string ParsePickListJson(string result) + { + StringBuilder pickDataArray = new StringBuilder(); + JArray Data; + try + { + result = result.Replace("\\", ";bkslh"); + JObject tstData = JObject.Parse(result); + Data = (JArray)tstData["pickdata"]; + } + catch (Exception ex) + { + throw ex; + } + + if (Data != null) + { + string fName = string.Empty; + string fValue = string.Empty; + for (int m = 0; m < Data.Count; m++) + { + if (Data[m]["rcount"] != null) + { + string rCount = Data[m]["rcount"].ToString(); + rCount = rCount.Replace("\"", ""); + if (rCount != "0") + pickDataArray.Append(rCount + "♣"); + } + else if (Data[m]["fname"] != null) + { + fName = (string)Data[m]["fname"].ToString(); + } + else + { + fValue = (string)Data[m]["fvalue"].ToString(); + //Following Code was removing first and last character of fname and fvalue resulting in issues.. hence commented + //fName = fName.Remove(0, 1); + //fName = fName.Remove(fName.Length - 1, 1); + //fValue = fValue.Remove(0, 1); + //fValue = fValue.Remove(fValue.Length - 1, 1); + fValue = fValue.Replace("^^dq", "\""); + fValue = fValue.Replace(";bkslh", @"\"); + string[] pickFldValues = fValue.Split('~'); + for (int j = 0; j < pickFldValues.Length; j++) + { + if (j == 0) + pickDataArray.Append(pickFldValues[j].ToString()); + else + pickDataArray.Append("¿" + pickFldValues[j].ToString()); + } + } + } + } + return pickDataArray.ToString(); + } + #endregion + + private void GetGlobalVars() + { + project = HttpContext.Current.Session["project"].ToString(); + user = HttpContext.Current.Session["user"].ToString(); + AxRole = HttpContext.Current.Session["AxRole"].ToString(); + sessionid = HttpContext.Current.Session["nsessionid"].ToString(); + } + + public string GetIncludeDcsForLoad() + { + string includeDcs = string.Empty; + string depDcs = string.Empty; + DataRow dr = DsGetRow("axp_mustloaddc", "001"); + if (dr != null) + depDcs = dr["axp_mustloaddc"].ToString(); + return depDcs; + } + + public void AddToFasDDl(string fName, string fJson) + { + if (fastDDL.ContainsKey(fName)) + fastDDL.Remove(fName); + + fastDDL.Add(fName, fJson); + } + + #region New Indexing Methods + + /// + /// Function loops through the dcs in the tstruct and for every dc adds the default fields into the field arrays. + /// + /// + private void CreateDefaultFArray(TStructDef strObj) + { + foreach (TStructDef.DcStruct dc in strObj.dcs) + UpdateRowCount(dc.frameno.ToString(), "DC" + dc.frameno.ToString() + "~1"); + } + + /// + /// Function loops through the dcs in the tstruct and for every dc adds the default fields into the Data Table. + /// + /// + private void CreateDataSets(TStructDef strObj) + { + DataSet ds = new DataSet("datacache"); + // TODO: needs proper comment - Create a DataSet and put both tables in it. + foreach (TStructDef.DcStruct dc in strObj.dcs) + { + ds.Tables.Add(DSConstruct(dc.frameno, strObj)); + ds.Tables.Add(DSConstructOld(dc.frameno, strObj)); + ds.Tables.Add(DSSaveFalse(dc.frameno, strObj)); + } + ds.Tables.Add(DSCreateDropDownTable()); + dsDataSet = ds; + } + + private DataTable DSCreateDropDownTable() + { + DataTable dtDropDownValue = new DataTable(); + dtDropDownValue.TableName = "dsdropdown"; + + DataColumn[] keys1 = new DataColumn[1]; + DataColumn column1 = dtDropDownValue.Columns.Add("dropdownkey"); + keys1[0] = column1; + dtDropDownValue.PrimaryKey = keys1; + + dtDropDownValue.Columns.Add("fldname"); + dtDropDownValue.Columns.Add("axp__rowno"); + dtDropDownValue.Columns.Add("rowvals"); + dtDropDownValue.Columns.Add("dpmvalues"); + dtDropDownValue.Columns.Add("dp"); + dtDropDownValue.Columns.Add("mr"); + dtDropDownValue.Columns.Add("idcol"); + + return dtDropDownValue; + } + + private DataTable DSSaveFalse(int dcNo, TStructDef strObj) + { + TStructDef.DcStruct dc = (TStructDef.DcStruct)strObj.dcs[dcNo - 1]; + DataTable dtObj = new DataTable("dc_savefalse" + dcNo.ToString()); + DataColumn[] keys = new DataColumn[1]; + DataColumn column; + string dcFldRange = strObj.GetDcFieldRange(dcNo.ToString()); + string[] fldRange = dcFldRange.Split(','); + int startIndex = Convert.ToInt32(fldRange[0]); + int endIndex = Convert.ToInt32(fldRange[1]); + + for (int j = startIndex; j <= endIndex; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)strObj.flds[j]; + + if (fld.savevalue == false) + { + dtObj.Columns.Add(fld.name); + } + } + + column = dtObj.Columns.Add("axp__rowno"); + column.DataType = typeof(Int32); + keys[0] = column; + dtObj.PrimaryKey = keys; + + return dtObj; + } + + private DataTable DSConstructOld(int dcNo, TStructDef strObj) + { + TStructDef.DcStruct dc = (TStructDef.DcStruct)strObj.dcs[dcNo - 1]; + DataTable dtOldObj = new DataTable("dc_old" + dcNo.ToString()); + DataColumn[] keys = new DataColumn[1]; + DataColumn column; + + string dcFldRange = strObj.GetDcFieldRange(dcNo.ToString()); + string[] fldRange = dcFldRange.Split(','); + int startIndex = Convert.ToInt32(fldRange[0]); + int endIndex = Convert.ToInt32(fldRange[1]); + + for (int j = startIndex; j <= endIndex; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)strObj.flds[j]; + + dtOldObj.Columns.Add("old__" + fld.name); + if (fld.savenormal) + dtOldObj.Columns.Add("oldid__" + fld.name); + } + + column = dtOldObj.Columns.Add("axp__rowno"); + column.DataType = typeof(Int32); + keys[0] = column; + dtOldObj.PrimaryKey = keys; + + return dtOldObj; + } + + /// + /// Function to add every field in given dc into the field array and index array. + /// + /// + /// + /// + private DataTable DSConstruct(int dcNo, TStructDef strObj) + { + TStructDef.DcStruct dc = (TStructDef.DcStruct)strObj.dcs[dcNo - 1]; + DataTable dtObj = new DataTable("dc" + dcNo.ToString()); + + DataColumn[] keys = new DataColumn[1]; + DataColumn column; + + string dcFldRange = strObj.GetDcFieldRange(dcNo.ToString()); + string[] fldRange = dcFldRange.Split(','); + int startIndex = Convert.ToInt32(fldRange[0]); + int endIndex = Convert.ToInt32(fldRange[1]); + + for (int j = startIndex; j <= endIndex; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)strObj.flds[j]; + dtObj.Columns.Add(fld.name); + //dtObj.Columns.Add("old__" + fld.name); + + if (fld.savenormal) + { + dtObj.Columns.Add("id__" + fld.name); + //dtObj.Columns.Add("oldid__" + fld.name); + } + } + //dtObj.Columns.Add("axp_recid" + dcNo); + column = dtObj.Columns.Add("axp__rowno"); + column.DataType = typeof(Int32); + keys[0] = column; + dtObj.PrimaryKey = keys; + dtObj.Columns.Add("axp__delrow"); + if (dc.isgrid) + dtObj.Columns.Add(Constants.AXPISROWVALID + dcNo); + + return dtObj; + } + + + /// + /// Function which loop though each dc till the given dc and appends the field count. + /// + /// + /// + /// + private int GetDcIndex(int dcNo) + { + int fldCnt = 0; + foreach (TStructDef.DcStruct dc in tstStrObj.dcs) + { + if (dc.frameno >= dcNo) + break; + + fldCnt += dc.fieldCount; + } + return fldCnt; + } + + /// + /// Function to calculate the index of the field in the fieldIndexArray + /// and return the value from that item of the fieldIndexArray. + /// + /// + /// + /// + /// + public int GetFldIndex(int dcNo, string fldName, int rowNo) + { + int idx = 0; + int index = 0; + if (rowNo == 0) rowNo = 1; + foreach (TStructDef.DcStruct dc in tstStrObj.dcs) + { + if (dc.frameno >= dcNo) + break; + + idx += GetDcRowCount(dc.frameno.ToString()) * dc.fieldCount; + } + + TStructDef.DcStruct currentDC = (TStructDef.DcStruct)tstStrObj.dcs[dcNo - 1]; + int fieldOrder = GetFieldOrder(fldName, dcNo, currentDC); + //Formula = idx + FieldCountInDC * (RowNo-1) + (FieldOrder - StartOrderInDC) + idx += currentDC.fieldCount * (rowNo - 1) + (fieldOrder - GetDcIndex(dcNo)); + if (idx >= fieldIndexArray.Count) index = -1; + else + index = (Int32)fieldIndexArray[idx]; + return index; + } + + /// + /// Function to get the field order for the given field in the given dc. + /// + /// + /// + /// + /// + private int GetFieldOrder(string fldName, int dcNo, TStructDef.DcStruct dc) + { + int fldOrd = 0; + string dcFldRange = tstStrObj.GetDcFieldRange(dcNo.ToString()); + string[] fldRange = dcFldRange.Split(','); + int startIndex = Convert.ToInt32(fldRange[0]); + int endIndex = Convert.ToInt32(fldRange[1]); + + for (int j = startIndex; j <= endIndex; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[j]; + if (fld.name == fldName) + { + fldOrd = j; + break; + } + } + return fldOrd; + } + + /// + /// Function to add or update the field arrays. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void SubmitFieldInArrays(string value, string oldValue, string idCol, string mr, string rowVals, string id, string oldId, string dpmValues, string dp, int index) + { + fieldValue[index] = value; + fieldOldValue[index] = value; + fldIdCol[index] = idCol; + fldMasterRow[index] = mr; + fieldRowValues[index] = rowVals; + fieldOldIdValue[index] = oldId; + fieldIdValue[index] = id; + fieldDPMVals[index] = dpmValues; + fieldDPVals[index] = dp; + //StringToFile("Replace Values - FieldName-" + fieldName[index].ToString() + " Rowno- " + fieldRowNo[index].ToString() + " Value- " + value + " Index- " + index); + } + + private void DSSubmit(string fldName, int rowNo, string value, string idValue) + { + int dcNo = tstStrObj.GetFieldDc(fldName); + if (dcNo == 0 && fldName.StartsWith(Constants.AXPISROWVALID)) + { + dcNo = Convert.ToInt32(fldName.Substring(13)); + } + if (rowNo == 0) rowNo = 1; + DataTable dt = dsDataSet.Tables["dc" + dcNo]; + DataRow foundRow = dsDataSet.Tables["dc" + dcNo].Rows.Find(rowNo); + if (foundRow == null) + { + foundRow = dt.NewRow(); + + foundRow["axp__rowno"] = Convert.ToInt32(rowNo); + foundRow["axp__delrow"] = 0; + dt.Rows.Add(foundRow); + } + if (!fldName.StartsWith("axp_recid")) + foundRow[fldName] = value; + string axp_recId = foundRow["axp_recid" + dcNo].ToString(); + foundRow["axp_recid" + dcNo] = axp_recId == "" ? "0" : axp_recId; + if (dt.Columns.Contains("id__" + fldName)) + foundRow["id__" + fldName] = idValue; + + dt.AcceptChanges(); + } + + private void DSSubmitDropDownValues(string fldName, int rowNo, string rowVals, string dpmValues, string dp, string mr, string idCol) + { + DataTable thisDataTable = dsDataSet.Tables["dsdropdown"]; + if (rowNo == 0) rowNo = 1; + DataRow thisDataRow = thisDataTable.Rows.Find(fldName + "-" + rowNo); + + if (thisDataRow == null) + { + thisDataRow = thisDataTable.NewRow(); + thisDataRow["dropdownkey"] = fldName + "-" + rowNo; + thisDataRow["fldname"] = fldName; + thisDataRow["axp__rowno"] = rowNo; + thisDataTable.Rows.Add(thisDataRow); + } + thisDataRow["rowvals"] = rowVals; + thisDataRow["dpmvalues"] = dpmValues; + thisDataRow["dp"] = dp; + thisDataRow["mr"] = mr; + thisDataRow["idcol"] = idCol; + + dsDataSet.AcceptChanges(); + } + + private void DSUpdateRowValues(string fldName, int rowNo, string rowVals, string dp, string masterRow, string idCol) + { + DataTable thisDataTable = dsDataSet.Tables["dsdropdown"]; + if (rowNo == 0) rowNo = 1; + DataRow thisDataRow = thisDataTable.Rows.Find(fldName + "-" + rowNo); + + if (thisDataRow == null) + { + thisDataRow = thisDataTable.NewRow(); + thisDataRow["dropdownkey"] = fldName + "-" + rowNo; + thisDataRow["fldname"] = fldName; + thisDataRow["axp__rowno"] = rowNo; + thisDataRow["idcol"] = idCol; + thisDataTable.Rows.Add(thisDataRow); + } + thisDataRow["rowvals"] = rowVals; + thisDataRow["dp"] = dp; + thisDataRow["mr"] = masterRow; + + dsDataSet.AcceptChanges(); + } + public DataRow DSGetDropdownRow(string fldName, string rowNo) + { + DataTable thisDataTable = dsDataSet.Tables["dsdropdown"]; + int rNo = Convert.ToInt32(rowNo); + if (rNo == 0) rNo = 1; + return thisDataTable.Rows.Find(fldName + "-" + rNo); + } + + private void DSSubmitWithOld(string fldName, int rowNo, string value, string idValue, string oldIdValue) + { + int dcNo = tstStrObj.GetFieldDc(fldName); + if (dcNo == 0) return; + if (rowNo == 0) rowNo = 1; + DataTable dt = dsDataSet.Tables["dc" + dcNo]; + DataRow foundRow = dsDataSet.Tables["dc" + dcNo].Rows.Find(rowNo); + + if (foundRow == null) + { + foundRow = dt.NewRow(); + + foundRow["axp__rowno"] = rowNo; + foundRow["axp__delrow"] = 0; + dt.Rows.Add(foundRow); + } + foundRow[fldName] = value; + + if (dt.Columns.Contains("id__" + fldName)) + foundRow["id__" + fldName] = idValue; + + dt.AcceptChanges(); + + DSSubmitOldValues(fldName, rowNo, value, idValue, oldIdValue); + } + + private void DSSubmitOldValues(string fldName, int rowNo, string value, string idValue, string oldIdValue) + { + int dcNo = tstStrObj.GetFieldDc(fldName); + if (rowNo == 0) rowNo = 1; + + DataTable dtOld = dsDataSet.Tables["dc_old" + dcNo]; + DataRow drOld = dtOld.Rows.Find(rowNo); + if (drOld == null) + { + drOld = dtOld.NewRow(); + + drOld["axp__rowno"] = rowNo; + dtOld.Rows.Add(drOld); + } + drOld["old__" + fldName] = value; + if (dtOld.Columns.Contains("oldid__" + fldName)) + drOld["oldid__" + fldName] = oldIdValue; + + dtOld.AcceptChanges(); + } + + private void DSInsertRow(int dcNo, int rowNo) + { + DataTable DCTable = dsDataSet.Tables["dc" + dcNo]; + for (int i = DCTable.Rows.Count - 1; i >= 0; i--) + { + DataRow thisrow = DCTable.Rows[i]; + int thisRowNo = Convert.ToInt32(thisrow["axp__rowno"]); + if (thisRowNo < rowNo) + break; + thisrow["axp__rowno"] = thisRowNo + 1; + } + DataRow newRow = DCTable.NewRow(); + newRow["axp__rowno"] = rowNo; + DCTable.Rows.Add(newRow); + DCTable.AcceptChanges(); + dsDataSet.AcceptChanges(); + } + + /// + /// Function to delete all the rows in the given dc from the field arrays. + /// + /// + private void DeleteAllRowsInDc(string dcNo) + { + DSDeleteAllRows(dcNo); + } + + private void DSDeleteAllRows(string dcNo) + { + int idx = AxDelDcNo.IndexOf("dc" + dcNo); + if (idx == -1) + AxDelDcNo.Add("dc" + dcNo); + + StringBuilder strDelIds = new StringBuilder(); + if (idx != -1) + strDelIds.Append(AxDelRecIds[idx].ToString()); + DataTable DCTable = dsDataSet.Tables["dc" + dcNo]; + + for (int j = DCTable.Rows.Count; j > 0; j--) + { + DataRow foundRow = DCTable.Rows.Find(j); + if (foundRow != null) + { + if (strDelIds.ToString() == string.Empty) + strDelIds.Append(foundRow["axp_recid" + dcNo].ToString()); + else + strDelIds.Append("," + foundRow["axp_recid" + dcNo].ToString()); + } + DeleteRowInFldArrays(dcNo, j.ToString()); + } + + if (idx == -1) + AxDelRecIds.Add(strDelIds.ToString()); + else + AxDelRecIds[idx] = strDelIds.ToString(); + + } + + //Set the deleted rows from GetDependents, to the global array + private void SetPopDeletedRows(string dcNo, string delRecIds) + { + int idx = AxDelDcNo.IndexOf("dc" + dcNo); + if (idx == -1) + { + AxDelDcNo.Add("dc" + dcNo); + AxDelRecIds.Add(delRecIds); + } + else + { + AxDelRecIds[idx] = delRecIds; + } + } + + public void DSDeleteRow(string dcNo, string rowNum) + { + DataTable DCTable = dsDataSet.Tables["dc" + dcNo]; + DataTable DCOldTable = dsDataSet.Tables["dc_old" + dcNo]; + + int rNo = Convert.ToInt32(rowNum); + if (rNo == 0) rNo = 1; + DataRow foundRow = DCTable.Rows.Find(rNo); + DataRow oldRow = DCOldTable.Rows.Find(rNo); + + DataTable DeletedRowsTable = dsDataSet.Tables["deldc" + dcNo]; + if (DeletedRowsTable == null) + { + DeletedRowsTable = DCTable.Clone(); + DeletedRowsTable.TableName = "deldc" + dcNo; + dsDataSet.Tables.Add(DeletedRowsTable); + } + + if (foundRow != null) + { + DeletedRowsTable.ImportRow(foundRow); + DataRow DelTableRow = DeletedRowsTable.Rows.Find(rNo); + DelTableRow["axp__delrow"] = DelTableRow["axp__rowno"]; + DelTableRow["axp__rowno"] = deletedCount--; + + //copying delete contents to xml for sending to web service. + StringBuilder strDelRowFlds = new StringBuilder(); + string axpRecidVal = "0"; + string axpNode = string.Empty; + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + for (int j = startIdx; j <= endIdx; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[j]; + if (recordid != "0") + { + if (oldRow != null) + { + if (fld.name == "axp_recid" + dcNo) + { + axpNode = "<" + fld.name + ">" + CheckSpecialChars(oldRow["old__" + fld.name].ToString()) + ""; + axpRecidVal = foundRow[fld.name].ToString(); + } + else + { + strDelRowFlds.Append("<" + fld.name + ">" + CheckSpecialChars(oldRow["old__" + fld.name].ToString()) + ""); + } + } + } + } + DelRowFldsXml.Add(axpRecidVal + "♦" + axpNode + strDelRowFlds.ToString()); + + foundRow.Delete(); + DCTable.AcceptChanges(); + DCTable.PrimaryKey = null; + DCTable = DeleteRowFalse(DCTable, DeletedRowsTable, dcNo); + int givenRow = Convert.ToInt32(rNo); + foreach (DataRow thisrow in DCTable.Rows) + { + int thisRowNo = Convert.ToInt32(thisrow["axp__rowno"]); + if (thisRowNo > givenRow) + thisrow["axp__rowno"] = thisRowNo - 1; + } + + + DCTable.PrimaryKey = new DataColumn[] { DCTable.Columns["axp__rowno"] }; + + if (oldRow != null) + { + oldRow.Delete(); + DCOldTable.AcceptChanges(); + } + + DCOldTable.PrimaryKey = null; + foreach (DataRow thisrow in DCOldTable.Rows) + { + int thisRowNo = Convert.ToInt32(thisrow["axp__rowno"]); + if (thisRowNo > givenRow) + thisrow["axp__rowno"] = thisRowNo - 1; + } + DCOldTable.PrimaryKey = new DataColumn[] { DCOldTable.Columns["axp__rowno"] }; + DSDeleteDropDown(dcNo, rowNum); + } + } + + private void deleteRowOnSave() + { + try + { + for (int i = 0; i < deletedRowCount.Count; i++) + { + string dcNumber = deletedRowCount[i].ToString().Split('♦')[1]; + string delRowNumber = (int.Parse(deletedRowCount[i].ToString().Split('♦')[0]) + 1).ToString(); + DSDeleteRow(dcNumber, delRowNumber); + } + } + catch (Exception ex) + { } + } + + private void UpdateGridDelRowVal(int dcNumner) + { + try + { + if (isDeletedRow) + { + int totRowCount = dsData.Tables["DC" + dcNumner].Rows.Count; + dsData.Tables["DC" + dcNumner].Rows[totRowCount - 1]["axp__isGrdVld" + dcNumner] = ""; + dsData.Tables["DC" + dcNumner].AcceptChanges(); + + if (deletedRowCount.Count == 0) + { + deletedRowCount.Add(totRowCount + "♦" + dcNumner); + } + else + { + string checkValue = string.Join(",", deletedRowCount.Select(x => x.ToString()).ToList()); + if (checkValue.IndexOf("♦" + dcNumner) != -1) + { + var prevValue = deletedRowCount.AsEnumerable().Where(x => x.Contains("♦" + dcNumner)).ToList(); + deletedRowCount.Remove(prevValue[0]); + deletedRowCount.Add(totRowCount + "♦" + dcNumner); + } + else + { + deletedRowCount.Add(totRowCount + "♦" + dcNumner); + } + } + } + } + catch (Exception ex) + { } + } + + private DataTable DeleteRowFalse(DataTable DCTable, DataTable DeletedRowsTable, string dcNo) + { + try + { + isDeletedRow = true; + int delRowCount = DeletedRowsTable.Rows.Count; + int OrgRows = DCTable.Rows.Count; + if (delRowCount < OrgRows) + { + for (int i = 1; i <= delRowCount; i++) + { + bool flagRemff = true; + foreach (DataColumn dc in DCTable.Columns) + { + if (dc.ColumnName == "axp__rowno") + { + break; + } + else if (DCTable.Rows[OrgRows - i][dc].ToString() != "" && DCTable.Rows[OrgRows - i][dc].ToString() != "0") + { + flagRemff = false; + } + } + if (flagRemff) + { + DCTable.Rows[OrgRows - i]["axp__isGrdVld" + dcNo] = "false"; + } + } + } + else + { + #region delete + int userValue = 0; + int ofrows = DCTable.Rows.Count; + for (int trc = 0; trc < DCTable.Rows.Count; trc++) + { + int dbValue = int.Parse(DCTable.Rows[trc]["axp__rowno"].ToString()); + if (dbValue >= userValue) + { + userValue = dbValue; + DeleteRowTopNo = trc; + } + } + bool flagRem = true; + foreach (DataColumn dc in DCTable.Columns) + { + if (dc.ColumnName.ToLower() == "axp__rowno") + { + break; + } + else if (DCTable.Rows[DeleteRowTopNo][dc].ToString() != "" && DCTable.Rows[DeleteRowTopNo][dc].ToString() != "0") + { + flagRem = false; + } + } + if (flagRem) + { + int totRowCount = DCTable.Rows.Count; + if (totRowCount != 1 && totRowCount == ofrows) + { + DCTable.Rows[totRowCount - 1]["axp__isGrdVld" + dcNo] = "false"; + DCTable.AcceptChanges(); + } + } + #endregion + } + return DCTable; + } + catch (Exception ex) + { + return DCTable; + } + } + + //Function to delete all the sub grid rows after the get dep call. + private void DeletePopRowsAfterDep() + { + //AxSubGridRows will have dcno~1,2,3 in every item + for (int i = 0; i < AxSubGridRows.Count; i++) + { + string[] dcData = AxSubGridRows[i].ToString().Split('~'); + string dcNo = dcData[0].ToString(); + int delIdx = AxDelDcNo.IndexOf("dc" + dcNo); + + //This code will add the dr attribute recids sent from the getdep, and store the deleted row information for save. + ArrayList delRecIds = new ArrayList(); + if (delIdx != -1) + { + string[] delIds = AxDelRecIds[delIdx].ToString().Split(','); + for (int ind = 0; ind < delIds.Length; ind++) + { + if (delIds[ind].ToString() != string.Empty) + delRecIds.Add(delIds[ind].ToString()); + } + } + + string[] popRows = dcData[1].ToString().Split(','); + //This loop is reversed as the array will be sorted in asc order. and while deleting it should always be in desc order. + for (int j = popRows.Length - 1; j >= 0; j--) + { + if (popRows[j] != "") + { + string rowNum = popRows[j].ToString(); + DataTable DCTable = dsDataSet.Tables["dc" + dcNo]; + DataTable DCOldTable = dsDataSet.Tables["dc_old" + dcNo]; + + int rNo = Convert.ToInt32(rowNum); + if (rNo == 0) rNo = 1; + DataRow foundRow = DCTable.Rows.Find(rNo); + DataRow oldRow = DCOldTable.Rows.Find(rNo); + + if (foundRow != null) + { + StringBuilder strDelRowFlds = new StringBuilder(); + string axpRecidVal = "0"; + string axpNode = string.Empty; + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + for (int k = startIdx; k <= endIdx; k++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[k]; + if (recordid != "0") + { + if (oldRow != null) + { + if (fld.name == "axp_recid" + dcNo) + { + axpNode = "<" + fld.name + ">" + CheckSpecialChars(oldRow["old__" + fld.name].ToString()) + ""; + axpRecidVal = foundRow[fld.name].ToString(); + } + else + { + strDelRowFlds.Append("<" + fld.name + ">" + CheckSpecialChars(oldRow["old__" + fld.name].ToString()) + ""); + } + } + } + } + if (delRecIds.IndexOf(axpRecidVal) != -1) + DelRowFldsXml.Add(axpRecidVal + "♦" + axpNode + strDelRowFlds.ToString()); + + + foundRow.Delete(); + DCTable.AcceptChanges(); + DCTable.PrimaryKey = null; + int givenRow = Convert.ToInt32(rNo); + foreach (DataRow thisrow in DCTable.Rows) + { + int thisRowNo = Convert.ToInt32(thisrow["axp__rowno"]); + if (thisRowNo > givenRow) + thisrow["axp__rowno"] = thisRowNo - 1; + } + + + + DCTable.PrimaryKey = new DataColumn[] { DCTable.Columns["axp__rowno"] }; + + if (oldRow != null) + { + oldRow.Delete(); + DCOldTable.AcceptChanges(); + } + + DCOldTable.PrimaryKey = null; + foreach (DataRow thisrow in DCOldTable.Rows) + { + int thisRowNo = Convert.ToInt32(thisrow["axp__rowno"]); + if (thisRowNo > givenRow) + thisrow["axp__rowno"] = thisRowNo - 1; + } + DCOldTable.PrimaryKey = new DataColumn[] { DCOldTable.Columns["axp__rowno"] }; + //DSDeleteDropDown(dcNo, rowNum); + } + } + + } + } + } + + private void DSDeleteDropDown(string dcNo, string rowNum) + { + DataTable dsDropDown = dsDataSet.Tables["dsdropdown"]; + if (dsDropDown == null) return; + int rNo = Convert.ToInt32(rowNum); + if (rNo == 0) rNo = 1; + + StringBuilder strDelRowFlds = new StringBuilder(); + string axpNode = string.Empty; + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + for (int j = startIdx; j <= endIdx; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[j]; + DataRow dr = dsDropDown.Rows.Find(fld.name + "-" + Convert.ToString(rNo)); + if (dr != null) + { + bool Proceed = false; + if (dr["mr"].ToString() == "0") Proceed = true; + + Proceed = Custom_CanDelRowInEsti(fld, dr["mr"].ToString(), dcNo, rowNum); + if (Proceed) + { + dr.Delete(); + dsDropDown.AcceptChanges(); + foreach (DataRow drRow in dsDropDown.Rows) + { + int rowNo = Convert.ToInt32(drRow["axp__rowno"]); + if (rowNo > rNo && fld.name == drRow["fldname"].ToString()) + { + drRow["axp__rowno"] = rowNo - 1; + drRow["dropdownkey"] = fld.name + "-" + Convert.ToString(rowNo - 1); + } + } + } + } + } + dsDropDown.AcceptChanges(); + } + + private bool Custom_CanDelRowInEsti(TStructDef.FieldStruct fld, string mr, string dcNo, string rowNum) + { + bool Proceed = false; + if (fld.name == "role") mr = "1"; + if (fld.name == "activity") + { + Proceed = true; + } + if (mr == "0") Proceed = true; + return Proceed; + + + } + + /// + /// Function to delete all the fields in the given row and dc from the field arrays. + /// + /// + /// + private void DeleteRowInFldArrays(string frameNo, string rowNum) + { + DSDeleteRow(frameNo, rowNum); + } + + /// + /// Function to get the index of the given row and dc from the fieldindexarray. + /// + /// + /// + /// + private int GetRowIndex(int dcNo, int rowNo) + { + int idx = 0; + if (rowNo == 0) rowNo = 1; + foreach (TStructDef.DcStruct dc in tstStrObj.dcs) + { + if (dc.frameno >= dcNo) + break; + + idx += GetDcRowCount(dc.frameno.ToString()) * dc.fieldCount; + } + + TStructDef.DcStruct currentDC = (TStructDef.DcStruct)tstStrObj.dcs[dcNo - 1]; + //Formula = idx + FieldCountInDC * (RowNo-1) + (FieldOrder - StartOrderInDC) + idx += currentDC.fieldCount * (rowNo - 1); + return idx; + } + + + private void RefInMemOnSave() + { + try + { + if (tstStrObj.axp_inmemTids != String.Empty && (HttpContext.Current.Session["RapidTsTruct"] != null && HttpContext.Current.Session["RapidTsTruct"].ToString() == "true") && (HttpContext.Current.Session["AxIsPerfCode"] != null && HttpContext.Current.Session["AxIsPerfCode"].ToString().ToLower() == "true")) + { + string[] inMemTids = tstStrObj.axp_inmemTids.Split(','); + + FDR fdrObj; + if (HttpContext.Current.Session["FDR"] != null) + fdrObj = (FDR)HttpContext.Current.Session["FDR"]; + else + fdrObj = new FDR(); + + FDW fdwObj = FDW.Instance; + foreach (string Tid in inMemTids) + { + ArrayList arrKeys = fdrObj.GetPrefixedKeys(project + "-" + Tid + "-"); + foreach (string key in arrKeys) + { + fdwObj.ClearRedisServerDataByKey(key, String.Empty, true); + } + } + + } + } + catch (Exception Ex) + { + + } + } + + #endregion + + #region Json creation Functions + + /// + /// Function to create json from the data arrays in the stored draft. + /// + /// + public string CreateJsonForDraft() + { + StringBuilder draftJson = new StringBuilder(); + StringBuilder dcJson = new StringBuilder(); + draftJson.Append("{\"data\":["); + string tmpStr = string.Empty; + + //loop for constructing the field value xml based on the frame no, row no and field order + foreach (TStructDef.DcStruct dc in tstStrObj.dcs) + { + string dcNo = Convert.ToString(dc.frameno); + + DataTable thisDataTable = dsDataSet.Tables["dc" + dcNo]; + if (dc.isgrid) + { + errlog = logobj.CreateLog("CreateJsonForDraft", sessionid, "CreateJson-tstData", "new"); + try + { + DataRow[] rows; + rows = thisDataTable.Select("axp__isGrdVld" + dcNo + " = 'false'"); // axp__isGrdVld is Column Name + foreach (DataRow r in rows) + thisDataTable.Rows.Remove(r); + } + catch (Exception ex) + { + errlog = logobj.CreateLog(ex.Message + ex.StackTrace, sessionid, "CreateJson-tstData", ""); + } + } + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + + int rowCnt = 0; + string cr = string.Empty; + if (dc.isgrid) + { + rowCnt = thisDataTable.Rows.Count; + cr = GetCrAttrJson(rowCnt); + } + tmpStr = "{\"n\":\"DC" + dcNo + "\",\"v\":\"" + rowCnt + "\", " + cr + " \"t\":\"dc\", \"hasdatarows\":\"" + (rowCnt > 0 && !string.IsNullOrEmpty(cr) ? "yes" : "no") + "\"}"; + //construct dc json tag + //{"n":"DC1","v":"1","t":"dc"} + if (dcJson.ToString() == string.Empty) + dcJson.Append(tmpStr); + else + dcJson.Append("," + tmpStr); + + foreach (DataRow dr in thisDataTable.Rows) + { + int rowNo = Convert.ToInt32(dr["axp__rowno"]); + for (int j = startIdx; j <= endIdx; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[j]; + dcJson.Append("," + GetFieldJson(rowNo.ToString(), dr, fld, thisDataTable)); + } + } + //close here + } + draftJson.Append(dcJson + "]}"); + + return draftJson.ToString(); + } + + public string GetCurrTabStatus(string dcNo) + { + //DC1-1,DC2-2 + string isTabOpened = "no"; + dcNo = "DC" + dcNo; + if (!string.IsNullOrEmpty(TabDcStatus)) + { + string[] dcAndStatusArray = TabDcStatus.Split(','); + foreach (string dcAndStatus in dcAndStatusArray) + { + string[] status = dcAndStatus.Split('-'); + if (status[0].ToLower() == dcNo.ToLower()) + { + if (status[1] == "1") + isTabOpened = "yes"; + break; + } + } + } + return isTabOpened; + } + + public string GetTabDCJson(string dcNo) + { + StringBuilder draftJson = new StringBuilder(); + StringBuilder dcJson = new StringBuilder(); + draftJson.Append("{\"data\":["); + string tmpStr = string.Empty; + bool isGrid = ((TStructDef.DcStruct)tstStrObj.dcs[int.Parse(dcNo) - 1]).isgrid; + DataTable thisDataTable = dsDataSet.Tables["dc" + dcNo]; + if (isGrid) + { + errlog = logobj.CreateLog("CreateJsonForDraft-GetTabDCJson", sessionid, "GetTabDCJson-tstData", "new"); + try + { + DataRow[] rows; + rows = thisDataTable.Select("axp__isGrdVld" + dcNo + " = 'false'"); // axp__isGrdVld is Column Name + foreach (DataRow r in rows) + thisDataTable.Rows.Remove(r); + } + catch (Exception ex) + { + errlog = logobj.CreateLog(ex.Message + ex.StackTrace, sessionid, "GetTabDCJson-tstData", ""); + } + } + + string[] dcRange = tstStrObj.GetDcFieldRange(dcNo).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + int rowCnt = 0; + string cr = string.Empty; + if (isGrid) + { + rowCnt = thisDataTable.Rows.Count; + cr = GetCrAttrJson(rowCnt); + } + + tmpStr = "{\"n\":\"DC" + dcNo + "\",\"v\":\"" + rowCnt + "\", " + cr + " \"t\":\"dc\", \"hasdatarows\":\"" + (rowCnt > 0 && !string.IsNullOrEmpty(cr) ? "yes" : "no") + "\"}"; + + if (dcJson.ToString() == string.Empty) + dcJson.Append(tmpStr); + else + dcJson.Append("," + tmpStr); + + + foreach (DataRow dr in thisDataTable.Rows) + { + int rowNo = Convert.ToInt32(dr["axp__rowno"]); + for (int j = startIdx; j <= endIdx; j++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[j]; + dcJson.Append("," + GetFieldJson(rowNo.ToString(), dr, fld, thisDataTable)); + } + } + + draftJson.Append(dcJson + "]}"); + return draftJson.ToString(); + } + + + /// + /// Function to get the cr attribute for the dc based on the rowcount. + /// + /// + /// + private string GetCrAttrJson(int rowCnt) + { + StringBuilder strCr = new StringBuilder(); + for (int i = 1; i <= rowCnt; i++) + { + if (i == 1) + { + strCr.Append("\"cr\":"); + strCr.Append("\"i" + i); + } + else + strCr.Append(",i" + i); + } + if (strCr.ToString() != string.Empty) + strCr.Append("\","); + return strCr.ToString(); + } + + /// + /// Function to get the field json based on its type. + /// + /// + /// + /// + /// + /// + private string GetFieldJson(string rowNo, DataRow dr, TStructDef.FieldStruct fld, DataTable dt) + { + string fieldName = fld.name; + string type = string.Empty; + string value = string.Empty; + string idVal = string.Empty; + string oldIdVal = string.Empty; + string mr = string.Empty; + string idCol = string.Empty; + string fldJson = string.Empty; + string strId = string.Empty; + string strComboValues = string.Empty; + string dpm = string.Empty; + + DataRow dsDataRow = DSGetDropdownRow(fieldName, rowNo); + + string fldRowVals = string.Empty; + string dpVals = string.Empty; + if (dsDataRow != null) + { + fldRowVals = dsDataRow["rowvals"].ToString(); + dpVals = dsDataRow["dp"].ToString(); + idCol = dsDataRow["idcol"].ToString(); + mr = dsDataRow["mr"].ToString(); + dpm = dsDataRow["dpmvalues"].ToString(); + } + + type = GetFieldType(fld); + value = dr[fld.name].ToString(); + if (dt.Columns.Contains("id__" + fieldName)) + idVal = dr["id__" + fld.name].ToString(); + + + if (dt.Columns.Contains("oldid__" + fld.name)) + oldIdVal = dr["oldid__" + fld.name].ToString(); + + + if (rowNo == "1" && mr == "1" && AxMasterRowFlds.IndexOf(fieldName) == -1) + AxMasterRowFlds.Add(fieldName); + + if (rowNo != "1" && AxMasterRowFlds.IndexOf(fieldName) != -1) + mr = "1"; + + if (mr != "1" && fld.fieldIsFrmList) + mr = "1"; + + if (mr != string.Empty) + mr = "\"mr\":\"" + mr + "\","; + + if (idCol != string.Empty) + { + if (idCol == "0") idCol = "no"; + else idCol = "yes"; + idCol = "\"idcol\":\"" + idCol + "\","; + if (type == "s") + idCol = string.Empty; + } + + if (type == "m") + value = value.Replace("\n", "
    "); + + value = CheckSpecialCharsForClient(value); + + strId = "\"id\":\"" + idVal + "\", \"oldid\":\"" + oldIdVal + "\","; + + if (dpm != string.Empty) + dpm = "\"dpm\":\"" + dpm + "\","; + + if (type == "c") + strComboValues = GetComboItemsJson(fldRowVals, dpVals); + + //This is a dummy json example for dropdown + //{"n":"sponsor","v":"abc","r":"0","idcol":"yes","id":"10032000001017","oldid":"0","mr":"0","dpm":"suffix,title","t":"c"}, + if (fld.savenormal) + fldJson = "{\"n\":\"" + fld.name + "\",\"v\":\"" + value + "\",\"r\":\"" + rowNo + "\"," + idCol + mr + strId + dpm + " \"t\":\"" + type + "\"}"; + else + fldJson = "{\"n\":\"" + fld.name + "\",\"v\":\"" + value + "\",\"r\":\"" + rowNo + "\"," + idCol + mr + dpm + "\"t\":\"" + type + "\"}"; + + if (strComboValues != string.Empty) + fldJson = fldJson + "," + strComboValues; + return fldJson; + } + + /// + /// Function to get the json for the dv nodes for a given combo box. + /// + /// + /// + private string GetComboItemsJson(string fldRowValues, string fldDpValues) + { + StringBuilder strItems = new StringBuilder(); + //sample json for dropdown item + //{"v":"15146000000000~EST-000274-Rev1","t":"dv","dp":"EST-000274~1~001~001~002"}, + string[] choices = fldRowValues.Split('♣'); + string[] dpValues = fldDpValues.Split('♣'); + string tmpStr = string.Empty; + for (int i = 0; i < choices.Length; i++) + { + string strChoice = choices[i].ToString(); + strChoice = CheckSpecialCharsForClient(strChoice); + if (strChoice != "" && i <= dpValues.Length) + { + tmpStr = "{\"v\":\"" + strChoice + "\", \"t\":\"dv\", \"dp\":\"" + dpValues[i].ToString() + "\"}"; + if (strItems.ToString() == string.Empty) + strItems.Append(tmpStr); + else + strItems.Append("," + tmpStr); + } + } + return strItems.ToString(); + } + + private string CheckSpecialCharsForClient(string value) + { + //single quote is handled in the tstruct.aspx.cs file before renddering the json to client. + //Hence handling only double quote and backward slash. + //fValue = fValue.Replace("^^dq", "\""); + //fValue = fValue.Replace(";bkslh", "\\"); + value = value.Replace("\"", "^^dq"); + value = value.Replace("\\", ";bkslh"); + return value; + } + + + /// + /// Function to get the field type of the given field and return the type attribute 't' in the json. + /// + /// + /// + private string GetFieldType(TStructDef.FieldStruct fld) + { + string type = string.Empty; + type = fld.ctype.ToUpper(); + string moe = string.Empty; + + if (fld.moe.ToLower() == "select") + { + if (fld.editcombo) + return "s"; + else + return "c"; + } + else + { + switch (type) + { + case "CHECK LIST": + return "cl"; + case "MEMO": + return "m"; + case "IMAGE": + return "i"; + case "CHECK BOX": + return "s"; + default: + if (type.IndexOf("AXPBUTTON") != -1) + return "b"; + else + return "s"; + + } + } + } + + #endregion + + public string GetFieldSqlQuery(string fldName, string fldValues, string globalVar, string userVars, int activeRow, string parentFlds) + { + int fldidx = tstStrObj.GetFieldIndex(fldName); + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)tstStrObj.flds[fldidx]; + string sqlQuery = fld.fieldSqlQuery; + string sqlParamsXML = string.Empty, appVarTypes = string.Empty, parentFldVals = string.Empty; + try + { + sqlQuery = "" + CheckSpecialChars(sqlQuery) + ""; + fldValues = "" + fldValues + ""; + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(fldValues); + sqlParamsXML += ""; + // in cluase paramets for grid field {invioceno*} for non grid field {invioceno} + if (Regex.Match(sqlQuery.ToLower(), @"{\b\w+\b}", RegexOptions.IgnoreCase).Success || Regex.Match(sqlQuery.ToLower(), @"{\b\w+\b\*}", RegexOptions.IgnoreCase).Success) + { + MatchCollection matchListSt = Regex.Matches(sqlQuery, @"{\b\w+\b\*}"); + var listSt = matchListSt.Cast().Select(match => match.Value).Distinct().ToList(); + MatchCollection matchList = Regex.Matches(sqlQuery, @"{\b\w+\b}"); + var list = matchList.Cast().Select(match => match.Value).Distinct().ToList(); + if (listSt.Count > 0) + { + foreach (var lst in listSt) + { + string strFld = lst.Split('{')[1].Split('*')[0]; + XmlNodeList slctNode = xmlDoc.SelectNodes("fldXML/" + strFld + ""); + int ic = 0; + string stFldValue = string.Empty; + foreach (XmlElement strText in slctNode) + { + if (strText.InnerText != "") + stFldValue += strText.InnerText + "~"; + if (ic == 0) + { + int fldidxs = tstStrObj.GetFieldIndex(strFld); + TStructDef.FieldStruct flds = (TStructDef.FieldStruct)tstStrObj.flds[fldidxs]; + if (flds.datatype == "Character" || flds.datatype == "Text") + appVarTypes += "c"; + else if (flds.datatype == "Numeric") + appVarTypes += "n"; + else if (flds.datatype == "Date/Time") + appVarTypes += "d"; + } + ic++; + } + if (stFldValue != string.Empty) + stFldValue = stFldValue.Remove(stFldValue.Length - 1); + sqlParamsXML += "<" + strFld + ">" + stFldValue + ""; + parentFldVals += strFld + ":" + stFldValue + "~"; + } + } + if (list.Count > 0) + { + foreach (var lst in list) + { + string strFld = lst.Split('{')[1].Split('}')[0]; + sqlParamsXML += xmlDoc.SelectSingleNode("fldXML/" + strFld + "").OuterXml; + parentFldVals += strFld + ":" + xmlDoc.SelectSingleNode("fldXML/" + strFld + "").InnerXml + "~"; + int fldidxs = tstStrObj.GetFieldIndex(strFld); + TStructDef.FieldStruct flds = (TStructDef.FieldStruct)tstStrObj.flds[fldidxs]; + if (flds.datatype == "Character" || flds.datatype == "Text") + appVarTypes += "c"; + else if (flds.datatype == "Numeric") + appVarTypes += "n"; + else if (flds.datatype == "Date/Time") + appVarTypes += "d"; + } + } + } + if (sqlQuery.Contains(":"))// to check any of tstruct fields & global Vars + { + if (Regex.Match(sqlQuery, String.Format(@":\b{0}\b", "recordid"), RegexOptions.IgnoreCase).Success) + { + if (xmlDoc.InnerText != "") + { + //sqlParamsXML += xmlDoc.SelectSingleNode("fldXML/axp_recid1").OuterXml; + string StrRecId = xmlDoc.SelectSingleNode("fldXML/axp_recid1").OuterXml; + StrRecId = StrRecId.Replace("axp_recid1", "recordid"); + sqlParamsXML += StrRecId; + parentFldVals += "recordid:" + xmlDoc.SelectSingleNode("fldXML/axp_recid1").InnerXml + "~"; + } + else + { + sqlParamsXML += "recordid"; + parentFldVals += "recordid:0~"; + } + int fldidxs = tstStrObj.GetFieldIndex("axp_recid1"); + TStructDef.FieldStruct flds = (TStructDef.FieldStruct)tstStrObj.flds[fldidxs]; + if (flds.datatype == "Character" || flds.datatype == "Text") + appVarTypes += "c"; + else if (flds.datatype == "Numeric") + appVarTypes += "n"; + else if (flds.datatype == "Date/Time") + appVarTypes += "d"; + } + foreach (XmlNode parms in xmlDoc.ChildNodes[0].ChildNodes) + { + if (Regex.Match(sqlQuery, String.Format(@":\b{0}\b", parms.Name.ToString()), RegexOptions.IgnoreCase).Success) + { + int fldidxs = tstStrObj.GetFieldIndex(parms.Name); + TStructDef.FieldStruct flds = (TStructDef.FieldStruct)tstStrObj.flds[fldidxs]; + bool isDcGrid = false; + isDcGrid = IsDcGrid(flds.fldframeno.ToString(), tstStrObj); + if (isDcGrid == true && int.Parse(parms.Attributes["rowno"].Value) == activeRow) + { + sqlParamsXML += parms.OuterXml; + parentFldVals += parms.Name + ":" + parms.InnerXml + "~"; + if (flds.datatype == "Character" || flds.datatype == "Text") + appVarTypes += "c"; + else if (flds.datatype == "Numeric") + appVarTypes += "n"; + else if (flds.datatype == "Date/Time") + appVarTypes += "d"; + } + else if (isDcGrid == false) + { + sqlParamsXML += parms.OuterXml; + parentFldVals += parms.Name + ":" + parms.InnerXml + "~"; + if (flds.datatype == "Character" || flds.datatype == "Text") + appVarTypes += "c"; + else if (flds.datatype == "Numeric") + appVarTypes += "n"; + else if (flds.datatype == "Date/Time") + appVarTypes += "d"; + } + } + } + XmlDocument xmlDocgbl = new XmlDocument(); + xmlDocgbl.LoadXml(globalVar); + string blgAppVar = string.Empty; + if (xmlDocgbl.SelectSingleNode("globalvars/appvartypes") != null) + blgAppVar = xmlDocgbl.SelectSingleNode("globalvars/appvartypes").InnerXml; + int gblIcnt = 1; + foreach (XmlNode parms in xmlDocgbl.ChildNodes[0].ChildNodes) + { + if (Regex.Match(sqlQuery, String.Format(@":\b{0}\b", parms.Name.ToString()), RegexOptions.IgnoreCase).Success && parms.Name != "appvartypes" && !Regex.Match(sqlParamsXML, System.String.Format(@"<\b{0}\b", parms.Name.ToString()), RegexOptions.IgnoreCase).Success) + { + sqlParamsXML += parms.OuterXml; + parentFldVals += parms.Name + ":" + parms.InnerXml + "~"; + if (blgAppVar.Length >= gblIcnt) + appVarTypes += blgAppVar[gblIcnt - 1].ToString(); + else if (blgAppVar.Length < gblIcnt) + appVarTypes += "c"; + } + gblIcnt++; + } + + XmlDocument xmlDocUv = new XmlDocument(); + xmlDocUv.LoadXml(userVars); + foreach (XmlNode parms in xmlDocUv.ChildNodes[0].ChildNodes) + { + if (Regex.Match(sqlQuery, String.Format(@":\b{0}\b", parms.Name.ToString()), RegexOptions.IgnoreCase).Success) + { + sqlParamsXML += parms.OuterXml; + parentFldVals += parms.Name + ":" + parms.InnerXml + "~"; + appVarTypes += "c"; + } + } + } + if (sqlParamsXML != "") + sqlParamsXML += "" + appVarTypes + ""; + sqlParamsXML += ""; + if (activeRow == 0) + { + string SessAutKey = "autocomplete♦" + transid + "-" + fldName + "-" + parentFlds; + HttpContext.Current.Session[SessAutKey] = sqlQuery + sqlParamsXML + "♠" + parentFldVals; + } + } + catch (Exception ex) + { + } + return sqlQuery + sqlParamsXML + "♠" + parentFldVals; + } +} +#endregion diff --git a/AW_11.2.0.0_release1/App_Code/TStructDef.cs b/AW_11.2.0.0_release1/App_Code/TStructDef.cs new file mode 100644 index 0000000..098d89e --- /dev/null +++ b/AW_11.2.0.0_release1/App_Code/TStructDef.cs @@ -0,0 +1,13158 @@ +#region NameSpaces +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI.WebControls; +using System.Collections; +using System.Xml; +using System.Text; +using System.IO; +using System.Data; +using System.Linq; +using System.Configuration; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System.Net; +//using RestSharp; + +#endregion + +#region TstructDef Class +/// +/// TStructDef class contains complete TStruct related Data. This also has method to +/// create the page HTML. The HTML can be generated in DC level. The necessary Javascript +/// arrays are created and passed on the client for client side validation and expression +/// processing. +/// +/// +/// +// TODO: Dc, Js -> DC, JS +[Serializable()] +public class TStructDef +{ + # region attributes + // attributes of the tstruct + public enum moe + { + ACCEPT, + SELECT, + FILL + }; + + public string EnableOldTheme = "false"; + public string transId = string.Empty; + public string tstCaption = string.Empty; + public string tstPform = string.Empty; + public string tstWorkflow = string.Empty; + //public string tstRuntimeModification = "F"; + //public string fldRuntimeCriteria = "F"; + public string tstUpdateOn = string.Empty; + public string tstUpdateBy = string.Empty; + public string tstReadOnly = string.Empty; + public string tstCancelled = string.Empty; + public string tstPdf = string.Empty; + public string tstVersion = string.Empty; + public string tstAttachment = string.Empty; + public string tstIviewButton = string.Empty; + public Boolean tstHyperLink = false; + public string tstLayout = string.Empty; + public string hlpText = string.Empty; + public string pdfList = string.Empty; + public bool wsPerfFormLoadCall = true; + public string wsPerfEvalExpClient = string.Empty; + public string[] wsPerfFGDcName; + public string[] wsPerfLDcName; + public string wsPerfFields = string.Empty; + public bool wsPerfEnabled = false; + public ArrayList wsPerfGRDDcs = new ArrayList(); + public string axdesignJson = string.Empty; + public DesignObject axdesignJObject = new DesignObject(); + public bool isFreshDesign = false; + int fieldIndex = 0; + public bool dwbToolbar = false; + + // List with structure + public ArrayList dcs = new ArrayList(); + public ArrayList popdcs = new ArrayList(); + public ArrayList flds = new ArrayList(); + public ArrayList btns = new ArrayList(); + public ArrayList taskBtns = new ArrayList(); + public ArrayList fgs = new ArrayList(); + public ArrayList hlnks = new ArrayList(); + public ArrayList actions = new ArrayList(); + public ArrayList customBtns = new ArrayList(); + //public StringBuilder customBtns = new StringBuilder(); + + // List without structure + public ArrayList searchDataNames = new ArrayList(); + public ArrayList searchDataCaptions = new ArrayList(); + public ArrayList customLabels = new ArrayList(); + public ArrayList customLblDcNo = new ArrayList(); + public ArrayList pageActionButtons = new ArrayList(); + public ArrayList pageActionDcNo = new ArrayList(); + public ArrayList dcTable = new ArrayList(); + + public ArrayList gridScriptButtons = new ArrayList(); + public ArrayList gridScriptDcNo = new ArrayList(); + public ArrayList gridHeaderScriptButtons = new ArrayList(); + public ArrayList gridHeaderScriptDcNo = new ArrayList(); + + //holds the dc's according to the page positioning + public ArrayList pagePositions = new ArrayList(); + public ArrayList visibleDCs = new ArrayList(); + public ArrayList tabDCs = new ArrayList(50); + public ArrayList tabDCStatus = new ArrayList(50); + + // javascript array attributes + public string jsFormcontrolArray = string.Empty; + public string jsHyperlinkArray = string.Empty; + public StringBuilder tabScript = new StringBuilder(); + public StringBuilder jsPatternArray = new StringBuilder(); + public StringBuilder jsFieldArray = new StringBuilder(); + public StringBuilder jsDCArray = new StringBuilder(); + public StringBuilder jsTabDCArray = new StringBuilder(); + public StringBuilder jsExpressionArray = new StringBuilder(); + public StringBuilder gridHeadHtml = new StringBuilder(); + public StringBuilder dummyGridHeadHtml = new StringBuilder(); + public StringBuilder gridHiddenHtml = new StringBuilder(); + public StringBuilder customLabelHtml = new StringBuilder(); + public StringBuilder btnHtml = new StringBuilder(); + public StringBuilder dcOtherRows = new StringBuilder(); + //public StringBuilder headerHtml = new StringBuilder(); + public Boolean IsObjFromCache = false; + public Boolean IsObjCustomHtml = false; + public ArrayList fldDcRange = new ArrayList(); + public int colCount = 0; + //this is old ifdesignmode flag.. do not change + public Boolean IsDesignMode = false; + + //Dependency arrays + public ArrayList childArray = new ArrayList(); + public ArrayList parentArray = new ArrayList(); + public ArrayList dependentsArray = new ArrayList(); + + public ArrayList subTotColValues = new ArrayList(); + private int fgCount = 0; + public string srchCols = string.Empty; + public string grpActBtns = string.Empty; + public string refreshSelect = string.Empty; + public string htmlToPDF = string.Empty; + //Fastdata variables + public string fastDataFlds = string.Empty; + public string fastDataDynamicFlds = string.Empty; + public string fastDataActiveFlds = string.Empty; + public ArrayList fastDataRefDSName = new ArrayList(); + public ArrayList fastDataRefEvent = new ArrayList(); + public DataSet dsFastDataDef = new DataSet(); + public List lstGlobalParams = new List(); + + public bool isFastFormLoad = false; + //public string formLoadCache = String.Empty; + public bool isWizardTstruct = false; + public bool hideToolBar = false; + + //Variables for Rapid performance changes- EPI + public DataTable dt_RapidFormControl = new DataTable(); + public DataTable dt_RapidDependents = new DataTable(); + public DataTable dt_RapidDependentsTemp = new DataTable(); + public bool rapidIsClientFormLoad = false; + public bool rapidDoFormLoad = true; + public string rapidFormLoadExpFlds = string.Empty; + public List rapidFLExpFlds = new List(); + public string rapidFormLoadJSON = string.Empty; + public string rapidGlobalParams = string.Empty; + public string rapidFormLoadActionXML = string.Empty; + + public string fromListFlds = string.Empty; + public ArrayList AxImageFields = new ArrayList(); + public ArrayList AxAttachFields = new ArrayList(); + public ArrayList AxpFileUploadFields = new ArrayList(); + Util.Util utilObj = new Util.Util(); + public Dictionary AxRowLimit = new Dictionary(); + public string FormLoadGlobalVarNode = string.Empty; + + // Global variables + [NonSerialized] + System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); + int exprNo = 0; + int fldNo = 0; + int DCNo = 0; + int popDCNo = 0; + int grfldNo = 0; + int patternNo = 0; + int lastDcHeight = 0; + int dcArrayNo = 0; + int gridDcColwidth = 0; + int maxDcHeight = 0; + int dcNo = 0; + int DcCnt = 0; + string dcRange = ""; + int fldGlobal = 0; + int dcFldCount = 0; + int dcFldVisibleCount = 0; + string defaultDateStr = "dd/mm/yyyy"; + string defaultTimeStr = "HH:MM"; + string defaultColWidth = "50"; + string res = string.Empty; + //If this property comes in Grid DC from xml, showZeroForNumeric variable should be updated. + Boolean showZeroForNumeric = true; + Boolean isFillGridCall = false; + public Boolean isAxpImagePath = false; + public Boolean ContainsImage = false; + public Boolean ContainsGridAttach = false; + public Boolean ContainsGridRefer = false; + string tabFunction = string.Empty; + public string browser = string.Empty; + string fldCss = string.Empty; + string fldHdnCss = string.Empty; + string ActiveKeyColValue = string.Empty; + public int docHeight = 0; + public int left = 0; + public int top = 0; + Custom cust = Custom.Instance; //murali + bool flgEnblPurpose = true; + + public string isPerfCode = "false"; + public bool AlwaysServer = true; + public string axp_inmemTids = string.Empty; + public string axp_inmemKeys = string.Empty; + + //DesignMode IDs + public string save_id = string.Empty; + public string Publish_id = string.Empty; + public string Is_Publish = "N"; + public string dcPlistaddrow = string.Empty; + Boolean IsPublish = false; + bool isMobile = false; + public ArrayList fldSetCarry = new ArrayList(); + public ArrayList fldAcceptFromApi = new ArrayList(); + private int webServiceTimeout = 100000; + public int WebServiceTimeout + { + get { return webServiceTimeout > 0 ? webServiceTimeout : 100000; } + set { webServiceTimeout = value; } + } + #endregion + + #region Constructor + + /// + /// Constructor which has the xml data. + /// + /// + public TStructDef(string xml, DataTable customDS, DataSet dsRapidDef) + { + if (HttpContext.Current.Session != null) + EnableOldTheme = HttpContext.Current.Session["AxEnableOldTheme"].ToString().ToLower(); + + if (HttpContext.Current.Session["AxImagePath"] != null && HttpContext.Current.Session["AxImagePath"].ToString() != "") + isAxpImagePath = true; + + if (HttpContext.Current.Session["ClientLocale"] != null && HttpContext.Current.Session["ClientLocale"].ToString() == "en-us") + defaultDateStr = "mm/dd/yyyy"; + if (HttpContext.Current.Session["MobileView"] != null && HttpContext.Current.Session["MobileView"].ToString().ToLower() == "true") + isMobile = true; + + ParseSearchAndGroups(customDS); + this.structRes = xml; + this.Create(xml); + if (!string.IsNullOrEmpty(tstVersion) && Int64.Parse(tstVersion) > 10000) + { + if (dsRapidDef != null && dsRapidDef.Tables.Count > 1) + { + ParseRapidDef(dsRapidDef); + SetRapidExpFlds(); + } + } + + if (HttpContext.Current.Session["AxIsPerfCode"] != null && !utilObj.IsNullOrEmpty(HttpContext.Current.Session["AxIsPerfCode"].ToString())) + isPerfCode = HttpContext.Current.Session["AxIsPerfCode"].ToString(); + } + + private void ParseRapidDef(DataSet dsRapidDef) + { + try + { + dt_RapidFormControl = dsRapidDef.Tables[0]; + dt_RapidDependents = dsRapidDef.Tables[1]; + dt_RapidDependentsTemp = dt_RapidDependents.Clone(); + SetRapidFormLoadProps(); + } + catch (Exception ex) + { + LogFile.Log logObj = new LogFile.Log(); + logObj.CreateLog("Exception in ParseRapidDef-" + ex.Message, HttpContext.Current.Session["nsessionid"].ToString(), "Exc-ParseRapidDef", "new"); + } + } + + + + /// + /// Function to get the Dependents, and their type from axp_Dependents table + /// + /// + /// + /*private FieldStruct SetRapidDependents(FieldStruct fld) + { + try + { + if (dt_RapidDependents != null && dt_RapidDependents.Rows.Count > 0) + { + var strDeps = dt_RapidDependents.AsEnumerable().Where(x => x.Field("parentfield") == fld.name).OrderBy(x => x.Field("frmno")).ThenBy(x => x.Field("ordno")) + .Select(x => new { dependentFld = x.Field("dependenttype") + x.Field("childfield"), allRows = x.Field("allrows") }).Distinct().ToList(); + + fld.FldRapidDeps = string.Join(",", strDeps.Select(x => x.dependentFld).ToArray()); + + var strExpDeps = dt_RapidDependents.AsEnumerable().Where(x => x.Field("parentfield") == fld.name && x.Field("dependenttype") == "e").OrderBy(x => x.Field("frmno")).Select(x => x.Field("dependenttype") + x.Field("childfield")).Distinct().ToList(); + fld.FldRapidExpDeps = string.Join(",", strExpDeps.Select(x => x.ToString()).ToArray()); + var strParents = dt_RapidDependents.AsEnumerable().Where(x => x.Field("parentfield") == fld.name && x.Field("dirparam") == "T") + .Select(x => new { parent = x.Field("paramname"), allRows = x.Field("allrows") }).Distinct().ToList(); + + fld.FldRapidParents = string.Join(",", strParents.Select(x => x.parent).ToArray()); + fld.FldRapidAllRows = string.Join(",", strParents.Select(x => x.allRows).ToArray()); + //Loop through dependents and their parents + List strParFlds = new List(); + strParFlds.AddRange(strParents.Select(x => x.parent).ToList()); + for (int i = 0; i < strDeps.Count; i++) + { + var strAllPars = dt_RapidDependents.AsEnumerable().Where(x => x.Field("parentfield") == strDeps[i].dependentFld.Substring(1)) + .Select(x => x.Field("paramname")).Distinct().ToList(); + strParFlds.AddRange(strAllPars.Select(x => x.ToString()).ToList()); + } + + strParFlds = strParFlds.Distinct().ToList(); + //Loop through the parents and their parents + List strParParFlds = new List(); + for (int j = 0; j < strParFlds.Count; j++) + { + var strAllPars = dt_RapidDependents.AsEnumerable().Where(x => x.Field("parentfield") == strParFlds[j].ToString() + && !string.IsNullOrEmpty(x.Field("paramname"))).OrderBy(x => x.Field("frmno")) + .Select(x => x.Field("paramname")).Distinct().ToList(); + strParParFlds.AddRange(strAllPars.Select(x => x.ToString()).ToList()); + //strParParFlds.AddRange(strAllPars.Select(x => tranform(x)).Where(y => y != null).ToString().ToList(); + } + + List fldAllParents = new List(); + fldAllParents.AddRange(strParFlds); + fldAllParents.AddRange(strParParFlds.Distinct().ToList()); + fldAllParents = fldAllParents.Distinct().ToList(); + + fld.FldRapidAllParents = string.Join(",", fldAllParents.Select(x => x.ToString()).Distinct().ToArray()); + + //var strAllParents = dt_RapidDependents.AsEnumerable().Where(x => x.Field("parentfield") == fld.name) + // .Select(x => new { parent = x.Field("paramname"), allRows = x.Field("allrows") }).Distinct().ToList(); + //fld.FldRapidAllParents = string.Join(",", strAllParents.Select(x => x.parent).ToArray()); + + if (fld.FldRapidDeps == fld.FldRapidExpDeps) + fld.FldRapidDepType = "c"; + else + fld.FldRapidDepType = "w"; + } + } + catch (Exception ex) + { + LogFile.Log logObj = new LogFile.Log(); + logObj.CreateLog("Exception in SetRapidDependents-" + ex.Message, HttpContext.Current.Session["nsessionid"].ToString(), "Exc-SetRapidDep", "new"); + } + + return fld; + }*/ + + private FieldStruct SetRapidDependents(FieldStruct fld) + { + try + { + if (dt_RapidDependents != null && dt_RapidDependents.Rows.Count > 0) + { + dt_RapidDependentsTemp.Clear(); + if (dt_RapidDependents.Select("parentfield ='" + fld.name + "'").Length > 0) + dt_RapidDependentsTemp = dt_RapidDependents.Select("parentfield ='" + fld.name + "'").CopyToDataTable(); + + if (dt_RapidDependentsTemp.Rows.Count > 0) + { + var strDeps = dt_RapidDependentsTemp.AsEnumerable().Select(x => new { dependentFld = x.Field("dependenttype") + x.Field("childfield"), allRows = x.Field("allrows") }).Distinct().ToList(); + fld.FldRapidDeps = string.Join(",", strDeps.Select(x => x.dependentFld).ToArray()); + + var strExpDeps = dt_RapidDependentsTemp.AsEnumerable().Where(x => x.Field("dependenttype") == "e").Select(x => x.Field("dependenttype") + x.Field("childfield")).Distinct().ToList(); + fld.FldRapidExpDeps = string.Join(",", strExpDeps.Select(x => x.ToString()).ToArray()); + + var strParents = dt_RapidDependentsTemp.AsEnumerable().Where(x => x.Field("dirparam") == "T") + .Select(x => new { parent = x.Field("paramname"), allRows = x.Field("allrows") }).Distinct().ToList(); + fld.FldRapidParents = string.Join(",", strParents.Select(x => x.parent).ToArray()); + fld.FldRapidAllRows = string.Join(",", strParents.Select(x => x.allRows).ToArray()); + + fld.FldRapidAllParents = string.Join(",", dt_RapidDependentsTemp.AsEnumerable().Select(x => x.Field("paramname")).Distinct().ToArray()); + + if (fld.FldRapidDeps == fld.FldRapidExpDeps) + fld.FldRapidDepType = "c"; + else + fld.FldRapidDepType = "w"; + } + } + } + catch (Exception ex) + { + LogFile.Log logObj = new LogFile.Log(); + logObj.CreateLog("Exception in SetRapidDependents-" + ex.Message, HttpContext.Current.Session["nsessionid"].ToString(), "Exc-SetRapidDep", "new"); + } + + return fld; + } + + private void SetRapidFormLoadProps() + { + try + { + if (dt_RapidFormControl.Rows.Count == 0) + { + rapidDoFormLoad = false; + rapidFormLoadJSON = string.Empty; + } + else + { + + string strRapidDefs; string strRapidExpFlds; + var rapidDefs = dt_RapidFormControl.AsEnumerable().Where(x => x.Field("context") == "new") + .Select(r => new { fieldname = r.Field("fieldname"), paramname = r.Field("paramname") }).ToList(); + rapidGlobalParams = string.Join(",", rapidDefs.Select(x => x.paramname).Distinct().ToArray()); + strRapidDefs = string.Join(",", rapidDefs.Select(x => x.fieldname).ToArray()); + var rapidExpFlds = dt_RapidFormControl.AsEnumerable().Where(x => x.Field("context") == "new" + && (string.IsNullOrWhiteSpace(x.Field("fldsql")) || string.IsNullOrEmpty(x.Field("fldsql"))) && !string.IsNullOrEmpty(x.Field("expression"))).Select(r => r.Field("fieldname")).ToList(); + strRapidExpFlds = string.Join(",", rapidExpFlds.Select(x => x.ToString()).ToArray()); + rapidFLExpFlds = rapidExpFlds; + if (rapidDefs.Count == 0 || strRapidExpFlds == strRapidDefs) + rapidIsClientFormLoad = true; + + } + } + catch (Exception ex) + { + LogFile.Log logObj = new LogFile.Log(); + logObj.CreateLog("Exception in SetRapidFormLoadProps-" + ex.Message, HttpContext.Current.Session["nsessionid"].ToString(), "Exc-SetRapidFormLoadProps", "new"); + } + } + + private void ParseSearchAndGroups(DataTable customDS) + { + if (customDS != null) + { + if (customDS.Rows.Count > 0) + { + try + { + foreach (DataRow dr in customDS.Rows) + { + if (dr["configname"].ToString() == "searchcols") + { + srchCols = dr["cvalue"].ToString(); + } + else if (dr["configname"].ToString() == "groupbtns") + { + grpActBtns = dr["cvalue"].ToString(); + } + else if (dr["configname"].ToString().ToLower() == "refreshselect") + { + refreshSelect = dr["cvalue"].ToString(); + } + else if (dr["configname"].ToString().ToLower() == "printform") + { + htmlToPDF = dr["cvalue"].ToString(); + HttpContext.Current.Session["htmltopdfParams"] = dr["cvalue"].ToString(); + } + } + } + catch (Exception ex) + { + LogFile.Log logObj = new LogFile.Log(); + logObj.CreateLog("Exception in ParseSearchAndGroups-" + ex.Message, HttpContext.Current.Session["nsessionid"].ToString(), "Exc-ParseSearchAndGroups", "new"); + } + } + } + } + + private bool CheckpurposeFld()//murali + { + bool resPurpose = false; + ASBCustom.CustomWebservice objCWbSer = new ASBCustom.CustomWebservice(); + string dbType = string.Empty; + if (!string.IsNullOrEmpty(HttpContext.Current.Session["axdb"].ToString())) + dbType = HttpContext.Current.Session["axdb"].ToString().ToLower(); + string sql = string.Empty; + + sql = "Select ( CASE WHEN (Select Value from axpCloudDevSettings where ID='" + HttpContext.Current.Session["user"] + "' and type=\'axPurpose\') IS NULL THEN 0 else (Select Value from axpCloudDevSettings where ID='" + HttpContext.Current.Session["user"] + "' and type=\'axPurpose\') end ) AS admn,(CASE WHEN (Select Value from axpCloudUserSettings where USERID='" + HttpContext.Current.Session["user"] + "' and \'axPurpose\') IS NULL THEN 0 else (Select Value from axpCloudUserSettings where USERID='" + HttpContext.Current.Session["user"] + "' and type=\'axPurpose\')end ) AS usr " + (dbType == "oracle" ? "from dual" : ""); + //sql = "select * from axpCloudDevSettings where ID='" + HttpContext.Current.Session["user"] + "'"; + string result = objCWbSer.GetChoices(transId, sql); + if (result != string.Empty) + { + DataSet ds = new DataSet(); + StringReader sr = new StringReader(result); + ds.ReadXml(sr); + DataTable dt = ds.Tables["row"]; + if (dt != null && dt.Rows.Count > 0) + { + if (!string.IsNullOrEmpty(dt.Rows[0]["admn"].ToString())) + { + int adminValue = Convert.ToInt32(dt.Rows[0]["admn"]); + int userValue = Convert.ToInt32(dt.Rows[0]["usr"]); + if (adminValue > 0 && userValue > 0) + resPurpose = true; + else if (adminValue <= 0 && userValue > 0) + resPurpose = true; + else if (adminValue > 0 && userValue <= 0) + resPurpose = false; + else if (adminValue <= 0 && userValue <= 0) + resPurpose = false; + } + else + resPurpose = false; + } + } + return resPurpose; + } + #endregion + + # region DataMembers with get set properties + + public ArrayList lstDc1 + { + get { return dcs; } + set { dcs = value; } + } + + public ArrayList lstPopDc + { + get { return popdcs; } + set { popdcs = value; } + } + + public ArrayList lstField + { + get { return flds; } + set { flds = value; } + } + + public ArrayList lstButton + { + get { return btns; } + set { btns = value; } + } + + public ArrayList lstFillgrid + { + get { return fgs; } + set { fgs = value; } + } + + public ArrayList lstHyperLink + { + get { return hlnks; } + set { hlnks = value; } + } + + public ArrayList lstSearchDataNames + { + get { return searchDataNames; } + set { searchDataNames = value; } + } + + public ArrayList lstSearchDataCaptions + { + get { return searchDataCaptions; } + set { searchDataCaptions = value; } + } + + public ArrayList lstActions + { + get { return actions; } + set { actions = value; } + } + + public string structRes + { + get { return res; } + set { res = value; } + } + + public Boolean ShowZeroForNumeric + { + get { return showZeroForNumeric; } + set { showZeroForNumeric = value; } + } + + public Boolean IsFillGridCall + { + get { return isFillGridCall; } + set { isFillGridCall = value; } + } + + public string HlpText + { + get { return hlpText; } + set { hlpText = value; } + } + #endregion + + # region Structures + /// + /// Structure for Dc data. + /// + [Serializable] + public struct DcStruct + { + string dcName; + string dcCaption; + int dcNo; + int fldCount; + int visFldCount; + bool dcIsGrid; + bool dcIsPopGrid; + int dcHgt; + int dcWdt; + bool dcIsAllowAddRows; + bool dcIsAllowchange; + bool dcIsAllowDeleteRows; + bool dcIsFormatGrid; + bool showAddBtn; + bool dcHasDataRows; + bool dcAllowEmpty; + string keyCol; + bool multiSelect; + string sql; + string hideColumns; + string mapColumn; + string mapParColumn; + ArrayList subTotalCols; + string displayKeyCol; + string displayTotCol; + string headerStyle; + string subTotalStyle; + string action; + string dcPurpose;//murali + ArrayList dispKeyColValues; + ArrayList keyColumnValues; + ArrayList tabParentFlds; + StringBuilder dcExpDependents; + string dcAcceptMRFields; + string dcPlist; + + public string dcPList + { + get { return dcPlist; } + set { dcPlist = value; } + } + + public int dcHeight + { + get { return dcHgt; } + set { dcHgt = value; } + } + + public int dcWidht + { + get { return dcWdt; } + set { dcWdt = value; } + } + + public int fieldCount + { + get { return fldCount; } + set { fldCount = value; } + } + public int visibleFldCount + { + get { return visFldCount; } + set { visFldCount = value; } + } + + public string name + { + get { return dcName; } + set { dcName = value; } + } + + public string caption + { + get { return dcCaption; } + set { dcCaption = value; } + } + + public int frameno + { + get { return dcNo; } + set { dcNo = value; } + } + + public bool isgrid + { + get { return dcIsGrid; } + set { dcIsGrid = value; } + } + + public bool DCHasDataRows + { + get { return dcHasDataRows; } + set { dcHasDataRows = value; } + } + + public bool DcAllowEmpty + { + get { return dcAllowEmpty; } + set { dcAllowEmpty = value; } + } + + public bool ispopgrid + { + get { return dcIsPopGrid; } + set { dcIsPopGrid = value; } + } + public bool isallowaddrows + { + get { return dcIsAllowAddRows; } + set { dcIsAllowAddRows = value; } + } + public bool isallowchange + { + get { return dcIsAllowchange; } + set { dcIsAllowchange = value; } + } + public bool isallowdeletrows + { + get { return dcIsAllowDeleteRows; } + set { dcIsAllowDeleteRows = value; } + } + + public bool IsFormatGrid + { + get { return dcIsFormatGrid; } + set { dcIsFormatGrid = value; } + } + public bool MultiSelect + { + get { return multiSelect; } + set { multiSelect = value; } + } + public bool ShowAddBtn + { + get { return showAddBtn; } + set { showAddBtn = value; } + } + public string KeyColumn + { + get { return keyCol; } + set { keyCol = value; } + } + public string Sql + { + get { return sql; } + set { sql = value; } + } + public string HideColumns + { + get { return hideColumns; } + set { hideColumns = value; } + } + public string Action + { + get { return action; } + set { action = value; } + } + public string MapColumn + { + get { return mapColumn; } + set { mapColumn = value; } + } + public string MapParentCol + { + get { return mapParColumn; } + set { mapParColumn = value; } + } + public ArrayList SubTotalColumns + { + get { return subTotalCols; } + set { subTotalCols = value; } + } + public string DisplayKeyCol + { + get { return displayKeyCol; } + set { displayKeyCol = value; } + } + public string DisplayTotalCol + { + get { return displayTotCol; } + set { displayTotCol = value; } + } + public string HeaderStyle + { + get { return headerStyle; } + set { headerStyle = value; } + } + public string SubTotalStyle + { + get { return subTotalStyle; } + set { subTotalStyle = value; } + } + public string DCAcceptMRFields + { + get { return dcAcceptMRFields; } + set { dcAcceptMRFields = value; } + } + + public string purpose //murali + { + get { return dcPurpose; } + set { dcPurpose = value; } + } + + public ArrayList DispKeyColValues + { + get { return dispKeyColValues; } + set { dispKeyColValues = value; } + } + public ArrayList KeyColValues + { + get { return keyColumnValues; } + set { keyColumnValues = value; } + } + + public ArrayList tabParentFields + { + get { return tabParentFlds; } + set { tabParentFlds = value; } + } + + public StringBuilder dcExpressionDeps + { + get { return dcExpDependents; } + set { dcExpDependents = value; } + } + } + + /// + /// Structure for PopDc data. + /// + [Serializable] + public struct PopDcStruct + { + + string dcCaption; + int dcNo; + int pDcNo; + string pFields; + string popField; + string popFirm; + string popAuto; + string popKeyCols; + string displaySummaryField; + string summaryParent; + string delimiter; + string sqlFill; + string popCond; + + public string caption + { + get { return dcCaption; } + set { dcCaption = value; } + } + + public int frameno + { + get { return dcNo; } + set { dcNo = value; } + } + + public int pdcno + { + get { return pDcNo; } + set { pDcNo = value; } + } + + public string pfields + { + get { return pFields; } + set { pFields = value; } + } + + public string popfield + { + get { return popField; } + set { popField = value; } + } + + public string pFirm + { + get { return popFirm; } + set { popFirm = value; } + } + + public string pAuto + { + get { return popAuto; } + set { popAuto = value; } + } + + public string pKeyCols + { + get { return popKeyCols; } + set { popKeyCols = value; } + } + + public string dispSummaryField + { + get { return displaySummaryField; } + set { displaySummaryField = value; } + } + + public string dispSummaryParent + { + get { return summaryParent; } + set { summaryParent = value; } + } + + public string summaryDelimiter + { + get { return delimiter; } + set { delimiter = value; } + } + + public string fillSql + { + get { return sqlFill; } + set { sqlFill = value; } + } + + public string PopCondition + { + get { return popCond; } + set { popCond = value; } + } + + } + + /// + /// Structure for Action data. + /// + [Serializable] + public struct ActionStruct + { + string actName; + string actDesc; + string actApply; + string actApplyOn; + string actStrName; + string actValidate; + string actWeb; + string actRemarks; + string manRemarks; + string actParentRefresh; + string actsavetask; + string actscripttask; + + public string actname + { + get { return actName; } + set { actName = value; } + } + + public string actdesc + { + get { return actDesc; } + set { actDesc = value; } + } + + public string actapply + { + get { return actApply; } + set { actApply = value; } + } + + public string actapplyon + { + get { return actApplyOn; } + set { actApplyOn = value; } + } + + public string actstrname + { + get { return actStrName; } + set { actStrName = value; } + } + + public string actvalidate + { + get { return actValidate; } + set { actValidate = value; } + } + + public string actweb + { + get { return actWeb; } + set { actWeb = value; } + } + + public string actRem + { + get { return actRemarks; } + set { actRemarks = value; } + } + + public string manRem + { + get { return manRemarks; } + set { manRemarks = value; } + } + public string actParRefresh + { + get { return actParentRefresh; } + set { actParentRefresh = value; } + } + public string actSaveTask + { + get { return actsavetask; } + set { actsavetask = value; } + } + public string actScriptTask + { + get { return actscripttask; } + set { actscripttask = value; } + } + } + + /// + /// Structure for field data. + /// + [Serializable] + public struct FieldStruct + { + string fldName; + string fldCaption; + string fldDatatype; + string fldTableVal; + string fldModeofEntry; + string fldExpression; + string fldValidateExpression; + string fldTLHW; + string fldChecktype; + string fldAllignType; + string fldColumnWidth; + string fldLabelTLHW; + string fldPattern; + string fldPasswordCharacter; + string fldApplyComma; + string fldSqlList; + string fldExpressionList; + string fldFillList; + string fldFillGridList; + string fldPopDepList; + string fldAutoSelect; + string fldRefreshOnSave; + string fldSourceField; + string fldSqlField; + string isSqlFld; + string isApiFld; + string fldSqlQuery; + string fldSelAPI; + string fieldSelApiParams; + string fldSelectMode; + string fldMoeValue; + string fldTooltip; + string fldDependents; + string fldSqlDeps; + string fldExpDeps; + string fldGridSqlDeps; + string fldSqlDepParents; + string fldDepGridDcs; + string fldDepFillDcs; + string fldParents; + string clientFldParents; + string fldHint; + string fldPurpose;//mAdd + //Events for the field + string fldOnFocus; + string fldOnBlur; + string fldOnKeyDown; + string fldOnKeyUp; + string fldOnClick; + string fldOnDbClick; + string fldOnKeyPress; + string fldOnChange; + string fldValue; + string masterRow; + string fldComboVals; + string fldIdCol; + string fldLblCss; + string fldTxtCss; + string fldValSeparator; + string fldBgColor; + ArrayList advSrchFlds; + ArrayList advSrchFldsType; + string pLabelTLHW; + string pwfldtlhw; + + public int fldFrameNo; + int fldLength; + int fldDecimalPlaces; + int fldParamCount; + int fldSelectRefresh; + int fldOrder; + bool fldIsVisibility; + bool fldIsAllowEmpty; + bool fldIsReadonly; + bool fldIsSaveNormal; + bool fldIsEditCombo; + bool fldIsSelectFireSql; + bool fldIsSaveValue; + bool fldIsAllowDuplicate; + bool fldIsImage; + bool fldIsFromList; + bool fldIsOnlyPositive; + bool fldIsTabStop; + + string fldRapidDeps; + string fldRapidExpDeps; + string fldRapidDepType; + string fldRapidParents; + string fldRapidAllParents; + string fldRapidAllRows; + int fieldindex; + string fldmultiselect; + string fldmultiselectsep; + string fldtype; + string fldacceptapi; + + int pwdMinChar; + bool pwdAlphaNumeric; + int pwdNodExpiry; + + public string OnFocus + { + get { return fldOnFocus; } + set { fldOnFocus = value; } + } + + public string OnBlur + { + get { return fldOnBlur; } + set { fldOnBlur = value; } + } + + public string OnKeyDown + { + get { return fldOnKeyDown; } + set { fldOnKeyDown = value; } + } + + public string OnKeyUp + { + get { return fldOnKeyUp; } + set { fldOnKeyUp = value; } + } + public string OnClick + { + get { return fldOnClick; } + set { fldOnClick = value; } + } + public string OnDbClick + { + get { return fldOnDbClick; } + set { fldOnDbClick = value; } + } + public string OnKeyPress + { + get { return fldOnKeyPress; } + set { fldOnKeyPress = value; } + } + public string OnChange + { + get { return fldOnChange; } + set { fldOnChange = value; } + } + + public string name + { + get { return fldName; } + set { fldName = value; } + } + + public string caption + { + get { return fldCaption; } + set { fldCaption = value; } + } + + public string datatype + { + get { return fldDatatype; } + set { fldDatatype = value; } + } + + public string tabletypeval + { + get { return fldTableVal; } + set { fldTableVal = value; } + } + + public string moe + { + get { return fldModeofEntry; } + set { fldModeofEntry = value; } + } + + public string expr + { + get { return fldExpression; } + set { fldExpression = value; } + } + + public string vexpr + { + get { return fldValidateExpression; } + set { fldValidateExpression = value; } + } + + public string fldtlhw + { + get { return fldTLHW; } + set { fldTLHW = value; } + } + + public string lbltlhw + { + get { return fldLabelTLHW; } + set { fldLabelTLHW = value; } + } + + public string plbltlhw + { + get { return pLabelTLHW; } + set { pLabelTLHW = value; } + } + + public string pfldtlhw + { + get { return pwfldtlhw; } + set { pwfldtlhw = value; } + } + public string pattern + { + get { return fldPattern; } + set { fldPattern = value; } + } + + public string pwdchar + { + get { return fldPasswordCharacter; } + set { fldPasswordCharacter = value; } + } + + public int pwdminchar + { + get { return pwdMinChar; } + set { pwdMinChar = value; } + } + + public bool pwdalphanumeric + { + get { return pwdAlphaNumeric; } + set { pwdAlphaNumeric = value; } + } + + public int pwdnodexpiry + { + get { return pwdNodExpiry; } + set { pwdNodExpiry = value; } + } + + public string applycomma + { + get { return fldApplyComma; } + set { fldApplyComma = value; } + } + + public string fieldHint + { + get { return fldHint; } + set { fldHint = value; } + } + public string fieldPurpose //m + { + get { return fldPurpose; } + set { fldPurpose = value; } + } + + public string slist + { + get { return fldSqlList; } + set { fldSqlList = value; } + } + + public string elist + { + get { return fldExpressionList; } + set { fldExpressionList = value; } + } + + public string flist + { + get { return fldFillList; } + set { fldFillList = value; } + } + + public string sflist + { + get { return fldPopDepList; } + set { fldPopDepList = value; } + } + + public string fglist + { + get { return fldFillGridList; } + set { fldFillGridList = value; } + } + + public string ctype + { + get { return fldChecktype; } + set { fldChecktype = value; } + } + + public string type + { + get { return fldAllignType; } + set { fldAllignType = value; } + } + + public string cwid + { + get { return fldColumnWidth; } + set { fldColumnWidth = value; } + } + + public string selectmode + { + get { return fldSelectMode; } + set { fldSelectMode = value; } + } + + public string autoselect + { + get { return fldAutoSelect; } + set { fldAutoSelect = value; } + } + + public string refreshOnSave + { + get { return fldRefreshOnSave; } + set { fldRefreshOnSave = value; } + } + + public string srcfld + { + get { return fldSourceField; } + set { fldSourceField = value; } + } + + public string sqlfld + { + get { return fldSqlField; } + set { fldSqlField = value; } + } + + public string isFieldSql + { + get { return isSqlFld; } + set { isSqlFld = value; } + } + + public string fieldSqlQuery + { + get { return fldSqlQuery; } + set { fldSqlQuery = value; } + } + + public string isFieldApi + { + get { return isApiFld; } + set { isApiFld = value; } + } + + public string fieldSelAPI + { + get { return fldSelAPI; } + set { fldSelAPI = value; } + } + + public string fieldSelAPIParams + { + get { return fieldSelApiParams; } + set { fieldSelApiParams = value; } + } + + public int fldframeno + { + get { return fldFrameNo; } + set { fldFrameNo = value; } + } + + public int fldlength + { + get { return fldLength; } + set { fldLength = value; } + } + + public int flddecimal + { + get { return fldDecimalPlaces; } + set { fldDecimalPlaces = value; } + } + + public int pcount + { + get { return fldParamCount; } + set { fldParamCount = value; } + } + + public int refresh + { + get { return fldSelectRefresh; } + set { fldSelectRefresh = value; } + } + + public int order + { + get { return fldOrder; } + set { fldOrder = value; } + } + + public string Value + { + get { return fldValue; } + set { fldValue = value; } + } + + public bool visibility + { + get { return fldIsVisibility; } + set { fldIsVisibility = value; } + } + + public bool allowempty + { + get { return fldIsAllowEmpty; } + set { fldIsAllowEmpty = value; } + } + + public bool allowduplicate + { + get { return fldIsAllowDuplicate; } + set { fldIsAllowDuplicate = value; } + } + + public bool freadonly + { + get { return fldIsReadonly; } + set { fldIsReadonly = value; } + } + + public bool savenormal + { + get { return fldIsSaveNormal; } + set { fldIsSaveNormal = value; } + } + + public bool savevalue + { + get { return fldIsSaveValue; } + set { fldIsSaveValue = value; } + } + + public bool editcombo + { + get { return fldIsEditCombo; } + set { fldIsEditCombo = value; } + } + + public bool firesql + { + get { return fldIsSelectFireSql; } + set { fldIsSelectFireSql = value; } + } + + public bool fieldIsImage + { + get { return fldIsImage; } + set { fldIsImage = value; } + } + + public bool fieldIsFrmList + { + get { return fldIsFromList; } + set { fldIsFromList = value; } + } + + public string moeval + { + get { return fldMoeValue; } + set { fldMoeValue = value; } + } + + public string tooltip + { + get { return fldTooltip; } + set { fldTooltip = value; } + } + + public string fieldLabelCss + { + get { return fldLblCss; } + set { fldLblCss = value; } + } + public string fieldCtrlCss + { + get { return fldTxtCss; } + set { fldTxtCss = value; } + } + + public string mRow + { + get { return masterRow; } + set { masterRow = value; } + } + + public string fldComboValues + { + get { return fldComboVals; } + set { fldComboVals = value; } + } + + public string fldIdCols + { + get { return fldIdCol; } + set { fldIdCol = value; } + } + + public string fieldParents + { + get { return fldParents; } + set { fldParents = value; } + } + + public string ClientFldParents + { + get { return clientFldParents; } + set { clientFldParents = value; } + } + + public string fieldDependents + { + get { return fldDependents; } + set { fldDependents = value; } + } + + public string fieldSqlDeps + { + get { return fldSqlDeps; } + set { fldSqlDeps = value; } + } + + public string fieldExpDeps + { + get { return fldExpDeps; } + set { fldExpDeps = value; } + } + + public string fieldSqlGridDeps + { + get { return fldGridSqlDeps; } + set { fldGridSqlDeps = value; } + } + + public string fieldSqlDepParents + { + get { return fldSqlDepParents; } + set { fldSqlDepParents = value; } + } + + public string fieldDepGridDcs + { + get { return fldDepGridDcs; } + set { fldDepGridDcs = value; } + } + + public string fieldDepFillDcs + { + get { return fldDepFillDcs; } + set { fldDepFillDcs = value; } + } + + public string fieldValSeparator + { + get { return fldValSeparator; } + set { fldValSeparator = value; } + } + + public string fldColor + { + get { return fldBgColor; } + set { fldBgColor = value; } + } + + public bool onlyPositive + { + get { return fldIsOnlyPositive; } + set { fldIsOnlyPositive = value; } + } + + public bool tabStop + { + get { return fldIsTabStop; } + set { fldIsTabStop = value; } + } + + public ArrayList AdvSrchFlds + { + get { return advSrchFlds; } + set { advSrchFlds = value; } + } + + public ArrayList AdvSrchFldsType + { + get { return advSrchFldsType; } + set { advSrchFldsType = value; } + } + + public string FldRapidDeps + { + get { return fldRapidDeps; } + set { fldRapidDeps = value; } + } + public string FldRapidExpDeps + { + get { return fldRapidExpDeps; } + set { fldRapidExpDeps = value; } + } + public string FldRapidDepType + { + get { return fldRapidDepType; } + set { fldRapidDepType = value; } + } + public string FldRapidParents + { + get { return fldRapidParents; } + set { fldRapidParents = value; } + } + public string FldRapidAllParents + { + get { return fldRapidAllParents; } + set { fldRapidAllParents = value; } + } + public string FldRapidAllRows + { + get { return fldRapidAllRows; } + set { fldRapidAllRows = value; } + } + public int fieldIndex + { + get { return fieldindex; } + set { fieldindex = value; } + } + public string fldMultiSelect + { + get { return fldmultiselect; } + set { fldmultiselect = value; } + } + public string fldMultiSelectSep + { + get { return fldmultiselectsep; } + set { fldmultiselectsep = value; } + } + public string fldType + { + get { return fldtype; } + set { fldtype = value; } + } + + public string fldAcceptApi + { + get { return fldacceptapi; } + set { fldacceptapi = value; } + } + } + + /// + /// FillGrid Structure + /// + [Serializable] + public struct FGStruct + { + string fgsqlparams; + string fgTargetDc; + string fgSourceDc; + string fgMultiSelect; + string fgAutoShow; + string fgCondition; + string fgCaption; + string fName; + string fgValidateExp; + ArrayList dcFldName; + ArrayList sqlFldName; + string fgExecOnSave; + public string fgSqlParams + { + get { return fgsqlparams; } + set { fgsqlparams = value; } + } + + public string fgcaption + { + get { return fgCaption; } + set { fgCaption = value; } + } + + public string fgName + { + get { return fName; } + set { fName = value; } + } + + public string fgtargetdc + { + get { return fgTargetDc; } + set { fgTargetDc = value; } + } + + public string fgSourceDC + { + get { return fgSourceDc; } + set { fgSourceDc = value; } + } + + public string fgmultiselect + { + get { return fgMultiSelect; } + set { fgMultiSelect = value; } + } + + public string fgautoshow + { + get { return fgAutoShow; } + set { fgAutoShow = value; } + } + + public string FGCondition + { + get { return fgCondition; } + set { fgCondition = value; } + } + public string FGExecOnSave + { + get { return fgExecOnSave; } + set { fgExecOnSave = value; } + } + + public string fgValExpression + { + get { return fgValidateExp; } + set { fgValidateExp = value; } + } + + public ArrayList fgDcFldName + { + get { return dcFldName; } + set { dcFldName = value; } + } + + public ArrayList fgSqlFldName + { + get { return sqlFldName; } + set { sqlFldName = value; } + } + } + + + /// + /// HyperLink Structure + /// + [Serializable] + private struct HLinkStruct + { + string hlName; + string hlSource; + string hlPop; + string hlLoad; + string hlParamName; + string hlParamValue; + + public string hlname + { + get { return hlName; } + set { hlName = value; } + } + + public string hlsource + { + get { return hlSource; } + set { hlSource = value; } + } + + public string hlpop + { + get { return hlPop; } + set { hlPop = value; } + } + + public string hlload + { + get { return hlLoad; } + set { hlLoad = value; } + } + + public string hlparamname + { + get { return hlParamName; } + set { hlParamName = value; } + } + + public string hlparamval + { + get { return hlParamValue; } + set { hlParamValue = value; } + } + } + /// + /// icon structure + /// + [Serializable] + public struct IconStruct + { + public string text; + public string addclass; + + } + + /// + /// Api structure + /// + [Serializable] + public struct btnApiStruct + { + public string url; + public string reqstr; + public string restype; + public string resformat; + public string category; + public string method; + } + + + /// + /// Button structure + /// + [Serializable] + public struct ButtonStruct + { + string btnTask; + string btnActionValue; + string btnFileUpload; + string btnFileMessage; + string btnFileType; + string btnImageName; + string btnCaption; + string btnFooter; + string btnVisible; + string btnHint; + string btnTLHW; + string btnCancel; + string btnID; + bool isDrpDwnBtn; + bool scriptapi; + bool isFormBtn; + IconStruct btnIcon; + btnApiStruct btnApi; + ArrayList childButtons; + bool script; + + public bool isformbtn + { + get { return isFormBtn; } + set { isFormBtn = value; } + } + public bool isDrpDwn + { + get { return isDrpDwnBtn; } + set { isDrpDwnBtn = value; } + } + public bool scriptApi + { + get { return scriptapi; } + set { scriptapi = value; } + } + public IconStruct icon + { + get { return btnIcon; } + set + { + btnIcon.text = value.text; + btnIcon.addclass = value.addclass; + } + } + public btnApiStruct btnapi + { + get { return btnApi; } + set + { + btnApi.url = value.url; + btnApi.reqstr = value.reqstr; + btnApi.restype = value.restype; + btnApi.resformat = value.resformat; + btnApi.category = value.category; + btnApi.method = value.method; + } + } + + public ArrayList childBtns + { + get { return childButtons; } + set { childButtons = value; } + } + + public string ID + { + get { return btnID; } + set { btnID = value; } + } + + public string task + { + get { return btnTask; } + set { btnTask = value; } + } + + public string action + { + get { return btnActionValue; } + set { btnActionValue = value; } + } + + public string fileupload + { + get { return btnFileUpload; } + set { btnFileUpload = value; } + } + + public string cancelBtn + { + get { return btnCancel; } + set { btnCancel = value; } + } + + + public string fmessage + { + get { return btnFileMessage; } + set { btnFileMessage = value; } + } + + public string ftype + { + get { return btnFileType; } + set { btnFileType = value; } + } + + public string image + { + get { return btnImageName; } + set { btnImageName = value; } + } + + public string hint + { + get { return btnHint; } + set { btnHint = value; } + } + + public string caption + { + get { return btnCaption; } + set { btnCaption = value; } + } + + public string dimension + { + get { return btnTLHW; } + set { btnTLHW = value; } + } + public bool isScript + { + get { return script; } + set { script = value; } + } + + public string footer + { + get { return btnFooter; } + set { btnFooter = value; } + } + + public string visible + { + get { return btnVisible; } + set { btnVisible = value; } + } + } + #endregion + + # region Methods + + #region Private Methods + + /// + /// function to update the tstruct related properties. + /// + /// + private void FillTstructProperties(XmlDocument xmlDoc) + { + //Loop through the root node and update the dcTitle + //Tstruct attributes of the TstructDef class. + XmlNodeList tstAttributeNodes = default(XmlNodeList); + tstAttributeNodes = xmlDoc.GetElementsByTagName("root"); + foreach (XmlNode tstAttributeNode in tstAttributeNodes) + { + if (tstAttributeNode.Attributes["pform"] != null) + tstPform = tstAttributeNode.Attributes["pform"].Value.ToString(); + if (tstAttributeNode.Attributes["wflow"] != null) + tstWorkflow = tstAttributeNode.Attributes["wflow"].Value.ToString(); + if (tstAttributeNode.Attributes["updatedon"] != null) + tstUpdateOn = tstAttributeNode.Attributes["updatedon"].Value.ToString(); + if (tstAttributeNode.Attributes["updusername"] != null) + tstUpdateBy = tstAttributeNode.Attributes["updusername"].Value.ToString(); + if (tstAttributeNode.Attributes["readonly"] != null) + tstReadOnly = tstAttributeNode.Attributes["readonly"].Value.ToString(); + if (tstAttributeNode.Attributes["cancelled"] != null) + tstCancelled = tstAttributeNode.Attributes["cancelled"].Value.ToString(); + if (tstAttributeNode.Attributes["pdf"] != null) + tstPdf = tstAttributeNode.Attributes["pdf"].Value.ToString(); + if (tstAttributeNode.Attributes["sverno"] != null) + tstVersion = tstAttributeNode.Attributes["sverno"].Value.ToString(); + //if (tstAttributeNode.Attributes["runtimemod"] != null) + // tstRuntimeModification = tstAttributeNode.Attributes["runtimemod"].Value.ToString(); + + // TODO : This is for temporary , we have to give all the tstruct related + // attributes either in the root node or in the first childnode[tstruct node] of the root node. + XmlNode tstBaseNode = tstAttributeNode.ChildNodes[0]; + if (tstBaseNode.Attributes["cat"].Value.ToString().ToLower() == "tstruct") + { + foreach (XmlNode tstNode in tstBaseNode) + { + if (tstNode.Name == "a1") + transId = tstNode.InnerText; + else if (tstNode.Name == "a2") + { + tstCaption = tstNode.InnerText; + tstCaption = tstCaption.Replace("&&", "&"); + } + else if (tstNode.Name == "a18") + tstAttachment = tstNode.InnerText; + else if (tstNode.Name == "a20") + tstIviewButton = tstNode.InnerText; + //else if (tstNode.Name == "a28") + // formLoadCache = tstNode.InnerText; + else if (tstNode.Name == "a29") + if (tstNode.InnerText != null && tstNode.InnerText.ToLower() == "wizard") + isWizardTstruct = true; + } + } + if (tstBaseNode.Attributes != null && tstBaseNode.Attributes["wsflds"] != null) + { + string tempWsFieldDetails = string.Empty; + try + { + tempWsFieldDetails = tstBaseNode.Attributes["wsflds"].Value.ToString(); + } + catch (Exception ex) { } + + //DoFormload~exflds~dcname`fillgrid names with auto show true~dcname`accpetsql,dcname`selectautoselectflds + if (tempWsFieldDetails != string.Empty) + { + wsPerfEnabled = true; + string[] wsDetails = tempWsFieldDetails.Split('~'); + if (wsDetails.Length >= 1)//Doformload + wsPerfFormLoadCall = wsDetails[0].ToString().ToLower() == "true" ? true : false; + if (wsDetails.Length >= 2)//Expression flds + wsPerfEvalExpClient = wsDetails[1].ToString(); + if (wsDetails.Length >= 3 && wsDetails[2] != "") + { + string[] flgDetails = wsDetails[2].Split(',').ToArray(); + wsPerfFGDcName = flgDetails.Select(x => x.Split('`')[0]).ToArray();//Fillgrid dcname + } + if (wsDetails.Length >= 4 && wsDetails[3] != "") + { + string[] ldcDetails = wsDetails[3].Split(',').ToArray(); + wsPerfLDcName = ldcDetails.Select(x => x.Split('`')[0]).ToArray();//dcname + wsPerfFields = string.Join(",", ldcDetails.Select(x => x.Split('`')[1]).ToArray());//acceptsql and select with autosel true fields + } + } + } + } + } + + /// + /// Function to parse the format grid xml and update the dc properties. + /// + /// + private void XmlLoadFormatDcs(XmlNode gFormatNodes) + { + string actions = string.Empty; + foreach (XmlNode dcNode in gFormatNodes) + { + for (int i = 0; i < dcs.Count; i++) + { + DcStruct dc = (DcStruct)dcs[i]; + if (dc.name == dcNode.Name) + { + dc.IsFormatGrid = true; + foreach (XmlNode dataNode in dcNode.ChildNodes) + { + string value = string.Empty; + if (dataNode.Attributes["val"] != null) + value = dataNode.Attributes["val"].Value; + if (dataNode.Name.ToLower() == "keycol") + dc.KeyColumn = value; + else if (dataNode.Name.ToLower() == "keyval") + { + if (dataNode.Attributes["multiselect"] != null) + { + if (dataNode.Attributes["multiselect"].Value == "true") + dc.MultiSelect = true; + else + dc.MultiSelect = false; + } + + if (value != string.Empty) + { + string[] strValues = value.Split(','); + for (int j = 0; j < strValues.Length; j++) + { + dc.KeyColValues.Add(value); + } + } + } + else if (dataNode.Name.ToLower() == "headlp") + { + dc.HeaderStyle = value; + } + else if (dataNode.Name.ToLower() == "headl") + { + string[] dispKeyCol = value.Split('='); + dc.DisplayKeyCol = dispKeyCol[0].ToString(); + foreach (XmlNode newItem in dataNode.ChildNodes) + { + dc.DispKeyColValues.Add(newItem.Name + "¿" + newItem.InnerText); + } + } + else if (dataNode.Name.ToLower() == "totlp") + { + dc.SubTotalStyle = value; + } + else if (dataNode.Name.ToLower() == "totl") + { + string[] stDetails = value.Split(','); + for (int j = 0; j < stDetails.Length; j++) + { + string[] cols = stDetails[j].ToString().Split('='); + if (cols.Length > 1) + { + if (cols[1].Substring(0, 1) != "#") + dc.DisplayTotalCol = cols[0].ToString().Trim(); + else + dc.SubTotalColumns.Add(cols[0].ToString().Trim()); + } + } + } + else if (dataNode.Name.ToLower() == "actions") + { + foreach (XmlNode actionNode in dataNode.ChildNodes) + { + if (actions == "") + actions = actionNode.InnerText; + else + actions = "," + actionNode.InnerText; + } + dc.Action = actions; + } + else if (dataNode.Name.ToLower() == "defaultvalues") + { + foreach (XmlNode defaultVal in dataNode.ChildNodes) + { + dc.KeyColValues.Add(defaultVal.Name); + dc.DispKeyColValues.Add(defaultVal.InnerText); + } + } + else if (dataNode.Name.ToLower() == "btns") + { + if (dataNode.InnerText.IndexOf("add") != -1) + dc.ShowAddBtn = true; + else + dc.ShowAddBtn = false; + } + else if (dataNode.Name.ToLower() == "sql") + { + if (dataNode.Attributes["hidecol"] != null) + dc.HideColumns = dataNode.Attributes["hidecol"].Value; + if (dataNode.Attributes["map"] != null) + dc.MapColumn = dataNode.Attributes["map"].Value; + if (dataNode.Attributes["mappar"] != null) + dc.MapParentCol = dataNode.Attributes["mappar"].Value; + dc.Sql = dataNode.InnerText; + } + } + dcs[i] = dc; + } + LoadFormatDcArray(dc); + } + } + + } + + /// + /// Function to get the Tabbed DC's information and store in the pagePositions and visibleDC's array. + /// + /// + private void XmlLoadTabDcs(XmlNode iframeNodes) + { + if (axdesignJObject.selectedLayout != null) + { + string visibleDC = string.Empty; + StringBuilder strTab = new StringBuilder(); + string lastDc = string.Empty; + + string layout = axdesignJObject.selectedLayout; + tstLayout = layout.ToLower(); + + var designMode = false; + + if (HttpContext.Current.Session[transId + "IsDesignMode"] != null && HttpContext.Current.Session[transId + "IsDesignMode"].ToString() != string.Empty) + { + designMode = Convert.ToBoolean(HttpContext.Current.Session[transId + "IsDesignMode"]); + } + + if (dcs.Count == 1) + isWizardTstruct = false; + + if ((tstLayout == "tile" && designMode) || isWizardTstruct || isMobile || dcs.Count == 1) tstLayout = "default"; + + ArrayList tempPositions = new ArrayList(); + + foreach (DcStruct dc in dcs) + { + bool isFirstDc = false; + bool isSecondLastDc = false; + bool isLastDc = false; + + if (dc.frameno == 1) + { + isFirstDc = true; + } + if (dc.frameno == dcs.Count) + { + isLastDc = true; + } + if (dc.frameno == dcs.Count - 1 && dcs.Count > 2) + { + isSecondLastDc = true; + } + + switch (tstLayout) + { + case "default": + case "tile": + { + tempPositions.Add(dc.frameno); + + visibleDCs.Add(tempPositions[0].ToString()); + pagePositions.Add(tempPositions[0].ToString()); + + tempPositions = new ArrayList(); + } + break; + case "tabbed": + { + tempPositions.Add(dc.frameno); + + if (isLastDc) + { + visibleDCs.Add(tempPositions[0].ToString()); + pagePositions.Add(String.Join(",", tempPositions.ToArray())); + + tempPositions = new ArrayList(); + } + } + break; + case "double": + { + tempPositions.Add(dc.frameno); + + if (isFirstDc) + { + visibleDCs.Add(tempPositions[0].ToString()); + pagePositions.Add(String.Join(",", tempPositions.ToArray())); + + tempPositions = new ArrayList(); + } + if (isSecondLastDc) + { + visibleDCs.Add(tempPositions[0].ToString()); + pagePositions.Add(String.Join(",", tempPositions.ToArray())); + + tempPositions = new ArrayList(); + } + if (isLastDc) + { + visibleDCs.Add(tempPositions[0].ToString()); + pagePositions.Add(String.Join(",", tempPositions.ToArray())); + + tempPositions = new ArrayList(); + } + } + break; + case "single": + { + tempPositions.Add(dc.frameno); + + if (isFirstDc) + { + visibleDCs.Add(tempPositions[0].ToString()); + pagePositions.Add(String.Join(",", tempPositions.ToArray())); + + tempPositions = new ArrayList(); + } + if (isLastDc) + { + visibleDCs.Add(tempPositions[0].ToString()); + pagePositions.Add(String.Join(",", tempPositions.ToArray())); + + tempPositions = new ArrayList(); + } + } + break; + } + } + } + else if (iframeNodes.Attributes["layout"] != null) + { + string visibleDC = string.Empty; + StringBuilder strTab = new StringBuilder(); + string lastDc = string.Empty; + + //The layout attribute is expected to be there only in 9.0 structue xml + string layout = iframeNodes.Attributes["layout"].Value; + tstLayout = layout.ToLower(); + + var designMode = false; + + //Below line will convert tile to default as tile is not working and not supported. + + if (dcs.Count == 1) + isWizardTstruct = false; + + if (tstLayout == "tile" || isWizardTstruct || isMobile /* || designMode*/) tstLayout = "default"; + foreach (XmlNode frmNode in iframeNodes) + { + //string dcName = frmNode.Attributes["name"].Value; + // + //string frameNo = frmNode.Attributes["fno"].Value; + string dcTLHW = frmNode.Attributes["tlhw"].Value; + foreach (XmlNode pageNode in frmNode) + { + foreach (XmlNode dcNode in pageNode) + { + string dcName = dcNode.InnerText; + string frameNo = dcName.Substring(2); + if (dcName.Substring(0, 2) != "dc") continue; + SetDcWidth(frameNo, dcTLHW); + + if (tstLayout == Constants.DEFAULT || tstLayout == Constants.TILE) + { + visibleDCs.Add(frameNo); + pagePositions.Add(frameNo); + } + else if (tstLayout == Constants.SINGLE || tstLayout == Constants.TABBED || tstLayout == Constants.DOUBLE) + { + if ((tstLayout == Constants.SINGLE || tstLayout == Constants.DOUBLE) && dcName == "dc1") + { + pagePositions.Add(frameNo); + visibleDCs.Add(frameNo); + } + else + { + if (tstLayout == Constants.DOUBLE && strTab.ToString() != string.Empty && frmNode.NextSibling == null) + lastDc = frameNo; + + if (strTab.ToString() == string.Empty) + { + strTab.Append(frameNo); + visibleDCs.Add(frameNo); + } + else + { + if ((tstLayout == Constants.DOUBLE && lastDc == string.Empty) || (tstLayout != Constants.DOUBLE)) + strTab.Append("," + frameNo); + } + } + } + } + } + + if (strTab.ToString() != string.Empty) + { + pagePositions.Add(strTab.ToString()); + strTab = new StringBuilder(); + } + } + + if (tstLayout == Constants.DOUBLE && lastDc != string.Empty) + { + pagePositions.Add(lastDc); + visibleDCs.Add(lastDc); + } + } + else + { + foreach (XmlNode ifrNode in iframeNodes) + { + string visibleDC = string.Empty; + XmlNodeList frames = ifrNode.ChildNodes; + StringBuilder strTab = new StringBuilder(); + string lastDc = string.Empty; + + foreach (XmlNode pageNode in frames) + { + if (pageNode.Name == "pages") + { + for (int i = 0; i < pageNode.ChildNodes.Count; i++) + { + string dcName = pageNode.ChildNodes[i].InnerText; + string tabNo = dcName.Substring(2, dcName.Length - 2); + if (i == 0) + { + visibleDC = tabNo; + strTab.Append(tabNo); + } + else + { + strTab.Append("," + tabNo); + } + } + } + } + if (strTab.ToString() != "") + { + pagePositions.Add(strTab); + visibleDCs.Add(visibleDC); + } + strTab = new StringBuilder(); + } + } + } + + + private void SetDcWidth(string frameNo, string tlhw) + { + DcStruct dc = (DcStruct)dcs[Convert.ToInt32(frameNo) - 1]; + string[] strTLHW = tlhw.Split(','); + if (strTLHW.Length > 3) + { + dc.dcWidht = Convert.ToInt32(strTLHW[3].ToString()); + dcs[Convert.ToInt32(frameNo) - 1] = dc; + } + } + + private string ReplaceSpecialCharsInHTML(string str) + { + str = str.Replace("&", "#amp:"); + str = str.Replace("<", "#lt:"); + str = str.Replace(">", "#gt:"); + str = str.Replace("'", "#apos:"); + //str = str.Replace("\"", """); + return str; + } + + /// + /// function to update the dc list. + /// + /// + private void XmlLoadDc(XmlNode dcNodes) + { + DcStruct dc = new DcStruct(); + PopDcStruct pdc = new PopDcStruct(); + dc.isallowaddrows = true; + dc.isallowdeletrows = true; + dc.DCHasDataRows = false; + dc.isallowchange = true; + dc.tabParentFields = new ArrayList(); + dc.dcExpressionDeps = new StringBuilder(); + foreach (XmlNode dcNode in dcNodes) + { + if (dcNode.Name == "a1") + dc.name = dcNode.InnerText; + else if (dcNode.Name == "a2") + { + string dcCaption = dcNode.InnerText; + dcCaption = dcCaption.Replace("&&", "&"); + dc.caption = dcCaption; + } + else if (dcNode.Name == "a5") + dcTable.Add(dcNode.InnerText); + else if (dcNode.Name == "a3") + dc.frameno = int.Parse(dcNode.InnerText); + else if (dcNode.Name == "a6") + dc.isgrid = bool.Parse(dcNode.InnerText); + else if (dcNode.Name == "a7") + dc.isallowchange = bool.Parse(dcNode.InnerText); + else if (dcNode.Name == "a17") + dc.DcAllowEmpty = bool.Parse(dcNode.InnerText); + else if (dcNode.Name == "a26") + { + if (dcNode.InnerText == string.Empty) dcNode.InnerText = "true"; + dc.isallowaddrows = bool.Parse(dcNode.InnerText); + } + else if (dcNode.Name == "a27") + { + if (dcNode.InnerText == string.Empty) dcNode.InnerText = "true"; + dc.isallowdeletrows = bool.Parse(dcNode.InnerText); + } + else if (dcNode.Name == "a9") + { + if (dcNode.Attributes["pop"] != null) + { + if (dcNode.Attributes["pop"].Value.ToString() == "t") + { + dc.ispopgrid = true; + pdc = LoadXmlPopDc(pdc, dcNode); + pdc.frameno = dc.frameno; + if (pdc.caption != string.Empty) + dc.caption = pdc.caption; + popdcs.Add(pdc); + } + else + { + dc.ispopgrid = false; + } + } + } + else if (dcNode.Name == "a31") + { + if (dcNode.Attributes["tlhw"] != null) + { + string NonGridDcHgt = string.Empty; + string[] dim = dcNode.Attributes["tlhw"].Value.Split(','); + if (EnableOldTheme == "false") + { + NonGridDcHgt = Math.Floor((Convert.ToInt32(dim[2].ToString()) * 1.5)).ToString(); + dc.dcHeight = Convert.ToInt32(NonGridDcHgt); + } + else + { + dc.dcHeight = Convert.ToInt32(Convert.ToInt32(dim[2].ToString()) * 1.15); + } + } + } + else if (dcNode.Name == "a59") + dc.purpose = dcNode.InnerText; + } + dc.IsFormatGrid = false; + dc.ShowAddBtn = true; + dc.MultiSelect = true; + dc.Action = string.Empty; + dc.KeyColumn = string.Empty; + dc.KeyColValues = new ArrayList(); + dc.DispKeyColValues = new ArrayList(); + dc.SubTotalColumns = new ArrayList(); + dc.HideColumns = string.Empty; + dc.Sql = string.Empty; + dc.MapColumn = string.Empty; + dc.MapParentCol = string.Empty; + dc.SubTotalStyle = string.Empty; + dc.HeaderStyle = string.Empty; + dc.DisplayKeyCol = string.Empty; + dc.DisplayTotalCol = string.Empty; + dc.dcPList = dcPlistaddrow; + LoadDCArray(dc, pdc); + dcs.Add(dc); + //For every dc add a field 'axp_recid + dcno' as a hidden field. + CreateAxpRecIdFld(dc.frameno); + } + + private void CreateAxpRecIdFld(int frameNo) + { + StringBuilder fldXml = new StringBuilder(); + fldXml.Append(""); + fldXml.Append(""); + fldXml.Append("axp_recid" + frameNo + ""); + fldXml.Append("axp_recid" + frameNo + ""); + fldXml.Append("Character"); + fldXml.Append("150"); + fldXml.Append("Accept0"); + fldXml.Append("0"); + fldXml.Append(""); + fldXml.Append("TrueTrueFalseFalseTrue"); + fldXml.Append("TrueTrueFalse"); + fldXml.Append(""); + fldXml.Append(""); + fldXml.Append("TrueTrue"); + fldXml.Append(""); + fldXml.Append(""); + + XmlDocument xmlD = new XmlDocument(); + xmlD.LoadXml(fldXml.ToString()); + XmlLoadField(xmlD.ChildNodes[0].ChildNodes[0]); + } + + /// + /// Function to construct the popDC and update its properties in the popDC structure PopDcStruct. + /// + /// + /// + /// + private PopDcStruct LoadXmlPopDc(PopDcStruct pdc, XmlNode PopDcNodes) + { + pdc.PopCondition = string.Empty; + foreach (XmlNode dcPopNode in PopDcNodes) + { + if (dcPopNode.Name == "a18") + pdc.caption = dcPopNode.InnerText; + else if (dcPopNode.Name == "a19") + pdc.pdcno = int.Parse(dcPopNode.InnerText.ToString().Substring(2)); + else if (dcPopNode.Name == "a20") + pdc.pfields = dcPopNode.InnerText; + else if (dcPopNode.Name == "a21") + pdc.popfield = dcPopNode.InnerText; + else if (dcPopNode.Name == "a23") + { + if (dcPopNode.Attributes["cond"] != null) + pdc.PopCondition = dcPopNode.Attributes["cond"].Value; + } + else if (dcPopNode.Name == "a24") + { + pdc.pFirm = dcPopNode.Attributes["firm"].Value.ToString(); + pdc.pAuto = dcPopNode.Attributes["auto"].Value.ToString(); + pdc.pKeyCols = dcPopNode.Attributes["kcol"].Value.ToString(); + string strSql = string.Empty; + XmlNodeList sqlNodes = dcPopNode.ChildNodes; + if (sqlNodes.Count > 0) + { + foreach (XmlNode sqlNode in dcPopNode) + { + strSql += sqlNode.InnerText; + } + } + pdc.fillSql = string.Empty; + if (strSql != string.Empty) + pdc.fillSql = "1"; + + } + else if (dcPopNode.Name == "a25") + { + if (dcPopNode.Attributes["disp"] != null) + pdc.dispSummaryParent = dcPopNode.Attributes["disp"].Value; + if (dcPopNode.Attributes["sum"] != null) + pdc.dispSummaryField = dcPopNode.Attributes["sum"].Value; + if (dcPopNode.Attributes["deli"] != null) + pdc.summaryDelimiter = dcPopNode.Attributes["deli"].Value; + } + } + + return pdc; + + } + + /// + /// function to update the javascript field array. + /// + /// + private void LoadDCArray(DcStruct dc, PopDcStruct pdc) + { + StringBuilder DCArray = new StringBuilder(); + + DCArray.Append("DCName[" + DCNo + "]=\"" + dc.name + "\";DCCaption[" + DCNo + "]=\"" + ReplaceSpecialCharsInHTML(dc.caption) + "\";DCFrameNo[" + DCNo + "]=\"" + dc.frameno + "\";DCIsGrid[" + DCNo + "]=\"" + dc.isgrid + "\";DCIsPopGrid[" + DCNo + "]=\"" + dc.ispopgrid + "\";DCAllowEmpty[" + DCNo + "]=\"" + dc.DcAllowEmpty.ToString() + "\";DCHasDataRows[" + DCNo + "]=\"" + dc.DCHasDataRows.ToString() + "\";DcAllowAdd[" + DCNo + "]=\"" + dc.isallowaddrows.ToString() + "\";DCAllowChange[" + DCNo + "]=\"" + dc.isallowchange.ToString() + "\";"); + DCNo++; + + if (dc.ispopgrid) + { + DCArray.Append("PopGridDCs[" + popDCNo + "]=\"" + dc.frameno + "\";PopParentDCs[" + popDCNo + "]=\"" + pdc.pdcno + "\";PopParentFlds[" + popDCNo + "]=\"" + pdc.pfields + "\";PopGridDCFirm[" + popDCNo + "]=\"" + pdc.pFirm + "\";PopCondition[" + popDCNo + "]=\"" + pdc.PopCondition + "\";"); + DCArray.Append("PopSqlFill[" + popDCNo + "]=\"" + pdc.fillSql + "\";PopSummaryParent[" + popDCNo + "]=\"" + pdc.dispSummaryParent + "\";PopSummaryFld[" + popDCNo + "]=\"" + pdc.dispSummaryField + "\";PopSummDelimiter[" + popDCNo + "]=\"" + pdc.summaryDelimiter + "\";"); + popDCNo++; + } + + jsDCArray.Append(DCArray.ToString().Trim()); + } + + /// + /// function to update the javascript field array. + /// + /// + private void LoadDCNewArray(DcStruct dc) + { + StringBuilder DCNewArray = new StringBuilder(); + + DCNewArray.Append("DCExpDeps[" + (dc.frameno - 1) + "]=\"" + dc.dcExpressionDeps.ToString() + "\";DcAcceptMRFlds[" + (dc.frameno - 1) + "]=\"" + dc.DCAcceptMRFields + "\";"); + DCNo++; + jsDCArray.Append(DCNewArray.ToString().Trim()); + } + + /// + /// Function to add dc format grid properties to the js arrays + /// + /// + private void LoadFormatDcArray(DcStruct dc) + { + StringBuilder DCArray = new StringBuilder(); + StringBuilder subTotCols = new StringBuilder(); + for (int i = 0; i < dc.SubTotalColumns.Count; i++) + { + if (subTotCols.ToString() == "") + subTotCols.Append(dc.SubTotalColumns[i].ToString()); + else + subTotCols.Append("," + dc.SubTotalColumns[i].ToString()); + } + DCArray.Append("DcIsFormatGrid[" + (dc.frameno - 1) + "]=\"" + dc.IsFormatGrid + "\";DcKeyColumns[" + (dc.frameno - 1) + "]=\"" + dc.KeyColumn + "\";DcKeyColValues[" + (dc.frameno - 1) + "]=\"" + dc.KeyColValues + "\";"); + DCArray.Append("DcSubTotCols[" + (dc.frameno - 1) + "]=\"" + subTotCols + "\";DcMultiSelect[" + (dc.frameno - 1) + "]=\"" + dc.MultiSelect + "\";"); + //DcMultiSelect + jsDCArray.Append(DCArray.ToString().Trim()); + + } + + /// + /// function to update the field list + /// + /// + private void XmlLoadField(XmlNode fieldNodes, string fieldType = "") + { + fieldIndex++; + List listSrchCols = null; + if (srchCols != String.Empty) + listSrchCols = srchCols.Split(',').ToList(); + + string fldFromApi = string.Empty; + FieldStruct fld = new FieldStruct(); + fld.fieldIndex = fieldIndex; + string fldSearchSQL = string.Empty; + fld.fieldSqlGridDeps = string.Empty; + fld.fieldDepGridDcs = string.Empty; + fld.isFieldSql = string.Empty; + fld.fieldSqlQuery = string.Empty; + fld.fieldSelAPI = string.Empty; + fld.isFieldApi = string.Empty; + fld.fieldValSeparator = string.Empty; + fld.fldColor = string.Empty; + fld.AdvSrchFlds = new ArrayList(); + fld.AdvSrchFldsType = new ArrayList(); + fld.FldRapidAllParents = string.Empty; + fld.FldRapidAllRows = string.Empty; + fld.fldType = fieldType; + foreach (XmlNode fldNode in fieldNodes) + { + if (fldNode.Name == "a1") + { + fld.name = fldNode.InnerText; + //To check if the field is a image and needs to be stored in the server folder. + fldFromApi = string.Empty; + if (fld.name.StartsWith(Constants.IMGPrefix)) + { + ContainsImage = true; + fld.fieldIsImage = true; + AxImageFields.Add(fld.name); + } + if (fld.name.StartsWith("axp_nga_")) + { + ContainsImage = true; + fld.fieldIsImage = true; + AxImageFields.Add(fld.name); + AxAttachFields.Add(fld.name); + } + if (fld.name.ToLower().StartsWith("axpfile_") || fld.name.ToLower().StartsWith("axpfilepath_")) + { + AxpFileUploadFields.Add(fld.name); + } + if (fld.name.ToLower() == (Constants.AXPIMAGEPATH)) + { + isAxpImagePath = true; + //fld.fieldIsImage = true; + //AxImageFields.Add(fld.name); + } + + if (fld.name.StartsWith("axp_gridattach_") || (fld.name.StartsWith("dc") && fld.name.ToLower().EndsWith("_image"))) + { + ContainsGridAttach = true; + AxAttachFields.Add(fld.name); + } + if (fld.name.StartsWith("dc") && fld.name.ToLower().EndsWith("_referimages")) + { + ContainsGridRefer = true; + AxAttachFields.Add(fld.name); + } + if (fld.name.ToLower().EndsWith("_imagepath")) + AxAttachFields.Add(fld.name); + } + else if (fldNode.Name == "a2") + { + string fldCaption = fldNode.InnerText; + fldCaption = fldCaption.Replace("&&", "&"); + fld.caption = fldCaption; + if (fld.caption == "") + fld.caption = " "; + } + else if (fldNode.Name == "a3") + { + fld.datatype = fldNode.InnerText; + if (fldNode.InnerText.ToLower() == "image") + { + ContainsImage = true; + fld.fieldIsImage = true; + AxImageFields.Add(fld.name); + } + } + else if (fldNode.Name == "a4") + fld.fldlength = int.Parse(fldNode.InnerText); + else if (fldNode.Name == "a5") + fld.flddecimal = int.Parse(fldNode.InnerText); + else if (fldNode.Name == "a6") + { + fld.moe = fldNode.InnerText; + if (fldNode.Attributes["apiname"] != null) + fld.fldAcceptApi = fldNode.Attributes["apiname"].Value; + else + fld.fldAcceptApi = ""; + + if (fldNode.Attributes["fromapi"] != null) + fldFromApi = fld.name + "^" + fldNode.Attributes["fromapi"].Value; + } + else if (fldNode.Name == "a7") + fld = UpdateDetailsofMOE(fldNode, fld); + else if (fldNode.Name == "a8") + fld.visibility = bool.Parse(fldNode.InnerText); + else if (fldNode.Name == "a9") + fld.allowempty = bool.Parse(fldNode.InnerText); + else if (fldNode.Name == "a10") + fld.freadonly = bool.Parse(fldNode.InnerText); + else if (fldNode.Name == "a11") + { + if (bool.Parse(fldNode.InnerText) == true) + fldSetCarry.Add(fld.name); + } + else if (fldNode.Name == "a12") + fld.savevalue = bool.Parse(fldNode.InnerText); + else if (fldNode.Name == "a13") + { + fld.expr = fldNode.InnerText.Trim().Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); + if (fldFromApi != "" && fld.expr != "") + { + fldFromApi += "^" + fld.expr; + fld.expr = string.Empty; + } + if (fld.name.ToUpper() == "AXP_HIDE_TOOLBAR") + { + if (fld.expr != string.Empty && fld.expr.Trim('{', '}').ToLower() == "t") + hideToolBar = true; + } + } + else if (fldNode.Name == "a14") + fld.vexpr = fldNode.InnerText.Trim().Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); + else if (fldNode.Name == "a15") + fld.allowduplicate = bool.Parse(fldNode.InnerText); + else if (fldNode.Name == "a16") + fld.onlyPositive = bool.Parse(fldNode.InnerText); + else if (fldNode.Name == "a67") + fld.tabStop = fldNode.InnerText == "" ? true : bool.Parse(fldNode.InnerText); + else if (fldNode.Name == "a17") + fld.savenormal = bool.Parse(fldNode.InnerText); + else if (fldNode.Name == "a49") + fld = PatternCheck(fldNode, fld); + else if (fldNode.Name == "a31") + fld = FldDimensionCheck(fldNode, fld); + else if (fldNode.Name == "a50") + { + if (fldNode.Attributes["minlength"] != null) + fld.pwdminchar = int.Parse(fldNode.Attributes["minlength"].Value); + if (fldNode.Attributes["expirydays"] != null) + fld.pwdnodexpiry = int.Parse(fldNode.Attributes["expirydays"].Value); + if (fldNode.Attributes["alphanumeric"] != null) + fld.pwdalphanumeric = bool.Parse(fldNode.Attributes["alphanumeric"].Value); + + fld.pwdchar = fldNode.InnerText; + } + else if (fldNode.Name == "a51") + fld.fieldHint = fldNode.InnerText; + else if (fldNode.Name == "a52") + fld.applycomma = fldNode.InnerText; + else if (fldNode.Name == "a58") + fld = SetValueFMT(fldNode, fld); + else if (fldNode.Name == "a59") //murali + fld.fieldPurpose = "";// fldNode.InnerText; + else if (fldNode.Name == "a64") + fldSearchSQL = fldNode.InnerText; + else if (fldNode.Name == "a65") + fld = SetTooltip(fldNode, fld); + else if (fldNode.Name == "a66") + fld = SetParents(fldNode, fld); + else if (fldNode.Name == "a70") + fld.tabletypeval = fldNode.InnerText.Replace("\"", """); + if (ContainsGridAttach) + { + if (fldNode.Name == "a13" && fldNode.InnerText != "") + { + ContainsGridRefer = true; + } + } + } + if (fldFromApi != string.Empty) + fldAcceptFromApi.Add(fldFromApi); + //To check if add row limit has been given + if (fld.name.ToLower().Contains("ax_rowlimit")) + { + int rowMaxVal; + string fldExpr = fld.expr.ToString().Replace("{", ""); + fldExpr = fldExpr.Replace("}", ""); + + if (int.TryParse(fldExpr, out rowMaxVal) && rowMaxVal > 1 && !AxRowLimit.Keys.Equals(fld.name)) + AxRowLimit.Add(fld.name.ToLower(), rowMaxVal); + } + + if (listSrchCols != null && listSrchCols.Count > 0) + { + //TODO: check if we can avoid the to lower check + if (listSrchCols.Contains(fld.name.ToLower())) + { + lstSearchDataNames.Add(fld.name); + lstSearchDataCaptions.Add(fld.caption); + } + } + else + { + if ((fld.savevalue == true || (fld.savevalue == false && fldSearchSQL != string.Empty)) && fld.datatype != "Image" && (!fld.visibility) && (fld.pwdchar == "")) + { + lstSearchDataNames.Add(fld.name); + lstSearchDataCaptions.Add(fld.caption); + } + } + + //Update the field count for the dc. + if (!string.IsNullOrEmpty(tstVersion) && Int64.Parse(tstVersion) > 10000) + { + fld = SetRapidDependents(fld); + } + + if (!fld.visibility) + dcFldVisibleCount++; + dcFldCount++; + DcStruct dc = ((DcStruct)(dcs[dcs.Count - 1])); + dc.fieldCount = dcFldCount; + dc.visibleFldCount = dcFldVisibleCount; + dcs[dcs.Count - 1] = dc; + + + if (HttpContext.Current.Session["AxpFldMultiSelect"] != null && HttpContext.Current.Session["AxpFldMultiSelect"].ToString() != "") + { + bool isMultiSelect = false; + var msFldList = (List)HttpContext.Current.Session["AxpFldMultiSelect"]; + isMultiSelect = msFldList.AsEnumerable().Where(x => x.ToString().ToLower() == fld.name.ToLower()).Any(); + if (isMultiSelect) + { + var MultiSelectSp = (List)HttpContext.Current.Session["AxpFldMultiSelSp"]; + MultiSelectSp = MultiSelectSp.AsEnumerable().Where(x => x.ToString().ToLower().Split('♦')[0] == fld.name.ToLower()).Select(x => x.ToString().ToLower().Split('♦')[1]).ToList(); + fld.fldMultiSelect = fld.name; + fld.fldMultiSelectSep = MultiSelectSp[0]; + } + } + + //If field is part of formload exp deps, construct the component id here + if (!string.IsNullOrEmpty(tstVersion) && Int64.Parse(tstVersion) > 10000) + { + UpdateRapidExpCompIds(fld.name, dc); + } + + fld.order = dcFldCount; + fld.fldframeno = dcs.Count; + fld = LoadFieldArray(fld); + flds.Add(fld); + } + + private void UpdateRapidExpCompIds(string fldName, DcStruct dc) + { + if (rapidFLExpFlds.Count == 0) return; + int rIdx = rapidFLExpFlds.IndexOf(fldName); + if (rIdx != -1) + { + string compId = string.Empty; + if (dc.isgrid) + compId = fldName + "001F" + dc.frameno; + else + compId = fldName + "000F" + dc.frameno; + rapidFLExpFlds[rIdx] = compId; + } + } + + private FieldStruct SetParents(XmlNode fldNode, FieldStruct fld) + { + string fmText = ""; + fmText = fldNode.InnerText.ToString(); + string[] depArray = null; + if (fmText != "") + depArray = fmText.Split(','); + + if (depArray != null) + { + for (int i = 0; i < depArray.Length; i++) + { + if (fld.fieldParents == null || fld.fieldParents == "") + fld.fieldParents = depArray[i].ToString(); + else + fld.fieldParents += "," + depArray[i].ToString(); + } + } + fld.fieldParents = cust.UpdateSqlGridParents(transId, fld.name, fld.fieldParents); + string flParents = fld.fieldParents; + fld.fieldParents = fld.fieldParents.Replace("~", ","); + if (flParents != "" && flParents.Contains("~")) + fld.ClientFldParents = flParents.Split('~')[0]; + else + fld.ClientFldParents = fld.fieldParents; + return fld; + } + + /// + /// function to update the javascript field array. + /// + /// + private FieldStruct LoadFieldArray(FieldStruct fld) + { + StringBuilder fieldArray = new StringBuilder(); + if (((fld.datatype == "Numeric") && (fld.flddecimal > 0))) + fld.fldlength = (int)fld.fldlength + 1; + + fldGlobal = fldNo; + + if (fldNo == 0) + { + dcNo = ((DcStruct)(dcs[dcs.Count - 1])).frameno; + dcRange = fldNo.ToString(); + } + string allowEmpty = ""; + if (fld.allowempty == true) allowEmpty = "T"; + else allowEmpty = "F"; + string applyComma = ""; + if (fld.applycomma.ToLower() == "true") applyComma = "T"; + else applyComma = "F"; + string visible = ""; + if (fld.visibility == true) visible = "T"; + else visible = "F"; + string onlyPositive = ""; + if (fld.onlyPositive == true) onlyPositive = "T"; + else onlyPositive = "F"; + string tabStop = ""; + if (fld.tabStop == true) tabStop = "T"; + else tabStop = "F"; + + fieldArray.Append(" FNames[" + fldNo + "]=\"" + fld.name + "\";ExprPosArray[" + fldNo + "]=\"\";FLowerNames[" + fldNo + "]=\"" + fld.name.ToLower() + "\"; FDataType[" + fldNo + "]=\"" + fld.datatype + "\"; FTableTypeVal[" + fldNo + "]=\"" + fld.tabletypeval + "\"; FDecimal[" + fldNo + "]=\"" + fld.flddecimal + "\";FldValidateExpr[" + fldNo + "]=\"" + fld.vexpr.Replace("\"", "'") + "\";FDupDecimals[" + fldNo + "]=\"" + fld.flddecimal + "\";"); + fieldArray.Append("FCaption[" + fldNo + "]=\"" + fld.caption + "\";FldsFrmLst[" + fldNo + "]=\"" + fld.fieldIsFrmList + "\";"); + fieldArray.Append("FMoe[" + fldNo + "]=\"" + fld.moe + "\";"); + fieldArray.Append("FMaxLength[" + fldNo + "]=\"" + fld.fldlength + "\";"); + fieldArray.Append("FProps[" + fldNo + "]=\"" + applyComma + allowEmpty + visible + onlyPositive + tabStop + "\";"); + fieldArray.Append("FldFrameNo[" + fldNo + "]=\"" + ((DcStruct)(dcs[dcs.Count - 1])).frameno + "\";"); + fieldArray.Append("FToolTip[" + fldNo + "]=\"" + fld.tooltip + "\";"); + fieldArray.Append("fDefList[" + fldNo + "]=\"" + fld.slist + "\";fExdefList[" + fldNo + "]=\"" + fld.elist + "\";ffillList[" + fldNo + "]=\"" + fld.flist + "\";fSfList[" + fldNo + "]=\"" + fld.sflist + "\";"); + + fieldArray.Append("FldDependents[" + fldNo + "]=\"" + fld.fieldDependents + "\";"); + fieldArray.Append("FldParents[" + fldNo + "]=\"" + fld.fieldParents + "\";"); + fieldArray.Append("ClientFldParents[" + fldNo + "]=\"" + fld.ClientFldParents + "\";"); + fieldArray.Append("FldAutoSelect[" + fldNo + "]=\"" + fld.autoselect + "\";"); + fieldArray.Append("FldIsSql[" + fldNo + "]=\"" + fld.isFieldSql + "\";"); + fieldArray.Append("FldIsAPI[" + fldNo + "]=\"" + fld.isFieldApi + "\";"); + fieldArray.Append("FldAlignType[" + fldNo + "]=\"" + fld.type + "\";"); + fieldArray.Append("FldChkSeparator[" + fldNo + "]=\"" + fld.fieldValSeparator + "\";"); + fieldArray.Append("FldMgsSeparator[" + fldNo + "]=\"" + fld.fldMultiSelectSep + "\";"); + fieldArray.Append("FFieldType[" + fldNo + "]=\"" + fld.fldType + "\";"); + fieldArray.Append("FFieldAcceptApi[" + fldNo + "]=\"" + fld.fldAcceptApi + "\";"); + + //Rapid field arrays + fieldArray.Append("FldRapidDeps[" + fldNo + "]=\"" + fld.FldRapidDeps + "\";"); + fieldArray.Append("FldRapidDepType[" + fldNo + "]=\"" + fld.FldRapidDepType + "\";"); + fieldArray.Append("FldRapidExpDeps[" + fldNo + "]=\"" + fld.FldRapidExpDeps + "\";"); + fieldArray.Append("FldRapidParents[" + fldNo + "]=\"" + fld.FldRapidParents + "\";"); + fieldArray.Append("FldPurpose[" + fldNo + "]=\"" + utilObj.CheckSpecialCharacterPurpose(fld.fieldPurpose) + "\";"); + + if (dcNo != ((DcStruct)(dcs[dcs.Count - 1])).frameno || DcCnt == dcs.Count) + { + dcRange = dcRange + "," + (fldNo - 1).ToString(); + fieldArray.Append("FldDcRange[" + DcCnt + "]=\"" + dcNo.ToString() + "~" + dcRange + "\";"); + fldDcRange.Add(dcNo.ToString() + "~" + dcRange); + dcRange = ""; + DcCnt++; + dcNo = ((DcStruct)(dcs[dcs.Count - 1])).frameno; + dcRange = fldNo.ToString(); + } + + if (!((DcStruct)(dcs[dcs.Count - 1])).isgrid) + { + fieldArray.Append("HTMLFldNames[" + fldNo + "]=\"" + fld.name + "000F0\";"); + } + else + { + fieldArray.Append("HTMLFldNames[" + fldNo + "]=\"" + fld.name + "001F" + ((DcStruct)(dcs[dcs.Count - 1])).frameno + "\";"); + grfldNo++; + } + fldNo++; + jsFieldArray.Append(fieldArray.ToString().Trim()); + + string gridType = string.Empty; + string gridNo = string.Empty; + if (((DcStruct)(dcs[dcs.Count - 1])).isgrid) + { + gridType = "GR."; + gridNo = "F" + ((DcStruct)(dcs[dcs.Count - 1])).frameno; + } + else + { + gridType = "NG."; + gridNo = "F0"; + } + + if (!string.IsNullOrEmpty(fld.expr)) + { + string tempExpr; + if ((fld.name.StartsWith("dc") && (fld.name.ToLower().EndsWith("_referimages") || fld.name.ToLower().EndsWith("_image") || fld.name.ToLower().EndsWith("_imagepath"))) && fld.expr.Contains(@"\") || fld.name == "axpattachmentpath") + tempExpr = fld.expr.Replace(@"\", "\\\\"); // In order to avoid the skipping of backslash + else if (fld.name.ToLower().StartsWith("axpfilepath_")) + tempExpr = fld.expr.Replace(@"\", "\\\\\\\\"); + else + tempExpr = fld.expr.Replace("\"", "'"); + jsExpressionArray.Append(" ExpFldNames[" + exprNo + "]=\"" + gridType + "" + fld.name + "." + gridNo + ".expr\";Expressions[" + exprNo + "]=\"" + tempExpr + "\";"); + exprNo++; + } + + return fld; + } + + private string GetFldDependents(string result, string depList) + { + if (depList != null) + { + if (result == "") + result = depList; + else if (depList != "") + result += "," + depList; + } + return result; + } + + /// + ///function to create and append javascript arrays for handling load single dc data for tabbed dc's + /// + public void CreateTabArrays() + { + for (int i = 0; i < tabDCs.Count; i++) + { + if (tabDCs[i].ToString() != "" && tabDCStatus[i].ToString() != "") + { + jsTabDCArray.Append("TabDCs[" + i + "]=\"" + tabDCs[i].ToString() + "\";TabDCStatus[" + i + "]=\"" + tabDCStatus[i] + "\";"); + } + else + { + break; + } + } + + for (int j = 0; j < pagePositions.Count; j++) + { + jsTabDCArray.Append("PagePositions[" + j + "]=\"" + pagePositions[j].ToString() + "\";VisibleDCs[" + j + "]=\"" + visibleDCs[j] + "\";"); + } + } + + /// + /// function to handle the pattern for the field values. + /// + /// + /// + private FieldStruct PatternCheck(XmlNode patternNode, FieldStruct fld) + { + fld.pattern = patternNode.InnerText; + + string patName = string.Empty; + if (!((DcStruct)(dcs[dcs.Count - 1])).isgrid) + patName = "ng_" + fld.name; + else + patName = "gr_" + fld.name; + if (!string.IsNullOrEmpty(fld.pattern)) + { + jsPatternArray.Append("PatternNames[" + patternNo + "]='" + patName + "';Patterns[" + patternNo + "]='" + fld.pattern + "';"); + patternNo++; + } + + return fld; + } + + /// + /// Update the dimensions of the field. + /// + /// + /// + private FieldStruct FldDimensionCheck(XmlNode dimensionNode, FieldStruct fld) + { + if (dimensionNode.Attributes["lbltlhw"] != null) + fld.lbltlhw = dimensionNode.Attributes["lbltlhw"].Value.ToString(); + else + fld.lbltlhw = ""; + + if (dimensionNode.Attributes["lblfont"] != null) + fld.fieldLabelCss = dimensionNode.Attributes["lblfont"].Value.ToString(); + else + fld.fieldLabelCss = ""; + + if (dimensionNode.Attributes["font"] != null) + fld.fieldCtrlCss = dimensionNode.Attributes["font"].Value.ToString(); + else + fld.fieldCtrlCss = ""; + + if (dimensionNode.Attributes["tlhw"] != null) + fld.fldtlhw = dimensionNode.Attributes["tlhw"].Value.ToString(); + else + fld.fldtlhw = ""; + + if (dimensionNode.Attributes["wlbltlhw"] != null) + fld.plbltlhw = dimensionNode.Attributes["wlbltlhw"].Value.ToString(); + else + fld.plbltlhw = ""; + if (dimensionNode.Attributes["wtlhw"] != null) + fld.pfldtlhw = dimensionNode.Attributes["wtlhw"].Value.ToString(); + else + fld.pfldtlhw = ""; + + if (dimensionNode.Attributes["ctype"] != null) + fld.ctype = dimensionNode.Attributes["ctype"].Value.ToString(); + else + fld.ctype = ""; + + if (dimensionNode.Attributes["sep"] != null) + fld.fieldValSeparator = dimensionNode.Attributes["sep"].Value.ToString(); + + + if (dimensionNode.Attributes["cwid"] != null) + fld.cwid = dimensionNode.Attributes["cwid"].Value.ToString(); + else + fld.cwid = ""; + + if (dimensionNode.Attributes["type"] != null) + fld.type = dimensionNode.Attributes["type"].Value.ToString(); + else + fld.type = ""; + + if (dimensionNode.Attributes["color"] != null) + { + fld.fldColor = dimensionNode.Attributes["color"].Value; + if (fld.fldColor != string.Empty) + { + fld.fldColor = fld.fldColor.Substring(2); + } + } + else + fld.fldColor = ""; + + return fld; + } + + /// + /// Set the tooltip from the xml to tooltip variable of the field structure + /// + /// + /// + /// + private FieldStruct SetTooltip(XmlNode fldNodes, FieldStruct fld) + { + foreach (XmlNode tlNode in fldNodes) + { + fld.tooltip += tlNode.InnerText + "/"; + } + return fld; + } + + /// + /// function to update sql,expression and fill dependent list. + /// + /// + /// + private FieldStruct SetValueFMT(XmlNode fmtNodes, FieldStruct fld) + { + fld.fieldDependents = string.Empty; + foreach (XmlNode fmtNode in fmtNodes) + { + string fmText = ""; + fmText = fmtNode.InnerText.ToString(); + if (fmText != "") + fld.fieldDependents += fmText; + } + //string strNewDeps = utilObj.IncludeDependents(transId, fld.name, fld.fieldDependents); + //strNewDeps = utilObj.ExcludeDependents(transId, fld.name, strNewDeps); + //fld.fieldDependents = strNewDeps; + string fldDeps = GetSqlDependents(fld); + string[] strDeps = fldDeps.Split('~'); + fld.fieldSqlDeps = strDeps[0].ToString(); + if (strDeps.Length > 1) + fld.fieldExpDeps = strDeps[1].ToString(); + + return fld; + } + + /// + /// Function which returns the sql dependents for a given field. + /// + /// + /// + private string GetSqlDependents(FieldStruct fld) + { + string fldDeps = fld.fieldDependents; + StringBuilder sqlDepFlds = new StringBuilder(); + StringBuilder sqlExpFlds = new StringBuilder(); + if (fldDeps != string.Empty) + { + string[] deps = fldDeps.Split(','); + for (int i = 0; i < deps.Length; i++) + { + string depStr = deps[i].ToString(); + + //|| depStr.Substring(0,1) == "f" - NOTE - here fill dependents have not been added to the sql dep list + if (depStr.Substring(0, 1) == "s") + { + if (sqlDepFlds.ToString() == string.Empty) + sqlDepFlds.Append(depStr); + else + sqlDepFlds.Append("," + depStr); + } + else if (depStr.Substring(0, 1) == "e") + { + if (sqlExpFlds.ToString() == string.Empty) + sqlExpFlds.Append(depStr); + else + sqlExpFlds.Append("," + depStr); + } + + } + } + + return sqlDepFlds.ToString() + "~" + sqlExpFlds.ToString(); + } + + /// + /// Update the moe details from the a7 node + /// + /// + /// + private FieldStruct UpdateDetailsofMOE(XmlNode moeDetailNodes, FieldStruct fld) + { + StringBuilder hashString = new StringBuilder(); + bool isUpdate = false; + ArrayList a26Array = new ArrayList(); + ArrayList a26ArrayType = new ArrayList(); + ArrayList a63Array = new ArrayList(); + ArrayList a63ArrayType = new ArrayList(); + string tmpMOE = fld.moe.ToUpper(); + if (tmpMOE == moe.ACCEPT.ToString() || tmpMOE == moe.SELECT.ToString() || tmpMOE == moe.FILL.ToString()) + isUpdate = true; + + if (isUpdate) + { + foreach (XmlNode moeDetailNode in moeDetailNodes) + { + if (tmpMOE == moe.ACCEPT.ToString()) + { + if (moeDetailNode.Name == "a22") + { + if (!string.IsNullOrEmpty(moeDetailNode.InnerText)) + fld.selectmode = "From Master"; + else + fld.selectmode = string.Empty; + + if (moeDetailNode.Attributes["pcount"] != null) + fld.pcount = int.Parse(moeDetailNode.Attributes["pcount"].Value); + else + fld.pcount = 0; + + if (moeDetailNode.ChildNodes.Count > 0 && fld.pcount == 0) + { + if (moeDetailNode.ChildNodes.Count == 1 && moeDetailNode.ChildNodes[0].InnerXml != "") + { + if (fromListFlds == "") + fromListFlds = fld.name; + else + fromListFlds += "," + fld.name; + } + } + if (moeDetailNode.ChildNodes.Count > 0 && moeDetailNode.ChildNodes[0].InnerText != "") + fld.isFieldSql = "True"; + + if (moeDetailNode.Attributes["stype"] != null && moeDetailNode.Attributes["stype"].Value.ToLower() == "accept") + { + if (moeDetailNode.Attributes["url"] != null) + fld.fieldSelAPI = moeDetailNode.Attributes["url"].Value; + if (moeDetailNode.Attributes["mapname"] != null) + fld.fieldSelAPIParams = moeDetailNode.Attributes["mapname"].Value; + if (moeDetailNode.Attributes["restype"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["restype"].Value; + if (moeDetailNode.Attributes["resformat"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["resformat"].Value; + if (moeDetailNode.Attributes["paramstr"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["paramstr"].Value; + if (moeDetailNode.Attributes["headerstr"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["headerstr"].Value; + if (moeDetailNode.Attributes["reqstr"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["reqstr"].Value; + } + } + } + else if (tmpMOE == moe.SELECT.ToString()) + { + if (moeDetailNode.Name == "a22") + { + if (moeDetailNode.Attributes["param"] != null) + { + if (moeDetailNode.Attributes["param"].Value == "y") + fld.refresh = 1; + else + fld.refresh = 0; + } + + if (moeDetailNode.Attributes["txt"] != null) + { + if (moeDetailNode.Attributes["txt"].Value == "t") + fld.editcombo = true; + else + fld.editcombo = false; + } + + if (moeDetailNode.Attributes["firesql"] != null) + { + if (moeDetailNode.Attributes["firesql"].Value == "True") + fld.firesql = true; + else + fld.firesql = false; + } + + if (fld.firesql) + fld.selectmode = string.Empty; + else + fld.selectmode = "From Master"; + + if (moeDetailNode.Attributes["pcount"] != null) + fld.pcount = int.Parse(moeDetailNode.Attributes["pcount"].Value); + else + fld.pcount = 0; + + if (moeDetailNode.Attributes["mulselect"] != null && moeDetailNode.Attributes["mulselect"].Value == "true") + fld.fldMultiSelect = fld.name; + if (moeDetailNode.Attributes["mulsep"] != null) + fld.fldMultiSelectSep = moeDetailNode.Attributes["mulsep"].Value; + + if (moeDetailNode.ChildNodes.Count > 0 && moeDetailNode.ChildNodes[0].InnerText != "") + fld.isFieldSql = "True"; + for (int i = 0; i < moeDetailNode.ChildNodes.Count; i++) + { + fld.fieldSqlQuery += " " + moeDetailNode.ChildNodes[i].InnerText; + } + if (moeDetailNode.Attributes["stype"] != null && moeDetailNode.Attributes["stype"].Value == "Select From API") + { + fld.isFieldApi = "true"; + if (moeDetailNode.Attributes["url"] != null) + fld.fieldSelAPI = moeDetailNode.Attributes["url"].Value; + if (moeDetailNode.Attributes["mapname"] != null) + fld.fieldSelAPIParams = moeDetailNode.Attributes["mapname"].Value; + if (moeDetailNode.Attributes["restype"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["restype"].Value; + if (moeDetailNode.Attributes["resformat"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["resformat"].Value; + if (moeDetailNode.Attributes["paramstr"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["paramstr"].Value; + if (moeDetailNode.Attributes["headerstr"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["headerstr"].Value; + if (moeDetailNode.Attributes["reqstr"] != null) + fld.fieldSelAPIParams += "♠" + moeDetailNode.Attributes["reqstr"].Value; + } + } + else if (moeDetailNode.Name == "a23") + { + fld.autoselect = moeDetailNode.InnerText; + } + else if (moeDetailNode.Name == "a24") + { + fld.refreshOnSave = moeDetailNode.InnerText; + } + else if (moeDetailNode.Name == "a25") + { + foreach (XmlNode selectNodes in moeDetailNode) + { + if (fld.moeval == "") + fld.moeval = selectNodes.InnerText; + else + fld.moeval += "," + selectNodes.InnerText; + } + + if (fld.moeval != "" && fld.moeval != null) + { + if (fromListFlds == "") + fromListFlds = fld.name; + else + fromListFlds += "," + fld.name; + fld.fieldIsFrmList = true; + + } + else + fld.fieldIsFrmList = false; + } + } + else if (tmpMOE == moe.FILL.ToString()) + { + if (moeDetailNode.Name == "a27") + fld.srcfld = moeDetailNode.InnerText; + else if (moeDetailNode.Name == "a28") + fld.sqlfld = moeDetailNode.InnerText; + + } + + if (moeDetailNode.Name == "a26") + { + if ((moeDetailNode.Attributes["stype"] != null)) + { + if (moeDetailNode.Attributes["stype"].Value == "tstruct" | moeDetailNode.Attributes["stype"].Value == "sql") + { + a26Array.Add(fld.caption); + a26ArrayType.Add(fld.datatype); + } + } + } + else if (moeDetailNode.Name == "a63") + { + foreach (XmlNode cnNode in moeDetailNode) + { + if ((cnNode.Attributes["cn"] != null)) + { + a63Array.Add(cnNode.Attributes["cn"].Value.Trim()); + a63ArrayType.Add(""); + } + } + } + + + } + //fld.AdvSrchFlds + if (a63Array.Count == 0) + { + fld.AdvSrchFlds = a26Array; + fld.AdvSrchFldsType = a26ArrayType; + } + else + { + fld.AdvSrchFlds = a63Array; + fld.AdvSrchFldsType = a63ArrayType; + } + } + return fld; + } + + /// + /// Update the fillgrid list. + /// + /// + private void XmlLoadFillgrid(XmlNode fgNodes) + { + FGStruct fg = new FGStruct(); + StringBuilder fgsql = new StringBuilder(); + foreach (XmlNode fgNode in fgNodes) + { + if (fgNode.Name == "a1") + { + fg.fgName = fgNode.InnerText; + + } + else if (fgNode.Name == "a4") + { + fg.fgcaption = fgNode.InnerText; + } + else if (fgNode.Name == "a5") + { + fgsql.Append(fgNode.Attributes["plist"].Value.ToString() + ""); + fg.fgSqlParams = fgsql.ToString(); + } + else if (fgNode.Name == "a6") + { + fg.fgtargetdc = fgNode.InnerText; + } + else if (fgNode.Name == "a7") + { + fg.fgSqlFldName = new ArrayList(); + fg.fgDcFldName = new ArrayList(); + foreach (XmlNode mapNode in fgNode) + { + fg.fgDcFldName.Add(mapNode.Name); + fg.fgSqlFldName.Add(mapNode.InnerText.ToLower()); + } + } + else if (fgNode.Name == "a8") + { + fg.fgmultiselect = fgNode.InnerText; + } + else if (fgNode.Name == "a9") + { + fg.fgautoshow = fgNode.InnerText; + } + else if (fgNode.Name == "a10") + { + fg.fgSourceDC = fgNode.InnerText; + } + else if (fgNode.Name == "a17") + { + fg.fgValExpression = fgNode.InnerText; + } + else if (fgNode.Name == "a13" && fgNode.InnerText.ToLower() == "true") + { + fg.FGExecOnSave = fg.fgtargetdc; + } + else if (fgNode.Name == "a18") + { + if (fgNode.InnerText == "Initialize grid and add") + fg.FGCondition = Constants.INIT; + else if (fgNode.InnerText == "Add only when grid is empty") + fg.FGCondition = Constants.AOWE; + else if (fgNode.InnerText == "Append selected rows to grid" || fgNode.InnerText == "Append rows to grid") + fg.FGCondition = Constants.APPEND; + } + } + fgs.Add(fg); + jsFieldArray.Append("FillAutoShow[" + fgCount + "]=\"" + ((FGStruct)(fgs[fgCount])).fgautoshow.ToString().ToLower() + "\";FillMultiSelect[" + fgCount + "]=\"" + ((FGStruct)(fgs[fgCount])).fgmultiselect.ToString().ToLower() + "\";FillParamDCs[" + fgCount + "]=\"" + ((FGStruct)(fgs[fgCount])).fgtargetdc.ToString() + "\";FillParamFld[" + fgCount + "]=\"" + ((FGStruct)(fgs[fgCount])).fgSqlParams.ToString() + "\";FillCondition[" + fgCount + "]=\"" + fg.FGCondition + "\";FillSourceDc[" + fgCount + "]=\"" + fg.fgSourceDC + "\";FillGridName[" + fgCount + "]=\"" + fg.fgName + "\";FillGridVExpr[" + fgCount + "]=\"" + fg.fgValExpression + "\";FillGridExecOnSave[" + fgCount + "]=\"" + fg.FGExecOnSave + "\";"); + fgCount++; + + } + + /// + /// Function to construct the Action buttons in the tstruct. + /// + /// + /// + private void XmlPageLoadButton(XmlNode btnNodes, string btnType) + { + if ((btnNodes.Attributes["cat"] != null) && (btnNodes.Attributes["cat"].Value == "btn")) + { + string caption = string.Empty; + string task = string.Empty; + string action = string.Empty; + string hint = string.Empty; + string dimension = string.Empty; + string btnTop = string.Empty; + string btnLeft = string.Empty; + string btnHeight = string.Empty; + string btnWidth = string.Empty; + string image = string.Empty; + string fileupload = string.Empty; + string cancelBtn = string.Empty; + string fmessage = string.Empty; + string ftype = string.Empty; + string btnId = string.Empty; + string position = string.Empty; + + int frameNo = 0; + if (btnNodes.Attributes["parent"] != null) + { + frameNo = Convert.ToInt32(btnNodes.Attributes["parent"].Value.Substring(3)); + } + + caption = btnNodes.Attributes["caption"].Value; + task = btnNodes.Attributes["task"].Value; + action = btnNodes.Attributes["action"].Value; + hint = btnNodes.Attributes["hint"].Value; + dimension = btnNodes.Attributes["tlhw"].Value; + image = btnNodes.Attributes["img"].Value; + position = btnNodes.Attributes["position"].Value; + if (btnNodes.Attributes["fileupload"] != null) + { + fileupload = btnNodes.Attributes["fileupload"].Value; + if (btnNodes.Attributes["fmsg"] != null) + fmessage = btnNodes.Attributes["fmsg"].Value; + if (btnNodes.Attributes["ftype"] != null) + ftype = btnNodes.Attributes["ftype"].Value; + } + + if (btnNodes.Attributes["rem"] != null) + { + cancelBtn = btnNodes.Attributes["rem"].Value; + } + string divDirection = "left"; + if (HttpContext.Current.Session["language"].ToString() == "ARABIC") + { + divDirection = "right"; + } + btnId = btnNodes.Name; + + if (dimension != string.Empty) + { + string[] tlhw = dimension.Split(','); + if (EnableOldTheme == "true") + btnTop = Math.Floor((Convert.ToInt32(tlhw[0].ToString()) * 1.2)).ToString() + "px"; + else + btnTop = Math.Floor((Convert.ToInt32(tlhw[0].ToString()) * 1.5)).ToString() + "px"; + btnLeft = tlhw[1].ToString() + "px"; + btnHeight = tlhw[2].ToString() + "px"; + btnWidth = tlhw[3].ToString() + "px"; + FieldStruct dummy = new FieldStruct(); + dummy.visibility = false; + dummy.fldlength = 15; + dummy.fldFrameNo = frameNo; + dummy.ctype = "button"; + dummy.datatype = "special"; + dummy.name = btnId; + + if (action != "") + { + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append("
    "); + // btnHtml.Append(""); + string btnFunction = string.Empty; + + if (!string.IsNullOrEmpty(fileupload)) + { + if (fileupload == "y") + { + btnFunction = " onclick='javascript:CallFileUploadAction(" + (char)34 + action + (char)34 + "," + (char)34 + fmessage + (char)34 + "," + (char)34 + ftype + (char)34 + ");' "; + if (string.IsNullOrEmpty(image)) + btnHtml.Append(""); + else + btnHtml.Append("" + caption + ""); + } + else if (fileupload == "a") + { + btnFunction = " onclick='javascript:AttachFiles();' "; + if (string.IsNullOrEmpty(image)) + btnHtml.Append(""); + else + btnHtml.Append("" + caption + ""); + } + else + { + if ((fileupload.IndexOf("\\") != -1)) + { + fileupload = fileupload.Replace("\\", "\\\\"); + } + btnFunction = " onclick='javascript:CallAction(" + (char)34 + action + (char)34 + "," + (char)34 + fileupload + (char)34 + ");' "; + if (string.IsNullOrEmpty(image)) + btnHtml.Append("
    "); + else + btnHtml.Append("" + caption + ""); + } + } + else + { + btnFunction = " onclick='javascript:CallAction(" + (char)34 + action + (char)34 + "," + (char)34 + fileupload + (char)34 + "," + (char)34 + string.Empty + (char)34 + "," + (char)34 + cancelBtn + (char)34 + ");' "; + if (!string.IsNullOrEmpty(caption) && !string.IsNullOrEmpty(image)) + { + //Display Image with caption as hint. + //btnHtml.Append("" + caption + ""); + btnHtml.Append("" + caption + ""); + } + else if (!string.IsNullOrEmpty(image) && string.IsNullOrEmpty(caption)) + { + //Display only image + //btnHtml.Append("" + hint + ""); + btnHtml.Append("" + caption + ""); + } + else if (!string.IsNullOrEmpty(caption) & string.IsNullOrEmpty(image)) + { + //Display button with Caption + btnHtml.Append("
    "); + } + else + { + //throw error + btnHtml.Append(""); + } + } + btnHtml.Append("
    "); + } + else if (task != "tasks") + { + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append("
    "); + + string btnFunction = string.Empty; + btnFunction = GetBtnFunction(transId, task); + + //TODO: provide the button like any other case, on click it should alert "No task defined" + //This button can be added for customisation, hence need not display the above.\ + if (string.IsNullOrEmpty(image)) + btnHtml.Append("
    "); + else + btnHtml.Append("" + caption + ""); + btnHtml.Append("
    "); + } + } + + pageActionButtons.Add(btnHtml.ToString()); + pageActionDcNo.Add(dcs.Count.ToString()); + btnHtml = new StringBuilder(); + } + } + + private void XmlPageLoadDWBButton(XmlDocument FormBtnNodes, int frameNo) + { + XmlNodeList formbtnlst = FormBtnNodes.SelectNodes("//root/dc" + frameNo); + if (formbtnlst.Count > 0) + { + string colFldWidth = "", colFldGridStackItem = "", colDivInputPadding = ""; + if (axdesignJObject.dcLayout != null && axdesignJObject.dcLayout != "" && axdesignJObject.dcLayout != "default") + { + colFldWidth = "
    "; + colFldGridStackItem = " colFldGridStackWidth "; + colDivInputPadding = " colDivInputPadding "; + } + foreach (XmlNode formbtns in formbtnlst) + { + foreach (XmlNode btnNodes in formbtns) + { + XmlNode ficonNode = btnNodes.SelectSingleNode("icon"); + if ((btnNodes.Attributes["cat"] != null) && (btnNodes.Attributes["cat"].Value == "btn")) + { + string caption = string.Empty; + string task = string.Empty; + string action = string.Empty; + string hint = string.Empty; + string dimension = string.Empty; + string btnTop = string.Empty; + string btnLeft = string.Empty; + string btnHeight = string.Empty; + string btnWidth = string.Empty; + string image = string.Empty; + string fileupload = string.Empty; + string cancelBtn = string.Empty; + string fmessage = string.Empty; + string ftype = string.Empty; + string btnId = string.Empty; + string position = string.Empty; + bool isGridBtn = false; + string gridBtnPosition = string.Empty; + bool script = false; + + caption = btnNodes.Attributes["caption"].Value; + task = btnNodes.Attributes["task"].Value; + action = btnNodes.Attributes["action"].Value; + hint = btnNodes.Attributes["hint"].Value; + dimension = btnNodes.Attributes["tlhw"].Value; + image = btnNodes.Attributes["img"].Value; + position = btnNodes.Attributes["position"].Value; + script = btnNodes.Attributes["script"].Value.ToLower() == "true" ? true : false; + string iconStyle = string.Empty; + + if (ficonNode != null) + { + if (ficonNode.SelectSingleNode("text") != null) + { + string ictext = ficonNode.SelectSingleNode("text").InnerText; + string icaddclass = ficonNode.SelectSingleNode("addClass").InnerText; + iconStyle = "" + ictext + ""; + } + else + { + iconStyle = ""; + } + } + + if (position.Split('~').Length > 1) + { + isGridBtn = true; + gridBtnPosition = position.Split('~')[1]; + } + + if (btnNodes.Attributes["fileupload"] != null) + { + fileupload = btnNodes.Attributes["fileupload"].Value; + if (btnNodes.Attributes["fmsg"] != null) + fmessage = btnNodes.Attributes["fmsg"].Value; + if (btnNodes.Attributes["ftype"] != null) + ftype = btnNodes.Attributes["ftype"].Value; + } + + if (btnNodes.Attributes["rem"] != null) + { + cancelBtn = btnNodes.Attributes["rem"].Value; + } + string divDirection = "left"; + if (HttpContext.Current.Session["language"].ToString() == "ARABIC") + { + divDirection = "right"; + } + btnId = btnNodes.Name; + string designFontStyle = ""; + if (axdesignJObject.buttonFieldFont != null && axdesignJObject.buttonFieldFont.Count > 0 && btnId != "") + { + var frbtnfld = axdesignJObject.buttonFieldFont.Where(elm => elm.id == btnId).ToList(); + if (frbtnfld != null && frbtnfld.Count > 0) + { + designFontStyle = " style='" + frbtnfld[0].fontFamilly + "'"; + } + } + if (dimension != string.Empty) + { + string[] tlhw = dimension.Split(','); + if (EnableOldTheme == "true") + btnTop = Math.Floor((Convert.ToInt32(tlhw[0].ToString()) * 1.2)).ToString() + "px"; + else + btnTop = Math.Floor((Convert.ToInt32(tlhw[0].ToString()) * 1.5)).ToString() + "px"; + btnLeft = tlhw[1].ToString() + "px"; + btnHeight = tlhw[2].ToString() + "px"; + btnWidth = tlhw[3].ToString() + "px"; + FieldStruct dummy = new FieldStruct(); + dummy.visibility = false; + dummy.fldlength = 15; + dummy.fldFrameNo = frameNo; + dummy.ctype = "button"; + dummy.datatype = "special"; + dummy.name = btnId; + if (!isGridBtn) + { + if (action != "" && action != "Custom") + { + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append(colFldWidth); + btnHtml.Append("
    "); + string btnFunction = string.Empty; + + if (!string.IsNullOrEmpty(fileupload)) + { + if (fileupload == "y") + { + btnFunction = " onclick='javascript:CallFileUploadAction(" + (char)34 + action + (char)34 + "," + (char)34 + fmessage + (char)34 + "," + (char)34 + ftype + (char)34 + ");' "; + if (string.IsNullOrEmpty(image)) + btnHtml.Append("" + iconStyle + "" + caption + ""); + else + btnHtml.Append("" + caption + ""); + } + else if (fileupload == "a") + { + btnFunction = " onclick='javascript:AttachFiles();' "; + if (string.IsNullOrEmpty(image)) + btnHtml.Append("" + iconStyle + "" + caption + ""); + else + btnHtml.Append("" + caption + ""); + } + else + { + if ((fileupload.IndexOf("\\") != -1)) + { + fileupload = fileupload.Replace("\\", "\\\\"); + } + btnFunction = " onclick='javascript:CallAction(\"" + action + "\",\"" + fileupload + "\",\"\",\"\",\"\",\"\",\"" + script.ToString().ToLower() + "\");' "; + if (string.IsNullOrEmpty(image)) + btnHtml.Append(""); + else + btnHtml.Append("" + caption + ""); + } + } + else + { + btnFunction = " onclick='javascript:CallAction(\"" + action + "\",\"" + fileupload + "\",\"\",\"" + cancelBtn + "\",\"\",\"\",\"" + script.ToString().ToLower() + "\");' "; + if (!string.IsNullOrEmpty(caption) && !string.IsNullOrEmpty(image)) + { + //Display Image with caption as hint. + btnHtml.Append("" + caption + ""); + } + else if (!string.IsNullOrEmpty(image) && string.IsNullOrEmpty(caption)) + { + //Display only image + btnHtml.Append("" + caption + ""); + } + else if (!string.IsNullOrEmpty(caption) & string.IsNullOrEmpty(image)) + { + //Display button with Caption + btnHtml.Append(""); + } + else + { + //throw error + btnHtml.Append(""); + } + } + if (colFldWidth != "") + btnHtml.Append("
    "); + btnHtml.Append("
    "); + } + else if (action == "Custom") + { + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append(colFldWidth); + btnHtml.Append("
    "); + + string btnFunction = string.Empty; + btnFunction = " onclick='javascript:" + btnId + "onclick();' "; + if (string.IsNullOrEmpty(image)) + //btnHtml.Append("" + iconStyle + "" + caption + ""); + btnHtml.Append(""); + else + btnHtml.Append("" + caption + ""); + if (colFldWidth != "") + btnHtml.Append("
    "); + btnHtml.Append("
  • "); + } + else if (task != "tasks") + { + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append("
    "); + btnHtml.Append(colFldWidth); + btnHtml.Append("
    "); + + string btnFunction = string.Empty; + btnFunction = GetBtnFunction(transId, task); + + //TODO: provide the button like any other case, on click it should alert "No task defined" + //This button can be added for customisation, hence need not display the above.\ + if (string.IsNullOrEmpty(image)) + btnHtml.Append(""); + else + btnHtml.Append("" + caption + ""); + if (colFldWidth != "") + btnHtml.Append("
    "); + btnHtml.Append("
    "); + } + } + else + { + if (gridBtnPosition == "rowlevel") + { + string btnFunction = string.Empty; + if (action == "Custom") + btnFunction = " onclick='javascript:" + btnId + "onclick(this);' "; + else + btnFunction = " onclick=javascript:CallAction('" + action + "','','','','','','" + script.ToString().ToLower() + "'); "; + string gsbtn = "" + caption + ""; + gridScriptButtons.Add("
    ♠
    " + gsbtn + "
    ♠
    1
    " + gsbtn + "
    "); + gridScriptDcNo.Add(dcs.Count.ToString()); + } + else if (gridBtnPosition == "headerlevel") + { + string btnFunction = string.Empty; + if (action == "Custom") + btnFunction = " onclick='javascript:" + btnId + "onclick();' "; + else + btnFunction = " onclick=javascript:CallAction('" + action + "','','','','','','" + script.ToString().ToLower() + "'); "; + gridHeaderScriptButtons.Add("check_box_outline_blank"); + gridHeaderScriptDcNo.Add(dcs.Count.ToString()); + } + } + } + + pageActionButtons.Add(btnHtml.ToString()); + pageActionDcNo.Add(dcs.Count.ToString()); + btnHtml = new StringBuilder(); + } + } + } + } + } + + private string GetBtnFunction(string transId, string task) + { + switch (task) + { + case "new": + return " onclick='javascript:NewTstruct();' "; + case "save": + return " onclick='javascript:FormSubmit();' "; + case "search": + return " onclick='javascript:OpenSearch(" + (char)34 + transId + (char)34 + ");' "; + case "remove": + return " onclick='javascript:DeleteTstruct();' "; + case "print": + return " onclick='javascript:OpenPrint(" + (char)34 + transId + (char)34 + ");' "; + case "pdf": + return " onclick='javascript:OpenPdfDocList();'"; + case "view history": + return " onclick='javascript:OpenHistory(" + (char)34 + transId + (char)34 + ");' "; + case "listview": + return " onclick='javascript:CallListView(" + (char)34 + transId + (char)34 + ");' "; + case "attach": + return " onclick='javascript:AttachFiles();' "; + case "preview": + return " onclick='javascript:OpenPrint(" + (char)34 + transId + (char)34 + ");' "; + default: + return " onclick='javascript:AlertNoAction();' "; + } + } + + /// + /// Update the button list. + /// + /// + /// + private void XmlLoadButton(XmlNode btnNodes, string btnType) + { + foreach (XmlNode btnNode in btnNodes) + { + if ((btnNode.Attributes["cat"] != null) && (btnNode.Attributes["cat"].Value == "btn")) + { + ButtonStruct btn = new ButtonStruct(); + btn.visible = "true"; + if (btnNode.Attributes["caption"] != null) + btn.caption = btnNode.Attributes["caption"].Value; + else + btn.caption = string.Empty; + + if (btnNode.Attributes["task"] != null) + btn.task = btnNode.Attributes["task"].Value; + else + btn.task = string.Empty; + if (btnNode.Attributes["action"] != null) + btn.action = btnNode.Attributes["action"].Value; + else + btn.action = string.Empty; + if (btnNode.Attributes["hint"] != null) + btn.hint = btnNode.Attributes["hint"].Value; + else + btn.hint = ""; + if (btnNode.Attributes["tlhw"] != null) + btn.dimension = btnNode.Attributes["tlhw"].Value; + else + btn.dimension = string.Empty; + if (btnNode.Attributes["img"] != null) + btn.image = btnNode.Attributes["img"].Value; + else + btn.image = string.Empty; + if (btnNode.Attributes["fileupload"] != null) + { + btn.fileupload = btnNode.Attributes["fileupload"].Value; + if (btnNode.Attributes["fmessage"] != null) + btn.fmessage = btnNode.Attributes["fmessage"].Value; + if (btnNode.Attributes["ftype"] != null) + btn.ftype = btnNode.Attributes["ftype"].Value; + } + if (btnNode.Attributes["rem"] != null) + { + btn.cancelBtn = btnNode.Attributes["rem"].Value; + } + + //if the button is task button, needs to be added to the task button list + if (btn.task == "tasks") + { + if (btnNode.ChildNodes.Count > 1) SortXMLElements(btnNode); + XmlNodeList taskNodes = btnNode.ChildNodes; + foreach (XmlNode taskNode in taskNodes) + { + if (taskNode.Name != "icon") + { + ButtonStruct tskBtn = new ButtonStruct(); + tskBtn.caption = taskNode.Attributes["caption"].Value; + tskBtn.action = taskNode.Attributes["action"].Value; + tskBtn.task = taskNode.Attributes["task"].Value; + if (taskNode.Attributes["fileupload"] != null) + tskBtn.fileupload = taskNode.Attributes["fileupload"].Value; + else + tskBtn.fileupload = string.Empty; + + taskBtns.Add(tskBtn); + } + + } + // add the task button to the buttons list only if task button contains any + // task + if (taskBtns.Count > 0) + { + btns.Add(btn); + } + } + else + { + btns.Add(btn); + } + } + else if ((btnNode.Attributes["t"] != null) && (btnNode.Attributes["t"].Value == "img")) + { + string btnImage = string.Empty; + string[] btnDim = "".Split(','); + if (btnNode.Attributes["f"] != null) + btnImage = btnNode.Attributes["f"].Value; + if (btnImage.IndexOf("\\") != -1) + btnImage = btnImage.Substring(btnImage.LastIndexOf("\\") + 1); + if (!utilObj.IsImageAvailable(btnImage)) + btnImage = string.Empty; + if (btnNode.Attributes["tlhw"] != null) + btnDim = btnNode.Attributes["tlhw"].Value.Split(','); + string imgFrameNo = string.Empty; + if (btnNode.Attributes["p"] != null) + { + imgFrameNo = btnNode.Attributes["p"].Value; + imgFrameNo = imgFrameNo.Substring(3); + } + + /*This code is commneted for now By Avi kant because while uploading image from desktop images is saving inside + * c:\ folder which is not accesssable in Code which is showing empty Image + */ + //customImageHtml.Append(""); position: absolute; top:" + btnDim[0] + "px;height:" + btnDim[2] + ";width:" + btnDim[3] + "\" > "); + //customImageHtml.Append(""); + //customImageHtml.Append(""); + //customImageHtml.Append("
    "); + //customLabels.Add(customImageHtml.ToString()); + //customLblDcNo.Add(imgFrameNo); + + } + } + } + + /// + /// load buttons for DWB toolbar. + /// + private ArrayList XmlLoadDWBButtons(XmlNode btnNodes) + { + ArrayList btnsArr = new ArrayList(); + foreach (XmlNode btnNode in btnNodes) + { + ButtonStruct btn = new ButtonStruct(); + IconStruct icon = new IconStruct(); + btnApiStruct btnapi = new btnApiStruct(); + XmlNode iconNode = btnNode.SelectSingleNode("icon"); + ArrayList childnodes = new ArrayList(); + if (btnNode.Name != "icon" && btnNode.Name != "x__heading") + { + if (btnNode.Attributes["caption"] != null) + btn.caption = btnNode.Attributes["caption"].Value; + else + btn.caption = string.Empty; + + if (btnNode.Attributes["footer"] != null) + btn.footer = btnNode.Attributes["footer"].Value; + else + btn.footer = string.Empty; + + if (btnNode.Attributes["visible"] != null) + btn.visible = btnNode.Attributes["visible"].Value; + else + btn.visible = "true"; + + if (btnNode.Attributes["task"] != null) + { + btn.task = btnNode.Attributes["task"].Value; + if (btn.task == "tasks") + continue; + } + else + btn.task = string.Empty; + if (btnNode.Attributes["action"] != null) + btn.action = btnNode.Attributes["action"].Value; + else + btn.action = string.Empty; + if (btnNode.Attributes["hint"] != null) + btn.hint = btnNode.Attributes["hint"].Value; + else + btn.hint = ""; + if (btnNode.Attributes["key"] != null) + btn.ID = btnNode.Attributes["key"].Value; + else + btn.ID = ""; + if (btnNode.Attributes["folder"] != null) + btn.isDrpDwn = btnNode.Attributes["folder"].Value.ToLower() == "true" ? true : false; + else + btn.isDrpDwn = false; + if (btnNode.Attributes["script"] != null) + btn.isScript = btnNode.Attributes["script"].Value.ToLower() == "true" ? true : false; + else + btn.isScript = false; + if (iconNode != null) + { + if (iconNode.SelectSingleNode("text") != null) + { + icon.text = iconNode.SelectSingleNode("text").InnerText; + icon.addclass = iconNode.SelectSingleNode("addClass").InnerText; + btn.icon = icon; + btn.image = ""; + } + else + { + icon.text = ""; + icon.addclass = ""; + btn.icon = icon; + btn.image = iconNode.InnerText; + } + } + else + { + icon.text = ""; + icon.addclass = ""; + btn.icon = icon; + btn.image = ""; + } + if (btn.isDrpDwn && btnNode.ChildNodes.Count > 0) + { + btn.childBtns = new ArrayList(XmlLoadDWBButtons(btnNode)); + } + + if (btnNode.Attributes["api"] != null && btnNode.Attributes["api"].Value != "") + { + btn.scriptApi = true; + XmlNode apiNode = btnNode.SelectSingleNode("api"); + + btnapi.url = apiNode.SelectSingleNode("url").InnerText; + btnapi.reqstr = apiNode.SelectSingleNode("reqstr").InnerText; + btnapi.restype = apiNode.SelectSingleNode("restype").InnerText; + btnapi.resformat = apiNode.SelectSingleNode("resformat").InnerText; + btnapi.category = apiNode.SelectSingleNode("category").InnerText; + btnapi.method = apiNode.SelectSingleNode("method").InnerText; + btn.btnapi = btnapi; + } + else + { + btn.scriptApi = false; + btnapi.url = ""; + btnapi.reqstr = ""; + btnapi.restype = ""; + btnapi.resformat = ""; + btnapi.category = ""; + btnapi.method = ""; + btn.btnapi = btnapi; + } + + btnsArr.Add(btn); + } + } + return btnsArr; + } + + // Sort the Task Button Elements in ascending order based on Element name + public static void SortXMLElements(XmlNode node) + { + bool changed = true; + int num0, num1; + while (changed) + { + changed = false; + for (int i = 1; i < node.ChildNodes.Count; i++) + { + if (Int32.TryParse(node.ChildNodes[i].Name.ToLower().Replace("pop", ""), out num1) && Int32.TryParse(node.ChildNodes[i - 1].Name.ToLower().Replace("pop", ""), out num0) && num1 < num0) + { + node.InsertBefore(node.ChildNodes[i], node.ChildNodes[i - 1]); //Replace the nodes + changed = true; + } + } + } + } + + /// + /// Update the formcontrol javascript array to the string variable. + /// + /// + private void XmlLoadJsFormcontrol(XmlNode actionNodes) + { + ActionStruct act = new ActionStruct(); + StringBuilder formcontrol = new StringBuilder(); + StringBuilder script_fc = new StringBuilder(); + int formcontrolNo = 0, actNo = 0, srConNo = 0; + XmlNode formcontrolTempNode1 = default(XmlNode); + XmlNode formcontrolTempNode2 = default(XmlNode); + foreach (XmlNode actionNode in actionNodes) + { + if (actionNode.Name == "formcontrol") + { + XmlNodeList formcontrolNode = actionNode.ChildNodes; + for (int i = 0; i <= formcontrolNode.Count - 1; i++) + { + formcontrolTempNode1 = formcontrolNode.Item(i); + XmlNodeList formcontrolChildNode = formcontrolTempNode1.ChildNodes; + for (int j = 0; j <= formcontrolChildNode.Count - 2; j++) + { + formcontrolTempNode2 = formcontrolChildNode.Item(j); + formcontrol.Append("Formcontrols[" + formcontrolNo + "] = " + "\"" + formcontrolTempNode2.InnerText + "\"; "); + formcontrolNo += 1; + } + //Last node needs to be "e". so the array will end one node before and e is hardcoded after + formcontrol.Append("Formcontrols[" + formcontrolNo + "]= " + "\"e\"; "); + formcontrolNo += 1; + } + } + else + { + if (actionNode.Attributes["formcontrol"] != null && actionNode.Attributes["formcontrol"].Value == "true") + { + string actstrname = string.Empty, actapplyon = string.Empty, actapply = string.Empty, actconname = string.Empty; + if (actionNode.Attributes["sname"] != null) + actstrname = actionNode.Attributes["sname"].Value.ToString(); + if (actionNode.Attributes["apply"] != null) + actapply = actionNode.Attributes["apply"].Value.ToString(); + if (actionNode.Attributes["applyon"] != null) + actapplyon = actionNode.Attributes["applyon"].Value.ToString(); + if (actionNode.HasChildNodes) + { + try + { + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(actionNode.OuterXml); + XmlNode resultNode = xmlDoc.SelectSingleNode("//r1/param1/exprset"); + foreach (XmlNode childNode in resultNode.ChildNodes) + { + actconname += childNode.InnerText.Replace("\"", "\'") + "~"; + } + if (actconname != string.Empty) + actconname = actconname.TrimEnd('~'); + } + catch (Exception ex) { } + } + script_fc.Append("SFormControls[" + srConNo + "]=" + "\"" + actconname + "\"; "); + script_fc.Append("SFCApply[" + srConNo + "]=" + "\"" + actapply + "\"; "); + script_fc.Append("SFCFldNames[" + srConNo + "]=" + "\"" + actapplyon + "\"; "); + script_fc.Append("SFCActionName[" + srConNo + "]=" + "\"" + actionNode.Name.ToString() + "\"; "); + srConNo++; + } + else + { + act.actname = actionNode.Name.ToString(); + if (actionNode.Attributes["sname"] != null) + act.actstrname = actionNode.Attributes["sname"].Value.ToString(); + if (actionNode.Attributes["apply"] != null) + act.actapply = actionNode.Attributes["apply"].Value.ToString(); + if (actionNode.Attributes["applyon"] != null) + act.actapplyon = actionNode.Attributes["applyon"].Value.ToString(); + if (actionNode.Attributes["desc"] != null) + act.actdesc = actionNode.Attributes["desc"].Value.ToString(); + if (actionNode.Attributes["validate"] != null) + act.actvalidate = actionNode.Attributes["validate"].Value.ToString(); + act.actweb = "no"; + if (actionNode.Attributes["web"] != null && actionNode.Attributes["web"].Value != null) + act.actweb = actionNode.Attributes["web"].Value.ToString(); + if (actionNode.Attributes["rem"] != null) + act.actRem = actionNode.Attributes["rem"].Value; + else + act.actRem = "n"; + + if (actionNode.Attributes["manrem"] != null) + act.manRem = actionNode.Attributes["manrem"].Value; + else + act.manRem = "n"; + + if (actionNode.Attributes["apply"] != null && actionNode.Attributes["apply"].Value != null && Convert.ToString(actionNode.Attributes["apply"].Value) == "On Form Load") + rapidFormLoadActionXML += actionNode.OuterXml; + + if (actionNode.HasChildNodes) + { + try + { + XmlNode node = actionNode.FirstChild; + XmlNodeList lstRefresh = node.ChildNodes[0].ChildNodes; + foreach (XmlNode ndRefresh in lstRefresh) + { + if (ndRefresh.Name == "Refresh") + { + act.actParRefresh = ndRefresh.InnerText; + break; + } + } + } + catch (Exception ex) { } + + try + { + act.actSaveTask = ""; + act.actScriptTask = ""; + XmlNodeList chkSaveTask = actionNode.ChildNodes; + foreach (XmlNode ndSave in chkSaveTask) + { + if (ndSave.Attributes["task"].Value.ToLower() == "save") + { + act.actSaveTask = "save"; + break; + } + else if (ndSave.Attributes["task"].Value.ToLower() == "scripts") + { + XmlNode scrpList = ndSave.ChildNodes[0].FirstChild; + foreach (XmlNode ndScrp in scrpList.ChildNodes) + { + if (ndScrp.InnerText.ToLower() == "save()") + { + act.actSaveTask = "save"; + break; + } + else if (ndScrp.InnerText.ToLower().StartsWith("loadform(")) + { + act.actScriptTask = "loadform♠" + ndScrp.InnerText; + break; + } + else if (ndScrp.InnerText.ToLower().StartsWith("loadformanddata(")) + { + act.actScriptTask = "loadformanddata♠" + ndScrp.InnerText; + break; + } + else if (ndScrp.InnerText.ToLower().StartsWith("loadiview(")) + { + act.actScriptTask = "loadiview♠" + ndScrp.InnerText; + break; + } + else if (ndScrp.InnerText.ToLower().StartsWith("loadpage(")) + { + act.actScriptTask = "loadpage♠" + ndScrp.InnerText; + break; + } + else if (ndScrp.InnerText.ToLower().StartsWith("openpage(")) + { + act.actScriptTask = "openpage♠" + ndScrp.InnerText; + break; + } + } + break; + } + } + } + catch (Exception ex) { } + } + + // check whether this action is used in any buttons, if so check for file upload and set it in the button + for (int i = 0; i < btns.Count; i++) + { + ButtonStruct btn = (ButtonStruct)btns[i]; + if (btn.action != act.actname) + continue; + + if (actionNode.Attributes["fileupload"] != null) + { + btn.fileupload = actionNode.Attributes["fileupload"].Value; + if (actionNode.Attributes["fmsg"] != null) + btn.fmessage = actionNode.Attributes["fmsg"].Value; + if (actionNode.Attributes["ftype"] != null) + btn.ftype = actionNode.Attributes["ftype"].Value; + + btns.RemoveAt(i); + btns.Insert(i, btn); + } + actions.Add(act); + break; + } + + // check whether this action is used in any buttons, if so check for file upload and set it in the button + for (int i = 0; i < taskBtns.Count; i++) + { + ButtonStruct btn = (ButtonStruct)taskBtns[i]; + if (btn.action != act.actname) + continue; + + if (actionNode.Attributes["fileupload"] != null) + { + btn.fileupload = actionNode.Attributes["fileupload"].Value; + if (actionNode.Attributes["fmsg"] != null) + btn.fmessage = actionNode.Attributes["fmsg"].Value; + if (actionNode.Attributes["ftype"] != null) + btn.ftype = actionNode.Attributes["ftype"].Value; + + taskBtns.RemoveAt(i); + taskBtns.Insert(i, btn); + } + actions.Add(act); + break; + } + formcontrol.Append("tstActionName[" + actNo + "]= " + "\"" + act.actname + "\";actParRefresh[" + actNo + "]= " + "\"" + act.actParRefresh + "\";actSaveTask[" + actNo + "]= " + "\"" + act.actSaveTask + "\";actScriptTask[" + actNo + "]=" + "\"" + act.actScriptTask + "\";"); + actNo++; + } + } + } + jsFormcontrolArray += formcontrol.ToString() + script_fc.ToString(); + } + + /// + /// Update hyperlink list + /// + /// + private void XmlLoadHyperLink(XmlNode hlinkNodes) + { + StringBuilder hyperlnklist = new StringBuilder(); + int hyperlnkNo = 0; + foreach (XmlNode hlinkNode in hlinkNodes) + { + HLinkStruct hl = new HLinkStruct(); + if (hlinkNode.Attributes["pop"] != null) + { + hl.hlpop = hlinkNode.Attributes["pop"].Value; + hyperlnklist.Append("HLinkPop[" + hyperlnkNo + "] = " + "\"" + hlinkNode.Attributes["pop"].Value.ToString() + "\";"); + } + else + { + hl.hlpop = "-"; + hyperlnklist.Append("HLinkPop[" + hyperlnkNo + "] = " + "\"-\";"); + } + + if (hlinkNode.Attributes["sname"] != null) + { + hl.hlname = hlinkNode.Attributes["sname"].Value; + hyperlnklist.Append("HLinkName[" + hyperlnkNo + "] = " + "\"" + hlinkNode.Attributes["sname"].Value.ToString() + "\";"); + } + else + { + hl.hlname = "-"; + hyperlnklist.Append("HLinkName[" + hyperlnkNo + "] = " + "\"-\";"); + } + + if (hlinkNode.Attributes["source"] != null) + { + hl.hlsource = hlinkNode.Attributes["source"].Value; + hyperlnklist.Append("HLinkSource[" + hyperlnkNo + "] = " + "\"" + hlinkNode.Attributes["source"].Value.ToString() + "\";"); + } + else + { + hl.hlsource = "-"; + hyperlnklist.Append("HLinkSource[" + hyperlnkNo + "] = " + "\"-\";"); + } + + if (hlinkNode.Attributes["load"] != null) + { + hl.hlload = hlinkNode.Attributes["load"].Value; + hyperlnklist.Append("HLinkLoad[" + hyperlnkNo + "] = " + "\"" + hlinkNode.Attributes["load"].Value.ToString() + "\";"); + } + else + { + hl.hlload = "-"; + hyperlnklist.Append("HLinkLoad[" + hyperlnkNo + "] = " + "\"-\";"); + } + + StringBuilder paramnm = new StringBuilder(); + StringBuilder paramval = new StringBuilder(); + foreach (XmlNode paramNode in hlinkNode) + { + if (paramnm.Length == 0) + { + paramnm.Append(paramNode.Attributes["n"].Value); + paramval.Append(paramNode.Attributes["v"].Value); + } + else + { + paramnm.Append("~" + paramNode.Attributes["n"].Value); + paramval.Append("~" + paramNode.Attributes["v"].Value); + } + } + + if (paramnm.Length != 0) + { + hl.hlparamname = paramnm.ToString(); + hl.hlparamval = paramval.ToString(); + hyperlnklist.Append("HLinkParamName[" + hyperlnkNo + "] = " + "\"" + hl.hlparamname + "\";"); + hyperlnklist.Append("HLinkParamValue[" + hyperlnkNo + "] = " + "\"" + hl.hlparamval + "\";"); + } + else + { + hl.hlparamname = "-"; + hl.hlparamval = "-"; + hyperlnklist.Append("HLinkParamName[" + hyperlnkNo + "] = " + "\"-\";"); + hyperlnklist.Append("HLinkParamValue[" + hyperlnkNo + "] = " + "\"-\";"); + } + hlnks.Add(hl); + hyperlnkNo++; + } + if (hyperlnklist.ToString() != "") + tstHyperLink = true; + jsHyperlinkArray = hyperlnklist.ToString(); + } + + /// + /// function to create customized labels, the customized labels users can provide, different font + /// styles like, bold, size, color + /// + /// + private void XmlCreateCustomLabel(XmlNode customLabelNodes) + { + XmlNode nodeLabelExists = customLabelNodes.Attributes["t"]; + if ((nodeLabelExists == null)) + { + customLabelHtml.Append(""); + } + else if (nodeLabelExists.Value == "lbl") + { + string LabelName = null; + LabelName = customLabelNodes.Attributes["c"].Value; + + int frameNo = 0; + if (customLabelNodes.Attributes["p"] != null) + { + frameNo = Convert.ToInt32(customLabelNodes.Attributes["p"].Value.Substring(3)); + } + + + if (string.IsNullOrEmpty(LabelName)) + LabelName = customLabelNodes.InnerText.ToString(); + if (LabelName.IndexOf("\n") != -1) + LabelName = LabelName.Replace("\n", "
    "); + string Labeltlhw = null; + Labeltlhw = ""; + string Labeltop = null; + string Labelleft = null; + string Labelht = null; + string Labelwidth = null; + XmlNode nodeLabel = customLabelNodes.Attributes["tlhw"]; + + if ((nodeLabel == null)) + Labeltlhw = ""; + else + Labeltlhw = nodeLabel.Value; + + string lblstyle = string.Empty; + nodeLabel = customLabelNodes.Attributes["font"]; + if ((nodeLabel == null)) + lblstyle = ""; + else + lblstyle = nodeLabel.Value; + + string style = string.Empty; + if (lblstyle == ",,," || string.IsNullOrEmpty(lblstyle)) + style = "font-family:'Lato', sans-serif; font-size:14px; font-weight:normal; font-style:normal; color:#000000;"; + else + { + string[] stylearr = lblstyle.Split(','); + if (string.IsNullOrEmpty(stylearr[0])) + style = "font-family:'Lato', sans-serif;"; + else + style = "font-family:" + stylearr[0].ToString() + ";"; + + if (string.IsNullOrEmpty(stylearr[1])) + style += " font-size:14px;"; + else + style += " font-size:" + stylearr[1].ToString() + "pt;"; + + if (string.IsNullOrEmpty(stylearr[2])) + style += " font-weight:normal; font-style:normal;"; + else + { + string fontstyle = stylearr[2].ToString(); + string fstyle = ""; + if ((fontstyle.Substring(0, 1) == "t")) + fstyle = " font-weight:bold;"; + else + fstyle = " font-weight:bold;"; + + if ((fontstyle.Substring(1, 1) == "t")) + fstyle += "font-style:italic;"; + else + fstyle += "font-style:bold;"; + + if ((fontstyle.Substring(2, 1) == "t")) + fstyle += "text-decoration:underline"; + else + fstyle += ""; + + if ((fontstyle.Substring(3, 1) == "t")) + fstyle += " line-through;"; + else + fstyle += ";"; + + style += fstyle; + } + + if (stylearr[3] == "clBlack") + style += " color:#000000;"; + else + { + if ((!string.IsNullOrEmpty(stylearr[3].ToString()))) + style += " color:" + stylearr[3].ToString().Substring(2) + ";"; + else + style += " color:#000000;"; + } + } + + if (!(string.IsNullOrEmpty(Labeltlhw))) + { + string[] Labelsplitout = Labeltlhw.Split(','); + if (EnableOldTheme == "true") + { + Labeltop = Math.Floor((Convert.ToInt32(Labelsplitout[0].ToString()) * 1.2)).ToString() + "px"; + Labelleft = Math.Floor((Convert.ToInt32(Labelsplitout[1].ToString()) * 1.01)).ToString() + "px"; + } + else + { + Labeltop = Math.Floor((Convert.ToInt32(Labelsplitout[0].ToString()) * 1.6)).ToString() + "px"; + Labelleft = Math.Floor((Convert.ToInt32(Labelsplitout[1].ToString()) * 1.07)).ToString() + "px"; + } + + Labelht = Labelsplitout[2].ToString() + "px"; + Labelwidth = Labelsplitout[3].ToString() + "px"; + string divDirection = "left"; + if (HttpContext.Current.Session["language"].ToString() == "ARABIC") + { + divDirection = "right"; + } + bool isHyper = false; + int n = 0; + for (n = 0; n <= hlnks.Count - 1; n++) + { + if (customLabelNodes.Name.ToLower() == ((HLinkStruct)(hlnks[n])).hlsource.ToString().ToLower()) + { + isHyper = true; + break; + } + } + + FieldStruct dummy = new FieldStruct(); + dummy.visibility = false; + dummy.fldlength = 15; + dummy.fldFrameNo = frameNo; + if (isHyper) + dummy.ctype = "hyperlink"; + else + dummy.ctype = "label"; + dummy.datatype = "special"; + dummy.name = customLabelNodes.Name; + + customLabelHtml.Append("
    "); + customLabelHtml.Append("
    "); + customLabelHtml.Append("
    "); + customLabelHtml.Append(""); + + if (isHyper) + customLabelHtml.Append("" + LabelName + "
    "); + else + customLabelHtml.Append("" + LabelName + "
    "); + + customLabelHtml.Append(""); + } + + customLabels.Add(customLabelHtml.ToString()); + customLblDcNo.Add(dcs.Count.ToString()); + customLabelHtml = new StringBuilder(); + } + } + + /// + /// function to construct the dc html with field html. + /// + /// + /// + /// completed field html. + private string GetFullDCHtml(int dcNo, string fieldhtml, string isTab) + { + colCount = 0; + if (dcNo == 1) docHeight = 0; + StringBuilder dcHtml = new StringBuilder(); + string dcFields1 = string.Empty; + string ngBorder = string.Empty; + StringBuilder customLabel = new StringBuilder(); + StringBuilder actionButton = new StringBuilder(); + StringBuilder defaultColsHtml = new StringBuilder(); + int gridwidth = 0; + string divDirection = "left"; + string divCollapse = "right"; + if (HttpContext.Current.Session["language"].ToString() == "ARABIC") + { + divDirection = "right"; + divCollapse = "left"; + } + var designMode = false; + + if (HttpContext.Current.Session[transId + "IsDesignMode"] != null && HttpContext.Current.Session[transId + "IsDesignMode"].ToString() != string.Empty) + { + designMode = Convert.ToBoolean(HttpContext.Current.Session[transId + "IsDesignMode"]); + } + for (int n = 0; n < customLblDcNo.Count; n++) + { + if (dcNo == Convert.ToInt32(customLblDcNo[n].ToString())) + customLabel.Append(customLabels[n].ToString()); + } + + for (int m = 0; m < pageActionDcNo.Count; m++) + { + if (dcNo == Convert.ToInt32(pageActionDcNo[m].ToString())) + actionButton.Append(pageActionButtons[m].ToString()); + } + + if (((DcStruct)(dcs[dcNo - 1])).isgrid) + docHeight += 500; + else + docHeight += ((DcStruct)(dcs[dcNo - 1])).dcHeight; + + int VisibleFlds = ((DcStruct)(dcs[dcNo - 1])).visibleFldCount; + for (int k = 0; k < flds.Count; k++) + { + FieldStruct fld = ((FieldStruct)(flds[k])); + if (fld.fldframeno < dcNo) continue; + if (fld.fldframeno > dcNo) break; + if (fld.fldframeno == dcNo) + { + if (fld.visibility == false) + { + gridwidth += (fld.fldlength > 51 ? 400 : (fld.fldlength <= 15) ? 150 : (fld.fldlength * 8)); + } + } + } + if (((DcStruct)(dcs[dcNo - 1])).isallowdeletrows.ToString().ToLower() == "true") + gridwidth = gridwidth + 80; + else + gridwidth = gridwidth + 40;//40 width for sl no column and 40 for delete button + if (((DcStruct)(dcs[dcNo - 1])).isgrid) + { + string rowSrNoClass = string.Empty; + if (IsFillGridCall) + { + rowSrNoClass = "gridtdclass"; + } + else + { + rowSrNoClass = "gridtdclass d-none"; + } + string dcRowone = ""; + if (((DcStruct)(dcs[dcNo - 1])).ispopgrid) + { + if (((DcStruct)(dcs[dcNo - 1])).isallowdeletrows.ToString().ToLower() == "false") + dcRowone = "
    " + fieldhtml + "
    "; + else + //delete grid row + dcRowone = "
    " + fieldhtml + "
    "; + + } + else + { + if (((DcStruct)(dcs[dcNo - 1])).isallowdeletrows.ToString().ToLower() == "false") + { + dcRowone = "
    " + fieldhtml + "
    "; + } + else + { + //delete grid row + dcRowone = "
    " + fieldhtml + "
    "; + } + } + + StringBuilder gridHdHtml = new StringBuilder(); + + gridHdHtml.Append("
    "); + + if (((DcStruct)(dcs[dcNo - 1])).isallowdeletrows.ToString().ToLower() == "true") + { + xywhGridStack(new FieldStruct { visibility = false, fldFrameNo = dcNo, name = ("uniqueThHead" + dcNo) }, true); + if (((DcStruct)(dcs[dcNo - 1])).ispopgrid) + { + defaultColsHtml.Append("
    S.no
    "); + colCount++; + } + else + { + defaultColsHtml.Append("
    S.no
    "); + colCount++; + } + } + else + { + if (((DcStruct)(dcs[dcNo - 1])).ispopgrid) + defaultColsHtml.Append(""); + else + { + xywhGridStack(new FieldStruct { visibility = false, fldFrameNo = dcNo, name = ("uniqueThHead" + dcNo) }, true); + defaultColsHtml.Append("
    S.no
    "); + colCount++; + } + } + + string dcBtns = GetGridButtonHtml(dcNo.ToString()); + //TODO: need to fix the calculation of colcount, the same code is there in GetTabFullDcHtml + colCount = 100; + gridHdHtml.Append("
    " + dcBtns); + gridHdHtml.Append("
    "); + string hideClass = "d-none"; + + gridHdHtml.Append("
    " + dcRowone + "
    Use Ctrl+Left arrow & Ctrl+Right arrow to navigate between record(s).
    "); + + if (HttpContext.Current.Session["language"].ToString().ToLower() == "arabic") + { + gridHdHtml.Append("
    "); + gridHdHtml.Append(""); + } + else + { + gridHdHtml.Append("
    "); + gridHdHtml.Append("
    "); + } + xywhGridStack(new FieldStruct { visibility = false, fldFrameNo = dcNo, name = ("uniqueEditDeleteAct" + dcNo) }, true); + gridHdHtml.Append("
    " + defaultColsHtml.ToString()); + gridHdHtml.Append(gridHeadHtml.ToString() + "
    "); + + StringBuilder gridHtml = new StringBuilder(); + string gridButtons = string.Empty; + + if (((DcStruct)(dcs[dcNo - 1])).ispopgrid) + { + gridHdHtml.Append("
    "); + gridHdHtml.Append(""); + } + else + { + gridHdHtml.Append("
    "); + gridHdHtml.Append("
    "); + } + + gridHdHtml.Append("
    "); + gridHdHtml.Append("
    "); + gridHdHtml.Append("
    "); + + string rowCountHtml = ""; + + string fullGridHtml1 = string.Empty; + + if (isTab == "true") + { + if (((DcStruct)(dcs[dcNo - 1])).isgrid) + { + fullGridHtml1 = "
    "; + if (!string.IsNullOrEmpty(((DcStruct)(dcs[dcNo - 1])).purpose)) + fullGridHtml1 += gridHdHtml.ToString() + rowCountHtml + "
    " + ((DcStruct)(dcs[dcNo - 1])).purpose + "
    ";//murali + else + fullGridHtml1 += gridHdHtml.ToString() + rowCountHtml + "";//murali + } + else + { + fullGridHtml1 = "
    "; + if (!string.IsNullOrEmpty(((DcStruct)(dcs[dcNo - 1])).purpose)) + fullGridHtml1 += gridHdHtml.ToString() + rowCountHtml + "
    " + ((DcStruct)(dcs[dcNo - 1])).purpose + "
    ";//murali + else + fullGridHtml1 += gridHdHtml.ToString() + rowCountHtml + "";//murali + } + } + else if (((DcStruct)(dcs[dcNo - 1])).ispopgrid) + { + fullGridHtml1 = "
    "; + if (!string.IsNullOrEmpty(((DcStruct)(dcs[dcNo - 1])).purpose)) + fullGridHtml1 += "
    " + ((DcStruct)(dcs[dcNo - 1])).purpose + "
    "; + else + fullGridHtml1 += ""; + fullGridHtml1 += gridHdHtml.ToString() + rowCountHtml + "
    "; //murali + + } + else + { + fullGridHtml1 = "
    "; + fullGridHtml1 += ""; + + fullGridHtml1 += gridHdHtml.ToString() + rowCountHtml + "
    "; + } + dcHtml.Append(fullGridHtml1 + "
    "); + } + else + { + // innermost div for all non grid dcs. + // lastDcHeight is used if there is a calendar control in the last Dc, So this + // was affecting the dcheight to overcome this there is check where the the greater height isa set as dcheight + if (dcNo == dcs.Count) + { + if (((DcStruct)(dcs[dcNo - 1])).dcHeight > lastDcHeight) + { + lastDcHeight = ((DcStruct)(dcs[dcNo - 1])).dcHeight; + } + //commented because form-horizontal was affecting ui.. previously added by anand.. checking need to be done after removing. + ngBorder = "
    "; + } + else + { + int tstHieght = ((DcStruct)(dcs[dcNo - 1])).dcHeight; + if (isTab == "true") + { + if (((DcStruct)(dcs[dcNo - 1])).isgrid) + ngBorder = "
    "; + else + { + string visibledc = GetVisibleDCs(); + string[] arrVisibleDc = visibledc.Split(','); + int pos = Array.IndexOf(arrVisibleDc, "dc" + dcNo); + if (pos > -1) + { + if (EnableOldTheme == "true") + ngBorder = "
    "; + else + ngBorder = "
    "; + + } + else + ngBorder = "
    "; + } + } + else + ngBorder = "
    "; + } + string ngFldHtml = ngBorder + fieldhtml + customLabel.ToString() + actionButton.ToString() + "
    "; + + if (isTab == "true") + { + if (dcNo > 1) + { + dcHtml.Append("
    "); + dcHtml.Append(ngFldHtml + "
    "); + + + } + else + { + //TODO: the primary dc can also be a tabbed dc + dcHtml.Append("
    "); + dcHtml.Append(ngFldHtml + "
    "); + + } + } + else + { + dcHtml.Append("
    "); + if (dcNo > 1 || tstLayout == Constants.TILE) + { + if (!string.IsNullOrEmpty(((DcStruct)(dcs[dcNo - 1])).purpose)) + dcHtml.Append("
    keyboard_arrow_up " + ((DcStruct)(dcs[dcNo - 1])).caption + "
    " + ((DcStruct)(dcs[dcNo - 1])).purpose + "

    ");//muralli + else + dcHtml.Append("
    " + ((DcStruct)(dcs[dcNo - 1])).caption + "

    ");//muralli + } + else if (dcNo == 1 && designMode) + { + dcHtml.Append("
    " + ((DcStruct)(dcs[dcNo - 1])).caption + "
    " + ((DcStruct)(dcs[dcNo - 1])).purpose + "

    "); + } + + dcHtml.Append(ngFldHtml + "
    "); + } + + } + return dcHtml.ToString(); + } + #endregion + + #region Public Methods + + public string GetFillGridCaption(int dcNo, string isTab) + { + StringBuilder fgfieldArray = new StringBuilder(); + string fgButCap = ""; + if (fgs.Count > 0) + { + int cnt = 0; + for (cnt = 0; cnt <= fgs.Count - 1; cnt++) + { + if (((DcStruct)(dcs[dcNo - 1])).name == ((FGStruct)(fgs[cnt])).fgtargetdc) + { + fgButCap = ((FGStruct)(fgs[cnt])).fgcaption; + break; + } + } + } + return fgButCap; + } + + /// + /// Method to initialize the fields. It takes XML returned by AWS, parses and + /// fills the arrays and fields. U + /// + /// + public void Create(string xml) + { + + xmlDoc.LoadXml(xml); + FillTstructProperties(xmlDoc); + XmlNodeList tstBaseDataNodes = default(XmlNodeList); + tstBaseDataNodes = xmlDoc.DocumentElement.SelectNodes("//root"); + + XmlNodeList hyperLinkNode = xmlDoc.GetElementsByTagName("hyperlinks"); + if (hyperLinkNode[0] != null) + XmlLoadHyperLink(hyperLinkNode[0]); + //Calling Runmode/design mode Api's + //getDesignData(); + if (HttpContext.Current.Session["IsCustomHtml"] == null || HttpContext.Current.Session["IsCustomHtml"].ToString() == string.Empty) + getDesignDataPerf(); + + + XmlDocument formbtnnode = new System.Xml.XmlDocument(); + XmlNode toolbarcomps = xmlDoc.SelectSingleNode("//root/comps"); + string pdcno = string.Empty; + string strformbt = string.Empty; + for (int i = toolbarcomps.ChildNodes.Count - 1; i < toolbarcomps.ChildNodes.Count; i--) + { + if (toolbarcomps.ChildNodes[i] == null) + break; + string newpdcno = string.Empty; + string innerXML = string.Empty; + if (toolbarcomps.ChildNodes[i].Attributes["position"] != null && toolbarcomps.ChildNodes[i].Attributes["position"].Value != "" && toolbarcomps.ChildNodes[i].Attributes["position"].Value.StartsWith("dc")) + { + newpdcno = toolbarcomps.ChildNodes[i].Attributes["position"].Value; + innerXML = toolbarcomps.ChildNodes[i].OuterXml; + newpdcno = newpdcno.Split('~')[0]; + newpdcno = newpdcno.Substring(2); + toolbarcomps.RemoveChild(toolbarcomps.ChildNodes[i]); + } + if (innerXML != string.Empty) + { + if (pdcno == string.Empty) + { + strformbt += ""; + strformbt += innerXML; + pdcno = newpdcno; + } + else if (pdcno == newpdcno) + { + strformbt += innerXML; + } + else if (pdcno != newpdcno) + { + strformbt += ""; + strformbt += ""; + strformbt += innerXML; + pdcno = newpdcno; + } + } + } + if (strformbt != string.Empty) + { + strformbt += ""; + formbtnnode.LoadXml("" + strformbt + ""); + } + + + foreach (XmlNode tstBaseDataNode in tstBaseDataNodes) + { + + XmlNodeList tstChildDataNodes = default(XmlNodeList); + tstChildDataNodes = tstBaseDataNode.ChildNodes; + + string category = string.Empty; + + foreach (XmlNode tstChildDataNode in tstChildDataNodes) + { + if (tstChildDataNode.Attributes["cat"] != null) + category = tstChildDataNode.Attributes["cat"].Value.ToString(); + else + category = string.Empty; + if (tstChildDataNode.Attributes["plist"] != null) + dcPlistaddrow = tstChildDataNode.Attributes["plist"].Value.ToString(); + else + dcPlistaddrow = string.Empty; + + if (category == "dc") + { + dcFldCount = 0; + dcFldVisibleCount = 0; + XmlLoadDc(tstChildDataNode); + + if (formbtnnode.ChildNodes.Count > 0) + { + XmlPageLoadDWBButton(formbtnnode, DCNo); + } + } + else if (category == "field") + { + string fieldType = string.Empty; + if (tstChildDataNode.Attributes["fieldtype"] != null) + fieldType = tstChildDataNode.Attributes["fieldtype"].Value.ToString(); + else + fieldType = string.Empty; + //if (tstChildDataNode.Attributes["runtimecriteria"] != null && tstChildDataNode.Attributes["runtimecriteria"].Value == "T" && fldRuntimeCriteria == "F") + // fldRuntimeCriteria = tstChildDataNode.Attributes["runtimecriteria"].Value.ToString(); + + XmlLoadField(tstChildDataNode, fieldType); + } + else if (category == "fillgrid") + XmlLoadFillgrid(tstChildDataNode); + else if (category == "btn") + XmlPageLoadButton(tstChildDataNode, "btn"); + else if (category == "comps") + { + if (tstChildDataNode.Attributes["dwbtb"] != null && tstChildDataNode.Attributes["dwbtb"].Value.ToString().ToLower() == "true") + { + dwbToolbar = true; + //btns = new ArrayList(XmlLoadDWBButtons(tstChildDataNode)); + btns = new ArrayList(XmlLoadDWBButtons(toolbarcomps)); + } + else + XmlLoadButton(tstChildDataNode, "btn"); + } + + else if (category == "tasks") + XmlLoadButton(tstChildDataNode, "task"); + else if (category == "hyperlinks") + continue; + else if (category == "actions") + XmlLoadJsFormcontrol(tstChildDataNode); + else if (category == "iframes") + XmlLoadTabDcs(tstChildDataNode); + else if (category == "gformat") + { + continue; + //XmlLoadFormatDcs(tstChildDataNode); + //Commented Bcoz this feature will be taken up later + //Right now it will skip the GFormat node from the tstruct + } + else if (category != "") + XmlCreateCustomLabel(tstChildDataNode); + } + } + + //XmlNodeList pdfListNode = xmlDoc.GetElementsByTagName(transId + "_pdflist"); + //if (pdfListNode[0] != null) + // pdfList = pdfListNode[0].OuterXml; + if (HttpContext.Current.Session[transId + "_pdflist"] != null) + { + pdfList = HttpContext.Current.Session[transId + "_pdflist"].ToString(); + HttpContext.Current.Session[transId + "_pdflist"] = null; + } + + if (dcRange != "") + { + dcRange = dcRange + "," + (fldGlobal).ToString(); + jsFieldArray.Append("FldDcRange[" + DcCnt + "]=\"" + dcNo.ToString() + "~" + dcRange + "\";"); + fldDcRange.Add(dcNo.ToString() + "~" + dcRange); + dcRange = ""; + } + + if (fldSetCarry.Count > 0) + { + jsFieldArray.Append("FSetCarry=['" + string.Join("','", fldSetCarry.ToArray()) + "'];"); + } + if (AxpFileUploadFields.Count > 0) + jsFieldArray.Append("AxpFileUploadFields=['" + string.Join("','", AxpFileUploadFields.ToArray()) + "'];"); + + FillNGSqlDepParents(); + + IsWsPerfDeleteGridRow(); + + FDR fastData = (FDR)HttpContext.Current.Session["FDR"]; + fastDataFlds = fastData.GetRedisServerFields(this); + fastData.GetFastDataRefEvents(this); + } + + /// + /// GridDC fields dependences are having Accept SQL or Select with AutoSelect true then only needs to call GridRowDelete service. + /// + private void IsWsPerfDeleteGridRow() + { + if (wsPerfFields != string.Empty) + { + string[] wsPerfFieldArr = wsPerfFields.Split(','); + for (int i = 0; i < dcs.Count; i++) + { + DcStruct dc = (DcStruct)dcs[i]; + if (dc.isgrid) + { + string[] dcRange = GetDcFieldRange(dc.frameno.ToString()).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + for (int k = startIdx; k <= endIdx; k++) + { + FieldStruct fld = (FieldStruct)flds[k]; + if (fld.fieldDependents == string.Empty) + continue; + string[] fldDeparray = fld.fieldDependents.Split(','); + var isfldDepBound = fldDeparray.Where(fd => wsPerfFieldArr.Any(vd => fd == "s" + vd || fd == "e" + vd || fd == "f" + vd)).ToList(); + if (isfldDepBound.Count > 0) + { + wsPerfGRDDcs.Add(dc.frameno.ToString()); + break; + } + else + { + for (int j = 0; j < fldDeparray.Length; j++) + { + if (GetFieldDc(fldDeparray[j]) != dc.frameno) + { + wsPerfGRDDcs.Add(dc.frameno.ToString()); + break; + } + } + if (wsPerfGRDDcs.Count > 0 && wsPerfGRDDcs.IndexOf(dc.frameno.ToString()) != -1) + break; + } + } + } + } + } + } + + private void SetRapidExpFlds() + { + if (rapidFLExpFlds.Count > 0) + { + rapidFormLoadExpFlds = string.Join(",", rapidFLExpFlds.Select(x => x.ToString()).ToArray()); + if (rapidFormLoadExpFlds != string.Empty) + rapidFormLoadJSON = "{\"evalexpr\":\"true\", \"flds\":\"" + rapidFormLoadExpFlds + "\"}"; + } + } + + + private FieldStruct SetFieldGridSqlDeps(FieldStruct fld, DcStruct dc, int idx) + { + ArrayList fldDepGridDcs = new ArrayList(); + StringBuilder strSqlDeps = new StringBuilder(); + + string strFldDeps = string.Empty; + strFldDeps = fld.fieldSqlDeps; + if (strFldDeps == "") strFldDeps = fld.fieldExpDeps; + else if (fld.fieldExpDeps != string.Empty) strFldDeps += "," + fld.fieldExpDeps; + if (!string.IsNullOrEmpty(strFldDeps)) + { + string[] strDeps = strFldDeps.Split(','); + + for (int i = 0; i < strDeps.Length; i++) + { + string fChar = strDeps[i].ToString().Substring(0, 1); + string fName = strDeps[i].ToString().Substring(1); + int dIdx = GetFieldIndex(fName); + + FieldStruct depFld = (FieldStruct)flds[dIdx]; + DcStruct depDc = (DcStruct)dcs[depFld.fldframeno - 1]; + if (!depDc.ispopgrid && depDc.isgrid && fld.fldframeno != depFld.fldframeno) + { + string depStr = depFld.name; + //Stores the dep grid dcs for a given field + if (fldDepGridDcs.IndexOf(depFld.fldframeno) == -1) + { + fldDepGridDcs.Add(depFld.fldframeno); + depStr += "," + "axp_recid" + depFld.fldframeno; + } + + //if (depFld.fieldParents != string.Empty && fChar != "e") here checking is dependece fields are sql or not if it is sql dependent adding else not adding + if (depFld.fieldParents != string.Empty) + { + depStr += "," + depFld.fieldParents; + } + + if (strSqlDeps.ToString() == string.Empty) + strSqlDeps.Append(depStr); + else + strSqlDeps.Append("," + depStr); + } + } + for (int j = 0; j < fldDepGridDcs.Count; j++) + { + if (fld.fieldDepGridDcs == string.Empty) + fld.fieldDepGridDcs = fldDepGridDcs[j].ToString(); + else + fld.fieldDepGridDcs += "," + fldDepGridDcs[j].ToString(); + } + } + + fld.fieldDepGridDcs = cust.UpdateSqlDepGridDcs(transId, fld.name, fld.fieldDepGridDcs); + //Hook to add or remove a given field's sql grid dependents + fld.fieldSqlGridDeps = cust.UpdateSqlGridDependents(transId, fld.name, strSqlDeps.ToString()); + //flds[idx] = fld; + return fld; + } + + /// + /// This function will be called on a tabbed grid dc only + /// all the tab grid dc parent fields will be stored in the array dc.tabParentFields. + /// tabParentFields will have parent fields outside the current dc and parent dc is grid. + /// + /// + /// + private void FillTabGridParentFlds(DcStruct dc, FieldStruct fld) + { + if (string.IsNullOrEmpty(fld.fieldParents)) return; + string[] parFlds = fld.fieldParents.Split(','); + + for (int i = 0; i < parFlds.Length; i++) + { + int idx = GetFieldIndex(parFlds[i].ToString()); + if (idx != -1) + { + FieldStruct pFld = (FieldStruct)flds[idx]; + DcStruct depDc = (DcStruct)dcs[pFld.fldframeno - 1]; + if (depDc.isgrid && depDc.frameno != dc.frameno && dc.tabParentFields.IndexOf(pFld.name) == -1) + { + dc.tabParentFields.Add(pFld.name); + } + } + } + } + + /// + /// This function will be called for every dc which has fillgrid + /// Updates the tabParentFields with the fillsql params which are grid fields and outside the current dc. + /// + /// + /// + private void FillTabGridParentFlds(int frameNo, DcStruct dc) + { + int idx = GetFillGridIndex("dc" + frameNo.ToString()); + if (idx != -1) + { + FGStruct fg = (FGStruct)fgs[idx]; + if (fg.fgSqlParams != string.Empty) + { + string[] fgParFields = fg.fgSqlParams.Split(','); + for (int i = 0; i < fgParFields.Length; i++) + { + int index = GetFieldIndex(fgParFields[i].ToString()); + if (index != -1) + { + FieldStruct pFld = (FieldStruct)flds[index]; + DcStruct depDc = (DcStruct)dcs[pFld.fldframeno - 1]; + if (depDc.isgrid && depDc.frameno != dc.frameno && dc.tabParentFields.IndexOf(pFld.name) == -1) + { + dc.tabParentFields.Add(pFld.name); + } + } + } + } + } + } + + private void GetGridExpDependents(DcStruct dc, FieldStruct fld) + { + if (fld.fieldDependents != string.Empty) + { + string[] depFlds = fld.fieldDependents.Split(','); + for (int j = 0; j < depFlds.Length; j++) + { + if (depFlds[j].ToString() != string.Empty) + { + string depName = depFlds[j].ToString().Substring(1); + string fChar = depFlds[j].ToString().Substring(0, 1); + if (fChar == "e") + { + int dIdx = GetFieldIndex(depName); + if (dIdx != -1) + { + FieldStruct depFld = (FieldStruct)flds[dIdx]; + DcStruct depDc = (DcStruct)dcs[depFld.fldframeno - 1]; + if (dc.frameno < depDc.frameno) + { + if (dc.dcExpressionDeps.ToString() == "") + dc.dcExpressionDeps.Append(depName); + else + dc.dcExpressionDeps.Append("," + depName); + } + + } + } + } + } + } + } + + /// + /// Updates the dependents and their parents in the fields + /// + private void FillNGSqlDepParents() + { + ArrayList gridDcs = GetGridDcs(); + for (int dcIdx = 0; dcIdx < dcs.Count; dcIdx++) + { + DcStruct dc = (DcStruct)dcs[dcIdx]; + string[] dcRange = GetDcFieldRange(dc.frameno.ToString()).Split(','); + int startIdx = Convert.ToInt32(dcRange[0]); + int endIdx = Convert.ToInt32(dcRange[1]); + bool isTabbedDc = Convert.ToBoolean(IsDcTab(dc.frameno)); + int fIdx = 0; + StringBuilder strDcMRFields = new StringBuilder(); + for (int i = startIdx; i <= endIdx; i++) + { + TStructDef.FieldStruct fld = (TStructDef.FieldStruct)flds[i]; + fIdx = i; + + + if (fld.moe.ToUpper() == moe.ACCEPT.ToString() && fld.selectmode == "From Master") + { + if (strDcMRFields.ToString() == string.Empty) + strDcMRFields.Append(fld.name); + else + strDcMRFields.Append("," + fld.name); + } + + //if (isTabbedDc)//AXP-C-0000185, SQL parameter field is in griddc and its depending on other grid dc field so required tabParentFields fields. + FillTabGridParentFlds(dc, fld); + + //THis function sets the grid sql dependents outside the current dc + fld = SetFieldGridSqlDeps(fld, dc, i); + + if (dc.isgrid) + { + GetGridExpDependents(dc, fld); + StringBuilder depParents = new StringBuilder(); + if (fld.fieldSqlDeps != string.Empty) + { + string[] sqlDeps = fld.fieldSqlDeps.Split(','); + for (int j = 0; j < sqlDeps.Length; j++) + { + string depName = sqlDeps[j].ToString().Substring(1); + int dIdx = GetFieldIndex(depName); + + if (dIdx != -1) + { + FieldStruct depFld = (FieldStruct)flds[dIdx]; + DcStruct depDc = (DcStruct)dcs[depFld.fldframeno - 1]; + if (!depDc.isgrid) + { + //get the parents for non grid sql dependents and check for the fields in same dc + string[] parFlds = depFld.fieldParents.Split(','); + for (int k = 0; k < parFlds.Length; k++) + { + int parIdx = GetFieldIndex(parFlds[k].ToString()); + if (parIdx != -1) + { + FieldStruct parFld = (FieldStruct)flds[parIdx]; + DcStruct parDc = (DcStruct)dcs[parFld.fldframeno - 1]; + if (parDc.frameno == dc.frameno) + { + if (depParents.ToString() == string.Empty) + depParents.Append(parFld.name); + else + depParents.Append("," + parFld.name); + } + } + else + { + //TODO: this is error condition when the parent field is not available in the tstruct. + } + } + } + } + } + } + fld.fieldSqlDepParents = depParents.ToString(); + } + else + { + //Fill grid dependency for a non grid field + ArrayList arrDepDcs = new ArrayList(); + if (fld.fieldDependents != string.Empty) + { + string[] depFlds = fld.fieldDependents.Split(','); + for (int j = 0; j < depFlds.Length; j++) + { + if (depFlds[j].ToString() != string.Empty) + { + string depName = depFlds[j].ToString().Substring(1); + string prefix = depFlds[j].ToString().Substring(0, 1); + if (prefix == "g" && depName.Substring(0, 2) == "dc") + { + int depDcNo = Convert.ToInt32(depName.Substring(2)); + if (gridDcs.IndexOf(depDcNo) != -1 && arrDepDcs.IndexOf(depDcNo) == -1) + arrDepDcs.Add(depDcNo); + } + else + { + int idx = GetFieldIndex(depName); + if (idx != -1) + { + FieldStruct depFld = (FieldStruct)flds[idx]; + if (gridDcs.IndexOf(depFld.fldframeno) != -1 && arrDepDcs.IndexOf(depFld.fldframeno) == -1) + arrDepDcs.Add(depFld.fldframeno); + } + } + } + } + + StringBuilder strDepDcs = new StringBuilder(); + for (int k = 0; k < arrDepDcs.Count; k++) + { + if (strDepDcs.ToString() == string.Empty) + strDepDcs.Append(arrDepDcs[k].ToString()); + else + strDepDcs.Append("," + arrDepDcs[k].ToString()); + } + + //TODO: this will store the dep fill grid dcs for a non grid field. + //fld.fieldDepFillDcs = strDepDcs.ToString(); + + } + } + + flds[fIdx] = fld; + } + FillTabGridParentFlds(dc.frameno, dc); + //Update the sql fields in the dc. + dc.DCAcceptMRFields = strDcMRFields.ToString(); + //update the parent flds for tab dc + dcs[dc.frameno - 1] = dc; + LoadDCNewArray(dc); + } + } + + private ArrayList GetGridDcs() + { + ArrayList gridDcs = new ArrayList(); + foreach (DcStruct dc in dcs) + { + if (dc.isgrid) + gridDcs.Add(dc.frameno); + } + return gridDcs; + } + + + /// + /// Function to generate the Tstruct Header Html. + /// + /// + /// + public string GetHeaderHtml(string Caption) + { + + StringBuilder strHeader = new StringBuilder(); + + //string nextimg = "../AxpImages/icons/16x16/navigate_wtright.png"; + //string previmg = "../AxpImages/icons/16x16/navigate_wtleft.png"; + //Util.Util util = new Util.Util(); + //string direction1 = "left"; + //string direction2 = "righbreadcrumb-panelt"; + //if (HttpContext.Current.Session["language"].ToString() == "ARABIC") + //{ + // direction1 = "right"; + // direction2 = "left"; + //} + ////if (util.BreadCrumb && breadCrumStr == string.Empty) + + //// //headerHtml.Append("
    " + breadCrumStr + Caption + "
    "); + + ////else if + + + + //strHeader.Append(""); + + strHeader.Append("

    " + Caption + "

    "); + + return strHeader.ToString(); + } + + /// + /// Main function to construct Dc Html. + /// + /// + /// + public string GetDcHtml(int dcNo) + { + StringBuilder dcFinalHtml = new StringBuilder(); + string fieldhtml = string.Empty; + fldNo = 0; + colCount = 0; + fieldhtml = GetFieldHtml(dcNo); + dcFinalHtml.Append(GetFullDCHtml(dcNo, fieldhtml, "false")); + + return dcFinalHtml.ToString(); + } + + /// + /// Function to construct dc as per page position + /// + /// + /// + public string GetPagePositionHtml(string dcNo) + { + StringBuilder dcFinalHtml = new StringBuilder(); + string fieldhtml = string.Empty; + if (dcNo.Contains(",")) + { + dcFinalHtml.Append(GetDCTabs(dcNo)); + } + else + { + + if (IsDcFormatGrid(Convert.ToInt32(dcNo))) + { + TStructData tstData = new TStructData("", transId, "0", this); + dcFinalHtml.Append(GetDefaultFormatGridHtml(Convert.ToInt32(dcNo), tstData, 1, "formatGrid", "false")); + } + else + { + fieldhtml = GetFieldHtml(Convert.ToInt32(dcNo)); + + if (tstLayout == Constants.TILE) + { + dcFinalHtml.Append("
    "); + } + + dcFinalHtml.Append(GetFullDCHtml(Convert.ToInt32(dcNo), fieldhtml, "false")); + + if (tstLayout == Constants.TILE) + { + dcFinalHtml.Append("
    "); + if ((Convert.ToInt32(dcNo) % 2) == 0) + { + dcFinalHtml.Append("
    "); + } + } + } + } + return dcFinalHtml.ToString(); + } + + /// + /// Function to construct dc as per page position in DesignMode + /// + /// + /// + public string GetPagePositionHtmlDesign(string dcNo) + { + StringBuilder dcFinalHtml = new StringBuilder(); + string fieldhtml = string.Empty; + if (dcNo.Contains(",")) + { + dcFinalHtml.Append(GetDCTabsDesign(dcNo)); + } + else + { + + if (IsDcFormatGrid(Convert.ToInt32(dcNo))) + { + TStructData tstData = new TStructData("", transId, "0", this); + //dcFinalHtml.Append(GetTabFullHTML(Convert.ToInt32(dcNo), 1, tstData, "false", "false")); + dcFinalHtml.Append(GetDefaultFormatGridHtml(Convert.ToInt32(dcNo), tstData, 1, "formatGrid", "false")); + } + else + { + fieldhtml = GetFieldHtml(Convert.ToInt32(dcNo)); + dcFinalHtml.Append(GetFullDCHtml(Convert.ToInt32(dcNo), fieldhtml, "false")); + } + } + return dcFinalHtml.ToString(); + } + + private int GetMaxTabDcsHgt(string[] dcNos) + { + int dcHeight = 0; + for (int j = 0; j < dcNos.Length; j++) + { + int tabNo = Convert.ToInt32(dcNos[j]); + DcStruct dc = (DcStruct)(dcs[tabNo - 1]); + if (dcHeight < dc.dcHeight) + dcHeight = dc.dcHeight; + } + return dcHeight; + } + + /// + /// Function to construct tabs for dc's. + /// + /// + /// + public string GetDCTabs(string dcNo) + { + StringBuilder tabHdrHtml = new StringBuilder(); + StringBuilder tabInnerHtml = new StringBuilder(); + string fieldhtml = string.Empty; + string finalHtml = string.Empty; + string strGridHtml = string.Empty; + + string[] dcNos = dcNo.Split(','); + string tabAlign = "left"; + + if (HttpContext.Current.Session["language"].ToString() == "ARABIC") + tabAlign = "right"; + + //write a function to get the max tab height + maxDcHeight = GetMaxTabDcsHgt(dcNos); + if (maxDcHeight < 250) + maxDcHeight = 255; + tabHdrHtml.Append("
    "); + for (int j = 0; j < dcNos.Length; j++) + { + int tabNo = Convert.ToInt32(dcNos[j]); + tabDCs.Add(tabNo); + tabFunction = string.Empty; + DcStruct dc = (DcStruct)(dcs[tabNo - 1]); + + if (j == 0) + { + tabHdrHtml.Append("
      "); + tabInnerHtml.Append("
      "); + if (IsDcFormatGrid(tabNo)) + { + TStructData tstData = new TStructData("", transId, "0", this); + strGridHtml = GetDefaultFormatGridHtml(tabNo, tstData, 1, "true", "false"); + } + else + { + fieldhtml = GetFieldHtml(tabNo); + strGridHtml = "
      " + GetFullDCHtml(tabNo, fieldhtml, "true") + "
      "; + } + tabDCStatus.Add("1"); + } + else + { + tabDCStatus.Add("0"); + } + + string activeClass = String.Empty; + activeClass = j == 0 ? "active" : ""; + tabHdrHtml.Append("
    • " + dc.caption + "
    • "); + + tabInnerHtml.Append("
      "); + if (j == 0) + tabInnerHtml.Append(strGridHtml); + + tabInnerHtml.Append("
      "); + + if (j == dcNos.Length - 1) + { + tabHdrHtml.Append("
    "); + tabInnerHtml.Append("
    "); + } + } + finalHtml = tabHdrHtml.ToString() + tabInnerHtml.ToString() + "
    "; + return finalHtml; + } + + /// + /// Function to construct tabs for dc's. + /// + /// + /// + public string GetDCTabsDesign(string dcNo) + { + StringBuilder tabHdrHtml = new StringBuilder(); + StringBuilder tabInnerHtml = new StringBuilder(); + string fieldhtml = string.Empty; + string finalHtml = string.Empty; + string strGridHtml = string.Empty; + + string[] dcNos = dcNo.Split(','); + string tabAlign = "left"; + + if (HttpContext.Current.Session["language"].ToString() == "ARABIC") + tabAlign = "right"; + + //write a function to get the max tab height + maxDcHeight = GetMaxTabDcsHgt(dcNos); + if (maxDcHeight < 250) + maxDcHeight = 255; + + for (int j = 0; j < dcNos.Length; j++) + { + int tabNo = Convert.ToInt32(dcNos[j]); + tabDCs.Add(tabNo); + tabFunction = string.Empty; + DcStruct dc = (DcStruct)(dcs[tabNo - 1]); + + if (j == 0) + { + // tabHdrHtml.Append("
      "); + tabHdrHtml.Append("
      "); + tabHdrHtml.Append(""); + tabInnerHtml.Append("
      "); + } + } + + finalHtml = tabHdrHtml.ToString() + tabInnerHtml.ToString() + "
    "; + return finalHtml; + } + + /// + /// Gets the tab inner html for the currently clicked tabbed DC. + /// + /// + /// + public string GetTabHtml(string DcNo) + { + int tabNo = 0; + if (DcNo != "") + tabNo = Convert.ToInt32(DcNo); + string fieldhtml = string.Empty; + string finalHtml = string.Empty; + fieldhtml = GetFieldHtml(tabNo); + finalHtml = (GetFullDCHtml(tabNo, fieldhtml, "true")); + return finalHtml; + } + + /// + /// Function to check if the field is checkbox in grid. + /// + /// + /// + private Boolean IsGridCheckBox(string[] moeValue) + { + bool chkBox = false; + + if (moeValue.Length <= 3) + { + StringBuilder tmpStr = new StringBuilder(); + for (int cnt = 0; cnt < moeValue.Length; cnt++) + { + tmpStr.Append(moeValue[cnt].ToLower()); + } + chkBox = tmpStr.ToString() == "yesno" || tmpStr.ToString() == "noyes" ? true : false; + } + return chkBox; + } + + /// + /// Function to return the currently visible DC's in the tstruct. + /// + /// + public string GetVisibleDCs() + { + int i = 0; string strDc = string.Empty; + for (i = 0; i < visibleDCs.Count; i++) + { + if (i == 0) + { + strDc = "dc" + visibleDCs[i].ToString(); + } + else + { + strDc += "," + "dc" + visibleDCs[i].ToString(); + } + } + return strDc; + } + + /// + /// Function to construct the field's id from the arrays. + /// + /// + /// The Component field ID of the given field name. + public string GetFieldID(string fieldName) + { + string fieldId = ""; + int dcNo = 0; + for (int i = 0; i < flds.Count; i++) + { + FieldStruct fld = (FieldStruct)flds[i]; + if (fld.name == fieldName) + { + dcNo = fld.fldframeno; + break; + } + } + + bool IsGrid = false; + for (int j = 0; j < dcs.Count; j++) + { + DcStruct dc = (DcStruct)dcs[j]; + if (dc.frameno == dcNo) + { + IsGrid = dc.isgrid; + break; + } + } + + if (IsGrid) + fieldId = fieldName + "001F" + dcNo; + else + fieldId = fieldName + "000F" + dcNo; + + return fieldId; + } + + /// + /// Function to get the index of the given field from the fields in the tstruct. + /// + /// + /// + public int GetFieldIndex(string fieldName) + { + int fieldIndex = -1; + for (int i = 0; i < flds.Count; i++) + { + FieldStruct fld = (FieldStruct)flds[i]; + if (fld.name.ToUpper() == fieldName.ToUpper()) + { + fieldIndex = i; + break; + } + } + return fieldIndex; + } + public int GetFieldDc(string fieldName) + { + int dcNo = 0; + for (int i = 0; i < flds.Count; i++) + { + FieldStruct fld = (FieldStruct)flds[i]; + if (fld.name.ToLower() == fieldName.ToLower()) + { + dcNo = fld.fldframeno; + break; + } + } + return dcNo; + } + + public string GetFieldParents(string fieldName) + { + string fieldParents = string.Empty; + for (int i = 0; i < flds.Count; i++) + { + FieldStruct fld = (FieldStruct)flds[i]; + if (fld.name.ToLower() == fieldName.ToLower()) + { + fieldParents = fld.fieldParents; + break; + } + } + return fieldParents; + } + + public int GetButtonIndex(string btnName) + { + int btnIndex = -1; + for (int i = 0; i < btns.Count; i++) + { + ButtonStruct invbtn = (ButtonStruct)btns[i]; + if (invbtn.ID.ToUpper() == btnName.ToUpper()) + { + btnIndex = i; + break; + } + } + return btnIndex; + } + + public string GetColumnWidth(string dcNo, string columnName) + { + string colWidth = defaultColWidth; + for (int i = 0; i < fldDcRange.Count; i++) + { + string[] fldRange = fldDcRange[i].ToString().Split('~'); + if (dcNo == fldRange[0].ToString()) + { + string[] dcIndex = fldRange[1].Split(','); + int startIndex = Convert.ToInt32(dcIndex[0].ToString()); + int endIndex = Convert.ToInt32(dcIndex[1].ToString()); + for (int j = startIndex; j <= endIndex; j++) + { + FieldStruct fld = (FieldStruct)flds[j]; + if (fld.caption.ToLower() == columnName.ToLower()) + { + string fldWidth = fld.cwid; + if (fldWidth != "" && Convert.ToInt32(fldWidth) > -1) + { + if (Convert.ToInt32(colWidth) > 130) colWidth = "100"; + colWidth = fldWidth; + break; + } + } + } + } + } + return colWidth; + } + + + #region GetJScriptArrays + /// + /// Function to Get the javascript dependency arrays and write it on to the response + /// + /// + public string GetJScriptArrays(TStructDef strObj) + { + string tst_Scripts = string.Empty; + StringBuilder strJSArray = new StringBuilder(); + strJSArray.Append(strObj.jsFieldArray); + strJSArray.Append(strObj.jsFormcontrolArray); + strJSArray.Append(strObj.jsHyperlinkArray); + strJSArray.Append(strObj.jsPatternArray); + strJSArray.Append(strObj.jsExpressionArray); + strJSArray.Append(strObj.jsDCArray); + strJSArray.Append(strObj.jsTabDCArray); + + string tstructDetails = "var tstructName='" + strObj.transId + "';var tstructCaption='" + ReplaceSpecialCharsInHTML(strObj.tstCaption) + "';var tstructAttachment='" + strObj.tstAttachment + "';var tstructCancelled='" + strObj.tstCancelled + "';var tstructUpdateOn='" + strObj.tstUpdateOn + "';var tstructUpdatedBy='" + strObj.tstUpdateBy + "';var tstructReadonly='" + strObj.tstReadOnly + "';var tstructWorkflow='" + strObj.tstWorkflow + "';"; + + string listFlds = "AxFromLstFlds='" + fromListFlds + "';"; + + string dcNum = "TotalDCs='" + strObj.dcs.Count + "';"; + tst_Scripts = ""; + tst_Scripts = tst_Scripts.Replace("\n", ""); + return tst_Scripts; + } + + /// + /// Function to return the tab event by generating the script for tab container. + /// + /// + /// + public string GenerateTabScript(TStructDef strObj) + { + StringBuilder dcScript = new StringBuilder(); + dcScript.Append(""); + } + } + dcScript.Append("}"); + + //return tabScript.ToString() + dcScript.ToString(); + return dcScript.ToString(); + } + + public Boolean IsDcGrid(int dcNo) + { + Boolean isGrid = false; + for (int i = 0; i < dcs.Count; i++) + { + DcStruct dcStr = (DcStruct)dcs[i]; + if (dcStr.frameno == dcNo) + { + if (dcStr.isgrid) + isGrid = true; + else + isGrid = false; + } + } + return isGrid; + } + + + #endregion + + #endregion + + #region Field HTML + + /// + /// function to construct the field html for a particular dc. It doesnot contains the outer + /// part of the DC like outer border, DC header, ADD, Fill. + /// It iterates throug the complete fields, check whether it belongs the DC by checking the + /// frame no. Then it constructs the HTML string for that field and appended to the DC HTML. + /// + /// + /// + /// returns the field html. + private string GetFieldHtml(int dcNo) + { + //NOTE: Assigning javascript functions for grid and non-grid fields's is done seperately, + //as the grid field javascript functions are written into the hidden field through the variable gridHiddenHtml. + //The difference for grid functions is usage of \"+quo+\" instead of \". + //The hidden field is used to store the dummy row value, + //the value assigned to hidden field will be written within double quotes and hence we use \"+quo+\" to write a double quote in the HTML. + colCount = 0; + Boolean isGrid = ((DcStruct)(dcs[dcNo - 1])).isgrid; + DcStruct dc = (DcStruct)(dcs[dcNo - 1]); + if (isGrid) + { + dcArrayNo++; + } + string divDirection = "left"; + if (HttpContext.Current.Session["language"].ToString() == "ARABIC") + { + divDirection = "right"; + } + int fcwidth = 0; + string colFldCaption = "", colFldWidth = "", colFldGridStackItem = "", colDivInputPadding = ""; + if (!isGrid && (axdesignJObject.dcLayout != null && axdesignJObject.dcLayout != "" && axdesignJObject.dcLayout != "default")) + { + fcwidth = int.Parse(axdesignJObject.fieldCaptionWidth); + fcwidth = fcwidth / 10; + colFldCaption = "col-sm-" + fcwidth + ""; + fcwidth = 12 - fcwidth; + colFldWidth = "
    "; + colFldGridStackItem = " colFldGridStackWidth "; + colDivInputPadding = " colDivInputPadding "; + } + + if (colFldWidth == "") + colFldWidth = "
    "; + + dummyGridHeadHtml = new StringBuilder(); + gridDcColwidth = 0; + gridHeadHtml = new StringBuilder(); + gridHiddenHtml = new StringBuilder(); + string colSpan = string.Empty; + string gridStackData = string.Empty; + string lblBsClass = string.Empty; + string lblBsIndex = string.Empty; + string fldBsClass = string.Empty; + Boolean isLastDcDate = false; + int randomID = 10; + StringBuilder fieldHtml = new StringBuilder(); + lastDcHeight = 0; + int gridInSlackGridX = 0; + int gridInSlackGridY = 0; + string layoutstyle = string.Empty; + if (HttpContext.Current.Session["layoutstyle"] != null) + { + layoutstyle = HttpContext.Current.Session["layoutstyle"].ToString(); + } + + for (int i = 0; i <= flds.Count - 1; i++) + { + FieldStruct fld = ((FieldStruct)(flds[i])); + if (fld.fldframeno < dcNo) continue; + if (fld.fldframeno > dcNo) break; + if (fld.fldframeno == dcNo) + { + //As the following code is going to be called for each field, + //its not made as method to avoid function call. + string[] tlhw; + if (fld.lbltlhw.ToString() != "") + { + tlhw = fld.lbltlhw.ToString().Split(','); + if (EnableOldTheme == "false") + { + tlhw[0] = Math.Floor((Convert.ToInt32(tlhw[0].ToString()) * 1.6)).ToString(); + tlhw[2] = "30"; + tlhw[1] = Math.Floor((Convert.ToInt32(tlhw[1].ToString()) * 1.07)).ToString(); + tlhw[3] = Math.Floor((Convert.ToInt32(tlhw[3].ToString()) * 1.15)).ToString(); + } + else + { + tlhw[0] = Math.Floor((Convert.ToInt32(tlhw[0].ToString()) * 1.2)).ToString(); + tlhw[1] = Math.Floor((Convert.ToInt32(tlhw[1].ToString()) * 1.0)).ToString(); + } + } + else + { + tlhw = ",,,".Split(','); // Hack: directly entering the data to the tlhw throws error + tlhw[0] = ""; + tlhw[1] = ""; + tlhw[2] = ""; + tlhw[3] = ""; + } + + + + string[] fldTlhw; + if (fld.fldtlhw.ToString() != "") + { + fldTlhw = fld.fldtlhw.ToString().Split(','); + if (EnableOldTheme == "false") + { + fldTlhw[0] = Math.Floor((Convert.ToInt32(fldTlhw[0].ToString()) * 1.6)).ToString(); + fldTlhw[1] = Math.Floor((Convert.ToInt32(fldTlhw[1].ToString()) * 1.07)).ToString(); + } + else + { + fldTlhw[0] = Math.Floor((Convert.ToInt32(fldTlhw[0].ToString()) * 1.2)).ToString(); + fldTlhw[1] = Math.Floor((Convert.ToInt32(fldTlhw[1].ToString()) * 1.0)).ToString(); + } + + + } + else + { + fldTlhw = ",,,".Split(','); // Hack: directly entering the data to the tlhw throws error + fldTlhw[0] = "0"; + fldTlhw[1] = "0"; + fldTlhw[2] = "0"; + fldTlhw[3] = "0"; + } + + if (fld.fldlength != 0) + { + lblBsClass = bsClassByDatawidth(fld.fldlength, i, fld); + lblBsIndex = fld.fieldIndex.ToString(); + } + + if (!fld.visibility) + gridStackData = xywhGridStack(fld); + + string name = string.Empty; + string hiddenName = string.Empty; + string width = string.Empty; + string fdwidth = "0"; + int rndnumber = 0; + Random randNum = new Random(); + rndnumber = randNum.Next(100000, 1000000); + fldNo = i; + + if (!fld.visibility) + fdwidth = xywhGridStack(fld, true); + + if (isGrid) + { + name = fld.name + "001F" + fld.fldframeno; + hiddenName = fld.name + "\" +nrno+\""; + // for grid its column width + width = fld.cwid; + if (!fld.visibility) + { + if (width != "") + gridDcColwidth += Convert.ToInt32(width); + else + gridDcColwidth += 1; + } + } + else + { + name = fld.name + "000F" + fld.fldframeno; + width = fldTlhw[3]; + } + + if (width == "") + width = "0"; + else + width = Convert.ToString(Convert.ToInt32(width) - 4); + + if (fld.caption.Contains("~")) + fld.caption = fld.caption.Replace("~", "\n"); + + + if (fld.visibility) + { + string cssAutoGen = string.Empty; + if (fld.moe == "AutoGenerate") + cssAutoGen = "class=\"autogen\""; + + if (name.StartsWith("axp_recid")) + { + fieldHtml.Append("
    "); + if (isGrid) + gridHiddenHtml.Append("
    "); + } + else + { + if (fld.name.ToLower().StartsWith("axpfilepath_") && cssAutoGen == "") + { + var endPart = name.Substring(12); + cssAutoGen = "class=\"axpFilePath_" + endPart + " axpFilePathFld \""; + } + if (fld.moe == "Select") + fieldHtml.Append("
    "); + else + fieldHtml.Append("
    "); + if (isGrid) + gridHiddenHtml.Append("
    "); + + } + if (fld.caption.Contains("~")) + { + gridHeadHtml.Append("
    "); + } + else + { + gridHeadHtml.Append("
    "); + } + } + + + if (!fld.visibility) + { + randomID++; + string popImg = string.Empty; + string popImgHidden = string.Empty; + int popwidth = 0; + for (int x = 0; x < popdcs.Count; x++) + { + if (((DcStruct)(dcs[dcNo - 1])).frameno == ((PopDcStruct)(popdcs[x])).pdcno) + { + if (fld.name.ToLower() == ((PopDcStruct)(popdcs[x])).popfield.ToLower()) + { + popImgHidden = "
    "; + popImg = "
    "; + popwidth = Convert.ToInt32(width) - 20; + break; + } + } + } + + + if (!isGrid) + { + if (fldTlhw[0] != "") + lastDcHeight = Convert.ToInt32(fldTlhw[0]) + Convert.ToInt32(fldTlhw[2]); + else if (fldTlhw[2] != "") + lastDcHeight = Convert.ToInt32(fldTlhw[2]); + } + bool isHyper = false; + int n = 0; + for (n = 0; n <= hlnks.Count - 1; n++) + { + if (fld.name.ToString() == ((HLinkStruct)(hlnks[n])).hlsource.ToString().Substring(3)) + { + isHyper = true; + break; + } + } + + string designFontStyle = ""; + string designHyperLink = ""; + if (!isGrid) + { + if (axdesignJObject.buttonFieldFont != null && axdesignJObject.buttonFieldFont.Count > 0) + { + var frbtnfld = axdesignJObject.buttonFieldFont.Where(elm => elm.id == name).ToList(); + if (frbtnfld != null && frbtnfld.Count > 0) + { + designFontStyle = frbtnfld[0].fontFamilly; + designHyperLink = frbtnfld[0].hyperlinkJson; + } + } + } + + if (isGrid) + { + string allowemptycss = ""; + if (!fld.allowempty && fld.caption != "") + allowemptycss = " required "; + colCount++; + if (fld.caption.Contains("~")) + { + gridHeadHtml.Append("
    "); + } + else if (fld.datatype.ToUpper() == "DATE/TIME") + { + gridHeadHtml.Append("
    "); + } + else + { + gridHeadHtml.Append("
    "); + } + + if (isHyper) + { + gridHeadHtml.Append(""); + } + if (fld.name.ToUpper().IndexOf("AXPBUTTON") == -1) + { + if (fld.caption.Contains("~")) + fld.caption = fld.caption.Replace("~", "\n"); + + gridHeadHtml.Append(fld.caption); + } + if (isHyper) + { + gridHeadHtml.Append(""); + } + + // to handle the mandatory fields. + //if (!fld.allowempty && fld.caption != "") + //{ + // gridHeadHtml.Append("*"); + //} + + if (!string.IsNullOrEmpty(fld.fieldPurpose)) + gridHeadHtml.Append(""); + gridHeadHtml.Append("
    "); + } + else + { + if (fld.ctype.ToUpper() != "CHECK BOX") + { + fieldHtml.Append("
    " + (randomID - 10) + "
    "); + string color = "cursor: default;"; + if (fld.fieldLabelCss != "") + { + //label font will be in the format "font-family,font-size,tttt,color". here the tttt-bold/italic/underline/strikeout + string[] newCss = fld.fieldLabelCss.Split(','); + string fontFamily = ""; + string fontSize = ""; + string textCss = ""; + + if (newCss.Length > 0) + { + if (newCss[0].ToString() != "") + fontFamily = "font-family:" + newCss[0].ToString() + ";"; + } + if (newCss.Length > 1) + { + if (newCss[1].ToString() != "") + fontSize = "font-size:" + newCss[1].ToString() + ";"; + } + + if (newCss.Length > 2) + { + if (newCss[2].ToString() != "") + { + string fontStyle = newCss[2].ToString(); + + if (fontStyle.Substring(0, 1) == "t") + textCss = "font-weight:bold;"; + if (fontStyle.Substring(1, 1) == "t") + textCss += "font-style:italic;"; + if (fontStyle.Substring(2, 1) == "t") + textCss += "text-decoration:underline;"; + if (fontStyle.Substring(3) == "t") + textCss += "text-decoration:overline;"; + } + } + if (newCss.Length > 3) + { + if (newCss[3].ToString() != "") + { + string txtColor = newCss[3].ToString().Substring(2); + textCss += " color:" + txtColor + "; "; + } + } + if (newCss.Length >= 4) + { + //changes for lable colors + string lblclr = fld.fieldLabelCss.Split(',').Last(); + string[] lblFonts = fld.fieldLabelCss.Split(','); + if (lblclr != "") + color += " color:" + GetFieldColor(lblclr) + "; "; + if (lblFonts[1] != "" && int.Parse(lblFonts[1]) >= 13) + color += " font-size:" + lblFonts[1] + "px; "; + if (lblFonts[2] != "") + { + if (lblFonts[0] != "" && lblFonts[2] != "ttff") + color += " font-family:" + lblFonts[0] + "; "; + if (lblFonts[2] == "tfff") + color += " font-weight:Bold; "; + else if (lblFonts[2] == "ftff") + color += " font-style:Oblique; "; + else if (lblFonts[2] == "ttff") + color += " font-family:Bold Oblique; "; + } + } + + //TODO: the font family is not considered as the ui alignment is not proper in web. we can enable it in future. + //fieldHtml.Append(""); + } + + if (isHyper) + fieldHtml.Append(""); + else if (designHyperLink != "") + fieldHtml.Append(""); + if (fld.allowempty && fld.caption != "") + fieldHtml.Append("
    "); + else + fieldHtml.Append(""); + } + else + { + fieldHtml.Append("
    " + (randomID - 10) + "
    "); + //label normal + fieldHtml.Append("
    "); + //fieldHtml.Append("