Пример #1
0
        public int Validate([FromUri] NewWebhookValidate hub)
        {
            //hub.verify_token =
            //03a5cde6-5717-4ec1-910e-ac5f15bbf068

            FilesService.CreateFile("web_hook_validate", JsonConvert.SerializeObject(hub), "json");
            return(hub.challenge);
        }
Пример #2
0
        public async Task <ActionResult> SavePhoto()
        {
            byte[] byteArray;
            if (Session["dump"] == null)
            {
                return(RedirectToAction("Index", "Error", new { message = string.Format("Try capturing the image again") }));
            }
            byteArray = String_To_Bytes2(Session["dump"].ToString());
            // Initialize the GraphServiceClient.
            GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient();
            var userDetails = await eventsService.GetMyDetails(graphClient);

            var result = await filesService.CreateFile(graphClient, byteArray);

            try
            {
                CaptureNote captureNote = new CaptureNote()
                {
                    CapturedDate = DateTime.Now,
                    Email        = Session["facultyMail"] != null ? Session["facultyMail"].ToString() : "",
                    NoteLink     = result.Display,
                    StudentName  = userDetails.DisplayName,
                };

                try
                {
                    db.captureNotes.Add(captureNote);
                    var val = db.SaveChanges();
                    if (val != 0)
                    {
                        var path = Server.MapPath("~/WebImages/");
                        System.IO.DirectoryInfo di = new DirectoryInfo(path);

                        foreach (FileInfo file in di.GetFiles())
                        {
                            file.Delete();
                        }
                    }
                }
                catch (RetryLimitExceededException /* dex */)
                {
                    //Log the error (uncomment dex variable name and add a line here to write a log.)
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }
            catch (ServiceException se)
            {
                if (se.Error.Message == Resource.Error_AuthChallengeNeeded)
                {
                    return(new EmptyResult());
                }

                // Personal accounts that aren't enabled for the Outlook REST API get a "MailboxNotEnabledForRESTAPI" or "MailboxNotSupportedForRESTAPI" error.
                return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) }));
            }

            return(RedirectToAction("Index", "Student").Success("Note captured successfully."));
        }
Пример #3
0
        // Create a text file in the current user's root directory.
        public async Task <ActionResult> CreateFile()
        {
            ResultsViewModel results = new ResultsViewModel();

            try
            {
                // Add the file.
                results.Items = await filesService.CreateFile();
            }
            catch (ServiceException se)
            {
                if ((se.InnerException as AuthenticationException)?.Error.Code == Resource.Error_AuthChallengeNeeded)
                {
                    HttpContext.Request.GetOwinContext().Authentication.Challenge();
                    return(new EmptyResult());
                }
                return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) }));
            }
            return(View("Files", results));
        }
        // Create a text file in the current user's root directory.
        public async Task <ActionResult> CreateFile()
        {
            ResultsViewModel results = new ResultsViewModel();

            try
            {
                // Initialize the GraphServiceClient.
                GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient();

                // Add the file.
                results.Items = await filesService.CreateFile(graphClient);
            }
            catch (ServiceException se)
            {
                if (se.Error.Message == Resource.Error_AuthChallengeNeeded)
                {
                    return(new EmptyResult());
                }
                return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) }));
            }
            return(View("Files", results));
        }
Пример #5
0
 public IHttpActionResult Subscription([FromBody] WebhookSubscription subs)
 {
     FilesService.CreateFile("web_hook_subscription", JsonConvert.SerializeObject(subs), "json");
     return(Ok());
 }
Пример #6
0
 public IActionResult Subscription([FromBody] NewWebhookSubscription subs)
 {
     FilesService.CreateFile(PathToCatalog, "web_hook_subscription", JsonConvert.SerializeObject(subs), "json");
     return(Ok());
 }