public bool PublishSite(string publishType)
        {
            PublishMode publishMode = PublishMode.Full;

            switch (publishType)
            {
            case  "smart":
                publishMode = PublishMode.Smart;
                break;

            case "incremental":
                publishMode = PublishMode.Incremental;
                break;

            default:
                publishMode = PublishMode.Full;
                break;
            }

            var publishConfig = new PublishConfiguration()
            {
                PublishMode = publishMode, RootPath = "/sitecore/content/Helixbase"
            };

            return(_publishRepository.PublishSite(publishConfig));
        }
Ejemplo n.º 2
0
        public void PublishItem(Item item, PublishMode publishMode, bool publishDeep = true, string sourceDatabaseName = Constants.MasterContextName, string targetDatabaseName = Constants.WebContextName, bool publishAsync = true)
        {
            using (new SecurityDisabler())
            {
                // We need to be able to set the source and target databases so that when we run things from another context like scheduler or others, we can publish as desired.
                var            sourceDatabase = Database.GetDatabase(sourceDatabaseName);
                var            targetDatabase = Database.GetDatabase(targetDatabaseName);
                PublishOptions publishOptions = new PublishOptions(sourceDatabase, targetDatabase, publishMode, item.Language, DateTime.Now);

                publishOptions.UserName = "******";
                Publisher publisher = new Publisher(publishOptions);

                // Publish start item
                publisher.Options.RootItem = item;

                // set "Deep" to true to Publish the child items as well
                publisher.Options.Deep = publishDeep;

                // Run the publish as async or sync as required
                if (publishAsync)
                {
                    publisher.PublishAsync();
                }
                else
                {
                    publisher.Publish();
                }

                item.Publishing.ClearPublishingCache();
            }
        }
        public void Publish(PublishMode mode, string languageName, List <string> publishingTargets, bool deep, string sourceDatabaseName = "master", string targetDatabaseName = "web", string rootItemPath = null)
        {
            //TODO : This option doesn't work yet

            using (new SecurityDisabler())
            {
                var sourceDatabase = Database.GetDatabase(sourceDatabaseName);
                var targetDatabase = Database.GetDatabase(targetDatabaseName);
                var language       = string.IsNullOrEmpty(languageName) ? null : LanguageManager.GetLanguage(languageName);
                var rootItem       = rootItemPath == null ? null : sourceDatabase.SelectSingleItem(rootItemPath);

                Sitecore.Publishing.PublishOptions publishOptions = new Sitecore.Publishing.PublishOptions(sourceDatabase,
                                                                                                           targetDatabase,
                                                                                                           mode,
                                                                                                           language,
                                                                                                           System.DateTime.Now /*, publishingTargets*/); // Create a publisher with the publishoptions


                // The publishOptions determine the source and target database,
                // the publish mode and language, and the publish date
                var publisher = new Sitecore.Publishing.Publisher(publishOptions);

                // Choose where to publish from
                publisher.Options.RootItem = rootItem;

                // Publish children as well?
                publisher.Options.Deep = deep;

                // Do the publish!
                publisher.Publish();
            }
        }
        /// <summary>
        /// Publishes item to all publication databases
        /// </summary>
        /// <param name="itemID">ID of Sitecore Item to publish</param>
        /// <param name="publishMode">Sitecore publish mode</param>
        public static void PublishItem(String itemID, PublishMode publishMode = PublishMode.SingleItem)
        {
            if (masterDB != null)
            {
                var item = masterDB.GetItem(itemID);

                PublishItem(item, publishMode);
            }
        }
 public override void PublishGameObject(PublishMode mode, PublishPlatform platform)
 {
     if (
         (this.remove == PublishMode.Debug && mode == PublishMode.Debug) ||
         (this.remove == PublishMode.Release && mode == PublishMode.Release)
     )
         DestroyImmediate(this.gameObject);
     else
         DestroyImmediate(this);
 }
Ejemplo n.º 6
0
    public void DotnetPublishWorks(PublishMode publishMode, DeploymentMode deploymentMode, NativeLibrariesDeploymentMode nativeLibsDeploymentMode)
    {
        // Publishing without specifying a RID is not supported.
        // Furthermore, only publishing in Release mode is tested.
        CleanSampleProject(Configuration.Release, RID.Win_x64);

        Exec(SampleProjectDirectory !, "dotnet", $"publish -c Release -f net6.0 -r win-x64 {ToOption(publishMode)} {ToOption(deploymentMode)} {ToOption(nativeLibsDeploymentMode)} /bl");

        string pathToAppHost = Path.Combine("bin", $"Release", "net6.0", "win-x64", "publish", "ComputeSharp.Sample.NuGet.exe");

        Assert.AreEqual(0, Exec(SampleProjectDirectory !, pathToAppHost, ""));
    }
Ejemplo n.º 7
0
 public void Publish(PublishMode mode, string languageName, string[] publishingTargets, bool deep, string sourceDatabaseName, string targetDatabaseName, string rootItemPath)
 {
     this.Invoke("Publish", new object[] {
         mode,
         languageName,
         publishingTargets,
         deep,
         sourceDatabaseName,
         targetDatabaseName,
         rootItemPath
     });
 }
Ejemplo n.º 8
0
 /// <remarks/>
 public void PublishAsync(PublishMode mode, string languageName, string[] publishingTargets, bool deep, string sourceDatabaseName, string targetDatabaseName, string rootItemPath, object userState)
 {
     if ((this.PublishOperationCompleted == null))
     {
         this.PublishOperationCompleted = new System.Threading.SendOrPostCallback(this.OnPublishOperationCompleted);
     }
     this.InvokeAsync("Publish", new object[] {
         mode,
         languageName,
         publishingTargets,
         deep,
         sourceDatabaseName,
         targetDatabaseName,
         rootItemPath
     }, this.PublishOperationCompleted, userState);
 }
Ejemplo n.º 9
0
        public Task PublishAsync(ITransaction tx, params IEvent[] events) => PublishAsync(tx, PublishMode.All, events);         //TODO set default mode on publisher

        public Task PublishAsync(ITransaction tx, PublishMode mode, params IEvent[] events)
        {
            switch (mode)
            {
            case PublishMode.All:
                return(Task.WhenAll(outBoxQueue(tx, events), eventLogger(events), Task.WhenAll(inProcess.Select(x => x(tx, events)))));

            case PublishMode.OutBoxQueue:
                return(Task.WhenAll(outBoxQueue(tx, events), eventLogger(events)));

            case PublishMode.InProcess:
                return(Task.WhenAll(Task.WhenAll(inProcess.Select(x => x(tx, events))), eventLogger(events)));

            default:
                return(Task.WhenAll(outBoxQueue(tx, events), eventLogger(events), Task.WhenAll(inProcess.Select(x => x(tx, events)))));
            }
        }
        public bool CheckAreAllReadyToBePublished(List <Course> courses, PublishMode publishMode)
        {
            bool AreAllReadyToBePublished = false;

            if (courses.Count.Equals(0))
            {
                return(AreAllReadyToBePublished);
            }

            var hasInvalidCourses = courses.Any(c => c.IsValid == false);

            if (hasInvalidCourses)
            {
                return(AreAllReadyToBePublished);
            }
            else
            {
                switch (publishMode)
                {
                case PublishMode.Migration:
                    var hasInvalidMigrationCourseRuns = courses.Any(x => x.CourseRuns.Any(cr => cr.RecordStatus == RecordStatus.MigrationPending));
                    if (!hasInvalidMigrationCourseRuns)
                    {
                        AreAllReadyToBePublished = true;
                    }
                    break;

                case PublishMode.BulkUpload:
                    var hasInvalidBulkUploadCourseRuns = courses.Any(x => x.CourseRuns.Any(cr => cr.RecordStatus == RecordStatus.BulkUploadPending));
                    if (!hasInvalidBulkUploadCourseRuns)
                    {
                        AreAllReadyToBePublished = true;
                    }
                    break;
                }
                return(AreAllReadyToBePublished);
            }
        }
        /// <summary>
        /// Publishes item to all publication databases
        /// </summary>
        /// <param name="item">Sitecore Item to publish</param>
        /// <param name="publishMode">Sitecore publish mode</param>
        public static void PublishItem(Item item, PublishMode publishMode = PublishMode.SingleItem)
        {
            if (masterDB != null && publicationDBs != null && publicationDBs.Count > 0)
            {
                var itemPublishToPublicationDatabasesOptionsArray = new PublishOptions[publicationDBs.Count][];

                for (int i = 0; i < publicationDBs.Count; i++)
                {
                    itemPublishToPublicationDatabasesOptionsArray[i] = new PublishOptions[masterDB.Languages.Length];

                    for (var j = 0; j < masterDB.Languages.Length; j++)
                    {
                        itemPublishToPublicationDatabasesOptionsArray[i][j] = new PublishOptions(masterDB, publicationDBs[i], publishMode, masterDB.Languages[j], DateTime.Now)
                        {
                            Deep = true,
                            CompareRevisions = true,
                            RootItem = item,
                        };
                    }

                    PublishManager.Publish(itemPublishToPublicationDatabasesOptionsArray[i]);
                }
            }
        }
Ejemplo n.º 12
0
 /// <remarks/>
 public void PublishAsync(PublishMode mode, string languageName, string[] publishingTargets, bool deep, string sourceDatabaseName, string targetDatabaseName, string rootItemPath)
 {
     this.PublishAsync(mode, languageName, publishingTargets, deep, sourceDatabaseName, targetDatabaseName, rootItemPath, null);
 }
Ejemplo n.º 13
0
        private void RunPublishJob(Item item, Database sourceDatabase, Database targetDatabase, PublishMode publishMode, Language language, bool deep)
        {
            var options = new PublishOptions(sourceDatabase, targetDatabase, publishMode, language, DateTime.Now)
            {
                Deep = deep,
                PublishRelatedItems = false,
                RootItem            = item
            };

            try
            {
                var publisher = new Publisher(options);
                publisher.Publish();
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error("Error publishing.", ex, this);
            }
        }
 private static PublishOptions Options(Data.Items.Item rootItem, Database source, Database target, Language lang, PublishMode publishMode)
 {
     return(new PublishOptions(source, target, publishMode, lang, DateTime.Now)
     {
         RootItem = rootItem, Deep = true
     });
 }
 public static void Publish(Instance instance, Window owner, PublishMode mode)
 {
     WindowHelper.LongRunningTask(
         () => PublishAsync(instance), "Publish",
         owner, "Publish", "Publish 'en' language from 'master' to 'web' with mode " + mode);
 }
        public void Publish(PublishMode mode, string languageName, List<string> publishingTargets, bool deep, string sourceDatabaseName = "master", string targetDatabaseName = "web", string rootItemPath = null)
        {
            //TODO : This option doesn't work yet

            using (new SecurityDisabler())
            {
                var sourceDatabase = Database.GetDatabase(sourceDatabaseName);
                var targetDatabase = Database.GetDatabase(targetDatabaseName);
                var language = string.IsNullOrEmpty(languageName) ? null : LanguageManager.GetLanguage(languageName);
                var rootItem = rootItemPath == null ? null : sourceDatabase.SelectSingleItem(rootItemPath);

                Sitecore.Publishing.PublishOptions publishOptions = new Sitecore.Publishing.PublishOptions(sourceDatabase,
                                                        targetDatabase,
                                                        mode,
                                                        language,
                                                        System.DateTime.Now/*, publishingTargets*/);  // Create a publisher with the publishoptions

                // The publishOptions determine the source and target database,
                // the publish mode and language, and the publish date
                var publisher = new Sitecore.Publishing.Publisher(publishOptions);

                // Choose where to publish from
                publisher.Options.RootItem = rootItem;

                // Publish children as well?
                publisher.Options.Deep = deep;

                // Do the publish!
                publisher.Publish();
            }
        }
 private static PublishOptions Options(Data.Items.Item rootItem, Database source, Database target, Language lang, PublishMode publishMode)
 {
     return new PublishOptions(source, target, publishMode, lang, DateTime.Now) { RootItem = rootItem, Deep = true };
 }
        /// <summary>
        /// Create a new Message with Binary (byte) Content for Publishing to an Exchange
        /// </summary>
        /// <param name="client">A <see cref="RabbitMQClient"/> Instance</param>
        /// <param name="exchange">The Exchange to Publish this Message to</param>
        /// <param name="routingKey">The Routing Key for this Message</param>
        /// <param name="bytes">The Binary (byte) Data for this Message</param>
        /// <param name="type">The Type of Message</param>
        /// <param name="mode">The Publishing Mode for this Message</param>
        /// <returns>A New <see cref="BinaryPublishMessage"/> Instance ready to be Published</returns>
        public static PublishMessage CreateNew(RabbitMQClient client, string exchange, string routingKey, ReadOnlyMemory <byte> bytes, string type = "", PublishMode mode = PublishMode.BrokerConfirm)
        {
            PublishMessage message = CreateNew(client, exchange, routingKey, type, mode);

            message.Body        = bytes;
            message.ContentType = ContentTypes.Binary;

            return(message);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Create a new Message with JSON Content for Publishing a Reply directly to a Queue
        /// </summary>
        /// <param name="client">A <see cref="RabbitMQClient"/> Instance</param>
        /// <param name="replyTo">The Name of the Queue to Directly Publish to</param>
        /// <param name="receivedMessageId">The ID of the Message that is being Replied to</param>
        /// <param name="json">The JSON Data for this Message</param>
        /// <param name="type">The Type of Message</param>
        /// <param name="mode">The Publishing Mode for this Message</param>
        /// <returns>A New <see cref="JSONPublishMessage"/> Instance ready to be Published</returns>
        public static PublishMessage CreateNew(RabbitMQClient client, string replyTo, Guid receivedMessageId, JToken json, string type = "", PublishMode mode = PublishMode.BrokerConfirm)
        {
            if (json == null)
            {
                throw new ArgumentNullException(nameof(json));
            }

            PublishMessage message = CreateNew(client, replyTo, receivedMessageId, type, mode);

            message.Body            = Encoding.UTF8.GetBytes(json.ToString(Formatting.None));
            message.ContentType     = ContentTypes.JSON;
            message.ContentEncoding = "utf8";

            return(message);
        }
        public async Task <IActionResult> Index(string learnAimRef, string notionalNVQLevelv2, string awardOrgCode, string learnAimRefTitle, string learnAimRefTypeDesc, Guid?courseId, Guid?courseRunId, bool fromBulkUpload, PublishMode mode)
        {
            if (!Session.GetInt32("UKPRN").HasValue)
            {
                return(RedirectToAction("Index", "Home", new { errmsg = "Please select a Provider." }));
            }

            if (!courseId.HasValue)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                }));
            }

            var result = await _courseService.GetCourseByIdAsync(new GetCourseByIdCriteria(courseId.Value));

            if (!result.IsSuccess)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                }));
            }

            var vm = new EditCourseViewModel
            {
                CourseName         = result.Value.QualificationCourseTitle,
                AwardOrgCode       = awardOrgCode,
                LearnAimRef        = learnAimRef,
                LearnAimRefTitle   = learnAimRefTitle,
                NotionalNVQLevelv2 = result.Value.NotionalNVQLevelv2,
                CourseId           = courseId,
                CourseRunId        = courseRunId,
                Mode      = mode,
                CourseFor = new CourseForModel()
                {
                    LabelText       = "Who this course is for",
                    HintText        = "Information that will help the learner decide whether this course is suitable for them, the learning experience and opportunities they can expect from the course.",
                    AriaDescribedBy = "Please enter who this course is for.",
                    CourseFor       = result.Value.CourseDescription
                },

                EntryRequirements = new EntryRequirementsModel()
                {
                    LabelText         = "Entry requirements",
                    HintText          = "Specific skills, licences, vocational or academic requirements. For example, DBS, driving licence, computer knowledge, literacy or numeracy requirements.",
                    AriaDescribedBy   = "Please list entry requirements.",
                    EntryRequirements = result.Value.EntryRequirements
                },
                WhatWillLearn = new WhatWillLearnModel()
                {
                    LabelText       = "What you’ll learn",
                    HintText        = "The main topics, units or modules of the course a learner can expect, include key features. For example, communication, team leadership and time management.",
                    AriaDescribedBy = "Please enter what will be learned.",
                    WhatWillLearn   = result.Value.WhatYoullLearn
                },
                HowYouWillLearn = new HowYouWillLearnModel()
                {
                    LabelText       = "How you’ll learn",
                    HintText        = "The methods used to deliver the course. For example, classroom based exercises, a work environment or online study materials.",
                    AriaDescribedBy = "Please enter how you’ll learn.",
                    HowYouWillLearn = result.Value.HowYoullLearn
                },
                WhatYouNeed = new WhatYouNeedModel()
                {
                    LabelText       = "What you’ll need to bring",
                    HintText        = "What the learner will need to access or bring to the course. For example, personal protective clothing, tools, devices or internet access.",
                    AriaDescribedBy = "Please enter what you need.",
                    WhatYouNeed     = result.Value.WhatYoullNeed
                },
                HowAssessed = new HowAssessedModel()
                {
                    LabelText       = "How you’ll be assessed",
                    HintText        = "The ways a learner will be assessed. For example, workplace assessment, written assignments, exams, group or individual project work or portfolio of evidence.",
                    AriaDescribedBy = "Please enter how you’ll be assessed.",
                    HowAssessed     = result.Value.HowYoullBeAssessed
                },
                WhereNext = new WhereNextModel()
                {
                    LabelText       = "What you can do next",
                    HintText        = "The further opportunities a learner can expect after successfully completing the course. For example, a higher level course, apprenticeship or entry to employment.",
                    AriaDescribedBy = "Please enter what you can do next.",
                    WhereNext       = result.Value.WhereNext
                },
                QualificationType    = result.Value.QualificationType,
                AdultEducationBudget = result.Value.AdultEducationBudget,
                AdvancedLearnerLoan  = result.Value.AdvancedLearnerLoan
            };

            return(View("EditCourse", vm));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Create a new Message for Publishing a Reply directly to a Queue
        /// </summary>
        /// <param name="client">A <see cref="RabbitMQClient"/> Instance</param>
        /// <param name="replyTo">The Name of the Queue to Directly Publish to</param>
        /// <param name="receivedMessageId">The ID of the Message that is being Replied to</param>
        /// <param name="type">The Type of Message</param>
        /// <param name="mode">The Publishing Mode for this Message</param>
        /// <returns>A New <see cref="PublishMessage"/> Instance ready to be Customized before Publishing</returns>
        public static PublishMessage CreateNew(RabbitMQClient client, string replyTo, Guid receivedMessageId, string type = "", PublishMode mode = PublishMode.BrokerConfirm)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (replyTo == null)
            {
                throw new ArgumentNullException(nameof(replyTo));
            }

            if (receivedMessageId == Guid.Empty)
            {
                throw new ArgumentOutOfRangeException(nameof(receivedMessageId), "The Received Message ID cannot be an Empty GUID");
            }

#if NETSTANDARD
            TimeSpan publishTimeout = client.DefaultPublishTimeout ?? TimeSpan.FromMilliseconds(client.HeartbeatInterval.TotalMilliseconds * 2);
#else
            TimeSpan publishTimeout = client.DefaultPublishTimeout ?? client.HeartbeatInterval.Multiply(2);
#endif

            return(new PublishMessage(client.DefaultPublishRetries)
            {
                Exchange = "",
                RoutingKey = replyTo,
                Mode = mode,
                Type = type,
                PublishTimeout = publishTimeout,
                PublishRetries = client.DefaultPublishRetries,
                CorrelationID = receivedMessageId,
            });
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Create a new Message for Publishing to an Exchange
        /// </summary>
        /// <param name="client">A <see cref="RabbitMQClient"/> Instance</param>
        /// <param name="exchange">The Exchange to Publish this Message to</param>
        /// <param name="routingKey">The Routing Key for this Message</param>
        /// <param name="type">The Type of Message</param>
        /// <param name="mode">The Publishing Mode for this Message</param>
        /// <returns>A New <see cref="PublishMessage"/> Instance ready to be Customized before Publishing</returns>
        public static PublishMessage CreateNew(RabbitMQClient client, string exchange, string routingKey, string type = "", PublishMode mode = PublishMode.BrokerConfirm)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (exchange == null)
            {
                throw new ArgumentNullException(nameof(exchange));
            }

            if (routingKey == null)
            {
                throw new ArgumentNullException(nameof(routingKey));
            }

#if NETSTANDARD
            TimeSpan publishTimeout = client.DefaultPublishTimeout ?? TimeSpan.FromMilliseconds(client.HeartbeatInterval.TotalMilliseconds * 2);
#else
            TimeSpan publishTimeout = client.DefaultPublishTimeout ?? client.HeartbeatInterval.Multiply(2);
#endif

            return(new PublishMessage(client.DefaultPublishRetries)
            {
                Exchange = exchange,
                RoutingKey = routingKey,
                Mode = mode,
                Type = type,
                PublishTimeout = publishTimeout,
                PublishRetries = client.DefaultPublishRetries,
            });
        }
Ejemplo n.º 23
0
 public Task ExecuteAsync <TState>(ICommand command, Func <TState, IEvent[]> f, PublishMode publishMode = PublishMode.OutBoxQueue)
     where TState : class, new()
 => this.stateManager.UseTransactionAsync(
     tx => ApplicationService.ExecuteAsync(
         store(tx), command,
         f,
         events => eventPublisher.PublishAsync(tx, publishMode, events)
         )
     );
        public async Task <IActionResult> Index(PublishMode publishMode, string notificationTitle, Guid?courseId, Guid?courseRunId, bool fromBulkUpload)
        {
            int?UKPRN = Session.GetInt32("UKPRN");

            if (!UKPRN.HasValue)
            {
                return(RedirectToAction("Index", "Home", new { errmsg = "Please select a Provider." }));
            }

            var coursesByUKPRN = (await _courseService.GetYourCoursesByUKPRNAsync(new CourseSearchCriteria(UKPRN))).Value;

            // Only display courses that have Lars and Qualification titles
            var courses = coursesByUKPRN.Value
                          .SelectMany(o => o.Value)
                          .SelectMany(i => i.Value)
                          .Where(c => !string.IsNullOrWhiteSpace(c.LearnAimRef) && !string.IsNullOrWhiteSpace(c.QualificationCourseTitle))
                          .ToList();

            courses = GetErrorMessages(courses, ValidationMode.MigrateCourse).ToList();

            PublishViewModel vm = new PublishViewModel();

            switch (publishMode)
            {
            case PublishMode.Migration:
                if (courses.Where(x => x.CourseRuns.Any(cr => cr.RecordStatus == RecordStatus.MigrationPending || cr.RecordStatus == RecordStatus.MigrationReadyToGoLive) && x.IsValid == false).Any())
                {
                    vm.PublishMode = PublishMode.Migration;

                    var migratedCourses           = courses.Where(x => x.CourseRuns.Any(cr => cr.RecordStatus == RecordStatus.MigrationPending || cr.RecordStatus == RecordStatus.MigrationReadyToGoLive));
                    var migratedCoursesWithErrors = GetErrorMessages(migratedCourses, ValidationMode.MigrateCourse).ToList();

                    vm.NumberOfCoursesInFiles = migratedCoursesWithErrors.SelectMany(s => s.CourseRuns.Where(cr => cr.RecordStatus == RecordStatus.MigrationPending ||
                                                                                                             cr.RecordStatus == RecordStatus.MigrationReadyToGoLive)).Count();

                    vm.Courses = migratedCoursesWithErrors.OrderBy(x => x.QualificationCourseTitle);
                    vm.AreAllReadyToBePublished = CheckAreAllReadyToBePublished(migratedCoursesWithErrors, PublishMode.Migration);
                    vm.Venues = VenueHelper.GetVenueNames(vm.Courses, _cosmosDbQueryDispatcher).Result;
                    break;
                }
                else
                {
                    return(View("../Migration/Complete/index"));
                }

            case PublishMode.BulkUpload:

                vm.PublishMode = PublishMode.BulkUpload;
                var bulkUploadedCourses = courses.Where(x => x.CourseRuns.Any(cr => cr.RecordStatus == RecordStatus.BulkUploadPending || cr.RecordStatus == RecordStatus.BulkUploadReadyToGoLive)).ToList();
                vm.NumberOfCoursesInFiles = bulkUploadedCourses.SelectMany(s => s.CourseRuns.Where(cr => cr.RecordStatus == RecordStatus.BulkUploadPending || cr.RecordStatus == RecordStatus.BulkUploadReadyToGoLive)).Count();
                vm.Courses = bulkUploadedCourses.OrderBy(x => x.QualificationCourseTitle);
                vm.AreAllReadyToBePublished = CheckAreAllReadyToBePublished(bulkUploadedCourses, PublishMode.BulkUpload);
                vm.Courses = GetErrorMessages(vm.Courses, ValidationMode.BulkUploadCourse);
                vm.Venues  = VenueHelper.GetVenueNames(vm.Courses, _cosmosDbQueryDispatcher).Result;
                break;

            case PublishMode.DataQualityIndicator:

                vm.PublishMode = PublishMode.DataQualityIndicator;
                var           validCourses         = courses.Where(x => x.IsValid && ((int)x.CourseStatus & (int)RecordStatus.Live) > 0);
                var           results              = _courseService.CourseValidationMessages(validCourses, ValidationMode.DataQualityIndicator).Value.ToList();
                var           invalidCoursesResult = results.Where(c => c.RunValidationResults.Any(cr => cr.Issues.Count() > 0));
                var           invalidCourses       = invalidCoursesResult.Select(c => (Course)c.Course).ToList();
                var           invalidCourseRuns    = invalidCourses.Select(cr => cr.CourseRuns.Where(x => x.StartDate < DateTime.Today));
                List <Course> filteredList         = new List <Course>();
                var           allRegions           = _courseService.GetRegions().RegionItems;
                foreach (var course in invalidCourses)
                {
                    var invalidRuns = course.CourseRuns.Where(x => x.StartDate < DateTime.Today);
                    if (invalidRuns.Any())
                    {
                        course.CourseRuns = invalidRuns;
                        filteredList.Add(course);
                    }
                }

                if (invalidCourseRuns.Count() == 0 && courseId != null && courseRunId != null)
                {
                    return(BadRequest());
                }

                vm.NumberOfCoursesInFiles = invalidCourses.Count();
                vm.Courses = filteredList.OrderBy(x => x.QualificationCourseTitle);
                vm.Venues  = VenueHelper.GetVenueNames(vm.Courses, _cosmosDbQueryDispatcher).Result;
                vm.Regions = allRegions;
                break;
            }

            vm.NotificationTitle = notificationTitle;
            vm.CourseId          = courseId;
            vm.CourseRunId       = courseRunId;

            if (vm.AreAllReadyToBePublished)
            {
                if (publishMode == PublishMode.BulkUpload)
                {
                    return(RedirectToAction("CoursesPublishFile", "Bulkupload", new { NumberOfCourses = courses.SelectMany(s => s.CourseRuns.Where(cr => cr.RecordStatus == RecordStatus.BulkUploadReadyToGoLive)).Count() })
                           .WithProviderContext(_providerContextProvider.GetProviderContext(withLegacyFallback: true)));
                }
            }
            else
            {
                if (publishMode == PublishMode.BulkUpload)
                {
                    var message = "";
                    if (fromBulkUpload)
                    {
                        var invalidCourseCount         = courses.Where(x => x.IsValid == false).Count();
                        var bulkUploadedPendingCourses = (courses.SelectMany(c => c.CourseRuns)
                                                          .Where(x => x.RecordStatus == RecordStatus.BulkUploadPending)
                                                          .Count());
                        message = "Your file contained " + bulkUploadedPendingCourses + @WebHelper.GetErrorTextValueToUse(bulkUploadedPendingCourses) + ". You must resolve all errors before your courses information can be published.";
                        return(RedirectToAction("WhatDoYouWantToDoNext", "Bulkupload", new { message = message }));
                    }
                }
            }

            return(View("Index", vm));
        }
        /// <summary>
        /// Create a new Message with Binary (byte) Content for Publishing a Reply directly to a Queue
        /// </summary>
        /// <param name="client">A <see cref="RabbitMQClient"/> Instance</param>
        /// <param name="replyTo">The Name of the Queue to Directly Publish to</param>
        /// <param name="receivedMessageId">The ID of the Message that is being Replied to</param>
        /// <param name="bytes">The Binary (byte) Data for this Message</param>
        /// <param name="type">The Type of Message</param>
        /// <param name="mode">The Publishing Mode for this Message</param>
        /// <returns>A New <see cref="BinaryPublishMessage"/> Instance ready to be Published</returns>
        public static PublishMessage CreateNew(RabbitMQClient client, string replyTo, Guid receivedMessageId, ReadOnlyMemory <byte> bytes, string type = "", PublishMode mode = PublishMode.BrokerConfirm)
        {
            PublishMessage message = CreateNew(client, replyTo, receivedMessageId, type, mode);

            message.Body        = bytes;
            message.ContentType = ContentTypes.Binary;

            return(message);
        }
Ejemplo n.º 26
0
 public void Publish(PublishMode mode, string languageName, string[] publishingTargets, bool deep, string sourceDatabaseName, string targetDatabaseName, string rootItemPath) {
     this.Invoke("Publish", new object[] {
                 mode,
                 languageName,
                 publishingTargets,
                 deep,
                 sourceDatabaseName,
                 targetDatabaseName,
                 rootItemPath});
 }
Ejemplo n.º 27
0
        public async Task <IActionResult> Index(string learnAimRef, string notionalNVQLevelv2, string awardOrgCode, string learnAimRefTitle, string learnAimRefTypeDesc, Guid?courseId, Guid courseRunId, PublishMode mode)
        {
            int?UKPRN;

            if (Session.GetInt32("UKPRN") != null)
            {
                UKPRN = Session.GetInt32("UKPRN").Value;
            }
            else
            {
                return(RedirectToAction("Index", "Home", new { errmsg = "Please select a Provider." }));
            }

            List <SelectListItem> courseRunVenues = new List <SelectListItem>();

            //VenueSearchCriteria criteria = new VenueSearchCriteria(UKPRN.ToString(), null);
            var venues = await GetVenuesByUkprn(UKPRN.Value);

            foreach (var venue in venues.VenueItems)
            {
                var item = new SelectListItem {
                    Text = venue.VenueName, Value = venue.Id
                };
                courseRunVenues.Add(item);
            }
            ;

            var regions = _courseService.GetRegions();

            Session.SetObject(SessionVenues, venues);
            Session.SetObject(SessionRegions, regions);

            if (courseId.HasValue)
            {
                var course = await _courseService.GetCourseByIdAsync(new GetCourseByIdCriteria(courseId.Value));

                var courseRun = course.Value.CourseRuns.SingleOrDefault(cr => cr.id == courseRunId);

                if (courseRun != null)
                {
                    EditCourseRunViewModel vm = new EditCourseRunViewModel
                    {
                        AwardOrgCode     = awardOrgCode,
                        LearnAimRef      = learnAimRef,
                        LearnAimRefTitle = learnAimRefTitle,

                        Mode         = mode,
                        CourseId     = courseId.Value,
                        CourseRunId  = courseRunId,
                        CourseName   = courseRun?.CourseName,
                        Venues       = courseRunVenues,
                        VenueId      = courseRun.VenueId ?? (Guid?)null,
                        ChooseRegion = new ChooseRegionModel
                        {
                            National = courseRun.DeliveryMode != DeliveryMode.WorkBased ? null : courseRun.National,
                            Regions  = regions
                        },
                        DeliveryMode = courseRun.DeliveryMode,

                        CourseProviderReference = courseRun?.ProviderCourseID,
                        DurationUnit            = courseRun.DurationUnit,
                        DurationLength          = courseRun?.DurationValue?.ToString(),
                        StartDateType           = courseRun.FlexibleStartDate
                            ? StartDateType.FlexibleStartDate
                            : StartDateType.SpecifiedStartDate,
                        Day                  = courseRun.StartDate?.Day.ToString("00"),
                        Month                = courseRun.StartDate?.Month.ToString("00"),
                        Year                 = courseRun.StartDate?.Year.ToString("0000"),
                        StudyMode            = courseRun.StudyMode,
                        Url                  = courseRun.CourseURL,
                        Cost                 = courseRun.Cost?.ToString("F"),
                        CostDescription      = courseRun.CostDescription,
                        AttendanceMode       = courseRun.AttendancePattern,
                        QualificationType    = course.Value.QualificationType,
                        NotionalNVQLevelv2   = course.Value.NotionalNVQLevelv2,
                        CurrentCourseRunDate = courseRun.StartDate
                    };

                    vm.ValPastDateRef     = DateTime.Now;
                    vm.ValPastDateMessage = "Start Date cannot be earlier than today’s date";

                    if (courseRun.Regions == null)
                    {
                        return(View("EditCourseRun", vm));
                    }

                    foreach (var selectRegionRegionItem in vm.ChooseRegion.Regions.RegionItems.OrderBy(x => x.RegionName))
                    {
                        //If Region is returned, check for existence of any subregions
                        if (courseRun.Regions.Contains(selectRegionRegionItem.Id))
                        {
                            var subregionsInList = from subRegion in selectRegionRegionItem.SubRegion
                                                   where courseRun.Regions.Contains(subRegion.Id)
                                                   select subRegion;

                            //If true, then ignore subregions
                            if (subregionsInList.Count() > 0)
                            {
                                foreach (var subRegion in subregionsInList)
                                {
                                    courseRun.Regions = courseRun.Regions.Where(x => (x != subRegion.Id)).ToList();
                                }
                            }
                            //If false, then tick all subregions
                            foreach (var subRegionItemModel in selectRegionRegionItem.SubRegion)
                            {
                                subRegionItemModel.Checked = true;
                            }
                        }
                        //Else, just tick the one subregion per item
                        else
                        {
                            foreach (var subRegionItemModel in selectRegionRegionItem.SubRegion)
                            {
                                if (courseRun.Regions.Contains(subRegionItemModel.Id))
                                {
                                    subRegionItemModel.Checked = true;
                                }
                            }
                        }
                    }

                    if (vm.ChooseRegion.Regions.RegionItems != null && vm.ChooseRegion.Regions.RegionItems.Any())
                    {
                        vm.ChooseRegion.Regions.RegionItems = vm.ChooseRegion.Regions.RegionItems.OrderBy(x => x.RegionName);
                        foreach (var selectRegionRegionItem in vm.ChooseRegion.Regions.RegionItems)
                        {
                            selectRegionRegionItem.SubRegion = selectRegionRegionItem.SubRegion.OrderBy(x => x.SubRegionName).ToList();
                        }
                    }

                    return(View("EditCourseRun", vm));
                }
            }

            //error page
            return(View("Error", new ErrorViewModel {
                RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
            }));
        }
Ejemplo n.º 28
0
 /// <remarks/>
 public void PublishAsync(PublishMode mode, string languageName, string[] publishingTargets, bool deep, string sourceDatabaseName, string targetDatabaseName, string rootItemPath, object userState) {
     if ((this.PublishOperationCompleted == null)) {
         this.PublishOperationCompleted = new System.Threading.SendOrPostCallback(this.OnPublishOperationCompleted);
     }
     this.InvokeAsync("Publish", new object[] {
                 mode,
                 languageName,
                 publishingTargets,
                 deep,
                 sourceDatabaseName,
                 targetDatabaseName,
                 rootItemPath}, this.PublishOperationCompleted, userState);
 }
Ejemplo n.º 29
0
 /// <remarks/>
 public void PublishAsync(PublishMode mode, string languageName, string[] publishingTargets, bool deep, string sourceDatabaseName, string targetDatabaseName, string rootItemPath) {
     this.PublishAsync(mode, languageName, publishingTargets, deep, sourceDatabaseName, targetDatabaseName, rootItemPath, null);
 }
        public IList <ImportLogEntry> Publish(Guid root, PublishMode mode = PublishMode.Smart,
                                              bool publishRelatedItems    = true,
                                              bool republishAll           = false)
        {
            var logs     = new List <ImportLogEntry>();
            var rootItem = this.SitecoreContext.Database?.GetItem(new ID(root));

            if (rootItem == null)
            {
                logs.Add(new ImportLogEntry {
                    Level = MessageLevel.Error, Message = $"Item {root} cannot be found"
                });
                return(logs);
            }

            try
            {
                logs.Add(new ImportLogEntry
                {
                    Level   = MessageLevel.Info,
                    Message =
                        $"Publishing item \"{rootItem.Paths.FullPath}\" [ID:{rootItem.ID}], pulishing mode: {mode}..."
                });
                var targetDatabase = Factory.GetDatabase(Constants.Sitecore.Databases.Web);
                var options        =
                    new PublishOptions(rootItem.Database, targetDatabase, mode, rootItem.Language, DateTime.Now)
                {
                    RootItem            = rootItem,
                    Deep                = true,
                    PublishRelatedItems = publishRelatedItems,
                    RepublishAll        = republishAll,
                };
                var sw = new Stopwatch();
                sw.Start();
                var publisher     = new Publisher(options);
                var publishResult = publisher.PublishWithResult();
                sw.Stop();
                var sb = new StringBuilder();
                sb.AppendLine($"Item  \"{rootItem.Name}\" [ID:{rootItem.ID}] has been published.\r\n");
                sb.AppendLine("Statistics:");
                sb.AppendLine($"Items skipped: {publishResult.Statistics.Skipped}");
                sb.AppendLine($"Items created: {publishResult.Statistics.Created}");
                sb.AppendLine($"Items updated: {publishResult.Statistics.Updated}");
                sb.AppendLine($"Items deleted: {publishResult.Statistics.Deleted}");
                sb.AppendLine($"Time taken: {sw.ElapsedMilliseconds} ms");
                logs.Add(new ImportLogEntry {
                    Level = MessageLevel.Info, Message = sb.ToString()
                });
            }
            catch (Exception exception)
            {
                logs.Add(new ImportLogEntry
                {
                    Level   = MessageLevel.Error,
                    Message =
                        $"An error has occurred while publishing an item \"{rootItem.Name}\" [ID:{rootItem.ID}]. Message: {exception.GetAllMessages()}"
                });
            }

            return(logs);
        }
 public static void Publish(Instance instance, Window owner, PublishMode mode)
 {
     WindowHelper.LongRunningTask(
         () => PublishAsync(instance), "Publish",
         owner, "Publish", $"Publish \'en\' language from \'master\' to \'web\' with mode {mode}");
 }
Ejemplo n.º 32
0
 public abstract void PublishGameObject(PublishMode mode, PublishPlatform platform);