public static void InsertCallDetails(object msg)
        {
            IMessage message = msg as IMessage;

            if (message != null)
            {
                switch (message.Id)
                {
                case EventRinging.MessageId:
                {
                    EventRinging eventRinging = message as EventRinging;
                    ProcessInsertCallDetails(eventRinging.GetType(), eventRinging);
                    break;
                }

                case EventReleased.MessageId:
                {
                    EventReleased eventRelease = message as EventReleased;
                    ProcessInsertCallDetails(eventRelease.GetType(), eventRelease);
                    break;
                }

                case EventEstablished.MessageId:
                {
                    EventEstablished eventEstablished = message as EventEstablished;
                    ProcessInsertCallDetails(eventEstablished.GetType(), eventEstablished);
                    break;
                }

                case EventPartyInfo.MessageId:
                {
                    EventPartyInfo eventPartyInfo = message as EventPartyInfo;
                    ProcessInsertCallDetails(eventPartyInfo.GetType(), eventPartyInfo);
                    break;
                }


                case EventHeld.MessageId:
                {
                    EventHeld eventHeld = message as EventHeld;
                    ProcessInsertCallDetails(eventHeld.GetType(), eventHeld);
                    break;
                }

                case EventPartyChanged.MessageId:
                {
                    EventPartyChanged eventPartyChanged = message as EventPartyChanged;
                    ProcessInsertCallDetails(eventPartyChanged.GetType(), eventPartyChanged);
                    break;
                }

                case EventAttachedDataChanged.MessageId:
                {
                    EventAttachedDataChanged eventDataChanged = message as EventAttachedDataChanged;
                    ProcessInsertCallDetails(eventDataChanged.GetType(), eventDataChanged);
                    break;
                }

                case EventDialing.MessageId:
                {
                    EventDialing eventDialing = message as EventDialing;
                    ProcessInsertCallDetails(eventDialing.GetType(), eventDialing);
                    break;
                }

                case EventRetrieved.MessageId:
                {
                    EventRetrieved eventRetrieved = message as EventRetrieved;
                    ProcessInsertCallDetails(eventRetrieved.GetType(), eventRetrieved);
                    break;
                }

                case EventAbandoned.MessageId:
                {
                    EventAbandoned eventAbandoned = message as EventAbandoned;
                    ProcessInsertCallDetails(eventAbandoned.GetType(), eventAbandoned);
                    break;
                }

                case EventPartyAdded.MessageId:
                {
                    EventPartyAdded eventPartyAdded = message as EventPartyAdded;
                    ProcessInsertCallDetails(eventPartyAdded.GetType(), eventPartyAdded);
                    break;
                }

                case EventPartyDeleted.MessageId:
                {
                    EventPartyDeleted eventpartyDeleted = message as EventPartyDeleted;
                    ProcessInsertCallDetails(eventpartyDeleted.GetType(), eventpartyDeleted);
                    break;
                }
                }
            }


            if (message.Id == EventRinging.MessageId)
            {
                // ProcessEventRaising(message as EventRinging);
            }
            else if (message.Id == EventReleased.MessageId)
            {
                //  ProcessEventRelease(message as EventReleased);
                EventReleased eventRelease = message as EventReleased;
                ProcessInsertCallDetails(eventRelease.GetType(), eventRelease);
            }
        }
        public static string GetSendCallDetailString(IMessage message)
        {
            string queryString = string.Empty;

            try
            {
                if (message != null)
                {
                    switch (message.Id)
                    {
                    case EventRinging.MessageId:
                    {
                        EventRinging eventRinging = message as EventRinging;
                        queryString  = ProcessKeyName(eventRinging.GetType(), eventRinging);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventRinging.UserData);
                        break;
                    }

                    case EventReleased.MessageId:
                    {
                        EventReleased eventRelease = message as EventReleased;
                        queryString  = ProcessKeyName(eventRelease.GetType(), eventRelease);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventRelease.UserData);
                        break;
                    }

                    case EventEstablished.MessageId:
                    {
                        EventEstablished eventEstablished = message as EventEstablished;
                        queryString  = ProcessKeyName(eventEstablished.GetType(), eventEstablished);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventEstablished.UserData);
                        break;
                    }

                    case EventPartyInfo.MessageId:
                    {
                        EventPartyInfo eventPartyInfo = message as EventPartyInfo;
                        queryString  = ProcessKeyName(eventPartyInfo.GetType(), eventPartyInfo);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventPartyInfo.UserData);
                        break;
                    }


                    case EventHeld.MessageId:
                    {
                        EventHeld eventHeld = message as EventHeld;
                        queryString  = ProcessKeyName(eventHeld.GetType(), eventHeld);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventHeld.UserData);
                        break;
                    }

                    case EventPartyChanged.MessageId:
                    {
                        EventPartyChanged eventPartyChanged = message as EventPartyChanged;
                        queryString  = ProcessKeyName(eventPartyChanged.GetType(), eventPartyChanged);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventPartyChanged.UserData);
                        break;
                    }

                    case EventAttachedDataChanged.MessageId:
                    {
                        EventAttachedDataChanged eventDataChanged = message as EventAttachedDataChanged;
                        queryString  = ProcessKeyName(eventDataChanged.GetType(), eventDataChanged);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventDataChanged.UserData);
                        break;
                    }

                    case EventDialing.MessageId:
                    {
                        EventDialing eventDialing = message as EventDialing;
                        queryString  = ProcessKeyName(eventDialing.GetType(), eventDialing);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventDialing.UserData);
                        break;
                    }

                    case EventRetrieved.MessageId:
                    {
                        EventRetrieved eventRetrieved = message as EventRetrieved;
                        queryString  = ProcessKeyName(eventRetrieved.GetType(), eventRetrieved);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventRetrieved.UserData);
                        break;
                    }

                    case EventAbandoned.MessageId:
                    {
                        EventAbandoned eventAbandoned = message as EventAbandoned;
                        queryString  = ProcessKeyName(eventAbandoned.GetType(), eventAbandoned);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventAbandoned.UserData);
                        break;
                    }

                    case EventPartyAdded.MessageId:
                    {
                        EventPartyAdded eventPartyAdded = message as EventPartyAdded;
                        queryString  = ProcessKeyName(eventPartyAdded.GetType(), eventPartyAdded);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventPartyAdded.UserData);
                        break;
                    }

                    case EventPartyDeleted.MessageId:
                    {
                        EventPartyDeleted eventpartyDeleted = message as EventPartyDeleted;
                        queryString  = ProcessKeyName(eventpartyDeleted.GetType(), eventpartyDeleted);
                        queryString += ((queryString.Length > 0) ? Settings.GetInstance().PortSetting.SendDataDelimiter : "") + ProcessUserData(eventpartyDeleted.UserData);
                        break;
                    }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(queryString);
        }