private NSArray GetManagedUpdates(string condition = null) { var managedUpdates = new List <Models.MunkiManifestManagedUpdate>(); foreach (var templateId in _templateIds) { if (!string.IsNullOrEmpty(condition)) { managedUpdates.AddRange( BLL.MunkiManagedUpdate.GetAllManagedUpdatesForMt(templateId) .Where(x => x.Condition == condition)); } else { managedUpdates.AddRange(BLL.MunkiManagedUpdate.GetAllManagedUpdatesForMt(templateId) .Where(x => string.IsNullOrEmpty(x.Condition))); } } var orderedManagedUpdates = managedUpdates.GroupBy(x => x.Name).Select(g => g.First()).OrderBy(x => x.Name); NSArray plManagedUpdates = new NSArray(orderedManagedUpdates.Count()); var counter = 0; foreach (var managedUninstall in orderedManagedUpdates) { plManagedUpdates.SetValue(counter, managedUninstall.Name); counter++; } return(plManagedUpdates); }
private NSArray GetIncludedManifests(string condition = null) { var includedManifests = new List <Models.MunkiManifestIncludedManifest>(); foreach (var templateId in _templateIds) { if (!string.IsNullOrEmpty(condition)) { includedManifests.AddRange(BLL.MunkiIncludedManifest.GetAllIncludedManifestsForMt(templateId) .Where(x => x.Condition == condition)); } else { includedManifests.AddRange(BLL.MunkiIncludedManifest.GetAllIncludedManifestsForMt(templateId) .Where(x => string.IsNullOrEmpty(x.Condition))); } } var orderedManifests = includedManifests.GroupBy(x => x.Name).Select(s => s.First()).OrderBy(x => x.Name); NSArray plIncludedManifests = new NSArray(orderedManifests.Count()); var counter = 0; foreach (var includedManifest in orderedManifests) { plIncludedManifests.SetValue(counter, includedManifest.Name); counter++; } return(plIncludedManifests); }
private NSArray GetOptionlInstalls(string condition = null) { var optionalInstalls = new List <MunkiManifestOptionInstallEntity>(); foreach (var templateId in _templateIds) { if (!string.IsNullOrEmpty(condition)) { optionalInstalls.AddRange( _munkiManifestTemplateServices.GetAllOptionalInstallsForMt(templateId) .Where(x => x.Condition == condition)); } else { optionalInstalls.AddRange(_munkiManifestTemplateServices.GetAllOptionalInstallsForMt(templateId) .Where(x => string.IsNullOrEmpty(x.Condition))); } } var orderedOptionalInstalls = optionalInstalls.GroupBy(x => x.Name) .Select(g => g.OrderByDescending(x => x.Version).First()) .OrderBy(x => x.Name); var plOptionalInstalls = new NSArray(orderedOptionalInstalls.Count()); var counter = 0; foreach (var optionalInstall in orderedOptionalInstalls) { if (optionalInstall.IncludeVersion == 1) { plOptionalInstalls.SetValue(counter, optionalInstall.Name + "-" + optionalInstall.Version); } else { plOptionalInstalls.SetValue(counter, optionalInstall.Name); } counter++; } return(plOptionalInstalls); }
private NSArray GetConditionals() { var uniqueConditions = GetAllUniqueConditions(); NSArray conditionalItems = new NSArray(uniqueConditions.Count); var uniqueConditionsCounter = 0; foreach (var uniqueCondition in uniqueConditions) { NSDictionary condition = new NSDictionary(); condition.Add("condition", uniqueCondition); conditionalItems.SetValue(uniqueConditionsCounter, condition); uniqueConditionsCounter++; NSArray plIncludedManifests = GetIncludedManifests(uniqueCondition); NSArray plManagedInstalls = GetManagedInstalls(uniqueCondition); NSArray plManagedUninstalls = GetManagedUninstalls(uniqueCondition); NSArray plManagedUpdates = GetManagedUpdates(uniqueCondition); NSArray plOptionalInstalls = GetOptionlInstalls(uniqueCondition); if (plIncludedManifests.Count > 0) { condition.Add("included_manifests", plIncludedManifests); } if (plManagedInstalls.Count > 0) { condition.Add("managed_installs", plManagedInstalls); } if (plManagedUninstalls.Count > 0) { condition.Add("managed_uninstalls", plManagedUninstalls); } if (plManagedUpdates.Count > 0) { condition.Add("managed_updates", plManagedUpdates); } if (plOptionalInstalls.Count > 0) { condition.Add("optional_installs", plOptionalInstalls); } } return(conditionalItems); }
private NSArray GetCatalogs() { var catalogs = new List <Models.MunkiManifestCatalog>(); foreach (var templateId in _templateIds) { catalogs.AddRange(BLL.MunkiCatalog.GetAllCatalogsForMt(templateId)); } var orderedCatalogs = catalogs.Distinct().OrderBy(x => x.Priority).ThenBy(x => x.Name).ToList(); orderedCatalogs = orderedCatalogs.GroupBy(x => x.Name).Select(s => s.First()).ToList(); NSArray plCatalogs = new NSArray(orderedCatalogs.Count); var counter = 0; foreach (var catalog in orderedCatalogs) { plCatalogs.SetValue(counter, catalog.Name); counter++; } return(plCatalogs); }
public static void AddBundleURLType(IIgorModule ModuleInst, string PlistPath, string NewURLScheme) { if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!")) { FileInfo PlistFileInfo = new FileInfo(PlistPath); NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo); if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!")) { if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary.")) { NSDictionary RootDictionary = (NSDictionary)PlistRoot; if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary.")) { NSSet BundleURLTypes = null; if (RootDictionary.ContainsKey("CFBundleURLTypes")) { NSObject BundleURLTypesObj = RootDictionary.Get("CFBundleURLTypes"); if (IgorAssert.EnsureTrue(ModuleInst, BundleURLTypesObj != null, "CFBundleURLTypes wasn't found in the root dictionary even though the key exists.")) { if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(BundleURLTypesObj.GetType()), "CFBundleURLTypes isn't an NSArray.")) { BundleURLTypes = new NSSet(((NSArray)BundleURLTypesObj).GetArray()); } } } if (BundleURLTypes == null) { BundleURLTypes = new NSSet(); } bool bAlreadyExists = false; foreach (NSObject CurrentURLType in BundleURLTypes) { if (bAlreadyExists) { break; } if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(CurrentURLType.GetType()), "One of the CFBundleURLTypes isn't an NSDictionary.")) { NSDictionary CurrentURLTypeDict = (NSDictionary)CurrentURLType; if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLTypeDict != null, "One of the CFBundleURLTypes didn't cast to NSDictionary correctly.")) { if (CurrentURLTypeDict.ContainsKey("CFBundleURLSchemes")) { NSObject CurrentURLSchemesArrayObj = CurrentURLTypeDict.Get("CFBundleURLSchemes"); if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(CurrentURLSchemesArrayObj.GetType()), "A CFBundleURLSchemes key exists for a given CFBundleURLType, but it's not an NSArray type.")) { NSArray CurrentURLSchemesArray = (NSArray)CurrentURLSchemesArrayObj; if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLSchemesArray != null, "The CFBundleURLSchemes object didn't cast to NSDictionary correctly.")) { NSSet CurrentURLSchemesSet = new NSSet(CurrentURLSchemesArray.GetArray()); foreach (NSObject CurrentURLSchemeObj in CurrentURLSchemesSet) { if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSString).IsAssignableFrom(CurrentURLSchemeObj.GetType()), "One of the CFBundleURLSchemes is not an NSString.")) { NSString CurrentURLScheme = (NSString)CurrentURLSchemeObj; if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLScheme != null, "A CFBundleURLScheme entry didn't cast to NSString correctly.")) { if (CurrentURLScheme.GetContent() == NewURLScheme) { bAlreadyExists = true; IgorDebug.Log(ModuleInst, "URL scheme " + NewURLScheme + " is already in " + PlistPath); break; } } } } } } } } } } if (!bAlreadyExists) { NSString NewSchemeString = new NSString(NewURLScheme); NSArray NewSchemeArray = new NSArray(1); NewSchemeArray.SetValue(0, NewSchemeString); NSDictionary NewTypeDictionary = new NSDictionary(); NewTypeDictionary.Add("CFBundleURLSchemes", NewSchemeArray); BundleURLTypes.AddObject(NewTypeDictionary); NSArray BundleURLTypesArray = new NSArray(BundleURLTypes.AllObjects()); if (RootDictionary.ContainsKey("CFBundleURLTypes")) { RootDictionary["CFBundleURLTypes"] = BundleURLTypesArray; IgorDebug.Log(ModuleInst, "Updated CFBundleURLTypes to add " + NewURLScheme + "."); } else { RootDictionary.Add("CFBundleURLTypes", BundleURLTypesArray); IgorDebug.Log(ModuleInst, "Added CFBundleURLTypes to add " + NewURLScheme + "."); } IgorRuntimeUtils.DeleteFile(PlistPath); PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo); } } } } } }