public void DeleteCommand(object data, jQueryEvent e)
 {
     Utility.ConfirmDialog(ResourceStrings.ConfirmDeleteConnection, delegate(){
         string id = e.Target.ParentNode.GetAttribute("rowId").ToString();
         OrganizationServiceProxy.BeginDelete(Connection.LogicalName, new Guid(id), delegate(object state)
         {
             try
             {
                 OrganizationServiceProxy.EndDelete(state);
                 foreach (Entity connection in Connections.Data)
                 {
                     if (connection.Id == id)
                     {
                         Connections.RemoveItem(connection);
                         break;
                     }
                 }
                 Connections.Refresh();
             }
             catch (Exception ex)
             {
                 ErrorMessage.SetValue(ex.Message);
             }
         });
     }, null);
 }
Exemplo n.º 2
0
        private void SaveNextRecord(List <QuoteDetail> dirtyCollection, List <string> errorMessages, Action callBack)
        {
            QuoteDetail itemToSave = dirtyCollection[0];

            if (itemToSave.EntityState == EntityStates.Deleted)
            {
                OrganizationServiceProxy.BeginDelete("quotedetail", itemToSave.QuoteDetailId, delegate(object r)
                {
                    try
                    {
                        OrganizationServiceProxy.EndDelete(r);
                        itemToSave.EntityState = EntityStates.Unchanged;
                    }
                    catch (Exception ex)
                    {
                        // Something when wrong with delete
                        errorMessages.Add(ex.Message);
                    }
                    FinishSaveRecord(dirtyCollection, errorMessages, callBack, itemToSave);
                });
            }
            else if (itemToSave.QuoteDetailId == null)
            {
                OrganizationServiceProxy.BeginCreate(itemToSave, delegate(object r)
                {
                    try
                    {
                        Guid newID = OrganizationServiceProxy.EndCreate(r);
                        itemToSave.QuoteDetailId = newID;
                        itemToSave.EntityState   = EntityStates.Unchanged;
                    }
                    catch (Exception ex)
                    {
                        // Something when wrong with create
                        errorMessages.Add(ex.Message);
                    }
                    FinishSaveRecord(dirtyCollection, errorMessages, callBack, itemToSave);
                });
            }
            else
            {
                OrganizationServiceProxy.BeginUpdate(itemToSave, delegate(object r)
                {
                    try
                    {
                        OrganizationServiceProxy.EndUpdate(r);
                        itemToSave.EntityState = EntityStates.Unchanged;
                    }
                    catch (Exception ex)
                    {
                        // Something when wrong with update
                        errorMessages.Add(ex.Message);
                    }

                    FinishSaveRecord(dirtyCollection, errorMessages, callBack, itemToSave);
                });
            }
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private void DeleteJob(List <PendingDelete> items, Action completedCallback)
        {
            DelegateItterator.CallbackItterate(delegate(int index, Action nextCallback, ErrorCallBack errorCallBack)
            {
                // Do work
                PendingDelete pendingDeleteItem = items[index];

                if (pendingDeleteItem.cancelFirst)
                {
                    // If the operation is not completed, we need to cancle it first
                    // TODO: Note this will fail if waiting for resources/in progress - so we should add a wait here until finished.
                    asyncoperation operationToUpdate   = new asyncoperation();
                    operationToUpdate.AsyncOperationId = pendingDeleteItem.id;
                    operationToUpdate.Id        = operationToUpdate.AsyncOperationId.Value;
                    operationToUpdate.StateCode = new OptionSetValue(3);
                    OrganizationServiceProxy.Update(operationToUpdate);
                }
                OrganizationServiceProxy.BeginDelete(pendingDeleteItem.entityName, pendingDeleteItem.id, delegate(object result)
                {
                    try
                    {
                        OrganizationServiceProxy.EndDelete(result);
                        IsBusyProgress.SetValue((index / items.Count) * 100);
                        nextCallback();
                    }
                    catch (Exception ex)
                    {
                        errorCallBack(ex);
                    }
                });
            },
                                               items.Count,
                                               completedCallback,
                                               delegate(Exception ex)
            {
                // Error
                ReportError(ex);
            });
        }
Exemplo n.º 5
0
        public Action DeleteCommand()
        {
            if (_deleteCommand == null)
            {
                _deleteCommand = delegate()
                {
                    List <int> selectedRows = DataViewBase.RangesToRows(this.SessionDataView.GetSelectedRows());
                    if (selectedRows.Count == 0)
                    {
                        return;
                    }

                    bool confirmed = Script.Confirm(String.Format("Are you sure you want to delete the {0} selected sessions?", selectedRows.Count));
                    if (!confirmed)
                    {
                        return;
                    }


                    IsBusyMessage.SetValue("Deleting Sessions...");
                    IsBusyProgress.SetValue(0);
                    IsBusy.SetValue(true);

                    // Get each item to remove
                    List <dev1_session> itemsToDelete = new List <dev1_session>();
                    for (int i = 0; i < selectedRows.Count; i++)
                    {
                        itemsToDelete.Add((dev1_session)this.SessionDataView.GetItem(i));
                    }
                    DelegateItterator.CallbackItterate(delegate(int index, Action nextCallback, ErrorCallBack errorCallBack)
                    {
                        dev1_session session = itemsToDelete[index];
                        IsBusyProgress.SetValue((index / selectedRows.Count) * 100);
                        OrganizationServiceProxy.BeginDelete(session.LogicalName, session.dev1_sessionId, delegate(object result)
                        {
                            try
                            {
                                OrganizationServiceProxy.EndDelete(result);
                                this.SessionDataView.RemoveItem(session);
                                this.SessionDataView.Refresh();
                                nextCallback();
                            }
                            catch (Exception ex)
                            {
                                Script.Alert(ex.Message);
                                nextCallback();
                            }
                        });
                    },
                                                       selectedRows.Count,
                                                       delegate()
                    {
                        // Complete
                        IsBusyProgress.SetValue(100);
                        IsBusy.SetValue(false);
                        SessionDataView.Refresh();
                        Days.ReCalculate();
                    },
                                                       delegate(Exception ex)
                    {
                        ReportError(ex);
                    }
                                                       );
                };
            }
            return(_deleteCommand);
        }