-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGS_PRJCT.CPP
5540 lines (4577 loc) · 199 KB
/
GS_PRJCT.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_PRJCT
Module description: File contenente le funzioni per la gestione dei progetti
di GEOsim
Author: Poltini Roberto
Paolo De Sole
(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 "AcExtensionModule.h" // per CAcModuleResourceOverride
#include "resource.h"
#include "gs_opcod.h" // codici delle operazioni
#include "gs_utily.h" // (gsc_tostring)
#include "gs_error.h" // codici errori
#include "gs_resbf.h" // (gsc_nth)
#include "gs_list.h"
#include "gs_sql.h" // gestione database
#include "gs_class.h"
#include "gs_conv.h" // conversione dati da versione di GEOsim precedente
#include "gs_sec.h"
#include "gs_user.h" // check_op
#include "gs_init.h" // direttori globali
#include "gs_netw.h" // funzioni di rete
#include "gs_prjct.h" // prototipi funzioni extern
#include "gs_area.h"
#include "gs_lock.h"
/*************************************************************************/
/* GLOBAL VARIABLES */
/*************************************************************************/
/*********************************************************/
/* PRIVATE FUNCTIONS */
/*********************************************************/
int gsc_getNewCode(_RecordsetPtr &pRs, int *new_code);
/*********************************************************/
/*.doc gs_current_prj <external> */
/*+
Questa funzione LISP restituisce i dati del progetto corrente
in caso di successo altrimenti restituisce NIL.
(<gs_id><name><descr><dir><key_dwg><coord><level><dwgdim>)
-*/
/*********************************************************/
int gs_current_prj(void)
{
C_RB_LIST ret;
C_INT_INT_LIST lista;
acedRetNil();
if (!GS_CURRENT_WRK_SESSION) return RTNORM;
if ((ret << GS_CURRENT_WRK_SESSION->get_pPrj()->to_rb()) == NULL) return RTERROR;
if (ret.get_head()->restype != RTNIL) ret.LspRetList();
return RTNORM;
}
/*********************************************************/
/*.doc gscreateprj <external> */
/*+
Questo comando senza dcl crea un progetto di GEOsim.
-*/
/*********************************************************/
void gscreateprj(void)
{
C_PROJECT *pProject;
int new_code, esco=0;
C_STRING direct, keydwg;
TCHAR name[MAX_LEN_PRJNAME] = GS_EMPTYSTR;
TCHAR syscoor[MAX_LEN_COORDNAME];
TCHAR buff[133];
GEOsimAppl::CMDLIST.StartCmd();
if (ads_getstring(TRUE, gsc_msg(138), buff) != RTNORM)
return GEOsimAppl::CMDLIST.ErrorCmd(); // "\nNome progetto: "
if (wcslen(buff) >= MAX_LEN_PRJNAME) { GS_ERR_COD = eGSStringTooLong; return GEOsimAppl::CMDLIST.ErrorCmd(); }
if (wcslen(buff) == 0) { GS_ERR_COD = eGSInvalidArg; return GEOsimAppl::CMDLIST.ErrorCmd(); }
gsc_strcpy(name, buff, MAX_LEN_PRJNAME);
if (ads_getstring(TRUE, gsc_msg(139), buff) != RTNORM) return GEOsimAppl::CMDLIST.ErrorCmd(); // "\nDirettorio: "
if (wcslen(buff) == 0) { GS_ERR_COD = eGSInvalidArg; return GEOsimAppl::CMDLIST.ErrorCmd(); }
direct = buff;
if (ads_getstring(TRUE, gsc_msg(140), buff) != RTNORM) return GEOsimAppl::CMDLIST.ErrorCmd(); // "\nDisegno chiave: "
keydwg = buff;
while (esco!=1)
{
if (ads_getstring(TRUE, gsc_msg(141), buff) != RTNORM) return GEOsimAppl::CMDLIST.ErrorCmd(); // "\nSistema coordinate: "
if ((gsc_strcmp(buff, _T("?")) == 0) || (gsc_strcmp(buff, GS_EMPTYSTR) == 0)) // l'utente ha dato return stampo lista
{
if (printlistcoord()!=GS_GOOD) return GEOsimAppl::CMDLIST.ErrorCmd();
}
else
{
if (wcslen(buff) >= MAX_LEN_COORDNAME)
{ GS_ERR_COD = eGSStringTooLong; return GEOsimAppl::CMDLIST.ErrorCmd(); }
if (gsc_toupper(buff)==GS_GOOD) // "Sistema coordinate"
{ gsc_strcpy(syscoor, buff, MAX_LEN_COORDNAME); esco=1; }
}
}
// Alloca una nuovo progetto
if ((pProject = new C_PROJECT()) == NULL)
{ GS_ERR_COD = eGSOutOfMem; return GEOsimAppl::CMDLIST.ErrorCmd(); }
// inizializzo i valori del progetto letti in input
if ((pProject->set_name(name)==GS_BAD)||
(pProject->set_dir(direct.get_name())==GS_BAD)||
(pProject->set_keydwg(keydwg.get_name())==GS_BAD)||
(pProject->set_coordinate(syscoor)==GS_BAD))
{ delete pProject; return GEOsimAppl::CMDLIST.ErrorCmd(); }
// chiamata funzione C++
if ((new_code=gsc_createprj(pProject)) == GS_BAD)
{ delete pProject; return GEOsimAppl::CMDLIST.ErrorCmd(); }
return GEOsimAppl::CMDLIST.EndCmd();
}
/*********************************************************/
/*.doc gs_createprj <external> */
/*+
Questa funzione LISP crea un progetto di GEOsim.
Parametri:
Lista RESBUF
(<prjname><prjDescr><prjdir>[<key_dwg>[<coordsys>[<dwg_dim>[<ConnStrUDLFile>[<UDLProperties>]]]]])
prjname; nome del progetto da creare
prjDescr; descrizione del progetto da creare
prjdir; direttorio del progetto
key_dwg; nome del file .dwg da utilizzare come sinottico
coordsys; codice sistema di coordinate
Restituisce il codice del nuovo progetto in caso di successo altrimenti
restituisce NIL.
-*/
/*********************************************************/
int gs_createprj(void)
{
resbuf *arg;
C_PROJECT *pProject;
int new_code;
acedRetNil();
arg = acedGetArgs();
// Alloca una nuovo progetto
if ((pProject = new C_PROJECT()) == NULL)
{ GS_ERR_COD = eGSOutOfMem; return RTERROR; }
// Ricopia i dati dalla struttura di ingresso
if (pProject->from_rb(arg) == GS_BAD) { delete pProject; return RTERROR; }
if ((new_code = gsc_createprj(pProject)) == GS_BAD) { delete pProject; return RTERROR; }
acedRetInt(new_code);
return RTNORM;
}
/*********************************************************/
/*.doc gs_ClassesStructReport <external> */
/*+
Questa funzione LISP esporta su file testo la struttura di una lista
di classi di un progetto di GEOsim.
Parametri:
Lista RESBUF (<Path><prj><open_file>(<cls1><cls2>...))
Restituisce il TRUE in caso di successo altrimenti
restituisce NIL.
-*/
/*********************************************************/
int gs_ClassesStructReport(void)
{
presbuf arg = acedGetArgs();
int prjcode;
C_PROJECT *pProject;
C_INT_LIST cls_list;
TCHAR *Path, *open_file;
bool SynthMode = false;
acedRetNil();
// Path
if (!arg || arg->restype != RTSTR) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
Path = arg->resval.rstring;
// codice del progetto
if (!(arg = arg->rbnext) || arg->restype != RTSHORT)
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
prjcode = arg->resval.rint;
// modalità di apertura file
if (!(arg = arg->rbnext) || arg->restype != RTSTR)
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
if ((open_file = arg->resval.rstring) == GS_BAD) return RTERROR;
// Lista classi
if (!(arg = arg->rbnext))
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
if (cls_list.from_rb(arg) == GS_BAD) return RTERROR;
// opzionale, flag di report sintetico
if ((arg = gsc_scorri(arg)) == NULL)
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
if ((arg = arg->rbnext) && arg->restype == RTT) SynthMode = true;
// cerco elemento in lista progetti
if ((pProject =(C_PROJECT *) GEOsimAppl::PROJECTS.search_key(prjcode)) == NULL) return RTERROR;
// reindicizzo le classi del progetto
if (pProject->ClassesStructReport(Path, open_file, cls_list, SynthMode) == GS_BAD)
return RTERROR;
acedRetT();
return RTNORM;
}
/*********************************************************/
/*.doc gs_checkclass <external> */
/*+
Questa funzione LISP controlla le classi di un progetto di GEOsim.
Parametri:
Lista RESBUF (<prj>, (<cls1><cls2>...) [DwgOpType [Path di file script]])
RTSHORT prj; codice del progetto
RTSHORT cls1, cls2, ... ; classi da reindicizzare
DwgOpType; 1=reindex, 2=sblocco, 4=estensioni, 8=purge
Restituisce il TRUE in caso di successo altrimenti
restituisce NIL.
-*/
/*********************************************************/
int gs_checkclass(void)
{
presbuf arg;
int prj;
C_PROJECT *pProject;
C_INT_LIST cls_list;
acedRetNil();
arg = acedGetArgs();
// codice del progetto
if (!arg || gsc_rb2Int(arg, &prj) != GS_GOOD)
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
if ((arg = arg->rbnext) == NULL) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
if (cls_list.from_rb(arg) == GS_BAD) return RTERROR;
// cerco elemento in lista progetti
if ((pProject =(C_PROJECT *) GEOsimAppl::PROJECTS.search_key(prj)) == NULL) return RTERROR;
if (arg->restype == RTLB) arg = gsc_scorri(arg);
if (arg && (arg = arg->rbnext) && arg->restype == RTSHORT)
{
int DwgOpType = arg->resval.rint;
TCHAR *ScriptFile = NULL;
if ((arg = arg->rbnext) && arg->restype == RTSTR) ScriptFile = arg->resval.rstring;
// reindicizzo le classi del progetto con tipo operazione per DWG
if (pProject->ClassCheck(&cls_list, DwgOpType, ScriptFile) == GS_BAD) return RTERROR;
}
else
// reindicizzo le classi del progetto
if (pProject->ClassCheck(&cls_list) == GS_BAD) return RTERROR;
acedRetT();
return RTNORM;
}
////////////////////////////////////////////////////////////////////////////////
// class C_PROJECT //
////////////////////////////////////////////////////////////////////////////////
// costruttore
C_PROJECT::C_PROJECT() : C_NODE()
{
gs_id = 0;
name[0] = _T('\0');
wcscpy(coordinate, DEFAULT_DWGCOORD);
level = GSInvisibleData;
dwg_dim = DEFAULT_DWG_DIM;
classlist.set_father_prj(this);
pConn = NULL;
isRsSelectLockSupported = -1; // non ancora inizializzato
}
// costruttore
C_PROJECT::C_PROJECT(const TCHAR *nameprj, const TCHAR *descrprj, const TCHAR *dirprj, const TCHAR *keydwgprj,
const TCHAR *coordinateprj, int dwgdim) : C_NODE()
{
set_name(nameprj);
set_descr(descrprj);
set_dir(dirprj);
set_keydwg(keydwgprj);
set_coordinate(coordinateprj);
set_dwg_dim(dwgdim);
return;
}
// distruttore
C_PROJECT::~C_PROJECT()
{
classlist.remove_all();
TerminateSQL();
}
/*********************************************************/
/*.doc C_PROJECT::get_key e set_key <external> */
/*+
Questa funzioni leggono e inizializzano il codice del progetto (non agisce sui database)
C_PROJECT::get_key restituisce il codice del progetto.
C_PROJECT::set_key restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_PROJECT::get_key(void)
{ return gs_id; }
int C_PROJECT::set_key(int in)
{
if (in <= 0) return GS_BAD;
gs_id = in;
return GS_GOOD;
}
/*********************************************************/
/*.doc C_PROJECT::get_name e set_name <external> */
/*+
Questa funzioni leggono e inizializzano il nome del progetto (non agisce sui database)
C_PROJECT::get_name restituisce il nome del progetto.
C_PROJECT::set_name restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
TCHAR *C_PROJECT::get_name(void)
{ return name; }
int C_PROJECT::set_name(const TCHAR *nameprj)
{
if (!nameprj || wcslen(nameprj) == 0)
{ GS_ERR_COD = eGSInvalidArg; return GS_BAD; }
if (wcslen(nameprj) >= MAX_LEN_PRJNAME)
{ GS_ERR_COD = eGSStringTooLong; return GS_BAD; }
wcscpy(name, nameprj);
return GS_GOOD;
}
/*********************************************************/
/*.doc C_PROJECT::get_descr e set_descr <external> */
/*+
Questa funzioni leggono e inizializzano la descrizione del progetto (non agisce sui database)
C_PROJECT::get_descr restituisce la descrizione del progetto.
C_PROJECT::set_descr restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
TCHAR *C_PROJECT::get_descr(void)
{ return Descr.get_name(); }
int C_PROJECT::set_descr(const TCHAR *descrprj)
{
Descr = descrprj;
return GS_GOOD;
}
/*********************************************************/
/*.doc C_PROJECT::get_dir e set_dir <external> */
/*+
Questa funzioni leggono e inizializzano il direttorio del progetto (non agisce sui database)
C_PROJECT::get_dir restituisce il nome del progetto.
C_PROJECT::set_dir restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
TCHAR *C_PROJECT::get_dir(void)
{ return dir.get_name(); }
int C_PROJECT::set_dir(const TCHAR *dirprj)
{
if (!dirprj) { GS_ERR_COD = eGSInvalidPath; return GS_BAD; }
dir = dirprj;
dir.alltrim();
if (gsc_validdir(dir) == GS_BAD)
{ dir.clear(); return GS_BAD; }
else return GS_GOOD;
}
/*********************************************************/
/*.doc C_PROJECT::get_keydwg e set_keydwg <external> */
/*+
Questa funzioni leggono e inizializzano il disegno chiave
del progetto (non agisce sui database)
C_PROJECT::get_keydwg restituisce il disegno chiave del progetto.
C_PROJECT::set_keydwg restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
TCHAR *C_PROJECT::get_keydwg(void)
{ return keydwg.get_name(); }
int C_PROJECT::set_keydwg(const TCHAR *keydwgprj)
{
if (!keydwgprj) { GS_ERR_COD = eGSInvalidArg; return GS_BAD; }
keydwg = keydwgprj;
return GS_GOOD;
}
/*********************************************************/
/*.doc C_PROJECT::get_coordinate e set_coordinate <external> */
/*+
Questa funzioni leggono e inizializzano il sistema di coordinate
del progetto (non agisce sui database)
C_PROJECT::get_coordinate restituisce il sistema di coordinate del progetto.
C_PROJECT::set_coordinate restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
TCHAR *C_PROJECT::get_coordinate(void)
{ return coordinate; }
int C_PROJECT::set_coordinate(const TCHAR *coordinateprj)
{
if (gsc_validcoord(coordinateprj) == GS_BAD) return GS_BAD;
gsc_strcpy(coordinate, coordinateprj, MAX_LEN_COORDNAME);
gsc_alltrim(coordinate);
gsc_toupper(coordinate);
return GS_GOOD;
}
GSDataPermissionTypeEnum C_PROJECT::get_level(void)
{ return level; }
/*********************************************************/
/*.doc C_PROJECT::get_dwg_dim e set_dwg_dim <external> */
/*+
Questa funzioni leggono e inizializzano la dimensione massima dei dwg
(MByte) delle classi del progetto (non agisce sui database)
C_PROJECT::get_dwg_dim restituisce la dimensione massima dei dwg.
C_PROJECT::set_dwg_dim restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_PROJECT::get_dwg_dim(void)
{ return dwg_dim; }
int C_PROJECT::set_dwg_dim(int in)
{
if (in <= 0) return GS_BAD;
dwg_dim = in;
return GS_GOOD;
}
/*********************************************************/
/*.doc C_PROJECT::get_ConnStrUDLFile e set_ConnStrUDLFile <external> */
/*+
Questa funzioni leggono e inizializzano il tipo di DB usato per le tabelle
interne del progetto e proposto come default quando si creano nuove classi
(non agisce sui database)
C_PROJECT::get_ConnStrUDLFile restituisce il sistema di coordinate del progetto.
C_PROJECT::set_ConnStrUDLFile restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
const TCHAR *C_PROJECT::get_ConnStrUDLFile(void)
{ return ConnStrUDLFile.get_name(); }
int C_PROJECT::set_ConnStrUDLFile(const TCHAR *in)
{
ConnStrUDLFile = in;
ConnStrUDLFile.alltrim();
if (gsc_path_exist(ConnStrUDLFile) == GS_GOOD)
// se si tratta di un file e NON di una stringa di connessione
gsc_nethost2drive(ConnStrUDLFile); // lo converto
return GS_GOOD;
}
/*********************************************************/
/*.doc C_PROJECT::get_UDLProperties e set_UDLProperties <external> */
/*+
Questa funzioni leggono e inizializzano il tipo di DB usato per le tabelle
interne del progetto e proposto come default quando si creano nuove classi
(non agisce sui database)
C_PROJECT::ptr_UDLProperties restituisce le proprietà UDL di connessione al DB.
C_PROJECT::set_UDLProperties restituisce GS_GOOD in caso di successo
(il puntatore <arg> viene avanzato nella lista) altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
C_2STR_LIST *C_PROJECT::ptr_UDLProperties(void)
{ return &UDLProperties; }
int C_PROJECT::set_UDLProperties(presbuf *arg)
{ return gsc_getUDLProperties(arg, UDLProperties); }
int C_PROJECT::set_UDLProperties(C_2STR_LIST &_UDLProperties)
{ return _UDLProperties.copy(UDLProperties); }
C_CLASS_LIST *C_PROJECT::ptr_classlist(void)
{ return &classlist; }
/*********************************************************/
/*.doc C_PROJECT::get_Bitmap <external> */
/*+
Funzione che restituisce la bitmap del progetto.
Parametri:
bool LargeSize; Se vero la dimensione della bitmap sarà di 32x16
altrimenti sarà di 16x16
CBitmap &CBMP; Oggetto bitmap (output)
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_PROJECT::get_Bitmap(bool LargeSize, CBitmap &CBMP)
{
UINT nIDResource = (LargeSize) ? IDB_PROJECT_32X16 : IDB_PROJECT_16X16;
// When resource from this ARX app is needed, just
// instantiate a local CAcModuleResourceOverride
CAcModuleResourceOverride myResources;
HBITMAP hBitmap=LoadBitmap(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(nIDResource));
HGDIOBJ obj = CBMP.Detach();
if (obj) ::DeleteObject(obj);
if (CBMP.Attach(hBitmap) == false) return GS_BAD;
return GS_GOOD;
}
/*********************************************************/
/*.doc C_PROJECT::getDBConnection <external> */
/*+
Questa funzione restituisce il puntatore alla connessione OLE-DB
per il progetto.
Restituisce GS-GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
C_DBCONNECTION* C_PROJECT::getDBConnection()
{
if (!pConn)
{
// se non è impostato alcun collegamento
if (ConnStrUDLFile.len() == 0 && UDLProperties.get_count() == 0)
{ // Imposto il DB ACCESS
C_STRING DataSource;
DataSource = dir;
DataSource += _T('\\');
DataSource += ACCESSGEOPRJDB;
UDLProperties.add_tail_2str(_T("Data Source"), DataSource.get_name());
ConnStrUDLFile = GEOSIM_DATASOURCE;
}
pConn = GEOsimAppl::DBCONNECTION_LIST.get_Connection(ConnStrUDLFile.get_name(), &UDLProperties);
}
return pConn;
}
/*********************************************************/
/*.doc C_PROJECT::get_CmdSelectLockWhereKey */
/*+
Questa funzione restituisce il comando SQL per la ricerca di lock
di una entità di una classe.
-*/
/*********************************************************/
_CommandPtr C_PROJECT::get_CmdSelectLockWhereKey(void)
{
if (CmdSelectLockWhereKey.GetInterfacePtr() == NULL)
{
C_DBCONNECTION *pDBConn;
C_STRING TableRef;
if (getLocksTabInfo(&pDBConn, &TableRef) == GS_BAD) return NULL;
if (gsc_PrepareSelLockWhereKey(pDBConn, TableRef,
CmdSelectLockWhereKey) == GS_BAD) return NULL;
}
return CmdSelectLockWhereKey;
}
/*********************************************************/
/*.doc C_PROJECT::get_RsSelectLock */
/*+
Questa funzione restituisce un recordset set per la ricerca dei lock.
-*/
/*********************************************************/
_RecordsetPtr C_PROJECT::get_RsSelectLock(void)
{
if (isRsSelectLockSupported == -1) // non ancora inizializzato
{
if (RsSelectLock.GetInterfacePtr() == NULL)
{
C_DBCONNECTION *pDBConn;
C_STRING TableRef;
bool RsOpened = false;
if (getLocksTabInfo(&pDBConn, &TableRef) == GS_BAD) return NULL;
// 1) il metodo seek è attualmente supportato solo da JET
// 2) se si prova ad aprire un recordset con la modalità adCmdTableDirect
// mentre si è in una transazione questa viene automaticamente abortita
// con PostgreSQL
if (gsc_strcmp(pDBConn->get_DBMSName(), _T("MS JET"), FALSE) != 0)
{
// Mi segno che non supporta il metodo seek per non riprovare più
isRsSelectLockSupported = 0;
return NULL;
}
// rimuove se esiste il prefisso e il suffisso (es. per ACCESS = [ ])
TableRef.removePrefixSuffix(pDBConn->get_InitQuotedIdentifier(), pDBConn->get_FinalQuotedIdentifier());
// istanzio un recordset
if (FAILED(RsSelectLock.CreateInstance(__uuidof(Recordset))))
{ GS_ERR_COD = eGSOutOfMem; return GS_BAD; }
try
{
RsSelectLock->CursorLocation = adUseServer;
// apro il recordset
RsSelectLock->Open(TableRef.get_name(), pDBConn->get_Connection().GetInterfacePtr(),
adOpenDynamic, adLockPessimistic, adCmdTableDirect);
RsOpened = true;
if (RsSelectLock->Supports(adIndex) && RsSelectLock->Supports(adSeek))
isRsSelectLockSupported = 1; // supportato
else
{
isRsSelectLockSupported = 0; // non supportato
gsc_DBCloseRs(RsSelectLock);
}
}
catch (_com_error)
{
isRsSelectLockSupported = 0; // non supportato
if (RsOpened) gsc_DBCloseRs(RsSelectLock);
else RsSelectLock.Release();
}
}
}
else // già inizializzato
if (isRsSelectLockSupported == 1) // se era supportato il recordset
// e per qualche motivo il recordset risulta chiuso
// (per esempio chiambiando indice su una tabella... baco microsoft)
if (gsc_DBIsClosedRs(RsSelectLock) == GS_GOOD)
{
isRsSelectLockSupported = 0;
try
{
RsSelectLock.Release();
}
catch (_com_error)
{}
}
return (isRsSelectLockSupported == 1) ? RsSelectLock : NULL;
}
/*********************************************************/
/*.doc C_PROJECT::get_RsInsertLock */
/*+
Questa funzione restituisce un recordset per l'inserimento dei locks.
-*/
/*********************************************************/
_RecordsetPtr C_PROJECT::get_RsInsertLock(void)
{
if (RsInsertLock.GetInterfacePtr() == NULL)
{
C_DBCONNECTION *pDBConn;
C_STRING TableRef;
// istanzio un recordset
if (FAILED(RsInsertLock.CreateInstance(__uuidof(Recordset))))
{ GS_ERR_COD = eGSOutOfMem; return NULL; }
if (getLocksTabInfo(&pDBConn, &TableRef) == GS_BAD) return NULL;
if (pDBConn->InitInsRow(TableRef.get_name(), RsInsertLock) == GS_BAD) return NULL;
}
return RsInsertLock;
}
/*********************************************************/
/*.doc C_PROJECT::TerminateSQL <internal> */
/*+
Questa funzione termina i recordset e i comandi eventualmente
inizializzati e pone la connessione OLE-DB nulla.
Parametri:
C_DBCONNECTION *pConnToTerminate; Opzionale; connessione da terminare,
se non passata termina tutte le connessioni
(default = NULL)
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
void C_PROJECT::TerminateSQL(C_DBCONNECTION *pConnToTerminate)
{
bool Terminate = true;
if (pConnToTerminate && pConnToTerminate != pConn) Terminate = false;
if (Terminate)
{
if (RsSelectLock.GetInterfacePtr())
{ RsSelectLock->Close(); RsSelectLock.Release(); }
if (RsInsertLock.GetInterfacePtr())
{ RsInsertLock->Close(); RsInsertLock.Release(); }
if (CmdSelectLockWhereKey.GetInterfacePtr()) CmdSelectLockWhereKey.Release();
if (CmdSelectLockWhereStatusFree.GetInterfacePtr()) CmdSelectLockWhereStatusFree.Release();
pConn = NULL;
}
}
/*********************************************************/
/*.doc C_PROJECT::from_rb <external> */
/*+
Questa funzione riempie i valori di un progetto da un resbuf
Lista RESBUF
(<name><dir>[<key_dwg>[<coordsys>[<dwg_dim>[(<DBConnection>)]]]])
dove:
<DBConnection> = (<UDL reference><UDL Props>)
<UDL reference> = UDL file | UDL connection string
<UDL Props> = ((<Prop Name1><Value1>)(<Prop Name2><Value2>)...) | nil
Restituisce GS-GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_PROJECT::from_rb(resbuf *rb)
{
if (rb == NULL) { GS_ERR_COD = eGSInvalidArg; return GS_BAD; }
// name
if (rb->restype == RTSTR)
{
if (wcslen(rb->resval.rstring) >= MAX_LEN_PRJNAME)
{ GS_ERR_COD = eGSStringTooLong; return GS_BAD; }
else wcscpy(name, rb->resval.rstring);
}
else { GS_ERR_COD=eGSInvRBType; return GS_BAD; }
// descr
if ((rb = rb->rbnext) == NULL) return GS_BAD;
if (rb->restype == RTSTR) Descr = rb->resval.rstring;
else Descr.clear();
// dir
if ((rb = rb->rbnext) == NULL) return GS_BAD;
if (rb->restype == RTSTR)
{
if (set_dir(rb->resval.rstring) == GS_BAD) return GS_BAD;
}
else { GS_ERR_COD = eGSInvRBType; return GS_BAD; }
// keydwg (opzionale)
if ((rb = rb->rbnext) == NULL) return GS_GOOD;
if (rb->restype == RTSTR)
{
if (set_keydwg(rb->resval.rstring) == GS_BAD) return GS_BAD;
}
else if (rb->restype != RTNIL) { GS_ERR_COD = eGSInvRBType; return GS_BAD; }
// coordinate (opzionale)
if ((rb = rb->rbnext) == NULL) return GS_GOOD;
if (rb->restype == RTSTR)
{
if (wcslen(rb->resval.rstring) >= MAX_LEN_COORDNAME)
{ GS_ERR_COD = eGSStringTooLong; return GS_BAD; }
else wcscpy(coordinate, rb->resval.rstring);
}
else if (rb->restype != RTNIL) { GS_ERR_COD = eGSInvRBType; return GS_BAD; }
// dwg_dim divisione territorio (opzionale)
if ((rb = rb->rbnext) == NULL) return GS_GOOD;
gsc_rb2Int(rb, &dwg_dim);
// DBConnection delle tabelle interne (opzionale)
if ((rb = rb->rbnext) == NULL) return GS_GOOD;
if (rb->restype != RTLB)
{
ConnStrUDLFile.clear();
UDLProperties.remove_all();
}
else
{
C_INFO info;
if (info.from_rb(rb) == NULL) return GS_BAD;
ConnStrUDLFile = info.ConnStrUDLFile;
info.UDLProperties.copy(UDLProperties);
}
return GS_GOOD;
}
/*********************************************************/
/*.doc C_PROJECT::is_valid <external> */
/*+
Questa funzione controlla i valori di un progetto.
Restituisce GS-GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_PROJECT::is_valid()
{
// verifico validità name
if (wcslen(name) == 0) { GS_ERR_COD = eGSInvalidPrjName; return GS_BAD; }
// verifico validità dir
if (gsc_validdir(dir) == NULL) return GS_BAD;
if (keydwg.len() > 0)
// verifico validità keydwg (funziona anche se keydwg è dir + file)
if (gsc_validdirdwg(keydwg) == NULL) return GS_BAD;
// verifico validità coord
if (gsc_validcoord(coordinate) == GS_BAD) return GS_BAD;
return GS_GOOD;
}
/*********************************************************/
/*.doc gs_ReindexMainTab <external> */
/*+
Questa funzione LISP reindicizza le tabelle principali di GEOsim e
dei progetti.
Parametri:
[prj] opzionale; se viene passato il codice di un progetto
verrà reindicizzato solo quel progetto
Restituisce TRUE in caso di successo altrimenti restituisce NIL.
-*/
/*********************************************************/
int gs_reindexmaintab(void)
{
presbuf arg = acedGetArgs();
int prj = 0;
acedRetNil();
// codice del progetto
if (arg)
if (gsc_rb2Int(arg, &prj) != GS_GOOD)
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
if (gsc_ReindexMainTab(prj) == GS_BAD) return RTERROR;
acedRetT();
return RTNORM;
}
/*********************************************************/
/*.doc gsc_ReindexMainTab <external> */
/*+
Questa funzione reindicizza le tabelle principali di GEOsim e
dei progetti.
Parametri:
int prj; codice progetto da reindicizzare (opzionale; se = 0
reindicizza tutti i progetti)
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int gsc_ReindexMainTab(int prj)
{
C_STRING TableRef, Index;
C_DBCONNECTION *pConn;
C_PROJECT *punt;
int result = GS_GOOD;
if (gsc_getPrjTabInfo(&pConn, &TableRef) == GS_BAD) return GS_BAD;
// (se fallisce devo comunque continuare)
// aggiorno gli indici di GS_PRJ
acutPrintf(_T("%s %s..."), gsc_msg(348), TableRef.get_name()); // "\nReindicizzazione"
// memorizzo gli indici utilizzati dalla tabella originale
pConn->Reindex(TableRef.get_name());
punt = (C_PROJECT *) GEOsimAppl::PROJECTS.get_head();
while (punt)
{
if (prj == 0 || punt->get_key() == prj)
if (punt->reindex() == GS_BAD) result = GS_BAD;
punt = (C_PROJECT *) GEOsimAppl::PROJECTS.get_next();
}
return result;
}
/*********************************************************/
/*.doc gsc_getPRJSampleTables <internal> */
/*+
Questa funzione legge la lista delle tabelle campione usate
come tabelle interne (meta-tabelle) di un progetto GEOsim.
Parametri:
C_STR_LIST &TableList; Lista delle tabelle
C_DBCONNECTION **pConn; Opzionale, connessione al DB campione
(default = NULL)
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int gsc_getPRJSampleTables(C_STR_LIST &TableList, C_DBCONNECTION **pConn)
{
C_STRING DataSource;
C_2STR_LIST UDLProps;
C_DBCONNECTION *pMyConn;
DataSource = GEOsimAppl::GEODIR + _T('\\') + GEOSAMPLEDIR + _T('\\') + ACCESSGEOPRJSAMPLEDB;
UDLProps.add_tail_2str(_T("Data Source"), DataSource.get_name());
// Leggo la lista delle tabelle dal database "campione" ACCESS
if ((pMyConn = GEOsimAppl::DBCONNECTION_LIST.get_Connection(ACCESS_DATASOURCE, &UDLProps)) == NULL)
return GS_BAD;
if (pMyConn->getTableAndViewList(TableList, NULL, NULL, NULL,
true, _T("TABLE"), false) == GS_BAD)
return GS_BAD;
if (pConn) *pConn = pMyConn;
return GS_GOOD;
}
/*********************************************************/
/*.doc gsc_createprj <external> */
/*+
Questa funzione crea un progetto di GEOsim.
Parametri:
C_PROJECT *pProject; Progetto campione
Restituisce codice progetto in caso di successo altrimenti restituisce GS_BAD.
-*/