Beispiel #1
0
 private void _activePort_AllRecDataReceive(TildaCIDHID.Public.CalllogDetail callogdetail, object mysender)
 {
     lock (this)
     {
         LogObjectValue?.Invoke("PortDataReceivedEventArgs", callogdetail.sUpdateFileds);
         SetLinesState(callogdetail);
     }
 }
Beispiel #2
0
        private void SetDialedNumberState(TildaCIDHID.Public.CalllogDetail receivedData, ILine line)
        {
            var dialedNumber = receivedData.DialNumber;

            LogStringValue?.Invoke("DialedNumber", dialedNumber);
            if (!string.IsNullOrEmpty(dialedNumber))
            {
                line.DialedNumber = dialedNumber;
            }
        }
Beispiel #3
0
        private void SetDurationState(TildaCIDHID.Public.CalllogDetail receivedData, ILine line)
        {
            var durationSecs = receivedData.Duration;

            LogIntValue?.Invoke("Duration", durationSecs);
            if (durationSecs >= 0)
            {
                line.DurationSecs = durationSecs;
            }
        }
Beispiel #4
0
 private int FindRingCounts(TildaCIDHID.Public.CalllogDetail strCallLog)
 {
     try
     {
         return(Convert.ToInt32(strCallLog.Rings));
     }
     catch (Exception)
     {
         return(1);
     }
 }
Beispiel #5
0
 private void SetLinesState(TildaCIDHID.Public.CalllogDetail receivedData)
 {
     try
     {
         if (receivedData == null)
         {
             return;
         }
         var lineNo = receivedData.LineNumber;
         if (lineNo == 0)
         {
             return;
         }
         ILine line = null;
         if (GetLinesMap().ContainsKey(GetLineKey(lineNo)))
         {
             line = GetLinesMap()[GetLineKey(lineNo)];
         }
         if (line == null)
         {
             return;
         }
         lock (line)
         {
             var status = FindCallStatus(receivedData);
             LogStringValue?.Invoke("Status", status.ToString());
             if (status > 0)
             {
                 line.Status = status;
             }
             SetDurationState(receivedData, line);
             SetDialedNumberState(receivedData, line);
             var str = FindNumber(receivedData);
             if (str != string.Empty)
             {
                 line.Number = str;
                 LogStringValue?.Invoke("PhoneNumber", str);
             }
             var num2 = FindRingCounts(receivedData);
             if (num2 > 0)
             {
                 line.RingCounts = num2;
                 LogIntValue?.Invoke("RingCount", num2);
             }
             line.LastUpdate = DateTime.UtcNow;
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("SetLinesState", ex);
     }
 }
Beispiel #6
0
 private LineStatus FindCallStatus(TildaCIDHID.Public.CalllogDetail strCallLog)
 {
     if (strCallLog.sUpdateFileds.IndexOf("Rings", StringComparison.OrdinalIgnoreCase) != -1)
     {
         return(LineStatus.Ringing);
     }
     if (strCallLog.sUpdateFileds.IndexOf("Hookon", StringComparison.OrdinalIgnoreCase) != -1)
     {
         return(LineStatus.HookOn);//تلفن قطع : تیلدا کیش
     }
     if (strCallLog.sUpdateFileds.IndexOf("Hookoff", StringComparison.OrdinalIgnoreCase) != -1)
     {
         return(LineStatus.HookOff);//تلفن وصل : تیلداکیش
     }
     if (strCallLog.sUpdateFileds.IndexOf("DialNumber", StringComparison.OrdinalIgnoreCase) != -1)
     {
         return(LineStatus.Ringing);//تلفن وصل : تیلداکیش
     }
     return(0);
 }
Beispiel #7
0
        private LineStatus FindCallStatus(TildaCIDHID.Public.CalllogDetail strCallLog)
        {
            switch (strCallLog.Status)
            {
            case "Idle":
                return(LineStatus.HookOff);

            case "Recording":
            case "Busy":
                return(LineStatus.HookOff);

            case "Ringing":
                return(LineStatus.Ringing);

            case "NoLine":
                return(LineStatus.HookOff);

            case "Missed Call":
                return(LineStatus.HookOff);
            }
            return(LineStatus.HookOff);

            /* if (strCallLog.sUpdateFileds.IndexOf("Rings", StringComparison.OrdinalIgnoreCase) != -1)
             * {
             *   return LineStatus.Ringing;
             * }
             * if (strCallLog.sUpdateFileds.IndexOf("Hookon", StringComparison.OrdinalIgnoreCase) != -1)
             * {
             *   return LineStatus.HookOff;//تلفن قطع : تیلدا کیش
             * }
             * if (strCallLog.sUpdateFileds.IndexOf("Hookoff", StringComparison.OrdinalIgnoreCase) != -1)
             * {
             *   return LineStatus.HookOn;//تلفن وصل : تیلداکیش
             * }
             * if (strCallLog.sUpdateFileds.IndexOf("DialNumber", StringComparison.OrdinalIgnoreCase) != -1)
             * {
             *   return LineStatus.Ringing;//تلفن وصل : تیلداکیش
             * }
             * return 0;*/
        }
Beispiel #8
0
 private string FindNumber(TildaCIDHID.Public.CalllogDetail strCallLog)
 {
     return(FixPhoneNumber(strCallLog.Number));
 }
Beispiel #9
0
        private void SetLinesState(TildaCIDHID.Public.CalllogDetail receivedData)
        {
            try
            {
                if (receivedData == null)
                {
                    return;
                }
                var lineNo = receivedData.LineNumber;
                if (lineNo == 0)
                {
                    return;
                }
                ILine line = null;
                if (GetLinesMap().ContainsKey(GetLineKey(lineNo)))
                {
                    line = GetLinesMap()[GetLineKey(lineNo)];
                }
                if (line == null)
                {
                    return;
                }
                lock (line)
                {
                    var status = FindCallStatus(receivedData);
                    LogStringValue?.Invoke("Status", status.ToString());
                    if (status > 0)
                    {
                        line.Status = status;
                    }
                    if (receivedData.sUpdateFileds.IndexOf("StatusRecord", StringComparison.Ordinal) != -1)
                    {
                        if (!receivedData.Status_Record)
                        {
                            ActivePort.StartRecordLine(line.LineNumber);
                        }
                        else
                        {
                            ActivePort.StopRecordLine(line.LineNumber);
                        }
                    }
                    if (receivedData.sUpdateFileds.IndexOf("Duration", StringComparison.Ordinal) != -1)
                    {
                        if (receivedData.Duration != -1)
                        {
                            SetDurationState(receivedData, line);
                        }
                    }

                    if (receivedData.sUpdateFileds.IndexOf("DialNumber", StringComparison.Ordinal) != -1)
                    {
                        if (!string.IsNullOrEmpty(receivedData.DialNumber))
                        {
                            SetDialedNumberState(receivedData, line);
                        }
                    }
                    if (receivedData.sUpdateFileds.IndexOf("Number-", StringComparison.Ordinal) != -1)
                    {
                        if (!string.IsNullOrEmpty(receivedData.Number))
                        {
                            var str = FindNumber(receivedData);
                            if (str != string.Empty)
                            {
                                line.Number = str;
                                LogStringValue?.Invoke("PhoneNumber", str);
                            }
                        }
                    }
                    if (receivedData.sUpdateFileds.IndexOf("Rings", StringComparison.Ordinal) != -1)
                    {
                        if (!string.IsNullOrEmpty(receivedData.Rings))
                        {
                            var num2 = FindRingCounts(receivedData);
                            if (num2 > 0)
                            {
                                line.RingCounts = num2;
                                LogIntValue?.Invoke("RingCount", num2);
                            }
                        }
                    }

                    line.LastUpdate = DateTime.UtcNow;
                }
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("SetLinesState", ex);
            }
        }