Example #1
0
        public void OnNext(iCallData value)
        {
            try
            {
                if (value == null || value.EventMessage == null)
                {
                    logger.Warn("Event detail is null.");
                    return;
                }

                if (objConfiguration.MediaType != value.MediaType)
                {
                    return;
                }

                if (value.EventMessage.Name.ToLower() != objConfiguration.FileEvent)
                {
                    return;
                }

                KeyValueCollection userData = null;
                Type   objType = null;
                object obj     = null;

                MediaEventHelper objEventHelper = new MediaEventHelper();
                switch (value.MediaType)
                {
                case MediaType.Voice:
                    if (!objEventHelper.ConvertVoiceEvent(ref objType, ref obj, ref userData, value.EventMessage))
                    {
                        logger.Warn("Voice event conversion getting failed");
                    }
                    break;

                case MediaType.Email:
                    if (!objEventHelper.ConvertEmailEvent(ref objType, ref obj, ref userData, value.EventMessage))
                    {
                        logger.Warn("Voice event conversion getting failed");
                    }
                    break;

                case MediaType.Chat:
                    if (!objEventHelper.ConvertChatEvent(ref objType, ref obj, ref userData, value.EventMessage))
                    {
                        logger.Warn("Voice event conversion getting failed");
                    }
                    break;

                case MediaType.SMS:
                    if (!objEventHelper.ConvertVoiceEvent(ref objType, ref obj, ref userData, value.EventMessage))
                    {
                        logger.Warn("Voice event conversion getting failed");
                    }
                    break;

                default:
                    logger.Warn("Unsupported media type");
                    break;
                }
                objEventHelper = null;

                // Functionality to send data in the specified format.
                if (objType != null && obj != null)
                {
                    switch (objConfiguration.FileFormat)
                    {
                    case "text":
                        ProcessTextFile(objType, obj, userData);
                        break;

                    case "json":
                        //SendJsonData(objType, obj, userdata);
                        break;

                    case "xml":
                        //SendXMLData(objType, obj, userdata);
                        break;

                    case "custom":
                        //SendTextData(objType, obj, userdata);
                        break;

                    default:
                        logger.Warn("The specified format not supported in the pipe integration");
                        break;
                    }
                }
                else
                {
                    logger.Warn("Required data is null.");
                }

                //if (ConfigContainer.Instance().AllKeys.Contains("enable.eclipse-integration") && ConfigContainer.Instance().GetAsBoolean("enable.eclipse-integration"))
                //{
                //    string sectionName = string.Empty;
                //    if (ConfigContainer.Instance().AllKeys.Contains("file.data-section"))
                //        sectionName = ConfigContainer.Instance().GetAsString("file.data-section");
                //    if (!string.IsNullOrEmpty(sectionName))
                //        PopupEclipseIntegration(objType, obj, userData, sectionName);
                //    else
                //        logger.Warn("Data section not available to file subscriber");
                //    return;
                //}
                //if (value.FileData.FileFormat == "text")
                //    WriteTextFile(objType, obj, userData, value);
                //if (value.FileData.FileFormat == "xml")
                //    WriteXMLFile(objType, obj, userData, value);
                //else
                //    PopupInformation(objType, obj, userData, value);

                DesktopMessenger.communicateUI.NotifyFileData(userData, setting.attachDataList, value.FileData.EnableView);
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while writing call data to a file " + generalException.ToString());
            }
        }