/// <summary> /// 发送即时通讯提醒 /// </summary> /// <param name="id">主键</param> /// <param name="auditStatus">审核状态</param> /// <param name="auditIdea">审核意见</param> /// <param name="userId">发送给用户主键</param> /// <param name="roleId">发送给角色主键</param> /// <returns>影响行数</returns> public int SendRemindMessage(string id, AuditStatus auditStatus, string auditIdea, string[] userIds, string[] organizeIds, string[] roleIds) { int returnValue = 0; // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.Id = BaseBusinessLogic.NewGuid(); // 这里是回调的类,用反射要回调的 messageEntity.FunctionCode = this.GetType().ToString(); messageEntity.ObjectId = id; // 这里是网页上的显示地址 // messageEntity.Title = this.GetUrl(id); // messageEntity.Content = BaseBusinessLogic.GetAuditStatus(auditStatus) + ":" + this.GetEntity(id).Title + " 请查收" // + Environment.NewLine // + this.GetUrl(id) // + auditIdea; messageEntity.IsNew = 1; messageEntity.ReadCount = 0; messageEntity.Enabled = 1; messageEntity.DeletionStateCode = 0; BaseMessageManager messageManager = new BaseMessageManager(this.UserInfo); returnValue = messageManager.BatchSend(userIds, organizeIds, roleIds, messageEntity, false); return(returnValue); }
/// <summary> /// 设置实体 /// </summary> /// <param name="baseMessageEntity">实体</param> private void SetEntity(SQLBuilder sqlBuilder, BaseMessageEntity baseMessageEntity) { SetEntityExpand(sqlBuilder, baseMessageEntity); sqlBuilder.SetValue(BaseMessageEntity.FieldParentId, baseMessageEntity.ParentId); sqlBuilder.SetValue(BaseMessageEntity.FieldReceiverDepartmentId, baseMessageEntity.ReceiverDepartmentId); sqlBuilder.SetValue(BaseMessageEntity.FieldReceiverDepartmentName, baseMessageEntity.ReceiverDepartmentName); sqlBuilder.SetValue(BaseMessageEntity.FieldReceiverId, baseMessageEntity.ReceiverId); sqlBuilder.SetValue(BaseMessageEntity.FieldReceiverRealName, baseMessageEntity.ReceiverRealName); sqlBuilder.SetValue(BaseMessageEntity.FieldFunctionCode, baseMessageEntity.FunctionCode); sqlBuilder.SetValue(BaseMessageEntity.FieldCategoryCode, baseMessageEntity.CategoryCode); sqlBuilder.SetValue(BaseMessageEntity.FieldObjectId, baseMessageEntity.ObjectId); sqlBuilder.SetValue(BaseMessageEntity.FieldTitle, baseMessageEntity.Title); sqlBuilder.SetValue(BaseMessageEntity.FieldContents, baseMessageEntity.Contents); sqlBuilder.SetValue(BaseMessageEntity.FieldIsNew, baseMessageEntity.IsNew); sqlBuilder.SetValue(BaseMessageEntity.FieldReadCount, baseMessageEntity.ReadCount); sqlBuilder.SetValue(BaseMessageEntity.FieldReadDate, baseMessageEntity.ReadDate); sqlBuilder.SetValue(BaseMessageEntity.FieldTargetURL, baseMessageEntity.TargetURL); sqlBuilder.SetValue(BaseMessageEntity.FieldIPAddress, baseMessageEntity.IPAddress); sqlBuilder.SetValue(BaseMessageEntity.FieldCreateDepartmentId, baseMessageEntity.CreateDepartmentId); sqlBuilder.SetValue(BaseMessageEntity.FieldCreateDepartmentName, baseMessageEntity.CreateDepartmentName); sqlBuilder.SetValue(BaseMessageEntity.FieldDeletionStateCode, baseMessageEntity.DeletionStateCode); sqlBuilder.SetValue(BaseMessageEntity.FieldEnabled, baseMessageEntity.Enabled); sqlBuilder.SetValue(BaseMessageEntity.FieldDescription, baseMessageEntity.Description); sqlBuilder.SetValue(BaseMessageEntity.FieldSortCode, baseMessageEntity.SortCode); }
public bool OnReceiveMessage(BaseMessageEntity messageEntity) { bool returnValue = false; // 判断消息,是否发送给本窗体的 //if (this.ReceiverId.Equals(Message.ReceiverId)) //{ returnValue = true; if (this.InvokeRequired) { SetMessage SetMessage = new SetMessage(OnReceiveMessage); this.Invoke(SetMessage, new object[] { messageEntity }); } else { //this.txtMessage.AppendText(messageEntity.CreateBy + " " + ((DateTime)messageEntity.CreateOn).ToString(BaseSystemInfo.DateTimeFormat) + " 说: " + "\r\n"); //this.txtMessage.AppendText(messageEntity.Content + "\r\n"); //this.txtMessage.AppendText("- - - - - - - - - - - - - - -" + "\r\n"); //this.txtMessage.ScrollToCaret(); //StringBuilder sbContent = new StringBuilder(); //sbContent.Append("<div style='color:#00f;font-size:12px;'>" + messageEntity.CreateBy + " ["); //if (isToday((DateTime)messageEntity.CreateOn)) //{ // sbContent.Append(((DateTime)messageEntity.CreateOn).ToLongTimeString() + "]:</div>"); //} //else //{ // sbContent.Append(((DateTime)messageEntity.CreateOn).ToString(BaseSystemInfo.DateTimeFormat) + "]:</div>"); //} //// Web里的单点登录识别码进行转换 //messageEntity.Contents = messageEntity.Contents.Replace("{OpenId}", this.UserInfo.OpenId); //sbContent.Append(messageEntity.Contents); //strOneShow.Append(sbContent.ToString()); //this.webBMsg.DocumentText = this.webBMsg.DocumentText.Insert(this.webBMsg.DocumentText.Length, sbContent.ToString()); messageEntity.Contents = ReplaceMessage(messageEntity.Contents); StringBuilder sbContent = new StringBuilder(); sbContent.Append("<div style='color:#00f;font-size:12px;'>" + messageEntity.CreateBy + " ["); if (isToday((DateTime)messageEntity.CreateOn)) { sbContent.Append(((DateTime)messageEntity.CreateOn).ToLongTimeString() + "]:</div>"); } else { sbContent.Append(((DateTime)messageEntity.CreateOn).ToString(BaseSystemInfo.DateTimeFormat) + "]:</div>"); } sbContent.Append(messageEntity.Contents); OneShow.Append(sbContent.ToString()); this.webMessage.DocumentText = this.webMessage.DocumentText.Insert(this.webMessage.DocumentText.Length, GetHtmlFace(sbContent.ToString())); this.PlaySound(); FlashWindow(this.Handle, true); } //} return(returnValue); }
public static GovTalkMessageEntity CreateBaseRequest(String serviceName, BaseMessageEntity message) { var auth = new AuthenticationEntity { Method = "clear", Value = ConfigurationManager.AppSettings["GovTalkPassword"] }; var idAuth = new IDAuthenticationEntity { SenderID = ConfigurationManager.AppSettings["GovTalkUserName"], Authentication = auth, }; var senderDetails = new SenderDetailsEntity { EmailAddress = "nomail", IDAuthentication = idAuth, }; var messageDetails = new MessageDetailsEntity { Class = serviceName, Function = "submit", Qualifier = "request", CorrelationID = "cor", }; var header = new HeaderEntity { SenderDetails = senderDetails, MessageDetails = messageDetails, }; var body = new BodyEntity { Entity = message, }; var error = new ErrorEntity { EnvelopeVersion = "369.25", Number = 2695, RaisedBy = "me", Text = "Exception", Type = "TypedError" }; var govTalkMessage = new GovTalkMessageEntity { EnvelopeVersion = 2.0M, Header = header, Body = body, }; return(govTalkMessage); }
/// <summary> /// 阅读短信 /// </summary> /// <param name="id">短信ID</param> /// <returns>数据权限</returns> public DataTable Read(string id) { // 这里需要改进一下,运行一个高性能的sql语句就可以了,效率会高一些 DataTable dataTable = this.GetDataTableById(id); BaseMessageEntity messageEntity = new BaseMessageEntity(dataTable); this.OnRead(messageEntity, id); dataTable = this.GetDataTableById(id); return(dataTable); }
/// <summary> /// 获取最新一条信息 /// </summary> /// <returns>记录个数</returns> public BaseMessageEntity GetNewOne() { BaseMessageEntity messageEntity = new BaseMessageEntity(); string sqlQuery = " SELECT * " + " FROM (SELECT * FROM " + BaseMessageEntity.TableName + " WHERE (" + BaseMessageEntity.FieldIsNew + " = " + ((int)MessageStateCode.New).ToString() + " ) " + " AND (" + BaseMessageEntity.FieldReceiverId + " = '" + UserInfo.Id + "') " + " ORDER BY " + BaseMessageEntity.FieldCreateOn + " DESC) " + " WHERE ROWNUM = 1 "; DataTable dataTable = DbHelper.Fill(sqlQuery); return(messageEntity.GetSingle(dataTable)); }
/// <summary> /// 添加短信,可以发给多个人 /// </summary> /// <param name="messageEntity">实体</param> /// <param name="receiverIds">接收者ID组</param> /// <returns>影响行数</returns> public int Send(BaseMessageEntity messageEntity, string[] receiverIds, bool saveSend = true) { BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo); // 每发一条短信,数据库中需要记录两条记录,他们的CreateUserId都为创建者ID。 // 接收者多人的话,不要重复设置创建人的记录了,即对发送者来说,只要记录一条记录就够了 int returnValue = 0; messageEntity.CategoryCode = MessageCategory.Receiver.ToString(); messageEntity.IsNew = (int)MessageStateCode.New; messageEntity.IPAddress = UserInfo.IPAddress; messageEntity.ParentId = null; messageEntity.DeletionStateCode = 0; messageEntity.Enabled = 1; returnValue++; BaseUserEntity userEntity = null; for (int i = 0; i < receiverIds.Length; i++) { messageEntity.ParentId = null; messageEntity.Id = Guid.NewGuid().ToString(); messageEntity.CategoryCode = MessageCategory.Receiver.ToString(); messageEntity.ReceiverId = receiverIds[i]; userEntity = userManager.GetEntity(receiverIds[i]); if (userEntity != null && !string.IsNullOrEmpty(userEntity.Id)) { messageEntity.ReceiverRealName = userEntity.RealName; // 发给了哪个部门的人,意义不大,是来自哪个部门的人,意义更大一些 // messageEntity.DepartmentId = userEntity.DepartmentId; // messageEntity.DepartmentName = userEntity.DepartmentName; } messageEntity.Enabled = 1; messageEntity.IsNew = 1; if (messageEntity.ReceiverId.Equals(UserInfo.Id)) { messageEntity.IsNew = (int)MessageStateCode.Old; } // 接收信息 string parentId = this.Add(messageEntity, false, false); if (saveSend) { // 已发送信息 messageEntity.Id = Guid.NewGuid().ToString(); messageEntity.ParentId = parentId; messageEntity.CategoryCode = MessageCategory.Send.ToString(); messageEntity.DeletionStateCode = 0; messageEntity.Enabled = 0; this.Add(messageEntity, false, false); } returnValue++; } return(returnValue); }
public Message GetRawMessage(string messageID) { TableOperation retrieveOperation = RetrieveUserlineMsgByID <BaseMessageEntity>(messageID); TableResult retrievedResult = _userline.ExecuteRetriveOperation(retrieveOperation); if (retrievedResult.Result != null) { BaseMessageEntity entity = (BaseMessageEntity)retrievedResult.Result; return(entity.ToMessage()); } return(null); }
/// <summary> /// 广播消息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="message">消息内容</param> /// <returns>主键</returns> public int Broadcast(BaseUserInfo userInfo, string message) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); string[] receiverIds = null; BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); receiverIds = userManager.GetIds(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1), new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0)); BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo); BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.Id = BaseBusinessLogic.NewGuid(); messageEntity.FunctionCode = MessageFunction.Remind.ToString(); messageEntity.Contents = message; messageEntity.IsNew = 1; messageEntity.ReadCount = 0; messageEntity.Enabled = 1; messageEntity.DeletionStateCode = 0; returnValue = messageManager.BatchSend(receiverIds, string.Empty, string.Empty, messageEntity, false); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_BatchSend, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 发送系统提示消息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="receiverId">接收者主键</param> /// <param name="contents">内容</param> /// <returns>主键</returns> public string Remind(BaseUserInfo userInfo, string receiverId, string contents) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif string returnValue = string.Empty; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseMessageEntity entity = new BaseMessageEntity(); entity.Id = Guid.NewGuid().ToString(); entity.CategoryCode = MessageCategory.Receiver.ToString(); entity.FunctionCode = MessageFunction.Remind.ToString(); entity.ReceiverId = receiverId; entity.Contents = contents; entity.IsNew = (int)MessageStateCode.New; entity.ReadCount = 0; entity.DeletionStateCode = 0; entity.Enabled = 1; BaseMessageManager manager = new BaseMessageManager(dbHelper, userInfo); returnValue = manager.Add(entity); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_Send, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
public int BatchSend(string[] receiverIds, string organizeId, string roleId, BaseMessageEntity messageEntity, bool saveSend = true) { string[] organizeIds = null; string[] roleIds = null; if (!string.IsNullOrEmpty(organizeId)) { organizeIds = new string[] { organizeId }; } if (!string.IsNullOrEmpty(roleId)) { roleIds = new string[] { roleId }; } return(BatchSend(receiverIds, organizeIds, roleIds, messageEntity, saveSend)); }
private void btnSend_Click(object sender, EventArgs e) { StringBuilder sbmy = new StringBuilder(); sbmy.Append("<div style='margin:2px;padding:0px 0px 0px 15px;" + "font-family:" + this.txtContents.Font.FontFamily.Name + ";" + "font-size:" + this.txtContents.Font.Size + "pt;color:#" + this.txtContents.ForeColor.R.ToString("X2") + this.txtContents.ForeColor.G.ToString("X2") + this.txtContents.ForeColor.B.ToString("X2")); sbmy.Append(";font-weight:"); sbmy.Append(this.txtContents.Font.Bold ? "bold" : ""); sbmy.Append(";font-style:"); sbmy.Append(this.txtContents.Font.Italic ? "italic" : ""); sbmy.Append(";'>"); sbmy.Append(GetHtmlHref(this.txtContents.Text) + "</div>"); DotNetService dotNetService = new DotNetService(); if (this.ucUser.SelectedIds != null) { // 发送信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.Id = BaseBusinessLogic.NewGuid(); messageEntity.FunctionCode = MessageFunction.Message.ToString(); messageEntity.Contents = sbmy.ToString(); messageEntity.IsNew = 1; messageEntity.ReadCount = 0; messageEntity.Enabled = 1; messageEntity.DeletionStateCode = 0; dotNetService.MessageService.BatchSend(UserInfo, this.ucUser.SelectedIds, null, null, messageEntity); } else { if (this.ucUser.SelectedId != null) { dotNetService.MessageService.Send(UserInfo, this.ucUser.SelectedId, sbmy.ToString()); } } if (dotNetService.MessageService is ICommunicationObject) { ((ICommunicationObject)dotNetService.MessageService).Close(); } // 2010-12-15 发好信息了,还是关闭了比较好 // this.txtContent.Clear(); // this.txtContent.Focus(); this.Close(); }
/// <summary> /// 更新实体 /// </summary> /// <param name="baseMessageEntity">实体</param> public int UpdateEntity(BaseMessageEntity baseMessageEntity) { SQLBuilder sqlBuilder = new SQLBuilder(DbHelper); sqlBuilder.BeginUpdate(this.CurrentTableName); this.SetEntity(sqlBuilder, baseMessageEntity); if (UserInfo != null) { sqlBuilder.SetValue(BaseMessageEntity.FieldModifiedUserId, UserInfo.Id); sqlBuilder.SetValue(BaseMessageEntity.FieldModifiedBy, UserInfo.RealName); } sqlBuilder.SetDBNow(BaseMessageEntity.FieldModifiedOn); sqlBuilder.SetWhere(BaseMessageEntity.FieldId, baseMessageEntity.Id); return(sqlBuilder.EndUpdate()); }
/// <summary> /// 按部门群发短信 /// </summary> /// <param name="messageEntity">实体</param> /// <param name="organizeId">部门主键</param> /// <returns>影响行数</returns> public int Send(BaseMessageEntity messageEntity, string organizeId, bool saveSend = true) { int returnValue = 0; int i = 0; BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo); DataTable dataTable = userManager.GetChildrenUsers(organizeId); string[] receiverIds = new string[dataTable.Rows.Count]; foreach (DataRow dataRow in dataTable.Rows) { receiverIds[i++] = dataRow[BaseMessageEntity.FieldId].ToString(); } returnValue = this.Send(messageEntity, receiverIds, saveSend); return(returnValue); }
public bool OnReceiveMessage(BaseMessageEntity messageEntity) { bool returnValue = false; if (this.InvokeRequired) { SetMessage SetMessage = new SetMessage(OnReceiveMessage); this.Invoke(SetMessage, new object[] { messageEntity }); } else { OnReceiveMessage(messageEntity.Contents, ((DateTime)messageEntity.CreateOn).ToString(BaseSystemInfo.DateTimeFormat)); returnValue = true; } return(returnValue); }
public bool OnReceiveMessage(BaseMessageEntity entity) { bool result = false; if (this.InvokeRequired) { SetMessage setMessage = new SetMessage(OnReceiveMessage); this.Invoke(setMessage, new object[] { entity }); } else { ShowMessage(entity); result = true; } return(result); }
public bool ShowMessage(BaseMessageEntity entity) { string createBy = string.Empty; if (!string.IsNullOrEmpty(entity.CreateCompanyName)) { createBy += entity.CreateCompanyName; } if (!string.IsNullOrEmpty(entity.CreateDepartmentName)) { createBy += " - " + entity.CreateDepartmentName; } if (!string.IsNullOrEmpty(entity.CreateBy)) { createBy += " - " + entity.CreateBy; } if (!string.IsNullOrEmpty(entity.Telephone)) { createBy += " - " + entity.Telephone; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<div style='color:#00f;font-size:12px;'>" + createBy + " ["); if (IsToday((DateTime)entity.CreateOn)) { stringBuilder.Append(((DateTime)entity.CreateOn).ToLongTimeString() + "]:</div>"); } else { stringBuilder.Append(((DateTime)entity.CreateOn).ToString(BaseSystemInfo.DateTimeFormat) + "]:</div>"); } stringBuilder.Append(entity.Contents); OneShow.Append(stringBuilder.ToString()); this.webMessage.DocumentText = this.webMessage.DocumentText.Insert(this.webMessage.DocumentText.Length, stringBuilder.ToString()); this.PlaySound(); FlashWindow(this.Handle, true); //this.txtContents.AppendText(createOn + " : " + "\r\n"); //this.txtContents.AppendText(message + "\r\n"); //this.txtContents.AppendText("- - - - - - - - - - - - - - -" + "\r\n"); //this.txtContents.ScrollToCaret(); return(true); }
/// <summary> /// 添加用户 /// </summary> /// <param name="dbHelper">数据库连接</param> /// <param name="userInfo">用户信息</param> /// <param name="userEntity">用户实体</param> /// <param name="statusCode">状态码</param> /// <param name="statusMessage">状态信息</param> /// <returns>主键</returns> public string AddUser(IDbHelper dbHelper, BaseUserInfo userInfo, BaseUserEntity userEntity, out string statusCode, out string statusMessage) { // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif string returnValue = string.Empty; BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); // 若是系统需要用加密的密码,这里需要加密密码。 if (BaseSystemInfo.ServerEncryptPassword) { userEntity.UserPassword = userManager.EncryptUserPassword(userEntity.UserPassword); // 安全通讯密码、交易密码也生成好 userEntity.CommunicationPassword = userManager.EncryptUserPassword(userEntity.CommunicationPassword); } returnValue = userManager.Add(userEntity, out statusCode); statusMessage = userManager.GetStateMessage(statusCode); // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了 if (userEntity.Enabled == 0 && statusCode.Equals(StatusCode.OKAdd.ToString())) { // 不是系统管理员添加 if (!userInfo.IsAdministrator) { // 给超级管理员群组发信息 BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo); string[] roleIds = roleManager.GetIds(new KeyValuePair <string, object>(BaseRoleEntity.FieldCode, "Administrators")); string[] userIds = userManager.GetIds(new KeyValuePair <string, object>(BaseUserEntity.FieldCode, "Administrator")); // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.FunctionCode = MessageFunction.WaitForAudit.ToString(); // Pcsky 2012.05.04 显示申请的用户名 messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.UserName + AppMessage.UserService_Check; //messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.RealName + AppMessage.UserService_Check; BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo); messageManager.BatchSend(userIds, null, roleIds, messageEntity, false); } } return(returnValue); }
/// <summary> /// 发送即时通讯提醒 /// </summary> /// <param name="workFlowCurrentEntity">当前审核流实体信息</param> /// <param name="auditStatus">审核状态</param> /// <param name="auditIdea">审核意见</param> /// <param name="userIds">发送给用户主键</param> /// <param name="roleIds">发送给角色主键</param> /// <returns>影响行数</returns> public virtual int SendRemindMessage(BaseWorkFlowCurrentEntity workFlowCurrentEntity, AuditStatus auditStatus, string[] userIds, string organizeId, string roleId) { // string currentId, string objectId, string objectFullName int returnValue = 0; // 不用给自己发消息了,消息多了也烦恼 userIds = StringUtil.Remove(userIds, this.UserInfo.Id); // BaseUserEntity userEntity = userManager.GetEntity(userId); // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.Id = BaseBusinessLogic.NewGuid(); // 这里是回调的类,用反射要回调的 messageEntity.FunctionCode = MessageFunction.Remind.ToString(); // messageEntity.FunctionCode = this.GetType().ToString(); messageEntity.ObjectId = workFlowCurrentEntity.ObjectId; // 这里是网页上的显示地址 // messageEntity.Title = this.GetUrl(id); string auditIdea = string.Empty; if (!string.IsNullOrEmpty(workFlowCurrentEntity.AuditIdea)) { auditIdea = " 批示: " + workFlowCurrentEntity.AuditIdea; } // messageEntity.Contents = userEntity.DepartmentName + " " + userEntity.RealName messageEntity.Contents = workFlowCurrentEntity.CreateBy + " 发出审批申请: " + "<a title='点击这里,直接查看单据' target='_blank' href='" + this.GetUrl(workFlowCurrentEntity.Id) + "'>" + workFlowCurrentEntity.ObjectFullName + "</a> " + Environment.NewLine + this.UserInfo.RealName + " " + BaseBusinessLogic.GetAuditStatus(auditStatus) + " " + Environment.NewLine + auditIdea; messageEntity.Contents = "有单据" + BaseBusinessLogic.GetAuditStatus(auditStatus); messageEntity.IsNew = 1; messageEntity.ReadCount = 0; messageEntity.Enabled = 1; messageEntity.DeletionStateCode = 0; BaseMessageManager messageManager = new BaseMessageManager(this.UserInfo); returnValue = messageManager.BatchSend(userIds, organizeId, roleId, messageEntity, false); return(returnValue); }
/// <summary> /// 检查信息状态 /// </summary> /// <returns>信息状态数组</returns> public string[] MessageChek() { string[] returnValue = new string[6]; // 0.新信息的个数 int messageCount = this.GetNewCount(); returnValue[0] = messageCount.ToString(); if (messageCount > 0) { BaseMessageEntity messageEntity = this.GetNewOne(); DateTime lastChekDate = DateTime.MinValue; if (messageEntity.CreateOn != null) { // 1.最后检查时间 lastChekDate = Convert.ToDateTime(messageEntity.CreateOn); returnValue[1] = lastChekDate.ToString(BaseSystemInfo.DateTimeFormat); } returnValue[2] = messageEntity.CreateUserId; // 2.最新消息的发出者 returnValue[3] = messageEntity.CreateBy; // 3.最新消息的发出者名称 returnValue[4] = messageEntity.Id; // 4.最新消息的主键 returnValue[5] = messageEntity.Contents; // 5.最新信息的内容 } return(returnValue); }
/// <summary> /// 阅读短信后设置状态值和阅读次数 /// </summary> /// <param name="messageEntity">实体</param> /// <param name="id">短信主键</param> /// <returns>影响的条数</returns> private int OnRead(BaseMessageEntity messageEntity, string id) { int returnValue = 0; // 针对“已发送”的情况 if (messageEntity.ReceiverId == UserInfo.Id) { // 针对“删除的信息”的情况 if (messageEntity.IsNew == (int)MessageStateCode.New) { SQLBuilder sqlBuilder = new SQLBuilder(this.DbHelper); sqlBuilder.BeginUpdate(this.CurrentTableName); sqlBuilder.SetValue(BaseMessageEntity.FieldIsNew, ((int)MessageStateCode.Old).ToString()); sqlBuilder.SetDBNow(BaseMessageEntity.FieldReadDate); sqlBuilder.SetWhere(BaseMessageEntity.FieldId, id); sqlBuilder.EndUpdate(); } } // 增加阅读次数 messageEntity.ReadCount++; this.SetProperty(id, new KeyValuePair <string, object>(BaseMessageEntity.FieldReadCount, messageEntity.ReadCount.ToString())); returnValue++; return(returnValue); }
/// <summary> /// 添加 /// </summary> /// <param name="baseMessageEntity">实体</param> /// <returns>主键</returns> public string Add(BaseMessageEntity baseMessageEntity) { return(this.AddEntity(baseMessageEntity)); }
// 这个是声明扩展方法 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseMessageEntity baseMessageEntity);
/// <summary> /// 批量发送消息 /// </summary> /// <param name="receiverIds">接收者主键组</param> /// <param name="organizeIds">组织机构主键组</param> /// <param name="roleIds">角色主键组</param> /// <param name="content">内容</param> /// <returns>影响行数</returns> public int BatchSend(string[] receiverIds, string[] organizeIds, string[] roleIds, BaseMessageEntity messageEntity, bool saveSend = true) { BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo); receiverIds = userManager.GetUserIds(receiverIds, organizeIds, roleIds); return(this.Send(messageEntity, receiverIds, saveSend)); }
/// <summary> /// 添加实体 /// </summary> /// <param name="baseMessageEntity">实体</param> public string AddEntity(BaseMessageEntity baseMessageEntity) { string sequence = string.Empty; this.Identity = false; if (baseMessageEntity.SortCode == null || baseMessageEntity.SortCode == 0) { BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName); baseMessageEntity.SortCode = int.Parse(sequence); } if (baseMessageEntity.Id != null) { sequence = baseMessageEntity.Id.ToString(); } SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId); sqlBuilder.BeginInsert(this.CurrentTableName, BaseMessageEntity.FieldId); if (!this.Identity) { if (string.IsNullOrEmpty(baseMessageEntity.Id)) { sequence = BaseBusinessLogic.NewGuid(); baseMessageEntity.Id = sequence; } sqlBuilder.SetValue(BaseMessageEntity.FieldId, baseMessageEntity.Id); } else { if (!this.ReturnId && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2)) { if (DbHelper.CurrentDbType == DbTypes.Oracle) { sqlBuilder.SetFormula(BaseMessageEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL "); } if (DbHelper.CurrentDbType == DbTypes.DB2) { sqlBuilder.SetFormula(BaseMessageEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper()); } } else { if (this.Identity && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2)) { if (string.IsNullOrEmpty(baseMessageEntity.Id)) { if (string.IsNullOrEmpty(sequence)) { BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName); } baseMessageEntity.Id = sequence; } sqlBuilder.SetValue(BaseMessageEntity.FieldId, baseMessageEntity.Id); } } } this.SetEntity(sqlBuilder, baseMessageEntity); if (UserInfo != null) { sqlBuilder.SetValue(BaseMessageEntity.FieldCreateUserId, UserInfo.Id); sqlBuilder.SetValue(BaseMessageEntity.FieldCreateBy, UserInfo.RealName); } sqlBuilder.SetDBNow(BaseMessageEntity.FieldCreateOn); if (UserInfo != null) { sqlBuilder.SetValue(BaseMessageEntity.FieldModifiedUserId, UserInfo.Id); sqlBuilder.SetValue(BaseMessageEntity.FieldModifiedBy, UserInfo.RealName); } sqlBuilder.SetDBNow(BaseMessageEntity.FieldModifiedOn); if (this.Identity && (DbHelper.CurrentDbType == DbTypes.SqlServer || DbHelper.CurrentDbType == DbTypes.Access)) { sequence = sqlBuilder.EndInsert().ToString(); } else { sqlBuilder.EndInsert(); } return(sequence); }
/// <summary> /// 获取实体 /// </summary> /// <param name="id">主键</param> public BaseMessageEntity GetEntity(string id) { BaseMessageEntity baseMessageEntity = new BaseMessageEntity(this.GetDataTable(new KeyValuePair <string, object>(BaseMessageEntity.FieldId, id))); return(baseMessageEntity); }
/// <summary> /// 更新 /// </summary> /// <param name="baseMessageEntity">实体</param> public int Update(BaseMessageEntity baseMessageEntity) { return(this.UpdateEntity(baseMessageEntity)); }
/// <summary> /// 添加 /// </summary> /// <param name="baseMessageEntity">实体</param> /// <param name="identity">自增量方式</param> /// <param name="returnId">返回主键</param> /// <returns>主键</returns> public string Add(BaseMessageEntity baseMessageEntity, bool identity, bool returnId) { this.Identity = identity; this.ReturnId = returnId; return(this.AddEntity(baseMessageEntity)); }
/// <summary> /// 批量发送站内信息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="receiverIds">接受者主键数组</param> /// <param name="organizeIds">组织机构主键数组</param> /// <param name="roleIds">角色主键数组</param> /// <param name="messageEntity">消息内容</param> /// <returns>影响行数</returns> public int BatchSend(BaseUserInfo userInfo, string[] receiverIds, string[] organizeIds, string[] roleIds, BaseMessageEntity messageEntity) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo); returnValue = messageManager.BatchSend(receiverIds, organizeIds, roleIds, messageEntity, true); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_BatchSend, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 添加一条短信,只能发给一个人,在数据库中加入两条记录 /// </summary> /// <param name="messageEntity">添加对象</param> /// <returns>影响行数</returns> public int Send(BaseMessageEntity messageEntity, bool saveSend = true) { string[] receiverIds = new string[1]; receiverIds[0] = messageEntity.ReceiverId.ToString(); return(this.Send(messageEntity, receiverIds, saveSend)); }