public void SetStatus(PublishingStatus status, string message)
        {
            this.Status  = status;
            this.Message = message;

            switch (status)
            {
            case PublishingStatus.Waiting:
                this.ImageIndex = 0;
                break;

            case PublishingStatus.Publishing:
                break;

            case PublishingStatus.Succeeded:
                this.ImageIndex = 1;
                break;

            case PublishingStatus.Failed:
                this.ImageIndex = 2;
                break;

            default:
                break;
            }

            this.OnStatusChanged(status);
        }
Example #2
0
        /// <summary>
        /// Change the status
        /// </summary>
        /// <param name="officeId">office identifier</param>
        /// <param name="publishingStatus">publishing status</param>
        /// <returns></returns>
        public virtual bool ChangeStatus(Guid officeId, PublishingStatus publishingStatus)
        {
            Guard.IsNotEmpty(officeId, "officeId");

            // retrieve the client
            var branchOffice = GetById(officeId);

            if (branchOffice != null)
            {
                branchOffice.CurrentPublishingStatus = publishingStatus;
                branchOffice.UpdatedOn = DateTime.UtcNow;

                branchOffice.AuditHistory.Add
                (
                    userActivityService.InsertActivity(SystemActivityLogTypeNames.ChangePublishingStatus,
                        publishingStatus.GetFriendlyName(), StateKeyManager.BRANCHOFFICE_ACTIVITY_COMMENT, branchOffice.BranchName)
                );

                this.dataRepository.Update(branchOffice);
                this.cacheManager.RemoveByPattern(BRANCHOFFICE_PATTERN_KEY);
                //event notification
                this.eventPublisher.EntityUpdated(branchOffice);

                return true;
            }

            return false;
        }
 private void OnStatusChanged(PublishingStatus status)
 {
     if (StatusChanged != null)
     {
         StatusChanged(this, new PublishingVersionInfoEventArgs(status));
     }
 }
 public UserRegistrationRequest(string username,
     string password, PublishingStatus currentPublishingStatus  = PublishingStatus.Active)
 {
     this.Username = username;
     this.Password = password;
     this.CurrentPublishingStatus = currentPublishingStatus;
 }
Example #5
0
        public virtual bool ChangeStatus(Guid clientId, PublishingStatus publishingStatus)
        {
            Guard.IsNotEmpty(clientId, "clientId");

            // retrieve the client
            var client = GetById(clientId);

            if (client != null)
            {
                client.CurrentPublishingStatus = publishingStatus;
                client.UpdatedOn = DateTime.UtcNow;

                client.AuditHistory.Add
                (
                    userActivityService.InsertActivity(SystemActivityLogTypeNames.ChangePublishingStatus,
                        publishingStatus.GetFriendlyName(), StateKeyManager.CLIENT_ACTIVITY_COMMENT, client.ClientName)
                );

                this.clientRepository.Update(client);
                this.cacheManager.RemoveByPattern(CLIENTS_PATTERN_KEY);
                //event notification
                this.eventPublisher.EntityUpdated(client);

                return true;
            }

            return false;
        }
        /// <summary>
        /// Checks if publishing status is valid or not.
        /// Allowed updates for publishing status:
        /// Draft/null -> Draft or Published
        /// Published  -> Modified, Published, Archived
        /// Archived   -> Modified, Published, Archived
        /// </summary>
        /// <returns></returns>
        public override void Validate(ModelStateDictionary modelState)
        {
            PublishingStatus?newPublishingStatus = null;

            if (!string.IsNullOrEmpty(Model))
            {
                newPublishingStatus = Model.Parse <PublishingStatus>();
            }

            if (string.IsNullOrEmpty(currentStatus))
            {
                if (newPublishingStatus.HasValue && newPublishingStatus != PublishingStatus.Draft && newPublishingStatus != PublishingStatus.Published)
                {
                    modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.PublishingStatusNotValid, newPublishingStatus, currentStatus));
                }
                return;
            }

            PublishingStatus currentPublishingStatus = currentStatus.Parse <PublishingStatus>();

            switch (currentPublishingStatus)
            {
            case PublishingStatus.Draft:
                if (newPublishingStatus.HasValue && newPublishingStatus != PublishingStatus.Draft && newPublishingStatus != PublishingStatus.Published)
                {
                    modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.PublishingStatusNotValid, newPublishingStatus, currentStatus));
                }
                break;

            case PublishingStatus.Published:
                if (newPublishingStatus.HasValue && newPublishingStatus != PublishingStatus.Modified && newPublishingStatus != PublishingStatus.Published && newPublishingStatus != PublishingStatus.Deleted)
                {
                    modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.PublishingStatusNotValid, newPublishingStatus, currentStatus));
                }
                break;

            case PublishingStatus.Deleted:
                if (!newPublishingStatus.HasValue)
                {
                    modelState.AddModelError(PropertyName, $"You need to define Publishing status when current one is {currentStatus}.");
                    break;
                }
                if (newPublishingStatus.HasValue && newPublishingStatus != PublishingStatus.Modified && newPublishingStatus != PublishingStatus.Published && newPublishingStatus != PublishingStatus.Deleted)
                {
                    modelState.AddModelError(PropertyName, string.Format(CoreMessages.OpenApi.PublishingStatusNotValid, newPublishingStatus, currentStatus));
                }
                break;

            case PublishingStatus.Modified:
                modelState.AddModelError(PropertyName, "You cannot update entity with status Modified.");
                break;

            case PublishingStatus.OldPublished:
                modelState.AddModelError(PropertyName, "You cannot update entity with status OldPublished.");
                break;

            default:
                break;
            }
        }
Example #7
0
        private void InitDatabase(int numPubStatuses)
        {
            Assert.NotNull(_dbContext);

            for (int i = 1; i <= numPubStatuses; i++)
            {
                PublishingStatus newPublishingStatus = CreatePublishingStatus(i);
                _dbContext.PublishingStatuses.Add(newPublishingStatus);
            }

            _dbContext.SaveChanges();
        }
Example #8
0
 /// <summary>
 /// Gets all companies
 /// </summary>
 /// <param name="status">A value indicating which status records</param>
 /// <returns>Company collection</returns>
 public virtual IList<Company> GetAll(PublishingStatus status = PublishingStatus.Active)
 {
     string key = string.Format(COMPANY_ALL_KEY, status.ToString());
     return this.cacheManager.Get(key, () =>
     {
         var query = from c in this.companyRepository.Table
                     orderby c.CompanyName
                     where (status == PublishingStatus.All || c.CurrentPublishingStatusId == (int)status)
                     select c;
         var companies = query.ToList();
         return companies;
     });
 }
Example #9
0
        public void PublishingStatusRefContainsCorrectData(int numPubStatuses)
        {
            InitDatabase(numPubStatuses);

            for (int i = 1; i <= numPubStatuses; i++)
            {
                PublishingStatus        expected            = CreatePublishingStatus(i);
                PublishingStatusSummary PublishingStatusRef = _referenceData.PublishingStatuses.GetSummary(i);

                Assert.NotNull(PublishingStatusRef);
                Assert.Equal(expected.Id, PublishingStatusRef.Id);
                Assert.Equal(expected.Name, PublishingStatusRef.Name);
                Assert.Equal(expected.Description, PublishingStatusRef.Description);
            }
        }
Example #10
0
        public void PublishAlarmsEvents(AlarmHelper alarm, PublishingStatus status)
        {
            switch (status)
            {
            case PublishingStatus.INSERT:
            {
                AlarmsEventsEventArgs e = new AlarmsEventsEventArgs()
                {
                    Alarm = alarm
                };

                try
                {
                    AlarmEvent(this, e);
                }
                catch (Exception ex)
                {
                    string message = string.Format("AES does not have any subscribed client for publishing new alarms. {0}", ex.Message);
                    CommonTrace.WriteTrace(CommonTrace.TraceVerbose, message);
                    Console.WriteLine(message);
                }

                break;
            }

            case PublishingStatus.UPDATE:
            {
                alarm.PubStatus = PublishingStatus.UPDATE;
                AlarmUpdateEventArgs e = new AlarmUpdateEventArgs()
                {
                    Alarm = alarm
                };

                try
                {
                    AlarmUpdate(this, e);
                }
                catch (Exception ex)
                {
                    string message = string.Format("AES does not have any subscribed client for publishing alarm status change. {0}", ex.Message);
                    CommonTrace.WriteTrace(CommonTrace.TraceVerbose, message);
                    Console.WriteLine(message);
                }
                break;
            }
            }
        }
 private void ExtractPublisingStatus(XmlNode listOfNode, ref Book book)
 {
     try
     {
         var publishingStatus = listOfNode.SelectSingleNode("PublishingStatus");
         if (publishingStatus != null)
         {
             if (publishingStatus != null)
             {
                 book.PublishStatus = PublishingStatus.GetPublishStatus(publishingStatus.InnerText);
             }
         }
     }
     catch (Exception ex)
     {
         BooksImportLog.Error("Extract publishing status data failed. Node data: " + listOfNode.ToString(), ex);
     }
 }
Example #12
0
        public void GetLatestService(PublishingStatus publishingStatus)
        {
            // Arrange
            var item   = _list.Where(i => i.PublishingStatusId == PublishingStatusCache.Get(publishingStatus)).FirstOrDefault();
            var rootId = item.UnificRootId;
            var id     = item.Id;

            VersioningManagerMock.Setup(s => s.GetVersionId <ServiceVersioned>(unitOfWorkMockSetup.Object, rootId, null, false)).Returns(id);
            var service = Arrange();

            // Act
            var result = service.GetServiceById(rootId, 7, VersionStatusEnum.Latest);

            // Assert
            result.Should().NotBeNull();
            var vmResult = Assert.IsType <V7VmOpenApiService>(result);

            vmResult.PublishingStatus.Should().Be(publishingStatus.ToString());
            VersioningManagerMock.Verify(x => x.GetVersionId <ServiceVersioned>(unitOfWorkMockSetup.Object, rootId, null, false), Times.Once);
        }
        public void GetLatestActiveServiceChannel(PublishingStatus publishingStatus)
        {
            // Arrange
            var channelType = ServiceChannelTypeEnum.ServiceLocation;
            var item        = _channelList.Where(i => i.PublishingStatusId == PublishingStatusCache.Get(publishingStatus)).FirstOrDefault();

            item.TypeId = TypeCache.Get <ServiceChannelType>(channelType.ToString());
            var rootId = item.UnificRootId;
            var id     = item.Id;

            VersioningManagerMock.Setup(s => s.GetVersionId <ServiceChannelVersioned>(unitOfWorkMockSetup.Object, rootId, null, true))
            .Returns(() =>
            {
                if (publishingStatus == PublishingStatus.Deleted || publishingStatus == PublishingStatus.OldPublished)
                {
                    return(null);
                }

                return(id);
            });

            var service = Arrange(channelType);

            // Act
            var result = service.GetServiceChannelById(rootId, 7, VersionStatusEnum.LatestActive);

            // Assert
            // Method should only return draft, modified or published versions.
            VersioningManagerMock.Verify(x => x.GetVersionId <ServiceChannelVersioned>(unitOfWorkMockSetup.Object, rootId, null, true), Times.Once);
            if (publishingStatus == PublishingStatus.Draft || publishingStatus == PublishingStatus.Modified || publishingStatus == PublishingStatus.Published)
            {
                result.Should().NotBeNull();
                var vmResult = Assert.IsType <V7VmOpenApiServiceLocationChannel>(result);
                vmResult.PublishingStatus.Should().Be(publishingStatus.ToString());
            }
            else
            {
                result.Should().BeNull();
            }
        }
Example #14
0
        protected IList<SelectListItem> PrepareSelectList(IUserService userService, ICacheManager cacheManager,
            Guid selectedUserId, PublishingStatus status = PublishingStatus.Active)
        {
            string cacheKey = ModelCacheEventUser.USERS_MODEL_KEY.FormatWith(
                "SelectList.{0}".FormatWith(status.ToString()));

            var cacheModel = cacheManager.Get(cacheKey, () =>
            {
                var users = userService.GetAll(status)
                    .Select(user =>
                    {
                        return new SelectListItem()
                        {
                            Value = user.RowId.ToString(),
                            Text = user.GetFullName(),
                            Selected = user.RowId.Equals(selectedUserId)
                        };
                    })
                    .ToList();

                return users;
            });

            return cacheModel;
        }
Example #15
0
 private void SetPublishingVersionStatus(PublishingVersionInfo info, PublishingStatus status)
 {
     this.SetPublishingVersionStatus(info, status, string.Empty);
 }
Example #16
0
        public void AddAlarm(AlarmHelper alarm)
        {
            bool normalAlarm = false;

            if (Alarms.Count == 0 && alarm.Type.Equals(AlarmType.NORMAL))
            {
                return;
            }

            PublishingStatus publishingStatus = PublishingStatus.INSERT;
            bool             updated          = false;

            try
            {
                alarm.AckState = AckState.Unacknowledged;
                if (string.IsNullOrEmpty(alarm.CurrentState))
                {
                    alarm.CurrentState = string.Format("{0} | {1}", State.Active, alarm.AckState);
                }

                // cleared status check
                foreach (AlarmHelper item in Alarms)
                {
                    if (item.Gid.Equals(alarm.Gid) && item.CurrentState.Contains(State.Active.ToString()))
                    {
                        item.Severity    = alarm.Severity;
                        item.Value       = alarm.Value;
                        item.Message     = alarm.Message;
                        item.TimeStamp   = alarm.TimeStamp;
                        publishingStatus = PublishingStatus.UPDATE;
                        updated          = true;
                        break;
                    }
                    else if (item.Gid.Equals(alarm.Gid) && item.CurrentState.Contains(State.Cleared.ToString()))
                    {
                        if (alarm.Type.Equals(AlarmType.NORMAL) && !item.Type.Equals(AlarmType.NORMAL.ToString()))
                        {
                            bool normalCreated = false;
                            if (this.isNormalCreated.TryGetValue(alarm.Gid, out normalCreated))
                            {
                                if (!normalCreated)
                                {
                                    normalAlarm = true;
                                }
                            }

                            break;
                        }
                    }
                }

                // ako je insert dodaj u listu - inace je updateovan
                if (publishingStatus.Equals(PublishingStatus.INSERT) && !updated && !alarm.Type.Equals(AlarmType.NORMAL))
                {
                    if (alarm.Type != AlarmType.DOM)
                    {
                        RemoveFromAlarms(alarm.Gid);
                        this.Alarms.Add(alarm);
                        if (InsertAlarmIntoDb(alarm))
                        {
                            Console.WriteLine("Alarm with GID:{0} recorded into alarms database.", alarm.Gid);
                        }
                        this.isNormalCreated[alarm.Gid] = false;
                    }
                    else
                    {
                        this.Alarms.Add(alarm);
                        if (InsertAlarmIntoDb(alarm))
                        {
                            Console.WriteLine("Alarm with GID:{0} recorded into alarms database.", alarm.Gid);
                        }
                        this.isNormalCreated[alarm.Gid] = false;
                    }
                }
                if (alarm.Type.Equals(AlarmType.NORMAL) && normalAlarm)
                {
                    RemoveFromAlarms(alarm.Gid);
                    this.Alarms.Add(alarm);
                    this.Publisher.PublishAlarmsEvents(alarm, publishingStatus);
                    this.isNormalCreated[alarm.Gid] = true;
                }
                else if (!alarm.Type.Equals(AlarmType.NORMAL))
                {
                    this.Publisher.PublishAlarmsEvents(alarm, publishingStatus);
                }

                //Console.WriteLine("AlarmsEvents: AddAlarm method");
                string message = string.Format("Alarm on Analog Gid: {0} - Value: {1}", alarm.Gid, alarm.Value);
                CommonTrace.WriteTrace(CommonTrace.TraceInfo, message);
            }
            catch (Exception ex)
            {
                string message = string.Format("Greska ", ex.Message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
                //throw new Exception(message);
            }
        }
Example #17
0
        /// <summary>
        /// Get versioned entity with specific publishing status.
        /// </summary>
        /// <typeparam name="TEntityType">Type of entity which will be filtered</typeparam>
        /// <param name="unitOfWork">Instance of unit of work</param>
        /// <param name="entity">Instance of entity which is used as input for searching specific version</param>
        /// <param name="publishingStatus">Searching criteria for publishing status</param>
        /// <returns></returns>
        public TEntityType GetSpecificVersion <TEntityType>(ITranslationUnitOfWork unitOfWork, TEntityType entity, PublishingStatus publishingStatus) where TEntityType : class, IVersionedVolume, new()
        {
            var publishingStatusId = PublishingStatuses[publishingStatus];

            if (entity.PublishingStatusId == publishingStatusId)
            {
                return(entity);
            }
            return(GetSpecificVersionByRoot <TEntityType>(unitOfWork, entity.UnificRootId, publishingStatus));
        }
Example #18
0
 private void SetPublishingVersionStatus(PublishingVersionInfo info, PublishingStatus status, string error)
 {
     info.SetStatus(status, error);
 }
Example #19
0
        /// <summary>
        /// Publish specified entity, check latest version and create new version with published state
        /// </summary>
        /// <typeparam name="TEntityType">Type of entity which will be promoted to published state</typeparam>
        /// <param name="unitOfWork">Unit Of Work</param>
        /// <param name="entity">Entity which will be promoted to published state</param>
        /// <param name="targetPublishingStatus">Entity which will be promoted to published state</param>
        public IList <PublishingAffectedResult> PublishVersion <TEntityType>(ITranslationUnitOfWork unitOfWork, TEntityType entity, PublishingStatus targetPublishingStatus = PublishingStatus.Published) where TEntityType : class, IVersionedVolume, new()
        {
            var entitySet     = unitOfWork.GetSet <TEntityType>();
            var allVersions   = GetAllVersions(unitOfWork, entity);
            var currentLatest = allVersions.LastOrDefault() ?? new VersionInfo();
            var result        = new List <PublishingAffectedResult>();

            if ((currentLatest.PublishingStatusId == PublishingStatuses[targetPublishingStatus]) && (currentLatest.VersionId == entity.VersioningId))
            {
                logger.LogDebug($"Publishing not needed, already in desired target publishing state. {entity.GetType().Name}, Id: {entity.Id}");
                return(result);
            }
            Guid?originVersioning = null;

            if (targetPublishingStatus == PublishingStatus.Published)
            {
                var previousPublishedVersion = allVersions.LastOrDefault(i => i.PublishingStatusId == PublishingStatuses[PublishingStatus.Published]);
                originVersioning = previousPublishedVersion?.VersionId;
                if (previousPublishedVersion != null)
                {
                    var previousEntity = entitySet.FirstOrDefault(i => i.Id == previousPublishedVersion.EntityId);
                    result.Add(new PublishingAffectedResult()
                    {
                        Id = previousEntity.Id,
                        PublishingStatusOld = previousEntity.PublishingStatusId,
                        PublishingStatusNew = PublishingStatuses[PublishingStatus.OldPublished]
                    });
                    previousEntity.PublishingStatus   = null;
                    previousEntity.PublishingStatusId = PublishingStatuses[PublishingStatus.OldPublished];
                }
                currentLatest.VersionMajor++;
                currentLatest.VersionMinor = 0;
            }
            else
            {
                if (targetPublishingStatus == PublishingStatus.Modified)
                {
                    if (allVersions.Any(i => i.PublishingStatusId == PublishingStatuses[PublishingStatus.Modified]))
                    {
                        throw new PublishModifiedExistsException();
                    }
                    currentLatest.VersionMinor++;
                    var versioningSet = unitOfWork.GetSet <Versioning>();
                    originVersioning = entity.VersioningId != null?versioningSet.Where(i => i.Id == entity.VersioningId).Select(i => i.PreviousVersionId).FirstOrDefault() : null;
                }
                else
                {
                    throw new InvalidOperationException($"It is not allowed to 'publish' entity to {targetPublishingStatus} state.");
                }
            }
            result.Add(new PublishingAffectedResult()
            {
                Id = entity.Id, PublishingStatusOld = entity.PublishingStatusId, PublishingStatusNew = PublishingStatuses[targetPublishingStatus]
            });
            entity.PublishingStatus   = null;
            entity.PublishingStatusId = PublishingStatuses[targetPublishingStatus];
            SetVersioning(entity, unitOfWork.GetSet <Versioning>(), currentLatest, originVersioning);
            return(result);
        }
Example #20
0
        /// <summary>
        /// Get versioned entity with specific publishing status.
        /// </summary>
        /// <typeparam name="TEntityType">Type of entity which will be filtered</typeparam>
        /// <param name="unitOfWork">Instance of unit of work</param>
        /// <param name="rootId">ID of unific root which is used as input for searching its specific version</param>
        /// <param name="publishingStatus">Searching criteria for publishing status</param>
        /// <returns></returns>
        public TEntityType GetSpecificVersionByRoot <TEntityType>(ITranslationUnitOfWork unitOfWork, Guid rootId, PublishingStatus publishingStatus) where TEntityType : class, IVersionedVolume, new()
        {
            var publishingStatusId = PublishingStatuses[publishingStatus];
            var entityRep          = unitOfWork.GetSet <TEntityType>();

            return(entityRep.FirstOrDefault(i => i.UnificRootId == rootId && i.PublishingStatusId == publishingStatusId));
        }
Example #21
0
        protected IList<SelectListItem> PrepareSelectList(IBranchOfficeService officeService, ICacheManager cacheManager,
            PublishingStatus status = PublishingStatus.Active)
        {
            string cacheKey = ModelCacheEventUser.OFFICE_MODEL_KEY.FormatWith(
                "SelectList.{0}".FormatWith(status.ToString()));

            var cacheModel = cacheManager.Get(cacheKey, () =>
            {
                var offices = officeService.GetAll(status)
                    .Select(office =>
                    {
                        return new SelectListItem()
                        {
                            Value = office.RowId.ToString(),
                            Text = office.BranchName
                        };
                    })
                    .ToList();

                return offices;
            });

            return cacheModel;
        }
Example #22
0
        /// <summary>
        /// Shows the status.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        private void ShowStatus(PublishingStatus message)
        {
            var stageVm = Stages.FirstOrDefault(vm => vm.Stage.ToString() == message.Stage);
            if (stageVm == null)
                return;

            stageVm.Progress = (PublishingProgress)Enum.Parse(typeof(PublishingProgress), message.Progress, true);

            switch (stageVm.Progress)
            {
                case PublishingProgress.InProgress:
                    stageVm.StatusText = string.IsNullOrWhiteSpace(message.StatusText) ? "In Progress..." : message.StatusText;
                    break;
                case PublishingProgress.Success:
                    stageVm.StatusText = "Succeeded" + (string.IsNullOrWhiteSpace(message.StatusText) ? "." : (": " + message.StatusText));
                    break;
                case PublishingProgress.Cancelled:
                    stageVm.StatusText = "Cancelled";
                    break;
                case PublishingProgress.Failure:
                    stageVm.StatusText = "Failed" + (string.IsNullOrWhiteSpace(message.StatusText) ? "." : (": " + message.StatusText));
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            RaisePropertyChanged(() => IsCompleted);
            RaisePropertyChanged(() => ReadyToClose);
            RaisePropertyChanged(() => ReadyToReload);
            RaisePropertyChanged(() => CancelVisible);

            WorkCompleted = Stages.Count(s => s.Progress == PublishingProgress.Success);
            RaisePropertyChanged(() => ProgressText);

            if (IsCompleted)
            {
                UnsubscribeFromStatusNotification();
            }
        }
Example #23
0
        /// <summary>
        /// Change publishing status of language version of specific entity which is of IMultilanguagedEntity type
        /// </summary>
        /// <typeparam name="T">Type of entity</typeparam>
        /// <typeparam name="TLang">Type of langauge version relation</typeparam>
        /// <param name="unitOfWork">Unit of work instance</param>
        /// <param name="entity">Entity to change</param>
        /// <param name="publishingStatusTo">Target publishing status of language version</param>
        /// <param name="publishingStatusFrom">Input criteria for selecting the language versions which will be switched</param>
        /// <param name="languageGuids">Input criteria for selecting the language versions which will be switched</param>
        public void ChangeStatusOfLanguageVersion <T, TLang>(ITranslationUnitOfWork unitOfWork, T entity, PublishingStatus publishingStatusTo, IEnumerable <PublishingStatus> publishingStatusFrom = null, IEnumerable <Guid> languageGuids = null) where T : class, IMultilanguagedEntity <TLang>, new() where TLang : class, ILanguageAvailability
        {
            if (entity == null)
            {
                return;
            }
            unitOfWork.LoadNavigationProperty(entity, i => i.LanguageAvailabilities);
            var publishingStatusToId = PublishingStatuses[publishingStatusTo];
            var applyOn = languageGuids == null ? entity.LanguageAvailabilities : entity.LanguageAvailabilities.Where(i => languageGuids.Contains(i.LanguageId));

            publishingStatusFrom?.ForEach(status =>
            {
                var publishingStatusFromId = PublishingStatuses[status];
                applyOn = applyOn.Where(i => i.StatusId == publishingStatusFromId);
            });
            applyOn.ForEach(i => i.StatusId = publishingStatusToId);
        }
Example #24
0
 public Guid Get(PublishingStatus publishingStatus)
 {
     return(Get(publishingStatus.ToString()));
 }
Example #25
0
 public PublishingVersionInfoEventArgs(PublishingStatus status)
 {
     this._status = status;
 }
        /// <summary>
        /// Change the status
        /// </summary>
        /// <param name="userId">user identifier</param>
        /// <param name="publishingStatus">publishing status</param>
        /// <returns></returns>
        public virtual bool ChangeStatus(Guid userId, PublishingStatus publishingStatus)
        {
            Guard.IsNotEmpty(userId, "userId");

            // retrieve the client
            var user = userService.GetById(userId);

            if (user != null &&
                user.CurrentPublishingStatus != PublishingStatus.PendingApproval)
            {
                user.CurrentPublishingStatus = publishingStatus;

                user.AuditHistory.Add
                (
                    userActivityService.InsertActivity(SystemActivityLogTypeNames.ChangePublishingStatus,
                        publishingStatus.GetFriendlyName(), StateKeyManager.USER_ACTIVITY_COMMENT, user.Username)
                );

                userService.Update(user);

                return true;
            }

            return false;
        }
Example #27
0
 /// <summary>
 /// Gets all branch offices
 /// </summary>
 /// <returns>Office collection</returns>
 public virtual IList<BranchOffice> GetAll(PublishingStatus status = PublishingStatus.Active)
 {
     string key = string.Format(BRANCHOFFICE_ALL_KEY, status.ToString());
     return this.cacheManager.Get(key, () =>
     {
         var query = from c in this.dataRepository.Table
                     orderby c.BranchName
                     where (status == PublishingStatus.All || c.CurrentPublishingStatusId == (int)status)
                     select c;
         var offices = query.ToList();
         return offices;
     });
 }