Esempio n. 1
0
        public bool EditModel(string data, int id, ActivityPageConfig model)
        {
            if (string.IsNullOrWhiteSpace(data) || id <= 0 || model == null)
            {
                return(false);
            }
            List <ActivityPageUrlConfig> list = JsonConvert.DeserializeObject <List <ActivityPageUrlConfig> >(data);

            foreach (var item in list)
            {
                if (item.Id == 0)
                {
                    int outid = 0;
                    item.ActivityPageId = id;
                    RegionActivityPageConfigManager.InsertActivityPageUrlConfig(item, ref outid);
                    if (item.IsDefault)
                    {
                        model.DefaultUrlId = outid;
                        RegionActivityPageConfigManager.UpdateActivityPageConfig(model);
                    }
                    EditRegion(item.RegionString, outid);
                }
                else
                {
                    RegionActivityPageConfigManager.UpdateActivityPageUrlConfig(item);
                    if (item.IsDefault)
                    {
                        model.DefaultUrlId = item.Id;
                        RegionActivityPageConfigManager.UpdateActivityPageConfig(model);
                    }
                    EditRegion(item.RegionString, item.Id);
                }
            }
            return(true);
        }
        public static List <ActivityPageConfig> GetActivityPageConfig(ActivityPageConfig model, int pageSize, int pageIndex, out int totalIteme)
        {
            string sql      = @"SELECT [Id]
                                  ,[DefaultUrlId]
                                  ,[Name]
                                  ,[StartTime]
                                  ,[EndTime]
                                  ,[CreateTime]
                                  ,[UpdateTime]
                                  ,[CreateName]
                                  ,[UpdateName]
                                  ,[ShareParameters]
                              FROM [Configuration].[dbo].[SE_ActivityPageConfig] AS A WITH (NOLOCK)                                
                                    ORDER BY  A.[Id] DESC 
                                    OFFSET ( @PageIndex - 1 ) * @PageSize ROWS  FETCH NEXT @PageSize ROWS  ONLY 
                                ";
            string sqlCount = @"SELECT Count(0)
                                FROM    [Configuration].[dbo].[SE_ActivityPageConfig] AS A WITH (NOLOCK)";

            var sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@PageSize", pageSize),
                new SqlParameter("@PageIndex", pageIndex)
            };

            totalIteme = (int)SqlHelper.ExecuteScalar(connOnRead, CommandType.Text, sqlCount);
            return(SqlHelper.ExecuteDataTable(connOnRead, CommandType.Text, sql, sqlParameters).ConvertTo <ActivityPageConfig>().ToList());
        }
        public static bool UpdateActivityPageConfig(ActivityPageConfig model)
        {
            const string sql          = @"UPDATE Configuration..SE_ActivityPageConfig SET                                      
                                        [DefaultUrlId]=@DefaultUrlId
                                        ,[Name]=@Name
                                        ,[StartTime]=@StartTime
                                        ,[EndTime]=@EndTime                                        
                                        ,[UpdateTime]=GETDATE()                                            
                                        ,[UpdateName]=@UpdateName
                                        ,[ShareParameters]=@ShareParameters                                      
                                 WHERE Id=@Id";
            var          sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@CreateName", model.CreateName),
                new SqlParameter("@EndTime", model.EndTime),
                new SqlParameter("@Name", model.Name),
                new SqlParameter("@DefaultUrlId", model.DefaultUrlId),
                new SqlParameter("@StartTime", model.StartTime),
                new SqlParameter("@UpdateName", model.UpdateName),
                new SqlParameter("@Id", model.Id),
                new SqlParameter("@ShareParameters", model.ShareParameters ?? string.Empty)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameter) > 0);
        }
 public bool InsertActivityPageConfig(ActivityPageConfig model, ref int id)
 {
     try
     {
         return(DALRegionActivityPageConfig.InsertActivityPageConfig(model, ref id));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "InsertActivityPageConfig");
         throw ex;
     }
 }
 public bool UpdateActivityPageConfig(ActivityPageConfig model)
 {
     try
     {
         return(DALRegionActivityPageConfig.UpdateActivityPageConfig(model));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "UpdateActivityPageConfig");
         throw ex;
     }
 }
 public List <ActivityPageConfig> GetActivityPageConfig(ActivityPageConfig model, int pageSize, int pageIndex, out int recordCount)
 {
     try
     {
         return(DALRegionActivityPageConfig.GetActivityPageConfig(model, pageSize, pageIndex, out recordCount));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "GetActivityPageConfig");
         throw ex;
     }
 }
Esempio n. 7
0
        public void AddOprLog(ActivityPageConfig model, string opr)
        {
            OprLog oprModel = new OprLog();

            oprModel.Author         = User.Identity.Name;
            oprModel.ChangeDatetime = DateTime.Now;
            oprModel.HostName       = Request.UserHostName;
            oprModel.ObjectID       = model.Id;
            oprModel.ObjectType     = "RAPC";
            oprModel.Operation      = opr;
            OprLogManager.AddOprLog(oprModel);
        }
Esempio n. 8
0
        public ActionResult Index(ActivityPageConfig model, int pageIndex = 1, int pageSize = 20)
        {
            int    count  = 0;
            string strSql = string.Empty;
            var    lists  = RegionActivityPageConfigManager.GetActivityPageConfig(model, pageSize, pageIndex, out count);

            var list  = new OutData <List <ActivityPageConfig>, int>(lists, count);
            var pager = new PagerModel(pageIndex, pageSize)
            {
                TotalItem = count
            };

            return(View(new ListModel <ActivityPageConfig>(list.ReturnValue, pager)));
        }
Esempio n. 9
0
        public JsonResult Delete(int id)
        {
            bool result = false;
            ActivityPageConfig model = new ActivityPageConfig();

            model.Id = id;

            if (RegionActivityPageConfigManager.DeleteRegionActivityPageConfig(id))
            {
                AddOprLog(model, "删除");
                result = true;
            }
            return(Json(result));
        }
Esempio n. 10
0
 public ActionResult Edit(int id = 0)
 {
     ViewBag.Id = id;
     if (id == 0)
     {
         var model = new ActivityPageConfig();
         model.StartTime = DateTime.Now;
         model.EndTime   = DateTime.Now.AddDays(30);
         ViewBag.ActivityPageUrlConfig = new List <ActivityPageUrlConfig>();
         return(View(model));
     }
     else
     {
         ActivityPageConfig model = RegionActivityPageConfigManager.GetActivityPageConfigById(id);
         ViewBag.ActivityPageUrlConfig = RegionActivityPageConfigManager.GetActivityPageUrlConfigById(id);
         return(View(model));
     }
 }
        public static bool InsertActivityPageConfig(ActivityPageConfig model, ref int id)
        {
            const string sql = @"  INSERT INTO Configuration..[SE_ActivityPageConfig]
                                              (                                        
                                               [DefaultUrlId]
                                              ,[Name]
                                              ,[StartTime]
                                              ,[EndTime]
                                              ,[CreateTime]
                                              ,[UpdateTime]
                                              ,[CreateName]
                                              ,[UpdateName]
                                              ,[ShareParameters]
                                              )
                                      VALUES  ( 
                                               @DefaultUrlId
                                              ,@Name                                            
                                              ,@StartTime
                                              ,@EndTime
                                              ,GETDATE()
                                              ,GETDATE()
                                              ,@CreateName
                                              ,@UpdateName 
                                              ,@ShareParameters                                                                               
                                              )SELECT @@IDENTITY";

            var sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@CreateName", model.CreateName ?? "途虎测试"),
                new SqlParameter("@EndTime", model.EndTime),
                new SqlParameter("@Name", model.Name),
                new SqlParameter("@DefaultUrlId", model.DefaultUrlId),
                new SqlParameter("@StartTime", model.StartTime),
                new SqlParameter("@UpdateName", model.UpdateName ?? "途虎测试"),
                new SqlParameter("@ShareParameters", model.ShareParameters),
            };

            id = Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, sqlParameter));
            return(id > 0);
        }
Esempio n. 12
0
        public ActionResult Edit(string data1, string data2)
        {
            try
            {
                ActivityPageConfig model = JsonConvert.DeserializeObject <ActivityPageConfig>(data1);
                string             name  = string.IsNullOrWhiteSpace(User.Identity.Name) ? "途虎系统" : User.Identity.Name;
                if (model.Id != 0)
                {
                    model.UpdateName = name;
                    model.UpdateName = name;
                    if (RegionActivityPageConfigManager.UpdateActivityPageConfig(model))
                    {
                        EditModel(data2, model.Id, model);
                        AddOprLog(model, "修改");
                        return(Json(true));
                    }
                    else
                    {
                        return(Json(false));
                    }
                }
                else
                {
                    string domain = Request.Url.Host.Contains("tuhu.cn") ? "http://res.tuhu.org" : "http://resource.tuhu.test";
                    int    newid  = 0;
                    model.CreateName = name;
                    model.UpdateName = name;
                    if (RegionActivityPageConfigManager.InsertActivityPageConfig(model, ref newid))
                    {
                        //默认添加分享链接
                        ShareParams share = JsonConvert.DeserializeObject <ShareParams>(model.ShareParameters);
                        if (string.IsNullOrWhiteSpace(share.URL))
                        {
                            share.URL = domain + "/StaticPage/pictures/adaptImgs.html?id=" + EncodeBase64(newid.ToString());
                        }
                        if (share.shareUrl == "&type=2&utm_source=1")
                        {
                            share.shareUrl = domain + "/StaticPage/pictures/adaptImgs.html?id=" + EncodeBase64(newid.ToString()) + "&type=2&utm_source=1";
                        }
                        model.ShareParameters = JsonConvert.SerializeObject(share);
                        model.Id = newid;
                        RegionActivityPageConfigManager.UpdateActivityPageConfig(model);

                        model.Id = newid;
                        EditModel(data2, model.Id, model);
                        AddOprLog(model, "添加");
                        return(Json(true));
                    }
                    else
                    {
                        return(Json(false));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(false));

                throw ex;
            }
        }