Click here to Skip to main content
15,887,175 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionfpassing asp.net field Pin
dcof1-Nov-11 12:36
dcof1-Nov-11 12:36 
AnswerRe: fpassing asp.net field Pin
Not Active1-Nov-11 13:51
mentorNot Active1-Nov-11 13:51 
GeneralRe: fpassing asp.net field Pin
dcof1-Nov-11 17:47
dcof1-Nov-11 17:47 
GeneralRe: fpassing asp.net field Pin
Brij1-Nov-11 21:48
mentorBrij1-Nov-11 21:48 
GeneralRe: fpassing asp.net field Pin
Not Active2-Nov-11 2:17
mentorNot Active2-Nov-11 2:17 
Questiontable control asp.net 2010 Pin
classy_dog1-Nov-11 9:27
classy_dog1-Nov-11 9:27 
AnswerRe: table control asp.net 2010 Pin
Dennis E White1-Nov-11 12:01
professionalDennis E White1-Nov-11 12:01 
QuestionAsync Report MVC3 Pin
eddieangel1-Nov-11 7:00
eddieangel1-Nov-11 7:00 
I have a page of records and on this page there is a link that allows the user to run a report asynchronously in a separate window. Here is the relevant code:

Link in view:
<p>
    @Html.ActionLink("Create New", "Create", new { claimId = ViewBag.claimId })
    @Html.ActionLink("PDF Print", "PhotoBook", new { claimId = ViewBag.claimId }, new { target = "_blank" })
</p>


Photobook action in controller:
public ActionResult PhotoBook(int claimId, int? defectId, int? propertyId, int? locationId, int? categoryId)
        {
            var observations = db.Observations.Where(o => o.claimId == claimId);

            if (defectId != null)
                observations = observations.Where(o => o.defectId == defectId);

            if (categoryId != null)
            {
                ViewBag.defectId = new SelectList(db.Defects.Where(d => d.categoryId == categoryId), "id", "displayId", defectId == null ? null : db.Defects.Where(d => d.id == defectId));
                observations = observations.Where(o => o.Defect.categoryId == categoryId);
            }
            else
            {
                ViewBag.defectId = new SelectList(db.Defects, "id", "displayId", defectId == null ? null : db.Defects.Where(d => d.id == defectId).FirstOrDefault());
            }

            if (propertyId != null)
                observations = observations.Where(o => o.propertyId == propertyId);

            if (locationId != null)
                observations = observations.Where(o => o.locationId == locationId);

            return RedirectToAction("Index", "Report", new { observations = observations });
        }


Index action in Report controller:
public void IndexAsync(IEnumerable<Observation> observations)
        {
            AsyncManager.OutstandingOperations.Increment();
            photoBook myReport = new photoBook();
            myReport.DataSource = observations;
            string fileName = "Photobook " + DateTime.Now.ToString("yyyyMMddHHmm") + ".pdf";
            AsyncManager.Parameters["fileName"] = fileName;

            ReportProcessor myProcessor = new ReportProcessor();
            RenderingResult result = myProcessor.RenderReport("PDF", myReport, null);

            FileStream fs = new FileStream(Server.MapPath("~/Reports/" + fileName), FileMode.Create);
            fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            fs.Flush();
            fs.Close();
            myReport.Dispose();
            fs.Dispose();
            AsyncManager.OutstandingOperations.Decrement();
        }


public ViewResult IndexCompleted(string fileName)
{
    ViewBag.fileName = fileName;
    return View();
}


Now my question is twofold:

1. Is passing the Observations collection around terribly inefficient? I could pass the query information to build the collection as opposed to the entire IEnumerable collection.
2. I want the report page to indicate to the user that something is happening before it starts processing the report. Can I return a view to the user while the IndexAsync is processing?

Cheers, --EA
QuestionNeeded Code of changing dropdownlist Pin
Raghu1630-Oct-11 19:28
Raghu1630-Oct-11 19:28 
AnswerRe: Needed Code of changing dropdownlist Pin
Anurag Gandhi30-Oct-11 22:47
professionalAnurag Gandhi30-Oct-11 22:47 
QuestionCan't see my site's flash in an iframe tag Pin
benams30-Oct-11 6:37
benams30-Oct-11 6:37 
QuestionSubmitChanges is not working Pin
classy_dog29-Oct-11 8:17
classy_dog29-Oct-11 8:17 
AnswerRe: SubmitChanges is not working Pin
Richard MacCutchan29-Oct-11 22:38
mveRichard MacCutchan29-Oct-11 22:38 
GeneralRe: SubmitChanges is not working Pin
classy_dog30-Oct-11 11:06
classy_dog30-Oct-11 11:06 
GeneralRe: SubmitChanges is not working Pin
Richard MacCutchan30-Oct-11 23:36
mveRichard MacCutchan30-Oct-11 23:36 
AnswerRe: SubmitChanges is not working Pin
phil.o29-Oct-11 23:54
professionalphil.o29-Oct-11 23:54 
GeneralRe: SubmitChanges is not working Pin
classy_dog30-Oct-11 11:08
classy_dog30-Oct-11 11:08 
GeneralRe: SubmitChanges is not working Pin
phil.o30-Oct-11 23:18
professionalphil.o30-Oct-11 23:18 
AnswerRe: SubmitChanges is not working Pin
oujeboland30-Oct-11 7:03
oujeboland30-Oct-11 7:03 
GeneralRe: SubmitChanges is not working Pin
classy_dog30-Oct-11 11:09
classy_dog30-Oct-11 11:09 
Questionvalidation control final? Pin
classy_dog29-Oct-11 8:05
classy_dog29-Oct-11 8:05 
AnswerRe: validation control final? Pin
Brij1-Nov-11 1:34
mentorBrij1-Nov-11 1:34 
QuestionHow to implement an automatic task in asp.net Pin
TRAORE cheickna29-Oct-11 2:40
TRAORE cheickna29-Oct-11 2:40 
AnswerRe: How to implement an automatic task in asp.net Pin
Philippe Mori29-Oct-11 3:15
Philippe Mori29-Oct-11 3:15 
GeneralRe: How to implement an automatic task in asp.net Pin
TRAORE cheickna29-Oct-11 3:41
TRAORE cheickna29-Oct-11 3:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.