예제 #1
0
        protected string GetAppActionIconUrl(Guid appID, int actionType)
        {
            FeedTemplate template = FeedBO.Instance.GetFeedTemplate(appID, actionType);

            if (template != null)
            {
                return(template.IconUrl);
            }

            AppBase app = AppManager.GetApp(appID);

            if (app == null)
            {
                return(string.Empty);
            }

            AppAction appAction = app.AppActions.GetValue(actionType);

            if (appAction == null)
            {
                return(string.Empty);
            }

            return(appAction.IconUrl);
        }
예제 #2
0
        static void GenerateFeed(GeneratorContext context)
        {
            string feedDir = Path.Combine(context.Site.WebPath, "feed");

            Directory.CreateDirectory(feedDir);
            using (TextWriter w = new StreamWriter(Path.Combine(feedDir, ".htaccess"), false, Encoding.ASCII))
            {
                w.WriteLine("DirectoryIndex index.atom");
                w.WriteLine("ForceType application/atom+xml");
                w.WriteLine("AddType application/atom+xml .atom");
            }
            var feedTemplate  = new FeedTemplate(context);
            var entryTemplate = new FeedEntryTemplate(context);

            //At least 5 posts and one month
            Html     entries = new Html();
            int      posts   = 0;
            DateTime expire  = DateTime.Now.AddMonths(-1);

            foreach (Post p in context.Site.Posts)
            {
                if (posts > 5 && p.Date < expire && p.LastModified < expire)
                {
                    continue;
                }

                entries += entryTemplate.Generate(context.Site, p);

                posts += 1;
            }
            feedTemplate.Generate(entries, Path.Combine(feedDir, "index.atom"));
        }
예제 #3
0
        private void LoadFeedTemplate(Guid appID, string id, FeedTemplate feedTemplate)
        {
            int actionType = _Request.Get <int>("FeedTemplate.ActionType." + id, Method.Post, 0);

            feedTemplate.ActionType = actionType;

            feedTemplate.Title = _Request.Get("FeedTemplate.Title." + id, Method.Post, string.Empty, false);

            feedTemplate.IconSrc = _Request.Get("FeedTemplate.IconSrc." + id, Method.Post, string.Empty);

            feedTemplate.Description = _Request.Get("FeedTemplate.Description." + id, Method.Post, string.Empty, false);
        }
예제 #4
0
        private void SaveFeedTemplates()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("FeedTemplate.IconSrc", "FeedTemplate.Title", "FeedTemplate.Description");

            Guid appID;
            string appIDString = _Request.Get("appID", Method.Get);
            if (appIDString == null)
                appID = new BasicApp().AppID;
            else
            {
                try
                {
                    appID = new Guid(appIDString);
                }
                catch
                {
                    msgDisplay.AddError(new InvalidParamError("appID").Message);
                    return;
                }
            }

            string[] ids = GetFeedTemplateIDs();
            if (ids != null)
            {
                FeedTemplateCollection feedTemplates = new FeedTemplateCollection();
                Dictionary<int, int> lines = new Dictionary<int, int>();
                int i = 0;
                foreach (string id in ids)
                {
                    //string changedKey = "FeedTemplate.Changed." + id;

                    //string changed = _Request.Get(changedKey, Method.Post, "0");

                    ////没改变就不保存
                    //if (changed == "0")
                    //    continue;




                    FeedTemplate feedTemplate = new FeedTemplate();
                    feedTemplate.AppID = appID;

                    LoadFeedTemplate(appID, id, feedTemplate);


                    feedTemplates.Add(feedTemplate);
                    lines.Add(i, int.Parse(id));
                    i++;
                }

                if (feedTemplates.Count > 0)
                {
                    try
                    {
                        using (new ErrorScope())
                        {
                            bool success = FeedBO.Instance.SetTemplates(MyUserID, appID, feedTemplates);
                            if (!success)
                            {
                                CatchError<ErrorInfo>(delegate(ErrorInfo error)
                                {
                                    msgDisplay.AddError(error.TatgetName, lines[error.TargetLine], error.Message);
                                });
                            }
                            else
                                _Request.Clear(Method.Post);
                        }
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddError(ex.Message);
                    }
                }
            }
        }
예제 #5
0
        private void LoadFeedTemplate(Guid appID, string id, FeedTemplate feedTemplate)
        {

            int actionType = _Request.Get<int>("FeedTemplate.ActionType." + id, Method.Post, 0);

            feedTemplate.ActionType = actionType;

            feedTemplate.Title = _Request.Get("FeedTemplate.Title." + id, Method.Post, string.Empty, false);

            feedTemplate.IconSrc = _Request.Get("FeedTemplate.IconSrc." + id, Method.Post, string.Empty);

            feedTemplate.Description = _Request.Get("FeedTemplate.Description." + id, Method.Post, string.Empty, false);

        }
예제 #6
0
        private void SaveFeedTemplates()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("FeedTemplate.IconSrc", "FeedTemplate.Title", "FeedTemplate.Description");

            Guid   appID;
            string appIDString = _Request.Get("appID", Method.Get);

            if (appIDString == null)
            {
                appID = new BasicApp().AppID;
            }
            else
            {
                try
                {
                    appID = new Guid(appIDString);
                }
                catch
                {
                    msgDisplay.AddError(new InvalidParamError("appID").Message);
                    return;
                }
            }

            string[] ids = GetFeedTemplateIDs();
            if (ids != null)
            {
                FeedTemplateCollection feedTemplates = new FeedTemplateCollection();
                Dictionary <int, int>  lines         = new Dictionary <int, int>();
                int i = 0;
                foreach (string id in ids)
                {
                    //string changedKey = "FeedTemplate.Changed." + id;

                    //string changed = _Request.Get(changedKey, Method.Post, "0");

                    ////没改变就不保存
                    //if (changed == "0")
                    //    continue;



                    FeedTemplate feedTemplate = new FeedTemplate();
                    feedTemplate.AppID = appID;

                    LoadFeedTemplate(appID, id, feedTemplate);


                    feedTemplates.Add(feedTemplate);
                    lines.Add(i, int.Parse(id));
                    i++;
                }

                if (feedTemplates.Count > 0)
                {
                    try
                    {
                        using (new ErrorScope())
                        {
                            bool success = FeedBO.Instance.SetTemplates(MyUserID, appID, feedTemplates);
                            if (!success)
                            {
                                CatchError <ErrorInfo>(delegate(ErrorInfo error)
                                {
                                    msgDisplay.AddError(error.TatgetName, lines[error.TargetLine], error.Message);
                                });
                            }
                            else
                            {
                                _Request.Clear(Method.Post);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddError(ex.Message);
                    }
                }
            }
        }