示例#1
0
        public string AddReceiver(string contactId, string receiverId)
        {
            string returnValue = string.Empty;

            // 需要判断是否存在
            if (this.Exists(new KeyValuePair <string, object>(BaseContactDetailsEntity.FieldContactId, contactId)
                            , new KeyValuePair <string, object>(BaseContactDetailsEntity.FieldReceiverId, receiverId)
                            , new KeyValuePair <string, object>(BaseContactDetailsEntity.FieldCategory, "User")))
            {
                return(string.Empty);
            }
            BaseUserManager          userManager          = new BaseUserManager(DbHelper, UserInfo);
            BaseUserEntity           useEntity            = userManager.GetEntity(int.Parse(receiverId));
            BaseContactDetailsEntity contactDetailsEntity = new BaseContactDetailsEntity();

            // 这里一定要给个不可猜测的主键,为了提高安全性
            contactDetailsEntity.Id               = BaseBusinessLogic.NewGuid();
            contactDetailsEntity.ContactId        = contactId;
            contactDetailsEntity.Category         = "User";
            contactDetailsEntity.ReceiverId       = useEntity.Id.ToString();
            contactDetailsEntity.ReceiverRealName = useEntity.RealName;
            contactDetailsEntity.IsNew            = 0;
            contactDetailsEntity.Enabled          = 1;
            contactDetailsEntity.NewComment       = 0;
            returnValue = this.Add(contactDetailsEntity);
            // 这里需要重新计算发送给了几个人,几个人已经阅读的功能
            this.SetReadState(contactId);
            return(returnValue);
        }
示例#2
0
        /// <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="receiverIds">接收者</param>
        /// <param name="organizeIds">组织机构数组</param>
        /// <param name="roleIds">角色数组</param>
        /// <returns>影响行数</returns>
        public int Send(string contactId, string[] receiverIds, string[] organizeIds, string[] roleIds)
        {
            BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo);

            receiverIds = userManager.GetUserIds(receiverIds, organizeIds, roleIds);

            // 删除邮件的处理技巧、发送给部门的、发送给角色的。
            // 删除邮件的列表过滤问题解决
            BaseContactDetailsManager contactDetailsManager = new BaseContactDetailsManager(DbHelper, UserInfo);
            BaseContactDetailsEntity  contactDetailsEntity  = null;

            // 组织机构数组
            if (organizeIds != null)
            {
                BaseOrganizeManager organizeManager = new BaseOrganizeManager(DbHelper, UserInfo);
                for (int i = 0; i < organizeIds.Length; i++)
                {
                    contactDetailsEntity = new BaseContactDetailsEntity();
                    // 这里一定要给个不可猜测的主键,为了提高安全性
                    contactDetailsEntity.Id               = BaseBusinessLogic.NewGuid();
                    contactDetailsEntity.ContactId        = contactId;
                    contactDetailsEntity.Category         = "Organize";
                    contactDetailsEntity.ReceiverId       = organizeIds[i];
                    contactDetailsEntity.ReceiverRealName = organizeManager.GetProperty(organizeIds[i], BaseOrganizeEntity.FieldFullName);
                    contactDetailsEntity.IsNew            = 1;
                    contactDetailsEntity.Enabled          = 1;
                    contactDetailsEntity.NewComment       = 0;
                    contactDetailsManager.Add(contactDetailsEntity, false);
                }
            }

            // 角色数组
            if (roleIds != null)
            {
                BaseRoleManager roleManager = new BaseRoleManager(DbHelper, UserInfo);
                for (int i = 0; i < roleIds.Length; i++)
                {
                    contactDetailsEntity = new BaseContactDetailsEntity();
                    // 这里一定要给个不可猜测的主键,为了提高安全性
                    contactDetailsEntity.Id               = BaseBusinessLogic.NewGuid();
                    contactDetailsEntity.ContactId        = contactId;
                    contactDetailsEntity.Category         = "Role";
                    contactDetailsEntity.ReceiverId       = roleIds[i];
                    contactDetailsEntity.ReceiverRealName = roleManager.GetProperty(roleIds[i], BaseRoleEntity.FieldRealName);
                    contactDetailsEntity.IsNew            = 1;
                    contactDetailsEntity.Enabled          = 1;
                    contactDetailsEntity.NewComment       = 0;
                    contactDetailsManager.Add(contactDetailsEntity, false);
                }
            }

            return(this.Send(contactId, receiverIds));
        }
示例#4
0
        /// <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="contactId">联络单主键</param>
        /// <param name="receiverIds">接收者</param>
        /// <returns>影响行数</returns>
        public int Send(string contactId, string[] receiverIds)
        {
            int returnValue = 0;
            // 是否给自己发过这封邮件
            bool findSend = false;
            BaseContactDetailsManager contactDetailsManager = new BaseContactDetailsManager(DbHelper, UserInfo);
            BaseUserManager           userManager           = new BaseUserManager(DbHelper, UserInfo);
            BaseUserEntity            useEntity             = null;
            BaseContactDetailsEntity  contactDetailsEntity  = null;

            for (int i = 0; i < receiverIds.Length; i++)
            {
                useEntity = userManager.GetEntity(int.Parse(receiverIds[i]));
                // 是有效的用户,而且是未必删除的用户才发邮件
                if (useEntity.Enabled == 1 && useEntity.DeletionStateCode == 0)
                {
                    contactDetailsEntity = new BaseContactDetailsEntity();
                    // 这里一定要给个不可猜测的主键,为了提高安全性
                    contactDetailsEntity.Id               = BaseBusinessLogic.NewGuid();
                    contactDetailsEntity.ContactId        = contactId;
                    contactDetailsEntity.Category         = "User";
                    contactDetailsEntity.ReceiverId       = useEntity.Id.ToString();
                    contactDetailsEntity.ReceiverRealName = useEntity.RealName;
                    contactDetailsEntity.IsNew            = 1;
                    contactDetailsEntity.Enabled          = 1;
                    contactDetailsEntity.NewComment       = 0;
                    contactDetailsManager.Add(contactDetailsEntity, false);
                }
                // 若已经有发过,就不用再判断了
                if (!findSend)
                {
                    if (UserInfo.Id.Equals(receiverIds[i]))
                    {
                        findSend = true;
                    }
                }
                returnValue++;
            }
            // 没有给自己发过
            if (!findSend)
            {
                // 发送给自己一份
                this.Send(contactId);
                returnValue++;
            }
            // 设置总共发送了几个人
            this.SetProperty(new KeyValuePair <string, object>(BaseContactEntity.FieldId, contactId), new KeyValuePair <string, object>(BaseContactEntity.FieldSendCount, receiverIds.Length.ToString()));
            return(returnValue);
        }
示例#6
0
        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();
        }
示例#7
0
        private string AddReceiver(BaseUserEntity useEntity, string contactId, string receiverId)
        {
            BaseContactDetailsEntity contactDetailsEntity = new BaseContactDetailsEntity();

            // 这里一定要给个不可猜测的主键,为了提高安全性
            contactDetailsEntity.Id               = BaseBusinessLogic.NewGuid();
            contactDetailsEntity.ContactId        = contactId;
            contactDetailsEntity.Category         = "User";
            contactDetailsEntity.ReceiverId       = useEntity.Id.ToString();
            contactDetailsEntity.ReceiverRealName = useEntity.RealName;
            contactDetailsEntity.IsNew            = 1;
            contactDetailsEntity.Enabled          = 1;
            contactDetailsEntity.NewComment       = 0;
            return(this.Add(contactDetailsEntity, false));
        }
        /// <summary>
        /// 发送给自己一份
        /// </summary>
        /// <param name="contactId">联络单主键</param>
        public string Send(string contactId)
        {
            BaseUserManager          userManager          = new BaseUserManager(DbHelper, UserInfo);
            BaseUserEntity           useEntity            = useEntity = userManager.GetEntity(int.Parse(UserInfo.Id));
            BaseContactDetailsEntity contactDetailsEntity = new BaseContactDetailsEntity();

            // 这里一定要给个不可猜测的主键,为了提高安全性
            contactDetailsEntity.Id               = BaseBusinessLogic.NewGuid();
            contactDetailsEntity.ContactId        = contactId;
            contactDetailsEntity.Category         = "User";
            contactDetailsEntity.ReceiverId       = useEntity.Id.ToString();
            contactDetailsEntity.ReceiverRealName = useEntity.RealName;
            contactDetailsEntity.IsNew            = 0;
            contactDetailsEntity.Enabled          = 1;
            contactDetailsEntity.NewComment       = 0;
            BaseContactDetailsManager contactDetailsManager = new BaseContactDetailsManager(DbHelper, UserInfo);

            return(contactDetailsManager.Add(contactDetailsEntity, false));
        }
        /// <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);
        }
示例#10
0
        /// <summary>
        /// 获取添加
        /// </summary>
        /// <param name="fullName">序列名</param>
        /// <param name="defaultSequence">序列</param>
        /// <param name="defaultReduction">降序序列</param>
        /// <returns>序列实体</returns>
        BaseSequenceEntity GetEntityByAdd(string fullName)
        {
            BaseSequenceEntity sequenceEntity = null;

            sequenceEntity = this.GetEntityByName(fullName);
            if (sequenceEntity == null)
            {
                sequenceEntity = new BaseSequenceEntity();
                // 这里是为了多种数据库的兼容
                sequenceEntity.Id        = BaseBusinessLogic.NewGuid();
                sequenceEntity.FullName  = fullName;
                sequenceEntity.Sequence  = this.DefaultSequence;
                sequenceEntity.Reduction = this.DefaultReduction;
                sequenceEntity.Step      = DefaultStep;
                sequenceEntity.Prefix    = DefaultPrefix;
                sequenceEntity.Separator = DefaultSeparator;
                sequenceEntity.IsVisible = DefaultIsVisable;
                this.Add(sequenceEntity);
            }

            return(sequenceEntity);
        }
        /// <summary>
        /// 记录异常情况
        /// </summary>
        /// <param name="Exception">异常类</param>
        /// <returns>主键</returns>
        public string AddEntity(Exception ex)
        {
            // string sequence = BaseSequenceManager.Instance.GetSequence(DbHelper, BaseExceptionEntity.TableName);
            string     sequence   = BaseBusinessLogic.NewGuid();
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginInsert(this.CurrentTableName);
            sqlBuilder.SetValue(BaseExceptionEntity.FieldId, sequence);
            // sqlBuilder.SetValue(BaseExceptionEntity.FieldTitle, UserInfo.ProcessName);
            // sqlBuilder.SetValue(BaseExceptionEntity.FieldProcessId, UserInfo.ProcessId);
            // sqlBuilder.SetValue(BaseExceptionEntity.FieldProcessName, UserInfo.ProcessName);
            sqlBuilder.SetValue(BaseExceptionEntity.FieldMessage, ex.Message);
            sqlBuilder.SetValue(BaseExceptionEntity.FieldThreadName, ex.Source);
            sqlBuilder.SetValue(BaseExceptionEntity.FieldFormattedMessage, ex.StackTrace);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseExceptionEntity.FieldIPAddress, UserInfo.IPAddress);
                sqlBuilder.SetValue(BaseExceptionEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseExceptionEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseExceptionEntity.FieldCreateOn);
            return(sqlBuilder.EndInsert() > 0 ? sequence : string.Empty);
        }
        /// <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);
        }
示例#13
0
        /// <summary>
        /// 更新访问当前访问状态
        /// </summary>
        /// <param name="userId">用户主键</param>
        /// <param name="createOpenId">是否每次都产生新的OpenId</param>
        /// <returns>OpenId</returns>
        private string UpdateVisitDate(string userId, bool createOpenId = false)
        {
            string returnValue = string.Empty;

#if (DEBUG)
            int milliStart = Environment.TickCount;
#endif

            string sqlQuery = string.Empty;

            // 是否更新访问日期信息
            if (BaseSystemInfo.UpdateVisit)
            {
                // 第一次登录时间
                sqlQuery = " UPDATE " + BaseUserEntity.TableName
                           + " SET " + BaseUserEntity.FieldFirstVisit + " = " + DbHelper.GetDBNow();

                switch (DbHelper.CurrentDbType)
                {
                case CurrentDbType.Access:
                    sqlQuery = sqlQuery + "  WHERE (" + BaseUserEntity.FieldId + " = " + userId + ") AND " + BaseUserEntity.FieldFirstVisit + " IS NULL";
                    break;

                default:
                    sqlQuery = sqlQuery + "  WHERE (" + BaseUserEntity.FieldId + " = '" + userId + "') AND " + BaseUserEntity.FieldFirstVisit + " IS NULL";
                    break;
                }

                DbHelper.ExecuteNonQuery(sqlQuery);

                // 最后一次登录时间
                sqlQuery = " UPDATE " + BaseUserEntity.TableName
                           + " SET " + BaseUserEntity.FieldPreviousVisit + " = " + BaseUserEntity.FieldLastVisit + " , "
                           + BaseUserEntity.FieldUserOnLine + " = 1 , "
                           + BaseUserEntity.FieldLastVisit + " = " + DbHelper.GetDBNow() + " , "
                           + BaseUserEntity.FieldLogOnCount + " = " + BaseUserEntity.FieldLogOnCount + " + 1 ";

                switch (DbHelper.CurrentDbType)
                {
                case CurrentDbType.Access:
                    sqlQuery += "  WHERE (" + BaseUserEntity.FieldId + " = " + userId + ")";
                    break;

                default:
                    sqlQuery += "  WHERE (" + BaseUserEntity.FieldId + " = '" + userId + "')";
                    break;
                }

                DbHelper.ExecuteNonQuery(sqlQuery);
            }

            // 实现单点登录功能,每次都更换Guid
            if (createOpenId)
            {
                returnValue = BaseBusinessLogic.NewGuid();
                sqlQuery    = " UPDATE " + BaseUserEntity.TableName
                              + "    SET " + BaseUserEntity.FieldOpenId + " = '" + returnValue + "'";

                switch (DbHelper.CurrentDbType)
                {
                case CurrentDbType.Access:
                    sqlQuery += " WHERE (" + BaseUserEntity.FieldId + " = " + userId + ")";
                    break;

                default:
                    sqlQuery += " WHERE (" + BaseUserEntity.FieldId + " = '" + userId + "')";
                    break;
                }

                // sqlQuery += " AND " + BaseUserEntity.FieldOpenId + " IS NULL ";
                DbHelper.ExecuteNonQuery(sqlQuery);
            }

            // 写入调试信息
#if (DEBUG)
            int milliEnd = Environment.TickCount;
            Trace.WriteLine(DateTime.Now.ToString(BaseSystemInfo.TimeFormat) + " Ticks: " + TimeSpan.FromMilliseconds(milliEnd - milliStart).ToString() + " " + " BaseUserManager.UpdateVisitDate(" + userId + ")");
#endif

            return(returnValue);
        }