public static void Run([ServiceBusTrigger("promcarmodel", "3series", AccessRights.Listen)] BrokeredMessage mySbMsg, TraceWriter log) { log.Info($"C# ServiceBus topic trigger function processed message: {mySbMsg}"); var stream = mySbMsg.GetBody <Stream>(); StreamReader reader = new StreamReader(stream); string obj = reader.ReadToEnd(); PromoData promoData = JsonConvert.DeserializeObject <PromoData>(obj); //save promotion posts into mongo collection.......................... MongoDBConnection.GetCollection <PromoData>("PromotionCollectionName").InsertOne(promoData); //save promotion posts into redis list and trim for the latest 5 posts. IDatabase cache = RedisConnection.Connection.GetDatabase(); string redisKey = System.Environment.GetEnvironmentVariable("key:3seriespromotionpost"); cache.ListLeftPush(redisKey, obj); cache.ListTrim(redisKey, 0, 5); }
public ActionResult AddParticipant(PromoData promo) { var promoData = _seminarService.GetPromoData(); promo.Positions = promoData.Positions; promo.Seminars = promoData.Seminars; if (promo.Participant?.Position == null) { ModelState.AddModelError("Position", "Укажите должность"); } if (promo.Participant != null && ModelState.IsValid) { bool isTransactionCommitted = _seminarService.AddParticipant(promo.Participant); promo.IsTransactionCommitted = isTransactionCommitted; } return(View("MainPage", promo)); }
public IEnumerator processPromo() { string url = generateURL(); WWW promoFile = new WWW(url); while(promoFile.isDone == false) yield return 0; if(promoFile.error != null) { Debug.LogError("Couldn't load promotion at url: " + url + " " + promoFile.error); return false; } //Got file. Now parse it string txt = promoFile.text; Debug.Log (txt); string[] lines = txt.Split('\n'); //Check version string firstLine = lines[0].Trim(); //promoVersion = Int32.Parse(firstLine); Debug.Log("Promo Version: " + promoVersion + " lastPromoVersion: " + lastPromoVersion); foreach(string line in lines) { string l = line.Trim(); //Remove comments if(l != null && l.Length > 0 && l[0] == '#') continue; int hashIndex = l.IndexOf('#'); if(hashIndex > 0) { l = l.Substring(0,hashIndex - 1); } string[] fields = l.Split('|'); if(fields.Length < 3) continue; PromoData pd = new PromoData(fields); //Don't show promo for our own app if(pd.appName == appID) continue; WWW icon = new WWW(pd.iconURL); while(icon.isDone == false) yield return 0; if(icon.error != null) { Debug.LogError("Couldn't load icon at url: " + pd.iconURL + " " + icon.error); return false; } pd.downloadedIcon = icon.texture; pd.debugPrint(); promoData.Add(pd); } //Should we show the promo? //Show if there is a new version or we have run the app a certain multiple of time Debug.Log ("runCounter: " + runCounter + " showEveryCount: " + showEveryCount + " runCounter % showEveryCount: " + runCounter % showEveryCount); if(runCounter > 2 && (promoVersion > lastPromoVersion || runCounter % showEveryCount == 0)) SendMessage("setGUIState", AppController.GUIState.PROMO, SendMessageOptions.DontRequireReceiver); storeRunCounterState(); }
public ActionResult MainPage(PromoData promo) { promo = _seminarService.GetPromoData(); return(View(promo)); }