-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigMgr.asmx.cs
2757 lines (2457 loc) · 106 KB
/
ConfigMgr.asmx.cs
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
//*******************************************************************************//
// Developpement : Raphael DELPLANQUE //
//*******************************************************************************//
using System;
using System.Threading;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
using System.Web.Services;
using ConfigMgr.Configuration.Webservice.utils;
using ConfigMgr.Configuration.Webservice.utils.SMS;
using ConfigMgr.Configuration.Webservice.utils.LDAP;
using Microsoft.Win32;
using Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine;
namespace ConfigMgr.Configuration.Webservice
{
//****************************************************************************//
// Cette classe definit les methodes relatives au Webservice ConfigMgr //
// permettant de disposer des informations d'installation des serveurs de //
// l infrastructure SCCM. //
// //
// Ce webservice met a disposition les methodes suivantes :
// AddClientToCollection
// Add a Client in a collection
//
// AddComputerAssociationForMigration
// Add a computer association between a computer and older computer for a single user
//
// AddDPGroups
// Add a distribution point to a Distribution Group
//
// AddPackageOnDistributionPoint
// Add a package on a Distribution Point
//
// AddSecondaryToCollection
// Add a distribution Group to a Collection
//
// AddSenderAddress
// Add a sender Address in order to communicate with a new site recently created
//
// AddSiteBoundaries
// Add Site Boundary
//
// AddUnknownClientToCollection
// Add an unknown Client from a collection
//
// AssignApplicationToCollection
// Deploy an application on a collection of devices or Users
//
// CopyPackageOnDP
// Copy all packages on the Dp from a Reference Distribution Point
//
// CreateApplication
// Add an unknown Client from a collection
//
// GetADSiteFromGateway
// Get ADSite by Gateway
//
// GetADSiteFromIP
// Get ADSite by IP Address
//
// GetAllBoundaries
// Get all boundaries available in SCCM
//
// GetAllClient
// Retrieve all clients informations available in SCCM
//
// GetAllDPGroups
// Get all DP Groups available in SCCM
//
// GetAllUserAdmin
// Retrieve all clients informations available in SCCM
//
// GetApplicationsListInfos
// Get all applications assign to a Site
//
// GetClientByName
// Retrieve Clients associate to the UserName (Without domain)
//
// GetClientBySubnet
// Retrieve Clients associate to a subnet (format = > 192.168.1.0)
//
// GetClientByUUID
// Retrieve client informations available in SCCM by BIOS UUID identifier
//
// GetClientByUserName
// Retrieve Clients associate to the UserName (Without domain)
//
// GetClientDetailsLDAP
// Get Computer informations from the active directory
//
// GetClientExist
// Client Exist ? 1=Yes | 0=No
//
// GetClientOSByResourceID
// Retrieve client Operating System informations available in SCCM by ResourceID
//
// GetCollectionID
// Get all Collection ID associate to a client
//
// GetCriticalSiteComponent
// Get All Critical status for a component, example : SMS_MP
//
// GetDirectCollectionID
// Get all direct collection assignement to a Client
//
// GetLocationSite
// Get client Location by IP Address
//
// GetPackagesListInfos
// Get all Packages | Boot Images | Windows Updates assign to a Site
//
// GetParentSiteInfos
// Get a parent of a SCCM server
//
// GetServerExist
// SCCM Server Exist => 1=Yes | 0=No
//
// GetServerInfos
// Get the SCCM Server informations
//
// GetSiteCodeInfos
// Get the Site code of a SCCM Server
//
// GetTaskSequencesListInfos
// Get all task sequences assign to a Site
//
// GetUnknowClientByUUID
// Check for 'Unknown' Client record by UUID (SMBIOS GUID)
//
// IsInAllSystemsCollection
// Check if client exist in the collection AllSystems
//
// IsPackageExist
// Check if a package exist in SCCM
//
// RefreshAllPackages
// Refresh all packages assign to a distribution point
//
// RefreshPackage
// Refresh a package assign to a distribution point
//
// RemoveClientByName
// Remove client in SCCM by Name
//
// RemoveClientByUUID
// Remove client in SCCM by BIOS UUID identifier
//
// RemoveClientFromCollection
// Remove a Client from a collection
//
// RemoveClientLDAP
// Remove a computer from the active directory
//
// RemoveDPGroups
// Remove a distribution point from a Distribution Group
//
// RemovePackageFromDistributionPoint
// Remove a Package from a distribution point
//
// RemoveSenderAddress
// Remove a Sender Address
//
// RemoveServerFromSCCM
// Remove a server from SCCL
//
// RemoveSiteBoundaries
// Remove all site boundaries associte to a Server site
//
// RemoveUnknowClientByUUID
// Check for 'Unknown' Client record by UUID (SMBIOS GUID)
//
// RemoveUnknownClientFromCollection
// Remove an unknown Client from a collection
//
// SyncKeySecondary
// Send the Secondary Key to The Primary server and conversely in order to synchronize both sites
//
// UpdateSiteBoundaries
// Update site boudaries
//****************************************************************************//
/// <summary>
///
/// </summary>
///
[WebService(Namespace = "ConfigMgr.ai3.infraweb.fr")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class ConfigMgr : WebService
{
//************************************************************************//
// Initialisation des variables de classe //
//************************************************************************//
private string _className = "ConfigMgr";
/// <summary>
///
/// </summary>
public Logger _log = new Logger();
/// <summary>
///
/// </summary>
public DataAccess _da = new DataAccess();
/// <summary>
///
/// </summary>
public LDAPAccess _ldap = new LDAPAccess();
//************************************************************************//
// Constructeur de SccmAccess //
//************************************************************************//
/// <summary>
/// Constructeur de SccmAccess
/// </summary>
public SccmAccess _sa = new SccmAccess();
/// <summary>
///
/// </summary>
/// <param name="IPStation"></param>
/// <returns></returns>
[WebMethod(Description = "Get client Location by IP Address")]
public List<SMS_Boundary> GetLocationSite(string IPStation)
{
List<SMS_Boundary> Boundaries = new List<SMS_Boundary>();
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, IPStation, "Starting the call " + methodName);
if (!string.IsNullOrEmpty(IPStation))
{
Boundaries = _sa.GetSiteCodeByIPBound(IPStation, ConnectionManager);
//if (Boundaries.Count > 1)
//{
// throw new Exception("Erreur Overlapping : L'Ip " + IPStation + " est associee à plusieurs sites");
//}
}
return Boundaries;
}
catch (Exception ex)
{
_log.Write(_className, methodName, "Exception", "Impossible de recuperer les informations de localisation");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
// return "1;" + ex.Message.ToString();
return new List<SMS_Boundary>();
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, IPStation, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="IPStation"></param>
/// <returns></returns>
[WebMethod(Description = "Get ADSite by IP Address")]
public List<SMS_ADSite> GetADSiteFromIP(string IPStation)
{
List<SMS_ADSite> SMS_ADSites = new List<SMS_ADSite>();
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, IPStation, "Starting the call " + methodName);
if (!string.IsNullOrEmpty(IPStation))
{
SMS_ADSites = _sa.GetADSiteByIPBound(IPStation, ConnectionManager);
}
return SMS_ADSites;
}
catch (Exception ex)
{
_log.Write(_className, methodName, "Exception", "Impossible de recuperer les informations de localisation");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
// return "1;" + ex.Message.ToString();
return new List<SMS_ADSite>();
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, IPStation, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="Domain"></param>
/// <param name="HostName"></param>
/// <param name="UserName"></param>
/// <param name="Password"></param>
/// <returns></returns>
[WebMethod(Description = "Get Computer informations from the active directory")]
public List<LDAPAccess.LDAP_Computer> GetClientDetailsLDAP(string Domain, string HostName, string UserName, string Password)
{
List<LDAPAccess.LDAP_Computer> LDAP_Computers = new List<LDAPAccess.LDAP_Computer>();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, HostName, "Starting the call " + methodName);
if (!string.IsNullOrEmpty(HostName))
{
LDAP_Computers = _ldap.GetComputerDetailsLDAP(Domain, HostName, UserName, Password);
};
return LDAP_Computers;
}
catch (Exception ex)
{
_log.Write(_className, methodName, "Exception", "Impossible de recuperer les informations LDAP");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
// return "1;" + ex.Message.ToString();
throw new Exception(ex.Message);
}
finally
{
_log.Write(_className, methodName, HostName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="Domain"></param>
/// <param name="HostName"></param>
/// <param name="UserName"></param>
/// <param name="Password"></param>
/// <returns></returns>
[WebMethod(Description = "Remove a computer from the active directory")]
public bool RemoveClientLDAP(string Domain, string HostName, string UserName, string Password)
{
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
bool Return = false;
try
{
_log.Write(_className, methodName, HostName, "Starting the call " + methodName);
if (!string.IsNullOrEmpty(HostName))
{
Return = _ldap.RemoveComputerFromLDAP(Domain, HostName, UserName, Password);
};
return Return;
}
catch (Exception ex)
{
_log.Write(_className, methodName, "Exception", "Impossible de supprimer l'objet de puis l AD");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
// return "1;" + ex.Message.ToString();
throw new Exception(ex.Message);
}
finally
{
_log.Write(_className, methodName, HostName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="Gateway"></param>
/// <returns></returns>
[WebMethod(Description = "Get ADSite by Gateway")]
public List<SMS_ADSite> GetADSiteFromGateway(string Gateway)
{
List<SMS_ADSite> SMS_ADSites = new List<SMS_ADSite>();
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, Gateway, "Starting the call " + methodName);
if (!string.IsNullOrEmpty(Gateway))
{
SMS_ADSites = _sa.GetADSiteByGateway(Gateway, ConnectionManager);
}
return SMS_ADSites;
}
catch (Exception ex)
{
_log.Write(_className, methodName, "Exception", "Impossible de recuperer les informations de localisation");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
// return "1;" + ex.Message.ToString();
return new List<SMS_ADSite>();
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, Gateway, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[WebMethod(Description = "Get all DP Groups available in SCCM")]
public SMS_DistributionPointList GetAllDPGroups()
{
string returnCode = "0";
System.Diagnostics.StackFrame sf;
SMS_DistributionPointList ListDPGroups = new SMS_DistributionPointList();
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
ListDPGroups = _sa.GetAllDPGroups(ConnectionManager);
return ListDPGroups;
}
catch (Exception ex)
{
returnCode = "1";
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information.");
return new SMS_DistributionPointList();
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "Fin de l'appel " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[WebMethod(Description = "Get all boundaries available in SCCM")]
public List<SMS_Boundary> GetAllBoundaries()
{
List<SMS_Boundary> SMSBoundaries = new List<SMS_Boundary>();
string returnCode = "0";
System.Diagnostics.StackFrame sf;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
SMSBoundaries = _sa.GetSiteBoundaries(string.Empty, ConnectionManager);
return SMSBoundaries;
}
catch (Exception ex)
{
returnCode = "1";
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information.");
// return returnCode + ";" + ex.Message;
return new List<SMS_Boundary>();
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "Fin de l'appel " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="SMSBIOSUUID"></param>
/// <returns></returns>
[WebMethod(Description = "Check for 'Unknown' Client record by UUID (SMBIOS GUID)")]
public List<SMS_R_System> GetUnknowClientByUUID(string SMSBIOSUUID)
{
string returnCode;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
List<SMS_R_System> ListSystem = new List<SMS_R_System>();
try
{
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
_log.Write(_className, methodName, methodName, "Une demande d informations va etre traitee.");
ListSystem = _sa.GetClientByUUID(ConnectionManager, SMSBIOSUUID);
return ListSystem;
}
catch (Exception ex)
{
returnCode = "1";
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return new List<SMS_R_System>();
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="Name"></param>
/// <param name="CollectionID"></param>
/// <returns></returns>
[WebMethod(Description = "Add a Client in a collection")]
public int AddClientToCollection(string Name, string CollectionID)
{
int returnCode;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
_log.Write(_className, methodName, methodName, "Une demande d informations va etre traitee.");
returnCode = _sa.AddClientToCollection(ConnectionManager, Name.ToUpper(), CollectionID);
return returnCode;
}
catch (Exception ex)
{
returnCode = 1;
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return returnCode;
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="Name"></param>
/// <param name="CollectionID"></param>
/// <returns></returns>
[WebMethod(Description = "Remove a Client from a collection")]
public int RemoveClientFromCollection(string Name, string CollectionID)
{
int returnCode;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
_log.Write(_className, methodName, methodName, "Une demande d informations va etre traitee.");
returnCode = _sa.RemoveClientFromCollection(ConnectionManager, Name.ToUpper(), CollectionID);
return returnCode;
}
catch (Exception ex)
{
returnCode = 1;
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return returnCode;
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="UUID"></param>
/// <param name="CollectionID"></param>
/// <returns></returns>
[WebMethod(Description = "Remove an unknown Client from a collection")]
public int RemoveUnknownClientFromCollection(string UUID, string CollectionID)
{
int returnCode;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
_log.Write(_className, methodName, methodName, "Une demande d informations va etre traitee.");
returnCode = _sa.RemoveUnknownComputerFromCollection(ConnectionManager, UUID, CollectionID);
return returnCode;
}
catch (Exception ex)
{
returnCode = 1;
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return returnCode;
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "End of the call " + methodName);
}
}
[WebMethod(Description = "Add a package on a Distribution Point")]
public int AddPackageOnDistributionPoint(string serverName, string PackageID)
{
int returnCode;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
string siteCode = null;
try
{
siteCode= _sa.GetSiteCodeByDistributionPointName(ConnectionManager, serverName);
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
_log.Write(_className, methodName, methodName, "Une demande d informations va etre traitee.");
returnCode = _sa.AssignPackageToDistributionPoint(ConnectionManager, PackageID, siteCode, serverName);
return returnCode;
}
catch (Exception ex)
{
returnCode = 1;
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return returnCode;
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="UUID"></param>
/// <param name="CollectionID"></param>
/// <returns></returns>
[WebMethod(Description = "Add an unknown Client from a collection")]
public int AddUnknownClientToCollection(string UUID, string CollectionID)
{
int returnCode;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
_log.Write(_className, methodName, methodName, "Une demande d informations va etre traitee.");
returnCode = _sa.AddUnknownComputerToCollection(ConnectionManager, UUID, CollectionID);
return returnCode;
}
catch (Exception ex)
{
returnCode = 1;
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return returnCode;
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="UUID"></param>
/// <param name="CollectionID"></param>
/// <returns></returns>
[WebMethod(Description = "Add an unknown Client from a collection")]
public int CreateApplication(string Publisher,string SoftwareVersion,string Title)
{
int returnCode;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
_log.Write(_className, methodName, methodName, "Une demande d informations va etre traitee.");
returnCode = _sa.CreateApplication(ConnectionManager, Publisher, SoftwareVersion, Title);
return returnCode;
}
catch (Exception ex)
{
returnCode = 1;
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
throw ex;
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="SMSBIOSUUID"></param>
/// <returns></returns>
[WebMethod(Description = "Check for 'Unknown' Client record by UUID (SMBIOS GUID)")]
public int RemoveUnknowClientByUUID(string SMSBIOSUUID)
{
int returnCode;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, methodName, "Starting the call " + methodName);
_log.Write(_className, methodName, methodName, "Une demande d informations va etre traitee.");
returnCode = _sa.RemoveUnknownClientByUUID(ConnectionManager, SMSBIOSUUID);
return returnCode;
}
catch (Exception ex)
{
returnCode = 1;
_log.Write(_className, methodName, "Exception", returnCode + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return returnCode;
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, methodName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="serverName"></param>
/// <param name="Type"></param>
/// <returns></returns>
[WebMethod(Description = "Get all Packages | Boot Images | Windows Updates assign to a Site")]
public ReturnsPackages GetPackagesListInfos(string serverName, string Type)
{
string SiteCode = null;
List<SMS_Package> PackageList = new List<SMS_Package>();
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, serverName, "Starting the call " + methodName);
if (_sa.ExistServerName(serverName, ConnectionManager))
{
SiteCode = _sa.GetSiteCodeByServerName(serverName, ConnectionManager);
if (string.IsNullOrEmpty(SiteCode))
{
return new ReturnsPackages() { ListPackage = new List<SMS_Package>(), ReturnCode = 1 };
}
else
{
if (string.IsNullOrEmpty(Type))
{
Type = "2";
}
PackageList.AddRange(_da.SMS_GetPackagesInfos(SiteCode, Type));
PackageList.AddRange(_da.SMS_GetImagesInfos(SiteCode, Type));
PackageList.AddRange(_da.SMS_GetSoftwareUpdatesInfos(SiteCode, Type));
}
}
else
{
return null;
}
return new ReturnsPackages() { ListPackage = PackageList, ReturnCode = 0 };
}
catch (Exception ex)
{
_log.Write(_className, methodName, "Exception", 1 + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return new ReturnsPackages() { ListPackage = new List<SMS_Package>(), ReturnCode = 1 };
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, serverName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="serverName"></param>
/// <returns></returns>
[WebMethod(Description = "Get all applications assign to a Site")]
public List<SMS_Application> GetApplicationsListInfos(string serverName)
{
string SiteCode = null;
List<SMS_Application> PackageList = new List<SMS_Application>();
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, serverName, "Starting the call " + methodName);
if (_sa.ExistServerName(serverName, ConnectionManager))
{
SiteCode = _sa.GetSiteCodeByServerName(serverName, ConnectionManager);
if (string.IsNullOrEmpty(SiteCode))
{
return new List<SMS_Application>();
}
else
{
PackageList.AddRange(_sa.GetApplicationsBySite(ConnectionManager,SiteCode));
}
}
else
{
return null;
}
return PackageList;
}
catch (Exception ex)
{
_log.Write(_className, methodName, "Exception", 1 + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return new List<SMS_Application>();
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, serverName, "End of the call " + methodName);
}
}
[WebMethod(Description = "Deploy an application on a collection of devices or Users")]
public int AssignApplicationToCollection(string AssignmentName, string ApplicationName, string CollectionID)
{
int Return = 0;
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, ApplicationName, "Starting the call " + methodName);
_sa.ApplicationAssignment(ConnectionManager, AssignmentName, ApplicationName, CollectionID);
return 0;
}
catch (Exception ex)
{
_log.Write(_className, methodName, "Exception", 1 + ";" + "Error retrieving information");
_log.Write(_className, methodName, "Exception", ex.Message.ToString());
return 1;
}
finally
{
Myconnection.Disconnect(ConnectionManager);
_log.Write(_className, methodName, ApplicationName, "End of the call " + methodName);
}
}
/// <summary>
///
/// </summary>
/// <param name="serverName"></param>
/// <returns></returns>
[WebMethod(Description = "Get all task sequences assign to a Site")]
public List<SMS_TaskSequencePackage> GetTaskSequencesListInfos(string serverName)
{
string SiteCode = null;
List<SMS_TaskSequencePackage> PackageList = new List<SMS_TaskSequencePackage>();
Connection Myconnection = new Connection();
WqlConnectionManager ConnectionManager = Myconnection.Connect();
System.Diagnostics.StackFrame sf;
sf = new System.Diagnostics.StackFrame();
string methodName = sf.GetMethod().Name;
try
{
_log.Write(_className, methodName, serverName, "Starting the call " + methodName);
if (_sa.ExistServerName(serverName, ConnectionManager))
{
SiteCode = _sa.GetSiteCodeByServerName(serverName, ConnectionManager);
if (string.IsNullOrEmpty(SiteCode))
{
return new List<SMS_TaskSequencePackage>();
}
else
{
PackageList.AddRange(_sa.GetTaskSequencesBySite(SiteCode, ConnectionManager));