Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[3.133.82.244] |
|
Сообщ.
#1
,
|
|
|
есть такой код) я пометил то что не могу понять
protected void Page_Load(object sender, EventArgs args) { if (!this.IsPostBack) { //Reserve a spot in Session for the UploadDetail object this.Session["UploadDetail"] = new UploadDetail { IsReady = false }; // ВОТ ТУТ непонятно, что такое UploadDetail(почему он и в кавычках и без) LoadUploadedFiles(ref gvNewFiles); // что такое { IsReady = false }? } } [System.Web.Services.WebMethod] // ТУТ ТОЖЕ непонятно [System.Web.Script.Services.ScriptMethod] // ТУТ ТОЖЕ непонятно public static object GetUploadStatus() // что это? { //Get the length of the file on disk and divide that by the length of the stream UploadDetail info = (UploadDetail)HttpContext.Current.Session["UploadDetail"]; // ТУТ ТОЖЕ непонятно я так понимаю создается // info типа UploadDetail if (info != null && info.IsReady) // а дальше разберусь после того как пойму то что выше. { int soFar = info.UploadedLength; int total = info.ContentLength; int percentComplete = (int)Math.Ceiling((double)soFar / (double)total * 100); string message = "Uploading..."; string fileName = string.Format("{0}", info.FileName); string downloadBytes = string.Format("{0} of {1} Bytes", soFar, total); return new { percentComplete = percentComplete, message = message, fileName = fileName, downloadBytes = downloadBytes }; } //Not ready yet return null; } по возможности расписать подробнее чтоб нагляднее было, вопрос переноса кода на vb вот с этим в обще попа public static object GetUploadStatus() что это такое? функция, класс, структура, переменная , [System.Web.Services.WebMethod] и [System.Web.Script.Services.ScriptMethod] я так понимаю к public static object GetUploadStatus() относится? что это? |
Сообщ.
#2
,
|
|
|
Цитата -=VIRUS=- @ // ВОТ ТУТ непонятно, что такое UploadDetail(почему он и в кавычках и без) без кавычек - тип, в кавычках - ключ-строка, по которой ссылка на объект типа UploadDetail помещается в объект Session // что такое { IsReady = false }? установление свойства IsReady для создаваемого объекта // ТУТ ТОЖЕ непонятно http://msdn.microsoft.com/ru-ru/library/sy...dattribute.aspx // ТУТ ТОЖЕ непонятно http://msdn.microsoft.com/ru-ru/library/sy...dattribute.aspx // что это? метод, который вызывается из javascript // ТУТ ТОЖЕ непонятно я так понимаю создается из объекта Session по ключу-строке достается созданный ранее объект |
Сообщ.
#3
,
|
|
|
Цитата -=VIRUS=- @ [System.Web.Services.WebMethod] и [System.Web.Script.Services.ScriptMethod] я так понимаю к public static object GetUploadStatus() относится? что это? это атрибуты метода Protected Sub Page_Load(sender As Object, args As EventArgs) If Not Me.IsPostBack Then 'Reserve a spot in Session for the UploadDetail object Me.Session("UploadDetail") = New UploadDetail() With { _ Key .IsReady = False _ } ' ВОТ ТУТ непонятно, что такое UploadDetail(почему он и в кавычках и без) ' что такое { IsReady = false }? LoadUploadedFiles(gvNewFiles) End If End Sub ' ТУТ ТОЖЕ непонятно ' ТУТ ТОЖЕ непонятно <System.Web.Services.WebMethod> _ <System.Web.Script.Services.ScriptMethod> _ Public Shared Function GetUploadStatus() As Object ' что это? 'Get the length of the file on disk and divide that by the length of the stream Dim info As UploadDetail = DirectCast(HttpContext.Current.Session("UploadDetail"), UploadDetail) ' ТУТ ТОЖЕ непонятно я так понимаю создается ' info типа UploadDetail If info IsNot Nothing AndAlso info.IsReady Then ' а дальше разберусь после того как пойму то что выше. Dim soFar As Integer = info.UploadedLength Dim total As Integer = info.ContentLength Dim percentComplete As Integer = CInt(Math.Ceiling(CDbl(soFar) / CDbl(total) * 100)) Dim message As String = "Uploading..." Dim fileName As String = String.Format("{0}", info.FileName) Dim downloadBytes As String = String.Format("{0} of {1} Bytes", soFar, total) Return New With { _ Key .percentComplete = percentComplete, _ Key .message = message, _ Key .fileName = fileName, _ Key .downloadBytes = downloadBytes _ } End If 'Not ready yet Return Nothing End Function |
Сообщ.
#4
,
|
|
|
о! ща заценю, заработает поставлю 2 плюсика
Добавлено Вот тут все ок! первый плюсик) Return New With { _ Key .percentComplete = percentComplete, _ Key .message = message, _ Key .fileName = fileName, _ Key .downloadBytes = downloadBytes _ } вот тут подчеркивает Key (значение должно начинаться с ".") Me.Session("UploadDetail") = New UploadDetail() With { _ Key .IsReady = False _ } вот класс: Public Class UploadDetail Public IsReady As Boolean Public ContentLength As Integer Public UploadedLength As Integer Public FileName As String End Class |