Ejemplo n.º 1
0
 protected void DeleteDraftButton_Click(object sender, EventArgs e)
 {
     if (CurrentUser.UserType == (byte)MemberTypeType.Admin)
     {
         using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
         {
             var posts = (from t in dc.Posts where t.Status == (byte)PostStatusType.Draft && (t.CreatedBy == CurrentUser.ID || CurrentUser.UserType == (byte)MemberTypeType.Admin) select t);
             foreach (Post p in posts)
             {
                 if (p != null && p.Status == (byte)PostStatusType.Draft)
                 {
                     try
                     {
                         System.IO.File.Delete(Server.MapPath(string.Format("{1}/articlexml-{0}.txt", p.ID, Utility.CustomPageFolder)));
                         dc.Posts.DeleteOnSubmit(p);
                         dc.SubmitChanges();
                     }
                     catch (Exception iex)
                     {
                         Trace.Write("Unable to delete article file.");
                         Trace.Write(iex.Message);
                         Trace.Write(iex.StackTrace);
                         Trace.Write(iex.Source);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public static void RecordPulse(Guid vid, long pageid)
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext())
     {
         dc.ExecuteCommand("UPDATE dbo.PageVisit Set LastHeartBeat = GETUTCDATE() WHERE ID = " + pageid);
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Mode == "edit")
        {
            //redirect if user is not admin or dont own the article
            using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
            {
                Post p = (from t in dc.Posts where t.ID == ID && (t.CreatedBy == CurrentUser.ID || CurrentUser.UserType == (byte)MemberTypeType.Admin) select t).SingleOrDefault();
                if (p == null)
                {
                    Response.Redirect("default.aspx");
                }
            }

            HeadingLit.Text = "Edit Article";
            //PopulateArticle();
        }

        if (!Page.IsCallback && !Page.IsPostBack)
        {
            TemplateDropDown.Items.Clear();
            TemplateDropDown.Items.Add(new ListItem("-- Select --", ""));
            using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
            {
                foreach (CustomDataSource item in dc.CustomDataSources)
                {
                    TemplateDropDown.Items.Add(new ListItem(item.Name, item.Name));
                }
            }
            if (Mode == "edit")
            {
                PopulateForm();
            }
        }
    }
Ejemplo n.º 4
0
 public static bool UpdateMessage(EmailMessage em)
 {
     try
     {
         using (RockyingDataClassesDataContext db = new RockyingDataClassesDataContext(Utility.ConnectionString))
         {
             EmailMessage item = (from u in db.EmailMessages where u.ID == em.ID select u).SingleOrDefault();
             item.CreateDate  = em.CreateDate;
             item.EmailGroup  = em.EmailGroup;
             item.EmailType   = em.EmailType;
             item.FromAddress = em.FromAddress;
             item.IsRead      = em.IsRead;
             item.IsSent      = em.IsSent;
             item.Message     = em.Message;
             item.SentDate    = em.SentDate;
             item.Subject     = em.Subject;
             item.ToAddress   = em.ToAddress;
             item.ReadDate    = em.ReadDate;
             db.SubmitChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         HttpContext.Current.Trace.Write("Unable to save EmailMessage object to database.");
         HttpContext.Current.Trace.Write(ex.Message);
         HttpContext.Current.Trace.Write(ex.StackTrace);
         return(false);
     }
 }
Ejemplo n.º 5
0
 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "TopStory")
     {
         try
         {
             using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
             {
                 TopStory ts = new TopStory();
                 ts.CreatedBy   = CurrentUser.ID;
                 ts.DateCreated = DateTime.UtcNow;
                 ts.PostId      = long.Parse(e.CommandArgument.ToString());
                 dc.TopStories.InsertOnSubmit(ts);
                 dc.SubmitChanges();
                 Response.Redirect("topstory.aspx");
             }
         }
         catch (Exception ex)
         {
             message1.Text     = string.Format("Unable to set top story. Error - {0}", ex.Message);
             message1.Visible  = true;
             message1.Indicate = AlertType.Error;
             Trace.Write("Unable to set top story.");
             Trace.Write(ex.Message);
             Trace.Write(ex.StackTrace);
         }
     }
     else if (e.CommandName == "DeleteCommand")
     {
     }
 }
Ejemplo n.º 6
0
 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         if (Mode == "edit")
         {
             Post p = (from t in dc.Posts where t.ID != ID && t.URL == URLTextBox.Text.Trim() select t).SingleOrDefault();
             if (p != null)
             {
                 args.IsValid = false;
             }
             else
             {
                 args.IsValid = true;
             }
         }
         else
         {
             Post p = (from t in dc.Posts where t.URL == URLTextBox.Text.Trim() select t).SingleOrDefault();
             if (p != null)
             {
                 args.IsValid = false;
             }
             else
             {
                 args.IsValid = true;
             }
         }
     }
 }
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        Page.Validate("CategoryGrp");
        if (!Page.IsValid)
        {
            return;
        }

        try
        {
            using (RockyingDataClassesDataContext db = new RockyingDataClassesDataContext(Utility.ConnectionString))
            {
                WebsiteSetting rs = (from u in db.WebsiteSettings where u.KeyName == "NewsletterDesign" select u).SingleOrDefault();
                rs.KeyValue = KeyValueTextBox.Text.Trim();
                db.SubmitChanges();
                CacheManager.Remove("NewsletterDesign");
                message1.Text     = "Saved Successfuly";
                message1.Visible  = true;
                message1.Indicate = AlertType.Success;
            }
        }
        catch (Exception ex)
        {
            message1.Text     = "Unable to save NewsletterDesign";
            message1.Visible  = true;
            message1.Indicate = AlertType.Error;
            Trace.Write("Unable to save NewsletterDesign.");
            Trace.Write(ex.Message);
            Trace.Write(ex.StackTrace);
        }
    }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Mode == "edit")
        {
            //redirect if user is not admin or dont own the article
            using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
            {
                Post p = (from t in dc.Posts where t.ID == ID && (t.CreatedBy == CurrentUser.ID || CurrentUser.UserType == (byte)MemberTypeType.Admin) select t).SingleOrDefault();
                if (p == null)
                {
                    Response.Redirect("default.aspx");
                }
            }

            HeadingLit.Text = "Edit";
            //PopulateArticle();
        }

        if (!Page.IsCallback && !Page.IsPostBack)
        {
            if (Mode == "edit")
            {
                PopulateForm();
            }
        }
    }
Ejemplo n.º 9
0
    protected void DeleteButton_Click(object sender, EventArgs e)
    {
        using (RockyingDataClassesDataContext db = new RockyingDataClassesDataContext(Utility.ConnectionString))
        {
            string query = "Delete FROM [EmailMessage] WHERE 1=1 ";

            if (TypeDropDown.SelectedValue != "")
            {
                query = string.Format("{0} AND([EmailType] = {1})", query, TypeDropDown.SelectedValue);
            }

            if (GroupDropDown.SelectedValue != "")
            {
                query = string.Format("{0} AND(EmailGroup = '{1}')", query, GroupDropDown.SelectedValue);
            }

            if (SentDropDown.SelectedValue != "")
            {
                query = string.Format("{0} AND([IsSent] = {1})", query, SentDropDown.SelectedValue);
            }

            if (ReadDropDown.SelectedValue != "")
            {
                query = string.Format("{0} AND([IsRead] = {1})", query, ReadDropDown.SelectedValue);
            }

            //query = string.Format("{0} ORDER BY CreateDate desc ", query);

            db.ExecuteCommand(query, new object[] { });
            Bind(0);
        }
    }
Ejemplo n.º 10
0
 public CustomDataSource GetByName(string name)
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         return((from t in dc.CustomDataSources where t.Name == name select t).SingleOrDefault <CustomDataSource>());
     }
 }
Ejemplo n.º 11
0
 public CustomDataSource GetById(int id)
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         return((from t in dc.CustomDataSources where t.ID == id select t).SingleOrDefault <CustomDataSource>());
     }
 }
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        Page.Validate("PageGrp");
        if (!Page.IsValid)
        {
            return;
        }

        using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
        {
            try
            {
                cp.Status     = (PostStatusType)Enum.Parse(typeof(PostStatusType), StatusDropDown.SelectedValue);
                cp.Body       = BodyTextBox.Text.Trim();
                cp.Name       = Utility.Slugify(NameTextBox.Text.Trim());
                cp.Title      = TitleTextBox.Text.Trim();
                cp.Head       = HeadTextBox.Text.Trim();
                cp.NoTemplate = NoTemplateCheckBox.Checked;
                cp.PageMeta   = PageMetaTextBox.Text.Trim();
                if (Mode == "edit")
                {
                    cp.DateModified   = DateTime.Now;
                    cp.ModifiedByName = CurrentUser.MemberName;
                    cp.ModifiedBy     = CurrentUser.ID;

                    CustomPage p = (from u in dc.CustomPages where u.ID == ID select u).SingleOrDefault();
                    p.DateModified = cp.DateModified;
                    p.ModifiedBy   = cp.ModifiedBy;
                    p.Name         = cp.Name;
                    p.Status       = (byte)cp.Status;
                    dc.SubmitChanges();
                }
                else
                {
                    cp.DateCreated   = DateTime.Now;
                    cp.CreatedByName = CurrentUser.MemberName;
                    cp.CreatedBy     = CurrentUser.ID;

                    CustomPage p = new CustomPage();
                    p.DateCreated = cp.DateCreated;
                    p.CreatedBy   = cp.CreatedBy;
                    p.Name        = cp.Name;
                    p.Status      = (byte)cp.Status;
                    dc.CustomPages.InsertOnSubmit(p);
                    dc.SubmitChanges();
                    cp.ID = p.ID;
                }

                string str = Utility.Serialize <CPage>(cp);
                System.IO.File.WriteAllText(Server.MapPath(string.Format("{1}/cpagexml-{0}.txt", cp.ID, Utility.CustomPageFolder)), str);
                Response.Redirect("custompagelist.aspx");
            }
            catch (Exception ex)
            {
                Trace.Write("Unable to save page details.");
                Trace.Write(ex.Message);
                Trace.Write(ex.StackTrace);
            }
        }
    }
Ejemplo n.º 13
0
    private void PopulateArticle()
    {
        using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
        {
            try
            {
                Post p = (from t in dc.Posts where t.ID == ID select t).SingleOrDefault();
                if (p != null)
                {
                    a = Utility.Deserialize <Article>(p.Article); //Utility.Deserialize<Article>(System.IO.File.ReadAllText(Server.MapPath(string.Format("{1}/articlexml-{0}.txt", ID, Utility.ArticleFolder))));
                    if (string.IsNullOrEmpty(a.MetaTitle))
                    {
                        a.MetaTitle = a.Title;
                    }


                    a.URL = p.URL;
                }
            }
            catch (Exception ex)
            {
                a = new Article();
                Trace.Write("Unable to read xml file of article.");
                Trace.Write(ex.Message);
                Trace.Write(ex.StackTrace);
                Post p = (from t in dc.Posts where t.ID == ID select t).SingleOrDefault();
                if (p != null)
                {
                    a.Category     = p.Category;
                    a.CreatedBy    = p.CreatedBy;
                    a.DateCreated  = p.DateCreated;
                    a.DateModified = p.DateModified;
                    a.Description  = p.Description;
                    a.ID           = p.ID;
                    a.ModifiedBy   = p.ModifiedBy;
                    a.Status       = (PostStatusType)Enum.Parse(typeof(PostStatusType), p.Status.ToString());
                    a.Tag          = p.Tag;
                    a.Title        = p.Title;
                    a.WriterEmail  = p.WriterEmail;
                    a.WriterName   = p.WriterName;
                    a.Viewed       = p.Viewed;
                    a.URL          = p.URL;
                    try
                    {
                        a.Text = System.IO.File.ReadAllText(Server.MapPath(string.Format("{1}/article-{0}.txt", p.ID, Utility.ArticleFolder)));
                    }
                    catch (Exception ex2)
                    {
                        Trace.Write(ex2.Message);
                        Trace.Write(ex2.StackTrace);
                    }
                }
                else
                {
                    Response.Redirect("default.aspx");
                }
            }
        }
    }
Ejemplo n.º 14
0
 public static bool ChangePassword(long id, string password)
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         Member m = (from u in dc.Members where u.ID == id select u).SingleOrDefault();
         m.Password = password;
         dc.SubmitChanges();
         return(true);
     }
 }
Ejemplo n.º 15
0
 public bool Delete(int id)
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         CustomDataSource item = (from t in dc.CustomDataSources where t.ID == id select t).SingleOrDefault <CustomDataSource>();
         dc.CustomDataSources.DeleteOnSubmit(item);
         dc.SubmitChanges();
         return(true);
     }
 }
Ejemplo n.º 16
0
 public static int GetArticleCount()
 {
     if (CacheManager.Get <int?>("ArticleCount") == null)
     {
         using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
         {
             CacheManager.Add("ArticleCount", (from t in dc.Posts where t.Status != (byte)PostStatusType.Inactive select t).Count(), DateTime.Now.AddMinutes(5));
         }
     }
     return(CacheManager.Get <int?>("ArticleCount").Value);
 }
Ejemplo n.º 17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         var query = from t in dc.Categories
                     where t.Posts.Count() > 0 && t.Status == (byte)GeneralStatusType.Active
                     select t;
         CategoryList = new List <Category>();
         CategoryList.AddRange(query);
     }
 }
Ejemplo n.º 18
0
 public static int GetDraftCommentCount()
 {
     if (CacheManager.Get <int?>("DraftCommentCount") == null)
     {
         using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
         {
             CacheManager.Add("DraftCommentCount", (from t in dc.PageComments where t.Status == (byte)PostStatusType.Draft select t).Count(), DateTime.Now.AddMinutes(1));
         }
     }
     return(CacheManager.Get <int?>("DraftCommentCount").Value);
 }
Ejemplo n.º 19
0
 public static int GetMemberCount()
 {
     if (CacheManager.Get <int?>("MemberCount") == null)
     {
         using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
         {
             CacheManager.Add("MemberCount", (from t in dc.Members where t.Status == (byte)GeneralStatusType.Active select t).Count(), DateTime.Now.AddMinutes(50));
         }
     }
     return(CacheManager.Get <int?>("MemberCount").Value);
 }
Ejemplo n.º 20
0
 public static List <Category> CategoryList()
 {
     if (CacheManager.Category.Count == 0)
     {
         using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
         {
             CacheManager.Category = (from t in dc.Categories select t).ToList <Category>();
         }
     }
     return(CacheManager.Category);
 }
Ejemplo n.º 21
0
 protected void SendActivationEmailButton_Click(object sender, EventArgs e)
 {
     using (RockyingDataClassesDataContext db = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         Member m = (from u in db.Members where u.ID == ID select u).SingleOrDefault();
         if (m != null)
         {
             EmailManager.SendActivationEmail(m.Email, m.MemberName, m.Password);
         }
     }
 }
Ejemplo n.º 22
0
 private void PopulateParent()
 {
     ParentDropDown.Items.Clear();
     ParentDropDown.Items.Add(new ListItem("--select--", ""));
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         var items = from u in dc.Categories where u.Status != (byte)GeneralStatusType.Deleted select u;
         foreach (Category c in items)
         {
             ParentDropDown.Items.Add(new ListItem(c.Name, c.ID.ToString()));
         }
     }
 }
Ejemplo n.º 23
0
 public bool Update(int id, string name, string query, string template, long memberid)
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         CustomDataSource item = (from t in dc.CustomDataSources where t.ID == id select t).SingleOrDefault <CustomDataSource>();
         item.Name         = name;
         item.Query        = query;
         item.HtmlTemplate = template;
         item.ModifiedBy   = memberid;
         item.DateModified = DateTime.Now;
         dc.SubmitChanges();
         return(true);
     }
 }
Ejemplo n.º 24
0
 public static List <Member> GetMemberList()
 {
     try
     {
         using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
         {
             return((from u in dc.Members where u.Status != (byte)GeneralStatusType.Deleted orderby u.Createdate descending select u).ToList <Member>());
         }
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 25
0
 public static Member GetUser(int id)
 {
     try
     {
         using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
         {
             return((from t in dc.Members where t.ID == id select t).SingleOrDefault());
         }
     }
     catch
     {
         throw;
     }
 }
    protected void ArticleButton_Click(object sender, EventArgs e)
    {
        try
        {
            StringBuilder builder = new StringBuilder();

            using (RockyingDataClassesDataContext db = new RockyingDataClassesDataContext(Utility.ConnectionString))
            {
                builder.Append("<ul style='list-style:none;'>\r\n");
                foreach (ListItem item in ArticleList.Items)
                {
                    if (item.Selected)
                    {
                        Post p = (from u in db.Posts where u.ID == int.Parse(item.Value) select u).SingleOrDefault();
                        if (p != null)
                        {
                            builder.Append("<li style='text-align:center;border-bottom:1px solid Gainsboro;margin-bottom:5px;'>");
                            builder.Append(Environment.NewLine);
                            builder.Append(string.Format("<a href='{0}/a/{1}?ref=newsletter'>", Utility.SiteURL, p.URL));
                            if (p.OGImage.StartsWith("//"))
                            {
                                p.OGImage = "https:" + p.OGImage;
                            }
                            builder.Append(string.Format("<img src='{0}' style='max-width:600px;max-height:250px;width:auto;border:0px;' alt=''/>", p.OGImage));
                            builder.Append("</a>");
                            builder.Append(Environment.NewLine);
                            builder.Append(string.Format("<a href='{1}/a/{2}?ref=newsletter' style='color:#000;'><h3>{0}</h3></a>\r\n", p.Title, Utility.SiteURL, p.URL, p.Title));
                            builder.Append(Environment.NewLine);
                            builder.Append(string.Format("<p>{0} story written by {1}</p>", p.Category1.Name, p.WriterName));
                            builder.Append(Environment.NewLine);
                            builder.Append(string.Format("<p>{0}</p>", p.OGDescription));
                            builder.Append("</li>");
                            //builder.Append("\t<li><hr/></li>\r\n");
                        }
                    }
                }
                builder.Append("</ul>\r\n");
            }
            KeyValueTextBox.Text = builder.ToString();
        }
        catch (Exception ex)
        {
            message1.Text     = "Unable to select article";
            message1.Visible  = true;
            message1.Indicate = AlertType.Error;
            Trace.Write("Unable to select article");
            Trace.Write(ex.Message);
            Trace.Write(ex.StackTrace);
        }
    }
Ejemplo n.º 27
0
 public static Member GetUser(string username)
 {
     try
     {
         using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
         {
             return((from t in dc.Members where (t.Email == username || t.UserName == username) && t.Status != (byte)GeneralStatusType.Deleted select t).SingleOrDefault());
         }
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 28
0
 public bool Add(string name, string query, string template, long memberid)
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext(Utility.ConnectionString))
     {
         CustomDataSource item = new CustomDataSource();
         item.Name         = name;
         item.Query        = query;
         item.HtmlTemplate = template;
         item.DateCreated  = DateTime.Now;
         item.CreatedBy    = memberid;
         dc.CustomDataSources.InsertOnSubmit(item);
         dc.SubmitChanges();
         return(true);
     }
 }
Ejemplo n.º 29
0
 private void GetRating()
 {
     using (RockyingDataClassesDataContext dc = new RockyingDataClassesDataContext())
     {
         Post p = dc.Posts.FirstOrDefault(t => t.ID == PPM.Item.ID);
         if (p != null)
         {
             var ratingcount = dc.StarRatings.Count(t => t.PostID == p.ID);
             if (ratingcount > 0)
             {
                 var totalrating = dc.StarRatings.Where(t => t.PostID == p.ID).Sum(t => t.Stars);
                 PostRating = totalrating / ratingcount;
             }
         }
     }
 }
Ejemplo n.º 30
0
    protected void btnDeleteRecords_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in MemberGridView.Rows)
        {
            if ((row.FindControl("chkSelect") as CheckBox).Checked)
            {
                int Emp_ID = Convert.ToInt32(MemberGridView.DataKeys[row.RowIndex].Value);
                using (RockyingDataClassesDataContext db = new RockyingDataClassesDataContext(Utility.ConnectionString))
                {
                    db.ExecuteCommand("DELETE FROM Member WHERE ID = " + Emp_ID, new object[] { });
                }
            }
        }

        Bind(0);
    }