-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGS_INIT.CPP
1890 lines (1601 loc) · 66.6 KB
/
GS_INIT.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**********************************************************
Name: GS_INIT
Module description: File contenente le procedure di inizializzazione
e di chiusura di Geosim
Author: Poltini Roberto
(c) Copyright 1995-2015 by IREN ACQUA GAS S.p.a.
Modification history:
Notes and restrictions on use:
**********************************************************/
/*********************************************************/
/* INCLUDES */
/*********************************************************/
#include "stdafx.h" // MFC core and standard components
#define INITGUID
#import "msado15.dll" no_namespace rename ("EOF", "EndOfFile") rename ("EOS", "ADOEOS")
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "adslib.h"
#include <adeads.h>
#include "GSresource.h"
#include "..\gs_def.h" // definizioni globali
#include "gs_utily.h" // (gsc_strcat, gsc_tostring)
#include "gs_error.h" // codici errori
#include "gs_list.h"
#include "gs_resbf.h" // gestione resbuf
#include "gs_ase.h" // gestione link db-grafica
#include "gs_class.h"
#include "gs_dbref.h" // cataloghi e schede
#include "gs_prjct.h" // prototipi funzioni extern
#include "gs_netw.h" // funzioni per gestione rete
#include "gs_init.h" // prototipi funzioni extern
#include "gs_ade.h"
#include "gs_lisp.h"
#include "gs_thm.h"
#include "gs_filtr.h"
#include "gs_user.h"
#include "gs_opcod.h"
#include "gs_area.h"
#include "gs_graph.h"
#include "gs_query.h"
#include "gs_evid.h" // per gsc_ddgraphBrowse
/*********************************************************/
/* TYPEDEFS */
/*********************************************************/
/*********************************************************/
/* PRIVATE VARIABLES */
/*********************************************************/
/*********************************************************/
/* FUNCTIONS */
/*********************************************************/
// Inizializzazione membri statici
CAseAppl* GEOsimAppl::ASE = NULL;
CAsiAppl* GEOsimAppl::ASI = NULL;
C_DBCONNECTION_LIST GEOsimAppl::DBCONNECTION_LIST;
C_RB_LIST GEOsimAppl::ASE_APP_ID_LIST;
C_RB_LIST GEOsimAppl::APP_ID_LIST;
C_STR_LIST GEOsimAppl::OD_TABLENAME_LIST;
C_CMDLIST GEOsimAppl::CMDLIST;
struct cmd_code GEOsimAppl::GS_COMMANDS[GS_COMMANDS_LEN];
C_STRING GEOsimAppl::GEODIR;
C_STRING GEOsimAppl::WORKDIR;
C_STRING GEOsimAppl::CURRUSRDIR;
C_INIT GEOsimAppl::GLOBALVARS;
C_ALIAS_LIST GEOsimAppl::GS_NET_LIST;
C_LIST_PRJ GEOsimAppl::PROJECTS;
C_USER GEOsimAppl::GS_USER;
C_SELSET GEOsimAppl::SAVE_SS;
C_SELSET GEOsimAppl::REFUSED_SS;
C_SET_VISIB_LIST* GEOsimAppl::ACTIVE_VIS_ATTRIB_SET = NULL;
int GEOsimAppl::LAST_CLS = 0;
int GEOsimAppl::LAST_SUB = 0;
double GEOsimAppl::TOLERANCE = 1.0E-4;
C_DYNAMIC_QRY_ATTR* GEOsimAppl::DYNAMIC_QRY_ATTR = NULL;
C_LAYER_DISPLAY_MODEL GEOsimAppl::LAYER_DISPLAY_MODEL;
AcRx::AppMsgCode GEOsimAppl::LastAppMsgCode = AcRx::kNullMsg;
C_STRING GEOsimAppl::LAST_STARTED_CMD;
C_WAIT_DLG_INSTANCE GEOsimAppl::WAIT_DLG_INSTANCE;
//C_WAIT_DLG_INSTANCE* GEOsimAppl::pWAIT_DLG_INSTANCE = NULL;
GEOsimAppl::GEOsimAppl()
{
}
GEOsimAppl::~GEOsimAppl()
{
terminate();
}
/*********************************************************/
/*.doc GEOsimAppl::init <external> */
/*+
Questa funzione inizializza GEOsim.
La procedura necessita di:
- una variabile di sistema GEOSIM contenente il direttorio di
installazione di GEOSIM (dove risiede GS_PRJ).
- una variabile di sistema GEOWORK contenente il direttorio di
lavoro locale.
- installazione di ACAD già avvenuta.
Vengono inizializzate le seguenti variabili:
- GEODIR = direttorio installazione GEOsim
- WORKDIR = direttorio di lavoro di GEOsim
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int GEOsimAppl::init(void)
{
C_STRING Prefix, pathfile, DestFile;
acutPrintf(gsc_msg(120)); // ""\nCaricamento GEOsim.\n1995-2015 IREN ACQUA GAS S.p.A.""
acutPrintf(_T("\n%s"), gsc_msg(130)); // Versione attuale di GEOsim
///////////////////////
// LATO SERVER - inizio
// leggo e verifico esistenza dei direttori di GEOsim
if (init_dir() == GS_BAD) return GS_BAD;
Prefix = GEODIR;
Prefix += _T('\\');
// verifico esistenza del sotto-direttorio USR di GEOsim
pathfile = Prefix;
pathfile += GEOUSRDIR;
if (gsc_mkdir(pathfile) == GS_BAD) return GS_BAD;
// verifico esistenza del sotto-direttorio THM GEOsim
pathfile = Prefix;
pathfile += GEOTHMDIR;
if (gsc_mkdir(pathfile) == GS_BAD) return GS_BAD;
// verifico esistenza del sotto-direttorio EXT GEOsim
pathfile = Prefix;
pathfile += GEOEXT;
if (gsc_mkdir(pathfile) == GS_BAD) return GS_BAD;
// verifico esistenza del sotto-direttorio SUPPORT GEOsim
pathfile = Prefix;
pathfile += GEOSUPPORTDIR;
if (gsc_mkdir(pathfile) == GS_BAD) return GS_BAD;
// se non esiste il database principale di GEOsim lo creo
DestFile = Prefix;
DestFile += ACCESSGEOMAINDB;
if (gsc_path_exist(DestFile) == GS_BAD) // se non esisteva
{
pathfile = Prefix + GEOSAMPLEDIR + _T('\\') + ACCESSGEOSIMMAINSAMPLEDB;
if (gsc_copyfile(pathfile.get_name(), DestFile.get_name()) == GS_BAD)
{ terminate(); return GS_BAD; }
}
///////////////////////
// LATO SERVER - fine
// LATO CLIENT - inizio
// leggo e verifico esistenza dei direttori locali di GEOsim
Prefix = CURRUSRDIR;
// se non esiste dir locale dell'utente corrente, la creo
pathfile = Prefix;
if (gsc_path_exist(pathfile) == GS_BAD) // probabile che sia la prima esecuzione
{
if (gsc_mkdir(pathfile) == GS_BAD) return GS_BAD;
// Elaboro i tematismi
if (gsc_refresh_thm() == GS_BAD) { terminate(); return GS_BAD; }
}
Prefix += _T('\\');
// se non esiste subdir TEMP di dir locale dell'utente corrente, la creo
pathfile = Prefix;
pathfile += GEOTEMPDIR;
if (gsc_mkdir(pathfile) == GS_BAD) return GS_BAD;
// leggo la lista delle macchine collegate in rete
if (restore_netpath() == GS_BAD) return GS_BAD;
// inizializzo ambiente ASE
if ((ASE = gsc_initase()) == GS_BAD) return GS_BAD;
// inizializzo ambiente ASE
if ((ASI = gsc_initasi()) == GS_BAD) return GS_BAD;
// inizializzo la lista che descrive l'identificatore di AUTOCAD ASE per le
// entità estese
if ((ASE_APP_ID_LIST << acutBuildList(RTSTR, ASE_APP_ID, 0)) == NULL) return GS_BAD;
// inizializzo la lista che descrive l'identificatore di GEOsim per le
// entità estese (dichiarata in GS_GRAPH)
if ((APP_ID_LIST << acutBuildList(RTSTR, GEO_APP_ID, 0)) == NULL) return GS_BAD;
// inizializzo la tolleranza nel confronto tra coordinate
resbuf AcadPrec;
if (acedGetVar(_T("LUPREC"), &AcadPrec) != RTNORM) TOLERANCE = 1.0E-4;
else TOLERANCE = pow(10.0, -1 * AcadPrec.resval.rint);
pathfile = Prefix; // Directory locale dell'utente corrente
pathfile += GS_INI_FILE;
// inizializzo variabili globali
if (GLOBALVARS.Load(pathfile.get_name()) == GS_BAD) { terminate(); return GS_BAD; }
// inizializza vettore dei comandi abilitabili e disabilitabili
init_cmd_vector();
// carica GSL.GSL dal direttorio centrale di GEOsim
gs_gsl_gs_reload();
return GS_GOOD;
}
/*********************************************************/
/*.doc GEOsimAppl::initByUser <external> */
/*+
Questa funzione inizializza le strutture usate da GEOsim che dipendono
dall'utente corrente.
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
N.B. la funzione è usabile solo se non esiste una sessione di lavoro attiva !!!
(vengono rilasciati e ricaricati i progetti rilasciando anche eventuali classi
caricate in memoria)
-*/
/*********************************************************/
int GEOsimAppl::initByUser()
{
C_MAP_ENV AdeEnv;
// inizializzo le variabili d'ambiente ADE per GEOsim (alcune variabili di ADE
// possono essere settate solo se si è SUPERUSER di MAP)
// AdeEnv.SetEnv4GEOsim(); roby questa inizializzazione non dipende dall'utente corrente
// se non c'è alcuna sessione attiva e non si è in fase di scongelamento
// (in caso di login automatica inserita nel file acaddoc.lsp)
if (!GS_CURRENT_WRK_SESSION && RS_LOCK_WRKSESSION.GetInterfacePtr() == NULL)
{
GEOsimAppl::DBCONNECTION_LIST.remove_all();
if (PROJECTS.restore_projects() == GS_BAD) return GS_BAD;
}
return GS_GOOD;
}
/*********************************************************/
/*.doc GEOsimAppl::init_dir <internal> */
/*+
Questa funzione inizializza e crea i direttori di GEOsim.
La procedura necessita di:
- una variabile di sistema GEOSIM contenente il direttorio di
installazione della banca dati centrale di GEOSIM (dove risiede GS_PRJ).
- una variabile di sistema GEOWORK contenente il direttorio di
lavoro locale.
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int GEOsimAppl::init_dir(void)
{
// leggo e verifico esistenza del direttorio di installazione di GEOsim
if (gsc_geosimdir(GEODIR) == GS_BAD) return GS_BAD;
// leggo il direttorio di lavoro locale di GEOsim
if (gsc_geoworkdir(WORKDIR) == GS_BAD) return GS_BAD;
// leggo il direttorio di GEOsim per l'utente corrente
if (gsc_getGEOsimUsrAppDataPath(CURRUSRDIR) == GS_BAD) return GS_BAD;
// se non esiste geoworkdir errore ripetere l'installazione
if (gsc_path_exist(WORKDIR) == GS_BAD) return GS_BAD;
return GS_GOOD;
}
/*************************************************************************/
/*.doc int GEOsimAppl::restore_netpath() */
/*+
Legge dal file GS_NET_FILE nella directory di GEOsim le lista delle
corrispondenze tra connessioni in rete e drive delle macchina.
Ritorna GS_BAD in caso di errore GS_BAD altrimenti.
-*/
/*************************************************************************/
int GEOsimAppl::restore_netpath(void)
{
if (GS_NET_LIST.load() == GS_BAD)
{
acutPrintf(gsc_msg(691)); // "\nConfigurare gli alias dei nodi di rete.\n"
return GS_BAD;
}
return GS_GOOD;
}
/*********************************************************/
/*.doc GEOsimAppl::terminate <external> */
/*+
Questa funzione termina GEOsim.
La procedura:
- rilascia la lista dei progetti e relative liste delle classi (PROJECTS)
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int GEOsimAppl::terminate(void)
{
C_STRING temp_dir;
// se c'era una sessione di GEOsim aperta la chiudo
if (GS_CURRENT_WRK_SESSION) gsc_ExitCurrSession();
// cancello la lista dei lista progetti
PROJECTS.remove_all();
// chiudo collegamento con ASE
gsc_termase(&ASE);
// chiudo collegamento con ASI
gsc_termasi(&ASI);
DBCONNECTION_LIST.remove_all(); // chiudo collegamenti OLE-DB
// rilascio lista pubblica di resbuf GS_RESBUF
gsc_dealloc_GS_RESBUF();
// cancello il contenuto del direttorio temporaneo GEOsimAppl::CURRUSRDIR + GEOTEMPDIR
temp_dir = CURRUSRDIR;
temp_dir += _T('\\');
temp_dir += GEOTEMPDIR;
gsc_delall(temp_dir.get_name(), NORECURSIVE, FALSE);
// rilascio il set di visibilità degli attributi attivo
if (ACTIVE_VIS_ATTRIB_SET)
{
delete ACTIVE_VIS_ATTRIB_SET;
ACTIVE_VIS_ATTRIB_SET = NULL;
}
// Se esiste il puntatore C_DYNAMIC_QRY_ATTR per l'interrogazione dinamica
if (DYNAMIC_QRY_ATTR)
{
delete DYNAMIC_QRY_ATTR;
DYNAMIC_QRY_ATTR = NULL;
}
// rilascio le liste resbuf perchè se lo faccio dopo attraverso il distruttore
// ottengo un errore (forse autocad non è più in grado di rilasciare i resbuf)
ASE_APP_ID_LIST.remove_all();
APP_ID_LIST.remove_all();
GS_LSFILTER.terminate();
return GS_GOOD;
}
/*********************************************************/
/*.doc (new 2) GEOsimAppl::init_cmd_vector <internal> */
/*+
Inizializza il vettore dei comandi di GEOsim che si possono abilitare/disabilitare.
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
void GEOsimAppl::init_cmd_vector(void)
{
int i = 0;
// "Modifica password"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(333), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opModPwd;
i++; // 1
// "Creazione sessione di lavoro"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(334), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opCreateArea;
i++; // 2
// "Cancellazione sessione di lavoro"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(335), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opDelArea;
i++; // 3
// "Congelamento sessione di lavoro"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(336), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opFreezeArea;
i++; // 4
// "Scongelamento/recupero sessione di lavoro"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(337), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opSelArea;
i++; // 5
// "Salvataggio sessione di lavoro"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(338), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opSaveArea;
i++; // 6
// "Uscita sessione di lavoro"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(541), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opCloseArea;
i++; // 7
// "Selezione classi da estrarre"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(540), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opSelAreaClass;
i++; // 8
// "Inserimento entità"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(339), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opInsEntity;
i++; // 9
// "Modifica entità"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(340), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opModEntity;
i++; // 10
// "Aggregazione entità"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(341), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opAggrEntity;
i++; // 11
// "Cancellazione entità"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(342), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opDelEntity;
i++; // 12
// "Interrogazione entità"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(343), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opQryEntity;
i++; // 13
// "Importa entità"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(344), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opImportEntity;
i++; // 14
// "Filtro entità"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(345), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opFilterEntity;
i++; // 15
// "Inserimento entità secondaria"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(542), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opInsSecondary;
i++; // 16
// "Modifica entità secondaria"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(543), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opModSecondary;
i++; // 17
// "Cancellazione entità secondaria"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(544), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opDelSecondary;
i++; // 18
// "Interrogazione entità secondaria"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(545), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opQrySecondary;
i++; // 19
// "Editazione attrib. visibili"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(546), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opAttEdit;
i++; // 20
// "'Spegnimento' blocchi attrib. visibili"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(547), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opAttInvisib;
i++; // 21
// "'Accensione' blocchi attrib. visibili"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(427), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opAttVisib;
i++; // 22
// "Gestione set di visibiltà"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(652), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opSetVisib;
i++; // 23
// "Modifica tabella definizione attributi"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(548), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opModDefTabRef;
i++; // 24
// "Creazione topologia"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(851), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opCreateTopo;
i++; // 25
// "Funzione cambio dim. testi e attrib. visibili"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(852), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opScaleAttrText;
i++; // 26
// "Funzione creaz. file DWF per WHIP!"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(853), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opWhip;
i++; // 27
// "Esportazione dati"
gsc_strcpy(GS_COMMANDS[i].name, gsc_msg(1091), MAX_LEN_DESCR_CMD);
GS_COMMANDS[i].code = opExport;
// ricordarsi di cambiare il valore di "GS_COMMANDS_LEN" al variare della
// dimensione di GS_COMMANDS
}
/*********************************************************/
/*.doc GEOsimAppl::TerminateSQL <internal> */
/*+
Questa funzione termina i recordset, i comandi e annulla la connessione
OLE_DB eventualmente inizializzata nei progetti, classi, sessioni di lavoro
quindi termina la connessione OLE-DB specificata.
Parametri:
C_DBCONNECTION *pConnToTerminate; Connessione da terminare
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
void GEOsimAppl::TerminateSQL(C_DBCONNECTION *pConnToTerminate)
{
C_PROJECT *pPrj;
C_CLASS *pCls;
if (!pConnToTerminate) return;
// Per ciascun progetto
pPrj = (C_PROJECT *) PROJECTS.get_head();
while (pPrj)
{
// Per ciascuna classe del progetto
pCls = (C_CLASS *) pPrj->ptr_classlist()->get_head();
while (pCls)
{
pCls->TerminateSQL(pConnToTerminate);
pCls = (C_CLASS *) pCls->get_next();
}
pPrj->TerminateSQL(pConnToTerminate);
pPrj = (C_PROJECT *) pPrj->get_next();
}
// Per la sessione di lavoro corrente
if (GS_CURRENT_WRK_SESSION)
GS_CURRENT_WRK_SESSION->TerminateSQL(pConnToTerminate);
// Rimuovo la connessione dalla lista delle connessioni OLE-DB
DBCONNECTION_LIST.remove(pConnToTerminate);
}
//-----------------------------------------------------------------------//
////////////////// C_INIT INIZIO ///////////////////////////////////////
//-----------------------------------------------------------------------//
/*********************************************************
/*.doc C_INIT::C_INIT <external> */
/*+
Questa funzione è il costruttore della classe C_INIT.
-*/
/*********************************************************/
C_INIT::C_INIT()
{
set_AutoHighlight(GS_BAD);
set_AutoSyncro(GS_GOOD);
set_AutoZoom(GS_BAD);
set_AutoZoomMinXDim(20);
set_AutoZoomMinYDim(20);
set_BoolFmt(0);
set_DimAssoc(1);
set_ShortDate(GS_GOOD);
set_InsXScale(AUTO);
set_InsYScale(AUTO);
set_InsRotaz(AUTO);
set_InsHText(AUTO);
set_InsPos(AUTO);
set_LogFile(GS_BAD);
set_DynamicExtraction(GS_BAD);
set_UpdGraphOnExtract(GS_BAD);
set_UpdGraphOnExtractSim(GS_BAD);
set_AlignHighlightedFASOnSave(GS_GOOD);
set_AddEntityToSaveSet(GS_GOOD);
set_AddLPTOnExtract(GS_BAD);
set_WaitTime(1);
set_NumTest(2);
set_SelectPreviousExtractedClasses(GS_GOOD);
}
/*********************************************************
/*.doc C_INIT::Load <external> */
/*+
Legge dal file "pathfile" i valori con cui inizializzare
le variabili globali.
Parametri:
TCHAR *pathfile; Path completa del file di inizializzazione,
se = NULL viene utilizzato il file
"GEOSIM.INI" in TEMP (default = NULL)
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_INIT::Load(TCHAR *pathfile)
{
C_STRING Path(pathfile), Buffer;
C_PROFILE_SECTION_BTREE ProfileSections;
C_BPROFILE_SECTION *ProfileSection;
C_2STR_BTREE *pProfileEntries;
C_B2STR *pProfileEntry;
if (Path.get_name() == NULL) // se parametro non passato uso quello di default
{
Path = GEOsimAppl::CURRUSRDIR; // Directory locale dell'utente corrente
Path += _T('\\');
Path += GS_INI_FILE;
}
if (gsc_read_profile(Path, ProfileSections) == GS_BAD) return GS_GOOD;
if (!(ProfileSection = (C_BPROFILE_SECTION *) ProfileSections.search(GS_INI_LABEL)))
return GS_GOOD;
pProfileEntries = (C_2STR_BTREE *) ProfileSection->get_ptr_EntryList();
// il pannello della sessione di lavoro
// evidenzia le entità correntemente selezionate
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_AutoHighlight"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_AutoHighlight(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_AutoHighlight(GS_BAD);
}
// il pannello della sessione di lavoro
// fa lo zoom sulle entità correntemente selezionate
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_AutoZoom"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_AutoZoom(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_AutoZoom(GS_BAD);
}
// Dimensione minima X della finestra di zoom
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("set_AutoZoomMinXDim"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
set_AutoZoomMinXDim(Buffer.tof());
}
// Dimensione minima X della finestra di zoom
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("set_AutoZoomMinYDim"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
set_AutoZoomMinYDim(Buffer.tof());
}
// Formato dei valori booleani
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_BoolFmt"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
set_BoolFmt(Buffer.toi());
}
// Modalità di quotatura
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_DimAssoc"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
set_DimAssoc(Buffer.toi());
}
// Formato della data
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_ShortDate"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_ShortDate(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_ShortDate(GS_BAD);
}
// Modalità di inserimento
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_InsXScale"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("MANUAL")) == 0) set_InsXScale(MANUAL);
else if (Buffer.comp(_T("AUTO")) == 0) set_InsXScale(AUTO);
}
// Modalità di inserimento
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_InsYScale"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("MANUAL")) == 0) set_InsYScale(MANUAL);
else if (Buffer.comp(_T("AUTO")) == 0) set_InsYScale(AUTO);
}
// Modalità di inserimento
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_InsRotaz"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("MANUAL")) == 0) set_InsRotaz(MANUAL);
else if (Buffer.comp(_T("AUTO")) == 0) set_InsRotaz(AUTO);
}
// Modalità di inserimento
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_InsHText"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("MANUAL")) == 0) set_InsHText(MANUAL);
else if (Buffer.comp(_T("AUTO")) == 0) set_InsHText(AUTO);
}
// Modalità di inserimento
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_InsPos"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("MANUAL")) == 0) set_InsPos(MANUAL);
else if (Buffer.comp(_T("AUTO")) == 0) set_InsPos(AUTO);
}
// Scrittura file LOG di GEOsim, MAP e AutoCAD
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_LogFile"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_LogFile(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_LogFile(GS_BAD);
}
// Allineamento automatico modifiche fatte senza comandi di GEOsim,
// parte su rettore InputContextReactor all'evento beginQuiescentState
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_AutoSyncro"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_AutoSyncro(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_AutoSyncro(GS_BAD);
}
// Estrazione dinamica su PAN o ZOOM
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_DynamicExtraction"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_DynamicExtraction(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_DynamicExtraction(GS_BAD);
}
// Aggiornamento grafica da DB dopo estrazione
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_UpdGraphOnExtract"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_UpdGraphOnExtract(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_UpdGraphOnExtract(GS_BAD);
}
// Aggiornamento grafica da DB dopo estrazione (solo per simulazioni)
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_UpdGraphOnExtractSim"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_UpdGraphOnExtractSim(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_UpdGraphOnExtractSim(GS_BAD);
}
// Allineamento grafica in fase di salvataggio
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_AlignHighlightedFASOnSave"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_AlignHighlightedFASOnSave(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_AlignHighlightedFASOnSave(GS_BAD);
}
// Inserimento delle entità nel salvataggio
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_AddEntityToSaveSet"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_AddEntityToSaveSet(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_AddEntityToSaveSet(GS_BAD);
}
// Aggiunta di LPT dopo estrazione
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("set_AddLPTOnExtract"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_AddLPTOnExtract(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_AddLPTOnExtract(GS_BAD);
}
// Secondi di attesa fra due tentativi
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_WaitTime"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
set_WaitTime(Buffer.toi());
}
// Tentativi da fare prima di segnalare l'errore
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_NumTest"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
set_NumTest(Buffer.toi());
}
// Seleziona le classi estratte nella sessione precedente
if ((pProfileEntry = (C_B2STR *) pProfileEntries->search(_T("Set_SelectPreviousExtractedClasses"))))
{
Buffer = pProfileEntry->get_name2();
Buffer.alltrim();
Buffer.toupper();
if (Buffer.comp(_T("ON")) == 0) set_SelectPreviousExtractedClasses(GS_GOOD);
else if (Buffer.comp(_T("OFF")) == 0) set_SelectPreviousExtractedClasses(GS_BAD);
}
return GS_GOOD;
}
/*********************************************************
/*.doc C_INIT::Save <external> */
/*+
Scrive nel file "pathfile" i valori delle variabili globali.
Parametri:
TCHAR *pathfile; Path completa del file di inizializzazione,
se = NULL viene utilizzato il file "GEOSIM.INI"
nella directory locale dell'utente corrente (default = NULL)
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_INIT::Save(TCHAR *pathfile)
{
C_PROFILE_SECTION_BTREE ProfileSections;
C_BPROFILE_SECTION *ProfileSection;
TCHAR buf[MAX_LEN_ENTRY];
int result = GS_BAD;
C_STRING Path(pathfile);
bool Unicode = false;
if (Path.get_name() == NULL) // se parametro non passato uso quello di default
{
Path = GEOsimAppl::CURRUSRDIR; // Directory locale dell'utente corrente
Path += _T('\\');
Path += GS_INI_FILE;
}
if (gsc_path_exist(Path) == GS_GOOD)
if (gsc_read_profile(Path, ProfileSections, &Unicode) == GS_BAD)
return GS_BAD;
if (!(ProfileSection = (C_BPROFILE_SECTION *) ProfileSections.search(GS_INI_LABEL)))
{
if (ProfileSections.add(GS_INI_LABEL) == GS_BAD) return GS_BAD;
ProfileSection = (C_BPROFILE_SECTION *) ProfileSections.get_cursor();
}
// Evidenziazione automatica
wcscpy(buf, (get_AutoHighlight() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_AutoHighlight"), buf);
// Zoom automatico
wcscpy(buf, (get_AutoZoom() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_AutoZoom"), buf);
// Dimensione minima X della finestra di zoom
ProfileSection->set_entry(_T("Set_AutoZoomMinXDim"), get_AutoZoomMinXDim());
// Dimensione minima Y della finestra di zoom
ProfileSection->set_entry(_T("Set_AutoZoomMinYDim"), get_AutoZoomMinYDim());
// Formato dei valori booleani
ProfileSection->set_entry(_T("Set_BoolFmt"), get_ShortDate());
// Modalità di quotatura
ProfileSection->set_entry(_T("Set_DimAssoc"), get_DimAssoc());
// Formato della data
wcscpy(buf, (get_ShortDate() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_ShortDate"), get_DimAssoc());
// Modalità di inserimento scala X
wcscpy(buf, (get_InsXScale() == MANUAL) ? _T("MANUAL") : _T("AUTO"));
ProfileSection->set_entry(_T("Set_InsXScale"), buf);
// Modalità di inserimento scala Y
wcscpy(buf, (get_InsYScale() == MANUAL) ? _T("MANUAL") : _T("AUTO"));
ProfileSection->set_entry(_T("Set_InsYScale"), buf);
// Modalità di inserimento rotazione
wcscpy(buf, (get_InsRotaz() == MANUAL) ? _T("MANUAL") : _T("AUTO"));
ProfileSection->set_entry(_T("Set_InsRotaz"), buf);
// Modalità di inserimento altezza testo
wcscpy(buf, (get_InsHText() == MANUAL) ? _T("MANUAL") : _T("AUTO"));
ProfileSection->set_entry(_T("Set_InsHText"), buf);
// Modalità di inserimento posizione
wcscpy(buf, (get_InsPos() == MANUAL) ? _T("MANUAL") : _T("AUTO"));
ProfileSection->set_entry(_T("Set_InsPos"), buf);
// Scrittura file LOG di GEOsim, MAP e AutoCAD
wcscpy(buf, (get_LogFile() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_LogFile"), buf);
// Allineamento automatico
wcscpy(buf, (get_AutoSyncro() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_AutoSyncro"), buf);
// Estrazione dinamica su PAN o ZOOM
wcscpy(buf, (get_DynamicExtraction() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_DynamicExtraction"), buf);
// Aggiornamento grafica da DB dopo estrazione
wcscpy(buf, (get_UpdGraphOnExtract() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_UpdGraphOnExtract"), buf);
// Aggiornamento grafica da DB dopo estrazione (solo per simulazioni)
wcscpy(buf, (get_UpdGraphOnExtractSim() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_UpdGraphOnExtractSim"), buf);
// Allineamento grafica in fase di salvataggio
wcscpy(buf, (get_AlignHighlightedFASOnSave() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_AlignHighlightedFASOnSave"), buf);
// Inserimento delle entità nel salvataggio
wcscpy(buf, (get_AddEntityToSaveSet() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_AddEntityToSaveSet"), buf);
// Aggiunta di LPT dopo estrazione
wcscpy(buf, (get_AddLPTOnExtract() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("set_AddLPTOnExtract"), buf);
// Secondi di attesa fra due tentativi
ProfileSection->set_entry(_T("Set_WaitTime"), get_WaitTime());
// Tentativi da fare prima di segnalare l'errore
ProfileSection->set_entry(_T("Set_NumTest"), get_NumTest());
// Seleziona le classi estratte nella sessione precedente
wcscpy(buf, (get_SelectPreviousExtractedClasses() == GS_GOOD) ? _T("ON") : _T("OFF"));
ProfileSection->set_entry(_T("Set_SelectPreviousExtractedClasses"), buf);
return gsc_write_profile(Path, ProfileSections, Unicode);
}
int C_INIT::set_BoolFmt(int SetBoolFmt)
{
if (SetBoolFmt != 0 && SetBoolFmt != 1 &&
SetBoolFmt != 2 && SetBoolFmt != 3)
{ GS_ERR_COD = eGSInvalidArg; return GS_BAD; }
BoolFmt = SetBoolFmt;
return GS_GOOD;
}
int C_INIT::set_DimAssoc(int SetDimAssoc)
{
if (SetDimAssoc != 0 && SetDimAssoc != 1 && SetDimAssoc != 2)
{ GS_ERR_COD = eGSInvalidArg; return GS_BAD; }
DimAssoc = SetDimAssoc;
return GS_GOOD;
}
int C_INIT::set_ShortDate(int SetShortDate)
{
if (SetShortDate != GS_GOOD && SetShortDate != GS_BAD)
{ GS_ERR_COD = eGSInvalidArg; return GS_BAD; }
ShortDate = SetShortDate;
return GS_GOOD;
}
int C_INIT::set_InsXScale(int SetInsXScale)
{
if (SetInsXScale != MANUAL && SetInsXScale != AUTO)
{ GS_ERR_COD = eGSInvalidArg; return GS_BAD; }
ins_x_scale = SetInsXScale;
return GS_GOOD;
}
int C_INIT::set_InsYScale(int SetInsYScale)
{
if (SetInsYScale != MANUAL && SetInsYScale != AUTO)
{ GS_ERR_COD = eGSInvalidArg; return GS_BAD; }
ins_y_scale = SetInsYScale;
return GS_GOOD;
}
int C_INIT::set_InsRotaz(int SetRotaz)
{
if (SetRotaz != MANUAL && SetRotaz != AUTO)
{ GS_ERR_COD = eGSInvalidArg; return GS_BAD; }
ins_rotaz = SetRotaz;