public string GetSplashImage() { string result = string.Empty; string splashImageId, newSplashImageId = string.Empty; string registrationId = _globalOptionService.GetOptionContent(SettingConstant.RegistrationKey); switch (registrationId) { case null: case "": registrationId = "-1"; _globalOptionService.SetOption(SettingConstant.RegistrationKey, registrationId); break; case "-1": registrationId = "0"; _globalOptionService.SetOption(SettingConstant.RegistrationKey, registrationId); break; } string promoCode = _globalOptionService.GetOptionContent(SettingConstant.PromoCodeKey); splashImageId = _globalOptionService.GetOptionContent(SettingConstant.SplashImageIDKey); newSplashImageId = GetImageId(registrationId, promoCode); if (!newSplashImageId.Equals(splashImageId, StringComparison.CurrentCulture)) { //Download the splash SplashDefinition splashDefinition = GetSplashDefData(); if (splashDefinition != null) { if (!splashDefinition.SplashImage.IsEmpty()) { _globalOptionService.SetOption(SettingConstant.SplashPictureKey, splashDefinition.SplashImage); result = splashDefinition.SplashImage; } CommonSplashData(splashDefinition); // Update New Splash Image Id _globalOptionService.SetOption(SettingConstant.SplashImageIDKey, newSplashImageId); } } if (result.IsEmpty()) { //Retrieve the existing splash result = _globalOptionService.GetOptionContent(SettingConstant.SplashPictureKey); } return(result); }
public void UpdatePromo() { //TODO: download new promo stuff SplashDefinition splashDef = GetSplashDefData(); if (splashDef != null && splashDef.ValidPromoCode) { string Promocode = _globalOptionService.GetOptionContent(SettingConstant.PromoCodeKey); CommonSplashData(splashDef); _globalOptionService.SetOption(SettingConstant.SplashPictureKey, splashDef.SplashImage); } //Andy _sponsorService.SaveSponsor(GetSponsorData()); }
public SplashDefinition GetSplashDefData() { SplashDefinition result = default(SplashDefinition); try { string registrationId = _globalOptionService.GetOptionContent(SettingConstant.RegistrationKey); string promoCode = _globalOptionService.GetOptionContent(SettingConstant.PromoCodeKey); result = _softwareService.AgentSplashDefData(registrationId, promoCode); if (result != null && !result.SplashImage.IsEmpty()) { result.SplashImage = result.SplashImage.ConvertToImageUrl(); } } catch (Exception ex) { _logService.LogException(ex); } return(result); }
public void CommonSplashData(SplashDefinition splashDefinition) { if (splashDefinition != null) { if (!splashDefinition.ImageId.IsEmpty()) { _globalOptionService.SetOption(SettingConstant.SplashImageIDKey, splashDefinition.ImageId); } if (splashDefinition.AgentXMLData != null) { try { var innerXml = JsonConvert.SerializeObject(splashDefinition.AgentXMLData.PROMOINFO); _globalOptionService.SetOption(SettingConstant.AgentXMLDataKey, innerXml); } catch (Exception ex) { _logService.LogException(ex); } } // Show message from the server try { if (splashDefinition.MessageText != null) { _globalOptionService.SetOption(SettingConstant.MessageFromServerKey, splashDefinition.MessageText); } else { _globalOptionService.SetOption(SettingConstant.MessageFromServerKey, string.Empty); } } catch (Exception ex) { } } }