Ejemplo n.º 1
0
        public void DeviceUpdated(	IDeviceMonitor monitor, IList<DevicePropertyChange> deviceChanges,
            IList<LinePropertyChange> lineChanges, IList<CallPropertyChange> callChanges)
        {
            // FIXME this is very inefficient
            List<PropertyChange> changes = new List<PropertyChange>();
            foreach( PropertyChange change in deviceChanges )
                changes.Add( change );
            foreach( PropertyChange change in lineChanges )
                changes.Add( change );
            foreach( PropertyChange change in callChanges )
                changes.Add( change );

            foreach( PropertyChange change in changes )
                // Note that we log changing to or from any given logging criteria
                if(	LookupPropertyChangeBehaviour( change.Underlying, change.Property, change.ChangedTo ).Log ||
                    LookupPropertyChangeBehaviour( change.Underlying, change.Property, change.ChangedFrom ).Log )
                    Logger.Instance().Log( change.Underlying.GetType().Name + " property " + change.Property + " has changed from " + change.ChangedFrom + " to " + change.ChangedTo );

            // Logging happens here:
            foreach( CallPropertyChange change in callChanges ) {
                if( change.Property == DeviceMonitor.PROPERTY_CALL_ACTIVITY ) {
                    if ( change.ChangedTo == Activity.Connected.ToString() ) {
                        CallRecord call = new CallRecord( monitor.GetDeviceState(), GetLine( change.Call ), change.Call, DateTime.Now, new DateTime() );

                        // Sanity check in case somehow call is already there
                        if ( mCalls.ContainsKey( change.Call ) ) {
                            mCalls.Remove( change.Call );
                            Logger.Instance().Log("Call #" + change.Call.Name + " had to be removed from the call list - did the previous call fail?");
                        }
                        mCalls.Add( change.Call, call );
                    } else if ( change.ChangedFrom == Activity.Connected.ToString() ) {
                        CallRecord call = mCalls[change.Call];
                        call.EndTime = DateTime.Now;
                        CallLogger.Instance().Log(call);
                        mCalls.Remove( change.Call );
                    }
                }

                if (change.Call.Activity != Activity.IdleDisconnected) {
                    if ( mCalls.ContainsKey( change.Call ) ) {
                        CallRecord call = mCalls[change.Call];
                        call.Call = change.Call;
                        call.Line = GetLine(change.Call);
                        mCalls[change.Call] = call;
                    }
                }
            }

            if( StateUpdate != null )
                StateUpdate( monitor, new StateUpdateEventArgs( deviceChanges, lineChanges, callChanges ) );
        }
Ejemplo n.º 2
0
 public void Log(CallRecord call)
 {
     Log(call.Device, call.Line, call.Call, call.StartTime, call.EndTime );
 }