Beispiel #1
0
        public QueryResult<SyncJobItem> GetJobItems(SyncJobItemQuery query)
        {
            var result = _repo.GetJobItems(query);

            if (query.AddMetadata)
            {
                result.Items.ForEach(FillMetadata);
            }

            return result;
        }
Beispiel #2
0
 public QueryResult<SyncedItemProgress> GetSyncedItemProgresses(SyncJobItemQuery query)
 {
     return _repo.GetSyncedItemProgresses(query);
 }
        private async Task LoadData(bool isRefresh)
        {
            try
            {
                SetProgressBar(AppResources.SysTrayGettingItems);

                var query = new SyncJobItemQuery
                {
                    JobId = SyncJob.Id,
                    TargetId = ConnectionManager.Device.DeviceId,
                    AddMetadata = true
                };
                var items = await ApiClient.GetSyncJobItems(query);

                if (items != null && !items.Items.IsNullOrEmpty())
                {
                    SyncJobItems = items.Items.Select(x => new SyncJobItemViewModel(x, NavigationService, ConnectionManager, this)).ToObservableCollection();
                }
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException("LoadData()", ex, NavigationService, Log);
            }

            SetProgressBar();
        }
Beispiel #4
0
        public QueryResult<SyncJobItem> GetJobItems(SyncJobItemQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            using (var cmd = _connection.CreateCommand())
            {
                cmd.CommandText = BaseJobItemSelectText;

                var whereClauses = new List<string>();

                if (!string.IsNullOrWhiteSpace(query.JobId))
                {
                    whereClauses.Add("JobId=@JobId");
                    cmd.Parameters.Add(cmd, "@JobId", DbType.String).Value = query.JobId;
                }
                if (!string.IsNullOrWhiteSpace(query.TargetId))
                {
                    whereClauses.Add("TargetId=@TargetId");
                    cmd.Parameters.Add(cmd, "@TargetId", DbType.String).Value = query.TargetId;
                }

                if (query.Statuses.Count > 0)
                {
                    var statuses = string.Join(",", query.Statuses.Select(i => "'" + i.ToString() + "'").ToArray());

                    whereClauses.Add(string.Format("Status in ({0})", statuses));
                }

                var whereTextWithoutPaging = whereClauses.Count == 0 ?
                    string.Empty :
                    " where " + string.Join(" AND ", whereClauses.ToArray());

                var startIndex = query.StartIndex ?? 0;
                if (startIndex > 0)
                {
                    whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM SyncJobItems ORDER BY DateCreated LIMIT {0})",
                        startIndex.ToString(_usCulture)));
                }

                if (whereClauses.Count > 0)
                {
                    cmd.CommandText += " where " + string.Join(" AND ", whereClauses.ToArray());
                }

                cmd.CommandText += " ORDER BY DateCreated";

                if (query.Limit.HasValue)
                {
                    cmd.CommandText += " LIMIT " + query.Limit.Value.ToString(_usCulture);
                }

                cmd.CommandText += "; select count (Id) from SyncJobItems" + whereTextWithoutPaging;

                var list = new List<SyncJobItem>();
                var count = 0;

                using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
                {
                    while (reader.Read())
                    {
                        list.Add(GetJobItem(reader));
                    }

                    if (reader.NextResult() && reader.Read())
                    {
                        count = reader.GetInt32(0);
                    }
                }

                return new QueryResult<SyncJobItem>()
                {
                    Items = list.ToArray(),
                    TotalRecordCount = count
                };
            }
        }
Beispiel #5
0
 public Dictionary<string, SyncedItemProgress> GetSyncedItemProgresses(SyncJobItemQuery query)
 {
     return _repo.GetSyncedItemProgresses(query);
 }
Beispiel #6
0
 public QueryResult<SyncJobItem> GetJobItems(SyncJobItemQuery query)
 {
     return _repo.GetJobItems(query);
 }