public ActionResult ExportResult(int Id)
        {
            var allResult = _examinationRepository.GetResultManagers.Where(x => x.Examination.Id == Id)
                            .OrderByDescending(x => x.StarTime)
                            .ToList();
            int i  = 0;
            var dt = new List <ResultDownload>();

            if (allResult.Any())
            {
                foreach (var data in allResult)
                {
                    if (data.EndTime != null)
                    {
                        i = i + 1;
                        var d = new ResultDownload
                        {
                            Id           = i,
                            Name         = data.MemberProfile.FullName,
                            Date         = data.StarTime.ToShortDateString(),
                            Email        = data.MemberProfile.Member.Email,
                            MobileNumber = data.MemberProfile.Member.PhoneNumber,
                            Score        = data.Remark,
                            TimeSpent    = TimeSpent(data.EndTime.ToString(), data.StarTime)
                        };
                        dt.Add(d);
                    }
                }
            }

            var gv = new GridView {
                DataSource = dt
            };

            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=result.xls");
            Response.ContentType = "application/ms-excel";
            Response.Charset     = "";
            var sw  = new StringWriter();
            var htw = new HtmlTextWriter(sw);

            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
            return(null);
        }
예제 #2
0
        private void DownDynamicUpdateFinish(bool success, string body)
        {
            ResultDownload result = new ResultDownload();

            result.success = success;
            if (success)
            {
                JSONNode node = JSONNode.Parse(body);
                result.totalSize   = node["totalSize"].AsLong;
                result.currentSize = node["currentSize"].AsLong;
            }
            else
            {
                result.message = body;
            }
            downDynamicUpdateListener(result);
        }