private Banner GetRandomBanner(int holderId) { BannerConfig banner = BannerGenerator.GetRandomFromBannerConfigs(holderIdToBannerConfigMap[holderId]); if (banner == null || Path.GetFileNameWithoutExtension(banner.Name) == "D1BFFB30-517B-4ED5-A401-FD301D03E8AB") { return(GetDefaultBannerIfPresent(holderId)); } else { try { using (FileStream stream = new FileStream(Path.Combine(this.currentBannerCampaignDirInfo.FullName, Path.GetFileName(banner.Name)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { return(new Banner(BitmapFrame.Create(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad), banner.Link)); } } catch (Exception ex) { Configuration.Analytics.TrackException(ex); return(GetDefaultBannerIfPresent(holderId)); } } }
public void SetConfig(Dictionary <string, object> bannerConfig) { this.config = new BannerConfig(bannerConfig); IconImage.sprite = this.config.IconSprite; AppName.text = this.config.AppName; AppDesc.text = this.config.AppDesc; }
public void SetConfig(BannerConfig config) { this.config = config; IconImage.sprite = this.config.IconSprite; AppName.text = this.config.AppName; AppDesc.text = this.config.AppDesc; }
public JsonResult AddOrUpdate(BannerConfig model) { if (!string.IsNullOrWhiteSpace(model.Image)) { model.Image = model.Image.Replace(WebConfigurationManager.AppSettings["DoMain_image"], ""); } if (!string.IsNullOrWhiteSpace(model.StartVersion)) { model.StartVersion = model.StartVersion.Trim(); } if (!string.IsNullOrWhiteSpace(model.EndVersion)) { model.EndVersion = model.EndVersion.Trim(); } if (string.IsNullOrWhiteSpace(model.Creator)) { model.Creator = string.Empty; } if (model.Id < 0) { var result = DownloadAppManager.InsertBannerConfig(model); if (result > 0) { var oprLog = new Tuhu.Provisioning.DataAccess.Entity.OprLog { ObjectID = result, ObjectType = "BannerConfig", AfterValue = "位置: " + model.Location + ", 平台:" + model.Channel + ", 状态:" + model.Status + ", 目标群体:" + (string.IsNullOrWhiteSpace(model.TargetGroups) ? "" : model.TargetGroups), Author = HttpContext.User.Identity.Name, Operation = "新建Banner配置" }; new OprLogManager().AddOprLog(oprLog); } return(Json(result)); } else { var result = DownloadAppManager.UpdateBannerConfig(model); if (result > 0) { var oprLog = new Tuhu.Provisioning.DataAccess.Entity.OprLog { ObjectID = model.Id, ObjectType = "BannerConfig", AfterValue = "位置: " + model.Location + ", 平台:" + model.Channel + ", 状态:" + model.Status + ", 目标群体:" + (string.IsNullOrWhiteSpace(model.TargetGroups) ? "" : model.TargetGroups), Author = HttpContext.User.Identity.Name, Operation = "更新Banner配置" }; new OprLogManager().AddOprLog(oprLog); } return(Json(result)); } }
public static int InsertBannerConfig(SqlConnection conn, BannerConfig model) { const string sql = @" INSERT INTO Configuration.dbo.PersonalCenterConfig ( DESCRIPTION, Route, ShareType, Image, Channel, Location, NoticeChannels, StartDateTime, EndDateTime, Status, TargetGroups, Grade, VIPAuthorizationRuleId, StartVersion, EndVersion, Sort, CreateTime, Creator, Link, IOSProcessValue, AndroidProcessValue, IOSCommunicationValue, AndroidCommunicationValue, IsNew, TargetSmallAppId, TargetSmallAppUrl ) VALUES ( @Description, @Route, @ShareType, @Image, @Channel, @Location, @NoticeChannels, @StartDateTime, @EndDateTime, @Status, @TargetGroups, @Grade, @VIPAuthorizationRuleId, @StartVersion, @EndVersion, @Sort, GETDATE(), @Creator, @Link, @IOSProcessValue, @AndroidProcessValue, @IOSCommunicationValue, @AndroidCommunicationValue, 1, @TargetSmallAppId, @TargetSmallAppUrl ); SELECT @@IDENTITY;"; var sqlParam = new[] { new SqlParameter("@Description", model.Description), new SqlParameter("@Route", model.Route), new SqlParameter("@ShareType", model.ShareType), new SqlParameter("@Image", model.Image), new SqlParameter("@Channel", model.Channel), new SqlParameter("@Location", model.Location), new SqlParameter("@NoticeChannels", model.NoticeChannels), new SqlParameter("@StartDateTime", model.StartDateTime), new SqlParameter("@EndDateTime", model.EndDateTime), new SqlParameter("@Status", model.Status), new SqlParameter("@TargetGroups", model.TargetGroups), new SqlParameter("@Grade", model.Grade), new SqlParameter("@VIPAuthorizationRuleId", model.VIPAuthorizationRuleId), new SqlParameter("@StartVersion", model.StartVersion), new SqlParameter("@EndVersion", model.EndVersion), new SqlParameter("@Sort", model.Sort), new SqlParameter("@Creator", model.Creator), new SqlParameter("@Link", model.Link), new SqlParameter("@IOSProcessValue", model.IOSProcessValue), new SqlParameter("@AndroidProcessValue", model.AndroidProcessValue), new SqlParameter("@IOSCommunicationValue", model.IOSCommunicationValue), new SqlParameter("@AndroidCommunicationValue", model.AndroidCommunicationValue), new SqlParameter("@TargetSmallAppId", model.TargetSmallAppId), new SqlParameter("@TargetSmallAppUrl", model.TargetSmallAppUrl), }; return(Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, sqlParam))); }
public static int UpdateBannerConfig(SqlConnection conn, BannerConfig model) { const string sql = @"UPDATE Configuration.dbo.PersonalCenterConfig SET Description=@Description, Route=@Route, ShareType=@ShareType, Image=@Image, Channel=@Channel, Location=@Location, NoticeChannels=@NoticeChannels, StartDateTime=@StartDateTime, EndDateTime=@EndDateTime, Status=@Status, TargetGroups=@TargetGroups, Grade=@Grade, VIPAuthorizationRuleId = @VIPAuthorizationRuleId, StartVersion=@StartVersion, EndVersion=@EndVersion, Sort=@Sort, Link=@Link, IOSProcessValue=@IOSProcessValue, AndroidProcessValue=@AndroidProcessValue, IOSCommunicationValue=@IOSCommunicationValue, AndroidCommunicationValue=@AndroidCommunicationValue, TargetSmallAppId=@TargetSmallAppId, TargetSmallAppUrl=@TargetSmallAppUrl WHERE Id=@Id"; var sqlParam = new[] { new SqlParameter("@Description", model.Description), new SqlParameter("@Route", model.Route), new SqlParameter("@ShareType", model.ShareType), new SqlParameter("@Image", model.Image), new SqlParameter("@Channel", model.Channel), new SqlParameter("@Location", model.Location), new SqlParameter("@NoticeChannels", model.NoticeChannels), new SqlParameter("@StartDateTime", model.StartDateTime), new SqlParameter("@EndDateTime", model.EndDateTime), new SqlParameter("@Status", model.Status), new SqlParameter("@TargetGroups", model.TargetGroups), new SqlParameter("@Grade", model.Grade), new SqlParameter("@VIPAuthorizationRuleId", model.VIPAuthorizationRuleId), new SqlParameter("@StartVersion", model.StartVersion), new SqlParameter("@EndVersion", model.EndVersion), new SqlParameter("@Sort", model.Sort), new SqlParameter("@Link", model.Link), new SqlParameter("@IOSProcessValue", model.IOSProcessValue), new SqlParameter("@AndroidProcessValue", model.AndroidProcessValue), new SqlParameter("@IOSCommunicationValue", model.IOSCommunicationValue), new SqlParameter("@AndroidCommunicationValue", model.AndroidCommunicationValue), new SqlParameter("@TargetSmallAppId", model.TargetSmallAppId), new SqlParameter("@TargetSmallAppUrl", model.TargetSmallAppUrl), new SqlParameter("@Id", model.Id) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParam)); }
private void SaveServerBanner(BannerConfig bannerConfigs, string bannerCampaignVersionString) { Byte[] bytes = this.serviceInstance.GetBannerBytesByVersion(bannerConfigs.Name, bannerCampaignVersionString); if (TrySaveBannerConfig(bannerConfigs)) { string bannerPath = Path.Combine(localBannersDirInfo.FullName, bannerCampaignVersionString, bannerConfigs.Name); File.WriteAllBytes(bannerPath, bytes); } }
public int UpdateBannerConfig(BannerConfig model) { try { return(handler.UpdateBannerConfig(model)); } catch (TuhuBizException) { throw; } catch (Exception ex) { var exception = new DownloadAppException(1, "UpdateBannerConfig", ex); Logger.Log(Level.Error, exception, "UpdateBannerConfig"); throw ex; } }
private bool TrySaveBannerConfig(BannerConfig bannerConfigs) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(BannerConfig)); bool isSave = false; using (FileStream fileStream = new FileStream(bannerConfigs.LocalFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)) { try { xmlSerializer.Serialize(fileStream, bannerConfigs); isSave = true; } catch (Exception ex) { Configuration.Analytics.TrackException(ex); } } return(isSave); }
public BannerController(BannerConfig config) => this.config = config;
public int UpdateBannerConfig(BannerConfig model) { return(DalBannerConfig.UpdateBannerConfig(conn, model)); }
public int InsertBannerConfig(BannerConfig model) { return(DalBannerConfig.InsertBannerConfig(conn, model)); }