/// <summary>
        /// Creates a new port for new terminal
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">NewContractEventArgs</param>
        public void OnNewcontractRegistering(object sender, NewContractEventArgs e)
        {
            Port port = new Port();

            port.PropertyChanged += this.OnPortStateChanged;
            e.port = port;
            Ports.Add(e.TelephoneNumber, port);
            PhoneNumbers.Add(port, e.TelephoneNumber);
        }
Пример #2
0
 /// <summary>
 /// Adds new contract
 /// </summary>
 /// <param name="newSubscriber">New subscriber</param>
 /// <param name="newContract">New contract</param>
 public void AddContract(Subscribers newSubscriber, ContractHead newContract)
 {
     if (NewContractRegistering != null)
     {
         Contracts.Add(newContract.ContractNumber, newContract);
         NewContractEventArgs args = new NewContractEventArgs(newContract.PhoneNumber);
         NewContractRegistering(this, args);
         Terminal terminal = new Terminal();
         //subscribing port to terminal events, and tepminal to port events
         terminal.PlugIn           += args.port.OnTerminalPlugedIn;
         terminal.Unplug           += args.port.OnTerminalUnPluged;
         terminal.Call             += args.port.OnOutgoingCall;
         terminal.Drop             += args.port.OnDropCall;
         terminal.Answer           += args.port.OnAnswerToCall;
         args.port.PropertyChanged += terminal.OnPortStateChanged;
         //Giving new contract and terminal to subscriber
         newSubscriber.Contract  = newContract;
         newSubscriber.Telephone = terminal;
     }
 }