Ejemplo n.º 1
0
        private async Task ExecuteLoadJobCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Jobs.Clear();
                var items = await JobManager.GetJobsForSingleClient(ClientId);

                if (items != null)
                {
                    foreach (var item in items)
                    {
                        Jobs.Add(item);
                    }
                }
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                IsBusy = false;
            }
        }
        private void Load( )
        {
            try
            {
                Jobs.Clear( );

                using (var cmd = DatabaseManager.CreateCommand("SELECT i.[Id], i.[Timestamp] FROM [dbo].[Lic_Index] i ORDER BY i.[Timestamp] DESC"))
                {
                    using (IDataReader reader = cmd.ExecuteReader( ))
                    {
                        while (reader.Read( ))
                        {
                            Jobs.Add(new IndexData
                            {
                                Id        = reader.GetInt64(0),
                                TimeStamp = reader.GetDateTime(1).ToLocalTime( )
                            });
                        }
                    }
                }
            }
            catch (Exception e)
            {
                PluginSettings.EventLog.WriteException(e);
            }
        }
Ejemplo n.º 3
0
        private async Task LoadJobsAsync(bool clearList = false)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            var result = await JobService.SearchAsync(SearchText, _filter?.Groups[0], _filter?.IsRemote, CurrentPage ++);

            TotalPages = result.Total_Pages;
            Device.BeginInvokeOnMainThread(() =>
            {
                if (clearList)
                {
                    Jobs.Clear();
                }
                foreach (var item in result.Results)
                {
                    Jobs.Add(new JobDetailViewModel(item));
                }
            });

            IsBusy = false;
        }
Ejemplo n.º 4
0
        private async void LoadJobs()
        {
            try
            {
                ShowBusyControl();

                Jobs.Clear();

                var jobs = (await _windowsServiceClient.GetJobsAsync())?
                           .Where(x => x != null)
                           .Where(x => SelectedJobState.HasValue ? x.State == SelectedJobState.Value : true)
                           .Where(x => SelectedDocumentType.HasValue ? x.Document.Type == SelectedDocumentType.Value : true)
                           .OrderByDescending(x => x.UpdatedOn);

                if (jobs == null)
                {
                    ShowMessageControl("Jobs cannot be loaded, the AutoPrintr service is not available. Please run the service and try again");
                    HideBusyControl();
                    return;
                }

                foreach (var job in jobs)
                {
                    Jobs.Add(job);
                }
            }
            catch (Exception e)
            {
                _loggingService?.WriteError(e);
            }
            finally
            {
                HideBusyControl();
            }
        }
Ejemplo n.º 5
0
        async Task ExecuteLoadJobsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Jobs.Clear();
                var trackers = await DataStore.GetItemsAsync(true);

                foreach (var tracker in trackers)
                {
                    Jobs.Add(tracker);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 6
0
        public void LoadJobs()
        {
            var jobs = JobService.GetAllJobs();

            Jobs.Clear();
            foreach (var v in jobs)
            {
                Jobs.Add(v);
            }
        }
        private async Task LoadJenkinsJobs()
        {
            try
            {
                if (SelectedJenkinsServer == null || SelectedView == null)
                {
                    return;
                }

                lock (_loadingJobsBusyLock)
                {
                    if (_loadingJobsBusy)
                    {
                        return;
                    }

                    _loadingJobsBusy = true;
                }

                string sourceUrl = SelectedJenkinsServer.Url;
                IEnumerable <JenkinsJob> refreshedJobs = await JenkinsDataLoader.GetJobsFromView(SelectedJenkinsServer, SelectedView);

                if (TryHandleNewJenkinsOverview(refreshedJobs, sourceUrl))
                {
                    JenkinsServersEnabled = true;
                    UpdateJobLinkedStatus();
                }

                LoadingFailed = false;
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                LoadingFailed = true;
                UIHelper.InvokeUI(() => Jobs.Clear());
                _refreshTimer.Stop();
                JenkinsServersEnabled = true;
            }
            finally
            {
                lock (_loadingJobsBusyLock)
                {
                    _loadingJobsBusy = false;

                    if (!LoadingFailed)
                    {
                        _refreshTimer.Interval = _forceRefresh ? 1 : _refreshInterval;
                        _forceRefresh          = false;
                        _refreshTimer.Start();
                    }
                }
            }
        }
Ejemplo n.º 8
0
        void AddToJobs(IEnumerable <JobItemViewModel> recentJobs, bool clear = false)
        {
            if (clear)
            {
                Jobs.Clear();
            }

            foreach (var item in recentJobs)
            {
                Jobs.Add(item);
            }

            IsLoading = false;
        }
Ejemplo n.º 9
0
        public virtual void CancelAll()
        {
            lock (SyncRoot)
            {
                if (IsDisposed)
                {
                    return;
                }

                Timer.Change(Timeout.Infinite, Timeout.Infinite);
                NextExecution = null;
                Jobs.Clear();
            }
        }
Ejemplo n.º 10
0
        private async Task ExecuteSearchCommand()
        {
            IsBusy = true;
            var jobsList = await SearchJob();

            if (Jobs.Any())
            {
                Jobs.Clear();
            }
            if (jobsList != null)
            {
                Jobs.AddRange(jobsList);
            }
            IsBusy = false;
        }
Ejemplo n.º 11
0
        async void OnUserSearch(NotifyFavoriteListUserChangedQuery qr)
        {
            var query = qr.Query;

            if (string.IsNullOrEmpty(query))
            {
                return;
            }

            Jobs.Clear();

            ShowLoadingState();

            await Task.Delay(2000);

            ShowEmptyState();
        }
Ejemplo n.º 12
0
        public void LoadJobs()
        {
            Jobs.Clear();
            FilteredJobs.Clear();

            // Pull the Job list from each Craft into Jobs list
            foreach (Craft c in Crafts)
            {
                // Alphabetize
                c.Jobs.Sort((x, y) => String.Compare(x.Name, y.Name));

                //Add to Jobs
                foreach (Job j in c.Jobs)
                {
                    Jobs.Add(j);
                }
            }
        }
Ejemplo n.º 13
0
        private void Start()
        {
            if (Active)
            {
                Cancellation.Cancel();
                Task.WaitAll(Jobs.Values.ToArray());
            }

            Jobs.Clear();
            Cancellation = new CancellationTokenSource();

            foreach (var prefix in Services.Keys)
            {
                var task = new Task(ProcessCommand, prefix);

                Jobs.Add(prefix, task);
                task.Start();
            }
        }
Ejemplo n.º 14
0
        /// <summary>开始</summary>
        public void Start()
        {
            // 如果没有指定工作者,则全局扫描
            var bs = Jobs.ToList();

            if (bs.Count == 0)
            {
                XTrace.WriteLine("没有可用工作者");
                return;
            }

            // 启动作业提供者,获取所有作业
            var prv = Provider;

            if (prv == null)
            {
                prv = Provider = new JobFileProvider();
            }
            if (prv.Schedule == null)
            {
                prv.Schedule = this;
            }
            prv.Start();

            var jobs = prv.GetJobs(bs.Select(e => e.Name).ToArray());

            if (jobs == null || jobs.Length == 0)
            {
                XTrace.WriteLine("没有可用作业");
                return;
            }

            // 输出日志
            var mode = $"定时{Period}秒";
            var msg  = $"启动任务调度引擎[{prv}],作业[{bs.Count}]项,模式:{mode}";

            XTrace.WriteLine(msg);

            // 设置日志
            foreach (var wrk in bs)
            {
                wrk.Schedule = this;
                wrk.Provider = prv;

                var job = wrk.Model = jobs.FirstOrDefault(e => e.Name == wrk.Name);
                if (job != null && job.Mode == 0)
                {
                    job.Mode = wrk.Mode;
                }

                wrk.Log = XTrace.Log;
                wrk.Start();
            }

            // 全部启动后再加入集合
            Jobs.Clear();
            Jobs.AddRange(bs);

            // 定时执行
            if (Period > 0)
            {
                _timer = new TimerX(Loop, null, 100, Period * 1000, "Job")
                {
                    Async = true
                }
            }
            ;
        }
Ejemplo n.º 15
0
 private void RefreshJobList()
 {
     Jobs.Clear();
     QuartzJsonContext.Instance.data.Jobs.ForEach(x => Jobs.Add(x));
 }
Ejemplo n.º 16
0
 public void ClearJobs()
 {
     Jobs.Clear();
 }
Ejemplo n.º 17
0
 private void RepopulateJobs()
 {
     Jobs.Clear();
     PopulateJobs();
 }
Ejemplo n.º 18
0
 public async void ClearJobsAsync()
 {
     Jobs.Clear();
     await DataStore.ClearItemsAsync();
 }
Ejemplo n.º 19
0
        public override void Reset()
        {
            Active.ForEach(req =>
            {
                req.Readback.WaitForCompletion();
                req.TextureSet.Release();
            });
            Active.Clear();

            Jobs.ForEach(job => job.Complete());
            Jobs.Clear();

            foreach (var tex in AvailableRenderTextures)
            {
                tex.Release();
            }
            ;
            AvailableRenderTextures.Clear();

            foreach (var tex in AvailableTextures)
            {
                Destroy(tex);
            }
            ;
            AvailableTextures.Clear();

            if (PointCloudBuffer != null)
            {
                PointCloudBuffer.Release();
                PointCloudBuffer = null;
            }

            if (Points.IsCreated)
            {
                Points.Dispose();
            }

            AngleStart = 0.0f;
            // Assuming center of view frustum is horizontal, find the vertical FOV (of view frustum) that can encompass the tilted Lidar FOV.
            // "MaxAngle" is half of the vertical FOV of view frustum.
            if (VerticalRayAngles.Count == 0)
            {
                MaxAngle = Mathf.Abs(CenterAngle) + FieldOfView / 2.0f;

                StartLatitudeAngle = 90.0f + MaxAngle;
                //If the Lidar is tilted up, ignore lower part of the vertical FOV.
                if (CenterAngle < 0.0f)
                {
                    StartLatitudeAngle -= MaxAngle * 2.0f - FieldOfView;
                }
                EndLatitudeAngle = StartLatitudeAngle - FieldOfView;
            }
            else
            {
                LaserCount         = VerticalRayAngles.Count;
                StartLatitudeAngle = 90.0f - VerticalRayAngles.Min();
                EndLatitudeAngle   = 90.0f - VerticalRayAngles.Max();
                FieldOfView        = StartLatitudeAngle - EndLatitudeAngle;
                MaxAngle           = Mathf.Max(StartLatitudeAngle - 90.0f, 90.0f - EndLatitudeAngle);
            }

            float startLongitudeAngle = 90.0f + HorizontalAngleLimit / 2.0f;

            SinStartLongitudeAngle = Mathf.Sin(startLongitudeAngle * Mathf.Deg2Rad);
            CosStartLongitudeAngle = Mathf.Cos(startLongitudeAngle * Mathf.Deg2Rad);

            // The MaxAngle above is the calculated at the center of the view frustum.
            // Because the scan curve for a particular laser ray is a hyperbola (intersection of a conic surface and a vertical plane),
            // the vertical FOV should be enlarged toward left and right ends.
            float startFovAngle = CalculateFovAngle(StartLatitudeAngle, startLongitudeAngle);
            float endFovAngle   = CalculateFovAngle(EndLatitudeAngle, startLongitudeAngle);

            MaxAngle = Mathf.Max(MaxAngle, Mathf.Max(startFovAngle, endFovAngle));

            // Calculate sin/cos of latitude angle of each ray.
            if (SinLatitudeAngles.IsCreated)
            {
                SinLatitudeAngles.Dispose();
            }
            if (CosLatitudeAngles.IsCreated)
            {
                CosLatitudeAngles.Dispose();
            }
            SinLatitudeAngles = new NativeArray <float>(LaserCount, Allocator.Persistent);
            CosLatitudeAngles = new NativeArray <float>(LaserCount, Allocator.Persistent);


            int totalCount = LaserCount * MeasurementsPerRotation;

            PointCloudBuffer = new ComputeBuffer(totalCount, UnsafeUtility.SizeOf <Vector4>());
            PointCloudMaterial?.SetBuffer("_PointCloud", PointCloudBuffer);

            Points = new NativeArray <Vector4>(totalCount, Allocator.Persistent);

            CurrentLaserCount = LaserCount;
            CurrentMeasurementsPerRotation = MeasurementsPerRotation;
            CurrentFieldOfView             = FieldOfView;
            CurrentVerticalRayAngles       = new List <float>(VerticalRayAngles);
            CurrentCenterAngle             = CenterAngle;
            CurrentMinDistance             = MinDistance;
            CurrentMaxDistance             = MaxDistance;

            IgnoreNewRquests = 0;

            // If VerticalRayAngles array is not provided, use uniformly distributed angles.
            if (VerticalRayAngles.Count == 0)
            {
                float deltaLatitudeAngle = FieldOfView / LaserCount;
                int   index = 0;
                float angle = StartLatitudeAngle;
                while (index < LaserCount)
                {
                    SinLatitudeAngles[index] = Mathf.Sin(angle * Mathf.Deg2Rad);
                    CosLatitudeAngles[index] = Mathf.Cos(angle * Mathf.Deg2Rad);
                    index++;
                    angle -= deltaLatitudeAngle;
                }
            }
            else
            {
                for (int index = 0; index < LaserCount; index++)
                {
                    SinLatitudeAngles[index] = Mathf.Sin((90.0f - VerticalRayAngles[index]) * Mathf.Deg2Rad);
                    CosLatitudeAngles[index] = Mathf.Cos((90.0f - VerticalRayAngles[index]) * Mathf.Deg2Rad);
                }
            }

            int   count = Mathf.CeilToInt(HorizontalAngleLimit / (360.0f / MeasurementsPerRotation));
            float deltaLongitudeAngle = (float)HorizontalAngleLimit / (float)count;

            SinDeltaLongitudeAngle = Mathf.Sin(deltaLongitudeAngle * Mathf.Deg2Rad);
            CosDeltaLongitudeAngle = Mathf.Cos(deltaLongitudeAngle * Mathf.Deg2Rad);

            // Enlarged the texture by some factors to mitigate alias.
            RenderTextureHeight = 16 * Mathf.CeilToInt(2.0f * MaxAngle * LaserCount / FieldOfView);
            RenderTextureWidth  = 8 * Mathf.CeilToInt(HorizontalAngleLimit / (360.0f / MeasurementsPerRotation));

            // View frustum size at the near plane.
            float frustumWidth  = 2 * MinDistance * Mathf.Tan(HorizontalAngleLimit / 2.0f * Mathf.Deg2Rad);
            float frustumHeight = 2 * MinDistance * Mathf.Tan(MaxAngle * Mathf.Deg2Rad);

            XScale = frustumWidth / RenderTextureWidth;
            YScale = frustumHeight / RenderTextureHeight;

            // construct custom aspect ratio projection matrix
            // math from https://www.scratchapixel.com/lessons/3d-basic-rendering/perspective-and-orthographic-projection-matrix/opengl-perspective-projection-matrix

            float v = 1.0f / Mathf.Tan(MaxAngle * Mathf.Deg2Rad);
            float h = 1.0f / Mathf.Tan(HorizontalAngleLimit * Mathf.Deg2Rad / 2.0f);
            float a = (MaxDistance + MinDistance) / (MinDistance - MaxDistance);
            float b = 2.0f * MaxDistance * MinDistance / (MinDistance - MaxDistance);

            var projection = new Matrix4x4(
                new Vector4(h, 0, 0, 0),
                new Vector4(0, v, 0, 0),
                new Vector4(0, 0, a, -1),
                new Vector4(0, 0, b, 0));

            SensorCamera.nearClipPlane    = MinDistance;
            SensorCamera.farClipPlane     = MaxDistance;
            SensorCamera.projectionMatrix = projection;
        }