public override async ValueTask <bool> MoveNextAsync() { if (entity == null) { if (await TryGetResponse($"/v1/user/bookmarks/illust?user_id={uid}&restrict=public&filter=for_ios") is (true, var model)) { entity = model; UpdateEnumerator(); } else { throw new QueryNotRespondingException(); } Enumerable.ReportRequestedPages(); }
public async IAsyncEnumerable <Illustration> MoveNextAsync() { var query = $"/v1/user/bookmarks/illust?user_id={uid}&restrict=public&filter=for_ios"; var model = (await HttpClientFactory.AppApiHttpClient.GetStringAsync(context == null ? query : context.NextUrl)).FromJson <GalleryResponse>(); if (context == null && model.Illusts.IsNullOrEmpty()) { throw new QueryNotRespondingException(); } context = model; foreach (var contextIllust in context.Illusts.Where(contextIllust => contextIllust != null)) { yield return(contextIllust.Parse()); } }
public async void LoadDataFromServer() { if (IsBusy) { return; } IsBusy = true; ImagesList.Clear(); StatusText = "Getting new data..."; var dialog = UserDialogs.Instance; dialog.ShowLoading("Loading..."); GalleryResponse response = await dataService.getAllImages(SelectedItemId, SelectedItemsType); if (response != null) { if (response.status.Equals("success")) { ImagesList = new ObservableCollection <GalleryItem>(response.data); ImagesList.OrderByDescending(x => x.img_link); } if (ImagesList.Count() > 0) { IsHasDataFlag = false; } else { StatusText = "No data is available"; IsHasDataFlag = true; } dialog.HideLoading(); } else { StatusText = "Service is unavailable"; dialog.HideLoading(); } IsBusy = false; }
public static SingleGalleryViewModel Generate(GalleryResponse galleryResponse) { var outList = new List <SingleGalleryImageViewModel>(); int totalSizeOfRow = 0, indexer = 0; var rowFormat = RandomHelpers.GetRandomRowFormat; foreach (var galleryItem in galleryResponse.GalleryItems) { if (totalSizeOfRow == 12) { totalSizeOfRow = 0; indexer = 0; rowFormat = RandomHelpers.GetRandomRowFormat; } var size = rowFormat[indexer]; var vm = new SingleGalleryImageViewModel { Id = galleryItem.Id, AppPath = galleryItem.AppPath, GalleryIndex = galleryItem.IndexGlobal ?? -1, IndexGlobal = galleryItem.IndexGlobal ?? -1, LargeScreenSize = size, PopUpDelay = 100 * indexer, MediaType = galleryItem.MediaType }; outList.Add(vm); totalSizeOfRow += size; indexer++; } return(new SingleGalleryViewModel { Id = galleryResponse.Id, Images = outList, GalleryTitle = galleryResponse.GalleryName }); }
public static GalleryResult ToGalleryResult(this GalleryResponse response) { return(new() { Id = response.Id, MediaId = response.MediaId, Title = new GalleryTitleResult { Japanese = response.Title.Japanese, English = response.Title.English, Pretty = response.Title.Pretty }, Images = response.Images.Images.ToGalleryImageResult(), Artists = response.Tags.GetTagByGroup("artist"), Parodies = response.Tags.GetTagByGroup("parody"), Characters = response.Tags.GetTagByGroup("character"), Tags = response.Tags.GetTagByGroup("tag"), Categories = response.Tags.GetTagByGroup("category"), Languages = response.Tags.GetTagByGroup("language"), TotalPages = response.TotalPages }); }
public HttpResponseMessage Get(string securityToken, int schoolId, int pageNumber, int pageSize) { var response = new GalleryResponse { Status = "OK", SchoolId = schoolId }; if (IsValid(securityToken)) { var svc = new GalleryService(this._dbContext); int count = 0; response.Images = svc.Get(schoolId, pageNumber, pageSize, out count); response.ImageCount = count; } else { response = new GalleryResponse { Status = "Error", ErrorCode = "ERR001", ErrorMessage = "Invalide security token" }; } return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public GalleryResponse AddGalery(Stream galleryStream) { GalleryResponse response = new GalleryResponse(); objResponse Response = new objResponse(); GalleryManager objGalManager = new GalleryManager(); Galleries objGallery = new Galleries(); string auth_token = ""; try { var parser = new MultipartFormDataParser(galleryStream); // Parse all the fields by name var token1 = parser.GetParameterValue("authentication_Token"); var token2 = parser.GetParameterValue("authentication_token"); var gName = parser.GetParameterValue("name"); var gType = parser.GetParameterValue("gallery_Type"); var gPrice = parser.GetParameterValue("price"); var gPermission = parser.GetParameterValue("gallery_Permission"); // Check Whether Req is null or not if ((token1 == null && token2 == null) || gName == null || gType == null) { response.header.ErrorCode = 500; response.header.ErrorMessage = "Bad Request"; response.gallery = null; return(response); } // Now Enter GalleryDetails in db objGallery.name = gName; objGallery.gallery_Type = gType; objGallery.price = gPrice; if (gPermission == "") { objGallery.gallery_Permission = "Public"; } else { objGallery.gallery_Permission = gPermission; } objGallery.productIdentifier = "com.nexomni.talkblox.talkblox" + Regex.Replace(gName, "[^a-zA-Z0-9_]+", ""); if (gPrice == "") { objGallery.isBuy = false; } else { objGallery.isBuy = true; } if (token1 != null) { auth_token = token1; } if (token2 != null) { auth_token = token2; } Response = objGalManager.AddGallery(objGallery, auth_token); if (Response.ErrorCode == 0) { if (Response.ErrorMessage != "Invalid Authentication Token") { // Now Save All Media File On Server objGallery.id = Response.ResponseData.Tables[0].Rows[0][0].ToString(); // Files are in list parse and save them one by one foreach (var file in parser.Files) { var temp = file.FileName.Split('.'); string filename = Guid.NewGuid() + "." + temp[temp.Length - 1]; Stream data = file.Data; string ThumbnailName = file.FileName; if (gType == "sound") { UploadAsStream(data, HostingEnvironment.MapPath(ConfigurationManager.AppSettings["galAudioUploadDirectory"].ToString()) + filename); } else if (gType == "video") { UploadAsStream(data, HostingEnvironment.MapPath(ConfigurationManager.AppSettings["galVideoUploadDirectory"].ToString()) + filename); string fpath = HostingEnvironment.MapPath(ConfigurationManager.AppSettings["galVideoUploadDirectory"].ToString()) + filename; string thpath = HostingEnvironment.MapPath(ConfigurationManager.AppSettings["galThumbUploadDirectory"].ToString()) + Guid.NewGuid() + "." + "jpg"; genreateThumb(fpath, thpath); } else if (gType == "image") { UploadAsStream(data, HostingEnvironment.MapPath(ConfigurationManager.AppSettings["galImageUploadDirectory"].ToString()) + filename); } else if (gType == "backgroundimage") { UploadAsStream(data, HostingEnvironment.MapPath(ConfigurationManager.AppSettings["galBackImageUploadDirectory"].ToString()) + filename); } else { UploadAsStream(data, HostingEnvironment.MapPath(ConfigurationManager.AppSettings["galSoundTrackUploadDirectory"].ToString()) + filename); } Response = objGalManager.AddGalleryMedia(objGallery.id, filename, ThumbnailName, gType); if (Response.ErrorCode == 0) { response.header.ErrorCode = 200; response.header.ErrorMessage = "Success"; response.gallery.id = objGallery.id; response.gallery.name = objGallery.name; response.gallery.galleryType = objGallery.gallery_Type; } else { response.header.ErrorCode = 501; response.header.ErrorMessage = "An Error Occured In Uploading Media , Please Try Again"; response.gallery = null; return(response); } } response.header.ErrorCode = 200; response.header.ErrorMessage = "Success"; response.gallery.id = objGallery.id; response.gallery.name = objGallery.name; response.gallery.galleryType = objGallery.gallery_Type; // response.response.TimeStamp = DateTime.Now.ToUniversalTime().ToString("u"); } else { response.header.ErrorCode = 501; response.header.ErrorMessage = Response.ErrorMessage; response.gallery = null; return(response); } } else { response.header.ErrorCode = 501; response.header.ErrorMessage = "An Error Occured , Please Try Again"; response.gallery = null; return(response); } } catch (Exception ex) { response.header.ErrorCode = 501; response.header.ErrorMessage = "Error Occured : " + ex.Message.ToString(); response.gallery = null; return(response); } return(response); }