Пример #1
0
        /// <summary>
        /// Calls the GrabzIt web service to take the screenshot and saves it to the target path provided
        /// </summary>
        /// <remarks>
        /// Warning, this is a SYNCHONOUS method and can take up to 5 minutes before a response
        /// </remarks>
        /// <param name="saveToFile">The file path that the screenshot should saved to.</param>
        /// <returns>Returns the true if it is successful otherwise it throws an exception.</returns>
        public bool SaveTo(string saveToFile)
        {
            int attempt = 0;

            while (true)
            {
                try
                {
                    GrabzItFile result = SaveTo();

                    if (result == null)
                    {
                        return(false);
                    }

                    result.Save(saveToFile);
                    break;
                }
                catch (GrabzItException e)
                {
                    throw e;
                }
                catch (Exception)
                {
                    if (attempt < 3)
                    {
                        attempt++;
                        continue;
                    }
                    throw new GrabzItException("An error occurred trying to save the capture to: " +
                                               saveToFile, ErrorCode.FileSaveError);
                }
            }
            return(true);
        }
Пример #2
0
        protected override void Process(HttpContext context, string filename, string id, string message, string customId, string format)
        {
            GrabzItClient grabzItClient = GrabzItClient.Create(ConfigurationManager.AppSettings["ApplicationKey"], ConfigurationManager.AppSettings["ApplicationSecret"]);
            GrabzItFile   file          = grabzItClient.GetResult(id);

            //Ensure that the application has the correct rights for this directory.
            file.Save(context.Server.MapPath("~/results/" + filename));
        }
Пример #3
0
        public ActionResult Handler(string filename, string id, string message, string customId, string format)
        {
            GrabzItClient grabzItClient = GrabzItClient.Create(ConfigurationManager.AppSettings["ApplicationKey"], ConfigurationManager.AppSettings["ApplicationSecret"]);
            GrabzItFile   file          = grabzItClient.GetResult(id);

            //Ensure that the application has the correct rights for this directory.
            file.Save(Server.MapPath("~/results/" + filename));

            return(null);
        }
Пример #4
0
        protected void grabzIt_ScreenShotComplete(object sender, ScreenShotEventArgs result)
        {
            if (!string.IsNullOrEmpty(result.Message))
            {
                lblMessage.Text = result.Message;
                lblMessage.Style.Clear();
                lblMessage.CssClass = "error";
            }
            GrabzItFile file = grabzItClient.GetResult(result.ID);

            //Ensure that the application has the correct rights for this directory.
            file.Save(Server.MapPath("~/results/" + result.Filename));
        }