Sunday, June 2, 2013

Report Generating and long Operation Module Dailog

 



        ///


        /// Start Long Operation
        ///
        protected void OperationStart()
        {
            try
            {
                using (SPLongOperation longOp = new SPLongOperation(this.Page))
                {
                    ///title for loading Window
                    longOp.LeadingHTML = "Long Operation Title";
                    //Decp or Message for wait
                    longOp.TrailingHTML = "This may take few seconds.";
                    //Window Start
                    longOp.Begin();
                    //--------------------------
                    //code for long running operation is here
                    //---------------------
                    System.Threading.Thread.Sleep(99999);
                    EndOperation(longOp);
                }
            }
            catch (ThreadAbortException) { /* Thrown when redirected */}
            catch (Exception ex)
            {
                SPUtility.TransferToErrorPage(ex.ToString());
            }
        }
        ///
        /// On Operation End  Hendler Perfrom action on Operation completed
        ///
        ///
        protected void EndOperation(SPLongOperation operation)
        {
            HttpContext Currentcontext = HttpContext.Current;
            if (Currentcontext.Request.QueryString["IsDlg"] != null)
            {
                //do you work here
                Currentcontext.Response.Write("");
                Currentcontext.Response.Flush();
                Currentcontext.Response.End();
            }
            else
            {
               
                //
                string SiteURL = SPContext.Current.Web.Url;
                operation.End(SiteURL, SPRedirectFlags.CheckUrl, context, string.Empty);
            }
        }

share this post
Share to Facebook Share to Twitter Share to Google+ Share to Stumble Upon Share to Evernote Share to Blogger Share to Email Share to Yahoo Messenger More...

0 comments: