Ejemplo n.º 1
0
 public static long CreateQuoteMiniBlog(User user, string oriMid, string quoMid, string content, string picID, int fromID)
 {
     try
     {
         MiniBlog oriMiniblog = MiniBlogs.GetMiniBlogByID(Convert.ToInt64(oriMid));
         if (oriMiniblog != null)
         {
             string   originalCon = content;
             string   realCon     = TransformToBBCode(content);
             string   atStr       = GetAtStr(realCon);
             MiniBlog miniblog    = new MiniBlog();
             string   idCode      = "";
             miniblog.ID     = Data.DbGenerateID.GenerateID(ref idCode);
             miniblog.IDCode = idCode;
             if (!atStr.Contains("a" + oriMiniblog.UID.ToString() + "a,"))
             {
                 atStr += "a" + oriMiniblog.UID.ToString() + "a,";
             }
             string[] oriAtArray = oriMiniblog.ReferUID.Split(',');
             for (int i = 0; i < oriAtArray.Length - 1; i++)
             {
                 if (!atStr.Contains(oriAtArray[i]))
                 {
                     atStr += oriAtArray[i] + ",";
                 }
             }
             Users.AtMeTip(atStr, user.ID, -1);
             miniblog.ReferUID        = atStr;
             miniblog.OriginalContent = originalCon;
             miniblog.RealContent     = realCon;
             miniblog.UID             = user.ID;
             miniblog.IsOriginal      = 0;
             miniblog.IsHaveVote      = oriMiniblog.IsHaveVote;
             miniblog.IsHaveVideo     = oriMiniblog.IsHaveVideo;
             miniblog.IsHavePic       = oriMiniblog.IsHavePic;
             miniblog.IsHaveMusic     = oriMiniblog.IsHaveMusic;
             miniblog.IsHaveLink      = oriMiniblog.IsHaveLink;
             miniblog.FromID          = fromID;
             Froms.UpdateFromForFromCount(fromID);
             miniblog.MediaContent     = "";
             miniblog.OriginalMID      = Convert.ToInt64(oriMid);
             miniblog.QuoteMID         = Convert.ToInt64(quoMid);
             miniblog.OriginalMContent = oriMiniblog.OriginalContent;
             MiniBlogs.CreateQuoteMiniBlog(miniblog);
             return(miniblog.ID);
         }
         else
         {
             return(-1);
         }
     }
     catch (Exception ex)
     {
         Logs.WriteErrorLog(ex);
         return(-1);
     }
 }
Ejemplo n.º 2
0
 public static long CreateOriginalMiniBlog(User user, string content, string picID, int fromID)
 {
     try
     {
         string   originalCon = content;
         string   realCon     = TransformToBBCode(content);
         string   atStr       = GetAtStr(realCon);
         MiniBlog miniblog    = new MiniBlog();
         string   idCode      = "";
         miniblog.ID     = Data.DbGenerateID.GenerateID(ref idCode);
         miniblog.IDCode = idCode;
         Users.AtMeTip(atStr, user.ID, 1);
         miniblog.ReferUID        = atStr;
         miniblog.OriginalContent = originalCon;
         miniblog.RealContent     = realCon;
         miniblog.PicID           = Convert.ToInt64(picID);
         miniblog.UID             = user.ID;
         miniblog.IsOriginal      = 1;
         miniblog.IsHaveVote      = new Regex(@"\[url\sc='[0-9a-zA-Z]+'\st='vote'\sm='[0-9\-]+'\so='[~#\+\\\'\?\,\=\:/a-zA-Z0-9\.&%\$\-_]+'\]").IsMatch(realCon) ? 1 : 0;
         miniblog.IsHaveVideo     = new Regex(@"\[url\sc='[0-9a-zA-Z]+'\st='video'\sm='[0-9\-]+'\so='[~#\+\\\'\?\,\=\:/a-zA-Z0-9\.&%\$\-_]+'\]").IsMatch(realCon) ? 1 : 0;
         miniblog.IsHavePic       = picID == "-1" ? 0 : 1;
         miniblog.IsHaveMusic     = new Regex(@"\[url\sc='[0-9a-zA-Z]+'\st='music'\sm='[0-9\-]+'\so='[~#\+\\\'\?\,\=\:/a-zA-Z0-9\.&%\$\-_]+'\]").IsMatch(realCon) ? 1 : 0;
         miniblog.IsHaveLink      = new Regex(@"\[url\sc='[0-9a-zA-Z]+'\st='normal'\sm='[0-9\-]+'\so='[~#\+\\\'\?\,\=\:/a-zA-Z0-9\.&%\$\-_]+'\]").IsMatch(realCon) ? 1 : 0;
         miniblog.FromID          = fromID;
         Froms.UpdateFromForFromCount(fromID);
         miniblog.MediaContent     = GetMediaContent(picID, realCon);
         miniblog.OriginalMID      = -1;
         miniblog.QuoteMID         = -1;
         miniblog.OriginalMContent = "";
         MiniBlogs.CreateMiniBlog(miniblog);
         return(miniblog.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteErrorLog(ex);
         return(-1);
     }
 }