コード例 #1
0
ファイル: Comments.cs プロジェクト: mrezakhani/8tafsir
 public int Save(CommentsEntity data)
 {
     try
     {
         return(Connection.Db.Query <int>("spCommentsSet",
                                          new
         {
             Id = data.Id,
             NewsId = data.NewsId,
             NewsType = data.NewsType,
             Name = data.Name,
             Email = data.Email,
             Comment = data.Comment,
             DateTime = data.DateTime,
             ShowMess = data.ShowMess,
             Reply = data.Reply,
             UserReply = data.UserReply,
             DateTimeReply = data.DateTimeReply,
         }, commandType: CommandType.StoredProcedure).SingleOrDefault());
     }
     catch (Exception ex)
     {
         Tools.SaveLog.Save(ex);
         return(-1);
     }
 }
コード例 #2
0
ファイル: Comments.cs プロジェクト: mrezakhani/8tafsir
 public List <CommentsEntity> Search(CommentsEntity data)
 {
     try
     {
         return(Connection.Db.Query <CommentsEntity>("spCommentsSearch",
                                                     new
         {
             Id = data.Id,
             NewsId = data.NewsId,
             NewsType = data.NewsType,
             Name = "%" + data.Name + "%",
             Email = "%" + data.Email + "%",
             Comment = "%" + data.Comment + "%",
             DateTime = "%" + data.DateTime + "%",
             ShowMess = data.ShowMess,
             Reply = "%" + data.Reply + "%",
             UserReply = data.UserReply,
             DateTimeReply = "%" + data.DateTimeReply + "%",
         }, commandType: CommandType.StoredProcedure).ToList());
     }
     catch (Exception ex)
     {
         Tools.SaveLog.Save(ex);
         return(new List <CommentsEntity>());
     }
 }
コード例 #3
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                BL             objBL       = new BL();
                CommentsEntity objComments = new CommentsEntity();
                objComments.name    = txtName.Text.Trim().Replace("'", "''");
                objComments.comment = txtComments.Text.Trim().Replace("'", "''");

                string result = objBL.InsertComment(objComments);
                //fillComments();
                if (result == "success")
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');",
                                                                                                     "Thanks for your comments"), true);
                    Clearfields();
                    fillComments();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');",
                                                                                                     "Error Occured, Please try Again"), true);
                }
            }
        }
コード例 #4
0
        protected AnnotationReplyInfo getAnnotationReplyInfo(CommentsEntity comment)
        {
            AnnotationReplyInfo annotationReplyInfo = base.GetAnnotationReplyInfo(comment);

            if (withGuid)
            {
                annotationReplyInfo.ParentReplyGuid = annotationData.id.ToString();
            }
            return(annotationReplyInfo);
        }
        /// <summary>
        /// Initial for reply annotation info
        /// </summary>
        /// <param name="comment">CommentsEntity</param>
        /// <returns>AnnotationReplyInfo</returns>
        protected AnnotationReplyInfo GetAnnotationReplyInfo(CommentsEntity comment)
        {
            AnnotationReplyInfo reply = new AnnotationReplyInfo();

            reply.Message = comment.text;
            DateTime date = DateTime.Parse(comment.time);

            reply.RepliedOn = date;
            reply.UserName  = comment.userName;
            return(reply);
        }
コード例 #6
0
        protected override Reply GetAnnotationReplyInfo(CommentsEntity comment)
        {
            Reply annotationReplyInfo = base.GetAnnotationReplyInfo(comment);

            if (withGuid)
            {
                annotationReplyInfo.ParentReply = new Reply {
                    Id = annotationData.id
                };
            }
            return(annotationReplyInfo);
        }
コード例 #7
0
        public string InsertComment(CommentsEntity objComment)
        {
            DA     objDA       = new DA();
            string sqlQuery    = "";
            string returnValue = string.Empty;

            //try
            //{
            //ID, Name, Description
            sqlQuery = "INSERT INTO tb_cloud (name,comments)VALUES('" + objComment.name + "','" + objComment.comment + "')";

            objDA.ExecuteNonQuery(sqlQuery);
            return("success");
            //}
            //catch()
            //{
            //return "error";
            //}
        }
        /// <summary>
        /// Initial for reply annotation info
        /// </summary>
        /// <param name="comment">CommentsEntity</param>
        /// <returns>AnnotationReplyInfo</returns>
        protected virtual Reply GetAnnotationReplyInfo(CommentsEntity comment)
        {
            Reply reply = new Reply();

            reply.Comment = comment.text;
            DateTime date;

            try
            {
                long     unixDate = long.Parse(comment.time);
                DateTime start    = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                date = start.AddMilliseconds(unixDate).ToLocalTime();
            }
            catch (System.Exception)
            {
                date = DateTime.Parse(comment.time);
            }
            reply.RepliedOn = date;
            reply.User      = new User {
                Name = comment.userName
            };
            return(reply);
        }
コード例 #9
0
        /// <summary>
        /// Map AnnotationInfo instances into AnnotationDataEntity
        /// </summary>
        /// <param name="annotationInfo">AnnotationInfo</param>
        /// <returns>AnnotationDataEntity</returns>
        public AnnotationDataEntity mapAnnotationDataEntity(AnnotationInfo annotationInfo)
        {
            AnnotationDataEntity annotation = new AnnotationDataEntity();

            annotation.font = annotationInfo.FontFamily;
            double fontSize = Convert.ToDouble((annotationInfo.FontSize == null) ? 0 : annotationInfo.FontSize);

            annotation.fontSize   = (float)fontSize;
            annotation.height     = annotationInfo.Box.Height;
            annotation.left       = annotationInfo.Box.X;
            annotation.pageNumber = (int)annotationInfo.PageNumber + 1;
            annotation.svgPath    = (annotationInfo.SvgPath != null) ? annotationInfo.SvgPath.Replace("l", "L") : null;
            string text = (annotationInfo.Text == null) ? annotationInfo.FieldText : annotationInfo.Text;

            annotation.text  = text;
            annotation.top   = annotationInfo.Box.Y;
            annotation.type  = Char.ToLowerInvariant(Enum.GetName(typeof(AnnotationType), annotationInfo.Type)[0]) + Enum.GetName(typeof(AnnotationType), annotationInfo.Type).Substring(1);
            annotation.width = annotationInfo.Box.Width;
            //  each reply data
            AnnotationReplyInfo[] replies = annotationInfo.Replies;
            if (replies != null && replies.Length > 0)
            {
                CommentsEntity[] comments = new CommentsEntity[replies.Length];
                for (int m = 0; m < replies.Length; m++)
                {
                    CommentsEntity      comment = new CommentsEntity();
                    AnnotationReplyInfo reply   = replies[m];
                    comment.text     = reply.Message;
                    comment.time     = reply.RepliedOn.ToString("yyyy-MM-dd HH:mm:ss");
                    comment.userName = reply.UserName;
                    comments[m]      = comment;
                }
                annotation.comments = comments;
            }
            return(annotation);
        }
        /// <summary>
        /// Map AnnotationInfo instances into AnnotationDataEntity
        /// </summary>
        /// <param name="annotationInfo">AnnotationInfo</param>
        /// <returns>AnnotationDataEntity</returns>
        public static AnnotationDataEntity MapAnnotationDataEntity(AnnotationBase annotationInfo, PageInfo pageInfo, string documentType)
        {
            string annotationTypeName = Enum.GetName(typeof(AnnotationType), annotationInfo.Type);
            float  maxY = 0, minY = 0, maxX = 0, minX = 0;
            float  boxX = 0, boxY = 0, boxHeight = 0, boxWidth = 0;
            string svgPath = "";

            if (annotationInfo is IPoints)
            {
                List <Point> points = ((IPoints)annotationInfo).Points;
                maxY = points.Max(p => p.Y);
                minY = points.Min(p => p.Y);
                maxX = points.Max(p => p.X);
                minX = points.Min(p => p.X);
            }

            if (annotationInfo is IBox)
            {
                Rectangle box = ((IBox)annotationInfo).Box;
                boxX      = box.X;
                boxY      = box.Y;
                boxHeight = box.Height;
                boxWidth  = box.Width;

                StringBuilder builder = new StringBuilder().
                                        Append("M").Append(box.X.ToString(CultureInfo.InvariantCulture)).
                                        Append(",").Append(box.Y.ToString(CultureInfo.InvariantCulture)).
                                        Append("L").Append(box.Width.ToString(CultureInfo.InvariantCulture)).
                                        Append(",").Append(box.Height.ToString(CultureInfo.InvariantCulture));

                svgPath = builder.ToString();
            }

            AnnotationDataEntity annotation = new AnnotationDataEntity();

            annotation.font = annotationInfo is IFontFamily ? ((IFontFamily)annotationInfo).FontFamily : "";
            double fontSize = annotationInfo is IFontSize?Convert.ToDouble((((IFontSize)annotationInfo).FontSize == null)? 0 : ((IFontSize)annotationInfo).FontSize) : (annotationInfo is ITextToReplace ? 10 : 0);

            annotation.fontSize   = (float)fontSize;
            annotation.fontColor  = annotationInfo is IFontColor ? ((((IFontColor)annotationInfo).FontColor == null) ? 0 : (int)((IFontColor)annotationInfo).FontColor) : 0;
            annotation.height     = annotationInfo is IBox ? boxHeight : (annotationInfo is IPoints ? (maxY - minY) : 0);
            annotation.left       = annotationInfo is IBox ? boxX : (annotationInfo is IPoints ? minX : 0);
            annotation.pageNumber = (int)annotationInfo.PageNumber + 1;
            annotation.svgPath    = annotationInfo is ISvgPath ? (((ISvgPath)annotationInfo).SvgPath?.Replace("l", "L")) : svgPath;
            string text = annotationInfo is IText ? ((IText)annotationInfo).Text : (annotationInfo is ITextToReplace ? ((ITextToReplace)annotationInfo).TextToReplace : "");

            annotation.text = text;
            // TODO: remove comment after check all annotations types on main formats
            annotation.top   = annotationInfo is IBox ? boxY : (annotationInfo is IPoints ? (!documentType.Equals("image") ? pageInfo.Height - maxY : minY) : 0);
            annotation.type  = char.ToLowerInvariant(annotationTypeName[0]) + annotationTypeName.Substring(1);
            annotation.width = annotationInfo is IBox ? boxWidth : (annotationInfo is IPoints ? (maxX - minX) : 0);
            //  each reply data
            Reply[] replies = annotationInfo.Replies.ToArray();
            if (replies != null && replies.Length > 0)
            {
                CommentsEntity[] comments = new CommentsEntity[replies.Length];
                for (int m = 0; m < replies.Length; m++)
                {
                    CommentsEntity comment = new CommentsEntity();
                    Reply          reply   = replies[m];
                    comment.text     = reply.Comment;
                    comment.time     = reply.RepliedOn.ToString("yyyy-MM-dd HH:mm:ss");
                    comment.userName = reply.User.Name;
                    comments[m]      = comment;
                }
                annotation.comments = comments;
            }
            return(annotation);
        }