Esempio n. 1
0
        private void OnServerDateGotten_Handler(object sender, GameEventArgs e)
        {
#if UNITY_EDITOR
            TimerController.Instance.CreateNewMonoTimer(3, () =>
            {
                if (!UserDataControl.Instance.UserData)
                {
                    UserDataControl.Instance.UserData = new UserDataPresenter();
                    UserDataControl.Instance.UserData = new UserDataPresenter();
                }

                CurrentDate = TimeManager.LocalUrmobiServerDT;

                try
                {
                    NextDate = System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate);
                    UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate = NextDate.ToString();
                }
                catch (System.Exception ex)
                {
                    Debug.LogWarning(ex, this);
                    var t = TimeManager.LocalUrmobiServerDT;
                    UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate = new System.DateTime().ToString();
                    NextDate = System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate);
                }
                UpdateDate();
                TimeManager.TickEvent -= OnTimeTick;
                TimeManager.TickEvent += OnTimeTick;
                EventManager.Unsubscribe(Events.SaveData.NEW_DATA_APPLIED, OnNewDataApplied_Handler);
                EventManager.Unsubscribe(Events.DateTime.URMOBI_DATE_GOTTEN, OnServerDateGotten_Handler);
            });
#endif
        }
Esempio n. 2
0
 public bool Consume()
 {
     if (AvailableToConsume)
     {
         reward.Consume();
         if (CurrentDate >= new System.DateTime(CurrentDate.Year, CurrentDate.Month, CurrentDate.Day, 6, 0, 0) && CurrentDate < new System.DateTime(CurrentDate.Year, CurrentDate.Month, CurrentDate.Day, 12, 0, 0))
         {
             NextDate = CurrentDate.AddHours(2);
         }
         else if (CurrentDate >= new System.DateTime(CurrentDate.Year, CurrentDate.Month, CurrentDate.Day, 12, 0, 0) && CurrentDate < new System.DateTime(CurrentDate.Year, CurrentDate.Month, CurrentDate.Day, 20, 0, 0))
         {
             NextDate = CurrentDate.AddHours(3);
         }
         else if (CurrentDate >= new System.DateTime(CurrentDate.Year, CurrentDate.Month, CurrentDate.Day, 20, 0, 0) && CurrentDate < new System.DateTime(CurrentDate.Year, CurrentDate.Month, CurrentDate.Day + 1, 6, 0, 0))
         {
             NextDate = CurrentDate.AddHours(6);
         }
         UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate = NextDate.ToString();
         UserDataControl.Instance.SaveData();
         AvailableToConsume = false;
         Debug.Log($"Reward claimed {reward.reward}", this);
         UIControl.Instance.ShowInfoPopUp(new UIPopUp.PopupData($"You have gotten {reward.reward}!"));
         return(true);
     }
     else
     {
         Debug.Log("Consume failed", this);
         return(false);
     }
 }
Esempio n. 3
0
        private void OnNewDataApplied_Handler(object sender, GameEventArgs e)
        {
#if !UNITY_EDITOR
            if (!UserDataControl.Instance.UserData)
            {
                UserDataControl.Instance.UserData = new UserDataPresenter();
                UserDataControl.Instance.UserData = new UserDataPresenter();
            }

            CurrentDate = TimeManager.LocalUrmobiServerDT;

            if (UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate != null && System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextDate) != System.DateTime.MinValue)
            {
                NextDate = System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate);
                UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate = NextDate.ToString();
            }
            else
            {
                var t = TimeManager.LocalUrmobiServerDT;
                UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate = new System.DateTime().ToString();
                NextDate = System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextSurprizeDate);
            }
            UpdateDate();
            TimeManager.TickEvent -= OnTimeTick;
            TimeManager.TickEvent += OnTimeTick;
            EventManager.Unsubscribe(Events.SaveData.NEW_DATA_APPLIED, OnNewDataApplied_Handler);
            EventManager.Unsubscribe(Events.DateTime.URMOBI_DATE_GOTTEN, OnServerDateGotten_Handler);
#endif
        }
Esempio n. 4
0
        private void OnServerDateGotten_Handler(object sender, GameEventArgs e)
        {
#if UNITY_EDITOR
            TimerController.Instance.CreateNewMonoTimer(3, () =>
            {
                if (!UserDataControl.Instance.UserData)
                {
                    UserDataControl.Instance.UserData = new UserDataPresenter();
                    UserDataControl.Instance.UserData = new UserDataPresenter();
                }

                CurrentDailyDay = UserDataControl.Instance.UserData.RewardsData.currentDailyDay;
                NextDailyDay    = CurrentDailyDay < daysCycle - 1 ? (byte)(CurrentDailyDay + 1) : (byte)0;
                //CurrentWheelDay = UserDataControl.Instance.UserData.RewardsData.currentWheelDay;
                //CurrentScratchDay = UserDataControl.Instance.UserData.RewardsData.currentScratchDay;
                //CurrentSlotDay = UserDataControl.Instance.UserData.RewardsData.currentSlotDay;
                //CurrentRewardMechanic = UserDataControl.Instance.UserData.RewardsData.currentRewardMechanic;

                try
                {
                    NextDate = System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextDate);
                    UserDataControl.Instance.UserData.RewardsData.nextDate = NextDate.ToString();
                }
                catch (System.Exception ex)
                {
                    Debug.LogWarning(ex, this);
                    var t = TimeManager.LocalUrmobiServerDT;
                    Debug.Log($"Next day on init: {new System.DateTime(t.Year, t.Month, t.Day, 0, 0, 0).AddDays(1).ToString()}");
                    UserDataControl.Instance.UserData.RewardsData.nextDate = new System.DateTime(t.Year, t.Month, t.Day, 0, 0, 0).AddDays(1).ToString();
                    Debug.Log($"Used data next day: {UserDataControl.Instance.UserData.RewardsData.nextDate}");
                    NextDate = System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextDate);
                }
                UpdateDays(true);
                TimeManager.TickEvent -= OnTimeTick;
                TimeManager.TickEvent += OnTimeTick;
                DataInited             = true;
            });
#endif
        }
Esempio n. 5
0
        private void OnNewDataApplied_Handler(object sender, GameEventArgs e)
        {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
            Debug.Log("OnNewDataApplied_Handler");

            if (!UserDataControl.Instance.UserData)
            {
                UserDataControl.Instance.UserData = new UserDataPresenter();
                UserDataControl.Instance.UserData = new UserDataPresenter();
            }
            CurrentDailyDay = UserDataControl.Instance.UserData.RewardsData.currentDailyDay;
            NextDailyDay    = CurrentDailyDay < daysCycle - 1 ? (byte)(CurrentDailyDay + 1) : (byte)0;
            //CurrentWheelDay = UserDataControl.Instance.UserData.RewardsData.currentWheelDay;
            //CurrentScratchDay = UserDataControl.Instance.UserData.RewardsData.currentScratchDay;
            //CurrentSlotDay = UserDataControl.Instance.UserData.RewardsData.currentSlotDay;
            //CurrentRewardMechanic = UserDataControl.Instance.UserData.RewardsData.currentRewardMechanic;

            if (UserDataControl.Instance.UserData.RewardsData.nextDate != null && System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextDate) != System.DateTime.MinValue)
            {
                Debug.Log("NEXT DATE DADA IS EMPTY!");
                NextDate = System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextDate);
                UserDataControl.Instance.UserData.RewardsData.nextDate = NextDate.ToString();
            }
            else
            {
                var t = TimeManager.UrmobiServerDT;
                Debug.Log($"Next day on init: {new System.DateTime(t.Year, t.Month, t.Day, 0, 0, 0).AddDays(1).ToString()}");
                UserDataControl.Instance.UserData.RewardsData.nextDate = new System.DateTime(t.Year, t.Month, t.Day, 0, 0, 0).AddDays(1).ToString();
                Debug.Log($"Used data next day: {UserDataControl.Instance.UserData.RewardsData.nextDate}");
                NextDate = System.DateTime.Parse(UserDataControl.Instance.UserData.RewardsData.nextDate);
            }
            UpdateDays(true);
            TimeManager.TickEvent -= OnTimeTick;
            TimeManager.TickEvent += OnTimeTick;
            DataInited             = true;
#endif
        }
        /// <summary>
        /// Restituisce le impostazioni del task periodico.
        /// </summary>
        /// <param name="next">Passare true per ottenere le impostazioni per il prossimo trigger</param>
        /// <returns>Restituisce sempre true. Se si passa next a true e non ci sono impostazioni successive, restituisce false.</returns>
        private async Task <bool> LoadWorkSetting(bool next = false)
        {
            if (!ExistsNextSetting())
            {
                return(false);
            }

            GetInterval(next, out uint interval);
            Interval = interval;

            Execute  = false;
            NextDate = DateTime.ParseExact(ApplicationData.Current.LocalSettings.Values[_taskName + ".NextDate"].ToString(), "dd-MM-yyyy, HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
            if (_executionMinutes >= NextDate)
            {
                Execute = true;
                await WorkLogger?.Debug(string.Format("Trigger eseguito. NextTrigger: {0}, Execution date: {1}", NextDate, _executionMinutes));

                int maxCount = 100;
                do
                {
                    if (!next && ExistsNextSetting(out uint nextInterval))
                    {
                        NextDate = NextDate.AddMinutes(nextInterval);
                    }
                    else
                    {
                        NextDate = NextDate.AddMinutes(Interval);
                    }
                    ApplicationData.Current.LocalSettings.Values[_taskName + ".NextDate"] = NextDate.ToString("dd-MM-yyyy, HH:mm:ss");
                    maxCount--;
                }while (NextDate < _executionMinutes && maxCount >= 0);

                Interval = (uint)Math.Round((NextDate - _executionMinutes).TotalMinutes, 0);
                await WorkLogger?.Debug(string.Format("Nuovo trigger: {0}, intervallo: {1} minuti", NextDate, Interval));
            }

            return(true);
        }
        static void Main(string[] args)
        {
            logger.Error("******************************************* Start *******************************************");
            logger.Error("Start Cost Variation Service at : " + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt"));

            try
            {
                var resolver   = UnityConfig.GetConfiguredContainer();
                var _Utilities = resolver.Resolve <IUtilities>();

                ReportViewer CostVariationReport = new ReportViewer();
                CostVariationReport.ProcessingMode = ProcessingMode.Remote;
                CostVariationReport.ServerReport.ReportServerUrl         = new Uri(_Utilities.GetAppSetting("ReportServerUrl"));
                CostVariationReport.ServerReport.ReportPath              = _Utilities.GetAppSetting("CostVariationReportReportPath");
                CostVariationReport.ServerReport.ReportServerCredentials = new ReportServerCredentials(_Utilities.GetAppSetting("ReportServerUsername"), _Utilities.GetAppSetting("ReportServerPassword"), _Utilities.GetAppSetting("ReportServerDomain"));
                AssignReportParameters(CostVariationReport);
                string   mimeType;
                string   encoding;
                string   extension;
                string   format  = "EXCEL";
                string   devInfo = null;
                string[] streams;
                byte[]   result = null;
                Microsoft.Reporting.WebForms.Warning[] warnings;
                result = CostVariationReport.ServerReport.Render(format, devInfo, out mimeType, out encoding, out extension, out streams, out warnings);

                string path = ConfigurationManager.AppSettings["FilePath"].ToString();

                using (System.IO.FileStream writer = new FileStream(path, FileMode.Create))
                {
                    logger.Error("Report Created at : " + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt"));
                    writer.Write(result, 0, result.Length);
                    logger.Error("Result written to the Report at : " + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt"));
                    writer.Close();
                }

                int hours   = int.Parse(System.Configuration.ConfigurationManager.AppSettings["Hour"]);
                int minutes = int.Parse(System.Configuration.ConfigurationManager.AppSettings["minutes"]);

                DateTime CureentDate = DateTime.Now;
                DateTime tempDate    = CureentDate.AddMonths(1);
                DateTime NextDate    = new DateTime();
                if (CureentDate.Day == 1 && CureentDate.Hour < 7)
                {
                    NextDate = new DateTime(CureentDate.Year, CureentDate.Month, 1, hours, minutes, 0);
                }
                else
                {
                    NextDate = new DateTime(tempDate.Year, tempDate.Month, 1, hours, minutes, 0);
                }
                TimeSpan TimeDiff = NextDate.Subtract(DateTime.Now);
                string   schedule = string.Format("{0} day(s) {1} hour(s) {2} minute(s) {3} second(s)", TimeDiff.Days, TimeDiff.Hours, TimeDiff.Minutes, TimeDiff.Seconds);
                logger.Error("Cost Variation  Service scheduled to run after: " + schedule + "From" + " {0} " + " Next Date To Execute Is: " + NextDate.ToString("dd/MM/yyyy hh:mm:ss tt"));

                SendEmail();
                CostVariationReport.ServerReport.Refresh();

                logger.Error("******************************************* End *******************************************");
            }
            catch (Exception exp)
            {
                logger.Error("Exception Error : " + exp.Message);
            }
        }