Exemplo n.º 1
0
 public bool InsertInProgressComment(InProgressComment comment)
 {
     try
     {
         if (XmlManager.InsertInProgressPostComment(Server.MapPath("~/App_Data/InProgressComments.xml"),
                                                    comment.InProgressPostId, comment.User, comment.Email, comment.HomePage, comment.Comment))
         {
             string Body = comment.User + " ( " + comment.Email + " ) added a comment for an In Progress Post." +
                           System.Environment.NewLine + comment.Comment;
             Utils.SendEmail("*****@*****.**", "*****@*****.**", "Comment Added for In Progress Post: ",
                             Body);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         string Body = "An error was encountered: " + Environment.NewLine + ex.ToString();
         Utils.SendEmail("*****@*****.**", "*****@*****.**", "error encountered", Body);
         return(false);
     }
 }
Exemplo n.º 2
0
 public static bool InsertInProgressPostComment(string Path, long InProgressPostId, string User, string Email,
                                                string HomePage, string Comment)
 {
     try
     {
         List <InProgressComment> comments = new List <InProgressComment>();
         InProgressComment        comment  = new InProgressComment();
         comment.Id = Generate.NewUniqueID;
         comment.InProgressPostId = InProgressPostId;
         comment.User             = User;
         comment.Email            = Email;
         comment.HomePage         = HomePage;
         comment.Comment          = Comment;
         comment.DatePublished    = DateTime.Now.ToString();
         comment.Active           = false;
         System.Xml.Serialization.XmlSerializer Serializer = new System.Xml.Serialization.XmlSerializer(comments.GetType());
         if (System.IO.File.Exists(Path))
         {
             Stream       PathStream      = File.Open(Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
             StreamReader objStreamReader = new StreamReader(PathStream);
             comments = (List <InProgressComment>)Serializer.Deserialize(objStreamReader);
             objStreamReader.Close();
             PathStream.Close();
             PathStream.Dispose();
             PathStream = File.Open(Path, FileMode.Truncate, FileAccess.Write, FileShare.Write);
             StreamWriter objStreamWriter = new StreamWriter(PathStream);
             comments.Reverse();
             comments.Add(comment);
             Serializer.Serialize(objStreamWriter, comments);
             objStreamWriter.Close();
         }
         else
         {
             comments.Add(comment);
             Stream       PathStream      = File.Open(Path, FileMode.Create, FileAccess.Write, FileShare.Write);
             StreamWriter objStreamWriter = new StreamWriter(PathStream);
             Serializer.Serialize(objStreamWriter, comments);
             objStreamWriter.Close();
             PathStream.Close();
             PathStream.Dispose();
         }
         return(true);
     }
     catch (Exception ex)
     {
         string Body = "An error was encountered: " + Environment.NewLine + ex.ToString();
         Utils.SendEmail("*****@*****.**", "*****@*****.**", "error encountered", Body);
         return(false);
     }
 }