private bool IsValidTime(long?time)
        {
            bool valid = true;

            try
            {
                RestApiCommon.ConvertUsecsToDateTime((long)time);
            }
            catch
            {
                valid = false;
            }
            return(valid);
        }
Esempio n. 2
0
        private bool IsValidPointInTime(long?restoreTimeSecs, long?startTime, long sourceId, Model.ProtectionJob job)
        {
            // identifying range from preceeding day
            System.DateTime startDate = RestApiCommon.ConvertUsecsToDateTime((long)startTime);
            startDate = startDate.AddDays(-1);
            long startTimeInUsec = RestApiCommon.ConvertDateTimeToUsecs(startDate);

            var pointsInTimeRange = new Model.RestorePointsForTimeRangeParam
            {
                EndTimeUsecs       = RestApiCommon.ConvertDateTimeToUsecs(System.DateTime.Now),
                Environment        = Model.RestorePointsForTimeRangeParam.EnvironmentEnum.KSQL,
                JobUids            = new List <Model.UniversalId>(),
                ProtectionSourceId = sourceId,
                StartTimeUsecs     = startTimeInUsec
            };

            pointsInTimeRange.JobUids.Add(job.Uid);

            var  pointsForTimeRangeUrl = $"/public/restore/pointsForTimeRange";
            var  timeRangeResult       = Session.ApiClient.Post <Model.RestorePointsForTimeRange>(pointsForTimeRangeUrl, pointsInTimeRange);
            bool foundPointInTime      = false;

            if (null != timeRangeResult.TimeRanges)
            {
                foreach (var item in timeRangeResult.TimeRanges)
                {
                    var restoreTimeUsecs = restoreTimeSecs * 1000 * 1000;
                    if (item.StartTimeUsecs < restoreTimeUsecs && restoreTimeUsecs < item.EndTimeUsecs)
                    {
                        foundPointInTime = true;
                        break;
                    }
                }
            }
            return(foundPointInTime);
        }
Esempio n. 3
0
        protected override void ProcessRecord()
        {
            DateTime result = RestApiCommon.ConvertUsecsToDateTime(Usecs);

            WriteObject(result);
        }