示例#1
0
        /// <summary>
        /// Deletes associated <see cref="Adapter"/> record.
        /// </summary>
        public override void Delete()
        {
            if (CanDelete && Confirm("Are you sure you want to delete \'" + GetCurrentItemName() + "\'?", "Delete " + DataModelName))
            {
                try
                {
                    if (OnBeforeDeleteCanceled())
                    {
                        throw new OperationCanceledException("Delete was canceled.");
                    }

                    int    currentItemKey = GetCurrentItemKey();
                    string result         = Adapter.Delete(null, m_adapterType, GetCurrentItemKey());
                    ItemsKeys.Remove(currentItemKey);

                    OnDeleted();

                    Load();
                    DisplayStatusMessage(result);
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        Popup(ex.Message + Environment.NewLine + "Inner Exception: " + ex.InnerException.Message, "Delete " + DataModelName + " Exception:", MessageBoxImage.Error);
                        CommonFunctions.LogException(null, "Delete " + DataModelName, ex.InnerException);
                    }
                    else
                    {
                        Popup(ex.Message, "Delete " + DataModelName + " Exception:", MessageBoxImage.Error);
                        CommonFunctions.LogException(null, "Delete " + DataModelName, ex);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Deletes <see cref="OutputStreamDevice"/>.
        /// </summary>
        public override void Delete()
        {
            //base.Delete();
            if (CanDelete && Confirm("Are you sure you want to delete \'" + GetCurrentItemName() + "\'?", "Delete " + DataModelName))
            {
                try
                {
                    if (OnBeforeDeleteCanceled())
                    {
                        throw new OperationCanceledException("Delete was canceled.");
                    }

                    int    currentItemKey = GetCurrentItemKey();
                    string result         = OutputStreamDevice.Delete(null, m_outputStreamID, CurrentItem.Acronym);
                    ItemsKeys.Remove(currentItemKey);

                    OnDeleted();

                    Load();

                    Popup(result, "Delete " + DataModelName, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        Popup(ex.Message + Environment.NewLine + "Inner Exception: " + ex.InnerException.Message, "Delete " + DataModelName + " Exception:", MessageBoxImage.Error);
                        CommonFunctions.LogException(null, "Delete " + DataModelName, ex.InnerException);
                    }
                    else
                    {
                        Popup(ex.Message, "Delete " + DataModelName + " Exception:", MessageBoxImage.Error);
                        CommonFunctions.LogException(null, "Delete " + DataModelName, ex);
                    }
                }
            }
        }