public JsonResult Poll(String guid)
        {
            // Read settings from the configuration file.
            var baseAddress = ConfigurationManager.AppSettings["baseAddress"];
            String userId = Request.Form["client_id"];
            String privateKey = Request.Form["private_key"];

            var service = new GroupdocsService(baseAddress, userId, privateKey);
            try
            {
                var response = service.ListAnnotations(guid);
                var output = "";
                foreach (AnnotationInfo annotation in response.Annotations)
                {
                    var replies = "";
                    foreach (AnnotationReplyInfo reply in annotation.Replies)
                    {
                        replies += reply.UserName + ": " + reply.Message;
                    }
                    output += "Annotation Type: " + annotation.Type + " -- Replies: " + replies + "<br/>";
                }
                return Json(output, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {

                return Json("Server error or no annotations");
            }
        }
        public ActionResult Sample28()
        {
            // Check is data posted
            if (Request.HttpMethod == "POST")
            {
                //### Set variables and get POST data
                System.Collections.Hashtable result = new System.Collections.Hashtable();
                String clientId = Request.Form["clientId"];
                String privateKey = Request.Form["privateKey"];
                String fileId = Request.Form["fileId"];
                String basePath = Request.Form["basePath"];
                // Set entered data to the results list
                result.Add("clientId", clientId);
                result.Add("privateKey", privateKey);
                result.Add("fileId", fileId);
                String error = null;
                // Check is all needed fields are entered
                if (clientId == null || privateKey == null || fileId == null)
                {
                    // If not all fields entered send error message
                    error = "Please enter all parameters";
                    result.Add("error", error);
                    return View("Sample28", null, result);
                }
                else
                {
                    if (basePath == "")
                    {
                        basePath = "https://api.groupdocs.com/v2.0";
                    }
                    result.Add("basePath", basePath);
                    // Create service for Groupdocs account
                    GroupdocsService service = new GroupdocsService(basePath, clientId, privateKey);
                    // Get all annotations from document
                    Groupdocs.Api.Contract.Annotation.ListAnnotationsResult annotations = service.ListAnnotations(fileId);
                    // If annotations wasn't found return error
                    if (annotations.Annotations.Length == 0)
                    {

                        error = "File you are entered contains no annotations";
                        result.Add("error", error);
                        return View("Sample28", null, result);

                    }
                    Groupdocs.Api.Contract.Annotation.DeleteAnnotationResult delAnnot = null;
                    if (annotations.Annotations.Length != 0)
                    {
                        String message = "All annotations deleted successfully";
                        result.Add("message", message);
                        //Get annotations data
                        for (int i = 0; i < annotations.Annotations.Length; i++)
                        {
                            delAnnot = service.DeleteAnnotation(annotations.Annotations[i].Guid);

                        }
                    }
                    String url = "";
                    //iframe to prodaction server
                    if (basePath.Equals("https://api.groupdocs.com/v2.0"))
                    {
                        url = "https://apps.groupdocs.com/document-viewer/embed/" + fileId;
                        //iframe to dev server
                    }
                    else if (basePath.Equals("https://dev-api-groupdocs.dynabic.com/v2.0"))
                    {
                        url = "https://dev-apps-groupdocs.dynabic.com/document-viewer/embed/" + fileId;
                        //iframe to test server
                    }
                    else if (basePath.Equals("https://stage-api-groupdocs.dynabic.com/v2.0"))
                    {
                        url = "https://stage-api-groupdocs.dynabic.com/document-viewer/embed/" + fileId;
                    }
                    else if (basePath.Equals("http://realtime-api.groupdocs.com"))
                    {
                        url = "http://realtime-apps.groupdocs.com/document-viewer/embed/" + fileId;
                    }
                    //Set data for template
                    result.Add("url", url);
                    return View("Sample28", null, result);
                }

            }
            // If data not posted return to template for filling of necessary fields
            else
            {
                return View("Sample28");
            }
        }
        public ActionResult Sample42()
        {
            // Check is data posted
            if (Request.HttpMethod == "POST")
            {
                //### Set variables and get POST data
                System.Collections.Hashtable result = new System.Collections.Hashtable();
                String clientId = Request.Form["clientId"];
                String privateKey = Request.Form["privateKey"];
                String fileId = Request.Form["fileId"];
                String basePath = Request.Form["basePath"];
                String guid = "";
                String message = null;
                String iframe = "";
                String name = "";
                if (clientId == null || privateKey == null)
                {
                    // If not all fields entered send error message
                    message = "Please enter all parameters";
                    result.Add("error", message);
                    return View("Sample42", null, result);
                }
                else
                {
                    if (basePath == "")
                    {
                        basePath = "https://api.groupdocs.com/v2.0";
                    }
                    //Add data to template
                    result.Add("basePath", basePath);
                    result.Add("clientId", clientId);
                    result.Add("privateKey", privateKey);
                    result.Add("fileId", fileId);

                    // Create service for Groupdocs account
                    GroupdocsService service = new GroupdocsService(basePath, clientId, privateKey);
                    //Create list with URL's
                    Groupdocs.Api.Contract.Annotation.ListAnnotationsResult allAnnotations = service.ListAnnotations(fileId);
                    if (allAnnotations.Annotations.Length != 0)
                    {
                        Random rand = new Random();
                        //Create job which will get document with annotations
                        Groupdocs.Api.Contract.CreateJobResult createJob = service.CreateJob(Groupdocs.Common.JobActions.ImportAnnotations, null, false, false, "test" + rand.Next());
                        if (!createJob.JobGuid.Equals(""))
                        {
                            //Add document with annotations to new job
                            Boolean addJobDocument = service.AddJobDocument(createJob.JobGuid, fileId, "pdf", false);
                            if (addJobDocument.Equals(false))
                            {
                                message = "Add document to job is failed";
                                result.Add("error", message);
                                return View("Sample42", null, result);
                            }
                            else
                            {
                                //Run job
                                Boolean schedule = service.ScheduleJob(createJob.JobId);
                                System.Threading.Thread.Sleep(5000);
                                //Get documents from job
                                int counter = 5;
                                for (int i = 0; i < counter; i++)
                                {
                                    Groupdocs.Api.Contract.GetJobDocumentsResult getDocument = service.GetJobDocuments(createJob.JobId);
                                    if (!getDocument.JobStatus.ToString().Equals("Archived"))
                                    {
                                        System.Threading.Thread.Sleep(5000);
                                    }
                                    else
                                    {
                                        guid = getDocument.Inputs[0].Outputs[0].Guid;
                                        name = getDocument.Inputs[0].Outputs[0].Name;
                                        break;
                                    }
                                }
                                if (String.IsNullOrEmpty(guid))
                                {
                                    message = "Get document from job is failed or job is Draft";
                                    result.Add("error", message);
                                    return View("Sample42", null, result);
                                }
                                else
                                {
                                    // Generate Embed Annotation url with entered file id
                                    if (basePath.Equals("https://api.groupdocs.com/v2.0"))
                                    {
                                        iframe = "https://apps.groupdocs.com/document-annotation/embed/" + guid;
                                    }
                                    if (basePath.Equals("https://dev-api-groupdocs.dynabic.com/v2.0"))
                                    {
                                        iframe = "https://dev-apps-groupdocs.dynabic.com/document-annotation/embed/" + guid;
                                    }
                                    if (basePath.Equals("https://stage-api-groupdocs.dynabic.com/v2.0"))
                                    {
                                        iframe = "https://stage-apps-groupdocs.dynabic.com/document-annotation/embed/" + guid;
                                    }
                                    if (basePath.Equals("https://realtime-api-groupdocs.dynabic.com/v2.0"))
                                    {
                                        iframe = "https://realtime-apps-groupdocs.dynabic.com/document-annotation/embed/" + guid;
                                    }
                                    iframe = Groupdocs.Security.UrlSignature.Sign(iframe, privateKey);
                                    result.Add("iframe", iframe);
                                    // Definition of folder where to download file
                                    String downloadFolder = AppDomain.CurrentDomain.BaseDirectory + "downloads/";

                                    if (!Directory.Exists(downloadFolder))
                                    {
                                        DirectoryInfo di = Directory.CreateDirectory(downloadFolder);
                                    }

                                    //### Make a request to Storage Api for dowloading file
                                    // Download file
                                    bool file = service.DownloadFile(guid, downloadFolder + name);
                                    message = "File with annotations was downloaded to server's local folder. You can download it from ";
                                    result.Add("message", message);
                                    result.Add("name", name);
                                    return View("Sample42", null, result);
                                }
                            }
                        }
                        else
                        {
                            message = "Create job is failed";
                            result.Add("error", message);
                            return View("Sample42", null, result);
                        }
                    }
                    else
                    {
                        message = "Get all anotations is failed";
                        result.Add("error", message);
                        return View("Sample42", null, result);
                    }
                }
            }
            // If data not posted return to template for filling of necessary fields
            else
            {
                return View("Sample42");
            }
        }
        public ActionResult Sample12()
        {
            // Check is data posted
            if (Request.HttpMethod == "POST")
            {
                //### Set variables and get POST data
                System.Collections.Hashtable result = new System.Collections.Hashtable();
                String clientId = Request.Form["clientId"];
                String privateKey = Request.Form["privateKey"];
                String fileId = Request.Form["fileId"];
                String basePath = Request.Form["basePath"];
                // Set entered data to the results list
                result.Add("clientId", clientId);
                result.Add("privateKey", privateKey);
                result.Add("fileId", fileId);
                String message = null;
                // Check is all needed fields are entered
                if (clientId == null || privateKey == null || fileId == null)
                {
                    // If not all fields entered send error message
                    message = "Please enter all parameters";
                    result.Add("error", message);
                    return View("Sample12", null, result);
                }
                else
                {
                    if (basePath == "")
                    {
                        basePath = "https://api.groupdocs.com/v2.0";
                    }
                    result.Add("basePath", basePath);
                    // Create service for Groupdocs account
                    GroupdocsService service = new GroupdocsService(basePath, clientId, privateKey);
                    // Get all annotations from document
                    Groupdocs.Api.Contract.Annotation.ListAnnotationsResult annotations = service.ListAnnotations(fileId);
                    // If annotations wasn't found return error
                    if (annotations.Annotations.Length == 0)
                    {

                        message = "File GuId you are entered is wrong";
                        result.Add("error", message);
                        return View("Sample12", null, result);

                    }
                    // Create String variables for creating HTMl div with results
                    String annotation = "";
                    String replies = "";
                    String block = "";
                    //Get annotations data
                    for (int i = 0; i < annotations.Annotations.Length; i++)
                    {
                        //Get Annotation access and type
                        annotation = "Access: " + annotations.Annotations[i].Access + "<br />" + "Type: " +
                                            annotations.Annotations[i].Type + "<br />";
                        //Check if Annotation have replies
                        if (annotations.Annotations[i].Replies.Length == 0)
                        {
                            replies = "";

                        }
                        else
                        {
                            //Get all replies from annotation
                            for (int n = i; n < annotations.Annotations[i].Replies.Length; n++)
                            {
                                //Get replies data
                                replies += "<li>" + annotations.Annotations[i].Replies[n].UserName +
                                                    " : " + annotations.Annotations[i].Replies[n].Message + "</li>";
                            }
                        }
                        //Create block with annotation data for template
                        block += "<div>" + annotation + "Replies: " + "<ul>" + replies + "</ul>" + "<hr />" + "</div>";
                    }
                    //Convert from string to HTML string
                    MvcHtmlString div = MvcHtmlString.Create(block);
                    //Set data for template
                    result.Add("div", div);
                    return View("Sample12", null, result);
                }

            }
            // If data not posted return to template for filling of necessary fields
            else
            {
                return View("Sample12");
            }
        }