Example #1
0
        private static bool ChangeWorkItemState(IWorkItem workItem, string orginalSourceState, string destState, string comment, ILogEvents logger)
        {
            // Try to save the new state.  If that fails then we also go back to the original state.
            try
            {
                workItem.TryOpen();
                workItem.Fields["State"].Value = destState;
                workItem.History = comment;

                logger.AttemptingToMoveWorkItemToState(workItem, orginalSourceState, destState);
                if (workItem.IsValid())
                {
                    logger.WorkItemIsValidToSave(workItem);
                }
                else
                {
                    logger.WorkItemIsInvalidInState(workItem, destState);
                }

                workItem.Save();
                return(true);
            }
            catch (Exception)
            {
                // Revert back to the original value.
                workItem.Fields["State"].Value = orginalSourceState;
                return(false);
            }
        }
Example #2
0
        private static bool ChangeWorkItemState(IWorkItem workItem, string orginalSourceState, string destState, string comment, ILogEvents logger)
        {
            // Try to save the new state.  If that fails then we also go back to the original state.
            try
            {
                workItem.TryOpen();
                workItem.Fields["State"].Value = destState;
                workItem.History = comment;

                logger.AttemptingToMoveWorkItemToState(workItem, orginalSourceState, destState);
                if (workItem.IsValid())
                {
                    logger.WorkItemIsValidToSave(workItem);
                }
                else
                {
                    logger.WorkItemIsInvalidInState(workItem, destState);
                }

                workItem.Save();
                return true;
            }
            catch (Exception)
            {
                // Revert back to the original value.
                workItem.Fields["State"].Value = orginalSourceState;
                return false;
            }
        }