Исключение параллелизма - PullRequest
       3

Исключение параллелизма

0 голосов
/ 11 декабря 2018

Я единственный пользователь, использующий систему, и этот код выдает исключение параллелизма, все, что я пытаюсь сделать, это обновить статус и добавить пользователя, который принимает задачу

OptimisticConcurrencyException:Оператор сохранения, вставки или удаления магазина затронул неожиданное количество строк (0).Объекты могут быть изменены или удалены с момента загрузки объектов.См. http://go.microsoft.com/fwlink/?LinkId=472540 для получения информации о понимании и обработке исключений оптимистичного параллелизма.

     namespace GoldMine.View.Notification.Home.Process {
   using PageInstruction = GraphiteGTC.Core.View.Element.Model.PageInstruction;
    using Notification = GoldMine.Model.Notification;
    using User = GoldMine.Model.User;
    using NotificationApprovalStatus = GoldMine.Model.NotificationApprovalStatus;
    using ButtonTypeOption = GoldMine.Model.ButtonTypeOption;

    /// <summary>
    ///
    /// Class housing the logic for OnClickAdoptApproveTaskButtonProcess
    ///
    /// </summary>
    public class OnClickAdoptApproveTaskButtonProcess : GoldMineViewProcess {
        /// <summary>
        ///
        /// View process inputs
        ///
        /// </summary>
        public new OnClickAdoptApproveTaskButtonProcessInputs Inputs {
            get { return ( OnClickAdoptApproveTaskButtonProcessInputs )base.Inputs; }
            set { base.Inputs = value; }
        }

        /// <summary>
        ///
        /// View process outputs
        ///
        /// </summary>
        public new OnClickAdoptApproveTaskButtonProcessOutputs Outputs {
            get { return ( OnClickAdoptApproveTaskButtonProcessOutputs )base.Outputs; }
            set { base.Outputs = value; }
        }

        /// <summary>
        ///
        /// UI outputs
        ///
        /// </summary>
        public OnClickAdoptApproveTaskButtonProcessUiOutputs UiOutputs {
            get { return new OnClickAdoptApproveTaskButtonProcessUiOutputs( Outputs ); }
        }

        /// <summary>
        ///
        /// Default parameter-less constructor
        ///
        /// </summary>
        public OnClickAdoptApproveTaskButtonProcess() {
            Name = "GoldMine.View.Notification.Home.Process.OnClickAdoptApproveTaskButtonProcess";
            Inputs = new OnClickAdoptApproveTaskButtonProcessInputs();
            Outputs = new OnClickAdoptApproveTaskButtonProcessOutputs();
            base.Outputs = Outputs;
            base.Inputs = Inputs;
            DelayedPropertyAssignments = new List<DelayedPropertyAssignment>();
        }

        /// <summary>
        ///
        /// Entry point for event processing
        ///
        /// </summary>
        protected override GraphiteGTCProcess ExecuteProcess( GTCEventRegistration executingEventRegistration ) {
            return base.ExecuteProcess( Inputs.EventRegistration );
        }

        /// <summary>
        ///
        /// Entry point for Business Logic Processing
        ///
        /// </summary>
        protected override GraphiteGTCProcess ExecuteForwardProcessing() {
            try {
                Outputs = new OnClickAdoptApproveTaskButtonProcessOutputs();

                Outputs.SessionToken = UiStringConverter.CreateSessionToken( Inputs.CurrentUser );
                Debugging.DebugWorker.Current.BeginProcess();
                Debugging.DebugWorker.Current.SetVariableValue( "ButtonType", Inputs.ButtonType );
                Debugging.DebugWorker.Current.SetVariableValue( "CurrentNotification", Inputs.CurrentNotification );
                Debugging.DebugWorker.Current.SetVariableValue( "PageInstructions", Outputs.PageInstructions );
                Debugging.DebugWorker.Current.SetVariableValue( "CurrentUser", Inputs.CurrentUser );
                Debugging.DebugWorker.Current.BeginInstruction( "b60bbb93-3a06-4a57-ace3-6024f91c94a0", "092c84bf-423e-454b-8efa-00749bc691ef" );

                // ShapeComment:[Create List of Page Instructions][b60bbb93-3a06-4a57-ace3-6024f91c94a0][4bf395e3-e0a1-4304-b987-dcdae594a524]
                Debugging.DebugWorker.Current.BeginInstruction( "b60bbb93-3a06-4a57-ace3-6024f91c94a0", "4bf395e3-e0a1-4304-b987-dcdae594a524" );
                Outputs.PageInstructions = new List<PageInstruction>();
                Debugging.DebugWorker.Current.SetVariableValue( "PageInstructions", Outputs.PageInstructions );

                // ShapeComment:[Get Receiver][b60bbb93-3a06-4a57-ace3-6024f91c94a0][6b9c89cc-79c7-4957-8164-9a0c25da7652]
                Debugging.DebugWorker.Current.BeginInstruction( "b60bbb93-3a06-4a57-ace3-6024f91c94a0", "6b9c89cc-79c7-4957-8164-9a0c25da7652" );
                #region Execute FindReceiverFromNotification Process

                var notificationFindReceiverFromNotificationProcess = new Notification( true ).FindReceiverFromNotificationProcess;
                notificationFindReceiverFromNotificationProcess.Inputs.EventRegistration = Inputs.EventRegistration;
                notificationFindReceiverFromNotificationProcess.Inputs.CurreuntUser = Inputs.CurrentUser;
                notificationFindReceiverFromNotificationProcess.Inputs.Notification = Inputs.CurrentNotification;
                notificationFindReceiverFromNotificationProcess.OverriddenValidations = OverriddenValidations;
                try {
                    notificationFindReceiverFromNotificationProcess.StartProcessing();
                    Outputs.Validations.AddRange( notificationFindReceiverFromNotificationProcess.Outputs.Validations );
                }
                catch ( ValidationResultException validationResultException ) {
                    Outputs.Validations.AddRange( validationResultException.Validations );
                    if ( validationResultException.ContainsError() ) {
                        throw new ValidationResultException( string.Format( "Processing {0} resulted in an error", Name ), Outputs.Validations );
                    }
                }

                #endregion
                var NotificationFindReceiverFromNotificationResult = notificationFindReceiverFromNotificationProcess;
                Debugging.DebugWorker.Current.SetVariableValue( "NotificationFindReceiverFromNotificationResult", NotificationFindReceiverFromNotificationResult );

                // ShapeComment:[Assign Notification as Read][b60bbb93-3a06-4a57-ace3-6024f91c94a0][324e353c-cdd6-488e-8c9c-3420051a06f5]
                Debugging.DebugWorker.Current.BeginInstruction( "b60bbb93-3a06-4a57-ace3-6024f91c94a0", "324e353c-cdd6-488e-8c9c-3420051a06f5" );
                Inputs.CurrentNotification.AdoptedBy = Inputs.CurrentUser;
                Inputs.CurrentNotification.ApprovalStatus = NotificationApprovalStatus.Approved;

                // ShapeComment:[Save Notification][b60bbb93-3a06-4a57-ace3-6024f91c94a0][c407dd77-b074-4c26-ac9b-557d73fec312]
                Debugging.DebugWorker.Current.BeginInstruction( "b60bbb93-3a06-4a57-ace3-6024f91c94a0", "c407dd77-b074-4c26-ac9b-557d73fec312" );
                GoldMine.View.Notification.Home.Process.SaveNotificationProcess SaveNotificationProcessResult = null;
                try {
                    SaveNotificationProcessResult = ( GoldMine.View.Notification.Home.Process.SaveNotificationProcess ) EventProcess.ExecuteUnregisteredViewEvent( "GoldMine.View.Notification.Home.Process.SaveNotificationProcess", Inputs.CurrentUser, new NameValuePairInputCollection {
                        { "Notification", Inputs.CurrentNotification }
                    } );
                    Outputs.Validations.AddRange( SaveNotificationProcessResult.Outputs.Validations );
                }
                catch ( ValidationResultException validationResultException ) {
                    Outputs.Validations.AddRange( validationResultException.Validations );
                    if ( validationResultException.ContainsError() ) {
                        throw new ValidationResultException( string.Format( "Processing {0} resulted in an error", Name ), Outputs.Validations );
                    }
                }
                var HomeSaveNotificationResult = SaveNotificationProcessResult;
                Debugging.DebugWorker.Current.SetVariableValue( "HomeSaveNotificationResult", HomeSaveNotificationResult );
                Debugging.DebugWorker.Current.BeginInstruction( "b60bbb93-3a06-4a57-ace3-6024f91c94a0", "85d667f2-7ed7-4d91-9dff-1c25687fa197" );
                Debugging.DebugWorker.Current.EndProcess();
                Outputs.SessionToken = UiStringConverter.CreateSessionToken( Inputs.CurrentUser );
                return this;
            }
            *catch ( ConcurrencyException ) {
                throw;*
            }

1 Ответ

0 голосов
/ 11 декабря 2018

Обратите внимание на это в сообщении об исключении:

повлияло на неожиданное количество строк (0)

Это в основном означает «Я думал, что собираюсь что-то изменить,но я ничего не изменил ".

Это может произойти с запросом типа UPDATE MyTable SET MyColumn = "hi" WHERE Id = 5, но нет записи с Id из 5.

Если исключениев одной из этих двух строк:

Inputs.CurrentNotification.AdoptedBy = Inputs.CurrentUser;
Inputs.CurrentNotification.ApprovalStatus = NotificationApprovalStatus.Approved;

, что означает, что методы установки этих свойств пишут в базу данных.Определение свойства будет выглядеть примерно так:

User AdoptedBy {
    get {
         //something here
    }
    set {
        //this is writing to the database
    }
}

И по какой-то причине оно обновляет то, что не существует.Но мы не можем сказать вам, почему или как решить эту проблему, не увидев этот код.

Так что это зависит от определения класса для любого типа Inputs.CurrentNotification.Если это один из ваших классов, то вы, вероятно, просто отлаживаете и просматриваете этот код.

Действительно, не рекомендуется выполнять какие-либо операции ввода / вывода в свойствах getter / setters.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...