public bool UpdateMessageReadFlag(long intRecipientId) { MessageDao messageDao = new MessageDao(); bool blResult = false; try { blResult = messageDao.UpdateMessageReadFlag(intRecipientId); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "MessageBo.cs:UpdateMessageReadFlag(long intRecipientId)"); object[] objects = new object[1]; objects[0] = intRecipientId; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(blResult); }
/// <summary> /// 获取消息 /// </summary> /// <param name="tenantId"></param> /// <param name="id"></param> /// <returns></returns> public MessageInfo Get(int tenantId, int id) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); return(MessageDao.Get(tenantId, id)); }
public DataSet GetUserListSpecificToRole(string strCurrentUserRole, int intUserId, string strRoleList) { MessageDao messageDao = new MessageDao(); DataSet ds = new DataSet(); try { ds = messageDao.GetUserListSpecificToRole(strCurrentUserRole, intUserId, strRoleList); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "MessageBo.cs:GetUserListSpecificToRole(string strUserType, int intUserId, string strRoleList)"); object[] objects = new object[3]; objects[0] = strCurrentUserRole; objects[1] = intUserId; objects[2] = strRoleList; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(ds); }
/// <summary> /// 发送文本消息 /// </summary> /// <param name="ToUserName"></param> /// <param name="Content"></param> public void SendMsg(string ToUserName, string Content) { Contact ToUser = WechatAPIService.GetContact(ToUserName); API.Message msg = new API.Message() { MsgType = 1, Content = Content, IsSend = true, Remote = ToUser, Mime = WechatAPIService.Self, }; Task <SendMsgResponse> task = api.SendMsgAsync(ToUserName, Content); task.ContinueWith((obj) => { SendMsgResponse res = obj.Result; if (res != null && !string.IsNullOrEmpty(res.MsgID)) { MessageDao MsgDao = DaoMaster.GetSession().GetMessageDao(); msg.MsgId = res.MsgID; MsgDao.InsertMessage(msg, openContact.Seq); } }); }
public string GetMessage(Int64 intMessageId) { MessageDao messageDao = new MessageDao(); string strResult; try { strResult = messageDao.GetMessage(intMessageId); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "MessageBo.cs:GetMessage(Int64 intMessageId)"); object[] objects = new object[1]; objects[0] = intMessageId; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(strResult); }
public ChatLogic() { chatRoomDao = new ChatRoomDao(); userDao = new UserDao(); messageDao = new MessageDao(); lastSeenDao = new LastSeenDao(); }
public bool InsertComposedMessage(MessageVo messageVo) { MessageDao messageDao = new MessageDao(); bool blResult = false; try { blResult = messageDao.InsertComposedMessage(messageVo); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "MessageBo.cs:InsertComposedMessage(MessageVo messageVo)"); object[] objects = new object[1]; objects[0] = messageVo; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(blResult); }
/// <summary> /// 获取后台账号的交接班列表 /// </summary> public static DataTable GetDutyInfoList(DateTime?dateStart, DateTime?dateEnd, int managerId = 0) { DataTable dt = new MessageDao().GetDutyInfoList(dateStart, dateEnd, managerId); dt.Columns.Add("DutyHours"); for (int i = 0; i < dt.Rows.Count; i++) { if (string.IsNullOrEmpty(dt.Rows[i]["LoginOutTime"].ToString()))//如果登出时间为空,表示还未关班 { //dt.Rows[i]["LoginOutTime"] = "未交班"; //dt.Rows[i]["OrdersCount"] = "未交班"; //dt.Rows[i]["OrdersTotal"] = "未交班"; } else { TimeSpan ts = ((DateTime)dt.Rows[i]["LoginOutTime"]).Subtract((DateTime)dt.Rows[i]["LoginTime"]); string timespan = (ts.Days.ToString() == "0" ? "" : ts.Days.ToString() + "天") + (ts.Hours.ToString() == "0" ? "" : ts.Hours.ToString() + "小时") + (ts.Minutes.ToString() == "0" ? "" : ts.Minutes.ToString() + "分钟"); dt.Rows[i]["DutyHours"] = timespan; } } return(dt); }
public DataSet GetInboxRecords(int intUserId) { MessageDao messageDao = new MessageDao(); DataSet ds = new DataSet(); try { ds = messageDao.GetInboxRecords(intUserId); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "MessageBo.cs:GetInboxRecords(int intUserId)"); object[] objects = new object[1]; objects[0] = intUserId; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(ds); }
/// <summary>Exclui uma determinada mensagem</sumary> public ObjResult DeleteMessage(int msg_id) { connection = db.GetCon(); connection.Open(); NpgsqlTransaction transaction = connection.BeginTransaction(); MessageDao dao = new MessageDao(connection, transaction); ObjResult result = new ObjResult(); try { msg_id = dao.Delete(msg_id); result.SetData(msg_id); result.Success(); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw new Exception(e.ToString()); } finally { connection.Close(); } return(result); }
public void UpdateSendResult(int tenantId, int id, string messageId, MessageState state, string result) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); MessageDao.UpdateSendResult(tenantId, id, messageId, state, result); }
public int GetUnreadMessageCount(int intId, out int flavourId) { MessageDao messageDao = new MessageDao(); int intUnreadMessageCount; flavourId = 0; try { intUnreadMessageCount = messageDao.GetUnreadMessageCount(intId, out flavourId); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "MessageBo.cs:GetUnreadMessageCount(int intId)"); object[] objects = new object[1]; objects[0] = intId; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(intUnreadMessageCount); }
/// <summary> /// Deletes the Messages and returns a boolean value indicating the success or failure /// </summary> /// <param name="strDeletedMessages">Contains the XML Dataset string of the deleted messages</param> /// <param name="intIsInbox">If 1 then inbox records will be deleted. If 0 then outbox records will be deleted</param> /// <returns>boolean</returns> public bool DeleteMessages(string strDeletedMessages, Int16 intIsInbox) { MessageDao messageDao = new MessageDao(); bool blResult = false; try { blResult = messageDao.DeleteMessages(strDeletedMessages, intIsInbox); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "MessageBo.cs:DeleteMessages(string strDeletedMessages, Int16 intIsInbox)"); object[] objects = new object[2]; objects[0] = strDeletedMessages; objects[1] = intIsInbox; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(blResult); }
public int Add(MessageInfo info) { ArgumentHelper.AssertIsTrue(info != null, "MessageInfo is null"); ArgumentHelper.AssertNotNullOrEmpty(info.BatchId, "MessageInfo.BatchId is null or empty"); ArgumentHelper.AssertIsTrue(info.TenantId > 0, "MessageInfo.TenantId is 0"); ArgumentHelper.AssertNotNullOrEmpty(info.AppAccountId, "MessageInfo.AppAccountId is null or empty"); ArgumentHelper.AssertNotNullOrEmpty(info.ContentJson, "MessageInfo.ContentJson is null or empty"); return(MessageDao.Insert(info)); }
/// <summary>Exclui uma determinada requisição</sumary> public ObjResult Delete(int request_id) { connection = db.GetCon(); connection.Open(); ObjResult result = new ObjResult(); List <RequestItem> items = new List <RequestItem>(); List <Message> messages = new List <Message>(); // Excluir a requisição NpgsqlTransaction transaction = connection.BeginTransaction(); RequestDao dao = new RequestDao(connection, transaction); RequestItemDao itemDao = new RequestItemDao(connection, transaction); MessageDao messageDao = new MessageDao(connection, transaction); try { // Verifica se a requisição possui itens items = itemDao.GetItemsByRequest(request_id); if (items.Count > 0) { // Exclui todos os itens que pertencem à requisição foreach (RequestItem item in items) { itemDao.Delete(item.itm_id); } } // Verifica se a requisição possui mensagens messages = messageDao.GetMessagesBySourceKey(request_id); if (messages.Count > 0) { // Exclui todas as mensagens associadas à requisição foreach (Message msg in messages) { messageDao.Delete(msg.msg_id); } } request_id = dao.Delete(request_id); result.SetData(request_id); result.Success(); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw new Exception(e.ToString()); } finally { connection.Close(); } return(result); }
public static ManagerInfo GetManager(int userId) { ManagerInfo manager = HiCache.Get(string.Format("DataCache-Manager-{0}", userId)) as ManagerInfo; if (manager == null) { manager = new MessageDao().GetManager(userId); HiCache.Insert(string.Format("DataCache-Manager-{0}", userId), manager, 360, CacheItemPriority.Normal); } return(manager); }
private void LoadMessageHistory() { if (openContact == null) { return; } string Seq = openContact.Seq; MessageDao MsgDao = DaoMaster.GetSession().GetMessageDao(); List <API.Message> message = MsgDao.GetMessage(Seq); m_SyncContext.Post(UpdateMessageList, message); }
public static bool Delete(int userId) { ManagerInfo manager = ManagerHelper.GetManager(userId); bool result; if (manager.UserId == Globals.GetCurrentManagerUserId()) { result = false; } else { HiCache.Remove(string.Format("DataCache-Manager-{0}", userId)); result = new MessageDao().DeleteManager(userId); } return(result); }
/// <summary>Retorna as mensagens associadas à um determinado recurso</sumary> public List <Message> GetMessagesBySourceKey(int source_key) { connection = db.GetCon(); connection.Open(); List <Message> messages = new List <Message>(); MessageDao dao = new MessageDao(connection, null); try { messages = dao.GetMessagesBySourceKey(source_key); } finally { connection.Close(); } return(messages); }
/// <summary>Marca como importante uma determinada mensagem</sumary> public ObjResult MarkAsImportant(int msg_id) { connection = db.GetCon(); connection.Open(); MessageDao dao = new MessageDao(connection, null); ObjResult result = new ObjResult(); try { msg_id = dao.IsImportant(msg_id); result.SetData(msg_id); result.Success(); } finally { connection.Close(); } return(result); }
/// <summary>Retorna uma determinada mensagem</sumary> public ObjResult GetMessageById(int msg_id) { connection = db.GetCon(); connection.Open(); Message msg = new Message(); ObjResult result = new ObjResult(); MessageDao dao = new MessageDao(connection, null); try { msg = dao.GetById(msg_id); result.SetData(msg); result.Success(); } finally { connection.Close(); } return(result); }
public MessageBLL(IDbConnection connection) { Mapper = new MapperConfiguration(cfg => { cfg.CreateMap <Message, MessageVM>().ForMember("ReceivedAt", o => { o.MapFrom("DateCreated"); }).AfterMap((m, vm) => { vm.Status = GetStatus(m.Status); }); cfg.CreateMap <MessageVM, Message>().ForMember("DateCreated", o => { o.MapFrom("ReceivedAt"); }).AfterMap((vm, m) => { m.Status = GetStatus(vm.Status); }); }).CreateMapper(); _messages = new MessageDao(connection); }
/// <summary>Envia uma mensagem</sumary> public void SendMessage(Message msg) { connection = db.GetCon(); connection.Open(); NpgsqlTransaction transaction = connection.BeginTransaction(); MessageDao dao = new MessageDao(connection, transaction); try { dao.Post(msg); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw new Exception(e.ToString()); } finally { connection.Close(); } }
public MessageRepository() { _dao = new MessageDao(); }
public MessageService() { _dao = new MessageDao(); }
/// <summary>Faz a publicação de uma determinada requisição</sumary> public ObjResult Send(int request_id, int user_id, string action, Message msg) { connection = db.GetCon(); connection.Open(); Request request = new Request(); ObjResult result = new ObjResult(); List <string> messages_list = new List <string>(); RequestDao requestDao = new RequestDao(connection, null); RequestBusiness business = new RequestBusiness(connection, null); try { // Validar requisição request = requestDao.GetById(request_id); Console.WriteLine("Status da requisição: " + request.req_status); messages_list = business.Validate(request, user_id, action); if (messages_list.Count > 0) { result.resultStatus = "error"; result.resultMessages = messages_list; connection.Close(); return(result); } } finally { connection.Close(); } connection.Open(); NpgsqlTransaction transaction = connection.BeginTransaction(); RequestItemDao itemDao = new RequestItemDao(connection, transaction); MessageDao messageDao = new MessageDao(connection, transaction); RequestDao r_dao = new RequestDao(connection, transaction); try { // Altera o status da requisição para ativa request_id = r_dao.ChangeStatus(request_id, 'A'); // Altera o status de todos os itens para <AAT> Aguardando Aprovação Técnica foreach (RequestItem item in itemDao.GetItemsByRequest(request_id)) { itemDao.SetStatus(item.itm_id, "AAT"); } // Envia mensagem e informa que foi gerada por meio de uma requisição de compra msg.SetSourceKey(request_id); msg.SetSourceType("request"); messageDao.Post(msg); // Adiciona o status de sucesso e data result.Success(); result.SetData(request_id); // Comita as alterações transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw new Exception(e.ToString()); } finally { connection.Close(); } return(result); }