Пример #1
0
        public void Connect()
        {
            Log("Connecting...");

            Debug.Assert(_callback == null);

            OperationContext.Current.Channel.Closed  += new EventHandler(Channel_Closed);
            OperationContext.Current.Channel.Faulted += new EventHandler(Channel_Faulted);

            _callback = OperationContext.Current.GetCallbackChannel <IC1ReportsSchedulerWcfCallback>();
            ((TaskListServer)_tasks.Tasks).WcfCallback = _callback;

            Log("Connected.");
        }
Пример #2
0
        protected override void OnPropertyChanged(string propertyName)
        {
            base.OnPropertyChanged(propertyName);

            TaskBase owner = _owner;

            if (propertyName != "CheckedStatus" && propertyName != "State")
            {
                CheckedStatus = CheckedStatus.Unknown;
                if (owner != null)
                {
                    owner.CheckedStatus = CheckedStatus.Unknown;
                }
            }

            if (owner == null)
            {
                return;
            }

            TaskListServer tasks = owner.Owner as TaskListServer;

            if (tasks == null)
            {
                return;
            }

            IC1ReportsSchedulerWcfCallback callback = tasks.WcfCallback;

            if (callback != null)
            {
                try
                {
                    callback.ActionPropertyChanged(owner.Id, this.Id, ToProxyXml(), propertyName);
                }
                catch (Exception ex)
                {
                    IC1ReportsSchedulerWcf wcfService = tasks.WcfService;
                    if (wcfService != null)
                    {
                        wcfService.Disconnect(ex.Message);
                    }
                }
            }
        }
Пример #3
0
 protected override void RemoveItem(int index)
 {
     lock (SyncRoot)
     {
         long id = ActionId(index);
         base.RemoveItem(index);
         TaskListServer tasks = _owner.Owner as TaskListServer;
         if (tasks == null)
         {
             return;
         }
         IC1ReportsSchedulerWcfCallback wcfCallback = tasks.WcfCallback;
         if (wcfCallback == null)
         {
             return;
         }
         wcfCallback.ActionRemoved(_owner.Id, id);
     }
 }
Пример #4
0
        protected override void OnPropertyChanged(string propertyName)
        {
            base.OnPropertyChanged(propertyName);
            if (propertyName != "NextDueTime")
            {
                base.OnPropertyChanged("NextDueTime");
            }

            if (_owner == null)
            {
                return;
            }

            TaskListServer tasks = _owner.Owner as TaskListServer;

            if (tasks == null)
            {
                return;
            }

            IC1ReportsSchedulerWcfCallback callback = tasks.WcfCallback;

            if (callback != null)
            {
                try
                {
                    string xml = ToProxyXml();
                    callback.SchedulePropertyChanged(_owner.Id, xml, propertyName);
                    callback.SchedulePropertyChanged(_owner.Id, xml, "NextDueTime");
                }
                catch (Exception ex)
                {
                    IC1ReportsSchedulerWcf wcfService = tasks.WcfService;
                    if (wcfService != null)
                    {
                        wcfService.Disconnect(ex.Message);
                    }
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Disconnects.
        /// </summary>
        /// <param name="reason">Reason for disconnecting.</param>
        public void Disconnect(string reason)
        {
            Log("Disconnecting...");

            ((TaskListServer)_tasks.Tasks).WcfCallback = null;
            _callback = null;

            if (OperationContext.Current != null && OperationContext.Current.Channel != null)
            {
                try
                {
                    if (OperationContext.Current.Channel.State == CommunicationState.Opened)
                    {
                        OperationContext.Current.Channel.Close();
                    }
                }
                catch (Exception ex)
                {
                    Log(string.Format("Exception while disconnecting: {0}", ex.Message));
                }
            }
            Log(string.Format("Disconnected, reason: {0}", reason ?? "None given."));
        }
Пример #6
0
        protected override void OnListChanged(ListChangedEventArgs e)
        {
            base.OnListChanged(e);

            TaskBase owner = _owner;

            if (owner == null)
            {
                return;
            }

            if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted)
            {
                owner.CheckedStatus = CheckedStatus.Unknown;
            }

            TaskListServer tasks = owner.Owner as TaskListServer;

            if (tasks == null)
            {
                return;
            }

            IC1ReportsSchedulerWcfCallback wcfCallback = tasks.WcfCallback;

            if (wcfCallback == null)
            {
                return;
            }

            try
            {
                switch (e.ListChangedType)
                {
                case ListChangedType.ItemAdded:
                    try
                    {
                        ActionServer action = (ActionServer)this[e.NewIndex];
                        long         ownerId;
                        long         actionId;
                        string       xml;
                        lock (action.SyncRoot)
                        {
                            ownerId  = owner.Id;
                            actionId = action.Id;
                            xml      = action.ToProxyXml();
                        }
                        wcfCallback.ActionAdded(ownerId, e.NewIndex, actionId, xml);
                    }
                    catch (Exception ex)
                    {
                        AltUtil.ShowError(ex.Message);
                    }
                    break;

                case ListChangedType.ItemChanged:
                    try
                    {
                        ActionServer action = (ActionServer)this[e.NewIndex];
                        long         ownerId;
                        long         actionId;
                        string       xml;
                        lock (action.SyncRoot)
                        {
                            ownerId  = owner.Id;
                            actionId = action.Id;
                            xml      = action.ToProxyXml();
                        }
                        wcfCallback.ActionPropertyChanged(ownerId, actionId, xml, e.PropertyDescriptor.Name);
                    }
                    catch (Exception ex)
                    {
                        AltUtil.ShowError(ex.Message);
                    }
                    break;

                case ListChangedType.ItemDeleted:
                    // we need removed task's id, hence TaskRemoved must be called from RemoveItem override:
                    // wcfCallback.TaskRemoved(TaskId(e.NewIndex));
                    break;

                case ListChangedType.ItemMoved:
                    break;

                case ListChangedType.Reset:
                    break;
                }
            }
            catch (Exception ex)
            {
                AltUtil.ShowError(ex.Message);
                IC1ReportsSchedulerWcf wcfService = tasks.WcfService;
                if (wcfService != null)
                {
                    wcfService.Disconnect(ex.Message);
                }
            }
        }