private Dictionary <string, string> ProcessingDelete(UniqueIdentifier id, ObserverObjectSetting objectSetting) { Dictionary <string, string> filesDeleted = new Dictionary <string, string>(); WriteDebug("Retrieve delete " + id.Value); var obj = observedObjects.Where(o => o.ObjectID == id).FirstOrDefault(); if (obj == null) { WriteVerbose("Target is not observed. Delete Request will be skipped."); return(filesDeleted); } ObjectSetting converterSetting = GetObjectSetting(obj, RMConverterSetting); foreach (string s in Converter.GetSerializedFiles( obj, converterSetting, RMObserverSetting.ExportDirectory, objectSetting.AttributeSeparations)) { if (File.Exists(s)) { File.Delete(s); filesDeleted.Add(s, "Deleted"); } } observedObjects.Remove(obj); return(filesDeleted); }
private Dictionary <string, string> ProcessingPut(ResourceObject obj, ObserverObjectSetting objectSetting) { WriteDebug("Retrieve put " + obj.ObjectID.Value); Dictionary <string, string> filesDeleted = ProcessingDelete(obj.ObjectID, objectSetting); Dictionary <string, string> filesCreated = ProcessingCreate(obj, objectSetting); Dictionary <string, string> filesModified = new Dictionary <string, string>(); foreach (var file in filesCreated.Keys) { var item = filesDeleted.FirstOrDefault(kvp => kvp.Key == file); if (item.Value == null) { filesModified.Add(file, "Added"); } else { filesModified.Add(file, "Updated"); filesDeleted.Remove(item.Key); } } foreach (var file in filesDeleted.Keys) { filesModified.Add(file, "Deleted"); } return(filesModified); }
private bool IsFiltered(ResourceObject obj, ObserverObjectSetting objectSetting) { if (objectSetting.XPathExpression == "/" + obj.ObjectTypeName) { return(false); } else { var xpath = AddObjectIDToXPath(obj, objectSetting.XPathExpression); var o = RmcWrapper.Client.GetResources(xpath, 1); return(o == null); } }
private Dictionary <string, string> ProcessingCreate(ResourceObject obj, ObserverObjectSetting observerObjectSetting) { WriteDebug("Retrieve create " + obj.ObjectID.Value); if (IsFiltered(obj, observerObjectSetting)) { WriteVerbose(String.Format("Create Request of Target type {0} with ID {1} is filtered by ObserverObjectSetting.", obj.ObjectTypeName, obj.ObjectID.Value)); return(new Dictionary <string, string>()); } ObjectSetting converterSetting = GetObjectSetting(obj, RMConverterSetting); ConfigFile configFile = Converter.ConvertToRMConfig(obj, RMConverterSetting); List <string> filesExported = Converter.SerializeConfigFile( configFile, observerObjectSetting.AttributeSeparations, Converter.GetFilePath(obj, converterSetting, RMObserverSetting.ExportDirectory) ); observedObjects.Add(obj); return(filesExported.ToDictionary(k => k, v => "Added")); }
private Dictionary <string, string> ProcessingPut(ResourceObject resourceObject) { ObserverObjectSetting observerObjectSetting = RMObserverSetting.ObserverObjectSettings.Where(c => c.ObjectType == resourceObject.ObjectTypeName).FirstOrDefault(); return(ProcessingPut(resourceObject, observerObjectSetting)); }
private Dictionary <string, string> ProcessingPut(UniqueIdentifier id, ObserverObjectSetting observerObjectSetting) { ResourceObject obj = RmcWrapper.Client.GetResource(id); return(ProcessingPut(obj, observerObjectSetting)); }
private Dictionary <string, string> ProcessingCreate(ResourceObject obj) { ObserverObjectSetting observerObjectSetting = RMObserverSetting.ObserverObjectSettings.Where(c => c.ObjectType == obj.ObjectTypeName).FirstOrDefault(); return(ProcessingCreate(obj, observerObjectSetting)); }