예제 #1
0
        /// <summary>
        /// 获取心跳key
        /// </summary>
        /// <returns></returns>
        public static string GetSyncKey()
        {
            BaseRequestEntity Bre = new BaseRequestEntity()
            {
                Uin = CommonDefine.LoginResult.wxuin, Sid = CommonDefine.LoginResult.wxsid, Skey = CommonDefine.LoginResult.skey, DeviceID = MethodsHelper.GetDeviceId()
            };
            BaseRequestSubmitEntity le = new BaseRequestSubmitEntity()
            {
                BaseRequest = Bre
            };
            string            SyncKeyData = JsonConvert.SerializeObject(le);
            string            SyncKeyUrl  = UrlDefine.GetSyncKey + CommonDefine.LoginResult.pass_ticket;
            string            SyncKeyList = HttpMethods.PostData(SyncKeyUrl, SyncKeyData, CommonDefine.Cookies, Encoding.UTF8).ContentData.ToString();
            BaseContactEntity bce         = JsonConvert.DeserializeObject <BaseContactEntity>(SyncKeyList);

            CommonDefine.SyncKey = bce.SyncKey;
            string SyncKey = string.Empty;

            for (int index = 0; index < bce.SyncKey.List.Count; index++)
            {
                if (!string.IsNullOrWhiteSpace(SyncKey))
                {
                    SyncKey = SyncKey + "|";
                }
                SyncKey = SyncKey + bce.SyncKey.List[index].Key + "_" + bce.SyncKey.List[index].Val;
            }
            Thread.Sleep(5000);
            return(SyncKey);
        }
예제 #2
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="baseContactEntity">实体</param>
        public int UpdateEntity(BaseContactEntity baseContactEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(BaseContactEntity.TableName);
            this.SetEntity(sqlBuilder, baseContactEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseContactEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseContactEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseContactEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(BaseContactEntity.FieldId, baseContactEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
예제 #3
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="baseContactEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseContactEntity baseContactEntity)
 {
     sqlBuilder.SetValue(BaseContactEntity.FieldParentId, baseContactEntity.ParentId);
     sqlBuilder.SetValue(BaseContactEntity.FieldTitle, baseContactEntity.Title);
     sqlBuilder.SetValue(BaseContactEntity.FieldContents, baseContactEntity.Contents);
     sqlBuilder.SetValue(BaseContactEntity.FieldPriority, baseContactEntity.Priority);
     sqlBuilder.SetValue(BaseContactEntity.FieldSendCount, baseContactEntity.SendCount);
     sqlBuilder.SetValue(BaseContactEntity.FieldReadCount, baseContactEntity.ReadCount);
     sqlBuilder.SetValue(BaseContactEntity.FieldIsOpen, baseContactEntity.IsOpen);
     sqlBuilder.SetValue(BaseContactEntity.FieldCommentUserId, baseContactEntity.CommentUserId);
     sqlBuilder.SetValue(BaseContactEntity.FieldCommentUserRealName, baseContactEntity.CommentUserRealName);
     sqlBuilder.SetValue(BaseContactEntity.FieldCommentDate, baseContactEntity.CommentDate);
     sqlBuilder.SetValue(BaseContactEntity.FieldDeletionStateCode, baseContactEntity.DeletionStateCode);
     sqlBuilder.SetValue(BaseContactEntity.FieldEnabled, baseContactEntity.Enabled);
     sqlBuilder.SetValue(BaseContactEntity.FieldSortCode, baseContactEntity.SortCode);
     sqlBuilder.SetValue(BaseContactEntity.FieldDescription, baseContactEntity.Description);
 }
        /// <summary>
        /// 邮件有评论时要进行的操作
        /// </summary>
        /// <param name="detailsID">邮件主键</param>
        /// <returns>影响行数</returns>
        public int OnCommnet(string detailsId)
        {
            int returnValue = 0;
            BaseContactDetailsEntity contactDetailsEntity = this.GetEntity(detailsId);
            // 更新子表的其他人的通知,首先是有效的邮件,其次不是新邮件,其次不是自己的邮件
            string sqlQuery = " UPDATE BaseContactDetails "
                              + "    SET NewComment = 1 "
                              + "  WHERE (Enabled = 1) "
                              + "        AND (IsNew = 0) "
                              + "        AND (ContactId = '" + contactDetailsEntity.ContactId + "') "
                              + "        AND (ID <> '" + detailsId + "')";

            returnValue += DbHelper.ExecuteNonQuery(sqlQuery);
            BaseContactManager contactManager = new BaseContactManager(DbHelper, UserInfo);
            BaseContactEntity  contactEntity  = contactManager.GetEntity(contactDetailsEntity.ContactId);

            // 更新主表状态,评论人、评论时间发布上去
            contactEntity.CommentDate         = DateTime.Now;
            contactEntity.CommentUserId       = UserInfo.Id;
            contactEntity.CommentUserRealName = UserInfo.RealName;
            returnValue += contactManager.Update(contactEntity);
            return(returnValue);
        }
예제 #5
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseContactEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseContactEntity baseContactEntity)
 {
     return(this.AddEntity(baseContactEntity));
 }
예제 #6
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="baseContactEntity">实体</param>
        public string AddEntity(BaseContactEntity baseContactEntity)
        {
            string sequence = string.Empty;

            sequence = baseContactEntity.Id;
            if (baseContactEntity.SortCode == 0)
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                baseContactEntity.SortCode = int.Parse(sequence);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(BaseContactEntity.TableName, BaseContactEntity.FieldId);
            if (baseContactEntity.Id is string)
            {
                this.Identity = false;
            }
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseContactEntity.FieldId, baseContactEntity.Id);
            }
            else
            {
                if (!this.ReturnId && DbHelper.CurrentDbType == DbTypes.Oracle)
                {
                    sqlBuilder.SetFormula(BaseContactEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                }
                else
                {
                    if (this.Identity && DbHelper.CurrentDbType == DbTypes.Oracle)
                    {
                        if (string.IsNullOrEmpty(sequence))
                        {
                            BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                            sequence = sequenceManager.GetSequence(this.CurrentTableName);
                        }
                        baseContactEntity.Id = sequence;
                        sqlBuilder.SetValue(BaseContactEntity.FieldId, baseContactEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, baseContactEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseContactEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseContactEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseContactEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseContactEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseContactEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseContactEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == DbTypes.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
예제 #7
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">主键</param>
        public BaseContactEntity GetEntity(string id)
        {
            BaseContactEntity baseContactEntity = new BaseContactEntity(this.GetDataTableById(id));

            return(baseContactEntity);
        }
예제 #8
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="baseContactEntity">实体</param>
 public int Update(BaseContactEntity baseContactEntity)
 {
     return(this.UpdateEntity(baseContactEntity));
 }
예제 #9
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseContactEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <returns>主键</returns>
 public string Add(BaseContactEntity baseContactEntity, bool identity)
 {
     this.Identity = identity;
     return(this.AddEntity(baseContactEntity));
 }