public static void ExecuteMethod_StoreCompleteObject(IContainerOwner owner, IInformationObject createdObject) { createdObject.StoreInformationMasterFirst(owner, false); }
public static void ExecuteMethod_StoreInitialObject(IContainerOwner owner, IInformationObject createdObject) { createdObject.StoreInformationMasterFirst(owner, true); }
public static void ExecuteMethod_StoreCompleteObject(IInformationObject rootObject) { rootObject.StoreInformationMasterFirst(InformationContext.CurrentOwner, false); }
private void HandleOwnerPostRequest(IContainerOwner containerOwner, HttpContext context, string contentPath) { InformationContext.Current.Owner = containerOwner; HttpRequest request = context.Request; var form = request.Unvalidated().Form; bool isAjaxDataRequest = request.ContentType.StartsWith("application/json"); // form.Get("AjaxObjectInfo") != null; if (isAjaxDataRequest) { // Various data deserialization tests - options need to be properly set // strong type radically faster 151ms over 25sec with flexible type - something ill throw new NotSupportedException("Not supported as-is, implementation for serialization available, not finished"); var stream = request.GetBufferedInputStream(); var dataX = JSONSupport.GetObjectFromStream <NodeSummaryContainer>(stream); var streamReader = new StreamReader(request.GetBufferedInputStream()); string data = streamReader.ReadToEnd(); var jsonData = JSONSupport.GetJsonFromStream(data); HandlerOwnerAjaxDataPOST(containerOwner, form); return; } bool isClientTemplateRequest = form.Get("ContentSourceInfo") != null || form.Get("ExecuteOperation") != null; if (isClientTemplateRequest) { HandleOwnerClientTemplatePOST(containerOwner, request); return; } string sourceNamesCommaSeparated = form["RootSourceName"]; bool isCancelButton = form["btnCancel"] != null; if (isCancelButton) { return; } string actionName = form["RootSourceAction"]; string objectFieldID = form["ObjectFieldID"]; CloudBlob webPageBlob = StorageSupport.CurrActiveContainer.GetBlob(contentPath, containerOwner); InformationSourceCollection sources = webPageBlob.GetBlobInformationSources(); if (sources == null) { throw new InvalidDataException("Postback to page with no information sources defined - where there should be"); } if (sourceNamesCommaSeparated == null) { sourceNamesCommaSeparated = ""; } sourceNamesCommaSeparated += ","; string[] sourceNames = sourceNamesCommaSeparated.Split(',').Distinct().ToArray(); if (objectFieldID != null && actionName.StartsWith("cmd") == false && actionName != "Save" && actionName.Contains(",") == false) { var result = PerformWebAction.Execute(new PerformWebActionParameters { CommandName = actionName, FormSourceNames = sourceNames, FormSubmitContent = form, InformationSources = sources, Owner = containerOwner, TargetObjectID = objectFieldID }); if (result.RenderPageAfterOperation) { RenderWebSupport.RefreshPHTMLContent(webPageBlob); } return; } string inContextEditFieldID = form["InContextEditFieldID"]; if (inContextEditFieldID != null) { string objectFieldValue = form["Text_Short"]; if (objectFieldValue == null) { objectFieldValue = form["Text_Long"]; } form = new NameValueCollection(); form.Set(inContextEditFieldID, objectFieldValue); } InformationSource[] sourceArray = sources.CollectionContent.Where( src => src.IsDynamic || (src.IsInformationObjectSource && sourceNames.Contains(src.SourceName))).ToArray(); foreach (InformationSource source in sourceArray) { string oldETag = source.SourceETag; IInformationObject rootObject = source.RetrieveInformationObject(); /* Temporarily removed all the version checks - last save wins! * if (oldETag != rootObject.ETag) * { * RenderWebSupport.RefreshPHTMLContent(webPageBlob); * throw new InvalidDataException("Information under editing was modified during display and save"); * } * */ // TODO: Proprely validate against only the object under the editing was changed (or its tree below) rootObject.SetValuesToObjects(form); IAddOperationProvider addOperationProvider = rootObject as IAddOperationProvider; bool skipNormalStoreAfterAdd = false; if (addOperationProvider != null) { skipNormalStoreAfterAdd = addOperationProvider.PerformAddOperation(actionName, sources, contentPath, request.Files); } if (skipNormalStoreAfterAdd == false) { // If not add operation, set media content to stored object foreach (string contentID in request.Files.AllKeys) { HttpPostedFile postedFile = request.Files[contentID]; if (String.IsNullOrWhiteSpace(postedFile.FileName)) { continue; } rootObject.SetMediaContent(containerOwner, contentID, postedFile); } rootObject.StoreInformationMasterFirst(containerOwner, false); } } RenderWebSupport.RefreshPHTMLContent(webPageBlob); // Temporary live to pub sync below, to be removed //SyncTemplatesToSite(StorageSupport.CurrActiveContainer.Name, // String.Format("grp/f8e1d8c6-0000-467e-b487-74be4ad099cd/{0}/", "livesite"), // StorageSupport.CurrAnonPublicContainer.Name, // String.Format("grp/default/{0}/", "livepubsite"), true); }
public static void ExecuteMethod_StoreInitialObject(IInformationObject createdObject) { createdObject.StoreInformationMasterFirst(InformationContext.CurrentOwner, true); }
private void HandleOwnerPostRequest(IContainerOwner containerOwner, HttpContext context, string contentPath) { HttpRequest request = context.Request; var form = request.Unvalidated().Form; string sourceNamesCommaSeparated = form["RootSourceName"]; bool isCancelButton = form["btnCancel"] != null; if (isCancelButton) { return; } string actionName = form["RootSourceAction"]; string objectFieldID = form["ObjectFieldID"]; string objectFieldValue = form["Text_Short"]; if (objectFieldValue == null) { objectFieldValue = form["Text_Long"]; } CloudBlob webPageBlob = StorageSupport.CurrActiveContainer.GetBlob(contentPath, containerOwner); InformationSourceCollection sources = webPageBlob.GetBlobInformationSources(); if (sources == null) { throw new InvalidDataException("Postback to page with no information sources defined - where there should be"); } if (sourceNamesCommaSeparated == null) { sourceNamesCommaSeparated = ""; } sourceNamesCommaSeparated += ","; string[] sourceNames = sourceNamesCommaSeparated.Split(',').Distinct().ToArray(); return; if (objectFieldID != null) { var result = PerformWebAction.Execute(new PerformWebActionParameters { CommandName = actionName, FormSourceNames = sourceNames, InformationSources = sources, Owner = containerOwner, TargetObjectID = objectFieldID }); if (result.RenderPageAfterOperation) { RenderWebSupport.RefreshPHTMLContent(webPageBlob); } return; } InformationSource[] sourceArray = sources.CollectionContent.Where( src => src.IsDynamic || (src.IsInformationObjectSource && sourceNames.Contains(src.SourceName))).ToArray(); foreach (InformationSource source in sourceArray) { string oldETag = source.SourceETag; IInformationObject rootObject = source.RetrieveInformationObject(); if (oldETag != rootObject.ETag) { RenderWebSupport.RefreshPHTMLContent(webPageBlob); throw new InvalidDataException("Information under editing was modified during display and save"); } rootObject.SetValuesToObjects(form); IAddOperationProvider addOperationProvider = rootObject as IAddOperationProvider; bool skipNormalStoreAfterAdd = false; if (addOperationProvider != null) { skipNormalStoreAfterAdd = addOperationProvider.PerformAddOperation(actionName, sources, contentPath, request.Files); } if (skipNormalStoreAfterAdd == false) { // If not add operation, set media content to stored object foreach (string contentID in request.Files.AllKeys) { HttpPostedFile postedFile = request.Files[contentID]; if (String.IsNullOrWhiteSpace(postedFile.FileName)) { continue; } rootObject.SetMediaContent(containerOwner, contentID, postedFile); } rootObject.StoreInformationMasterFirst(containerOwner, false); } } RenderWebSupport.RefreshPHTMLContent(webPageBlob); // Temporary live to pub sync below, to be removed //SyncTemplatesToSite(StorageSupport.CurrActiveContainer.Name, // String.Format("grp/f8e1d8c6-0000-467e-b487-74be4ad099cd/{0}/", "livesite"), // StorageSupport.CurrAnonPublicContainer.Name, // String.Format("grp/default/{0}/", "livepubsite"), true); }
public static void ExecuteOwnerWebPOST(IContainerOwner containerOwner, NameValueCollection form, HttpFileCollection fileContent) { bool isCancelButton = form["btnCancel"] != null; if (isCancelButton) { return; } string operationName = form["ExecuteOperation"]; if (operationName != null) { executeOperationWithFormValues(containerOwner, operationName, form, fileContent); return; } string contentSourceInfo = form["ContentSourceInfo"]; string[] contentSourceInfos = contentSourceInfo.Split(','); NameValueCollection fileEntries = new NameValueCollection(); NameValueCollection fieldEntries = new NameValueCollection(); NameValueCollection objectEntries = new NameValueCollection(); foreach (var key in form.AllKeys) { var value = form[key]; if (key.StartsWith("File_")) { fileEntries.Add(key, value); } else if (key.StartsWith("Object_")) { objectEntries.Add(key, value); } else { fieldEntries.Add(key, value); } } foreach (var key in fileContent.AllKeys) { if (key.StartsWith("File_") && fileEntries.AllKeys.Contains(key) == false) { fileEntries.Add(key, ""); } } foreach (string sourceInfo in contentSourceInfos) { string relativeLocation; string oldETag; retrieveDataSourceInfo(sourceInfo, out relativeLocation, out oldETag); VirtualOwner verifyOwner = VirtualOwner.FigureOwner(relativeLocation); if (verifyOwner.IsSameOwner(containerOwner) == false) { throw new SecurityException("Mismatch in ownership of data submission"); } IInformationObject rootObject = StorageSupport.RetrieveInformation(relativeLocation, oldETag, containerOwner); if (oldETag != rootObject.ETag) { throw new InvalidDataException("Information under editing was modified during display and save"); } // TODO: Proprely validate against only the object under the editing was changed (or its tree below) SetFieldValues(rootObject, fieldEntries); SetBinaryContent(rootObject, fileEntries, fileContent, containerOwner); SetObjectLinks(rootObject, objectEntries); /* Operation bridge model below - not used/needed with field assignment solution */ /* * var removeMediaList = form["cmdRemoveMedia"]; * if (String.IsNullOrWhiteSpace(removeMediaList) == false) * { * string[] removeList = removeMediaList.Split(','); * foreach (string contentInfo in removeList) * { * SetBinaryContent(containerOwner, contentInfo, rootObject, null); * } * } * */ rootObject.StoreInformationMasterFirst(containerOwner, false); } }