public CommunicationInfo(CommunicationEntry dbCommunication)
        {
            this.CommunicationGUID = dbCommunication.Id;
            this.Type = dbCommunication.Type;
            this.Tag = dbCommunication.Tag;
            this.Status = dbCommunication.Status;
            this.IncidentGUID = (dbCommunication.IncidentID != null) ? dbCommunication.IncidentID : "NONE";
            this.Notes = dbCommunication.Notes;
            this.StartTime = (dbCommunication.StartTime != null) ? dbCommunication.StartTime : null; //DateTime.Now;
            this.EndTime = (dbCommunication.EndTime != null) ? dbCommunication.EndTime : null; //DateTime.Now;

            //Create UserInfo Object based upon Passed in ProviderUserID [Call to DB Made in Constructor]
            AccountInfo lookupUser = new AccountInfo(dbCommunication.OperatorID);
            this.OperatorAccountInfo = lookupUser;
        }
        public CommunicationInfo(CommunicationEntry dbCommunication)
        {
            this.CommunicationGUID = dbCommunication.Id;
            this.Type         = dbCommunication.Type;
            this.Tag          = dbCommunication.Tag;
            this.Status       = dbCommunication.Status;
            this.IncidentGUID = (dbCommunication.IncidentID != null) ? dbCommunication.IncidentID : "NONE";
            this.Notes        = dbCommunication.Notes;
            this.StartTime    = (dbCommunication.StartTime != null) ? dbCommunication.StartTime : null; //DateTime.Now;
            this.EndTime      = (dbCommunication.EndTime != null) ? dbCommunication.EndTime : null;     //DateTime.Now;

            //Create UserInfo Object based upon Passed in ProviderUserID [Call to DB Made in Constructor]
            AccountInfo lookupUser = new AccountInfo(dbCommunication.OperatorID);

            this.OperatorAccountInfo = lookupUser;
        }
        public async Task<HttpResponseMessage> CustomerClientExceptionContact(ExceptionContactRequest contactRequest)
        {
            Services.Log.Warn("Mobile Customer Client Exception Contact Request [API]");
            string responseText = "";

            IHubContext hubContext = Services.GetRealtime<IncidentHub>();

            CommunicationEntry newCommunication = new CommunicationEntry()
            {
                Id = Guid.NewGuid().ToString(),
                Tag = contactRequest.ContactPhone,
                IncidentID = contactRequest.IncidentGUID,
                Type = "MOBILE CUSTOMER CLIENT EXCEPTION CONTACT REQUEST",
                Status = "SUBMITTED",
                StartTime = DateTime.Now
            };

            stranddContext context = new stranddContext();
            context.CommunicationLog.Add(newCommunication);

            await context.SaveChangesAsync();
            responseText = "Communication Logged in Service";
            Services.Log.Info(responseText);
            responseText = "";

            if (contactRequest.ContactPhone != null)
            {
                responseText += "CONTACT CUSTOMER on Phone [" + contactRequest.ContactPhone + "] ";
            }

            if (contactRequest.IncidentGUID != null)
            {
                responseText += " | Exception on Incident [" + contactRequest.IncidentGUID + "]" ;
                //hubContext.Clients.All.updateIncidentCustomerError(responseText);
            }

            Services.Log.Warn(responseText);

            hubContext.Clients.All.notifyCustomerClientExceptionContact(new CommunicationInfo(newCommunication));
            Services.Log.Info("Connected Clients Updated");

            //Return Successful Response
            return this.Request.CreateResponse(HttpStatusCode.OK, responseText);

            //PENDING TO ADD: Incident Updation with Error
        }
        public async Task<HttpResponseMessage> inboundSms()
        {
            Microsoft.AspNet.SignalR.IHubContext hubContext = Services.GetRealtime<IncidentHub>();
            Services.Log.Info("Inbound SMS Request");

            String Type = "INBOUND SMS";
            String ID = Guid.NewGuid().ToString();

            var queryStrings = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value);
            String from = String.Empty;
            String message = String.Empty;
            String ts = String.Empty;


            if (queryStrings.ContainsKey("from"))
            {
                from = queryStrings["from"];
            }
            if (queryStrings.ContainsKey("message"))
            {
                message = queryStrings["message"];
            }
            if (queryStrings.ContainsKey("ts"))
            {
                ts = queryStrings["ts"];
            }

        
            //store at DB Level
           // LogInboundOutboundMessageToDB(ID, Type, from, "SUBMITTED", "Source", message);

            CommunicationEntry newCommunication = new CommunicationEntry()
            {
                Id = ID,
                Type = Type,
                Tag = from,
                Status = "SUBMITTED",
                Text = message,
                StartTime = DateTime.Now
            };


            stranddContext context = new stranddContext();
            context.CommunicationLog.Add(newCommunication);

            await context.SaveChangesAsync();
            String responseText = ("New Communication Log Created #" + ID);
            Services.Log.Info(responseText);
         
          //  return this.Request.CreateResponse(HttpStatusCode.Created, responseText);


            //----------------------------NOTIFICATION INBOUND SMS CODE-------------------------------//
            responseText = "";

            if (from != null)
            {
                responseText += "Please call [" + from + "] ";
            }

            if (message != null)
            {
                responseText += "[" + message + "]";
                //hubContext.Clients.All.updateIncidentCustomerError(responseText);
            }

            Services.Log.Warn(responseText);

           // hubContext.Clients.All.notifyCustomerClientExceptionContact(new CommunicationInfo(newCommunication));
            hubContext.Clients.All.notifyCustomerNewInboundSmsContact(new InboundsmsInfo(newCommunication));
            Services.Log.Info("Inbound Notification Cerated.");


           // Outbound SMS triggered to above Number with following text from MM-STRNDD:
            String strdownloadlink = ConfigurationManager.AppSettings["Appdownloadlink"];
            strdownloadlink = "<" + "a href='" + strdownloadlink + "'>" + strdownloadlink + "<a>";
          
            CommunicationsLogOutboundRequest communicationRequest = new CommunicationsLogOutboundRequest();
            communicationRequest.MobileNo = from;
            communicationRequest.Message = "Please download the StrandD App [" + strdownloadlink + "] so we can better assist you incase you need us again.";

            await OutboundSms(communicationRequest);

            //Return Successful Response
            return this.Request.CreateResponse(HttpStatusCode.OK, responseText);

            //----------------------------NOTIFICATION INBOUND SMS CODE END-------------------------------//

        }
        private void LogOutboundMessageToDB(String ID, String Type, String Tag, String Status, String Source, String Text)
        {
            CommunicationEntry newCommlog = new CommunicationEntry()
            {
                Id = ID,
                Type = Type,
                Tag = Tag,
                Status = "SUBMITTED",
                Source = Source,
                Text = Text,
                StartTime = DateTime.Now
            };

            stranddContext context = new stranddContext();
            context.CommunicationLog.Add(newCommlog);

            //Save record
            context.SaveChangesAsync();


        }
Example #6
0
 public InboundsmsInfo(CommunicationEntry dbCommunication)
 {
     this.Type = dbCommunication.Type;
     this.Tag  = dbCommunication.Tag;
     this.Text = dbCommunication.Text;
 }
 public InboundsmsInfo(CommunicationEntry dbCommunication)
 {
     this.Type = dbCommunication.Type;
     this.Tag = dbCommunication.Tag;
     this.Text = dbCommunication.Text;
 }