public static InformationSource GetAsDefaultSource(IInformationObject informationObject) { CloudBlob blob = StorageSupport.GetInformationObjectBlobWithProperties(informationObject); InformationSource informationSource = FromBlob(blob); return(informationSource); }
private static string GetSpanTag(object content, string spanTagFormatForIDandETag) { return(""); IInformationObject informationObject = content as IInformationObject; string currID; string currEtag; if (informationObject != null) { currID = informationObject.ID; if (informationObject.ETag != null) { currEtag = informationObject.ETag.Substring(1, informationObject.ETag.Length - 2); } else { currEtag = ""; } } else { currID = ""; currEtag = ""; } return(String.Format(spanTagFormatForIDandETag, currID, currEtag)); }
private static int GetTotalSubscriberCount(IInformationObject informationObject, ref int CurrMaxSubs, ref int CurrMaxDistinct, Dictionary <string, SubcriptionGraphItem> lookupDictionary) { string location = informationObject.RelativeLocation; //SubscribeSupport.GetSubscriptionDictionary(location, populatedDictionary); List <Subscription> result = new List <Subscription>(); Stack <string> subscriberStack = new Stack <string>(); SubscribeSupport.GetSubcriptionList(location, result, subscriberStack, lookupDictionary); int count = result.Count; int distinctCount = result.Select(sub => sub.SubscriberRelativeLocation).Distinct().Count(); if (result.Count >= CurrMaxSubs || distinctCount >= CurrMaxDistinct) { if (count > CurrMaxSubs) { CurrMaxSubs = count; } if (distinctCount > CurrMaxDistinct) { CurrMaxDistinct = distinctCount; } Console.WriteLine(count + " / " + distinctCount + " : " + location); } return(count); }
public static void ExecuteMethod_DeleteObject(IInformationObject objectToDelete) { if (objectToDelete != null) { objectToDelete.DeleteInformationObject(); } }
public static void SetMediaContent(this IInformationObject rootObject, IContainerOwner containerOwner, string containerID, string containedField, object mediaContent) { List <IInformationObject> containerList = new List <IInformationObject>(); rootObject.FindObjectsFromTree(containerList, iObj => iObj.ID == containerID, false); foreach (var iObj in containerList) { var type = iObj.GetType(); var prop = type.GetProperty(containedField); if (prop == null) { throw new InvalidDataException(String.Format("No property {0} found in type {1}", containedField, type.Name)); } MediaContent propValue = (MediaContent)prop.GetValue(iObj, null); if (propValue == null && mediaContent == null) { continue; } if (propValue != null && mediaContent == null) { propValue.ClearCurrentContent(containerOwner); prop.SetValue(iObj, null, null); continue; } if (propValue == null && mediaContent != null) { propValue = MediaContent.CreateDefault(); prop.SetValue(iObj, propValue, null); } propValue.SetMediaContent(containerOwner, propValue.ID, mediaContent); } }
public ReferenceOutdatedException(IInformationObject containerObject, IInformationObject referenceInstance, IInformationObject masterInstance) { // TODO: Complete member initialization this.containerObject = containerObject; this.referenceInstance = referenceInstance; this.masterInstance = masterInstance; }
public static void InitializeChainAndReturnPropertyOwningObject(IInformationObject createdObject, string objectProp, out object actualContainingObject, out string fieldPropertyName) { actualContainingObject = null; fieldPropertyName = null; if (objectProp.Contains("___") == false) return; string[] objectChain = objectProp.Split(new[] { "___" }, StringSplitOptions.None); fieldPropertyName = objectChain[objectChain.Length - 1]; Stack<string> objectChainStack = new Stack<string>(objectChain.Reverse().Skip(1)); actualContainingObject = createdObject; while (objectChainStack.Count > 0) { Type currType = actualContainingObject.GetType(); string currObjectProp = objectChainStack.Pop(); PropertyInfo prop = currType.GetProperty(currObjectProp); if (prop == null) throw new InvalidDataException("Property not found by name: " + currObjectProp); var currPropValue = prop.GetValue(actualContainingObject, null); if (currPropValue == null) { var currPropType = prop.PropertyType; currPropValue = Activator.CreateInstance(currPropType); prop.SetValue(actualContainingObject, currPropValue, null); } actualContainingObject = currPropValue; } }
private static TextContent getOrCreateInformationObjectsTextContent(Process process, IInformationObject sourceObject) { var processItems = process.ProcessItems; var matchingProcessItem = processItems.FirstOrDefault(processItem => processItem.Inputs.Any(sourceObject.IsObjectsSemanticItem)); TextContent result = null; if (matchingProcessItem != null) { var matchingOutput = matchingProcessItem.Outputs.FirstOrDefault(semanticItem => semanticItem.ItemFullType == typeof (TextContent).FullName); if (matchingOutput != null) { var textContentLocation = matchingOutput.ItemValue; result = TextContent.RetrieveTextContent(textContentLocation, Owner); } if (result == null) { processItems.Remove(matchingProcessItem); matchingProcessItem = null; } } if(matchingProcessItem == null) { matchingProcessItem = new ProcessItem(); matchingProcessItem.Inputs.Add(new SemanticInformationItem(sourceObject)); TextContent textContent = new TextContent(); textContent.SetLocationAsOwnerContent(Owner, textContent.ID); textContent.GeneratedByProcessID = process.ID; matchingProcessItem.Outputs.Add(new SemanticInformationItem(textContent)); processItems.Add(matchingProcessItem); result = textContent; } return result; }
public static void ExecuteMethod_DeleteObjects(IInformationObject[] processingResultsToDelete) { if (processingResultsToDelete == null) return; foreach(var iObj in processingResultsToDelete) iObj.DeleteInformationObject(); }
public static void ExecuteMethod_StoreObjects(IInformationObject[] processingResultsToStore) { if (processingResultsToStore == null) return; foreach (var iObj in processingResultsToStore) iObj.StoreInformation(); }
public static void UpdateContainerFromMaster(string containerLocation, string containerType, string masterLocation, string masterType) { bool masterEtagUpdated = false; //do //{ masterEtagUpdated = false; IInformationObject container = StorageSupport.RetrieveInformation(containerLocation, containerType); IInformationObject referenceToMaster = StorageSupport.RetrieveInformation(masterLocation, masterType); string masterEtag = referenceToMaster.ETag; string masterID = referenceToMaster.ID; Dictionary <string, List <IInformationObject> > result = new Dictionary <string, List <IInformationObject> >(); container.CollectMasterObjectsFromTree(result, candidate => candidate.ID == masterID); bool foundOutdatedMaster = result.Values.SelectMany(item => item).Count(candidate => candidate.MasterETag != masterEtag) > 0; if (foundOutdatedMaster) { referenceToMaster.MasterETag = referenceToMaster.ETag; container.ReplaceObjectInTree(referenceToMaster); container.StoreInformation(); referenceToMaster = StorageSupport.RetrieveInformation(masterLocation, masterType); masterEtagUpdated = referenceToMaster.ETag != masterEtag; } //} while (masterEtagUpdated); }
private static InformationSource GetMissingRootAsNewSource(ContentItem root, string masterLocation, out bool foundExistingSource) { InformationSource source = root.Source ?? InformationSource.CreateDefault(); IInformationObject informationObject = (IInformationObject)root.RootObject; if (informationObject == null) { foundExistingSource = false; return(null); } string sourceContentLocation = informationObject.GetLocationRelativeToContentRoot(masterLocation, root.RootName); CloudBlob blob; IInformationObject existingObject = StorageSupport.RetrieveInformationWithBlob(sourceContentLocation, root.RootType, out blob); if (existingObject == null) { informationObject.SetLocationRelativeToContentRoot(masterLocation, root.RootName); blob = StorageSupport.StoreInformation(informationObject); foundExistingSource = false; } else { informationObject = existingObject; root.RootObject = existingObject; foundExistingSource = true; } source.SetBlobValuesToSource(blob); source.SetInformationObjectValuesToSource(root.RootName, informationObject.GetType().FullName); source.IsDynamic = root.IsDynamicRoot; return(source); }
private static string GetDefaultDynamicRenderingViewURL(IInformationObject informationObject) { string viewName = informationObject.GetType().FullName + "_DefaultView.phtml"; string viewItemLocation = informationObject.RelativeLocation; string viewItemURL = RenderWebSupport.GetUrlFromRelativeLocation(viewItemLocation); return(viewName + "?viewItem=" + HttpUtility.UrlEncode(viewItemURL)); }
public static void ExecuteMethod_CreateInternalObjects(IInformationObject rootObject, NameValueCollection httpFormData) { var internalObjectProperties = httpFormData.AllKeys.Where(key => key.Contains("___")).ToArray(); foreach (var objectProp in internalObjectProperties) { initializeChainObjects(rootObject, objectProp); } }
public static void Execute(DeleteSpecifiedInformationObjectParameters parameters) { PrepareParameters(parameters); DeleteSpecifiedInformationObjectImplementation.ExecuteMethod_CatchInvalidDomains(parameters.ObjectDomainName); IInformationObject ObjectToDelete = DeleteSpecifiedInformationObjectImplementation.GetTarget_ObjectToDelete(parameters.Owner, parameters.ObjectDomainName, parameters.ObjectName, parameters.ObjectID); DeleteSpecifiedInformationObjectImplementation.ExecuteMethod_DeleteObject(ObjectToDelete); }
public static IInformationObject GetTarget_ObjectToDelete(IContainerOwner owner, string objectDomainName, string objectName, string objectId) { IInformationObject objectToDelete = StorageSupport.RetrieveInformationObjectFromDefaultLocation(objectDomainName, objectName, objectId, owner); return(objectToDelete); }
public static SetObjectTreeValuesParameters SetObjectValues_GetParameters(NameValueCollection httpFormData, HttpFileCollection httpFileData, IInformationObject createdObject) { return new SetObjectTreeValuesParameters { RootObject = createdObject, HttpFormData = httpFormData, HttpFileData = httpFileData }; }
public static void ExecuteMethod_SetBinaryContent(IInformationObject rootObject, Dictionary<string, MediaFileData> binaryContentFiles) { foreach (var fileKey in binaryContentFiles.Keys) { string contentInfo = fileKey.Substring(5); // Substring("File_".Length); ModifyInformationSupport.SetBinaryContent(InformationContext.CurrentOwner, contentInfo, rootObject, binaryContentFiles[fileKey]); } }
public static void ExecuteMethod_SetBinaryContent(IContainerOwner owner, IInformationObject createdObject, Dictionary <string, HttpPostedFile> binaryContentFiles) { foreach (var fileKey in binaryContentFiles.Keys) { string contentInfo = fileKey.Substring(5); // Substring("File_".Length); ModifyInformationSupport.SetBinaryContent(owner, contentInfo, createdObject, binaryContentFiles[fileKey]); } }
public static IInformationObject GetTarget_CreatedObject(IContainerOwner owner, string objectDomainName, string objectName) { string objectTypeName = objectDomainName + "." + objectName; Type objectType = Type.GetType(objectTypeName); IInformationObject iObj = (IInformationObject)Activator.CreateInstance(objectType); var relativeLocation = StorageSupport.GetBlobOwnerAddress(owner, objectDomainName + "/" + objectName + "/" + iObj.ID); iObj.RelativeLocation = relativeLocation; return(iObj); }
private static void UpdateCollectionFromDirectory(string collectionType, string collectionLocation, string directoryLocation) { IInformationObject collectionObject = StorageSupport.RetrieveInformation(collectionLocation, collectionType); if (collectionObject is IInformationCollection) { IInformationCollection collection = (IInformationCollection)collectionObject; collection.RefreshContent(); StorageSupport.StoreInformation(collectionObject); } }
/// <summary> /// Creates default views and returns the one relative to the requester /// </summary> /// <param name="requesterLocation">Requester relative location</param> /// <param name="informationObject">Information object to create the view for</param> /// <param name="owner">Container owner</param> /// <returns></returns> public static CloudBlob CreateDefaultViewRelativeToRequester(string requesterLocation, IInformationObject informationObject, IContainerOwner owner) { bool isAccountOwner = owner.IsAccountContainer(); bool isGroupOwner = owner.IsGroupContainer(); bool isDeveloperView = owner.ContainerName == "dev"; string[] viewLocations; if (isAccountOwner) viewLocations = FixedAccountSiteLocations; else if (isGroupOwner) viewLocations = FixedGroupSiteLocations; else throw new NotSupportedException("Invalid owner container type for default view (non acct, non group): " + owner.ContainerName); string requesterDirectory = StorageSupport.GetLocationParentDirectory(requesterLocation); FileInfo fileInfo = new FileInfo(requesterLocation); //string viewRoot = fileInfo.Directory.Parent != null // ? fileInfo.Directory.Parent.Name // : fileInfo.Directory.Name; CloudBlob relativeViewBlob = null; bool hasException = false; bool allException = true; foreach (string viewLocation in viewLocations) { try { string viewRoot = isDeveloperView ? "developer-00000000000000000000000000" : GetViewRoot(viewLocation); string viewItemDirectory = Path.Combine(viewRoot, viewLocation).Replace("\\", "/") + "/"; string viewName = GetDefaultStaticViewName(informationObject); string viewTemplateName = GetDefaultStaticTemplateName(informationObject); // TODO: Relative from xyzsite => xyztemplate; now we only have website - also acct/grp specific //string viewTemplateLocation = "webtemplate/oip-viewtemplate/" + viewTemplateName; string viewTemplateLocation = viewItemDirectory + viewTemplateName; CloudBlob viewTemplate = StorageSupport.CurrActiveContainer.GetBlob(viewTemplateLocation, owner); string renderedViewLocation = viewItemDirectory + viewName; CloudBlob renderTarget = StorageSupport.CurrActiveContainer.GetBlob(renderedViewLocation, owner); InformationSource defaultSource = InformationSource.GetAsDefaultSource(informationObject); RenderWebSupport.RenderTemplateWithContentToBlob(viewTemplate, renderTarget, defaultSource); if (viewItemDirectory == requesterDirectory) relativeViewBlob = renderTarget; allException = false; } catch (Exception ex) { hasException = true; } } if (relativeViewBlob == null && hasException == false && false) throw new InvalidDataException( String.Format("Default view with relative location {0} not found for owner type {1}", requesterLocation, owner.ContainerName)); return relativeViewBlob; }
public IInformationObject RetrieveInformationObject() { if (String.IsNullOrEmpty(SourceInformationObjectType)) { return(null); } CloudBlob blob; IInformationObject content = StorageSupport.RetrieveInformationWithBlob(SourceLocation, SourceInformationObjectType, out blob); SourceETag = content.ETag; SourceMD5 = blob.Properties.ContentMD5; SourceLastModified = blob.Properties.LastModifiedUtc; return(content); }
private static void UpdateCollectionFromMasterCollection(string referenceCollectionType, string referenceCollectionLocation, string masterCollectionType, string masterCollectionLocation) { IInformationObject referenceCollectionObject = StorageSupport.RetrieveInformation(referenceCollectionLocation, referenceCollectionType); IInformationCollection referenceCollection = (IInformationCollection)referenceCollectionObject; // TODO: Revisit why this can be null if (referenceCollection == null) { return; } referenceCollection.RefreshContent(); StorageSupport.StoreInformation(referenceCollectionObject); }
public static void Execute(CreateSpecifiedInformationObjectWithValuesParameters parameters) { PrepareParameters(parameters); CreateSpecifiedInformationObjectWithValuesImplementation.ExecuteMethod_CatchInvalidDomains(parameters.ObjectDomainName); IInformationObject CreatedObject = CreateSpecifiedInformationObjectWithValuesImplementation.GetTarget_CreatedObject(parameters.Owner, parameters.ObjectDomainName, parameters.ObjectName); NameValueCollection FieldValues = CreateSpecifiedInformationObjectWithValuesImplementation.GetTarget_FieldValues(parameters.HttpFormData, CreatedObject); NameValueCollection ObjectLinkValues = CreateSpecifiedInformationObjectWithValuesImplementation.GetTarget_ObjectLinkValues(parameters.HttpFormData, CreatedObject); Dictionary <string, System.Web.HttpPostedFile> BinaryContentFiles = CreateSpecifiedInformationObjectWithValuesImplementation.GetTarget_BinaryContentFiles(parameters.HttpFormData, parameters.HttpFileData, CreatedObject); CreateSpecifiedInformationObjectWithValuesImplementation.ExecuteMethod_SetFieldValues(CreatedObject, FieldValues); CreateSpecifiedInformationObjectWithValuesImplementation.ExecuteMethod_SetObjectLinks(CreatedObject, ObjectLinkValues); CreateSpecifiedInformationObjectWithValuesImplementation.ExecuteMethod_StoreInitialObject(parameters.Owner, CreatedObject); CreateSpecifiedInformationObjectWithValuesImplementation.ExecuteMethod_SetBinaryContent(parameters.Owner, CreatedObject, BinaryContentFiles); CreateSpecifiedInformationObjectWithValuesImplementation.ExecuteMethod_StoreCompleteObject(parameters.Owner, CreatedObject); }
public static void SetBinaryContent(IInformationObject rootObject, NameValueCollection fileEntries, HttpFileCollection fileContent, IContainerOwner containerOwner) { foreach (string fileKey in fileEntries.AllKeys) { HttpPostedFile postedFile = null; if (fileContent.AllKeys.Contains(fileKey)) { postedFile = fileContent[fileKey]; } //if (String.IsNullOrWhiteSpace(postedFile.FileName)) // continue; string contentInfo = fileKey.Substring(5); // Substring("File_".Length); SetBinaryContent(containerOwner, contentInfo, rootObject, postedFile); } }
private static void UpdateContainerFromMasterCollection(string containerType, string containerLocation, string masterCollectionType, string masterCollectionLocation) { IInformationObject containerObject = StorageSupport.RetrieveInformation(containerLocation, containerType); IInformationObject masterCollectionObject = StorageSupport.RetrieveInformation(masterCollectionLocation, masterCollectionType); IInformationCollection masterCollection = (IInformationCollection)masterCollectionObject; // TODO: Revisit why this can be null if (containerObject == null || masterCollection == null) { return; } containerObject.UpdateCollections(masterCollection); StorageSupport.StoreInformation(containerObject); }
public static void SetObjectLinks(IInformationObject rootObject, NameValueCollection objectEntries) { foreach (var objectKey in objectEntries.AllKeys) { string objectInfo = objectKey.Substring(7); // Substring("Object_".Length); int firstIX = objectInfo.IndexOf('_'); if (firstIX < 0) { throw new InvalidDataException("Invalid field data on binary content"); } string containerID = objectInfo.Substring(0, firstIX); string containerField = objectInfo.Substring(firstIX + 1); string objectIDCommaSeparated = objectEntries[objectKey] ?? ""; string[] objectIDList = objectIDCommaSeparated.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); rootObject.SetObjectContent(containerID, containerField, objectIDList); } }
public static void ExecuteMethod_AddEncodedFormDataToBinaryFiles(IInformationObject rootObject, NameValueCollection httpFormData, Dictionary<string, MediaFileData> binaryContentFiles) { const string base64CommaValue = "base64,"; const int base64Length = 7; // base64CommaValue.Length; string objectID = rootObject.ID; foreach (var key in httpFormData.AllKeys) { if (key.StartsWith("FileEmbedded_")) { string dictKey = prefixWithIDIfMissing(key, "FileEmbedded_", objectID); dictKey = dictKey.Replace("FileEmbedded_", "File_"); string formValue = httpFormData[key]; MediaFileData mediaFileData = null; if (String.IsNullOrEmpty(formValue) == false) { int fileNameEndIX = formValue.IndexOf(':'); string fileName = formValue.Substring(0, fileNameEndIX); fileName = Path.GetFileName(fileName); int base64CommaIX = formValue.IndexOf(base64CommaValue, System.StringComparison.Ordinal); var base64Data = formValue.Substring(base64CommaIX + base64Length); // Strip off remaining comma separated datas in case the field value has those var existingDataCommaIX = base64Data.IndexOf(','); if (existingDataCommaIX > 0) base64Data = base64Data.Substring(0, existingDataCommaIX); byte[] realData = Convert.FromBase64String(base64Data); mediaFileData = new MediaFileData { FileName = fileName, FileContent = realData }; } binaryContentFiles.Add(dictKey, mediaFileData); } } }
public static Dictionary <string, HttpPostedFile> GetTarget_BinaryContentFiles(NameValueCollection httpFormData, HttpFileCollection httpFileData, IInformationObject createdObject) { Dictionary <string, HttpPostedFile> resultDict = new Dictionary <string, HttpPostedFile>(httpFileData.Count); string objectID = createdObject.ID; foreach (var key in httpFormData.AllKeys) { var value = httpFormData[key]; if (key.StartsWith("File_")) { HttpPostedFile httpFile = null; if (httpFileData.AllKeys.Contains(key)) { httpFile = httpFileData[key]; } string dictKey = key.Replace("File_", "File_" + objectID + "_"); resultDict.Add(dictKey, httpFile); } } foreach (var key in httpFileData.AllKeys) { if (key.StartsWith("File_")) { string dictKey = key.Replace("File_", "File_" + objectID + "_"); if (resultDict.ContainsKey(dictKey) == false) { resultDict.Add(dictKey, httpFileData[key]); } } } return(resultDict); }
void IInformationObject.ReplaceObjectInTree(IInformationObject replacingObject) { for(int i = 0; i < CollectionContent.Count; i++) // > { if(CollectionContent[i].ID == replacingObject.ID) CollectionContent[i] = (NetworkUsage )replacingObject; else { // Cannot have circular reference, so can be in else branch IInformationObject iObject = CollectionContent[i]; iObject.ReplaceObjectInTree(replacingObject); } } }
public static void ExecuteMethod_StoreCompleteObject(IContainerOwner owner, IInformationObject createdObject) { createdObject.StoreInformationMasterFirst(owner, false); }
public static NameValueCollection GetTarget_FieldValues(NameValueCollection httpFormData, IInformationObject createdObject) { NameValueCollection fieldEntries = new NameValueCollection(); string objectID = createdObject.ID; foreach (var key in httpFormData.AllKeys) { var value = httpFormData[key]; if (key.StartsWith("File_") == false && key.StartsWith("Object_") == false) { fieldEntries.Add(objectID + "_" + key, value); } } return(fieldEntries); }
public static VirtualOwner FigureOwner(IInformationObject ownedObject) { string relativeLocation = ownedObject.RelativeLocation; return(FigureOwner(relativeLocation)); }
public static InformationSource GetAsDefaultSource(IInformationObject informationObject) { CloudBlob blob = StorageSupport.GetInformationObjectBlobWithProperties(informationObject); InformationSource informationSource = FromBlob(blob); return informationSource; }
public static Dictionary<string, MediaFileData> GetTarget_BinaryContentFiles(IInformationObject rootObject, NameValueCollection httpFormData, HttpFileCollection httpFileData) { if (httpFileData == null) return new Dictionary<string, MediaFileData>(); Dictionary<string, MediaFileData> resultDict = new Dictionary<string, MediaFileData>(httpFileData.Count); string objectID = rootObject.ID; foreach (var key in httpFormData.AllKeys) { if (key.StartsWith("File_")) { HttpPostedFile httpFile = null; if (httpFileData.AllKeys.Contains(key)) httpFile = httpFileData[key]; string dictKey = prefixWithIDIfMissing(key, "File_", objectID); resultDict.Add(dictKey, httpFile != null ? new MediaFileData { HttpFile = httpFile} : null); } } foreach (var key in httpFileData.AllKeys) { if (key.StartsWith("File_")) { string dictKey = prefixWithIDIfMissing(key, "File_", objectID); if (resultDict.ContainsKey(dictKey) == false) { var httpFile = httpFileData[key]; resultDict.Add(dictKey, httpFile != null ? new MediaFileData { HttpFile = httpFile } : null); } } } return resultDict; }
void IInformationObject.ReplaceObjectInTree(IInformationObject replacingObject) { if(InvoiceRowGroupCollection != null) { if(InvoiceRowGroupCollection.ID == replacingObject.ID) InvoiceRowGroupCollection = (InvoiceRowGroupCollection) replacingObject; else { IInformationObject iObject = InvoiceRowGroupCollection; iObject.ReplaceObjectInTree(replacingObject); } } if(InvoiceEventDetailGroupCollection != null) { if(InvoiceEventDetailGroupCollection.ID == replacingObject.ID) InvoiceEventDetailGroupCollection = (InvoiceEventDetailGroupCollection) replacingObject; else { IInformationObject iObject = InvoiceEventDetailGroupCollection; iObject.ReplaceObjectInTree(replacingObject); } } }
public static void ExecuteMethod_SetObjectLinks(IInformationObject rootObject, NameValueCollection objectLinkValues) { ModifyInformationSupport.SetObjectLinks(rootObject, objectLinkValues); }
public static void ExecuteMethod_StoreCompleteObject(IInformationObject rootObject) { rootObject.StoreInformationMasterFirst(InformationContext.CurrentOwner, false); }
public static void ExecuteMethod_SetFieldValues(IInformationObject rootObject, NameValueCollection fieldValues) { ModifyInformationSupport.SetFieldValues(rootObject, fieldValues); }
public static CreateSpecifiedInformationObjectWithValuesReturnValue Get_ReturnValue(IInformationObject createdObject) { return new CreateSpecifiedInformationObjectWithValuesReturnValue {CreatedObjectResult = createdObject}; }
public static NameValueCollection GetTarget_FieldValues(IInformationObject rootObject, NameValueCollection httpFormData) { NameValueCollection fieldEntries = new NameValueCollection(); string objectID = rootObject.ID; foreach (var key in httpFormData.AllKeys) { if (String.IsNullOrEmpty(key)) continue; var value = httpFormData[key]; if (key.StartsWith("File_") == false && key.StartsWith("Object_") == false && key.StartsWith("FileEmbedded_") == false) { if (key.Contains("___")) { object actualContainingObject; string fieldPropertyName; ModifyInformationSupport.InitializeChainAndReturnPropertyOwningObject(rootObject, key, out actualContainingObject, out fieldPropertyName); IInformationObject containingObject = actualContainingObject as IInformationObject; if (containingObject == null) throw new NotSupportedException("Object property setting at creation only supported for IInformationObject types"); fieldEntries.Add(containingObject.ID + "_" + fieldPropertyName, value); } else { string fixedKey = prefixWithIDIfMissing(key, "", objectID); fieldEntries.Add(fixedKey, value); } } } return fieldEntries; }
public static CloudBlob GetInformationObjectBlobWithProperties(IInformationObject informationObject) { CloudBlob blob = CurrActiveContainer.GetBlob(informationObject.RelativeLocation); blob.FetchAttributes(); return blob; }
public static void SetCollectionSubscriptionToMaster(IInformationObject containerObject, string masterCollectionLocation, Type collectionType) { AddSubscriptionToObject(masterCollectionLocation, containerObject.RelativeLocation, SubscribeType_MasterCollectionToContainerUpdate, collectionType.FullName, containerObject.GetType().FullName); }
void IInformationObject.ReplaceObjectInTree(IInformationObject replacingObject) { if(TimeRange != null) { if(TimeRange.ID == replacingObject.ID) TimeRange = (TimeRange) replacingObject; else { IInformationObject iObject = TimeRange; iObject.ReplaceObjectInTree(replacingObject); } } }
public static void ExecuteMethod_StoreInitialObject(IInformationObject createdObject) { createdObject.StoreInformationMasterFirst(InformationContext.CurrentOwner, true); }
void IInformationObject.ReplaceObjectInTree(IInformationObject replacingObject) { if(OpenInvoices != null) { if(OpenInvoices.ID == replacingObject.ID) OpenInvoices = (InvoiceCollection) replacingObject; else { IInformationObject iObject = OpenInvoices; iObject.ReplaceObjectInTree(replacingObject); } } if(PredictedInvoices != null) { if(PredictedInvoices.ID == replacingObject.ID) PredictedInvoices = (InvoiceCollection) replacingObject; else { IInformationObject iObject = PredictedInvoices; iObject.ReplaceObjectInTree(replacingObject); } } if(PaidInvoicesActiveYear != null) { if(PaidInvoicesActiveYear.ID == replacingObject.ID) PaidInvoicesActiveYear = (InvoiceCollection) replacingObject; else { IInformationObject iObject = PaidInvoicesActiveYear; iObject.ReplaceObjectInTree(replacingObject); } } if(PaidInvoicesLast12Months != null) { if(PaidInvoicesLast12Months.ID == replacingObject.ID) PaidInvoicesLast12Months = (InvoiceCollection) replacingObject; else { IInformationObject iObject = PaidInvoicesLast12Months; iObject.ReplaceObjectInTree(replacingObject); } } }
public static TBRAccountRoot GetOwningAccountRoot(IInformationObject informationObject) { string accountID = StorageSupport.GetAccountIDFromLocation(informationObject.RelativeLocation); return TBRAccountRoot.RetrieveFromDefaultLocation(accountID); }
public static TBRAccountRoot GetOwningAccountRoot(IInformationObject informationObject) { string accountID = StorageSupport.GetAccountIDFromLocation(informationObject.RelativeLocation); return(TBRAccountRoot.RetrieveFromDefaultLocation(accountID)); }
void IInformationObject.UpdateMasterValueTreeFromOtherInstance(IInformationObject sourceMaster) { if (sourceMaster == null) throw new ArgumentNullException("sourceMaster"); if (GetType() != sourceMaster.GetType()) throw new InvalidDataException("Type mismatch in UpdateMasterValueTree"); IInformationObject iObject = this; if(iObject.IsIndependentMaster == false) throw new InvalidDataException("UpdateMasterValueTree called on non-master type"); if(ID != sourceMaster.ID) throw new InvalidDataException("UpdateMasterValueTree is supported only on masters with same ID"); CopyContentFrom((NetworkUsageCollection) sourceMaster); }
void IInformationObject.ReplaceObjectInTree(IInformationObject replacingObject) { if(ReferenceToInformation != null) { if(ReferenceToInformation.ID == replacingObject.ID) ReferenceToInformation = (ReferenceToInformation) replacingObject; else { IInformationObject iObject = ReferenceToInformation; iObject.ReplaceObjectInTree(replacingObject); } } }
public static void SetObjectContent(this IInformationObject rootObject, string containerID, string containedField, string[] objectIDList) { List <IInformationObject> containerList = new List <IInformationObject>(); rootObject.FindObjectsFromTree(containerList, iObj => iObj.ID == containerID, false); foreach (var iObj in containerList) { var type = iObj.GetType(); var prop = type.GetProperty(containedField); if (prop == null) { throw new InvalidDataException(String.Format("No property {0} found in type {1}", containedField, type.Name)); } IInformationObject containedObject = (IInformationObject)prop.GetValue(iObj, null); if (containedObject == null && objectIDList.Length == 0) { continue; } if (objectIDList.Length == 0) { prop.SetValue(iObj, null, null); } else { VirtualOwner owner = VirtualOwner.FigureOwner(rootObject.RelativeLocation); Type contentType = prop.PropertyType; string contentDomain = contentType.Namespace; string contentTypeName = contentType.Name; bool isCollectionType = typeof(IInformationCollection).IsAssignableFrom(contentType); if (isCollectionType) { if (containedObject == null) { containedObject = (IInformationObject)Activator.CreateInstance(contentType); prop.SetValue(iObj, containedObject, null); } dynamic dynObj = containedObject; object listObject = dynObj.CollectionContent; // Note the below works for List<T>, that we know the type is of ;-) Type collectionItemType = listObject.GetType().GetGenericArguments()[0]; // This is assuming collections are referring within same domain only contentTypeName = collectionItemType.Name; IList contentList = (IList)listObject; IEnumerable <IInformationObject> contentEnum = (IEnumerable <IInformationObject>)listObject; List <IInformationObject> objectsToRemove = new List <IInformationObject>(); foreach (IInformationObject existingObject in contentList) { if (objectIDList.Contains(existingObject.ID) == false) { objectsToRemove.Add(existingObject); } } objectsToRemove.ForEach(obj => contentList.Remove(obj)); foreach (string contentObjectID in objectIDList) { if (contentEnum.Any(item => item.ID == contentObjectID)) { continue; } IInformationObject contentObject = StorageSupport.RetrieveInformationObjectFromDefaultLocation(contentDomain, contentTypeName, contentObjectID, owner); if (contentObject == null) { continue; } contentList.Add(contentObject); } } else { if (objectIDList.Length > 1) { throw new InvalidDataException("Object link name " + containedField + " of type " + contentTypeName + " does not allow multiple values"); } string contentObjectID = objectIDList[0]; IInformationObject contentObject = StorageSupport.RetrieveInformationObjectFromDefaultLocation(contentDomain, contentTypeName, contentObjectID, owner); prop.SetValue(iObj, contentObject, null); } //RetrieveInformationObjectFromDefaultLocation() } } }
void IInformationObject.ReplaceObjectInTree(IInformationObject replacingObject) { if(ExportedInvoices != null) { if(ExportedInvoices.ID == replacingObject.ID) ExportedInvoices = (InvoiceCollection) replacingObject; else { IInformationObject iObject = ExportedInvoices; iObject.ReplaceObjectInTree(replacingObject); } } }
public static void FixOwnerLocation(IInformationObject informationObject, IContainerOwner owner) { string ownerLocation = GetBlobOwnerAddress(owner, informationObject.RelativeLocation); informationObject.RelativeLocation = ownerLocation; }
public static NameValueCollection GetTarget_ObjectLinkValues(NameValueCollection httpFormData, IInformationObject createdObject) { NameValueCollection objectEntries = new NameValueCollection(); string objectID = createdObject.ID; foreach (var key in httpFormData.AllKeys) { var value = httpFormData[key]; if (key.StartsWith("Object_")) { objectEntries.Add(key.Replace("Object_", "Object_" + objectID + "_"), value); } } return(objectEntries); }
public static void ExecuteMethod_SetObjectLinks(IInformationObject createdObject, NameValueCollection objectLinkValues) { ModifyInformationSupport.SetObjectLinks(createdObject, objectLinkValues); }
public static void ExecuteMethod_SetFieldValues(IInformationObject createdObject, NameValueCollection fieldValues) { ModifyInformationSupport.SetFieldValues(createdObject, fieldValues); }
public static NameValueCollection GetTarget_ObjectLinkValues(IInformationObject rootObject, NameValueCollection httpFormData) { NameValueCollection objectEntries = new NameValueCollection(); if (httpFormData == null) return objectEntries; string objectID = rootObject.ID; foreach (var key in httpFormData.AllKeys) { if (key.StartsWith("Object_")) { var value = httpFormData[key]; string newKey = prefixWithIDIfMissing(key, "Object_", objectID); objectEntries.Add(newKey, value); } } return objectEntries; }
public static void ExecuteMethod_StoreInitialObject(IContainerOwner owner, IInformationObject createdObject) { createdObject.StoreInformationMasterFirst(owner, true); }
private static void initializeChainObjects(IInformationObject createdObject, string objectProp) { object actualContainingObject; string fieldPropertyName; ModifyInformationSupport.InitializeChainAndReturnPropertyOwningObject(createdObject, objectProp, out actualContainingObject, out fieldPropertyName); }