예제 #1
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);
                    }
                }
            }
        }
예제 #2
0
        public void FeedTemplateList(string appID
            , GlobalTemplateMembers.CannotDoTemplate canNotDo
            , FeedTemplateHeadFootItemTemplate head
            , FeedTemplateHeadFootItemTemplate foot
            , FeedTemplateListItemTemplate item)
        {
            Guid currentAppID;
            try
            {
                currentAppID = new Guid(appID);
            }
            catch
            {
                currentAppID = new BasicApp().AppID;
                //throw new Exception("非法的AppID");
            }


            FeedTemplateCollection feedTemplates;
            using (ErrorScope errorScope = new ErrorScope())
            {
                feedTemplates = FeedBO.Instance.GetFeedTemplates(currentAppID);
                errorScope.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                {
                    canNotDo(error.Message);
                    return;
                });
            }

            int totalCount = feedTemplates.Count;

            AppBase currentApp = AppManager.GetApp(currentAppID);

            head(totalCount > 0, totalCount, currentApp);

            int i = 0;

            foreach (FeedTemplate feedTemplate in feedTemplates)
            {
                item(i++, feedTemplate, currentApp);
            }

            foot(totalCount > 0, totalCount, currentApp);
        }