Пример #1
0
        /// <summary>
        /// 获得一个非阻塞锁
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="timeout">过期时间</param>
        /// <param name="timeoutType"></param>
        /// <returns></returns>
        public async Task <RedisLock> GetNonBlockingLockAsync(string key, int timeout, DateTimeTypeEnum timeoutType)
        {
            var milliseconds = Convert.ToInt64(DateTimeManager.ToMilliseconds(timeout, timeoutType));
            var expiry       = new TimeSpan(milliseconds * 10000);

            return(await GetNonBlockingLockAsync(key, expiry));
        }
Пример #2
0
        static void Main(string[] args)
        {
            Initialize();
            Console.ReadKey();
            Console.WriteLine();

            do
            {
                InitializeHeader();

                DateTime dateTime1 = ReadDateFromConsole();
                ConsoleManager.Header.Replace("1) __ . __ . ____", "1) " + dateTime1.ToShortDateString());
                DateTime dateTime2 = ReadDateFromConsole();
                ConsoleManager.Header.Replace("2) __ . __ . ____", "2) " + dateTime2.ToShortDateString());

                ConsoleManager.RefreshHeader();

                DateTimeManager.RevertDatesIfNeeded(ref dateTime1, ref dateTime2);

                ConsoleManager.Write("The necessary data has been entered. Click any key to calculate...");
                Console.ReadKey();
                ConsoleManager.Write("Calculation...");
                Thread.Sleep(1000);

                ConsoleManager.Header.Replace("______ - ______", DateTimeManager.CalculateDates(dateTime1, dateTime2));
                ConsoleManager.Write("DONE! Click escape to stop...");
            }while (Console.ReadKey(true).Key != ConsoleKey.Escape);
        }
Пример #3
0
    public bool RewardedReachedLimit(RewardedAdsType type)//2.2.2
    {
        if (dailyRewardedFrequency == 0)
        {
            return(false);
        }
        dailyRewardedShown[(int)type] = PlayerPrefs.GetInt(type.ToString());
        if (!DateTimeManager.IsPeriodPassed(type.ToString()))
        {
            return(true);
        }
        if (dailyRewardedFrequency > 0 && dailyRewardedShown[(int)type] >= dailyRewardedFrequency)
        {
            return(true);
        }
        // if (Random.Range(0, 5) > 0) return true;
        dailyRewardedShown[(int)type]++;
        PlayerPrefs.SetInt(type.ToString(), dailyRewardedShown[(int)type]);
        if (dailyRewardedShown[(int)type] >= dailyRewardedFrequency)
        {
            DateTimeManager.SetDateTimeNow(type.ToString());
        }
        PlayerPrefs.Save();

        return(false);
    }
Пример #4
0
        /// <summary>Creates a default theme file in the templates folder.</summary>
        /// <param name="force">Forcefully overwrite any default theme with a new one.</param>
        public static void GenerateDefaultThemeFile(bool force = false)
        {
            string _defaultThemePath = SettingConstants.TemplatesFilePath;

            if (force)
            {
                CreateDefaultThemeFile();
                return;
            }

            if (File.Exists(_defaultThemePath))
            {
                FileInfo fileInfo     = new FileInfo(_defaultThemePath);
                DateTime lastModified = fileInfo.LastWriteTime;

                // 24 Hours interval.
                DateTime expiryDate = lastModified.AddDays(1);

                if (DateTimeManager.DateExpired(expiryDate))
                {
                    CreateDefaultThemeFile();
                }
                else
                {
                    // Next update check within 24 hours.
                }
            }
            else
            {
                // Create default theme file since none found.
                CreateDefaultThemeFile();
            }
        }
Пример #5
0
        /// <summary>
        /// 设置String值
        /// </summary>
        /// <param name="collectionName">集合名称</param>
        /// <param name="timeValue">时间点</param>
        /// <param name="dateTimeType"></param>
        /// <returns></returns>
        public async Task <bool> SetExpiryAsync(string collectionName, int timeValue, DateTimeTypeEnum dateTimeType)
        {
            var milliseconds = Convert.ToInt64(DateTimeManager.ToMilliseconds(timeValue, dateTimeType));
            var expiry       = new TimeSpan(milliseconds * 10000);

            return(await SetExpiryAsync(collectionName, expiry));
        }
        public void Spawn()
        {
            Player player = Game.Player;
            Ped    ped    = Game.Player.Character;

            if (!Main.configData.Auto_Save_When_Wanted)
            {
                Game.Player.WantedLevel = 0;
            }

            World.Weather = GameWeather;
            DateTimeManager.SetDate(GameDate);
            DateTimeManager.SetTime(GameTime);

            Function.Call(GTA.Native.Hash.SET_FOLLOW_PED_CAM_VIEW_MODE, OnFootCameraMode);
            Function.Call(GTA.Native.Hash.SET_FOLLOW_VEHICLE_CAM_VIEW_MODE, InVehicleCameraMode);

            player.Money       = Money;
            ped.Money          = Money;
            ped.HealthFloat    = Health;
            ped.MaxHealthFloat = MaxHealth;
            ped.ArmorFloat     = Armor;

            InitPlayer setupPlayer = Script.InstantiateScript <InitPlayer>();

            setupPlayer.Start(this);

            Debug.Log("Init player started!");
        }
Пример #7
0
 /// <summary>
 /// 构造一个创世区块
 /// </summary>
 /// <param name="data"></param>
 public MBlock(object data)
 {
     Index     = 0;
     TimeStamp = DateTimeManager.GetTimeStamp();
     Data      = data.ToJson();
     PrevHash  = string.Empty;
     Hash      = GetHash();
 }
Пример #8
0
 /// <summary>
 /// 构造一个新的区块
 /// </summary>
 /// <param name="lastBlock"></param>
 /// <param name="data"></param>
 public MBlock(MBlock lastBlock, object data)
 {
     Index     = lastBlock.Index + 1;
     TimeStamp = DateTimeManager.GetTimeStamp();
     Data      = data.ToJson();
     PrevHash  = lastBlock.Hash;
     Hash      = GetHash();
 }
Пример #9
0
        public ClockTimeScript()
        {
            Pause();

            DateTimeManager.SetTimerate(Main.configClock.Virtual_Timerate);

            Tick += ClockScripts_Tick;
        }
Пример #10
0
        private void InitializeManagers()
        {
            Debug.Log("Initializing managers...");

            DateTimeManager.SetMode(configClock.Clock_Mode);

            AmmunationManager.CreateAmmunations();
            if (!configBlips.Show_Ammunations)
            {
                AmmunationManager.HideAmmunationBlips();
            }

            AtmManager.CreateATMs();
            if (!configBlips.Show_Atm)
            {
                AtmManager.HideATMBlips();
            }

            DoorManager.CreateDoors();
            if (configSettings.Unlock_All_Doors)
            {
                DoorManager.UnlockAll();
            }

            HospitalManager.CreateDefaultHospitalBlips();
            if (!configBlips.Show_Hospitals)
            {
                HospitalManager.HideHospitalBlips();
            }
            if (configSettings.Hospital_Spawn_OnDeath)
            {
                HospitalManager.EnableAllHospitals();
            }
            else
            {
                HospitalManager.DisableAllHospitals();
            }

            PoliceStationManager.CreateDefaultPoliceStationBlips();
            if (!configBlips.Show_PoliceStations)
            {
                PoliceStationManager.HidePoliceStationBlips();
            }
            if (configSettings.PoliceStation_Spawn_OnArrest)
            {
                PoliceStationManager.EnableAllPoliceStations();
            }
            else
            {
                PoliceStationManager.DisableAllPoliceStations();
            }

            StoreManager.CreateStores();
            if (!configBlips.Show_Stores)
            {
                StoreManager.HideStoreBlips();
            }
        }
Пример #11
0
        public void RevertDatesIfNeeded_FirstDateEqualToSecond_LeaveAsItIs()
        {
            DateTime date1 = new DateTime(2018, 4, 16);
            DateTime date2 = new DateTime(2018, 4, 16);

            DateTimeManager.RevertDatesIfNeeded(ref date1, ref date2);

            Assert.IsTrue(date1 <= date2);
        }
Пример #12
0
        public void RevertDatesIfNeeded_FirstDateGreaterThanSecond_Revert()
        {
            DateTime date1 = new DateTime(2018, 4, 16);
            DateTime date2 = new DateTime(2006, 2, 2);

            DateTimeManager.RevertDatesIfNeeded(ref date1, ref date2);

            Assert.IsTrue(date1 <= date2);
        }
Пример #13
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         return;
     }
     Destroy(gameObject);
 }
Пример #14
0
        public void RevertDatesIfNeeded_FirstDateLessThanSecond_LeaveAsItIs()
        {
            DateTime date1 = new DateTime(2000, 12, 1);
            DateTime date2 = new DateTime(2000, 12, 20);

            DateTimeManager.RevertDatesIfNeeded(ref date1, ref date2);

            Assert.IsTrue(date1 <= date2);
        }
Пример #15
0
    void Start()
    {
        gameStatManager = GameObject.Find("GameStatManager").GetComponent <GameStatManager>();
        dateTimeManager = GameObject.Find("Interface/DateContainer").GetComponent <DateTimeManager>();

        okButton = newPanel.transform.Find("Button").GetComponent <Button>();
        okButton.onClick.AddListener(ClosePanel);
        badgePos = newPanel.transform.Find("BadgePlacer");
        newPanel.SetActive(false);
    }
Пример #16
0
        public void CalculateDates_CompletelyDifferentDates_DisplayInFull()
        {
            DateTime date1 = new DateTime(1999, 1, 10);
            DateTime date2 = new DateTime(2011, 12, 25);

            string value = DateTimeManager.CalculateDates(date1, date2);

            string expected = "10.01.1999 - 25.12.2011";

            Assert.AreEqual(value, expected);
        }
Пример #17
0
        public void CalculateDates_SameYear_CutYear()
        {
            DateTime date1 = new DateTime(2000, 10, 1);
            DateTime date2 = new DateTime(2000, 12, 20);

            string value = DateTimeManager.CalculateDates(date1, date2);

            string expected = "01.10 - 20.12.2000";

            Assert.AreEqual(value, expected);
        }
Пример #18
0
        public void CalculateDates_SameYearAndMonth_CutYearAndMonth()
        {
            DateTime date1 = new DateTime(1994, 2, 5);
            DateTime date2 = new DateTime(1994, 2, 8);

            string value = DateTimeManager.CalculateDates(date1, date2);

            string expected = "05 - 08.02.1994";

            Assert.AreEqual(value, expected);
        }
Пример #19
0
        public void CalculateReportingDate_Expected_ReportingDate(string beginingOfDay, string dateNow, string reportingDay)
        {
            // Arrange
            TimeSpan beginingOfDayTimeSpan = TimeSpan.Parse(beginingOfDay, CultureInfo.InvariantCulture);
            DateTime now            = DateTime.Parse(dateNow, CultureInfo.InvariantCulture);
            DateTime expextedResult = DateTime.Parse(reportingDay, CultureInfo.InvariantCulture);

            // Act
            DateTime actualResult = DateTimeManager.CalculateReportingDate(now, beginingOfDayTimeSpan);

            // Assert
            Assert.AreEqual(actualResult, expextedResult);
        }
Пример #20
0
        private void Debugger_Tick(object sender, EventArgs e)
        {
            DateTimeManager.DebugThisFrame();

            TimeScaleManager.DebugThisFrame();

            if (Game.GameTime > fpsUpdateTimer)
            {
                currentFps     = Convert.ToInt32(Game.FPS);
                fpsUpdateTimer = Game.GameTime + 100;
            }

            Debug.DrawText(new GTA.Math.Vector2(0.49f, 0.03f), "FPS: " + currentFps.ToString("0"));
        }
Пример #21
0
        public void EnrichData_Expected_FirstTimePeriodIsBeginingOfTheDay()
        {
            // Arrange
            var powerTrade = new Fixture().Create <PowerTrade>();

            powerTrade.Date = powerTrade.Date.Date;

            // Act
            var result = DateTimeManager.EnrichDataWithDates(powerTrade);

            // Assert
            TimeSpan.TryParse(result.First().Period, out TimeSpan firstTimePeriod);
            var beginingOfDayUtc = DateTimeManager.CalculateBegginingOfReportingDayUtc(powerTrade.Date).TimeOfDay;

            Assert.AreEqual(firstTimePeriod, beginingOfDayUtc);
        }
        private void DrawTime()
        {
            float yOffset = -0.023f;
            float scale   = 3f;

            string time = DateTimeManager.GetTimeString();

            // scale an offset
            if (Main.configClock.Show_Seconds || !Main.configClock.Military_Time_Format)
            {
                yOffset = 0.02f;
                scale   = 1.75f;
            }

            Helpers.DrawText(new Vector2(0.5f, 0.33f + yOffset), time, true, true, scale, 238, 201, 76, alpha, font);
        }
        public static void TestChangeLoggerTest()
        {
            using (var context = new ErpContext())
            {
                var identityService = new IdentityService();
                var dateTimeManager = new DateTimeManager();
                var changesFinder   = new ChangesFinder(identityService, dateTimeManager);
                var changeLogger    = new ConsoleChangeLogger(changesFinder);

                var unitOfWork = new UnitOfWork(context, changeLogger);

                var customer = context.Customers.First();

                customer.Name1 = "Max";
                customer.Name2 = "Lustig";

                unitOfWork.Complete();
            }
        }
Пример #24
0
        private static DateTime ReadDateFromConsole()
        {
            string date = null;

            do
            {
                if (date != null)
                {
                    ConsoleManager.Write("Incorrect format!");
                    Console.ReadKey();
                }

                ConsoleManager.Write("Enter a date: ");

                date = Console.ReadLine();
            }while (!DateTimeManager.IsValidDate(date));

            return(DateTime.Parse(date, new CultureInfo("pl-PL")));
        }
Пример #25
0
        public DashBoardPage(string matric, Server server)
        {
            InitializeComponent();
            this.server         = server;
            this.matric         = matric;
            studentEventManager = new StudentEventManager(server);

            this.nameLabel.Text   = studentEventManager.GetName(matric);
            this.matricLabel.Text = matric;

            dateManager = new DateTimeManager();
            DateTime today = DateTime.Today;

            this.dateLabel.Text            = today.ToString("d") + " |";
            this.weekLabel.Text            = dateManager.CurrentAcademicWeek();
            this.academicYearSemLabel.Text = dateManager.CurrentAcademicYear();

            studentEventManager.GetStudentEventsTasks(this.myEventListView, this.myTaskListView, matric);
            studentEventManager.GetEvents(this.eventListView);
        }
Пример #26
0
        [TestCase("10/26/2014 00:00:00.000")] // Russia long day
        public void EnrichDataLongDay_Expected_LastPeriodIsNotDuplicateOfFirstPeriod(DateTime date)
        {
            // Arrange
            PowerTrade powerTrade;

            if (TimeZoneInfo.Local.IsDaylightSavingTime(date))
            {
                powerTrade = TestHelper.BuildPowerTradesCollection(1, 25, date).First();
            }
            else
            {
                powerTrade = TestHelper.BuildPowerTradesCollection(1, 24, date).First();
            }

            // Act
            var result = DateTimeManager.EnrichDataWithDates(powerTrade);

            // Assert
            Assert.AreNotEqual(result.First().Period, result.Last().Period);
        }
    void Start()
    {
        //Singleton
        dateManager = this;

        //Get other objects
        gameStatManager = GameObject.Find("GameStatManager").GetComponent <GameStatManager>();
        displayDate     = transform.Find("Date").gameObject.GetComponent <Text>();
        displayTime     = transform.Find("Time").gameObject.GetComponent <Text>();
        timeScaleImage  = transform.Find("TimeScale").gameObject.GetComponent <Image>();

        //Initialize
        dateTime = gameStatManager.GetDateTime();
        endTime  = new DateTime(2140, 01, 01);

        //Set default
        Time.timeScale        = 1;
        timeScaleImage.sprite = slow;
        counter    = 0f;
        dayCounter = 0;
    }
Пример #28
0
        public void IsValidDate_CorrectFormat_True()
        {
            bool value = DateTimeManager.IsValidDate("01.01.2012");

            Assert.IsTrue(value);
        }
Пример #29
0
        public void SetByAbsolute(string key, object content, double timer, DateTimeTypeEnum dateTimeType)
        {
            double millisecond = DateTimeManager.ToMilliseconds(timer, dateTimeType);

            SetByAbsolute(key, content, TimeSpan.FromMilliseconds(millisecond));
        }
Пример #30
0
        public void IsValidDate_IncorrectFormat_False()
        {
            bool value = DateTimeManager.IsValidDate("21.20.2001");

            Assert.IsFalse(value);
        }