Windows phone app with many image - best way? - c#

In my application, there are about 300 images(.jpg). These images are displayed to the user. I now choose between two options loaded:
Loading of resources in isolated storage.
Working with resource files directly.
Which of these options is better ?

If you are using these images as a static data means these 300 images are kind of dataset for your application then second option Working with resource files directly is fine. There is no need for isolated storage. It is typically used for data that is generated in your app or downloaded from server and you want to use it for future.
Hope it helps you.

Related

How to insert images into database using asp.net core mvc 6?

I'm trying to create a website. But i don't know how to upload photos into database. All information is outdated
If the size of your images are small, then you can convert it to base64, and store in your DB.
If the size is very larger, then you will face some issue.
The correct way to save pictures and Images
If the images are static resouce, and you can store it under wwwroot. Due to it will not often update, you can save it here.
If the images are create by web user, you also can follow the first suggestion, and create folder like wwwroot/userdata/userid/, and the path like wwwroot/userdata/userid/xx.jpg. The main disadvantage is that it is not conducive to maintenance.
The disadvantage is that the published files under wwwroot will become larger and larger, and the pressure on the web server will also increase, when many users access operations.
The best choice you can store images to storage account or other third party service.
In this way, our database only needs to save the path. Conducive to the maintenance of images data. There will be no stress on the web server during access and operation.

c# uwp read csv from web

I am trying to make an app that make use of open data.
The data I try to read out is in a CSV format (and is about 40mb big).
I have 2 problems I can't solve.
First I having difficulties to read the file from the web.
I already read on MSDN how to read files asynchrome but it's all about local files. I want to make a list of objects. Each line (except the first line) contains all props for 1 object
Secondly when I finally managed to read the file, is there a way to save it's data and read it somehow the next time? Because 40mb is pretty big to re-download each time you open the app and it takes a lot of time.
I was wondering if it is possible that when I read the the file on the web again, it will only read and at the new lines.
I am a newbie in UWP (c#) applications, so my apologies for the questions.
Thanks in advance.
There are two APIs you can use to download a file. One is HttpClient, described here on MSDN Documentation and in a UWP sample here. This class is usually recommended for smaller files and smaller data, but can easily handler larger files as well. Its disadvantage is, that when the user closes the app, the file will stop downloading.
The alternative is BackgroundDownloader, again here on MSDN and here in UWP samples. This class is usually recommended for downloading larger files and data, as it automatically perfroms the download in the background so the download will continue even when the app is closed.
To store your files, you can use the ApplicationData.Current.LocalFolder. This is a special folder provided to you by the system for storage of application files. You have read/write access to this folder and you can not only store your files here, but even create subfolder structure using UWP StorageFile and StorageFolder APIs. More about this is on MSDN.

File upload / did I make a mistake choosing vb.net instead of php?

for the past 3 days I've been trying to create an upload system for multiple files, possibly large, with progress bars.
I've been roaming the web relentlessly for the past few days, and I can say, I am now familiar with most difficulties.
sadly, all the solutions I've found online are not written c# or vbscript, in fact most of them are written in php.
I wouldn't mind switching to another language but the entire website is written in vb.net and for the sake of coherence I thought it might be best to keep with it.
File uploads:
Problem 1 - progress bar:
I understand file uploads will not work with ajax, since the ajax response will only occur after the file had completed its upload.
I understand there is a solution using iFrames but I cannot seem to find any online examples (preferably using vb.net or c#).
I understand there is another alternative using flash. how???
I also understand people are mostly against using iframes but I can't find what the reason might be.
Problem 2 - Multiple Files:
I can have multiple file support with HTML5. great, but IE doesn't support it? well... IE users will just have to upload one file at a time.
Problem 3 - Large files:
how?
I heard something about chunking, and blobs, but these are still just random gibberish words for me. can somebody explain, the meaning and the implementation?
references to reading material are much appreciated even though, if it's on the web, I've probably already read it in my search for my solution.
#DevlshOne has a decent thread with some good information.
Here are the three basic requirements for what I did:
Create Silverlight app for clientside access and upload control. (use app of your choice)
Create an HttpHandler to receive the data in chunks and manage requests.
Create the database backend to handle the files.
Silverlight worked well because I was already in VB (ASP.NET). When used in-browser, as opposed to out-of-browser, the ASP.NET session was shared with Silverlight, so there was no need to have additional security/login measures. Silverlight also allowed me to limit what file types could be selected and allow the user to select multiple files from the same folder.
The Silverlight app grabs the files selected by the user, displays them for editing of certain properties, and then begins the upload when the user clicks the 'upload' button. This sets off a number of threads that each upload chunks of data to the httphandler. The HttpHandler and Silverlight app send and receive in chunks, with the HttpHandler always sending an OK or ERROR message when the request has been processed for the uploaded chunk.
Our specific implementation of file uploading also required some database properties (fields) to be filled out by the user, so we also had inputs for those properties and uploaded them to the server with the file data.
An in-browser Silverlight app can also have parameters passed into it through the html, so I do this with settings like 'max chunk size' or 'max thread count'. I can change the setting in the database and have it apply to all users.
The database backend is basically a few stored procedures (insert your data management preference here) that control the flow of the logic. One table holds completed files (no file data), and a second holds the temp files that are in progress of being uploaded. One stored procedure initiates a new file record in the temp table and processes additional chunk uploads, and another controls the migration of the completely uploaded file from the temp table to the completed table. (A piece of VB code in the HttpHandler migrates the actual binary file data from the temp table to a physical file.)
This seems pretty complex, but the most difficult part would be the interaction with the handler and passing the chunks around (response/requests, uploading successive chunks, etc.). I left out a lot of information, but this is the basic implementation.

Place to save playlist in music application after exit

I try to create music application and now I am in place where after exit from app I want to save somewhere my playlist to when reopen I have my songs in app.
Where application like winamp save that information ?
You can use Isolated storage. This way is quite easy and transparent. Then you can put some sort of XML into your Isolated storage.
Or you can use some sort of in-proc database engines to store your settings. I would recommend using SQL Server Compact as it is quite natural to use it in .NET.
So you have two options. If you have little amount of information to store (playlist only), I would select Isolated Storage. And when your application grows and settings become more complicated you could switch to SQL Server Compact.
You can use the Isolated Storage API to read and write files specific to your application under the user's profile directory. You can store the playlist in a file in any format you choose; using .NET serialization would be quickest, using XML or JSON will let you arbitrarily customise the output.
Take a look at the Isolated Storage feature, see Introduction to Isolated Storage
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MyApplication")
Winamp save the last used playlist in this directory
C:\Users\<username>\AppData\Roaming\Winamp
As for your application, I'd suggest that you use the Isolated Storage API
You could use Application settings which are stored in the user's profile folder.
You can save in a text file or an embedded database like SQLite.
I dont know how winamp does this, but you can do it in many ways. I would create a xml file, or save it in application settings like Darin Dimitrov says it. with the content i need and save it on windows close event. Open it on application start to "restore" application state.

Most efficient data storage

I need to transform/convert/process TransXchange data dump to reduce the size of data as some of the xml files can be up to 400 MB. I have the following options:
Sqlite database
CSV files
Binary Serialization
?
What is the best method of reducing the file sizes so that they would be feasible for use in a Windows Phone 7 application?
EDIT: I am going to create journey planning application that will allow users to specify source and destination. The application will then present the available services. In down under we have spotty mobile broadband coverage therefore I am aiming to have offline application.
This analysis is superb for showing you the timing of serialisation: http://www.eugenedotnet.com/2010/12/windows-phone-7-serialization-comparison/
For size... It's quite easy to guess that binary is smaller than sqlite (or Sterling) which in turn is smaller than CSV
However, if you are looking at processing 400MB of data on the phone... then I'd say you are doing the wrong thing - farm the processing out to a server (to the cloud?) and just view the summary results on the phone - think "thin client".
(Off to wash my mouth out now after all those jargon words!)
The main question is what are you going to do with that data.
If you just need to store the data and files are fine then binary serialization + compression (zlib, lzo...) will work best.
CSV won't do you any good.. will probably occupy more than the XML.
Database (for example, Sqlite) is the most expensive it terms of storage but you can manage and search the data more easily.

Categories

Resources