Esempio n. 1
0
        public override void SetTemplates(FeedTemplateCollection feedTemplates)
        {
            using (SqlQuery query = new SqlQuery(QueryMode.Prepare))
            {
                query.CommandText = @"
IF EXISTS(SELECT * FROM [bx_FeedTemplates] WHERE [AppID]=@AppID AND [ActionType]=@ActionType)
	UPDATE [bx_FeedTemplates] SET
                 [Title]=@Title 
                ,[IconUrl]=@IconUrl
                ,[Description]=@Description 
                WHERE [AppID]=@AppID AND [ActionType]=@ActionType;
ELSE
	INSERT [bx_FeedTemplates] (
                 [AppID]

                ,[ActionType]

                ,[Title]
                ,[IconUrl]
                ,[Description]
                ) VALUES(
                  @AppID

                , @ActionType

                , @Title
                , @IconUrl
                , @Description
                );
";

                foreach (FeedTemplate feedTemplate in feedTemplates)
                {
                    query.CreateParameter<Guid>("@AppID", feedTemplate.AppID, SqlDbType.UniqueIdentifier);

                    query.CreateParameter<int>("@ActionType", feedTemplate.ActionType, SqlDbType.Int);

                    query.CreateParameter<string>("@Title", feedTemplate.Title, SqlDbType.NVarChar, 900);
                    query.CreateParameter<string>("@IconUrl", feedTemplate.IconSrc, SqlDbType.NVarChar, 200);
                    query.CreateParameter<string>("@Description", feedTemplate.Description, SqlDbType.NVarChar, 2900);

                    query.ExecuteNonQuery();
                }

                //query.Submit();
            }
        }
        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);
                    }
                }
            }
        }
Esempio n. 3
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);
                    }
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 设置动态模板,存在就更新,不存在就插入
 /// </summary>
 /// <param name="feedTemplete"></param>
 public abstract void SetTemplates(FeedTemplateCollection feedTemplates);