Ejemplo n.º 1
0
 protected virtual void OnPrepareData(object sender, PostProgressPrepareDataEventArgs eventArgs)
 {
     if (this.PreapreData != null)
     {
         this.PreapreData(sender, eventArgs);
     }
 }
Ejemplo n.º 2
0
        private void ProcessUploadData()
        {
            HttpResponse response = HttpContext.Current.Response;
            HttpRequest  request  = HttpContext.Current.Request;

            try
            {
                ExceptionHelper.FalseThrow(request["postedData"].IsNotEmpty(),
                                           Translator.Translate(Define.DefaultCulture, "没有上传的数据"));

                ProcessProgress.Current.RegisterResponser(UploadProgressResponser.Instance);
                response.Write(new string(' ', 4096));

                this.ClientExtraPostedData = request.Form["clientExtraPostedData"];

                PostProgressPrepareDataEventArgs prepareDataArgs = new PostProgressPrepareDataEventArgs()
                {
                    SerializedData = request["postedData"]
                };

                OnPrepareData(this, prepareDataArgs);

                if (prepareDataArgs.DeserializedData == null)
                {
                    prepareDataArgs.DeserializedData = (IList)JSONSerializerExecute.DeserializeObject(prepareDataArgs.SerializedData);
                }

                response.Buffer       = false;
                response.BufferOutput = false;

                UploadProgressResult result = new UploadProgressResult();

                OnDoPostedData(this, new PostProgressDoPostedDataEventArgs()
                {
                    Result = result, ClientExtraPostedData = this.ClientExtraPostedData, Steps = prepareDataArgs.DeserializedData
                });

                result.Response();
            }
            catch (System.Exception ex)
            {
                response.Write(string.Format("<script type=\"text/javascript\">top.document.getElementById(\"resetInterfaceButton\").click();</script>"));

                WebUtility.ResponseShowClientErrorScriptBlock(ex.Message, ex.StackTrace,
                                                              Translator.Translate(Define.DefaultCulture, "错误"));
            }
            finally
            {
                response.End();
            }
        }