public void SetUpAllEmails(EmailListJSON loadedEmails) // Called from XMLSaveLoad { foreach (EmailEntry email in loadedEmails.emailEntries) { if (email.entryID != "____") // Only continue if this is not a blank entry { allEmailsInData.Add(email); Debug.Log("loaded email entryID = " + email.entryID + " | conversationID = " + email.conversationID); // Make new EmailConversations if not already made if (emailConversationsDictionary.ContainsKey(email.conversationID) == false) { EmailConversation newConversation = new EmailConversation(); newConversation.conversationID = email.conversationID; emailConversationsDictionary.Add(newConversation.conversationID, newConversation); Debug.Log("Created New Email Conversation: " + newConversation.conversationID); // Add the initial email newConversation.AddNextEmail(email); } // Check if player has received this email before. If so, add it to the conversation if (email.received) { emailConversationsDictionary[email.conversationID].AddNextEmail(email); } // Find Max stage for each conversation emailConversationsDictionary[email.conversationID].CheckMaxStage(email.stage); } } CheckNotifications(); }
void PopulateConversationsList() // The Screen where it shows all conversations and the latest from each { foreach (KeyValuePair <string, EmailConversation> eConvo in EM.emailConversationsDictionary) { EmailConversation conversation = eConvo.Value; GameObject emailConversationHeader; if (!eConvo.Value.uiHeaderExists) { // Set up Email Conversation Prefab and Text, etc emailConversationHeader = GameObject.Instantiate(emailPrefab, emailListScrollContent); conversation.inGameHeader = emailConversationHeader; conversation.uiHeaderExists = true; } EmailEntry latestEmail = eConvo.Value.GetLatestEmail(); conversation.inGameHeader.transform.Find("Text_Name").GetComponent <Text>().text = latestEmail.characterName; conversation.inGameHeader.transform.Find("Text_Subject").GetComponent <Text>().text = latestEmail.bodyText; Transform readButton = conversation.inGameHeader.transform.Find("Button_Open"); // Display "NEW" if has an unread email if (conversation.unreadEmail) { readButton.GetComponent <Image>().color = Color.yellow; readButton.GetComponentInChildren <Text>().text = "New Message!"; } else { readButton.GetComponent <Image>().color = Color.white; readButton.GetComponentInChildren <Text>().text = "Open"; } // Set up button readButton.GetComponent <Button>().onClick.AddListener(delegate { CreateEmailConversation(latestEmail.conversationID); }); } }
public ActionResult CreateEmailConversation([FromBody] EmailConversationDTO emailConversationDTO) { if (!ModelState.IsValid) { return(BadRequest()); } if (emailConversationDTO == null) { return(BadRequest()); } var checkEmailConversationIdinDb = _choiceRepoistory.GetEmailConversation().Find(c => c.EmailConversationId == emailConversationDTO.EmailConversationId); if (checkEmailConversationIdinDb != null) { return(BadRequest()); } EmailConversation newlyEmailConversation = new EmailConversation() { EmailTitle = emailConversationDTO.EmailTitle, Message = emailConversationDTO.Message, Sender = emailConversationDTO.Sender, CCAddress = emailConversationDTO.CCAddress, BookingId = emailConversationDTO.BookingId, MessageId = emailConversationDTO.MessageId, To = emailConversationDTO.To, CreatedDate = emailConversationDTO.CreatedDate, CreatedBy = emailConversationDTO.CreatedBy, SharepointId = emailConversationDTO.SharepointId, }; _choiceRepoistory.SetEmailConversation(newlyEmailConversation); _choiceRepoistory.Complete(); return(CreatedAtRoute("GetEmailConversationById", new { emailConversationId = newlyEmailConversation.EmailConversationId }, newlyEmailConversation)); }
public void SetEmailConversation(EmailConversation emailConversation) { _dbContext.EmailConversation.Add(emailConversation); }
public void Init() { instance = new EmailConversation(); }
/// <summary> /// currentEmail is the EmailEntry the player is replying to. /// playerReplyGBN is a single-character string g,b,or n /// </summary> /// <param name="currentEmail"></param> public void RecordPlayerReplyAndQueueNextEmail(EmailEntry currentEmail, string playerReplyGBN, string playerReplyFull) // Will run when player has replied to an email. Finds next Email, Packs it, sends to DeliveryMgr // NOTE: Has to queue TWO emails: The initial reply *and* the next item order (if there is one) { EmailConversation currentConversation = emailConversationsDictionary[currentEmail.conversationID]; // -------------------- RECORD PLAYER RESPONSE -------------- // Before Anything else, record the player's response. Important for saving and loading emails later currentEmail.playerReplyGBN = playerReplyGBN; currentEmail.replied = true; EmailEntry playerReplyEmail = new EmailEntry(); playerReplyEmail.conversationID = currentEmail.conversationID; playerReplyEmail.characterName = "Player"; playerReplyEmail.stage = currentEmail.stage; playerReplyEmail.entryID = currentEmail.conversationID + "_" + currentEmail.stage + "_" + "player"; playerReplyEmail.bodyText = playerReplyFull; playerReplyEmail.received = true; playerReplyEmail.dateTime = System.DateTime.Now.ToString("dddd MMM dd h:mm:ss tt"); // Put player reply to allEmails List in the right spot int targetIndex = allEmailsInData.IndexOf(currentEmail) + 1; allEmailsInData.Insert(targetIndex, playerReplyEmail); // Add player reply to Conversation currentConversation.AddNextEmail(playerReplyEmail); // ----------------- FIND NEXT EMAIL ---------------- // Find next emailID // Examples: davinta_0_normal_initial_n //davinta_0_normal_reply_g //davinta_0_normal_reply_b //davinta_0_normal_reply_n // Create the string to find the next emailID (The immediate reply to the player). string replyEmailID = currentEmail.conversationID + "_" + currentEmail.stage + "_" + currentEmail.state + "_" + "reply" + "_" + playerReplyGBN; Debug.Log("Next NPC Reply EmailID = " + replyEmailID); // Create the email on disc, we will send it to Delivery Manager shortly EmailEntry replyEmail = GetEmailByID(replyEmailID); Debug.Log("Found reply email: " + replyEmail.entryID); // ---------------- QUEUE NEXT TIME EMAIL --------------- EmailEntry nextTimeEmail = new EmailEntry(); string nextEmailID = currentEmail.conversationID + "_" + (currentEmail.stage + 1) + "_" + "normal" + "_" + "initial" + "_" + "n"; if (currentConversation.stage < currentConversation.maxStage) { nextTimeEmail = GetEmailByID(nextEmailID); } // ---------------- SEND NEXT EMAILS TO DELIVERY MANAGER ----------- // Immediate NPC Response Order Order emailOrder = new Order(); emailOrder.myOrderType = Order.orderType.email; emailOrder.orderAmount = 1; emailOrder.orderID = replyEmail.entryID; GetComponent <DelayedOrderManager>().AddNewOrder (emailOrder, 1, "You have a reply email from " + replyEmail.characterName); // 1 minute // Next time NPC Initial Email Order if (nextTimeEmail.entryID != null) { Order nextTimeEmailOrder = new Order(); nextTimeEmailOrder.myOrderType = Order.orderType.email; nextTimeEmailOrder.orderAmount = 1; nextTimeEmailOrder.orderID = nextTimeEmail.entryID; // Randomise delivery time between 1 - 6 hours (adjusted to 1 hour for development) int deliveryTime = 60; GetComponent <DelayedOrderManager>().AddNewOrder (nextTimeEmailOrder, deliveryTime, "You have a new email from " + replyEmail.characterName + "!"); // Six hours } }
public void InsertData(ClientContext clientContext, DKBSDbContext dbContext) { try { Console.WriteLine(" Successfully Connected"); SP.List oListData = clientContext.Web.Lists.GetByTitle("Service request conversation items"); ListItemCollectionPosition position = null; var page = 1; do { CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = "<View Scope='Recursive'><Query></Query><RowLimit>5000</RowLimit></View>"; camlQuery.ListItemCollectionPosition = position; ListItemCollection oListDataItem = oListData.GetItems(camlQuery); clientContext.Load(oListDataItem); clientContext.ExecuteQuery(); position = oListDataItem.ListItemCollectionPosition; foreach (ListItem oItem in oListDataItem) { Console.WriteLine("ID: {0} \nTitle: {1}", oItem["ID"], oItem["Title"]); Console.WriteLine(((SP.FieldUserValue)(oItem["Author"])).LookupValue); Console.WriteLine(((SP.FieldUserValue)(oItem["Editor"])).LookupValue); Console.WriteLine(oItem["Created"].ToString()); Console.WriteLine(oItem["Modified"].ToString()); Console.WriteLine(oItem["Message"]); Console.WriteLine(oItem["Sender"]); Console.WriteLine(oItem["CcAdresses"]); Console.WriteLine(oItem["MessageId"]); if (oItem["RelatedServiceRequest"] != null) { Console.WriteLine(oItem["RelatedServiceRequest"]); var childIdField = oItem["RelatedServiceRequest"] as FieldLookupValue[]; if (childIdField != null) { foreach (var lookupValue in childIdField) { var childId_Value = lookupValue.LookupValue; var childId_Id = lookupValue.LookupId; Console.WriteLine("LookupID: " + childId_Id.ToString()); Console.WriteLine("LookupValue: " + childId_Value.ToString()); } } } EmailConversation emailConversation = new EmailConversation(); emailConversation.BookingId = 7; //hardcode if (oItem["MessageId"] != null) { emailConversation.MessageId = Convert.ToInt32(oItem["MessageId"]); } if (oItem["Message"] != null) { emailConversation.Message = oItem["Message"].ToString(); } emailConversation.EmailTitle = oItem["Title"].ToString(); if (oItem["Sender"] != null) { emailConversation.Sender = oItem["Sender"].ToString(); } if (oItem["CcAdresses"] != null) { emailConversation.CCAddress = oItem["CcAdresses"].ToString(); } if (oItem["To"] != null) { emailConversation.To = oItem["To"].ToString(); } if (oItem["ID"] != null) { emailConversation.SharepointId = Convert.ToInt32(oItem["ID"]); } emailConversation.CreatedBy = ((SP.FieldUserValue)(oItem["Author"])).LookupValue; emailConversation.CreatedDate = Convert.ToDateTime(oItem["Created"].ToString()); dbContext.Add(emailConversation); dbContext.SaveChanges(); } page++; }while (position != null); } catch (Exception) { throw; } }