For example in the class file:
public class DoSomething
{
public string test { get; set; }
public string test1 { get; set; }
public int test2 { get; set; }
public int test3 { get; set; }
// others
}
Then:
if (stringProgressReport[1] == "Uploading")
{
fileuploadpercentages = (int)Math.Round(((double)obj.BytesSent) / totalBytes * 100);
fileuploadstatus = "uploading file";
}
Somehow to assign fileuploadpercentage that is int to test2 or test3 and fileuploadstatus to test1 and then in form1:
if (request.QueryString[0] == "uploadstatus")
{
switch (Youtube_Uploader.fileuploadstatus)
{
case "uploading file":
return "uploading";
case "status":
return Youtube_Uploader.fileuploadpercentages.ToString();
case "file uploaded successfully":
Youtube_Uploader.fileuploadstatus = "";
return "upload completed";
default:
return "upload unknown state";
}
Maybe not using switch case but somehow to make that it will return both test1 and test2 so if in the class file:
if (stringProgressReport[1] == "Uploading")
Return both test1 and test2 at the same time. Two parameters but return them whtnh it's "Uploading"
What i tried so far:
In the new form i added this:
public enum UploadState
{
Uploading,
InProgress,
Completed,
Unknown
}
public class UploadStatus
{
public UploadState State { get; private set; }
public int Progress { get; private set; }
public UploadStatus(UploadState state)
{
State = state;
}
public UploadStatus(int progress)
{
Progress = progress;
State = UploadState.InProgress;
}
}
Now i have in this new form two events how do i use in the events with the UploadState class ?
The first event:
public static string uploadstatus = "";
private void videosInsertRequest_ResponseReceived(Video obj)
{
uploadstatus = obj.Status.UploadStatus;
if (uploadstatus == "uploaded")
{
//fileuploadstatus = new UploadStatus("file uploaded successfully");
}
The second event:
private void videosInsertRequest_ProgressChanged(IUploadProgress obj)
{
stringProgressReport[1] = obj.Status.ToString();
if (stringProgressReport[1] == "Uploading")
{
//percentComplete = (int)Math.Round(((double)obj.BytesSent) / totalBytes * 100);
//fileuploadstatus = "status";
//fileuploadpercentages = new UploadStatus((int)Math.Round(((double)obj.BytesSent) / totalBytes * 100));
//fileuploadstatus = new UploadStatus("uploading file");// + fileuploadpercentages;
}
Also in form1 in all the return i'm getting errors:
Error 1 Cannot implicitly convert type 'Automatic_Record.Youtube_Uploader.UploadStatus' to 'string'
case "uploading file":
return new Youtube_Uploader.UploadStatus(Youtube_Uploader.UploadState.Uploading);
case "status":
return new Youtube_Uploader.UploadStatus(Youtube_Uploader.fileuploadpercentages);
case "file uploaded successfully":
Youtube_Uploader.fileuploadstatus = "";
return new Youtube_Uploader.UploadStatus(Youtube_Uploader.UploadState.Completed);
default:
return new Youtube_Uploader.UploadStatus(Youtube_Uploader.UploadState.Unknown);
On each return i'm getting same error can't convert to string.
Also in this line in form1:
return new Youtube_Uploader.UploadStatus(Youtube_Uploader.fileuploadpercentages);
I'm getting the also the error:
Error 3 Argument 1: cannot convert from 'Automatic_Record.Youtube_Uploader.UploadStatus' to 'Automatic_Record.Youtube_Uploader.UploadState'