internal void AssignInitialValueAsync(List <BarcodeModel> _alerts) { try { ConstantManager.VerifiedBarcodes = _alerts; LoadOwnderAsync(); LoadAssetSizeAsync(); LoadAssetTypeAsync(); var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()); foreach (var item in _alerts) { AssetTypeModel selectedType = null; AssetSizeModel selectedSize = null; OwnerModel selectedOwner = OwnerCollection.Where(x => x.FullName == item?.Kegs?.Partners?.FirstOrDefault()?.FullName).FirstOrDefault(); if (selectedOwner != null) { RealmDb.Write(() => { selectedOwner.HasInitial = true; }); } if (item.Tags.Count > 2) { selectedType = TypeCollection.Where(x => x.AssetType == item.Tags?[2]?.Value).FirstOrDefault(); RealmDb.Write(() => { selectedType.HasInitial = true; }); } if (item.Tags.Count > 3) { selectedSize = SizeCollection.Where(x => x.AssetSize == item.Tags?[3]?.Value).FirstOrDefault(); RealmDb.Write(() => { selectedSize.HasInitial = true; }); } MaintenaceCollection.Add( new MoveMaintenanceAlertModel { UOwnerCollection = OwnerCollection.ToList(), USizeCollection = SizeCollection.ToList(), UTypeCollection = TypeCollection.ToList(), BarcodeId = item.Barcode, SelectedUOwner = selectedOwner ?? selectedOwner, SelectedUSize = selectedSize ?? selectedSize, SelectedUType = selectedType ?? selectedType }); } } catch (Exception ex) { Crashes.TrackError(ex); } }
private void initialiseSize() { int smallCount = context.orders.Where(e => e.size.Equals("Small")).Count(); int mediumCount = context.orders.Where(e => e.size.Equals("Medium")).Count(); int larkeCount = context.orders.Where(e => e.size.Equals("Large")).Count(); SizeCollection.Clear(); SizeCollection.Add(new PieSeries { Title = Application.Current.FindResource("Small") as string, Values = new ChartValues <ObservableValue> { new ObservableValue(smallCount) }, DataLabels = true }); SizeCollection.Add(new PieSeries { Title = Application.Current.FindResource("Medium") as string, Values = new ChartValues <ObservableValue> { new ObservableValue(mediumCount) }, DataLabels = true }); SizeCollection.Add(new PieSeries { Title = Application.Current.FindResource("Large") as string, Values = new ChartValues <ObservableValue> { new ObservableValue(larkeCount) }, DataLabels = true }); }
public void UploadPictureBasicTest() { Flickr f = TestData.GetAuthInstance(); f.OnUploadProgress += (sender, args) => { // Do nothing }; byte[] imageBytes = TestData.TestImageBytes; Stream s = new MemoryStream(imageBytes); s.Position = 0; string title = "Test Title"; string desc = "Test Description\nSecond Line"; string tags = "testtag1,testtag2"; string photoId = f.UploadPicture(s, "Test.jpg", title, desc, tags, false, false, false, ContentType.Other, SafetyLevel.Safe, HiddenFromSearch.Visible); try { PhotoInfo info = f.PhotosGetInfo(photoId); Assert.AreEqual(title, info.Title); Assert.AreEqual(desc, info.Description); Assert.AreEqual(2, info.Tags.Count); Assert.AreEqual("testtag1", info.Tags[0].Raw); Assert.AreEqual("testtag2", info.Tags[1].Raw); Assert.IsFalse(info.IsPublic); Assert.IsFalse(info.IsFamily); Assert.IsFalse(info.IsFriend); SizeCollection sizes = f.PhotosGetSizes(photoId); string url = sizes[sizes.Count - 1].Source; using (WebClient client = new WebClient()) { byte[] downloadBytes = client.DownloadData(url); string downloadBase64 = Convert.ToBase64String(downloadBytes); Assert.AreEqual(TestData.TestImageBase64, downloadBase64); } } finally { f.PhotosDelete(photoId); } }
public IFileSize GetSize(string name) { return(SizeCollection.Exists(name) ? SizeCollection[name] : null); }
internal static async Task DownloadFileAsync(this Flickr flickr, StorageFolder folder, string fileName, SizeCollection sizes, CancellationToken cancellationToken) { var url = sizes.OrderByDescending(s => s.Label == "Original" ? int.MaxValue : s.Width * s.Height).First().Source; var request = WebRequest.CreateHttp(url); using (cancellationToken.Register(request.Abort, false)) using (var response = await request.GetResponseAsync()) using (var responseStream = response.GetResponseStream()) using (var outStream = await folder.OpenStreamForWriteAsync(fileName, CreationCollisionOption.ReplaceExisting)) { await responseStream.CopyToAsync(outStream); } }