コード例 #1
0
        //Insert help session into the table storage
        public static void InsertOrUpdate(HelpSessionDataType entity)
        {
            //entity.PartitionKey = Settings.MainHost;
            entity.RowKey = "";

            var helper = new TableHelper(Settings.StorageAccountConnection, tablename);
            helper.InsertOrReplace<HelpSessionDataType>(entity);
        }
コード例 #2
0
 // Delete a help session form the table storage
 public static void Delete(string sessionId)
 {
     var entity = new HelpSessionDataType();
     entity.PartitionKey = sessionId;
     entity.RowKey = "";
     var helper = new TableHelper(Settings.StorageAccountConnection, tablename);
     helper.DeleteIfPresent<HelpSessionDataType>(entity, true);
 }
コード例 #3
0
 public ActionResult HelpDequeue()
 {
     CloudQueueMessage helpSessionKey = HelpSessionQueue.GetMessage();
     var model = new HelpSessionDataType();
     if(helpSessionKey == null)
     {
         Response.SetStatus(HttpStatusCode.NoContent);
         return null;
     }
     model = GetSession(helpSessionKey.AsString);
     HelpSessionQueue.DeleteMessage(helpSessionKey);
     var responseData = new
     {
         apiKey = Settings.Tk.ApiKey,
         sessionId = model.SessionId,
         token = Settings.Tk.GenerateToken(model.SessionId),
         customerName = model.CustomerName,
         problemText = model.ProblemText
     };
     return Json(responseData, JsonRequestBehavior.AllowGet);
 }
コード例 #4
0
 public ActionResult HelpSession()
 {
     string errorMessage = null;
         var customerName = Request.Params["customer_name"];
         var  problemText = Request.Params["problem_text"];
         Debug.WriteLine(customerName + problemText);
         // Validation for the text fields
         if (customerName.IsEmpty() || problemText.IsEmpty())
         {
             errorMessage = "The fields customer_name and problem_text are required.";
         }
         if (customerName.Length > 50)
         {
             errorMessage = "The field customer_name is too long";
         }
         if (problemText.Length > 200)
         {
             errorMessage = "The field problem_text is too long";
         }
         if (!(errorMessage.IsEmpty()))
         {
             Response.SetStatus(400);
             return Json(errorMessage);
         }
         var session = Settings.Tk.CreateSession();
         var model = new HelpSessionDataType
         {
             PartitionKey = session.Id,
             ProblemText = problemText,
             CustomerName = customerName,
             SessionId = session.Id
         };
         HelpSessionData.InsertOrUpdate(model);
         var responseData =
             new {apiKey = Settings.Tk.ApiKey, sessionId = session.Id, token = session.GenerateToken()};
         Response.ContentType = "application/json";
         return Json(responseData, JsonRequestBehavior.AllowGet);
 }