Example #1
0
 private DialogResult WantsToSetArticleDateToNow(ArticleWorkflowCommand command)
 {
     if (command != null && command.SendsToFinal)
     {
         const string            messageBoxText = "Your Scheduled Article Publish Date is in the past, update to the current date and time?";
         const MessageBoxButtons buttons        = MessageBoxButtons.YesNoCancel;
         return(MessageBox.Show(messageBoxText, "Update publish date?", buttons, MessageBoxIcon.Question));
     }
     return(DialogResult.No);
 }
Example #2
0
        public ArticleWorkflowState GetWorkFlowState(Guid articleId)
        {
            var item = _sitecoreMasterService.GetItem <Item>(articleId);

            if (item?.State?.GetWorkflowState() == null)
            {
                return(null);
            }
            var currentState = item.State.GetWorkflowState();

            Sitecore.Workflows.IWorkflow workflow = item.State.GetWorkflow();
            var workFlowState = new ArticleWorkflowState();

            workFlowState.IsFinal     = currentState.FinalState;
            workFlowState.DisplayName = currentState.DisplayName;
            var commands = new List <ArticleWorkflowCommand>();

            foreach (Sitecore.Workflows.WorkflowCommand command in workflow.GetCommands(item))
            {
                var wfCommand = new ArticleWorkflowCommand();
                wfCommand.DisplayName = command.DisplayName;
                wfCommand.StringID    = command.CommandID;
                ICommand commandItem   = _sitecoreMasterService.GetItem <ICommand>(new Guid(command.CommandID));
                IState   nextStateItem = _sitecoreMasterService.GetItem <IState>(commandItem.Next_State);

                if (nextStateItem != null)
                {
                    wfCommand.SendsToFinal     = nextStateItem.Final;
                    wfCommand.GlobalNotifyList = new List <StaffStruct>();
                    foreach (var staff in nextStateItem.Staffs)
                    {
                        var staffItem = _sitecoreMasterService.GetItem <IStaff_Item>(staff._Id);
                        if (staffItem.Inactive)
                        {
                            continue;
                        }
                        var staffMember = new StaffStruct
                        {
                            ID   = staffItem._Id,
                            Name = staffItem.Last_Name + " , " + staffItem.First_Name
                        };
                        //   staffMember.Publications = staff  //TODO :Check if this field if we need this field.
                        wfCommand.GlobalNotifyList.Add(staffMember);
                    }
                    commands.Add(wfCommand);
                }
            }
            workFlowState.Commands = commands;

            return(workFlowState);
        }
Example #3
0
        public bool IsValidArticleDate(ArticleStruct articleDetails, ArticleWorkflowCommand command)
        {
            var articleDate = articleDetails.WebPublicationDate;

            if (articleDate < DateTime.Now)
            {
                var result = WantsToSetArticleDateToNow(command);
                if (result == DialogResult.Yes)
                {
                    articleDetails.WebPublicationDate = DateTime.Now;
                    return(true);
                }
                else if (result == DialogResult.Cancel)
                {
                    MessageBox.Show("Save cancelled.");
                    return(false);
                }
            }

            return(true);
        }