コード例 #1
0
        public IActionResult SendFormSubmit(SendRequestModel sendRequest)   //(string email, string fileName)
        {
            if (s_username != "" && s_password != "")
            {
                DocuSignDemo.DocuSignDemo demo = new DocuSignDemo.DocuSignDemo();

                sendRequest.SenderAccountId = s_accountId;

                ViewData["Message"] = demo.SendSignDocumentRequest(s_tmpFilenames, ref sendRequest);

                s_envelopeId     = sendRequest.EnvelopeId;
                s_recipientName  = sendRequest.RecipientName;
                s_recipientEmail = sendRequest.RecipientEmailAddress;

                //clean out array of file names
                for (int i = 0; i < 10; i++)
                {
                    s_tmpFilenames[0, i] = null;
                    s_tmpFilenames[1, i] = null;
                }
            }

            else
            {
                ViewData["Message"] = "You need to sign in before you can send documents.";
            }


            return(View("Index"));
        }
コード例 #2
0
        public static List <ErrorModel> sendCreationCode(string email, int uid)
        {
            Random rand     = new Random();
            long   r        = rand.Next(0, 200000000);
            string longcode = SecurityService.GetStringSha256Hash(r.ToString());
            string code     = longcode.Substring(0, 8);

            creationCodes.Add(uid, code);
            SendRequestModel mod = new SendRequestModel();

            mod.toEmail = email;
            mod.subject = "Welcome to ChatLoco";
            mod.Message = "Your verification code is: " + code;
            var errors     = new List <ErrorModel>();
            var mail       = new MailMessage();
            var SmtpServer = new SmtpClient("smtp.gmail.com", 587);

            SmtpServer.UseDefaultCredentials = false;
            SmtpServer.Credentials           = new System.Net.NetworkCredential(sender, pass);
            SmtpServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
            SmtpServer.EnableSsl             = true;
            try
            {
                mail.From = new MailAddress(sender);
                mail.To.Add(email);
                mail.Subject = mod.subject;
                mail.Body    = mod.Message;
                SmtpServer.Send(mail);
            }
            catch (Exception e)
            {
                errors.Add(new ErrorModel(e.ToString()));
            }
            return(errors);
        }
コード例 #3
0
        public async Task <SendFileUploadDataResponseModel> PostFile([FromBody] SendRequestModel model)
        {
            if (model.Type != SendType.File)
            {
                throw new BadRequestException("Invalid content.");
            }

            if (!model.FileLength.HasValue)
            {
                throw new BadRequestException("Invalid content. File size hint is required.");
            }

            if (model.FileLength.Value > SendService.MAX_FILE_SIZE)
            {
                throw new BadRequestException($"Max file size is {SendService.MAX_FILE_SIZE_READABLE}.");
            }

            var userId = _userService.GetProperUserId(User).Value;

            var(send, data) = model.ToSend(userId, model.File.FileName, _sendService);
            var uploadUrl = await _sendService.SaveFileSendAsync(send, data, model.FileLength.Value);

            return(new SendFileUploadDataResponseModel
            {
                Url = uploadUrl,
                FileUploadType = _sendFileStorageService.FileUploadType,
                SendResponse = new SendResponseModel(send, _globalSettings)
            });
        }
コード例 #4
0
        public IActionResult Send(SendRequestModel model)
        {
            Application application = _dbContext.Application.SingleOrDefault(m => m.id == model.id);

            List <Device> devices = _dbContext.Device.Where(m => m.appId == application.id).ToList();

            string vapidPublicKey  = application.publicKey;
            string vapidPrivateKey = application.privateKey;

            PushModel payload = new PushModel
            {
                title   = model.title,
                message = model.message
            };

            foreach (Device device in devices)
            {
                var pushSubscription = new PushSubscription(device.pushEndpoint, device.pushP256DH, device.pushAuth);
                var vapidDetails     = new VapidDetails("mailto:[email protected]", vapidPublicKey, vapidPrivateKey);

                var webPushClient = new WebPushClient();
                webPushClient.SendNotification(pushSubscription, JsonConvert.SerializeObject(payload), vapidDetails);
            }

            return(RedirectToAction(nameof(Index)));
        }
コード例 #5
0
        public static List <ErrorModel> SendMail(SendRequestModel request)
        {
            var errors     = new List <ErrorModel>();
            var mail       = new MailMessage();
            var SmtpServer = new SmtpClient("smtp.gmail.com", 587);

            SmtpServer.UseDefaultCredentials = false;
            SmtpServer.Credentials           = new System.Net.NetworkCredential(sender, pass);
            SmtpServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
            SmtpServer.EnableSsl             = true;
            try
            {
                mail.From = new MailAddress(request.fromEmail);
                mail.To.Add(request.toEmail);
                mail.Subject = request.subject;
                mail.Body    = request.Message;
                SmtpServer.Send(mail);
            }
            catch (Exception e)
            {
                errors.Add(new ErrorModel(e.ToString()));
            }
            //email sent
            return(errors);
        }
コード例 #6
0
        public SendRequestModel BuildSendSmsRequestModel(string[] to, string message, string from, int unixTimestamp, string encoding, string dlrUrl, int flash, string reference)
        {
            var model = new SendRequestModel(to, message, from);

            if (unixTimestamp > 0)
            {
                model.UnixTimestamp = unixTimestamp;
            }
            if (flash != 0)
            {
                model.Flash = flash;
            }
            if (!string.IsNullOrEmpty(encoding))
            {
                model.Encoding = encoding;
            }
            if (!string.IsNullOrEmpty(dlrUrl))
            {
                model.DlrUrl = dlrUrl;
            }
            if (!string.IsNullOrEmpty(reference))
            {
                model.Reference = reference;
            }
            return(model);
        }
コード例 #7
0
ファイル: SendsController.cs プロジェクト: jewjitsu/server
        public async Task <SendResponseModel> Post([FromBody] SendRequestModel model)
        {
            var userId = _userService.GetProperUserId(User).Value;
            var send   = model.ToSend(userId, _sendService);
            await _sendService.SaveSendAsync(send);

            return(new SendResponseModel(send, _globalSettings));
        }
コード例 #8
0
ファイル: SendsController.cs プロジェクト: jewjitsu/server
        public async Task <SendResponseModel> Put(string id, [FromBody] SendRequestModel model)
        {
            var userId = _userService.GetProperUserId(User).Value;
            var send   = await _sendRepository.GetByIdAsync(new Guid(id));

            if (send == null || send.UserId != userId)
            {
                throw new NotFoundException();
            }

            await _sendService.SaveSendAsync(model.ToSend(send, _sendService));

            return(new SendResponseModel(send, _globalSettings));
        }
コード例 #9
0
ファイル: SendRequestModelTests.cs プロジェクト: xq2/server
        public void ToSend_Text_Success()
        {
            var deletionDate = DateTime.UtcNow.AddDays(5);
            var sendRequest  = new SendRequestModel
            {
                DeletionDate   = deletionDate,
                Disabled       = false,
                ExpirationDate = null,
                HideEmail      = false,
                Key            = "encrypted_key",
                MaxAccessCount = null,
                Name           = "encrypted_name",
                Notes          = null,
                Password       = "******",
                Text           = new SendTextModel()
                {
                    Hidden = false,
                    Text   = "encrypted_text"
                },
                Type = SendType.Text,
            };

            var sendService = Substitute.For <ISendService>();

            sendService.HashPassword(Arg.Any <string>())
            .Returns((info) => $"hashed_{(string)info[0]}");

            var send = sendRequest.ToSend(Guid.NewGuid(), sendService);

            Assert.Equal(deletionDate, send.DeletionDate);
            Assert.False(send.Disabled);
            Assert.Null(send.ExpirationDate);
            Assert.False(send.HideEmail);
            Assert.Equal("encrypted_key", send.Key);
            Assert.Equal("hashed_Password", send.Password);

            using var jsonDocument = JsonDocument.Parse(send.Data);
            var root = jsonDocument.RootElement;
            var text = AssertHelper.AssertJsonProperty(root, "Text", JsonValueKind.String).GetString();

            Assert.Equal("encrypted_text", text);
            AssertHelper.AssertJsonProperty(root, "Hidden", JsonValueKind.False);
            Assert.False(root.TryGetProperty("Notes", out var _));
            var name = AssertHelper.AssertJsonProperty(root, "Name", JsonValueKind.String).GetString();

            Assert.Equal("encrypted_name", name);
        }
コード例 #10
0
        public void TestSend()
        {
            ContactController contactControllerTest = new ContactController();
            SendRequestModel  model = new SendRequestModel()
            {
                fromEmail = "*****@*****.**",
                toEmail   = "*****@*****.**",
                subject   = "Email Sent Via Unit Tesing",
                Message   = "This is a test email. Please do not respond."
            };

            //Test seccussful message sent
            var result = contactControllerTest.Send(model) as JsonResult;

            Assert.AreEqual(0, ((SendResponseModel)result.Data).Errors.Count);
            Assert.AreEqual("Email sent successfully. We will respond ASAP!</p><br><p>You will be redirected to the home page shortly.", ((SendResponseModel)result.Data).Message);
        }
コード例 #11
0
        public ActionResult Send(SendRequestModel request)
        {
            var response = new SendResponseModel();

            //try to send email and make appropriate json object if not.

            response.Errors.AddRange(SendMailService.SendMail(request));

            if (!response.Errors.Any())
            {
                response.Message = "Email sent successfully. We will respond ASAP!</p><br><p>You will be redirected to the home page shortly.";
            }

            return(Json(response));
            //? Json(new { status = "success", Message = "<p>Email sent successfully. We will respond ASAP!</p><br><p>You will be redirected to the home page shortly.</p><br>" })
            //: Json(new { status = "error", Message = "<p>Error sending email.</p><br><p> Please make sure your information is correct.</p>" });
        }
コード例 #12
0
 public JsonResult SendRequest(SendRequestModel model)
 {
     try
     {
         Request request = new Request()
         {
             Theme    = model.Theme,
             Body     = model.Body,
             Date     = DateTime.UtcNow,
             Status   = DatabaseContext.Statuses.FirstOrDefault(s => s.Id == 1),
             Resident = CurrentUser as Resident
         };
         DatabaseContext.Requests.Add(request);
         DatabaseContext.SaveChanges();
         if (model.Files != null)
         {
             string        rootDirectory           = Server.MapPath("~\\Files");
             string        currentRequestDirectory = "\\Request_" + request.Id;
             string        requestDirectoryName    = rootDirectory + currentRequestDirectory;
             DirectoryInfo directory = new DirectoryInfo(requestDirectoryName);
             if (!directory.Exists)
             {
                 directory.Create();
                 request.File = currentRequestDirectory;
                 DatabaseContext.SaveChanges();
             }
             foreach (var file in model.Files)
             {
                 string fileName = Path.GetFileName(file.FileName);
                 file.SaveAs(directory.FullName + "\\" + fileName);
             }
         }
         return(Json(new { result = true }));
     }
     catch (Exception e)
     {
         Logger.Error(e.Message);
         return(Json(new { result = false }));
     }
 }
コード例 #13
0
 public SendData(SendRequestModel send)
 {
     Name  = send.Name;
     Notes = send.Notes;
 }
コード例 #14
0
        //Method sends a document signing request to user specified on View Send form.
        public string SendSignDocumentRequest(string[,] fileNamesPaths, ref SendRequestModel sendRequest)
        {
            try
            {
                for (int i = 0; i < 10; i++)

                {
                    if (fileNamesPaths[0, i] != null)
                    {
                        // Read a file from disk to use as a document
                        //byte[] fileBytes = File.ReadAllBytes(sendRequest.FileName);
                        byte[] fileBytes = File.ReadAllBytes(fileNamesPaths[1, i]);

                        EnvelopeDefinition envDef = new EnvelopeDefinition();
                        envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

                        // Add a document to the envelope
                        Document doc = new Document();
                        doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
                        //doc.Name = sendRequest.FileName;
                        doc.Name       = fileNamesPaths[0, i];
                        doc.DocumentId = "1";


                        envDef.Documents = new List <Document>();
                        envDef.Documents.Add(doc);

                        // Add a recipient to sign the documeent
                        Signer signer = new Signer();
                        signer.Name        = sendRequest.RecipientName;
                        signer.Email       = sendRequest.RecipientEmailAddress;
                        signer.RecipientId = "1";  //"3d8b53e4-d35c-4f4d-ac9a-9fa8fd0e3aba";

                        // must set |clientUserId| to embed the recipient
                        signer.ClientUserId = "1234";

                        // Create a |SignHere| tab somewhere on the document for the recipient to sign
                        signer.Tabs = new Tabs();
                        signer.Tabs.SignHereTabs = new List <SignHere>();
                        SignHere signHere = new SignHere();
                        signHere.DocumentId  = "1";
                        signHere.PageNumber  = "1";
                        signHere.RecipientId = "1";
                        signHere.XPosition   = "400";
                        signHere.YPosition   = "300";
                        signer.Tabs.SignHereTabs.Add(signHere);

                        envDef.Recipients         = new Recipients();
                        envDef.Recipients.Signers = new List <Signer>();
                        envDef.Recipients.Signers.Add(signer);

                        // set envelope status to "sent" to immediately send the signature request
                        envDef.Status = "sent";

                        // Use the EnvelopesApi to create and send the signature request
                        EnvelopesApi    envelopesApi    = new EnvelopesApi();
                        EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(sendRequest.SenderAccountId, envDef);
                        sendRequest.EnvelopeId = envelopeSummary.EnvelopeId;
                        //return JsonConvert.SerializeObject(envelopeSummary.EnvelopeId).ToString();
                    }
                }
                return("Success! Signing Request sent to " + sendRequest.RecipientEmailAddress);
            }

            catch (Exception e)
            {
                //handle error
                return(e.Message.ToString());
            }
        }
コード例 #15
0
ファイル: SendFileData.cs プロジェクト: ebell451/core
 public SendFileData(SendRequestModel send, string fileName)
     : base(send)
 {
     FileName = fileName;
 }
コード例 #16
0
 public SendTextData(SendRequestModel send)
     : base(send)
 {
     Text   = send.Text.Text;
     Hidden = send.Text.Hidden;
 }