public static void ExecuteMethod_InitializeGroupContentAndMasters(TBRGroupRoot groupRoot)
        {
            var grp = groupRoot.Group;

            RenderWebSupport.RefreshGroupTemplates(grp.ID, false);
            OwnerInitializer.InitializeAndConnectMastersAndCollections(grp);
        }
        public static void ExecuteMethod_PublishGroupContent(string groupID, bool useWorker, string currentContainerName, string publicContainerName)
        {
            string groupPublicSiteLocation            = "grp/" + groupID + "/" + RenderWebSupport.DefaultPublicGroupSiteLocation;
            string defaultPublicSiteLocation          = "grp/default/" + RenderWebSupport.DefaultPublicGroupSiteLocation;
            string aboutAuthTargetLocation            = RenderWebSupport.DefaultAboutTargetLocation;
            List <OperationRequest> operationRequests = new List <OperationRequest>();
            var publishPublicContent = RenderWebSupport.SyncTemplatesToSite(currentContainerName, groupPublicSiteLocation, publicContainerName, groupPublicSiteLocation, useWorker, false);

            operationRequests.Add(publishPublicContent);
            string defaultGroupID = "undefinedForNow";

            if (groupID == defaultGroupID)
            {
                OperationRequest publishDefault = RenderWebSupport.SyncTemplatesToSite(currentContainerName, groupPublicSiteLocation, publicContainerName, defaultPublicSiteLocation, useWorker, false);
                operationRequests.Add(publishDefault);
                publishDefault = RenderWebSupport.SyncTemplatesToSite(currentContainerName, groupPublicSiteLocation, currentContainerName,
                                                                      aboutAuthTargetLocation, useWorker, false);
                operationRequests.Add(publishDefault);
            }
            if (useWorker)
            {
                //QueueSupport.PutToOperationQueue(localGroupTemplates, renderLocalTemplates);
                QueueSupport.PutToOperationQueue(operationRequests.ToArray());
            }
        }
Beispiel #3
0
        private static void ProcessDynamicRegisterRequest(HttpRequest request, HttpResponse response)
        {
            string    blobPath = GetBlobPath(request);
            CloudBlob blob     = StorageSupport.CurrActiveContainer.GetBlobReference(blobPath);

            response.Clear();
            try
            {
                string template  = blob.DownloadText();
                string returnUrl = request.Params["ReturnUrl"];
                TBRegisterContainer registerContainer = GetRegistrationInfo(returnUrl);
                string responseContent = RenderWebSupport.RenderTemplateWithContent(template, registerContainer);
                response.ContentType = blob.Properties.ContentType;
                response.Write(responseContent);
            }
            catch (StorageClientException scEx)
            {
                response.Write(scEx.ToString());
                response.StatusCode = (int)scEx.StatusCode;
            }
            finally
            {
                response.End();
            }
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        private static void SyncWwwPublicFromDefaultGroup()
        {
            string publicSite = "demowww.aaltoglobalimpact.org";

            string[] folderList = new[] { "bootstrap-default", "oip-additions", "www-public" };
            foreach (string folder in folderList)
            {
                string sourceFolder = folder;
                //if (sourceFolder == "www-public")
                //    sourceFolder = "oip-public";
                var operationRequest = RenderWebSupport.SyncTemplatesToSite(StorageSupport.CurrActiveContainer.Name, "grp/9798daca-afc4-4046-a99b-d0d88bb364e0/wwwsite/" + sourceFolder,
                                                                            publicSite.Replace('.', '-'), folder, true, false);
                QueueSupport.PutToOperationQueue(operationRequest);
            }
        }
Beispiel #6
0
        public static TBRLoginRoot GetOrCreateLoginRootWithAccount(string loginUrl, bool isAccountRequest)
        {
            string loginRootID = TBLoginInfo.GetLoginIDFromLoginURL(loginUrl);
            var    loginRoot   = RetrieveFromDefaultLocation(loginRootID);

            if (loginRoot == null)
            {
                // Storing loginroot
                loginRoot    = TBRLoginRoot.CreateDefault();
                loginRoot.ID = loginRootID;
                loginRoot.UpdateRelativeLocationFromID();
                StorageSupport.StoreInformation(loginRoot);

                // Creating login info for account and storing the account
                TBLoginInfo loginInfo = TBLoginInfo.CreateDefault();
                loginInfo.OpenIDUrl = loginUrl;

                TBRAccountRoot accountRoot = TBRAccountRoot.CreateAndStoreNewAccount();
                accountRoot.Account.Logins.CollectionContent.Add(loginInfo);
                string accountID = accountRoot.ID;
                accountRoot.StoreInformation();

                UpdateAccountRootToReferences.Execute(new UpdateAccountRootToReferencesParameters
                {
                    AccountID = accountID
                });
                UpdateAccountContainerFromAccountRoot.Execute(new UpdateAccountContainerFromAccountRootParameters
                {
                    AccountID = accountID
                });

                // If this request is for account, we propagate the pages immediately
                bool useBackgroundWorker = isAccountRequest == false;
                RenderWebSupport.RefreshAccountTemplates(accountRoot.ID, useBackgroundWorker);
                if (isAccountRequest)
                {
                    accountRoot.Account.InitializeAndConnectMastersAndCollections();
                }
            }
            loginRoot = RetrieveFromDefaultLocation(loginRootID);
            return(loginRoot);
        }
        private static string GetSizedLocation(string masterRelativeLocation, Size size, bool fittingAllIn, ImageFormat format)
        {
            string masterLocationWithoutExtension = RenderWebSupport.GetLocationWithoutExtension(masterRelativeLocation);
            string fileExtensionWithoutDot;

            if (format == ImageFormat.Jpeg)
            {
                fileExtensionWithoutDot = "jpg";
            }
            else if (format == ImageFormat.Png)
            {
                fileExtensionWithoutDot = "png";
            }
            else
            {
                throw new NotSupportedException("File format extension not defined for format: " + format.ToString());
            }
            string formatWithExtension = fittingAllIn
                                             ? String.Format("_{0}x{1}_whole.{2}", size.Width, size.Height, fileExtensionWithoutDot)
                                             : String.Format("_{0}x{1}_crop.{2}", size.Width, size.Height, fileExtensionWithoutDot);

            return(masterLocationWithoutExtension + formatWithExtension);
        }
        private static void ProcessDynamicRegisterRequest(HttpRequest request, HttpResponse response)
        {
            CloudBlobClient publicClient = new CloudBlobClient("http://theball.blob.core.windows.net/");
            string          blobPath     = GetBlobPath(request);
            CloudBlob       blob         = publicClient.GetBlobReference(blobPath);

            response.Clear();
            try
            {
                string template  = blob.DownloadText();
                string returnUrl = request.Params["ReturnUrl"];
                TBRegisterContainer registerContainer = GetRegistrationInfo(returnUrl, request.Url.DnsSafeHost);
                string responseContent = RenderWebSupport.RenderTemplateWithContent(template, registerContainer);
                response.ContentType = blob.Properties.ContentType;
                response.Write(responseContent);
            } catch (StorageClientException scEx)
            {
                response.Write(scEx.ToString());
                response.StatusCode = (int)scEx.StatusCode;
            } finally
            {
                response.End();
            }
        }
Beispiel #9
0
        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 string GetTarget_PublicContainerName(string groupID)
 {
     return(RenderWebSupport.GetCurrentAnonContainerName());
 }
Beispiel #11
0
 private static void TestDriveDynamicCreation()
 {
     object test = RenderWebSupport.GetOrInitiateContentObject(new List <RenderWebSupport.ContentItem>(),
                                                               "AaltoGlobalImpact.OIP.InformationSource",
                                                               "vilperi", false);
 }
        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);
        }
Beispiel #13
0
        /// <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);
        }
Beispiel #14
0
        private static void Main(string[] args)
        {
            try
            {
                //Console.WriteLine("Running test EKE...");
                //TheBallEKE.TestExecution();
                //Console.WriteLine("Running test EKE complete.");
                ////return;
                ////SecurityNegotiationManager.EchoClient().Wait();
                //SecurityNegotiationManager.EchoClient();
                //Console.ReadLine(); // Enter to exit
                //return;

                //return;
                if (args.Length != 4 || args[0].Length != 4)
                {
                    Console.WriteLine("Usage: WebTemplateManager.exe <-pub name/-pri name> grp<groupID>/acc<acctID> <connection string>");
                    return;
                }
                //Debugger.Launch();
                string pubPriPrefixWithDash = args[0];
                string templateName         = args[1];
                if (String.IsNullOrWhiteSpace(templateName))
                {
                    throw new ArgumentException("Template name must be given");
                }
                string connStr   = args[3];
                string grpacctID = args[2];
                if (pubPriPrefixWithDash != "-pub" && pubPriPrefixWithDash != "-pri")
                {
                    throw new ArgumentException("-pub or -pri misspelled or missing");
                }
                string       pubPriPrefix = pubPriPrefixWithDash.Substring(1);
                string       ownerPrefix  = grpacctID.Substring(0, 3);
                string       ownerID      = grpacctID.Substring(3);
                VirtualOwner owner        = VirtualOwner.FigureOwner(ownerPrefix + "/" + ownerID);

                //string connStr = String.Format("DefaultEndpointsProtocol=http;AccountName=theball;AccountKey={0}",
                //                               args[0]);
                //connStr = "UseDevelopmentStorage=true";
                bool debugMode = false;

                StorageSupport.InitializeWithConnectionString(connStr, debugMode);
                InformationContext.InitializeFunctionality(3, true);
                InformationContext.Current.InitializeCloudStorageAccess(
                    Properties.Settings.Default.CurrentActiveContainerName);

                string directory = Directory.GetCurrentDirectory();
                if (directory.EndsWith("\\") == false)
                {
                    directory = directory + "\\";
                }
                string[] allFiles =
                    Directory.GetFiles(directory, "*", SearchOption.AllDirectories)
                    .Select(str => str.Substring(directory.Length))
                    .ToArray();
                if (pubPriPrefix == "pub" && templateName == "legacy")
                {
                    FileSystemSupport.UploadTemplateContent(allFiles, owner,
                                                            RenderWebSupport.DefaultPublicWwwTemplateLocation, true,
                                                            Preprocessor, ContentFilterer, InformationTypeResolver);
                    RenderWebSupport.RenderWebTemplate(owner.LocationPrefix, true, "AaltoGlobalImpact.OIP.Blog",
                                                       "AaltoGlobalImpact.OIP.Activity");
                }
                else
                {
                    FileSystemSupport.UploadTemplateContent(allFiles, owner, templateName, true);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("EXCEPTION: " + exception.ToString());
            }
            Console.WriteLine("DONE");
        }
Beispiel #15
0
 public static string GetTarget_WwwContainerName(string groupID)
 {
     return(RenderWebSupport.GetCurrentWwwContainerName(groupID));
 }
        private void HandleOwnerGetRequest(IContainerOwner containerOwner, HttpContext context, string contentPath)
        {
            //CloudBlob blob = StorageSupport.GetOwnerBlobReference(containerOwner, contentPath);

            // Read blob content to response.
            context.Response.Clear();
            try
            {
                string contentType = StorageSupport.GetMimeType(Path.GetExtension(contentPath));
                context.Response.ContentType = contentType;
                string prefixStrippedContent = contentPath; //contentPath.Substring(AuthDeveloperPrefixLen + GuidIDLen + 1);
                string fileName = Path.Combine(DeveloperWebRootFolder, prefixStrippedContent);

                //blob.FetchAttributes();
                var matches = defaultViewRegex.Matches(contentPath);
                if (matches.Count > 0)
                {
                    var                match = matches[0];
                    string             informationObjectType = match.Groups["typename"].Value;
                    string             objectID   = match.Groups["id"].Value;
                    Type               objectType = typeof(IInformationObject).Assembly.GetType(informationObjectType);
                    MethodInfo         retrieveFromDefaultLocation = objectType.GetMethod("RetrieveFromDefaultLocation");
                    IInformationObject iObject      = (IInformationObject)retrieveFromDefaultLocation.Invoke(null, new object[] { objectID, containerOwner });
                    string             templateName = DefaultViewSupport.GetDefaultStaticTemplateName(iObject);
                    foreach (string groupTemplateDirectory in DefaultViewSupport.FixedGroupSiteLocations)
                    {
                        string filesystemDirectory = Path.Combine(DeveloperWebRootFolder, groupTemplateDirectory);
                        string templateFileName    = Path.Combine(filesystemDirectory, templateName);
                        string templateContent;
                        try
                        {
                            templateContent = GetTemplateContent(templateFileName);
                        }
                        catch
                        {
                            continue;
                        }
                        string blobDirectory = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(contentPath)),
                                                            groupTemplateDirectory);
                        string templateBlobPath = Path.Combine(blobDirectory, templateName).Replace("\\", "/");
                        var    templateBlob     = StorageSupport.UploadOwnerBlobText(containerOwner, templateBlobPath,
                                                                                     templateContent,
                                                                                     StorageSupport.
                                                                                     InformationType_WebTemplateValue);
                    }
                    var blob = DefaultViewSupport.CreateDefaultViewRelativeToRequester(contentPath, iObject, containerOwner);
                    blob.DownloadToStream(context.Response.OutputStream);
                }
                else
                {
                    string templateContent = GetTemplateContent(fileName);
                    if (templateContent != null)
                    {
                        string templateBlobPath = Path.Combine("template", contentPath).Replace("\\", "/");
                        var    templateBlob     = StorageSupport.UploadOwnerBlobText(containerOwner, templateBlobPath,
                                                                                     templateContent,
                                                                                     StorageSupport.
                                                                                     InformationType_WebTemplateValue);
                        var targetBlob = StorageSupport.GetOwnerBlobReference(containerOwner, contentPath);
                        RenderWebSupport.RenderTemplateWithContentToBlob(templateBlob, targetBlob);
                        targetBlob.DownloadToStream(context.Response.OutputStream);
                        //List<RenderWebSupport.ContentItem> contentRoots = new List<RenderWebSupport.ContentItem>();
                        //string rendered = RenderWebSupport.RenderTemplateWithContentRoots(fixedContent, contentRoots); //RenderWebSupport.Ren
                        //context.Response.Output.Write(rendered);
                    }
                    else
                    {
                        if (File.Exists(fileName))
                        {
                            var fileStream = File.OpenRead(fileName);
                            fileStream.CopyTo(context.Response.OutputStream);
                            fileStream.Close();
                        }
                        else
                        {
                            var targetBlob = StorageSupport.GetOwnerBlobReference(containerOwner, contentPath);
                            targetBlob.DownloadToStream(context.Response.OutputStream);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.ToString());
            }
            context.Response.End();
        }
Beispiel #17
0
 private static void RenderAllPagesInWorker()
 {
     RenderWebSupport.RefreshAllAccountAndGroupTemplates(true, "AaltoGlobalImpact.OIP.Blog", "AaltoGlobalImpact.OIP.Activity", "AaltoGlobalImpact.OIP.AddressAndLocation",
                                                         "AaltoGlobalImpact.OIP.Image", "AaltoGlobalImpact.OIP.ImageGroup", "AaltoGlobalImpact.OIP.Category");
 }
Beispiel #18
0
        static void Main(string[] args)
        {
            try
            {
                string connStr = "DefaultEndpointsProtocol=https;AccountName=theballmichael;AccountKey=CWz4Sp47JIASPy99OMQX+MCdbc82pHqI0obsTAeRNb2k++YVhssKZ1RVAal8LVvA0ekXddWKIBQ7LA3Z0P6bAA==";
                //connStr = "UseDevelopmentStorage=true";
                bool debugMode = false;

                StorageSupport.InitializeWithConnectionString(connStr, debugMode);
                InformationContext.InitializeFunctionality(3, true);
                InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);

                if (DataPatcher.DoPatching())
                {
                    Console.WriteLine("DONE");
                    Console.ReadLine();
                    return;
                }

                //ProcessErrors(false);
                //return;

                string       templateLocation    = "livetemplate";
                string       privateSiteLocation = "livesite";
                string       publicSiteLocation  = "livepubsite";
                const string accountNamePart     = "oip-account\\";
                const string publicGroupNamePart = "oip-public\\";
                const string groupNamePart       = "oip-group\\";
                const string wwwNamePart         = "www-public\\";
                //DoMapData(webGroup);
                //return;
                string directory = Directory.GetCurrentDirectory();
                if (directory.EndsWith("\\") == false)
                {
                    directory = directory + "\\";
                }
                string[] allFiles =
                    Directory.GetFiles(directory, "*", SearchOption.AllDirectories).Select(
                        str => str.Substring(directory.Length)).Where(str => str.StartsWith("theball-") == false).ToArray();
                string[] groupTemplates =
                    allFiles.Where(file => file.StartsWith(accountNamePart) == false && file.StartsWith(publicGroupNamePart) == false && file.StartsWith(wwwNamePart) == false).
                    ToArray();
                string[] publicGroupTemplates =
                    allFiles.Where(file => file.StartsWith(accountNamePart) == false && file.StartsWith(groupNamePart) == false && file.StartsWith(wwwNamePart) == false).
                    ToArray();
                string[] accountTemplates =
                    allFiles.Where(file => file.StartsWith(groupNamePart) == false && file.StartsWith(publicGroupNamePart) == false && file.StartsWith(wwwNamePart) == false).
                    ToArray();
                string[] wwwTemplates =
                    allFiles.Where(file => file.StartsWith(groupNamePart) == false && file.StartsWith(publicGroupNamePart) == false && file.StartsWith(accountNamePart) == false).
                    ToArray();
                UploadAndMoveUnused(accountTemplates, groupTemplates, publicGroupTemplates, null);
                //UploadAndMoveUnused(null, null, null, wwwTemplates);
                //UploadAndMoveUnused(null, null, publicGroupTemplates, null);
                //UploadAndMoveUnused(accountTemplates, null, null);

                //DeleteAllAccountAndGroupContents(true);
                //RefreshAllAccounts();

                // TODO: The delete above needs to go through first before the refresh one below

                RenderWebSupport.RefreshAllAccountAndGroupTemplates(true, "AaltoGlobalImpact.OIP.Blog", "AaltoGlobalImpact.OIP.Activity", "AaltoGlobalImpact.OIP.AddressAndLocation",
                                                                    "AaltoGlobalImpact.OIP.Image", "AaltoGlobalImpact.OIP.ImageGroup", "AaltoGlobalImpact.OIP.Category");

                //RunTaskedQueueWorker();


                //FileSystemSupport.UploadTemplateContent(groupTemplates, webGroup, templateLocation, true);
                Console.WriteLine("Starting to sync...");
                //DoSyncs(templateLocation, privateSiteLocation, publicSiteLocation);
                //"grp/default/pub/", true);
                return;
                //doDataTest(connStr);
                //InitLandingPages();
                //Console.WriteLine("Press enter to continue...");
                //Console.ReadLine();
            }
            catch (InvalidDataException ex)
            {
                Console.WriteLine("Error exit: " + ex.ToString());
            }
        }