public static void RefreshAccountTemplates(string acctID, bool useWorker, params string[] viewTypesToRefresh) { string currContainerName = StorageSupport.CurrActiveContainer.Name; string syscontentRoot = "sys/AAA/"; string acctTemplateLocation = "acc/" + acctID + "/" + DefaultWebTemplateLocation; string acctSiteLocation = "acc/" + acctID + "/" + DefaultWebSiteLocation; string acctViewLocation = acctSiteLocation + "/" + DefaultAccountViewLocation; // Sync to account local template var accountLocalTemplate = SyncTemplatesToSite(currContainerName, syscontentRoot + DefaultAccountTemplates, currContainerName, acctTemplateLocation, useWorker, false); // Render local template var renderLocalTemplate = SyncTemplatesToSite(currContainerName, acctTemplateLocation, currContainerName, acctSiteLocation, useWorker, true); List <OperationRequest> operationRequests = new List <OperationRequest>(); operationRequests.Add(accountLocalTemplate); operationRequests.Add(renderLocalTemplate); foreach (string viewTypeToRefresh in viewTypesToRefresh) { OperationRequest refreshOp = RefreshDefaultViews(acctViewLocation, viewTypeToRefresh, useWorker); operationRequests.Add(refreshOp); } if (useWorker) { QueueSupport.PutToOperationQueue(operationRequests.ToArray()); } }
public void PerformFinalizingActions() { var grouped = SubscriptionChainTargetsToUpdate.GroupBy(item => item.Owner); foreach (var grpItem in grouped) { SubscribeSupport.AddPendingRequests(grpItem.Key, grpItem.Select(item => item.TargetLocation).ToArray()); } FinalizingOperationQueue.ForEach(oper => QueueSupport.PutToOperationQueue(oper)); }
public static void ProcessMessage(QueueEnvelope envelope, bool reportEnvelopeError = true) { try { InformationContext.Current.InitializeCloudStorageAccess(envelope.ActiveContainerName); if (envelope.SingleOperation != null) { ProcessSingleOperation(envelope.SingleOperation); } if (envelope.OrderDependentOperationSequence != null) { Exception firstException = null; //envelope.OrderDependentOperationSequence.CollectionContent.ForEach(ProcessSingleOperation); foreach (var singleOperation in envelope.OrderDependentOperationSequence.CollectionContent) { try { ProcessSingleOperation(singleOperation); } catch (Exception ex) { firstException = ex; ErrorSupport.ReportException(ex); } } if (firstException != null) { throw firstException; } } } catch (Exception ex) { if (reportEnvelopeError) { ErrorSupport.ReportEnvelopeWithException(envelope, ex); } throw; } finally { InformationContext.ProcessAndClearCurrent(); } counter++; if (counter >= 1000) { QueueSupport.ReportStatistics("Processed " + counter + " messages..."); counter = 0; } }
public static void SendGroupJoinEmail(TBEmailValidation emailValidation, TBCollaboratingGroup collaboratingGroup) { string urlLink = GetUrlLink(emailValidation.ID); QueueSupport.ReportStatistics("Group Email sent! Link: " + urlLink, TimeSpan.FromDays(1)); // string emailMessageFormat = // @"You have been invited to join in the collaboration platform by Aalto Global Impact to collaborate in the group: {0}. // // //Use the following link to accept the invitation and join the group: //{1} // // //The link is valid for 14 days, after which you need to request new invitation."; // string message = String.Format(emailMessageFormat, collaboratingGroup.Title, urlLink); // SendEmail(FromAddress, emailValidation.Email, // "Invitation to join collaboration group: " + collaboratingGroup.Title, message); }
public static QueueEnvelope RetrieveRetryableEnvelope(out CloudQueueMessage message) { SystemError error = QueueSupport.GetFromErrorQueue(out message); while (error != null) { if (error.MessageContent == null) { QueueSupport.CurrErrorQueue.DeleteMessage(message); error = QueueSupport.GetFromErrorQueue(out message); } else { return(error.MessageContent); } } return(null); }
public static void ExecuteSubscriptionChain(SubscriptionChainRequestMessage subscriptionChainRequest) { InformationContext.Current.IsExecutingSubscriptions = true; SubscriptionChainRequestContent requestContent = SubscriptionChainRequestContent.RetrieveFromDefaultLocation(subscriptionChainRequest.ContentItemID); requestContent.ProcessingStartTime = DateTime.UtcNow; requestContent.StoreInformation(); string[] subscriptionTargetList = requestContent.SubscriptionTargetCollection.CollectionContent.Select(subTarget => subTarget.BlobLocation) .ToArray(); var subscriptions = SubscribeSupport.GetSubscriptionChainItemsInOrderOfExecution(subscriptionTargetList); int currSubscription = 1; var informationObjectSubscriptions = subscriptions.Where(sub => sub.SubscriptionType != SubscribeSupport.SubscribeType_WebPageToSource). ToArray(); var webPageSubscriptions = subscriptions.Where(sub => sub.SubscriptionType == SubscribeSupport.SubscribeType_WebPageToSource). ToArray(); foreach (var subscription in informationObjectSubscriptions) { ExecuteSubscription(subscription); Debug.WriteLine("Executing subscription {0} of total {1} of {2} for {3}", currSubscription++, subscriptions.Length, subscription.SubscriptionType, subscription.SubscriberRelativeLocation); } requestContent.ProcessingEndTimeInformationObjects = DateTime.UtcNow; requestContent.StoreInformation(); foreach (var subscription in webPageSubscriptions) { //ExecuteSubscription(subscription); OperationRequest operationRequest = new OperationRequest(); operationRequest.SubscriberNotification = subscription; QueueSupport.PutToOperationQueue(operationRequest); Debug.WriteLine("Executing subscription {0} of total {1} of {2} for {3}", currSubscription++, subscriptions.Length, subscription.SubscriptionType, subscription.SubscriberRelativeLocation); } requestContent.ProcessingEndTimeWebTemplatesRendering = DateTime.UtcNow; requestContent.ProcessingEndTime = DateTime.UtcNow; requestContent.StoreInformation(); InformationContext.Current.IsExecutingSubscriptions = false; }
public static bool ProcessOwnerSubscriptionChains(IContainerOwner lockedOwner, string acquiredEtag, string containerName) { try { if (containerName != null) { InformationContext.Current.InitializeCloudStorageAccess(containerName: containerName); } string[] blobs = SubscribeSupport.GetChainRequestList(lockedOwner); var chainContent = blobs.Select(blob => StorageSupport.RetrieveInformation(blob, typeof(SubscriptionChainRequestContent))).Cast <SubscriptionChainRequestContent>().ToArray(); const double invalidSubscriptionSubmissionTimeInSeconds = 600; if (chainContent.Any(item => item.SubmitTime < DateTime.UtcNow.AddSeconds(-invalidSubscriptionSubmissionTimeInSeconds))) { return(false); } WorkerSupport.ExecuteSubscriptionChains(chainContent); foreach (string blob in blobs) { StorageSupport.DeleteBlob(blob); } } catch (Exception ex) { ErrorSupport.ReportException(ex); throw; } finally { SubscribeSupport.ReleaseChainLock(lockedOwner, acquiredEtag); if (containerName != null) { InformationContext.ProcessAndClearCurrent(); } } counter++; if (counter >= 1000) { QueueSupport.ReportStatistics("Processed " + counter + " messages..."); counter = 0; } return(true); }
public static void SendValidationEmail(TBEmailValidation emailValidation) { string urlLink = GetUrlLink(emailValidation.ID); QueueSupport.ReportStatistics("Email sent! Link: " + urlLink, TimeSpan.FromDays(1)); // string emailMessageFormat = // @"Welcome to The Open Innovation Platform! // // //You have just joined the collaboration platform by Aalto Global Impact. Your email address '{0}' has been registered on the OIP system. Before you start your collaboration we simply need to confirm that you did register your email. Please follow the link below during which you might be redirected to perform the authentication on OIP. // // //Use the following link to complete your registration (the link is valid for 30 minutes after which you need to resend the validation): //{1} // // //Wishing you all the best from OIP team!"; // string message = string.Format(emailMessageFormat, emailValidation.Email, urlLink); // SendEmail(FromAddress, emailValidation.Email, "Welcome to The Open Innovation Platform!", message); }
public static void RenderWebTemplate(string grpID, bool useWorker, params string[] viewTypesToRefresh) { string currContainerName = StorageSupport.CurrActiveContainer.Name; string groupWwwPublicTemplateLocation = "grp/" + grpID + "/" + DefaultPublicWwwTemplateLocation; string groupWwwPublicSiteLocation = "grp/" + grpID + "/" + DefaultPublicWwwSiteLocation; string groupWwwSiteViewLocation = groupWwwPublicSiteLocation + "/" + DefaultPublicWwwViewLocation; List <OperationRequest> operationRequests = new List <OperationRequest>(); var renderWwwTemplates = SyncTemplatesToSite(currContainerName, groupWwwPublicTemplateLocation, currContainerName, groupWwwPublicSiteLocation, useWorker, true); operationRequests.Add(renderWwwTemplates); foreach (string viewTypeToRefresh in viewTypesToRefresh) { OperationRequest refreshOp = RefreshDefaultViews(groupWwwSiteViewLocation, viewTypeToRefresh, useWorker); operationRequests.Add(refreshOp); } if (useWorker) { QueueSupport.PutToOperationQueue(operationRequests.ToArray()); } }
public static void SendInputJoinEmail(TBEmailValidation emailValidation, InformationInput informationInput, string[] ownerEmailAddresses) { string urlLink = GetUrlLink(emailValidation.ID); QueueSupport.ReportStatistics("Input Join Email sent! Link: " + urlLink, TimeSpan.FromDays(1)); // bool isAccount = emailValidation.InformationInputConfirmation.AccountID != null; // string ownerID = isAccount // ? emailValidation.InformationInputConfirmation.AccountID // : emailValidation.InformationInputConfirmation.GroupID; // string emailMessageFormat = // @"Your confirmation is required to allow the following information source '{0}' to be fetched within {1} ID {2}. // // //Click the following link to confirm this action: //{3}"; // string message = String.Format(emailMessageFormat, informationInput.Description, // isAccount ? "account" : "collaboration group", ownerID, urlLink); // foreach (string emailAddress in ownerEmailAddresses) // { // SendEmail(FromAddress, emailAddress, "Information Input Confirmation", message); // } }
public static void ExecuteSubscriptionChains(params SubscriptionChainRequestContent[] contentList) { InformationContext.Current.IsExecutingSubscriptions = true; try { string[] subscriptionTargetList = contentList.SelectMany(reqContent => reqContent.SubscriptionTargetCollection.CollectionContent).Select(subTarget => subTarget.BlobLocation) .ToArray(); var subscriptions = SubscribeSupport.GetSubscriptionChainItemsInOrderOfExecution(subscriptionTargetList); int currSubscription = 1; var informationObjectSubscriptions = subscriptions.Where(sub => sub.SubscriptionType != SubscribeSupport.SubscribeType_WebPageToSource). ToArray(); var webPageSubscriptions = subscriptions.Where(sub => sub.SubscriptionType == SubscribeSupport.SubscribeType_WebPageToSource). ToArray(); foreach (var subscription in informationObjectSubscriptions) { ExecuteSubscription(subscription); Debug.WriteLine("Executing subscription {0} of total {1} of {2} for {3}", currSubscription++, subscriptions.Length, subscription.SubscriptionType, subscription.SubscriberRelativeLocation); } foreach (var subscription in webPageSubscriptions) { //ExecuteSubscription(subscription); OperationRequest operationRequest = new OperationRequest(); operationRequest.SubscriberNotification = subscription; QueueSupport.PutToOperationQueue(operationRequest); Debug.WriteLine("Executing subscription {0} of total {1} of {2} for {3}", currSubscription++, subscriptions.Length, subscription.SubscriptionType, subscription.SubscriberRelativeLocation); } } finally { InformationContext.Current.IsExecutingSubscriptions = false; } }
public static void ReportError(SystemError error) { QueueSupport.PutToErrorQueue(error); }
public static void ProcessQueries(QueueSupport.MessageObject<string>[] queryMessages, string indexStorageRootFolder) { foreach (var queryMessage in queryMessages) { var splitValues = queryMessage.RetrievedObject.Split(':'); var containerName = splitValues[0]; var ownerString = splitValues[1]; var owner = VirtualOwner.FigureOwner(ownerString); var queryRequestID = splitValues[2]; string containerIndexRoot = Path.Combine(indexStorageRootFolder, containerName); if (Directory.Exists(containerIndexRoot) == false) Directory.CreateDirectory(containerIndexRoot); try { InformationContext.Current.InitializeCloudStorageAccess(containerName: containerName); InformationContext.Current.Owner = owner; InformationContext.StartResourceMeasuringOnCurrent(InformationContext.ResourceUsageType.WorkerQuery); QueryIndexedInformation.Execute(new QueryIndexedInformationParameters { QueryRequestID = queryRequestID, IndexName = IndexSupport.DefaultIndexName, IndexStorageRootPath = containerIndexRoot, Owner = owner }); } finally { if (containerName != null) InformationContext.ProcessAndClearCurrent(); } } }
public static void RefreshGroupTemplates(string grpID, bool useWorker, params string[] viewTypesToRefresh) { string syscontentRoot = "sys/AAA/"; string currContainerName = StorageSupport.CurrActiveContainer.Name; string anonContainerName = GetCurrentAnonContainerName(); //StorageSupport.CurrAnonPublicContainer.Name; //"demopublicoip-aaltoglobalimpact-org"; string groupTemplateLocation = "grp/" + grpID + "/" + DefaultWebTemplateLocation; string groupSiteLocation = "grp/" + grpID + "/" + DefaultWebSiteLocation; string groupSiteViewLocation = groupSiteLocation + "/" + DefaultGroupViewLocation; string groupPublicTemplateLocation = "grp/" + grpID + "/" + DefaultPublicGroupTemplateLocation; string groupPublicSiteLocation = "grp/" + grpID + "/" + DefaultPublicGroupSiteLocation; string groupPublicViewLocation = groupPublicSiteLocation + "/" + DefaultPublicGroupViewLocation; string defaultPublicSiteLocation = "grp/default/" + DefaultPublicGroupSiteLocation; //string groupWwwPublicTemplateLocation = "grp/" + grpID + "/" + DefaultPublicWwwTemplateLocation; //string groupWwwPublicSiteLocation = "grp/" + grpID + "/" + DefaultPublicWwwSiteLocation; //string groupWwwSiteViewLocation = groupWwwPublicSiteLocation + "/" + DefaultPublicWwwViewLocation; string aboutAuthTargetLocation = DefaultAboutTargetLocation; // Sync to group local template List <OperationRequest> operationRequests = new List <OperationRequest>(); var localGroupTemplates = SyncTemplatesToSite(currContainerName, syscontentRoot + DefaultGroupTemplates, currContainerName, groupTemplateLocation, useWorker, false); // Render local template var renderLocalTemplates = SyncTemplatesToSite(currContainerName, groupTemplateLocation, currContainerName, groupSiteLocation, useWorker, true); // Sync public pages to group local template var publicGroupTemplates = SyncTemplatesToSite(currContainerName, syscontentRoot + DefaultPublicGroupTemplates, currContainerName, groupPublicTemplateLocation, useWorker, false); // Render local template var renderPublicTemplates = SyncTemplatesToSite(currContainerName, groupPublicTemplateLocation, currContainerName, groupPublicSiteLocation, useWorker, true); /* * // Sync public www-pages to group local template * var publicWwwTemplates = SyncTemplatesToSite(currContainerName, syscontentRoot + DefaultPublicWwwTemplates, * currContainerName, groupWwwPublicTemplateLocation, useWorker, false); * * // Render local template * var renderWwwTemplates = SyncTemplatesToSite(currContainerName, groupWwwPublicTemplateLocation, currContainerName, groupWwwPublicSiteLocation, useWorker, true); */ operationRequests.Add(localGroupTemplates); operationRequests.Add(renderLocalTemplates); operationRequests.Add(publicGroupTemplates); operationRequests.Add(renderPublicTemplates); //operationRequests.Add(publicWwwTemplates); //operationRequests.Add(renderWwwTemplates); foreach (string viewTypeToRefresh in viewTypesToRefresh) { OperationRequest refreshOp = RefreshDefaultViews(groupSiteViewLocation, viewTypeToRefresh, useWorker); operationRequests.Add(refreshOp); refreshOp = RefreshDefaultViews(groupPublicViewLocation, viewTypeToRefresh, useWorker); operationRequests.Add(refreshOp); //refreshOp = RefreshDefaultViews(groupWwwSiteViewLocation, viewTypeToRefresh, useWorker); //operationRequests.Add(refreshOp); } // Publish group public content #if never // Moved to separate operations to be web-ui activated var publishPublicContent = SyncTemplatesToSite(currContainerName, groupPublicSiteLocation, anonContainerName, groupPublicSiteLocation, useWorker, false); operationRequests.Add(publishPublicContent); if (grpID == DefaultGroupID) // Currently also publish www { OperationRequest publishDefault = SyncTemplatesToSite(currContainerName, groupPublicSiteLocation, anonContainerName, defaultPublicSiteLocation, useWorker, false); operationRequests.Add(publishDefault); publishDefault = SyncTemplatesToSite(currContainerName, groupPublicSiteLocation, currContainerName, aboutAuthTargetLocation, useWorker, false); operationRequests.Add(publishDefault); string defaultWwwContainerName = GetCurrentWwwContainerName(); publishDefault = SyncTemplatesToSite(currContainerName, groupWwwPublicSiteLocation, defaultWwwContainerName, "", useWorker, false); operationRequests.Add(publishDefault); } #endif if (useWorker) { //QueueSupport.PutToOperationQueue(localGroupTemplates, renderLocalTemplates); QueueSupport.PutToOperationQueue(operationRequests.ToArray()); } }