Exemple #1
0
        public async Task <IActionResult> PutMissedCall(int id, MissedCall missedCall)
        {
            if (id != missedCall.Id)
            {
                return(BadRequest());
            }

            context.Entry(missedCall).State = EntityState.Modified;

            try
            {
                await context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MissedCallExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
        public async Task <ActionResult <MissedCall> > PostMissedCall(MissedCall missedCall)
        {
            try
            {
                TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");

                missedCall.EventTime = TimeZoneInfo.ConvertTimeFromUtc(missedCall.EventTime.ToUniversalTime(), cstZone);

                // to check if the missed call is from the whitelisted numbers
                var whiteList = context.WhiteList.Where(x => x.MobileNumber.Equals(missedCall.CustomerMobileNumber)).FirstOrDefault();

                if (whiteList?.MobileNumber != null)
                {
                    missedCall.IsWhiteListed = true;

                    missedCall.CustomerName = whiteList.Name;
                }

                context.MissedCalls.Add(missedCall);

                await context.SaveChangesAsync();

                logger.LogInformation("Post Missed Call successfull");

                return(CreatedAtAction("GetMissedCall", new { id = missedCall.Id }, missedCall));
            }
            catch (Exception ex)
            {
                logger.LogError("Exception in PostMissedCall" + ex.Message);

                return(StatusCode((int)HttpStatusCode.InternalServerError, "Error in Posting Missed Call Obnect"));
            }
        }
        public string PostToTata(MissedCall objMissedCall)
        {
            try
            {
                // URL format for tata bss service
                //URL :  http://14.141.40.188/NeoGrowthService/NGrowthService.svc/ImportDataFromDigitalImportDataFromDigital /
                //       {sCallFrom}/{sCallTo}/{sProvider}/{sLocation}/{sSource}

                var baseAddress = ConfigurationManager.AppSettings["MissedURL"];
                baseAddress = baseAddress + "/" + objMissedCall.CallFrom + "/" + objMissedCall.CallTo + "/" + objMissedCall.Provider + "/" + objMissedCall.Location + "/" + objMissedCall.Source;
                var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress));
                http.Accept      = "application/json";
                http.ContentType = "application/json";
                http.Method      = "GET";
                var     response = http.GetResponse();
                var     stream   = response.GetResponseStream();
                var     sr       = new StreamReader(stream);
                var     content  = sr.ReadToEnd();
                dynamic dynObj   = JsonConvert.DeserializeObject(content);
                if (!string.IsNullOrEmpty(dynObj.ImportDataFromMissedCallResult._sStatus.Value))
                {
                    return(dynObj.ImportDataFromMissedCallResult._sStatus.Value);
                }
                else
                {
                    return("FAILURE");
                }
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
        public string TrackMissedCall(string clid, string calltime, string called)
        {
            string    sYear           = DateTime.Now.Year.ToString();
            string    sMonth          = DateTime.Now.Month.ToString();
            string    sDay            = DateTime.Now.Day.ToString();
            string    sErrorTime      = sYear + sMonth + sDay;
            string    filePath        = HttpContext.Current.Server.MapPath("~/App_Data/TrackMissedCall_" + sErrorTime + ".log");
            LogEvents log             = new LogEvents();
            string    TataBSSResponse = "";

            try
            {
                MissedCall objMissedCall = new MissedCall();
                objMissedCall.CallTo   = called;
                objMissedCall.CallFrom = clid;
                objMissedCall.Provider = "NA";
                objMissedCall.Location = "NA";
                objMissedCall.Source   = "MissedCall";
                TataBSSResponse        = PostToTata(objMissedCall);
                log.Logevent("clid = " + clid + " calltime = " + calltime + " called= " + called + " TataBSSResponse = " + TataBSSResponse, filePath);
                return("success");
            }
            catch (Exception ex)
            {
                log.Logevent(ex.Message, filePath);
                return("fail");
            }
        }
Exemple #5
0
 private void Channel_UnsolicitedEvent(object sender, UnsolicitedEventArgs e)
 {
     if (e.Line1 == "RING")
     {
         IncomingCall?.Invoke(this, new IncomingCallEventArgs());
     }
     else if (e.Line1.StartsWith("VOICE CALL: BEGIN"))
     {
         CallStarted?.Invoke(this, new CallStartedEventArgs());
     }
     else if (e.Line1.StartsWith("VOICE CALL: END"))
     {
         CallEnded?.Invoke(this, CallEndedEventArgs.CreateFromResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("MISSED_CALL: "))
     {
         MissedCall?.Invoke(this, MissedCallEventArgs.CreateFromResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("+CMTI: "))
     {
         SmsReceived?.Invoke(this, SmsReceivedEventArgs.CreateFromResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("+CUSD: "))
     {
         UssdResponseReceived?.Invoke(this, UssdResponseEventArgs.CreateFromResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("+CME ERROR:"))
     {
         ErrorReceived?.Invoke(this, ErrorEventArgs.CreateFromCmeResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("+CMS ERROR:"))
     {
         ErrorReceived?.Invoke(this, ErrorEventArgs.CreateFromCmsResponse(e.Line1));
     }
 }
        private async Task CreateMissedCallAndRedirectToVoiceMail(string taskAttributes)
        {
            dynamic attributes = JsonConvert.DeserializeObject(taskAttributes);
            var     missedCall = new MissedCall
            {
                PhoneNumber = attributes.from,
                Product     = attributes.selected_product,
                CreatedAt   = DateTime.Now
            };

            await _service.CreateAsync(missedCall);

            string voiceSid = attributes.call_sid;

            VoiceMail(voiceSid);
        }
Exemple #7
0
 protected void OnMissedCall(string str)
 {
     MissedCall?.Invoke(this, str);
 }
 public async Task <int> CreateAsync(MissedCall missedCall)
 {
     _context.MissedCalls.Add(missedCall);
     return(await _context.SaveChangesAsync());
 }
Exemple #9
0
 private static Boolean KawigiEdit_RunTest(int testNum, int p0, int p1, int p2, Boolean hasAnswer, int p3)
 {
     Console.Write("Test " + testNum + ": [" + p0 + "," + p1 + "," + p2);
     Console.WriteLine("]");
     MissedCall obj;
     int answer;
     obj = new MissedCall();
     DateTime startTime = DateTime.Now;
     answer = obj.waitingTime(p0, p1, p2);
     DateTime endTime = DateTime.Now;
     Boolean res;
     res = true;
     Console.WriteLine("Time: " + (endTime - startTime).TotalSeconds + " seconds");
     if (hasAnswer) {
         Console.WriteLine("Desired answer:");
         Console.WriteLine("\t" + p3);
     }
     Console.WriteLine("Your answer:");
     Console.WriteLine("\t" + answer);
     if (hasAnswer) {
         res = answer == p3;
     }
     if (!res) {
         Console.WriteLine("DOESN'T MATCH!!!!");
     } else if ((endTime - startTime).TotalSeconds >= 2) {
         Console.WriteLine("FAIL the timeout");
         res = false;
     } else if (hasAnswer) {
         Console.WriteLine("Match :-)");
     } else {
         Console.WriteLine("OK, but is it right?");
     }
     Console.WriteLine("");
     return res;
 }
Exemple #10
0
            public void MissedCallsDetail(DateTime start_dt, DateTime end_dt, string queues, string agents)
            {
                MySqlConnection con = GetConnection();
                MySqlCommand com = new MySqlCommand("missed_calls", con);
                com.CommandType = System.Data.CommandType.StoredProcedure;
                com.Parameters.Add(new MySqlParameter("?start_dt", start_dt.ToString("yyyy-MM-dd hh:mm")));
                com.Parameters.Add(new MySqlParameter("?end_dt", end_dt.ToString("yyyy-MM-dd hh:mm")));
                MySqlDataReader rdr = com.ExecuteReader();

                if (rdr.HasRows)
                    foreach (DbDataRecord record in rdr)
                    {
                        DateTime edt = Convert.ToDateTime(record["edt"]);
                        DateTime adt = Convert.ToDateTime(record["adt"]);
                        MissedCall mc = MissedCalls.Find(p => p.uniqueid == record["uniqueid"].ToString());

                        if (mc == null)
                        {
                            mc = new MissedCall();
                            mc.uniqueid = record["uniqueid"].ToString();
                            MissedCalls.Add(mc);
                        }

                        mc.start_pos = Convert.ToInt32(record["ainfo2"]);
                        mc.end_pos = Convert.ToInt32(record["ainfo1"]);
                        mc.Queue = record["qname"].ToString();
                        mc.AbandonDt = adt;
                        mc.WaitTime = Convert.ToInt32(record["ainfo3"]);
                        mc.EnterQueueDt = edt;
                        mc.phonenumber = record["einfo2"].ToString();
                        mc.agent = record["agent"].ToString();
                        mc.WaitTimeForOperator = new TimeSpan(0, 0 , Convert.ToInt32(record["waittime"]));
                    }

                rdr.Close();
                con.Close();
            }