예제 #1
0
        public async Task <ActionResult> AddActionPlanFormData([FromForm] ActionPlanParams obj)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = Extensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            obj.OwnerID = userID;
            IFormFile file = Request.Form.Files["UploadedFile"];

            if (file != null)
            {
                if (!Directory.Exists(_environment.WebRootPath + "\\ExcelFolder\\"))
                {
                    Directory.CreateDirectory(_environment.WebRootPath + "\\ExcelFolder\\");
                }
                using (FileStream fileStream = System.IO.File.Create(_environment.WebRootPath + "\\ExcelFolder\\" + file.FileName))
                {
                    file.CopyTo(fileStream);
                    fileStream.Flush();
                }
                obj.FileName = file.FileName;
            }
            else
            {
                obj.FileName = null;
            }

            var data = await _actionPlanService.AddActionPlanFormData(obj);


            await _hubContext.Clients.All.SendAsync("ReceiveMessage", "user", "message");


            return(Ok(new { status = data.Status, isSendmail = true, message = data.Message }));
        }
예제 #2
0
        public async Task <IActionResult> Add([FromBody] ActionPlanParams obj)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = Extensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            obj.OwnerID = userID;
            var data = await _actionPlanService.Add(obj);//(item, obj.Subject, obj.Auditor, obj.CategoryID);

            try
            {
                await _hubContext.Clients.All.SendAsync("ReceiveMessage", "user", "message");
            }
            catch (System.Exception ex)
            {
                throw;
            }



            return(Ok(new { status = data.Status, isSendmail = true }));
        }