public DataSet UpdateCallBackRequestStatus(UDC.OutboundCall callObj)
 {
     _cmd = new SqlCommand();
     _ds  = new DataSet();
     _da  = new SqlDataAdapter();
     try
     {
         _cmd.CommandText = "UpdateCallBackRequestStatus";
         _cmd.CommandType = CommandType.StoredProcedure;
         _cmd.Connection  = Connection;
         _cmd.Parameters.Add("@CallId", SqlDbType.Int).Value                     = callObj.Id;
         _cmd.Parameters.Add("@StartTime", SqlDbType.Int).Value                  = callObj.AnswerTime;
         _cmd.Parameters.Add("@EndReason", SqlDbType.VarChar, 225).Value         = callObj.EndReason;
         _cmd.Parameters.Add("@HangupDisposition", SqlDbType.VarChar, 225).Value = callObj.HangupDisposition;
         _cmd.Parameters.Add("@Message", SqlDbType.VarChar, 500).Direction       = ParameterDirection.Output;
         _cmd.Parameters.Add("@Success", SqlDbType.Bit).Direction                = ParameterDirection.Output;
         Connection.Open();
         _cmd.ExecuteNonQuery();
         Connection.Close();
         _ds.Tables.Add(_helper.ConvertOutputParametersToDataTable(_cmd.Parameters));
     }
     catch (Exception ex)
     {
         Logger.Error(ex.ToString());
     }
     finally
     {
         _cmd = null;
         _da  = null;
         Connection.Close();
     }
     return(_ds);
 }
 public DataSet UpdateOutboundConferenceDetails(UDC.OutboundCall callObj)
 {
     _cmd = new SqlCommand();
     _ds  = new DataSet();
     _da  = new SqlDataAdapter();
     try
     {
         _cmd.CommandText = "UpdateOutboundConferenceDetails";
         _cmd.CommandType = CommandType.StoredProcedure;
         _cmd.Connection  = Connection;
         _cmd.Parameters.Add("@CallId", SqlDbType.Int).Value  = callObj.Id;
         _cmd.Parameters.Add("@AgentId", SqlDbType.Int).Value = callObj.AgentId;
         _cmd.Parameters.Add("@ConferenceRoom", SqlDbType.VarChar, 100).Value = callObj.ConferenceName;
         _cmd.Parameters.Add("@IsCustomer", SqlDbType.Bit).Value                = callObj.IsCustomer;
         _cmd.Parameters.Add("@Event", SqlDbType.VarChar, 100).Value            = callObj.Event;
         _cmd.Parameters.Add("@ConferenceAction", SqlDbType.VarChar, 100).Value = callObj.ConferenceAction;
         _cmd.Parameters.Add("@RequestUUID", SqlDbType.VarChar, 225).Value      = callObj.RequestUUID;
         _cmd.Parameters.Add("@FromNumber", SqlDbType.VarChar, 20).Value        = callObj.Source;
         _cmd.Parameters.Add("@ToNumber", SqlDbType.VarChar, 20).Value          = callObj.Destination;
         _cmd.Parameters.Add("@FsMemberId", SqlDbType.Int).Value                = callObj.FsMemberId;
         _cmd.Parameters.Add("@EventTimeStamp", SqlDbType.BigInt).Value         = callObj.EventTimeStamp;
         _cmd.Parameters.Add("@Message", SqlDbType.VarChar, 500).Direction      = ParameterDirection.Output;
         _cmd.Parameters.Add("@Success", SqlDbType.Bit).Direction               = ParameterDirection.Output;
         Connection.Open();
         _cmd.ExecuteNonQuery();
         Connection.Close();
         _ds.Tables.Add(_helper.ConvertOutputParametersToDataTable(_cmd.Parameters));
     }
     catch (Exception ex)
     {
         Logger.Error(ex.ToString());
     }
     finally
     {
         _cmd = null;
         _da  = null;
         Connection.Close();
     }
     return(_ds);
 }
示例#3
0
        public JObject UpdateCallDetails(HttpContext context, string connectionString, string outboundCallBackUrl, bool isCustomer, int agentId, string voiceClipPath)
        {
            JObject  resObj = new JObject();
            Gateways gatewayObj = new Gateways();
            DataSet  ds = null;
            string   conferenceRoom = ""; string gatewayURL = "";

            try
            {
                ParseParameters(context);
                UDC.OutboundCall callObj = new UDC.OutboundCall();
                Press3.DataAccessLayer.OutboundCall outboundCallObj = new Press3.DataAccessLayer.OutboundCall(connectionString);

                if (httpParameters.Event == "newcall")
                {
                    callObj.Event      = httpParameters.Event;
                    callObj.Id         = httpParameters.SequenceNumber;
                    callObj.IsCustomer = isCustomer;
                    if (!isCustomer)
                    {
                        JObject messageJobj = new JObject(new JProperty("Channel_Name", "Agent_o_" + httpParameters.CallUUid),
                                                          new JProperty("Message", httpParameters.CallStatus),
                                                          new JProperty("CallId", httpParameters.SequenceNumber),
                                                          new JProperty("Event", httpParameters.Event));
                        Press3.DataAccessLayer.WebSocketController WSCObj = new Press3.DataAccessLayer.WebSocketController(connectionString);
                        WSCObj.InsertWsNofificationQueue(messageJobj.ToString());
                    }
                    Logger.Info("WebSocket newcall event");

                    ds = outboundCallObj.UpdateCallDetails(callObj);
                    if (ds == null)
                    {
                        helper.CreateProperty(UDC.Label.MESSAGE, "No data returned from database");
                        helper.CreateProperty(UDC.Label.SUCCESS, false);
                    }
                    else
                    {
                        ds = outboundCallObj.GetAgentConferenceRoom(httpParameters.SequenceNumber);
                        if (ds == null)
                        {
                            helper.CreateProperty(UDC.Label.MESSAGE, "No data returned from database");
                            helper.CreateProperty(UDC.Label.SUCCESS, false);
                        }
                        else
                        {
                            if (ds.Tables.Count > 0)
                            {
                                if (Convert.ToBoolean(ds.Tables[0].Rows[0]["Success"]))
                                {
                                    conferenceRoom = ds.Tables[0].Rows[0]["ConferenceRoom"].ToString();
                                }
                            }
                        }

                        if (isCustomer)
                        {
                            if (conferenceRoom != "")
                            {
                                helper.CreateProperty(UDC.Label.RESPONSEXML, "<Response><Conference callbackUrl='" + outboundCallBackUrl + "?IsCustomer=true&amp;AgentId=" + agentId + "'>" + conferenceRoom + "</Conference></Response>");
                            }
                            else
                            {
                                helper.CreateProperty(UDC.Label.RESPONSEXML, "<Response></Hangup></Response>");
                            }
                        }
                        else
                        {
                            helper.CreateProperty(UDC.Label.RESPONSEXML, "<Response><Conference waitSound='" + voiceClipPath + "AloneWaitClip.mp3' callbackUrl='" + outboundCallBackUrl + "?IsCustomer=false&amp;AgentId=" + agentId + "'>" + httpParameters.CallUUid + "</Conference></Response>");
                        }
                        helper.ParseDataSet(ds);
                    }
                }
                else if (httpParameters.Event == "hangup")
                {
                    callObj.Event             = httpParameters.Event;
                    callObj.Id                = httpParameters.SequenceNumber;
                    callObj.RingTime          = httpParameters.RingTIme;
                    callObj.AnswerTime        = httpParameters.StartTime;
                    callObj.EndTime           = httpParameters.EndTime;
                    callObj.EndReason         = httpParameters.EndReason;
                    callObj.HangupDisposition = httpParameters.HangupDisposition;
                    callObj.IsCustomer        = isCustomer;

                    JObject messageJobj = new JObject();
                    Press3.DataAccessLayer.WebSocketController WSCObj = new Press3.DataAccessLayer.WebSocketController(connectionString);

                    if (!isCustomer)
                    {
                        messageJobj = new JObject(new JProperty("Channel_Name", "Agent_o_" + httpParameters.CallUUid),
                                                  new JProperty("Message", httpParameters.EndReason),
                                                  new JProperty("CallId", httpParameters.SequenceNumber),
                                                  new JProperty("Event", httpParameters.Event));
                        WSCObj.InsertWsNofificationQueue(messageJobj.ToString());
                    }


                    ds = outboundCallObj.UpdateCallDetails(callObj);
                    if (ds == null)
                    {
                        helper.CreateProperty(UDC.Label.MESSAGE, "No data returned from database");
                        helper.CreateProperty(UDC.Label.SUCCESS, false);
                    }
                    else
                    {
                        ds = outboundCallObj.GetAgentConferenceRoom(httpParameters.SequenceNumber);
                        if (ds == null)
                        {
                            helper.CreateProperty(UDC.Label.MESSAGE, "No data returned from database");
                            helper.CreateProperty(UDC.Label.SUCCESS, false);
                        }
                        else
                        {
                            if (ds.Tables.Count > 0)
                            {
                                if (Convert.ToBoolean(ds.Tables[0].Rows[0]["Success"]))
                                {
                                    gatewayURL     = ds.Tables[0].Rows[0]["GatewayURL"].ToString();
                                    conferenceRoom = ds.Tables[0].Rows[0]["ConferenceRoom"].ToString();
                                }
                            }
                        }
                        helper.ParseDataSet(ds);
                    }


                    messageJobj = new JObject(new JProperty("Channel_Name", "Agent_" + agentId),
                                              new JProperty("CallId", httpParameters.SequenceNumber.ToString()),
                                              new JProperty("ConferenceRoom", conferenceRoom),
                                              new JProperty("FromNumber", httpParameters.FromNumber),
                                              new JProperty("IsAgent", true),
                                              new JProperty("CallType", 1),
                                              new JProperty("RequestUUID", httpParameters.RequestUuid),
                                              new JProperty("IsOutbound", 1),
                                              new JProperty("Event", "exit"));
                    WSCObj.InsertWsNofificationQueue(messageJobj.ToString());
                    Logger.Info("WebSocket hangup event");


                    JObject  apiResponseObj                   = new JObject();
                    JObject  apiResponseObjPrivate            = new JObject();
                    Gateways gatewaysObj                      = new Gateways();
                    Press3.DataAccessLayer.Conference confObj = new Press3.DataAccessLayer.Conference(connectionString);
                    apiResponseObj        = gatewaysObj.RestApiRequest("ConferenceName=" + conferenceRoom + "&MemberID=all", gatewayURL + "ConferenceHangup/", "POST");
                    apiResponseObjPrivate = gatewaysObj.RestApiRequest("ConferenceName=private_" + conferenceRoom + "&MemberID=all", gatewayURL + "ConferenceHangup/", "POST");

                    if (isCustomer)
                    {
                        ds = outboundCallObj.UpdateCallBackRequestStatus(callObj);
                        if (ds == null)
                        {
                            helper.CreateProperty(UDC.Label.MESSAGE, "No data returned from database");
                            helper.CreateProperty(UDC.Label.SUCCESS, false);
                        }
                        else
                        {
                            helper.ParseDataSet(ds);
                        }
                    }
                }
                else if (httpParameters.Event == "conference" && httpParameters.ConferenceAction == "enter")
                {
                    callObj.Id               = httpParameters.SequenceNumber;
                    callObj.Event            = httpParameters.Event;
                    callObj.ConferenceAction = httpParameters.ConferenceAction;
                    callObj.RequestUUID      = httpParameters.RequestUuid;
                    callObj.Source           = httpParameters.FromNumber;
                    callObj.Destination      = httpParameters.ToNumber;
                    callObj.FsMemberId       = httpParameters.ConferenceMemberID;
                    callObj.IsCustomer       = isCustomer;
                    callObj.EventTimeStamp   = httpParameters.Eventtimestamp;
                    callObj.ConferenceName   = httpParameters.ConferenceName;
                    callObj.AgentId          = agentId;

                    if (isCustomer)
                    {
                        if (!httpParameters.ConferenceName.StartsWith("private"))
                        {
                            JObject messageJobj = new JObject(new JProperty("Channel_Name", "Agent_" + agentId),
                                                              new JProperty("CallId", httpParameters.SequenceNumber.ToString()),
                                                              new JProperty("ConferenceRoom", httpParameters.ConferenceName),
                                                              new JProperty("FromNumber", httpParameters.FromNumber),
                                                              new JProperty("IsAgent", true),
                                                              new JProperty("CallType", 1),
                                                              new JProperty("RequestUUID", httpParameters.RequestUuid),
                                                              new JProperty("IsOutbound", 1),
                                                              new JProperty("Event", httpParameters.ConferenceAction));
                            Press3.DataAccessLayer.WebSocketController WSCObj = new Press3.DataAccessLayer.WebSocketController(connectionString);
                            WSCObj.InsertWsNofificationQueue(messageJobj.ToString());
                        }
                    }
                    else
                    {
                        JObject messageJobj = new JObject(new JProperty("Channel_Name", "Agent_" + agentId),
                                                          new JProperty("CallId", httpParameters.SequenceNumber.ToString()),
                                                          new JProperty("ConferenceRoom", httpParameters.ConferenceName),
                                                          new JProperty("FromNumber", httpParameters.FromNumber),
                                                          new JProperty("IsAgent", true),
                                                          new JProperty("CallType", 9),
                                                          new JProperty("RequestUUID", httpParameters.RequestUuid),
                                                          new JProperty("IsOutbound", 1),
                                                          new JProperty("ConferenceEvent", httpParameters.ConferenceAction),
                                                          new JProperty("Event", "CustomerOutBound"));
                        Press3.DataAccessLayer.WebSocketController WSCObj = new Press3.DataAccessLayer.WebSocketController(connectionString);
                        WSCObj.InsertWsNofificationQueue(messageJobj.ToString());
                    }

                    ds = outboundCallObj.UpdateOutboundConferenceDetails(callObj);
                    if (ds == null)
                    {
                        helper.CreateProperty(UDC.Label.MESSAGE, "No data returned from database");
                        helper.CreateProperty(UDC.Label.SUCCESS, false);
                    }
                    else
                    {
                        helper.ParseDataSet(ds);
                    }
                }
                else if (httpParameters.Event == "conference" && httpParameters.ConferenceAction == "exit")
                {
                    callObj.Id               = httpParameters.SequenceNumber;
                    callObj.Event            = httpParameters.Event;
                    callObj.ConferenceAction = httpParameters.ConferenceAction;
                    callObj.FsMemberId       = httpParameters.ConferenceMemberID;
                    callObj.EventTimeStamp   = httpParameters.Eventtimestamp;

                    ds = outboundCallObj.UpdateOutboundConferenceDetails(callObj);
                    if (ds == null)
                    {
                        helper.CreateProperty(UDC.Label.MESSAGE, "No data returned from database");
                        helper.CreateProperty(UDC.Label.SUCCESS, false);
                    }
                    else
                    {
                        helper.ParseDataSet(ds);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Exception in BAL.UpdateCallDetails" + ex.ToString());
            }
            return(helper.GetResponse());
        }