コード例 #1
0
ファイル: SupportArticle.cs プロジェクト: Cycli/Cycli
        public static SupportArticle Load(string action)
        {
            SupportArticle s = new SupportArticle();
            // Query checks that race is in the right mode, the invitee is not already invited and that the invite limit has not been exceeded
            SQLiteDatabase db = new SQLiteDatabase();
            try
            {

                // This query checks that the user has not already been invited
                string sql = "select a._action, a.title, a.body, a.footerLink, a.updated " +
                    "from cycli_content a " +
                    "where lower(a._action) = lower(@a) ";
                DataTable dtAction = db.GetDataTable(sql, "@a", action);

                if (dtAction.Rows.Count > 0)
                {
                    s = new SupportArticle
                               {
                                   Action = dtAction.Rows[0].Field<string>("_action"),
                                   Title = dtAction.Rows[0].Field<string>("title"),
                                   Body = dtAction.Rows[0].Field<string>("body"),
                                   FooterLink = bool.Parse(dtAction.Rows[0].Field<string>("footerLink")),
                                   Updated = DbTime.FromDbSecs(dtAction.Rows[0].Field<long>("updated"))
                               };

                    sql = "select b._action, b.title " +
                        "from cycli_content_links a, cycli_content b " +
                        "where lower(a.sourceaction) = lower(@a) " +
                        "and a.destinationaction = b._action";
                    DataTable dtLink = db.GetDataTable(sql, "@a", action);
                    if (dtLink.Rows.Count > 0)
                    {
                        s.Links = dtLink.AsEnumerable().ToDictionary(key => key.Field<string>("_action"), value => value.Field<string>("title"));
                    }
                    string path = VirtualPathUtility.ToAbsolute("~/media/");
                    // Find images, movies etc
                    s.Body = _ImageRegex.Replace(s.Body, delegate(Match m)
                    {
                        string filename = path + m.Groups["src"].Value;
                        return "<img src='"+filename+"' alt='"+m.Groups["alt"].Value+"' />";
                    });

                }
            }
            finally
            {
                db.Close();
            }

            return s;
        }
コード例 #2
0
ファイル: SupportArticle.cs プロジェクト: Cycli/Cycli
        public static SupportArticle[] LoadAll()
        {
            SupportArticle[] s = new SupportArticle[] { };
            // Query checks that race is in the right mode, the invitee is not already invited and that the invite limit has not been exceeded
            SQLiteDatabase db = new SQLiteDatabase();
            try
            {
                // This query checks that the user has not already been invited
                string sql = "select _action, title, body, footerLink, updated from cycli_content order by title";
                DataTable dtContent = db.GetDataTable(sql);

                if (dtContent.Rows.Count > 0)
                {
                    s = dtContent.AsEnumerable().Select(dr => new SupportArticle
                    {
                        Action = dr.Field<string>("_action"),
                        Title = dr.Field<string>("title"),
                        Body = (dr.Field<string>("body").Length > 80 ? dr.Field<string>("body").Substring(0, 77) + "..." : dr.Field<string>("body")),
                        FooterLink = bool.Parse(dr.Field<string>("footerLink")),
                        Updated = DbTime.FromDbSecs(dr.Field<long>("updated")),
                        Links = new Dictionary<string, string>()
                    }).ToArray();
                }
            }
            finally
            {
                db.Close();
            }
            return s;
        }
コード例 #3
0
ファイル: SupportArticle.cs プロジェクト: Cycli/Cycli
 public static SupportArticle New()
 {
     SupportArticle s = new SupportArticle()
     {
         Action = "NewSupportArticle",
         Title = "New Support Article",
         Body = "<p>Add your content here</p>",
         FooterLink = false,
         Updated = DateTime.UtcNow
     };
     return s;
 }
コード例 #4
0
ファイル: DataHub.cs プロジェクト: Cycli/Cycli
 public void SaveSupportArticle(SupportArticle sa)
 {
     sa.Save();
 }