/// <summary> /// Thread safe function to update msg status /// </summary> /// <param name="ids"></param> /// <param name="status"></param> /// <returns></returns> public static string updateAllMsgStatus(string fromUser, long[] ids, int status) { bool shouldSubmit = false; string msisdn = null; using (HikeChatsDb context = new HikeChatsDb(App.MsgsDBConnectionstring + ";Max Buffer Size = 1024")) { for (int i = 0; i < ids.Length; i++) { ConvMessage message = DbCompiledQueries.GetMessagesForMsgId(context, ids[i]).FirstOrDefault <ConvMessage>(); if (message != null) { if ((int)message.MessageStatus < status) { if (fromUser == null || fromUser == message.Msisdn) { message.MessageStatus = (ConvMessage.State)status; msisdn = message.Msisdn; shouldSubmit = true; } } } } if (shouldSubmit) { SubmitWithConflictResolve(context); } shouldSubmit = false; return(msisdn); } }
public static string updateMsgStatus(string fromUser, long msgID, int val) { using (HikeChatsDb context = new HikeChatsDb(App.MsgsDBConnectionstring + ";Max Buffer Size = 1024")) { ConvMessage message = DbCompiledQueries.GetMessagesForMsgId(context, msgID).FirstOrDefault <ConvMessage>(); if (message != null) { if ((int)message.MessageStatus < val) { if (fromUser == null || fromUser == message.Msisdn) { message.MessageStatus = (ConvMessage.State)val; SubmitWithConflictResolve(context); return(message.Msisdn); } else { return(null); } } } else { return(null); } } return(null); }
public static void deleteMessage(long msgId) { using (HikeChatsDb context = new HikeChatsDb(App.MsgsDBConnectionstring)) { context.messages.DeleteAllOnSubmit <ConvMessage>(DbCompiledQueries.GetMessagesForMsgId(context, msgId)); SubmitWithConflictResolve(context); } }