private void downloadMenu_Click(object sender, System.EventArgs e)
        {
            ResolveFileCallback old = BlogXData.Resolver;

            BlogXData.Resolver = new ResolveFileCallback(ResolvePathToCache);

            Debug.WriteLine("Begin GetDaysWithEntries");
            DateTime[] dates = browse.GetDaysWithEntries();
            Debug.WriteLine("End GetDaysWithEntries");

            foreach (DateTime date in dates)
            {
                Debug.WriteLine("Begin GetDayEntry");
                DayEntry dayEntry = browse.GetDayEntry(date);
                Debug.WriteLine("End GetDayEntry");
                dayEntry.Save();

                Debug.WriteLine("Begin GetDayExtra");
                DayExtra dayExtra = browse.GetDayExtra(date);
                Debug.WriteLine("End GetDayExtra");
                if (dayExtra.Comments.Count > 0)
                {
                    dayExtra.Save();
                }
            }

            BlogXData.Resolver = old;
        }
Exemplo n.º 2
0
        private void save_Click(object sender, System.EventArgs e)
        {
            if (SiteSecurity.IsInRole("admin"))
            {
                BlogXData data = new BlogXData();

                bool added = false;

                Entry entry = new Entry();
                entry.Initialize();
                entry.Title       = entryTitle.Text;
                entry.Description = entryAbstract.Text;
                entry.Content     = entryContent.Text;
                entry.Categories  = entryCategories.Text;

                foreach (DayEntry day in data.Days)
                {
                    if (day.Date == entry.Created.Date)
                    {
                        added = true;
                        day.Load();
                        day.Entries.Add(entry);
                        day.Save();
                        data.IncrementEntryChange();
                        BlogXUtils.PingWeblogsCom();
                        break;
                    }
                }
                if (!added)
                {
                    DayEntry newDay = new DayEntry();
                    newDay.Date = entry.Created.Date;
                    newDay.Entries.Add(entry);
                    newDay.Save();

                    data.IncrementEntryChange();
                    BlogXUtils.PingWeblogsCom();
                }

                entryTitle.Text      = "";
                entryAbstract.Text   = "";
                entryContent.Text    = "";
                entryCategories.Text = "";

                Response.Redirect("default.aspx", false);
            }
        }
Exemplo n.º 3
0
        public string CreateEntry(Entry entry, string username, string password)
        {
            if (SiteSecurity.Login(username, password).Role != "admin")
            {
                throw new Exception("Invalid Password");
            }
            bool added = false;

            // ensure that the entryId was filled in
            //
            if (entry.EntryId == null || entry.EntryId.Length == 0)
            {
                entry.EntryId = Guid.NewGuid().ToString();
            }

            foreach (DayEntry day in data.Days)
            {
                if (day.Date == entry.Created.Date)
                {
                    added = true;
                    day.Load();
                    day.Entries.Add(entry);
                    day.Save();
                    data.IncrementEntryChange();
                    BlogXUtils.PingWeblogsCom();
                    break;
                }
            }
            if (!added)
            {
                DayEntry newDay = new DayEntry();
                newDay.Date = entry.Created.Date;
                newDay.Entries.Add(entry);
                newDay.Save();

                data.IncrementEntryChange();
                BlogXUtils.PingWeblogsCom();
            }

            return(entry.EntryId);
        }