Esempio n. 1
0
        protected void btnWrite_Click(object sender, EventArgs e)
        {
            ReplyEntity re = new ReplyEntity();

            re.Name     = txtName.Text;
            re.Email    = txtEmail.Text;
            re.Homepage = txtHomepage.Text;
            re.Title    = txtTitle.Text;
            re.PostIP   = Request.UserHostAddress;
            re.Content  = txtContent.Text;
            re.Encoding = lstEncoding.SelectedValue;
            re.Password = txtPassword.Text;

            if (!String.IsNullOrEmpty(Request["Mode"]) && Request["Mode"].ToLower() == "reply")
            {
                // 답변 로직 처리 : 두번째 매개변수가 부모글의 번호(ParentNUm)로 저장
                (new ReplyBiz()).InsertReply(re, Convert.ToInt32(Request["Num"]));
            }
            else
            {
                // 저장 로직 처리
                ReplyBiz rb = new ReplyBiz();
                rb.InsertReply(re);
            }

            // 리스트로 이동
            string strJs = @"
            <script>alert('입력되었습니다.'); location.href='List.aspx';</script>
        ";

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "goList", strJs);
        }
        private async void PostReplyCommandExecute()
        {
            if (this.IsPostingRepy)
            {
                return;
            }

            this.IsPostingRepy = true;

            try
            {
                ReplyPostData post = new ReplyPostData()
                {
                    Content = this.NewReplyText,
                    Post    = this.idGuid
                };
                ReplyEntity repy = await App.Client.ReplyAsync(post);

                this.Replys.Clear();
                this.NewReplyText = string.Empty;
            }
            catch (ApiException exception)
            {
                this.Message = exception.ToString();
            }
            finally
            {
                this.IsPostingRepy = false;
            }

            this.LoadItemById(this.idGuid);
        }
Esempio n. 3
0
        public int InsertReply(ReplyEntity re, int num)
        {
            SqlConnection con = new SqlConnection(_ConnectionString);

            SqlCommand cmd = new SqlCommand("ReplyReply", con);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@Name", re.Name);
            cmd.Parameters.AddWithValue("@Email", re.Email);
            cmd.Parameters.AddWithValue("@Title", re.Title);
            cmd.Parameters.AddWithValue("@PostIp", re.PostIP);
            cmd.Parameters.AddWithValue("@Content", re.Content);
            cmd.Parameters.AddWithValue("@Password", re.Password);
            cmd.Parameters.AddWithValue("@Encoding", re.Encoding);
            cmd.Parameters.AddWithValue("@Homepage", re.Homepage);
            cmd.Parameters.AddWithValue("@ParentNum", num);

            con.Open();
            int result = cmd.ExecuteNonQuery();

            con.Close();

            return(result);
        }
Esempio n. 4
0
        public static List <ReplyEntity> GetTaskReplys(string guid, int pageSize, int pageIndex, ref int totalCount, ref int pageCount)
        {
            List <ReplyEntity> list = new List <ReplyEntity>();

            DataSet   ds          = ReplyDAL.BaseProvider.GetTaskReplys(guid, pageSize, pageIndex, ref totalCount, ref pageCount);
            DataTable replys      = ds.Tables["Replys"];
            DataTable attachments = ds.Tables["Attachments"];

            foreach (DataRow dr in replys.Rows)
            {
                ReplyEntity model = new ReplyEntity();
                model.FillData(dr);
                model.CreateUser = OrganizationBusiness.GetUserCacheByUserID(model.CreateUserID, model.ClientID);
                if (!string.IsNullOrEmpty(model.FromReplyID))
                {
                    model.FromReplyUser = OrganizationBusiness.GetUserCacheByUserID(model.FromReplyUserID, model.FromReplyAgentID);
                }

                model.Attachments = new List <Attachment>();
                if (attachments.Rows.Count > 0)
                {
                    foreach (DataRow dr2 in attachments.Select(" Guid='" + model.ReplyID + "'"))
                    {
                        Attachment attachment = new Attachment();
                        attachment.FillData(dr2);

                        model.Attachments.Add(attachment);
                    }
                }
                list.Add(model);
            }

            return(list);
        }
Esempio n. 5
0
        public int UpdateReply(ReplyEntity entity)
        {
            SqlConnection con = new SqlConnection(_ConnectionString);

            SqlCommand cmd = new SqlCommand("ModifyReply", con);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@Name", entity.Name);
            cmd.Parameters.AddWithValue("@Email", entity.Email);
            cmd.Parameters.AddWithValue("@Title", entity.Title);
            cmd.Parameters.AddWithValue("@ModifyIp", entity.ModifyIP);
            cmd.Parameters.AddWithValue("@Content", entity.Content);
            cmd.Parameters.AddWithValue("@Encoding", entity.Encoding);
            cmd.Parameters.AddWithValue("@Homepage", entity.Homepage);
            cmd.Parameters.AddWithValue("@Password", entity.Password);
            cmd.Parameters.AddWithValue("@Num", entity.Num);

            con.Open();
            int result = cmd.ExecuteNonQuery();

            con.Close();

            return(result);
        }
Esempio n. 6
0
        public void ProcessRequest(HttpContext context)
        {
            string userId       = DEncryptUtils.DESDecrypt(CookieHelper.GetCookieValue("52cos", "user_id")).Replace("\0", "");
            string type         = context.Request.Form["comment_parent"];
            string workId       = context.Request.Form["comment_post_ID"];
            string replyContent = context.Request.Form["comment"];
            string s            = "{\"status\":\"error\"}";

            if (userId.Trim() != "")
            {
                ReplyEntity replyEntity = new ReplyEntity();
                replyEntity.User_id      = userId;
                replyEntity.type         = type;
                replyEntity.workId       = workId;
                replyEntity.ReplyContent = replyContent;
                replyEntity.ReleaseTime  = DateTime.Now;
                //插入回复表
                if (ReplyBll.Instance.Add(replyEntity) > 0)
                {
                    // todo 更新作品时间
                    s = "{\"status\":\"success\"}";
                }
            }

            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            context.Response.Write(s);
        }
Esempio n. 7
0
        public JsonResult SavaReply(string entity)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ReplyEntity          model      = serializer.Deserialize <ReplyEntity>(entity);

            string replyID = "";

            replyID = OrdersBusiness.CreateReply(model.GUID, model.Content, CurrentUser.UserID, CurrentUser.AgentID, model.FromReplyID, model.FromReplyUserID, model.FromReplyAgentID);

            List <ReplyEntity> list = new List <ReplyEntity>();

            if (!string.IsNullOrEmpty(replyID))
            {
                model.ReplyID      = replyID;
                model.CreateTime   = DateTime.Now;
                model.CreateUser   = CurrentUser;
                model.CreateUserID = CurrentUser.UserID;
                model.AgentID      = CurrentUser.AgentID;
                if (!string.IsNullOrEmpty(model.FromReplyUserID) && !string.IsNullOrEmpty(model.FromReplyAgentID))
                {
                    model.FromReplyUser = OrganizationBusiness.GetUserByUserID(model.FromReplyUserID, model.FromReplyAgentID);
                }
                list.Add(model);
            }
            JsonDictionary.Add("items", list);
            return(new JsonResult
            {
                Data = JsonDictionary,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Esempio n. 8
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // parse query parameter
            string name = req.GetQueryNameValuePairs()
                          .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
                          .Value;

            // Get request body
            dynamic data = await req.Content.ReadAsAsync <object>();

            // Set name to query string or body data
            name = name ?? data?.name;

            ReplyEntity replyOb = new ReplyEntity
            {
                Id    = Guid.NewGuid(),
                Name  = "Test",
                Value = "Value result"
            };

            return(name == null
                ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
                : req.CreateResponse(HttpStatusCode.OK, replyOb));
        }
Esempio n. 9
0
        /// <summary>
        /// Insert reply
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="replyHandle">Reply handle</param>
        /// <param name="commentHandle">Comment handle</param>
        /// <param name="topicHandle">Topic handle</param>
        /// <param name="text">Reply text</param>
        /// <param name="language">Reply language</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="createdTime">Created time</param>
        /// <param name="reviewStatus">Review status</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="requestId">Request id associated with the create reply request</param>
        /// <returns>Insert reply task</returns>
        public async Task InsertReply(
            StorageConsistencyMode storageConsistencyMode,
            string replyHandle,
            string commentHandle,
            string topicHandle,
            string text,
            string language,
            string userHandle,
            DateTime createdTime,
            ReviewStatus reviewStatus,
            string appHandle,
            string requestId)
        {
            ReplyEntity replyEntity = new ReplyEntity()
            {
                CommentHandle   = commentHandle,
                TopicHandle     = topicHandle,
                Text            = text,
                Language        = language,
                UserHandle      = userHandle,
                CreatedTime     = createdTime,
                LastUpdatedTime = createdTime,
                AppHandle       = appHandle,
                ReviewStatus    = reviewStatus,
                RequestId       = requestId
            };

            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Replies);

            ObjectTable table     = this.tableStoreManager.GetTable(ContainerIdentifier.Replies, TableIdentifier.RepliesObject) as ObjectTable;
            Operation   operation = Operation.Insert(table, replyHandle, replyHandle, replyEntity);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }
Esempio n. 10
0
        public List <ReplyEntity> SelectReply()
        {
            // 반환 용도로 리스트제네릭클래스 변수 선언
            List <ReplyEntity> lst = new List <ReplyEntity>();
            // Dac단에서 DataSet 받기
            DataSet   ds = (new ReplyDac()).SelectReply();
            DataTable dt = ds.Tables[0];

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            { // 반환된 레코드 수만큼 반복
                ReplyEntity re = new ReplyEntity();

                re.Num       = Convert.ToInt32(dt.Rows[i]["Num"]);
                re.Name      = dt.Rows[i]["Name"].ToString();
                re.Email     = dt.Rows[i]["Email"].ToString();
                re.Title     = dt.Rows[i]["Title"].ToString();
                re.PostDate  = Convert.ToDateTime(dt.Rows[i]["PostDate"]);
                re.PostIP    = dt.Rows[i]["PostIP"].ToString();
                re.Content   = dt.Rows[i]["Content"].ToString();
                re.Password  = dt.Rows[i]["Password"].ToString();
                re.ReadCount = Convert.ToInt32(dt.Rows[i]["ReadCount"].ToString());
                re.Encoding  = dt.Rows[i]["Encoding"].ToString();
                re.Homepage  = dt.Rows[i]["Homepage"].ToString();
                //re.ModifyDate = Convert.ToDateTime(dt.Rows[i]["ModifyDate"]);
                //re.ModifyIP = dt.Rows[i]["ModifyIP"].ToString();
                re.Ref      = Convert.ToInt32(dt.Rows[i]["Ref"]);
                re.Step     = Convert.ToInt32(dt.Rows[i]["Step"]);
                re.RefOrder = Convert.ToInt32(dt.Rows[i]["RefOrder"]);

                lst.Add(re);
            }

            return(lst);
        }
Esempio n. 11
0
        /// <summary>
        /// Query reply
        /// </summary>
        /// <param name="replyHandle">Reply handle</param>
        /// <returns>Reply entity</returns>
        public async Task <IReplyEntity> QueryReply(string replyHandle)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Replies);

            ObjectTable table       = this.tableStoreManager.GetTable(ContainerIdentifier.Replies, TableIdentifier.RepliesObject) as ObjectTable;
            ReplyEntity replyEntity = await store.QueryObjectAsync <ReplyEntity>(table, replyHandle, replyHandle);

            return(replyEntity);
        }
Esempio n. 12
0
        private void DisplayData()
        {
            // 부모글의 제목과 내용을 텍스트박스에 바인딩
            ReplyEntity re = (new ReplyBiz()).SelectReplyByNum(Convert.ToInt32(Request["Num"]));

            this.txtTitle.Text   = "Re : " + re.Title; // 부모글의 Re : 붙여서 출력
            this.txtContent.Text =
                "\r\n\r\n--------------------\r\n>" +
                re.Content.Replace("\r\n", "\r\n>")
                + "\r\n--------------------\r\n";
        }
Esempio n. 13
0
        private bool UpdateReplyEntity(ReplyEntity replyEntity, UpdateReplyModel updateReplyModel)
        {
            var requireUpdate = false;

            if (replyEntity.Content != updateReplyModel.Content)
            {
                replyEntity.Content = updateReplyModel.Content;
                requireUpdate       = true;
            }

            return(requireUpdate);
        }
Esempio n. 14
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(ReplyEntity model)
 {
     try
     {
         return(ReplyDb.Instance.Add(model));
     }
     catch (Exception ex)
     {
         WriteLog.WriteError(ex);
         throw ex;
     }
 }
Esempio n. 15
0
        public int UpdateReply(ReplyEntity entity)
        {
            int result = -1;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                result = (new ReplyDac()).UpdateReply(entity);

                scope.Complete();
            }

            return(result);
        }
Esempio n. 16
0
        public int InsertReply(ReplyEntity re)
        {
            int result = -1;

            using (TransactionScope scope =
                       new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                ReplyDac rd = new ReplyDac();
                result = rd.InsertReply(re);

                scope.Complete();
            }
            return(result);
        }
Esempio n. 17
0
        public async Task <IActionResult> Edit(Guid id, ReplyEntity comment)
        {
            if (ModelState.IsValid)
            {
                var targetComment = await this.commentRepository.GetById(id);

                targetComment.Content = comment.Content;

                await this.commentRepository.Update(targetComment);

                return(this.RedirectToAsync <PostController>(x => x.Details(targetComment.PostId.Value)));
            }

            return(View(comment));
        }
Esempio n. 18
0
        private async Task <ReplyEntity> SavePostEntity(ReplyPostData daten, SqlConnection connection)
        {
            var user = await this.userDatabaseAccess.Get(this.userService.Username, connection);

            var newReply = new ReplyEntity();

            newReply.CopyPropertiesFrom(daten);
            newReply.Creationdate = DateTime.Now;
            newReply.Author       = user.Id;

            using var context = new DatabaseContext(connection);
            await context.Reply.AddAsync(newReply);

            await context.SaveChangesAsync();

            return(newReply);
        }
Esempio n. 19
0
        public async Task <Guid> AddReplyAsync(Guid commentId, SaveReplyModel model)
        {
            ArgumentGuard.NotEmpty(commentId, nameof(commentId));
            ArgumentGuard.NotNull(model, nameof(model));

            // validation,

            var replyEntity = new ReplyEntity
            {
                AuthorId       = _userContext.UserId,
                CommentId      = commentId,
                Content        = model.Content,
                CreatedDateUtc = DateTime.UtcNow
            };

            return(await _replyRepository.AddAsync(replyEntity));
        }
Esempio n. 20
0
        public JsonResult SavaReply(EnumLogObjectType type, string entity, string attchmentEntity)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ReplyEntity          model      = serializer.Deserialize <ReplyEntity>(entity);

            model.Attachments = serializer.Deserialize <List <Attachment> >(attchmentEntity);
            string replyID = "";

            switch (type)
            {
            case EnumLogObjectType.Customer:
                replyID = ReplyBusiness.CreateCustomerReply(model.GUID, model.Content, CurrentUser.UserID, CurrentUser.ClientID, model.FromReplyID, model.FromReplyUserID, model.FromReplyAgentID);
                ReplyBusiness.AddCustomerReplyAttachments(model.GUID, replyID, model.Attachments, CurrentUser.UserID, CurrentUser.ClientID);
                break;

            case EnumLogObjectType.OrderTask:
                replyID = ReplyBusiness.CreateTaskReply(model.GUID, model.Content, CurrentUser.UserID, CurrentUser.ClientID, model.FromReplyID, model.FromReplyUserID, model.FromReplyAgentID);
                ReplyBusiness.AddTaskReplyAttachments(model.GUID, replyID, model.Attachments, CurrentUser.UserID, CurrentUser.ClientID);
                break;
            }


            List <ReplyEntity> list = new List <ReplyEntity>();

            if (!string.IsNullOrEmpty(replyID))
            {
                model.ReplyID      = replyID;
                model.CreateTime   = DateTime.Now;
                model.CreateUser   = OrganizationBusiness.GetUserCacheByUserID(CurrentUser.UserID, CurrentUser.ClientID);;
                model.CreateUserID = CurrentUser.UserID;
                if (!string.IsNullOrEmpty(model.FromReplyUserID) && !string.IsNullOrEmpty(model.FromReplyAgentID))
                {
                    model.FromReplyUser = OrganizationBusiness.GetUserCacheByUserID(model.FromReplyUserID, model.FromReplyAgentID);
                }
                list.Add(model);
            }
            JsonDictionary.Add("items", list);
            return(new JsonResult
            {
                Data = JsonDictionary,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Esempio n. 21
0
        private void DisplayData()
        {
            // 메서드 실행 후 그 결과값을 ReplyEntity 엔터티 개체에 담기
            ReplyEntity re = (new ReplyBiz()).SelectReplyByNum(Convert.ToInt32(Request["Num"]));

            // 각각의 컨트롤에 바인딩
            lblNum.Text      = Request["Num"];
            lblTitle.Text    = re.Title;
            lblName.Text     = re.Name;
            lblEmail.Text    = re.Email;
            lblHomepage.Text = re.Homepage;
            lblPostDate.Text = re.PostDate.ToString();

            // 수정되었을 때에만, 해당 날짜 기록
            if (re.ModifyDate != DateTime.MinValue)
            {
                lblModifyDate.Text = re.ModifyDate.ToString();
            }

            lblReadCount.Text = re.ReadCount.ToString();
            lblPostIP.Text    = re.PostIP;

            #region 인코딩 방식에 따른 컨텐츠 출력
            lblContent.Text =
                BoardUtil.ConvertContentByEncoding(re.Content, re.Encoding);
            //if (re.Encoding == "Text") // 태그 실행 방지/소스 그대로
            //{
            //    lblContent.Text =
            //        re.Content.Replace("&", "&amp;").Replace(
            //                "<", "&lt;").Replace(">", "&gt;").Replace(
            //                        "\r\n", "<br />").Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
            //}
            //else if (re.Encoding == "Mixed") // 태그 실행
            //{
            //    lblContent.Text = re.Content.Replace("\r\n", "<br />");
            //}
            //else // HTML로 표시
            //{
            //    lblContent.Text = re.Content;
            //}
            #endregion
        }
Esempio n. 22
0
        public static List <ReplyEntity> GetReplys(string guid, int pageSize, int pageIndex, ref int totalCount, ref int pageCount)
        {
            List <ReplyEntity> list     = new List <ReplyEntity>();
            string             whereSql = " Status<>9 and GUID='" + guid + "' ";
            DataTable          dt       = CommonBusiness.GetPagerData("CustomerReply", "*", whereSql, "AutoID", "CreateTime desc ", pageSize, pageIndex, out totalCount, out pageCount, false);

            foreach (DataRow dr in dt.Rows)
            {
                ReplyEntity model = new ReplyEntity();
                model.FillData(dr);
                model.CreateUser = OrganizationBusiness.GetUserByUserID(model.CreateUserID, model.AgentID);
                if (!string.IsNullOrEmpty(model.FromReplyID))
                {
                    model.FromReplyUser = OrganizationBusiness.GetUserByUserID(model.FromReplyUserID, model.FromReplyAgentID);
                }
                list.Add(model);
            }

            return(list);
        }
Esempio n. 23
0
        public bool AddCommentByUser(CommentEntity comment, int userId = 0, bool?admin = null, int commentIdToAddOn = 0)  //
        {
            var reply            = new ReplyEntity();
            var resultForComment = AddJustComment(comment);

            if (comment.IsReply && resultForComment)
            {
                reply.AvatarId            = userId;
                reply.CommentId           = _ctx.CommentEntity.Max(c => c.Id);
                reply.ResponseToCommentId = commentIdToAddOn;
                reply.IsSuperUser         = admin;

                _ctx.ReplyEntity.Add(reply);
                bool result = Save();

                var check = _ctx.ReplyEntity.Include(r => r.ResponseComment).AsSingleQuery().ToList();

                return(result);
            }
            return(resultForComment);
        }
Esempio n. 24
0
        public ReplyEntity SelectReplyByNum(int num)
        {
            // 1개 레코드 타입 변수 선언
            ReplyEntity re = new ReplyEntity();

            // 데이터가 있으면, 엔터티에 담기
            using (IDataReader dr = (new ReplyDac()).SelectReplyByNum(num))
            {
                if (dr.Read())
                {
                    re.Num       = Convert.ToInt32(dr["Num"]);
                    re.Name      = dr["Name"].ToString();
                    re.Email     = dr["Email"].ToString();
                    re.Title     = dr["Title"].ToString();
                    re.PostDate  = Convert.ToDateTime(dr["PostDate"]);
                    re.PostIP    = dr["PostIP"].ToString();
                    re.Content   = dr["Content"].ToString();
                    re.Password  = dr["Password"].ToString();
                    re.ReadCount = Convert.ToInt32(dr["ReadCount"].ToString());
                    re.Encoding  = dr["Encoding"].ToString();
                    re.Homepage  = dr["Homepage"].ToString();
                    if (dr.IsDBNull(11))
                    {
                        re.ModifyDate = DateTime.MinValue;
                    }
                    else
                    {
                        re.ModifyDate = Convert.ToDateTime(dr["ModifyDate"]);
                    }
                    re.ModifyIP = dr["ModifyIP"].ToString();
                    re.Ref      = Convert.ToInt32(dr["Ref"]);
                    re.Step     = Convert.ToInt32(dr["Step"]);
                    re.RefOrder = Convert.ToInt32(dr["RefOrder"]);
                }
                dr.Close(); // DataReader가 클로즈되는 순간에 DAC에서 Open()된 커넥션 종료
            }
            // 결과값 반환
            return(re);
        }
Esempio n. 25
0
        public object PostComment(string uid, string cv, string aid, [FromBody] string cont)
        {
            string      userId       = uid;
            string      type         = cv;
            string      workId       = aid;
            string      replyContent = cont;
            int         i            = -1;
            ReplyEntity replyEntity  = new ReplyEntity();

            replyEntity.User_id      = userId;
            replyEntity.type         = type;
            replyEntity.workId       = workId;
            replyEntity.ReplyContent = replyContent;
            replyEntity.ReleaseTime  = DateTime.Now;
            //插入回复表
            if (ReplyBll.Instance.Add(replyEntity) > 0)
            {
                //更新作品时间
                if (cv == "works")
                {
                    WorksEntity worksEntity = WorksBll.Instance.GetModel(int.Parse(aid));
                    worksEntity.UpdateTime = DateTime.Now;
                    WorksBll.Instance.Update(worksEntity);
                }

                return(new Dictionary <string, StatusEnum> {
                    { "Status", StatusEnum.success }
                });
            }
            else
            {
                return(new Dictionary <string, StatusEnum> {
                    { "Status", StatusEnum.error }
                });
            }
        }
Esempio n. 26
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ReplyEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into sns_reply(");
            strSql.Append("type,workId,User_id,ReplyContent,ReleaseTime,Status)");
            strSql.Append(" values (");
            strSql.Append("@type,@workId,@User_id,@ReplyContent,@ReleaseTime,@Status)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@type",         SqlDbType.VarChar,   50),
                new SqlParameter("@workId",       SqlDbType.VarChar,   50),
                new SqlParameter("@User_id",      SqlDbType.VarChar,   50),
                new SqlParameter("@ReplyContent", SqlDbType.Text),
                new SqlParameter("@ReleaseTime",  SqlDbType.DateTime),
                new SqlParameter("@Status",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.type;
            parameters[1].Value = model.workId;
            parameters[2].Value = model.User_id;
            parameters[3].Value = model.ReplyContent;
            parameters[4].Value = model.ReleaseTime;
            parameters[5].Value = model.Status;

            object obj = SqlHelper.Instance.ExecSqlScalar(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 27
0
        public Reply PostReply(string user,
                               string[] atUser,
                               string msgContent,
                               string richMessage,
                               string[] attachmentID,
                               DateTime timestamp,
                               //string originMessageUser,
                               string originMessageID)
        {
            if (_accManager.FindUser(user) == null)
            {
                throw new UserNotFoundException(user);
            }

            //merge toUser list and @somebody in the message content
            List <String>    validToUsers = new List <String>();
            HashSet <string> ToUserIDs    = new HashSet <string>();

            ToUserIDs.UnionWith(Utils.GetAtUserid(msgContent));
            if (atUser != null)
            {
                ToUserIDs.UnionWith(atUser);
            }
            foreach (string uid in ToUserIDs)
            {
                var temp = _accManager.FindUser(uid);
                if (temp != null)
                {
                    validToUsers.Add(temp.Userid);
                }
            }
            atUser = validToUsers.ToArray();

            TableOperation retreiveOperation = MessageManager.RetrieveUserlineMsgByID <UserLineEntity>(originMessageID);
            TableResult    retreiveResult    = _userline.Execute(retreiveOperation);
            UserLineEntity originMsg         = ((UserLineEntity)retreiveResult.Result);

            if (originMsg == null)
            {
                throw new MessageNotFoundException();
            }

            //Insert Rich Message
            string richMessageID = null;

            if (!string.IsNullOrEmpty(richMessage))
            {
                richMessageID = _richMsgManager.PostRichMessage(user, timestamp, richMessage);
            }

            //Reply reply = new Reply(user, atUser, msgContent, timestamp, originMessageUser, originMessageID);
            Reply reply = new Reply(user, originMsg.Group, msgContent, timestamp, null, originMessageID, atUser, richMessageID, attachmentID);

            //insert reply
            ReplyEntity    replyEntity     = new ReplyEntity(reply);
            TableOperation insertOperation = TableOperation.Insert(replyEntity);

            _reply.Execute(insertOperation);

            //update reply count
            originMsg.ReplyCount++;
            TableOperation updateOperation = TableOperation.Replace(originMsg);

            _userline.Execute(updateOperation);

            foreach (string userid in atUser)
            {
                if (_accManager.FindUser(userid) == null)
                {
                    continue;
                }
                //notif user
                ReplyNotificationEntifity notifEntity = new ReplyNotificationEntifity(userid, reply);
                insertOperation = TableOperation.Insert(notifEntity);
                _replyNotification.Execute(insertOperation);
                _replyArchive.Execute(insertOperation);

                _notifManager.incrementReplyNotifCount(userid);
            }

            return(reply);
        }
Esempio n. 28
0
 public int InsertReply(ReplyEntity re, int parentNum)
 {
     return((new ReplyDac()).InsertReply(re, parentNum));
 }