コード例 #1
0
        public async Task <IEnumerable <dynamic> > SaveOrUpdate(OtherReportsViewModel orvm)
        {
            string sql = "dbo.EAppSaveOtherReportsAttachments";

            using (var conn = util.MasterCon())
            {
                try
                {
                    return(await(conn.QueryAsync <dynamic>(sql, new
                    {
                        orvm.OtherReportsAttachId,
                        orvm.ClientSiteId,
                        orvm.ReportTypeId,
                        orvm.PlantAreaId,
                        orvm.ReportDate,
                        orvm.FileName,
                        orvm.FileDescription,
                        orvm.LogicalName,
                        orvm.PhysicalPath,
                        orvm.Active,
                        orvm.UserId
                    }, commandType: CommandType.StoredProcedure)));
                }
                catch (Exception ex)
                {
                    throw new CustomException("Unable to Load Data, Please Contact Support!!!", "Error", true, ex);
                }
            }
        }
コード例 #2
0
        public async Task <IActionResult> UploadFiles()
        {
            try
            {
                CurrentUser cUser = new CurrentUser(HttpContext, _configuration);

                var          customHeaders   = Request.Headers;
                StringValues aId             = "";
                StringValues Type            = "";
                StringValues FileDescription = "";
                StringValues PlantAreaId     = "";
                StringValues ReportTypeId    = "";
                StringValues EquipmentId     = "";
                StringValues UnitId          = "";
                StringValues ReportDate      = "";
                if (customHeaders.ContainsKey("aId") && customHeaders.ContainsKey("Type"))
                {
                    customHeaders.TryGetValue("aId", out aId);
                    customHeaders.TryGetValue("Type", out Type);
                    customHeaders.TryGetValue("fileDescription", out FileDescription);
                    customHeaders.TryGetValue("plantAreaId", out PlantAreaId);
                    customHeaders.TryGetValue("equipmentId", out EquipmentId);
                    customHeaders.TryGetValue("unitId", out UnitId);
                    customHeaders.TryGetValue("reportTypeId", out ReportTypeId);
                    customHeaders.TryGetValue("reportDate", out ReportDate);
                    List <FileUploadViewModel> fuvms = await fileUploadService.UploadFiles(Request, HttpContext);

                    foreach (FileUploadViewModel fuvm in fuvms)
                    {
                        OtherReportsViewModel orvm = new OtherReportsViewModel();
                        orvm.ClientSiteId    = Int32.Parse(aId);
                        orvm.PlantAreaId     = Int32.Parse(PlantAreaId);
                        orvm.EquipmentId     = Int32.Parse(EquipmentId);
                        orvm.UnitId          = Int32.Parse(UnitId);
                        orvm.ReportTypeId    = Int32.Parse(ReportTypeId);
                        orvm.ReportDate      = DateTime.Parse(ReportDate);
                        orvm.FileDescription = FileDescription;
                        orvm.FileName        = fuvm.OriginalFileName;
                        orvm.LogicalName     = fuvm.LogicalFileName;
                        orvm.PhysicalPath    = fuvm.PhysicalFilePath;
                        orvm.Active          = "Y";
                        orvm.UserId          = cUser.UserId;
                        await OtherReportsRepo.SaveOrUpdate(orvm);
                    }
                }

                return(Json("Success"));
            }
            catch (CustomException cex)
            {
                var responseObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError, responseObj));
            }
            catch (Exception ex)
            {
                return(Ok(new EmaintenanceMessage(ex.Message)));
            }
        }