From 2aede91f9b083f48b804e14c93252ed2ad2f0cd1 Mon Sep 17 00:00:00 2001 From: Mattia Tollari Date: Fri, 19 Oct 2018 09:24:45 +0200 Subject: [PATCH] Patch level : 12.0 no-patch Files correlati : ps Commento : - Creato programma creazione/esportazione tabelle campo per Diana 2000, potrebbe essere una versione migliorata del ba2900 - Sistemati progetti ps --- build/ps.sln | 15 +- build/ps0017.vcxproj | 5 +- build/ps0077.vcxproj | 5 +- build/ps0099.vcxproj | 5 +- build/ps0330.vcxproj | 5 +- build/ps0398.vcxproj | 5 +- build/ps0430.vcxproj | 5 +- build/ps0431.vcxproj | 5 +- build/ps0544.vcxproj | 5 +- build/ps0713.vcxproj | 5 +- build/ps0816.vcxproj | 5 +- build/ps0830.vcxproj | 5 +- build/ps0872.vcxproj | 5 +- build/ps0883.vcxproj | 5 +- build/ps0913 .vcxproj | 5 +- build/ps0920.vcxproj | 5 +- build/ps0925.vcxproj | 5 +- build/ps0982 .vcxproj | 5 +- build/ps1001.vcxproj | 5 +- build/ps1004.vcxproj | 185 ++++++++++++++++++++ build/ps1004.vcxproj.filters | 41 +++++ build/ps1100.vcxproj | 5 +- build/ps1104.vcxproj | 5 +- src/ps/ps1004.cpp | 15 ++ src/ps/ps1004.h | 7 + src/ps/ps1004100.cpp | 326 +++++++++++++++++++++++++++++++++++ src/ps/ps1004100a.h | 4 + src/ps/ps1004100a.uml | 43 +++++ 28 files changed, 714 insertions(+), 22 deletions(-) create mode 100644 build/ps1004.vcxproj create mode 100644 build/ps1004.vcxproj.filters create mode 100644 src/ps/ps1004.cpp create mode 100644 src/ps/ps1004.h create mode 100644 src/ps/ps1004100.cpp create mode 100644 src/ps/ps1004100a.h create mode 100644 src/ps/ps1004100a.uml diff --git a/build/ps.sln b/build/ps.sln index c1bda93cb..d873c7553 100644 --- a/build/ps.sln +++ b/build/ps.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2027 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ps0430", "ps0430.vcxproj", "{E307FE10-BB05-41EE-AFA0-CB32ABAFF4DC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ps0544", "ps0544.vcxproj", "{9C56A620-4E67-4AB1-8772-27F22DEA10DA}" @@ -47,6 +49,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AgaLib", "AgaLib.vcxproj", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vedoc", "vedoc.vcxproj", "{A1CE9743-A597-4F92-B55A-345A366C9E55}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ps1004", "ps1004.vcxproj", "{FEE6BF0D-35E7-441C-AACD-B903065DC90E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -145,8 +149,15 @@ Global {A1CE9743-A597-4F92-B55A-345A366C9E55}.Debug|Win32.Build.0 = Debug|Win32 {A1CE9743-A597-4F92-B55A-345A366C9E55}.Release|Win32.ActiveCfg = Release|Win32 {A1CE9743-A597-4F92-B55A-345A366C9E55}.Release|Win32.Build.0 = Release|Win32 + {FEE6BF0D-35E7-441C-AACD-B903065DC90E}.Debug|Win32.ActiveCfg = Debug|Win32 + {FEE6BF0D-35E7-441C-AACD-B903065DC90E}.Debug|Win32.Build.0 = Debug|Win32 + {FEE6BF0D-35E7-441C-AACD-B903065DC90E}.Release|Win32.ActiveCfg = Release|Win32 + {FEE6BF0D-35E7-441C-AACD-B903065DC90E}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CFF0DFF4-4A84-4BE7-8D13-CACE234A6278} + EndGlobalSection EndGlobal diff --git a/build/ps0017.vcxproj b/build/ps0017.vcxproj index 102ca24af..e0ad21276 100644 --- a/build/ps0017.vcxproj +++ b/build/ps0017.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {DE2790CA-A340-4706-B6AD-171311213B64} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0077.vcxproj b/build/ps0077.vcxproj index e19d36675..461727b91 100644 --- a/build/ps0077.vcxproj +++ b/build/ps0077.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -13,15 +13,18 @@ {F3E85440-C87A-43C5-9EE8-680D704B8C8F} ps0077 + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0099.vcxproj b/build/ps0099.vcxproj index 37ae7e0bb..3a3f4a9ed 100644 --- a/build/ps0099.vcxproj +++ b/build/ps0099.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {FA6B7892-807C-4126-A019-9029B73EA590} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0330.vcxproj b/build/ps0330.vcxproj index 9ab0b73b1..ac7ad4e00 100644 --- a/build/ps0330.vcxproj +++ b/build/ps0330.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {7C524DB8-94A5-48FB-8D87-D0C51C433473} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0398.vcxproj b/build/ps0398.vcxproj index 3709a57f6..641fea79f 100644 --- a/build/ps0398.vcxproj +++ b/build/ps0398.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {335E96CD-D2FD-4688-9B3B-1B39858F5630} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0430.vcxproj b/build/ps0430.vcxproj index 3c0fa6e39..8749482d3 100644 --- a/build/ps0430.vcxproj +++ b/build/ps0430.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {E307FE10-BB05-41EE-AFA0-CB32ABAFF4DC} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0431.vcxproj b/build/ps0431.vcxproj index 411271ed5..c2b48b4a4 100644 --- a/build/ps0431.vcxproj +++ b/build/ps0431.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {A7BF5474-DA14-48AB-B7E3-D8B1F4D39914} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0544.vcxproj b/build/ps0544.vcxproj index 21f33d3a1..fbd3ada7d 100644 --- a/build/ps0544.vcxproj +++ b/build/ps0544.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {9C56A620-4E67-4AB1-8772-27F22DEA10DA} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0713.vcxproj b/build/ps0713.vcxproj index 33cb7d896..6bf8f337b 100644 --- a/build/ps0713.vcxproj +++ b/build/ps0713.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {E4B973C4-6B5A-4FE8-8D73-FD55F48B7CE3} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0816.vcxproj b/build/ps0816.vcxproj index 2f87f812c..d4bd722df 100644 --- a/build/ps0816.vcxproj +++ b/build/ps0816.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {6C2071C1-CF99-46B7-9330-B0CF390CCD2E} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0830.vcxproj b/build/ps0830.vcxproj index 720883b3b..5a73a3b3a 100644 --- a/build/ps0830.vcxproj +++ b/build/ps0830.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {ED2CD5CA-A826-4256-A03F-28BB519CA00B} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0872.vcxproj b/build/ps0872.vcxproj index c6f0b4978..363770b77 100644 --- a/build/ps0872.vcxproj +++ b/build/ps0872.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {1D01DF6D-E6E6-4715-A026-A802EE08BBAA} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0883.vcxproj b/build/ps0883.vcxproj index 0fab05fad..b2b80a623 100644 --- a/build/ps0883.vcxproj +++ b/build/ps0883.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -13,15 +13,18 @@ {F4BA5949-4FCD-4AF4-ABC5-CDADA21E1663} ve4 + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0913 .vcxproj b/build/ps0913 .vcxproj index 9030062fb..7ae502c17 100644 --- a/build/ps0913 .vcxproj +++ b/build/ps0913 .vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -13,15 +13,18 @@ ps0913 {1259CE4F-11A5-4E9B-84B8-437357363558} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0920.vcxproj b/build/ps0920.vcxproj index 0fecf43d9..0d38849d0 100644 --- a/build/ps0920.vcxproj +++ b/build/ps0920.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {A52ECDA0-74E6-4303-A6F4-4EE701C5945F} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0925.vcxproj b/build/ps0925.vcxproj index f8bb532f9..b58f533fe 100644 --- a/build/ps0925.vcxproj +++ b/build/ps0925.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {511A655D-306E-49FB-A1E8-BB7E8F8F8F35} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps0982 .vcxproj b/build/ps0982 .vcxproj index 691c77547..349bb410f 100644 --- a/build/ps0982 .vcxproj +++ b/build/ps0982 .vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -13,15 +13,18 @@ ps0982 {451E54F8-0F4B-4E79-A5B2-23EF9284C420} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps1001.vcxproj b/build/ps1001.vcxproj index 944db079c..0747dceea 100644 --- a/build/ps1001.vcxproj +++ b/build/ps1001.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {639CD16B-2488-4AA4-87AE-0AA286FDA2CA} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps1004.vcxproj b/build/ps1004.vcxproj new file mode 100644 index 000000000..82c602df4 --- /dev/null +++ b/build/ps1004.vcxproj @@ -0,0 +1,185 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {FEE6BF0D-35E7-441C-AACD-B903065DC90E} + 10.0.16299.0 + + + + Application + false + v141 + + + Application + false + v141 + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\exe\ + ..\obj\$(SolutionName)\$(ProjectName)\ + false + ..\exe\ + ..\obj\$(SolutionName)\$(ProjectName)\ + true + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\..\release/ps1004.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\src\xvtdb\;..\src\cg;..\src\include;..\src\xvaga;%(AdditionalIncludeDirectories) + NDEBUG;WIN32;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + .\..\release/ps1004.pch + .\..\release/ + .\..\release/ + .\..\release/ + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0410 + ..\wx28X\include;%(AdditionalIncludeDirectories) + + + wsock32.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName)$(TargetExt) + true + %(IgnoreSpecificDefaultLibraries) + .\..\release/ps1004.pdb + Windows + false + + + MachineX86 + + + true + .\..\release/ps1004.bsc + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\..\debug/ps1004.tlb + + + + + Disabled + ..\src\xvtdb\;..\src\cg;..\src\include;..\src\xvaga;%(AdditionalIncludeDirectories) + _DEBUG;WIN32;__LONGDOUBLE__;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDebug + .\..\debug/ps1004.pch + .\..\debug/ + .\..\debug/ + .\..\debug/ + true + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0410 + ..\libraries\wx28X\include;%(AdditionalIncludeDirectories) + + + wsock32.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName)$(TargetExt) + true + %(IgnoreSpecificDefaultLibraries) + true + .\..\debug/ps1004.pdb + Windows + false + + + MachineX86 + + + true + .\..\debug/ps1004.bsc + + + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + + + Compiling mask %(FullPath)... + msk32 %(FullPath) $(TargetDir)%(Filename).msk + + $(TargetDir)%(Filename).msk;%(Outputs) + Compiling mask %(FullPath)... + msk32 %(FullPath) $(TargetDir)%(Filename).msk + + $(TargetDir)%(Filename).msk;%(Outputs) + + + + + + + + + {2d38a763-3d74-4338-9362-b891784ec90e} + + + + + + + + + \ No newline at end of file diff --git a/build/ps1004.vcxproj.filters b/build/ps1004.vcxproj.filters new file mode 100644 index 000000000..15ffdb2da --- /dev/null +++ b/build/ps1004.vcxproj.filters @@ -0,0 +1,41 @@ + + + + + {2aa15991-562d-4fba-afc5-a0fd3b06ec97} + cpp + + + {c41a2928-af62-4e3d-94cd-59438053b6e2} + uml + + + {ca21a647-c7c2-492c-bbbe-26d801e87179} + h + + + + + Sources + + + Sources + + + + + Headers + + + Headers + + + + + Masks + + + + + + \ No newline at end of file diff --git a/build/ps1100.vcxproj b/build/ps1100.vcxproj index 28d706ab4..0c0a4a630 100644 --- a/build/ps1100.vcxproj +++ b/build/ps1100.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {2CC07FDE-D15A-420B-9DDB-1FDF32B73BC2} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/build/ps1104.vcxproj b/build/ps1104.vcxproj index 700d66041..778c34c26 100644 --- a/build/ps1104.vcxproj +++ b/build/ps1104.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -12,15 +12,18 @@ {45F0BF2E-66DF-44B8-9BC6-55E0ECC89DB7} + 10.0.16299.0 Application false + v141 Application false + v141 diff --git a/src/ps/ps1004.cpp b/src/ps/ps1004.cpp new file mode 100644 index 000000000..cbc671f87 --- /dev/null +++ b/src/ps/ps1004.cpp @@ -0,0 +1,15 @@ +#include +#include "ps1004.h" + +int main(int argc, char** argv) +{ + int rt = -1; + const int r = (argc > 1) ? atoi(&argv[1][1]) : 1; + + switch (r) + { + case 0: + default: rt = ps1004100(argc, argv); break; // Configurazione + } + return rt; +} \ No newline at end of file diff --git a/src/ps/ps1004.h b/src/ps/ps1004.h new file mode 100644 index 000000000..63ee2cfc3 --- /dev/null +++ b/src/ps/ps1004.h @@ -0,0 +1,7 @@ +#ifndef __PS1004_H +#define __PS1004_H + +int ps1004100(int argc, char* argv[]); + +#endif // __PS1004_H + diff --git a/src/ps/ps1004100.cpp b/src/ps/ps1004100.cpp new file mode 100644 index 000000000..0067b2a4f --- /dev/null +++ b/src/ps/ps1004100.cpp @@ -0,0 +1,326 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include "../ca/calib01.h" +#include "../cg/cgsaldac.h" +#include "../ef/ef0301.h" + +#include "ps1004.h" +#include "ps1004100a.h" +#include "utility.h" + +/////////////////////////////////////////////////////////// +// Utilities +/////////////////////////////////////////////////////////// +void set_connection(SSimple_query& s); + +SSimple_query& diana_db() +{ + static SSimple_query* db = nullptr; + + if (db == nullptr) + { + db = new SSimple_query(); + set_connection(*db); + // Non utilizzo l'autocommit, viene gestito manualmente + db->sq_set_autocommit(false); + } + return *db; +} + +void set_connection(SSimple_query& s) +{ + if (s.sq_connect( + TString() << ini_get_string(CONFIG_DITTA, "ps1004", "ip") << "@" << ini_get_string(CONFIG_DITTA, "ps1004", "db"), + ini_get_string(CONFIG_DITTA, "ps1004", "usr"), + decode(ini_get_string(CONFIG_DITTA, "ps1004", "psw")), + TSDB_MSSQL) != NOERR) + fatal_box("Impossibile connettersi al DB esterno"); +} + +const TString to_escape(const TString& val) +{ + TString& app = get_tmp_string(); + for (int k = 0; k < val.len(); k++) + { + switch (val[k]) + { + case '\'': + app << "''"; + break; + default: + app << val[k]; + break; + } + } + return app; +} + +const TString query_to_null(TString& val) +{ + int lastpos = val.find("(\'\'", 0); // Devo trovarne uno tra virgole + while (lastpos != -1) + { + lastpos++; + val[lastpos] = ' '; + val[lastpos + 1] = ' '; + val.insert("NULL", lastpos); + lastpos = val.find(",\'\'", lastpos); + } + lastpos = val.find(",\'\'", 0); // Devo trovarne uno tra virgole + while (lastpos != -1) + { + lastpos++; + val[lastpos] = ' '; + val[lastpos + 1] = ' '; + val.insert("NULL", lastpos); + lastpos = val.find(",\'\'", lastpos); + } + + return val; +} + +/////////////////////////////////////////////////////////// +// Main Mask +/////////////////////////////////////////////////////////// + +class TDianaExport_mask : public TAutomask +{ + +protected: + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + void load_all(); +public: + void save_all() const; + TDianaExport_mask(); + virtual ~TDianaExport_mask(){} +}; + +bool TDianaExport_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + return TRUE; +} + +TDianaExport_mask::TDianaExport_mask() : TAutomask("ps1004100a") +{ + load_all(); +} + +void TDianaExport_mask::save_all() const +{ + ini_set_string(CONFIG_DITTA, "ps1004", "ip", get(F_INDIRIZZO)); + ini_set_string(CONFIG_DITTA, "ps1004", "db", get(F_DATABASE)); + ini_set_string(CONFIG_DITTA, "ps1004", "usr", get(F_USER)); + ini_set_string(CONFIG_DITTA, "ps1004", "psw", encode(get(F_PASSWORD))); +} + +void TDianaExport_mask::load_all() +{ + set(F_INDIRIZZO, ini_get_string(CONFIG_DITTA, "ps1004", "ip")); + set(F_DATABASE, ini_get_string(CONFIG_DITTA, "ps1004", "db")); + set(F_USER, ini_get_string(CONFIG_DITTA, "ps1004", "usr")); + set(F_PASSWORD, decode(ini_get_string(CONFIG_DITTA, "ps1004", "psw"))); +} + + +/////////////////////////////////////////////////////////// +// Main Program +/////////////////////////////////////////////////////////// + +class TDianaExport_app : public TSkeleton_application +{ + bool _visual; + bool export_all(); + bool export_table(const int logicnum); + bool create_table(const int logicnum); + bool deploy_data(const int logicnum); + inline bool rko_outta_nowhere(const int logicnum); +public: + virtual bool create(); + virtual void main_loop(); + TDianaExport_app() : _visual(false) {} +}; + +bool TDianaExport_app::export_all() +{ + return + export_table(LF_TAB) && + export_table(LF_CLIFO) && + export_table(LF_ANAMAG) && + export_table(LF_COMUNI) && + export_table(LF_LVPASPLAN) && + export_table(LF_LVRCONDV); +} + +bool TDianaExport_app::export_table(const int logicnum) +{ + return rko_outta_nowhere(logicnum) && create_table(logicnum) && deploy_data(logicnum); +} + +bool TDianaExport_app::create_table(const int logicnum) +{ + const TString& table = logic2table(logicnum); + const RecDes& rd = prefix().get_recdes(logicnum); + + // Create new table + TString sql; sql.cut(0) << "CREATE TABLE " << table << "\n("; + for (int i = 0; i < rd.NFields; i++) + { + if (i > 0) sql << ','; + sql << rd.Fd[i].Name << ' '; + switch (rd.Fd[i].TypeF) + { + case _charfld: + case _alfafld: + sql << "VARCHAR(" << rd.Fd[i].Len << ")"; + break; + case _memofld: + sql << "TEXT"; break; + case _datefld: + sql << "DATE"; break; + case _boolfld: + sql << "BIT DEFAULT 0"; break; + case _realfld: + case _wordfld: + case _intfld: + case _longfld: + case _intzerofld: + case _longzerofld: + default: sql << "NUMERIC(" << rd.Fd[i].Len << "," << rd.Fd[i].Dec << ")"; break; + } + } + sql << ");"; + + return diana_db().sq_set_exec(sql) && diana_db().sq_commit();; +} + +bool TDianaExport_app::deploy_data(const int logicnum) +{ + const RecDes& rd = prefix().get_recdes(logicnum); + TLocalisamfile table(logicnum); + TString queryF, queryV; + TProgress_monitor p(table.items(), TString("Esportazione tabella ") << logic2table(logicnum)); + bool export_status = true; + for(bool ok = table.first() == NOERR; ok && export_status; ok = table.next() == NOERR) + { + if (_visual && !p.add_status()) + return false; + queryF.cut(0) << "INSERT INTO [" << logic2table(logicnum) << "] ("; // Tolgo il simbolo iniziale + queryV.cut(0) << "("; + for (int k = 0; k < rd.NFields; k++) + { + queryF << "[" << rd.Fd[k].Name << "]"; + if (table.get(rd.Fd[k].Name).empty()) // Vuoto, causa errori se non controllato + queryV << "''"; + else + { + switch (rd.Fd[k].TypeF) + { + case _intfld: + case _wordfld: + case _intzerofld: + queryV << "'" << table.get_int(rd.Fd[k].Name) << "'"; + break; + + case _longfld: + case _longzerofld: + queryV << "'" << table.get_long(rd.Fd[k].Name) << "'"; + break; + + // Real + case _realfld: + queryV << "'" << table.get_real(rd.Fd[k].Name).string() << "'"; + break; + + case _datefld: + queryV << "'" << table.get_date(rd.Fd[k].Name).date2ansi() << "'"; + break; + + case _boolfld: + if (table.get_bool(rd.Fd[k].Name)) + queryV << "'1'"; + else + queryV << "'0'"; + break; + + case _charfld: + case _alfafld: + default: + queryV << "'" << to_escape(table.get(rd.Fd[k].Name)) << "'"; + break; + } + } + + if (k + 1 < rd.NFields) // Modo più comodo + { + queryF << ","; + queryV << ","; + } + } + queryV << ")"; + queryF << ") VALUES " << queryV; + export_status &= diana_db().sq_set_exec(query_to_null(queryF)); + } + return export_status && diana_db().sq_commit(); +} + +bool TDianaExport_app::rko_outta_nowhere(const int logicnum) +{ + diana_db().sq_set_exec(TString().cut(0) << "DROP TABLE " << logic2table(logicnum) << ';') && diana_db().sq_commit(); + return true; +} + +bool TDianaExport_app::create() +{ + open_files(LF_TAB, LF_CLIFO, LF_ANAMAG, + LF_COMUNI, LF_LVPASPLAN, LF_LVRCONDV, 0); + return TSkeleton_application::create(); +} + +void TDianaExport_app::main_loop() +{ + TDianaExport_mask msk; + while (msk.run() == K_ENTER) + { + bool connected = false; + _visual = true; + { + TString ad; ad << msk.get(F_INDIRIZZO) << "@" << msk.get(F_DATABASE); + + SSimple_query s(ad, msk.get(F_USER), msk.get(F_PASSWORD), TSDB_MSSQL); + connected = s.sq_is_connect(); + if (connected) + { + msk.save_all(); + message_box("Dati salvati correttamente!"); + } + else + { + error_box("Impossibile stabilire una connessione al database"); + } + } + connected && yesno_box("Vuoi eseguire l'esportazione dei dati?") && export_all(); + } +} + + +int ps1004100(int argc, char* argv[]) +{ + int n = 0; + TDianaExport_app pe; + pe.run(argc, argv, TR("Esportazione tabelle per terminalino")); + return 0; +} diff --git a/src/ps/ps1004100a.h b/src/ps/ps1004100a.h new file mode 100644 index 000000000..9a2396dfb --- /dev/null +++ b/src/ps/ps1004100a.h @@ -0,0 +1,4 @@ +#define F_INDIRIZZO 101 +#define F_DATABASE 102 +#define F_USER 103 +#define F_PASSWORD 104 \ No newline at end of file diff --git a/src/ps/ps1004100a.uml b/src/ps/ps1004100a.uml new file mode 100644 index 000000000..78623cded --- /dev/null +++ b/src/ps/ps1004100a.uml @@ -0,0 +1,43 @@ +#include "ps1004100a.h" + +TOOLBAR "topbar" 0 0 0 2 +#include +ENDPAGE + +PAGE "Configurazione Server Diana" 0 2 0 0 + +GROUPBOX DLG_NULL 78 6 +BEGIN + PROMPT 1 1 "@BDatabase" +END + +STRING F_INDIRIZZO 50 +BEGIN + PROMPT 2 2 "Indirizzo " + FLAGS "" + CHECKTYPE REQUIRED +END + + +STRING F_DATABASE 15 +BEGIN + PROMPT 2 3 "Nome " + FLAGS "" + CHECKTYPE REQUIRED +END + +STRING F_USER 15 +BEGIN + PROMPT 2 4 "Utente " + FLAGS "" + CHECKTYPE REQUIRED +END + +STRING F_PASSWORD 15 +BEGIN + PROMPT 2 5 "Password " + FLAGS "*" + CHECKTYPE REQUIRED +END + +ENDPAGE \ No newline at end of file