예제 #1
0
 private void ContactsViewModel_OnSaveComplete(string result)
 {
     if (result == null)
     {
         Contacts.Reset();
         Contacts.Refresh();
     }
     ErrorMessage.SetValue(result);
 }
예제 #2
0
        public Action DeleteCommand()
        {
            if (_deleteCommand == null)
            {
                _deleteCommand = delegate()
                {
                    // Delete all selected jobs in grid
                    SelectedRange[] ranges = JobsViewModel.GetSelectedRows();
                    List <int>      rows   = DataViewBase.RangesToRows(ranges);

                    bool confirmed = Script.Confirm(String.Format("Are you sure you want to delete these {0} job(s)?", rows.Count));
                    if (!confirmed)
                    {
                        return;
                    }



                    IsBusy.SetValue(true);
                    DelegateItterator.CallbackItterate(delegate(int index, Action nextCallback, ErrorCallBack errorCallBack)
                    {
                        dev1_ScheduledJob job = (dev1_ScheduledJob)this.JobsViewModel.GetItem(rows[index]);
                        // First delete the scheduled jobs associated
                        DeleteBulkDeleteJobs(job.dev1_ScheduledJobId, delegate(){
                            OrganizationServiceProxy.BeginDelete(dev1_ScheduledJob.EntityLogicalName, job.dev1_ScheduledJobId, delegate(object result)
                            {
                                try
                                {
                                    OrganizationServiceProxy.EndDelete(result);
                                    IsBusyProgress.SetValue((index / rows.Count) * 100);
                                    nextCallback();
                                }
                                catch (Exception ex)
                                {
                                    errorCallBack(ex);
                                }
                            });
                        });
                    },
                                                       rows.Count,
                                                       delegate()
                    {
                        // Completed
                        IsBusy.SetValue(false);
                        JobsViewModel.Reset();
                        JobsViewModel.Refresh();
                    },
                                                       delegate(Exception ex)
                    {
                        // Error
                        ReportError(ex);
                    });
                };
            }
            return(_deleteCommand);
        }
 private void ConnectionsViewModel_OnSaveComplete(string result)
 {
     if (result == null)
     {
         // Saved OK
         Connections.Reset();
         Connections.Refresh();
     }
     ErrorMessage.SetValue(result);
 }
예제 #4
0
 void ContactViewModel_OnSaveComplete(string result)
 {
     if (result == null)
     {
         ErrorMessage.SetValue(null);
         Contacts.Reset();
         Contacts.Refresh();
     }
     else
     {
         ErrorMessage.SetValue(result);
     }
 }
        public Action SaveSelectedContact()
        {
            if (_saveSelectedContact == null)
            {
                _saveSelectedContact = delegate()
                {
                    if (((IValidatedObservable)SelectedContact).IsValid())
                    {
                        Contact           contact         = SelectedContact.GetValue().Commit();
                        ObservableContact selectedContact = SelectedContact.GetValue();

                        if (selectedContact.EntityState.GetValue() == EntityStates.Created)
                        {
                            this.Contacts.AddItem(contact);

                            // Move to the last page
                            PagingInfo paging = this.Contacts.GetPagingInfo();

                            SelectedRange[] newRow = new SelectedRange[1];
                            newRow[0]         = new SelectedRange();
                            newRow[0].FromRow = paging.TotalRows - ((paging.TotalPages - 1) * paging.PageSize) - 1;
                            this.Contacts.RaiseOnSelectedRowsChanged(newRow);
                            selectedContact.EntityState.SetValue(EntityStates.Changed);
                        }
                        else
                        {
                            Contacts.Refresh();
                        }
                    }
                    else
                    {
                        Script.Literal("{0}.errors.showAllMessages()", SelectedContact);
                    }
                };
            }
            return(_saveSelectedContact);
        }
예제 #6
0
        void jobsViewModel_OnSelectedRowsChanged()
        {
            // Get the selected bulk delete
            SelectedRange[] selectedRows = JobsViewModel.GetSelectedRows();
            if (selectedRows.Length > 0)
            {
                ScheduledJob job = SelectedJob.GetValue();

                dev1_ScheduledJob item = (dev1_ScheduledJob)JobsViewModel.GetItem(selectedRows[0].FromRow.Value);

                job.RecurrancePattern.SetValue(item.dev1_RecurrancePattern);
                RecurrancePatternMapper.DeSerialise(job, item.dev1_RecurrancePattern);
                job.ScheduledJobId.SetValue(item.dev1_ScheduledJobId);
                job.Name.SetValue(item.dev1_Name);
                job.StartDate.SetValue(item.dev1_StartDate);
                job.RecurrancePattern.SetValue(item.dev1_RecurrancePattern);

                EntityReference entityName = new EntityReference(null, null, item.dev1_WorkflowName);

                job.WorkflowId.SetValue(entityName);

                // Update the dependant data grid
                string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' returntotalrecordcount='true' no-lock='true' distinct='false' count='{0}' paging-cookie='{1}' page='{2}'>
                            <entity name='bulkdeleteoperation'>
                            <attribute name='name' />
                            <attribute name='createdon' />
                            <attribute name='asyncoperationid' />
                            <filter type='and'>
                            <condition attribute='name' operator='like' value='%" + item.dev1_ScheduledJobId.Value + @"%' />
                            </filter>
                            <link-entity name='asyncoperation' to='asyncoperationid' from='asyncoperationid' link-type='inner' alias='a0'>
                            <attribute name='postponeuntil' alias='asyncoperation_postponeuntil' />
                            <attribute name='statecode' alias='asyncoperation_statecode' />
                            <attribute name='statuscode'  alias='asyncoperation_statuscode' />
                            <attribute name='recurrencepattern'  alias='asyncoperation_recurrencepattern' />
                            </link-entity>{3}
                            </entity>
                            </fetch>";

                bulkDeleteJobsViewModel.FetchXml = fetchXml;
                bulkDeleteJobsViewModel.Reset();
                bulkDeleteJobsViewModel.Refresh();
            }
        }
예제 #7
0
 void quote_PropertyChanged(object sender, Xrm.ComponentModel.PropertyChangedEventArgs e)
 {
     Window.SetTimeout(delegate() { Lines.Refresh(); }, 0);
 }