Beispiel #1
0
        private Call getOutboundCallFromChannelInfo(List<string> result, bool callerIdUnknown)
        {
            char[] splitter = { '=' };
            Call c = null;
            try
            {
                c = new Call();
                c.type = CallType.placed;
                c.startTime = DateTime.Now;
                foreach (string s in result)
                {

                    if (s.StartsWith("level 1: ") && !callerIdUnknown)
                    {

                        string cdrvarkey = "";
                        string cdrvarvalue = "";
                        string cdrvar = s.Substring(9);
                        log.Debug(s + ", " + cdrvar);
                        cdrvarkey = cdrvar.Split(splitter)[0];
                        cdrvarvalue = cdrvar.Split(splitter)[1];
                        switch (cdrvarkey)
                        {
                            case "src":
                                c.caller = cdrvarvalue;
                                break;
                            case "dst":
                                c.callee = cdrvarvalue;
                                break;
                            case "uniqueid":
                                c.callId = cdrvarvalue;
                                break;
                        }
                    }
                    else
                    {
                        if (s.Contains("UniqueID:"))
                        {
                            c.callId = s.Substring(s.LastIndexOf(" ") + 1);
                        }
                        else if (s.Contains("Caller ID:"))
                        {
                            c.caller = s.Substring(s.LastIndexOf(" ") + 1);
                        }
                        else if (s.Contains("EXTTOCALL="))
                        {
                            c.callee = s.Substring(s.LastIndexOf("=") + 1);
                        }
                    }
                }
                if (c.callee == null || c.caller == null || c.callee.StartsWith("*") || c.caller == ""  || c.callee == "s")
                {
                    c = null;
                }
            }
            catch (Exception callException)
            {
                log.Debug(callException.Message);
            }
            return c;
        }
Beispiel #2
0
 private void AddCallLogs(string dn,Call c)
 {
     //adjust callid for compatibility issue with TALK Gadget:
     try
     {
         if (c.type != CallType.missed)
         {
             c.callId = c.callId.Substring(0, 6) + "," + c.callId.Substring(6);
         }
         ss.AddCallLogs(dn, c);
     }
     catch (Exception e)
     {
         log.Debug("Unable to add call logs:" + e.Message);
     }
 }
Beispiel #3
0
 private void AddCall(Call c, string address)
 {
     try
     {
         if (((Hashtable)Calls[address]).ContainsKey(c.callId))
         {
             log.Debug("Adding call for " + address + ": " + c.ToString());
             ss.AddCallLogs(address, c);
             shiftCall(c.callId, address);
         }
     }
     catch (Exception e)
     {
         log.Error("Unable to add call " + c.callId + " from " + address + ": " + e.Message);
     }
 }
Beispiel #4
0
 private static bool FindCall(Call c)
 {
     log.Debug("Comparing call " + c.callId + " with " + callToFind + "...");
     if (c.callId == callToFind)
     {
         return true;
     }
     {
         return false;
     }
 }
Beispiel #5
0
 void manager_CallStateChanged(object sender, CallStateEventArgs e)
 {
     Call c = getCall(e.Call.Address.Address, e.Call.Id.ToString());
     if (c != null)
     {
         switch (e.CallState)
         {
             case CallState.Connected:
                 switch (c.type)
                 {
                     case CallType.missed:
                         c.type = CallType.received;
                         putCall(c, e.Call.Address.Address);
                         break;
                     case CallType.placed:
                         c.callee = e.Call.CalledId;
                         putCall(c, e.Call.Address.Address);
                         break;
                 }
                 break;
             case CallState.Disconnected:
                 c.endTime = DateTime.Now;
                 AddCall(c, e.Call.Address.Address);
                 break;
             case CallState.Idle:
                 if (e.OldCallState != CallState.Idle && e.OldCallState != CallState.Disconnected)
                 {
                     c.endTime = DateTime.Now;
                     AddCall(c, e.Call.Address.Address);
                 }
                 break;
         }
     }
     else
     {
         c = new Call();
         c.callee = e.Call.CalledId;
         c.caller = e.Call.CallerId;
         c.callId = e.Call.Id.ToString();
         c.startTime = DateTime.Now;
         switch (e.Call.CallState)
         {
             case CallState.Accepted:
                 //first missed
                 c.type = CallType.missed;
                 break;
             case CallState.Dialing:
                 //placed 
                 c.type = CallType.placed;
                 break;
             case CallState.Dialtone:
                 //placed
                 c.type = CallType.placed;
                 break;
             case CallState.Offering:
                 //first missed
                 c.type = CallType.missed;
                 break;
         }
         putCall(c, e.Call.Address.Address);
     }
     CallStateChanged(e, "Manager");
 }
Beispiel #6
0
 private void putCall(Call c, string address)
 {
     try
     {
         Hashtable addressCalls = new Hashtable(); 
         if (Calls.ContainsKey(address))
         {
             addressCalls = (Hashtable)Calls[address];
             if (addressCalls != null)
             {
                 if (addressCalls.Contains(c.callId))
                 {
                     addressCalls[c.callId] = c;
                 }
                 else
                 {
                     addressCalls.Add(c.callId, c);
                 }
             }
             else
             {
                 addressCalls = new Hashtable();
                 addressCalls.Add(c.callId, c);
             }
             log.Debug("Adding call " + c.callId + " from " + address);
             Calls[address] = addressCalls;
         }
         else
         {
             addressCalls.Add(c.callId, c);
             log.Debug("Adding call " + c.callId + " from " + address);
             Calls.Add(address, addressCalls);
         }
     }
     catch (Exception e)
     {
         log.Error("Unable to put call " + c.callId + " from " + address + " in queue: " + e.Message);
     }
 }
Beispiel #7
0
 void manager_NewCall(object sender, NewCallEventArgs e)
 {
     Call c = new Call();
     c.callee = e.Call.CalledId;
     c.caller = e.Call.CallerId;
     c.callId = e.Call.Id.ToString();
     c.startTime = DateTime.Now;
     switch (e.Call.CallState)
     {
         case CallState.Accepted:
             //first missed
             c.type = CallType.missed;
             break;
         case CallState.Dialing:
             //placed 
             c.type = CallType.placed;
             break;
         case CallState.Dialtone:
             //placed
             c.type = CallType.placed;
             break;
         case CallState.Offering:
             //first missed
             c.type = CallType.missed;
             break;
     }
     putCall(c, e.Call.Address.Address);
     NewCall(e, "Manager");
 }
Beispiel #8
0
 /// <remarks/>
 public void AddCallLogsAsync(string dn, Call call, object userState) {
     if ((this.AddCallLogsOperationCompleted == null)) {
         this.AddCallLogsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddCallLogsOperationCompleted);
     }
     this.InvokeAsync("AddCallLogs", new object[] {
                 dn,
                 call}, this.AddCallLogsOperationCompleted, userState);
 }
Beispiel #9
0
 /// <remarks/>
 public void AddCallLogsAsync(string dn, Call call) {
     this.AddCallLogsAsync(dn, call, null);
 }
Beispiel #10
0
 /// <remarks/>
 public System.IAsyncResult BeginAddCallLogs(string dn, Call call, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("AddCallLogs", new object[] {
                 dn,
                 call}, callback, asyncState);
 }
Beispiel #11
0
 public bool AddCallLogs(string dn, Call call) {
     object[] results = this.Invoke("AddCallLogs", new object[] {
                 dn,
                 call});
     return ((bool)(results[0]));
 }