Example #1
0
        /// <summary>
        /// Execute new change, send them, or execute localy, or nothing of that.
        /// </summary>
        /// <param name="client">Where potencial new changes should be sent.</param>
        /// <param name="hash">Hash of change that should be executed.</param>
        /// <param name="side">Side of </param>
        /// <param name="sendChange">Determine if it should be send new changes to client.</param>
        public void ExecuteNewChange(TextWriter client, string hash, ChangeSide side, bool sendChange, Queue <Change> changeCache, Queue <TimeEvent> timeEventCache)
        {
            switch (side)
            {
            case ChangeSide.Local:
            case ChangeSide.RemoteSideDisabled:
                if (sendChange)
                {
                    lock (LocalChanges)
                        SendChange(client, LocalChanges[hash], LocalChanges[hash].TimeEvent);
                }
                break;

            case ChangeSide.Remote:
            case ChangeSide.LocalSideDisabled:
                lock (RemoteChanges)
                    ExecuteChange(RemoteChanges[hash], timeEventCache, changeCache);
                break;

            case ChangeSide.NotDecided:
                using (SideChooseForm choose = new SideChooseForm(LocalChanges[hash], RemoteChanges[hash]))
                {
                    DialogResult isLocalOne = choose.ShowDialog();

                    if (isLocalOne == DialogResult.Yes)
                    {
                        SendChange(client, LocalChanges[hash], LocalChanges[hash].TimeEvent);
                    }

                    else if (isLocalOne == DialogResult.No)
                    {
                        ExecuteChange(RemoteChanges[hash], timeEventCache, changeCache);
                    }
                    else
                    {
                        return;
                    }
                }
                break;

            default:
                break;
            }
        }
Example #2
0
        /// <summary>
        /// Execute new change, send them, or execute localy, or nothing of that.
        /// </summary>
        /// <param name="client">Where potencial new changes should be sent.</param>
        /// <param name="hash">Hash of change that should be executed.</param>
        /// <param name="side">Side of </param>
        /// <param name="sendChange">Determine if it should be send new changes to client.</param>
        public void ExecuteNewChange(TextWriter client, string hash, ChangeSide side, bool sendChange, Queue<Change> changeCache, Queue<TimeEvent> timeEventCache)
        {
            switch (side)
            {
                case ChangeSide.Local:
                case ChangeSide.RemoteSideDisabled:
                    if (sendChange)
                        lock (LocalChanges)
                            SendChange(client, LocalChanges[hash], LocalChanges[hash].TimeEvent);
                    break;
                case ChangeSide.Remote:
                case ChangeSide.LocalSideDisabled:
                    lock (RemoteChanges)
                        ExecuteChange(RemoteChanges[hash], timeEventCache, changeCache);
                    break;
                case ChangeSide.NotDecided:
                    using (SideChooseForm choose = new SideChooseForm(LocalChanges[hash], RemoteChanges[hash]))
                    {
                        DialogResult isLocalOne = choose.ShowDialog();

                        if (isLocalOne == DialogResult.Yes)
                            SendChange(client, LocalChanges[hash], LocalChanges[hash].TimeEvent);

                        else if (isLocalOne == DialogResult.No)
                            ExecuteChange(RemoteChanges[hash], timeEventCache, changeCache);
                        else
                            return;
                    }
                    break;
                default:
                    break;
            }
        }