internal program(IResultObject obj) { obj.Get(); this.actionInProgress = nullIntHandler(obj, "ActionInProgress"); this.applicationHierarchy = nullStringHandler(obj, "ApplicationHierarchy"); this.commandLine = nullStringHandler(obj, "CommandLine"); this.comment = nullStringHandler(obj, "Comment"); this.dependentProgram = nullStringHandler(obj, "DependentProgram"); this.description = nullStringHandler(obj, "Description"); this.deviceFlags = nullIntHandler(obj, "DeviceFlags"); this.diskSpaceReq = nullStringHandler(obj, "DiskSpaceReq"); this.driveLetter = nullStringHandler(obj, "DriveLetter"); this.duration = nullIntHandler(obj, "Duration"); this.extendedData = convertIntArray(obj["ExtendedData"].IntegerArrayValue); this.extendedDataSize = nullIntHandler(obj, "ExtendedDataSize"); this.icon = convertIntArray(obj["Icon"].IntegerArrayValue); this.iconSize = nullIntHandler(obj, "IconSize"); this.isvData = convertIntArray(obj["ISVData"].IntegerArrayValue); this.isvDataSize = nullIntHandler(obj, "ISVDataSize"); this.msiFilePath = nullStringHandler(obj, "MSIFilePath"); this.msiProductID = nullStringHandler(obj, "MSIProductID"); this.packageID = nullStringHandler(obj, "PackageID"); this.programFlags = nullIntHandler(obj, "ProgramFlags"); this.programName = nullStringHandler(obj, "ProgramName"); this.removalKey = nullStringHandler(obj, "RemovalKey"); this.requirements = nullStringHandler(obj, "Requiremens"); this.supportedOperatingSystems = generateSupportedOperatingSystemList(obj); this.workingDirectory = nullStringHandler(obj, "WorkingDirectory"); }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String DisplayName = request.Inputs["Display Name"].AsString(); String Description = request.Inputs["Description"].AsString(); String InformativeURL = request.Inputs["Informative URL"].AsString(); String LocaleID = request.Inputs["LocaleID"].AsString(); String UpdatesList = request.Inputs["Updates List (CSV)"].AsString(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password); using (connection) { try { IResultObject col = CM2012Interop.createSCCMAuthorizationList(connection, DisplayName, Description, InformativeURL, LocaleID, UpdatesList); if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } } catch (Exception ex) { response.LogErrorMessage(ex.Message); } response.Publish("Number of Packages", ObjCount); } }
private static void DeleteDeployment(object sender, IResultObject selectedResultObject, PropertyDataUpdated dataUpdatedDelegate, string displayPropertyName, bool confirmDialog = true) { IResultObject deploymentFromSummarizer = Utilities.GetCorrespondingDeploymentFromSummarizer(selectedResultObject); if (confirmDialog) { if (System.Windows.MessageBox.Show(string.Format("Delete the selected '{0}' deployment?", selectedResultObject[displayPropertyName].StringValue), "Configuration Manager", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) != MessageBoxResult.Yes) { return; } } deploymentFromSummarizer.Delete(); List <PropertyDataUpdateItem> refreshDataList = new List <PropertyDataUpdateItem> { new PropertyDataUpdateItem(selectedResultObject, PropertyDataUpdateAction.Delete) }; if (dataUpdatedDelegate == null) { return; } dataUpdatedDelegate(sender, refreshDataList); }
private static String generateSupportedOperatingSystemList(IResultObject obj) { String retValue = String.Empty; try { List <IResultObject> arrayItems = obj.GetArrayItems("SupportedOperatingSystems"); if (arrayItems != null) { foreach (IResultObject supportedOS in arrayItems) { if (retValue.Equals(String.Empty)) { retValue = "Name:" + supportedOS["Name"].StringValue + "-Platform:" + supportedOS["Platform"].StringValue + "-MinVersion:" + supportedOS["MinVersion"].StringValue + "-MaxVersion:" + supportedOS["MaxVersion"].StringValue; } else { retValue = retValue + ",Name:" + supportedOS["Name"].StringValue + "-Platform:" + supportedOS["Platform"].StringValue + "-MinVersion:" + supportedOS["MinVersion"].StringValue + "-MaxVersion:" + supportedOS["MaxVersion"].StringValue; } } } } catch { } return(retValue); }
public bool DoInspect(IParameter parameter, ref IInspectedResult inspectedResult) { if (parameter.SpecMap["Bond"] is BondSpec spec) { inspectedResult.Description += String.Format("본드 이진화 값:{0} ", spec.BinarizationThreshold); } IResultObject resultObject = _container.Resolve <IResultObject>(); resultObject.ResultType = ResultType.Ng; resultObject.Description = "본드 모르는 불량."; resultObject.GrabImageMap = new Dictionary <string, IGrabImage>() { { "Bond", parameter.GrabImageMap["Bond"] } }; resultObject.ShapeMap = new Dictionary <string, EditableShape>() { { "Bond", parameter.EditableShapesMap["Bond"].First() } }; inspectedResult.ResultObjectMap.Add("Bond", resultObject); foreach (var shape in parameter.EditableShapesMap["Bond"]) { IRoundingRect rect = shape as IRoundingRect; } return(true); }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String pkgName = request.Inputs["New Package Name"].AsString(); String pkgDescription = request.Inputs["New Package Description"].AsString(); int pkgSourceFlag = (int)request.Inputs["New Package Source Flag"].AsUInt32(); String pkgSourcePath = request.Inputs["New Package Source Path"].AsString(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password); using (connection) { IResultObject col = CM2012Interop.createSCCMPackage(connection, pkgName, pkgDescription, pkgSourceFlag, pkgSourcePath); if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } response.Publish("Number of Packages", ObjCount); } }
private static String generateCollectionRulesString(IResultObject obj) { String retValue = String.Empty; List <IResultObject> arrayItems = obj.GetArrayItems("CollectionRules"); try { if (arrayItems != null) { foreach (IResultObject CollectionRules in arrayItems) { if (retValue.Equals(String.Empty)) { retValue = CollectionRules["RuleName"].StringValue; } else { retValue = retValue + "," + CollectionRules["RuleName"].StringValue; } } } } catch { } return(retValue); }
internal bool CheckIfExists(ConnectionManagerBase connectionManager) { // would be good if we could check based on architecture here, but there is no column that supports that in SMS_Driver without digging into the xml // we could maybe hack in the description field and append architecture string query = string.Format("SELECT * FROM SMS_Driver WHERE LocalizedDisplayName='{0}' AND DriverVersion='{1}' AND DriverINFFile='{2}'", Model, Version, Path.GetFileName(InfLocation)); IResultObject driverObject = Utility.GetFirstWMIInstance(connectionManager, query); if (driverObject != null) { if (!Directory.Exists(driverObject["ContentSourcePath"].StringValue)) { log.Debug("UpdateContentSourcePath: " + driverObject["LocalizedDisplayName"].StringValue); try { driverObject["ContentSourcePath"].StringValue = Path.GetDirectoryName(InfLocation); driverObject.Put(); driverObject.Get(); } catch (SmsQueryException ex) { ManagementException mgmtException = ex.InnerException as ManagementException; Exception = new SystemException(mgmtException.ErrorInformation["Description"].ToString()); log.Error(string.Format("PutDriverObject: {0}, {1}, {2}", InfLocation, ex.GetType().Name, Exception.Message)); return(false); } } Object = driverObject; return(true); } return(false); }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String filter = request.Inputs["Filter Query"].AsString(); String objClass = request.Inputs["Class"].AsString(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password); using (connection) { IResultObject col = CMInterop.getSCCMObject(connection, objClass, filter); CMInterop.removeSCCMObject(connection, filter, objClass); foreach (IResultObject obj in col) { ObjCount++; } response.Publish("Number of Objects", ObjCount); } }
public NeoQueryData CollectData() { NeoQueryData querydata = new NeoQueryData(); List <object> propertylist = new List <object>(); try { // This query selects all collections string cmquery = "select * from SMS_Application WHERE IsLatest='TRUE'"; // Run query using (IResultObject results = Connector.Instance.Connection.QueryProcessor.ExecuteQuery(cmquery)) { // Enumerate through the collection of objects returned by the query. foreach (IResultObject resource in results) { propertylist.Add(new { IsDeployed = ResultObjectHandler.GetBool(resource, "IsDeployed"), IsEnabled = ResultObjectHandler.GetBool(resource, "IsEnabled"), IsSuperseded = ResultObjectHandler.GetBool(resource, "IsSuperseded"), IsSuperseding = ResultObjectHandler.GetBool(resource, "IsSuperseding"), IsLatest = ResultObjectHandler.GetBool(resource, "IsLatest"), ID = ResultObjectHandler.GetString(resource, "CI_ID"), Name = ResultObjectHandler.GetString(resource, "LocalizedDisplayName") }); } } } catch { } querydata.Properties = propertylist; return(querydata); }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String objID = request.Inputs["Collection ID"].AsString(); String contentIDList = request.Inputs["Content ID List (CSV)"].AsString(); bool refreshDPs = request.Inputs["Refresh DPs"].AsBoolean(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password); using (connection) { CM2012Interop.modifySCCMSoftwareUpdatesPackageRemoveCIs(connection, objID, contentIDList, refreshDPs); IResultObject col = null; col = CM2012Interop.getSCCMSoftwareUpdatesPackage(connection, "PackageID LIKE '" + objID + "'"); if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } response.Publish("Number of Collections", ObjCount); } }
public NeoQueryData CollectData() { NeoQueryData querydata = new NeoQueryData(); List <object> propertylist = new List <object>(); try { // This query selects all collections string cmquery = "select CollectionID,ResourceID from SMS_FullCollectionMembership"; List <object> retlist = new List <object>(); // Run query using (IResultObject results = Connector.Instance.Connection.QueryProcessor.ExecuteQuery(cmquery)) { // Enumerate through the collection of objects returned by the query. foreach (IResultObject resource in results) { string colids = ResultObjectHandler.GetString(resource, "CollectionID"); string resourceid = ResultObjectHandler.GetString(resource, "ResourceID"); //split the collection list and foreach (string collectionid in colids.Split(',')) { propertylist.Add(new { resourceid, collectionid }); } } } } catch { } querydata.Properties = propertylist; return(querydata); }
/// <summary> /// IResultObject disposal version 2. Manual call of Dipose. /// </summary> /// <param name="wqlConnection"></param> private void IResultObjectExecuteQueryDisposalV2(WqlConnectionManager wqlConnection) { try { // As an example, get all SMS_Package objects. // ExecuteQuery returns IResultObject which is a WqlQueryResultsObject using (IResultObject queryResults = wqlConnection.QueryProcessor.ExecuteQuery("SELECT * FROM SMS_Package")) { // WqlQueryResultsObject.GetEnumerator() is implemented as: // yield return (object) new WqlResultObject(this.ConnectionManager, this.ConnectionManager.NamedValueDictionary, managementObject); foreach (IResultObject item in queryResults) { string packageName = item["Name"].StringValue; Console.WriteLine("Package: " + packageName); // Must call Dispose on each item enumerated item.Dispose(); } } } catch (SmsException) { // Error handling. } }
public NeoQueryData CollectData() { NeoQueryData querydata = new NeoQueryData(); List <object> propertylist = new List <object>(); try { // This query selects all collections int type = (int)PackageType.RegularSoftwareDistribution; string cmquery = "select * from SMS_PackageBaseclass WHERE PackageType='" + type + "'"; // Run query using (IResultObject results = Connector.Instance.Connection.QueryProcessor.ExecuteQuery(cmquery)) { // Enumerate through the collection of objects returned by the query. foreach (IResultObject resource in results) { propertylist.Add(new { Name = ResultObjectHandler.GetString(resource, "Name"), ID = ResultObjectHandler.GetString(resource, "PackageID"), Description = ResultObjectHandler.GetString(resource, "Description"), PackageType = ((PackageType)ResultObjectHandler.GetInt(resource, "PackageType")).ToString() }); } } } catch { } querydata.Properties = propertylist; return(querydata); }
public NeoQueryData CollectData() { NeoQueryData querydata = new NeoQueryData(); List <object> propertylist = new List <object>(); try { string cmquery = "select * from SMS_TaskSequencePackage"; // Run query using (IResultObject results = Connector.Instance.Connection.QueryProcessor.ExecuteQuery(cmquery)) { // Enumerate through the collection of objects returned by the query. foreach (IResultObject resource in results) { propertylist.Add(new { ID = ResultObjectHandler.GetString(resource, "PackageID"), Name = ResultObjectHandler.GetString(resource, "Name"), TaskSequenceType = ((TaskSequenceType)ResultObjectHandler.GetInt(resource, "Type")).ToString() }); } } } catch { } querydata.Properties = propertylist; return(querydata); }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String filter = request.Inputs["Filter Query"].AsString(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password); using (connection) { IResultObject col = CMInterop.getSCCMObject(connection, "SMS_R_System", filter); List <system> systemCollection = new List <system>(); foreach (IResultObject obj in col) { ObjCount++; systemCollection.Add(new system(obj)); } if (systemCollection != null) { response.WithFiltering().PublishRange(getObjects(systemCollection)); } response.Publish("Number of Systems", ObjCount); CMInterop.removeSCCMObject(connection, filter, "SMS_R_System"); } }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String objID = request.Inputs["Collection ID"].AsString(); String ruleName = request.Inputs["Rule Name"].AsString(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CM2012Interop.connectSCCMServer(SCCMServer, userName, password); using (connection) { CM2012Interop.removeSCCMCollectionMember(connection, objID, ruleName); IResultObject col = null; col = CM2012Interop.getSCCMCollection(connection, "CollectionID LIKE '" + objID + "'"); if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } response.Publish("Number of Collections", ObjCount); } }
private static String generateRefreshSchedule(IResultObject obj) { String retValue = String.Empty; List <IResultObject> arrayItems = obj.GetArrayItems("RefreshSchedule"); try { if (arrayItems != null) { foreach (IResultObject schedule in arrayItems) { if (retValue.Equals(String.Empty)) { retValue = "DayDuration:" + Convert.ToString(schedule["DayDuration"].IntegerValue) + "-HourDuration:" + Convert.ToString(schedule["HourDuration"].IntegerValue) + "-IsGMT:" + Convert.ToString(schedule["IsGMT"].BooleanValue) + "-MinuteDuration:" + Convert.ToString(schedule["MinuteDuration"].IntegerValue) + "-StartTime:" + Convert.ToString(schedule["StartTime"].DateTimeValue); } else { retValue = retValue + ",DayDuration:" + Convert.ToString(schedule["DayDuration"].IntegerValue) + "-HourDuration:" + Convert.ToString(schedule["HourDuration"].IntegerValue) + "-IsGMT:" + Convert.ToString(schedule["IsGMT"].BooleanValue) + "-MinuteDuration:" + Convert.ToString(schedule["MinuteDuration"].IntegerValue) + "-StartTime:" + Convert.ToString(schedule["StartTime"].DateTimeValue); } } } } catch { } return(retValue); }
public DeviceProgressDialog(ActionDescription action, IResultObject selectedResultObjects, MethodInfo method) : this() { resultObjects = selectedResultObjects; this.method = method; Title = action.DisplayName; }
private static String determineComputerSiteCode(IResultObject computerObj) { String SiteCode = ""; Hashtable siteTable = new Hashtable(); foreach (String sCode in computerObj["AgentSite"].StringArrayValue) { if (siteTable.ContainsKey(sCode)) { int temp = (int)siteTable[sCode]; temp++; siteTable[sCode] = temp; } else { siteTable.Add(sCode, 1); } } int highest = 0; foreach (String sCode in siteTable.Keys) { int temp = (int)siteTable[sCode]; if (temp > highest) { highest = temp; SiteCode = sCode; } } return(SiteCode); }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String objID = request.Inputs["Collection ID"].AsString(); String ruleName = request.Inputs["Rule Name"].AsString(); String wqlQuery = request.Inputs["WQL Query"].AsString(); String limitCollectionID = String.Empty; if (request.Inputs.Contains("Collection ID to Limit Query To")) { limitCollectionID = request.Inputs["Collection ID to Limit Query To"].AsString(); } //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password); using (connection) { CMInterop.addSCCMCollectionRule(connection, objID, ruleName, wqlQuery, limitCollectionID); IResultObject col = null; col = CMInterop.getSCCMCollection(connection, "CollectionID LIKE '" + objID + "'"); if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } response.Publish("Number of Collections", ObjCount); } }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String objID = request.Inputs["Advertisement ID"].AsString(); DateTime startTime = request.Inputs["Start Time"].AsDateTime(); int dayDuration = request.Inputs["Day Duration"].AsInt32(); int hourDuration = request.Inputs["Hour Duration"].AsInt32(); int minuteDuration = request.Inputs["Minute Duration"].AsInt32(); bool isGMT = request.Inputs["Is GMT"].AsBoolean(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password); using (connection) { CMInterop.modifySCCMAdvertisementAddAssignmentScheduleNonReccuring(connection, objID, isGMT, dayDuration, hourDuration, minuteDuration, startTime); IResultObject col = CMInterop.getSCCMAdvertisement(connection, "AdvertisementID LIKE '" + objID + "'"); if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } response.Publish("Number of Advertisements", ObjCount); } }
/// <summary> /// This event is fired for each item received from the above query. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void worker_QueryProcessorObjectReady(object sender, QueryProcessorObjectEventArgs e) { foreach (IResultObject queryResult in (IResultObject)e.ResultObject) { IResultObject SMS_CollectionDependencies = queryResult.GenericsArray[1]; IResultObject SMS_Collection = queryResult.GenericsArray[0]; string DependantCollectionID = ""; string DependantCollectionName = ""; string SourceCollectionID = ""; foreach (IResultObject Resource1 in SMS_CollectionDependencies) { Console.WriteLine(Resource1["DependentCollectionID"].StringValue); DependantCollectionID = Resource1["DependentCollectionID"].StringValue; SourceCollectionID = Resource1["SourceCollectionID"].StringValue; } foreach (IResultObject Resource1 in SMS_Collection) { DependantCollectionName = Resource1["Name"].StringValue; } TreeNode[] tn = treeView1.Nodes.Find(SourceCollectionID, true); tn[0].Nodes.Add(DependantCollectionID, DependantCollectionName + " (" + DependantCollectionID + ")"); treeView1.Nodes[0].ExpandAll(); GetNestedCollection(DependantCollectionID); } e.ResultObject.Dispose(); }
public void RemoveCMApplicationCategory(string appName, string categoryName) { SmsProvider smsProvider = new SmsProvider(); WqlConnectionManager connectionManager = smsProvider.Connect(SiteServer); ObservableCollection <CMApplicationCategory> applicationCategories = GetCMApplicationCategories(false); string appQuery = string.Format("SELECT * FROM SMS_ApplicationLatest WHERE (IsHidden = 0) AND (LocalizedDisplayName = '{0}')", appName); IResultObject appQueryResult = connectionManager.QueryProcessor.ExecuteQuery(appQuery); if (appQueryResult != null) { foreach (IResultObject app in appQueryResult) { ArrayList appCategories = new ArrayList(app["CategoryInstance_UniqueIDs"].StringArrayValue); CMApplicationCategory applicationCategory = applicationCategories.Where(c => c.LocalizedCategoryInstanceName == categoryName).First(); if (appCategories.Contains(applicationCategory.CategoryInstance_UniqueID)) { appCategories.Remove(applicationCategory.CategoryInstance_UniqueID); app["CategoryInstance_UniqueIDs"].StringArrayValue = (string[])appCategories.ToArray(typeof(string)); app.Put(); } else { MessageBox.Show(appName + " doesn't contain " + categoryName); } } } }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String objID = request.Inputs["CI_ID"].AsString(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password); using (connection) { String[] propertyNameChoices = CMInterop.getSCCMObjectPropertyNames(connection, "SMS_AuthorizationList"); foreach (String propertyName in propertyNameChoices) { if ((request.Inputs.Contains(propertyName + " : Property Type")) && (request.Inputs.Contains(propertyName + " : Property Value"))) { CMInterop.modifySCCMAuthorizationList(connection, objID, request.Inputs[(propertyName + " : Property Type")].AsString(), propertyName, request.Inputs[(propertyName + " : Property Value")].AsString()); } } IResultObject col = null; col = CMInterop.getSCCMAuthorizationList(connection, "CI_ID LIKE '" + objID + "'"); if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } response.Publish("Number of Authorization Lists", ObjCount); } }
public NeoQueryData CollectData() { NeoQueryData querydata = new NeoQueryData(); List <object> propertylist = new List <object>(); try { // https://docs.microsoft.com/en-us/configmgr/develop/reference/osd/sms_tasksequenceappreferencesinfo-server-wmi-class string cmquery = "select * from SMS_TaskSequenceAppReferencesInfo"; List <object> retlist = new List <object>(); // Run query using (IResultObject results = Connector.Instance.Connection.QueryProcessor.ExecuteQuery(cmquery)) { // Enumerate through the collection of objects returned by the query. foreach (IResultObject resource in results) { string tsid = ResultObjectHandler.GetString(resource, "PackageID"); string appid = ResultObjectHandler.GetString(resource, "RefAppCI_ID"); propertylist.Add(new { tsid, appid }); } } } catch { } querydata.Properties = propertylist; return(querydata); }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String pkgID = request.Inputs["Existing Package ID"].AsString(); String prgName = request.Inputs["New Program Name"].AsString(); String prgComment = request.Inputs["New Program Comment"].AsString(); String prgCommandLine = request.Inputs["New Program Command Line"].AsString(); int prgMaxRunTime = (int)request.Inputs["New Program Max Runtime"].AsUInt32(); String prgWorkingDirectory = request.Inputs["New Program Working Directory"].AsString(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password); using (connection) { IResultObject col = CMInterop.createSCCMProgram(connection, pkgID, prgName, prgComment, prgCommandLine, prgMaxRunTime, prgWorkingDirectory); if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } response.Publish("Number of Programs", ObjCount); } }
/// <summary> /// /// </summary> /// <param name="Pkgresults"></param> /// <returns></returns> public static SMS_Package PackageFromIresultObject(IResultObject Pkgresults) { Pkgresults = CompleteIresultOject(Pkgresults); return(new SMS_Package() { PackageID = Pkgresults["PackageID"].StringValue, LastRefreshTime = Pkgresults["LastRefreshTime"].DateTimeValue, Name = Pkgresults["Name"].StringValue, MIFPublisher = Pkgresults["MIFPublisher"].StringValue, MIFVersion = Pkgresults["MIFVersion"].StringValue, NumOfPrograms = Pkgresults["NumOfPrograms"].IntegerValue, PackageSize = Pkgresults["PackageSize"].IntegerValue, PackageType = Pkgresults["PackageType"].IntegerValue, PkgFlags = Pkgresults["PkgFlags"].IntegerValue, PkgSourceFlag = Pkgresults["PkgSourceFlag"].IntegerValue, PkgSourcePath = Pkgresults["PkgSourcePath"].StringValue, PreferredAddressType = Pkgresults["PreferredAddressType"].StringValue, Priority = Pkgresults["Priority"].IntegerValue, RefreshPkgSourceFlag = Pkgresults["RefreshPkgSourceFlag"].BooleanValue, SecuredScopeNames = Pkgresults["SecuredScopeNames"].StringArrayValue, ShareName = Pkgresults["ShareName"].StringValue, ShareType = Pkgresults["ShareType"].IntegerValue, SourceDate = Pkgresults["SourceDate"].DateTimeValue, SourceSite = Pkgresults["SourceSite"].StringValue, SourceVersion = Pkgresults["SourceVersion"].IntegerValue, StoredPkgPath = Pkgresults["StoredPkgPath"].StringValue, StoredPkgVersion = Pkgresults["StoredPkgVersion"].IntegerValue }); }
/// <summary> /// /// </summary> /// <param name="Admin"></param> /// <returns></returns> public static SMS_Admin AdminFromIresultObject(IResultObject Admin) { Admin.Get(); Admin = CompleteIresultOject(Admin); return(new SMS_Admin() { AccountType = Admin["AccountType"].IntegerValue, AdminID = Admin["AdminID"].IntegerValue, AdminSid = Admin["AdminSid"].StringValue, Categories = Admin["Categories"].StringArrayValue, CategoryNames = Admin["CategoryNames"].StringArrayValue, CollectionNames = Admin["CollectionNames"].StringArrayValue, CreatedBy = Admin["CreatedBy"].StringValue, CreatedDate = Admin["CreatedDate"].DateTimeValue, DisplayName = Admin["DisplayName"].StringValue, DistinguishedName = Admin["DistinguishedName"].StringValue, IsCovered = Admin["IsCovered"].BooleanValue, IsDeleted = Admin["IsDeleted"].BooleanValue, IsGroup = Admin["IsGroup"].BooleanValue, LastModifiedBy = Admin["LastModifiedBy"].StringValue, LastModifiedDate = Admin["LastModifiedDate"].DateTimeValue, LogonName = Admin["LogonName"].StringValue, Permissions = APermissionFromIresultObject((ManagementBaseObject[])Admin["Permissions"].ObjectArrayValue), RoleNames = Admin["RoleNames"].StringArrayValue, Roles = Admin["Roles"].StringArrayValue, SKey = Admin["SKey"].StringValue, SourceSite = Admin["SourceSite"].StringValue, }); }
internal advertisement(IResultObject obj) { obj.Get(); this.actionInProgress = nullIntHandler(obj, "ActionInProgress"); this.advertFlags = nullIntHandler(obj, "AdvertFlags"); this.advertisementID = obj["AdvertisementID"].StringValue; this.advertisementName = obj["AdvertisementName"].StringValue; this.assignedSchedule = generateAssignedSchedule(obj); this.assignedScheduleEnabled = nullBoolHandler(obj, "AssignedScheduleEnabled"); this.assignedScheduleIsGMT = nullBoolHandler(obj, "AssignedScheduleIsGMT"); this.assignmentID = nullIntHandler(obj, "AssignmentID"); this.collectionID = obj["CollectionID"].StringValue; this.deviceFlags = nullIntHandler(obj, "DeviceFlags"); this.expirationTime = nullDateTimeHandler(obj, "ExpirationTime"); this.expirationTimeEnabled = obj["ExpirationTimeEnabled"].BooleanValue; this.expirationTimeIsGMT = obj["ExpirationTimeIsGMT"].BooleanValue; this.hierarchyPath = obj["HierarchyPath"].StringValue; this.includeSubCollection = obj["IncludeSubCollection"].BooleanValue; this.isvData = convertIntArray(obj["ISVData"].IntegerArrayValue); this.isvDataSize = nullIntHandler(obj, "ISVDataSize"); this.mandatoryCountdown = nullIntHandler(obj, "MandatoryCountdown"); this.packageID = obj["PackageID"].StringValue; this.presentTime = nullDateTimeHandler(obj, "PresentTime"); this.presentTimeEnabled = obj["PresentTimeEnabled"].BooleanValue; this.presentTimeIsGMT = obj["PresentTimeIsGMT"].BooleanValue; this.priority = nullIntHandler(obj, "Priority"); this.programName = obj["programName"].StringValue; this.remoteClientFlags = nullIntHandler(obj, "RemoteClientFlags"); this.sourceSite = obj["SourceSite"].StringValue; this.timeFlags = nullIntHandler(obj, "TimeFlags"); }
private IPromise<IResultObject> Submit(string query, OutputType preferred = OutputType.Any, int batchSize = 0, int concurrentCount = 0) { if (_currentQuery != null) { outputEditor.Text = ""; _currentQuery.Cancel(); _currentQuery = null; lblClock.Text = ""; progQuery.Visible = false; _clock.Enabled = false; btnSubmit.Text = "► Run"; lblProgress.Text = "Canceled"; return null; } if (_proxy.ConnData != null && _proxy.ConnData.Confirm) { if (Dialog.MessageDialog.Show("Do you want to run this query on " + _proxy.ConnData.ConnectionName + "?", "Confirm Execution" , "&Run Query", "&Cancel") != DialogResult.OK) { return null; } } try { var cmd = _proxy.NewCommand() .WithQuery(query) .WithAction(this.SoapAction) .WithStatementCount(batchSize) .WithConcurrentCount(concurrentCount); var queryParams = _proxy.GetHelper().GetParameterNames(query) .Select(p => GetCreateParameter(p)).ToList(); if (queryParams.Any() && this.SoapAction != ArasEditorProxy.UnitTestAction) { using (var dialog = new Dialog.ParameterDialog(queryParams)) { switch (dialog.ShowDialog(this)) { case System.Windows.Forms.DialogResult.OK: foreach (var param in queryParams) { cmd.WithParam(param.Name, param.GetValue()); } break; case System.Windows.Forms.DialogResult.Ignore: break; default: return null; } } } outputEditor.Text = "Processing..."; lblProgress.Text = "Processing..."; _start = DateTime.UtcNow; lblClock.Text = ""; progQuery.Visible = true; _clock.Enabled = true; _outputTextSet = false; btnSubmit.Text = "Cancel"; // Only reset if we are getting a new result if (preferred != OutputType.None) { _result = null; _outputSet = null; CleanupGrids(); } if (_proxy.ConnData != null) { SnippetManager.Instance.SetLastQueryByConnection(_proxy.ConnData.ConnectionName, new Snippet() { Action = this.SoapAction, Text = inputEditor.Text }); Properties.Settings.Default.LastConnection = _proxy.ConnData.ConnectionName; Properties.Settings.Default.Save(); Properties.Settings.Default.Reload(); } var st = Stopwatch.StartNew(); _currentQuery = _proxy .Process(cmd, true, (p, m) => this.UiThreadInvoke(() => { lblProgress.Text = m; progQuery.Value = p; })) .UiPromise(this) .Done(result => { try { var milliseconds = st.ElapsedMilliseconds; _clock.Enabled = false; SetResult(result, milliseconds, preferred); } catch (Exception ex) { Utils.HandleError(ex); } }).Fail(ex => { outputEditor.Text = ex.Message; tbcOutputView.SelectedTab = pgTextOutput; lblProgress.Text = "Error"; }) .Always(() => { lblClock.Text = ""; _clock.Enabled = false; _currentQuery = null; progQuery.Visible = false; btnSubmit.Text = "► Run"; }); // Handle the synchronous option if (!_clock.Enabled) _currentQuery = null; } catch (Exception err) { outputEditor.Text = err.Message; tbcOutputView.SelectedTab = pgTextOutput; _clock.Enabled = false; progQuery.Visible = false; lblClock.Text = ""; lblProgress.Text = "Error"; _currentQuery = null; btnSubmit.Text = "► Run"; } return _currentQuery; }
private void SetResult(IResultObject result, long milliseconds, OutputType preferred = OutputType.Any) { var mode = this.PreferredMode; if (mode == OutputType.Any) mode = preferred; if (mode == OutputType.Any) mode = result.PreferredMode; tbcOutputView.TabsVisible = this.PreferredMode == OutputType.Any; if (result.ItemCount > 0) { lblProgress.Text = string.Format("{0} item(s) found in {1} ms.", result.ItemCount, milliseconds); } else { lblProgress.Text = string.Format("No items found in {0} ms.", milliseconds); } if (mode != OutputType.None) { _outputTextSet = false; dgvItems.DataSource = null; _outputSet = null; _result = result; if (mode == OutputType.Table && result.ItemCount > 0) { tbcOutputView.SelectedTab = pgTableOutput; EnsureDataTable(); } else if (mode == OutputType.Html) { browser.Navigate(GetReportUri().ToString()); tbcOutputView.SelectedTab = pgHtml; } else { tbcOutputView.SelectedTab = pgTextOutput; EnsureTextResult(); } } inputEditor.Editor.Focus(); this.Text = string.IsNullOrEmpty(result.Title) ? "Innovator Admin" : result.Title + " [Innovator Admin]"; }
private IPromise<IResultObject> Submit(string query, OutputType preferred = OutputType.Any) { if (_currentQuery != null) { _currentQuery.Cancel(); _clock.Enabled = false; lblProgress.Text = "Canceled"; _currentQuery = null; outputEditor.Text = ""; _clock.Enabled = false; btnSubmit.Text = "► Run"; return null; } if (_proxy.ConnData != null && _proxy.ConnData.Confirm) { if (MessageBox.Show("Do you want to run this query on " + _proxy.ConnData.ConnectionName +"?", "Confirm Execution", MessageBoxButtons.YesNo) == DialogResult.No) { return null; } } try { outputEditor.Text = "Processing..."; lblProgress.Text = "Processing..."; _start = DateTime.UtcNow; _clock.Enabled = true; _outputTextSet = false; btnSubmit.Text = "Cancel"; var cmd = _proxy.NewCommand().WithQuery(query).WithAction(this.SoapAction); var queryParams = _proxy.GetHelper().GetParameterNames(query) .Select(p => GetCreateParameter(p)).ToList(); if (queryParams.Any() && this.SoapAction != ArasEditorProxy.UnitTestAction) { using (var dialog = new ParameterWindow(queryParams)) { switch (dialog.ShowDialog(this)) { case System.Windows.Forms.DialogResult.OK: foreach (var param in queryParams) { cmd.WithParam(param.Name, param.GetValue()); } break; case System.Windows.Forms.DialogResult.Ignore: break; default: return null; } } } // Only reset if we are getting a new result if (preferred != OutputType.None) { _result = null; _outputSet = null; var pagesToRemove = tbcOutputView.TabPages.OfType<TabPage>() .Where(p => p.Name.StartsWith(GeneratedPage)).ToArray(); foreach (var page in pagesToRemove) { tbcOutputView.TabPages.Remove(page); } pgTableOutput.Text = "Table"; dgvItems.DataSource = null; } if (_proxy.ConnData != null) { SnippetManager.Instance.SetLastQueryByConnection(_proxy.ConnData.ConnectionName, new Snippet() { Action = this.SoapAction, Text = inputEditor.Text }); Properties.Settings.Default.LastConnection = _proxy.ConnData.ConnectionName; Properties.Settings.Default.Save(); Properties.Settings.Default.Reload(); } var st = Stopwatch.StartNew(); _currentQuery = _proxy.Process(cmd, true) .UiPromise(this) .Done(result => { try { var milliseconds = st.ElapsedMilliseconds; _clock.Enabled = false; SetResult(result, milliseconds, preferred); } catch (Exception ex) { Utils.HandleError(ex); } }).Fail(ex => { outputEditor.Text = ex.Message; tbcOutputView.SelectedTab = pgTextOutput; lblProgress.Text = "Error"; }) .Always(() => { _clock.Enabled = false; _currentQuery = null; btnSubmit.Text = "► Run"; }); } catch (Exception err) { outputEditor.Text = err.Message; tbcOutputView.SelectedTab = pgTextOutput; _clock.Enabled = false; lblProgress.Text = "Error"; _currentQuery = null; btnSubmit.Text = "► Run"; } return _currentQuery; }