Beispiel #1
0
        public AddEditStatusModel(AddEditIssueStatusDialog view)
        {
            mIssueStatus = new IssueStatus();
            View = view;
            SelectedIssueType = IssueTypes[0];

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, CanExecuteOkButtonHandler);
        }
Beispiel #2
0
        public AddEditStatusModel(int issueStatusId)
        {
            if (DesignerProperties.IsInDesignTool) { return; }

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            mIssueStatus = new IssueStatus();
            mIssueStatus.Id = issueStatusId;

            cmsWebServiceClient.GetIssueStatusCompleted += cmsWebServiceClient_GetIssueStatusCompleted;
            cmsWebServiceClient.GetIssueStatusAsync(mIssueStatus.Id);

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, CanExecuteOkButtonHandler);
        }
 public IssueWorkflowViewModel(IssueStatus issueStatus, IssueType issueType)
 {
     mIssueStatus = issueStatus;
     mIssueType = issueType;
     LoadData();
 }
        public void GetAvailableStatuses(bool callSetUpChanges = false)
        {
            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            EventHandler<GetAvailableStatusesCompletedEventArgs> handler = null;

            handler = (s, e) =>
            {
                mStatuses = new List<IssueStatus>();
                foreach (IssueStatus issueStatus in CMS.Cache.IssueStatuses.Where(x => x.IsActive))
                {
                    var matchingStatus = e.Result.FirstOrDefault(x => x.AvailableStatusId == issueStatus.Id && x.IssueTypeId == mIssue.IssueTypeId);

                    if (matchingStatus != null && matchingStatus.IsVisible)
                    {
                        IssueStatus newIssueStatus = new IssueStatus
                        {
                            Id = issueStatus.Id,
                            Name = issueStatus.Name,
                            IsEnabled = matchingStatus.IsEnabled,
                            DisableWorkflow = matchingStatus.IssueStatus.DisableWorkflow
                        };
                        mStatuses.Add(newIssueStatus);
                    }
                }
                RaisePropertyChanged("Statuses");
                RaisePropertyChanged("SelectedStatus");

                if (callSetUpChanges)
                {
                    Utils.SetUpChangeEvents(View, EventAggregator, mIssue);
                }

                cmsWebServiceClient.GetAvailableStatusesCompleted -= handler;

                mAvailableStatusesLoaded = true;

                OnModelLoaded();

                OnGetAvailableStatusesLoaded();

            };

            cmsWebServiceClient.GetAvailableStatusesCompleted += handler;
            cmsWebServiceClient.GetAvailableStatusesAsync(mIssue.IssueStatusId);
        }
Beispiel #5
0
        public void ImportIssueStatus()
        {
            mForm.AddMessage(MessageType.Info, "-------------------- Importing Issue Status --------------------");
            List<Status> Statuss = (from x in mOldIssuesDataContext.Status select x).ToList();

            foreach (var Status in Statuss)
            {
                IssueStatus newStatus = new IssueStatus()
                {
                    Name = Status.Name,
                    Ordinal = Status.Ordinal
                };

                var statusExist = (from x in mCee.IssueStatuses where x.Name == newStatus.Name select x).FirstOrDefault();

                if (statusExist == null)
                {
                    string message = String.Format("Adding Issue Status '{0}'", newStatus.Name);
                    mForm.AddMessage(MessageType.Info, message);
                    mCee.IssueStatuses.AddObject(newStatus);
                }
                else
                {
                    string message = String.Format("Issue Status '{0}' already exist, skipping", statusExist.Name);
                    mForm.AddMessage(MessageType.Warning, message);
                }
            }
            mCee.SaveChanges();
        }
Beispiel #6
0
        void cmsWebServiceClient_GetIssueStatusCompleted(object sender, GetIssueStatusCompletedEventArgs e)
        {
            mIssueStatus = e.Result;

            //Enable all items (if they are in the database that means they are enabled
            if (mIssueStatus.StatusTypeRules != null)
            {
                mIssueStatus.StatusTypeRules.ForEach(x => x.IsEnabled = true);
            }
            if (mIssueStatus.StatusTypeEnabledControls != null)
            {
                mIssueStatus.StatusTypeEnabledControls.ForEach(x => x.IsEnabled = true);
            }
            //mIssueStatus.StatusTypeStatuses.ForEach(x => x.IsEnabled = true);

            RaisePropertyChanged("Name");
            RaisePropertyChanged("Ordinal");
            RaisePropertyChanged("IsActive");
            SelectedIssueType = IssueTypes[0];
        }
        public IssueStatus SaveIssueStatus(IssueStatus issueStatus)
        {
            IssueStatus issueStatusToUpdate = null;
            try
            {
                using (var cee = new CmsEntities())
                {
                    //Check if the object exist
                    issueStatusToUpdate = (from x in cee.IssueStatuses where x.Id == issueStatus.Id select x).FirstOrDefault();

                    int issueStatusId = issueStatus.Id;

                    if (issueStatusToUpdate == null)
                    {
                        //Create new Issue Status
                        issueStatusToUpdate = new IssueStatus
                        {
                            Name = issueStatus.Name,
                            Ordinal = issueStatus.Ordinal,
                            Code = issueStatus.Name.Replace(" ", ""),
                            IsActive = issueStatus.IsActive,
                            DisableWorkflow = issueStatus.DisableWorkflow
                        };

                        cee.IssueStatuses.Add(issueStatusToUpdate);
                        cee.SaveChanges();
                        issueStatusId = issueStatusToUpdate.Id;
                    }
                    else
                    {
                        //Update existing Status
                        issueStatusToUpdate.Name = issueStatus.Name;
                        issueStatusToUpdate.Ordinal = issueStatus.Ordinal;
                        issueStatusToUpdate.IsActive = issueStatus.IsActive;
                        issueStatusToUpdate.DisableWorkflow = issueStatus.DisableWorkflow;

                        //Delete Rules
                        cee.DeleteWhere<StatusTypeRule>(cee, x => x.StatusId == issueStatus.Id);

                        //Delete Issue Control Statuses
                        cee.DeleteWhere<StatusTypeEnabledControl>(cee, x => x.IssueStatusId == issueStatus.Id);

                        //Delete Issue Available Statuses
                        cee.DeleteWhere<StatusTypeAvailableStatus>(cee, x => x.StatusId == issueStatus.Id);
                    }

                    //Update Rules
                    foreach (StatusTypeRule issueStatusRule in issueStatus.StatusTypeRules)
                    {
                        StatusTypeRule newStatusTypeRule = new StatusTypeRule
                        {
                            RuleName = issueStatusRule.RuleName,
                            StatusId = issueStatusId,
                            IssueTypeId = issueStatusRule.IssueTypeId
                        };
                        issueStatusToUpdate.StatusTypeRules.Add(newStatusTypeRule);
                    }

                    //Update Issue Control Statuses
                    foreach (StatusTypeEnabledControl issueStatuesControl in issueStatus.StatusTypeEnabledControls)
                    {
                        StatusTypeEnabledControl newStatusTypeEnabledControl = new StatusTypeEnabledControl
                        {
                            IssueStatusId = issueStatusId,
                            IssueTypeId = issueStatuesControl.IssueTypeId,
                            IssueTabControlId = issueStatuesControl.IssueTabControlId
                        };
                        issueStatusToUpdate.StatusTypeEnabledControls.Add(newStatusTypeEnabledControl);
                    }

                    //Update Issue Available Statuses
                    foreach (StatusTypeAvailableStatus issueAvailableStatus in issueStatus.StatusTypeAvailableStatuses)
                    {
                        StatusTypeAvailableStatus newStatusTypeAvailableStatus = new StatusTypeAvailableStatus
                        {
                            StatusId = issueStatusId,
                            IssueTypeId = issueAvailableStatus.IssueTypeId,
                            AvailableStatusId = issueAvailableStatus.AvailableStatusId,

                            IsEnabled = issueAvailableStatus.IsEnabled,
                            IsVisible = issueAvailableStatus.IsVisible
                        };
                        issueStatusToUpdate.StatusTypeAvailableStatuses.Add(newStatusTypeAvailableStatus);
                    }
                    cee.SaveChanges();
                }
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var validationErrors in ex.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        log.Error("", ex, "Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("", ex, "Error in SaveIssueStatus()");
            }
            return issueStatusToUpdate;
        }