Пример #1
0
        public async Task <ActionResult> UpdateWorkflowStatusById([FromBody] WorkflowDataRequest workflowDataRequest)
        {
            workflowService = new WorkflowService();
            WorkflowDataResponse workflowDataResponse = workflowService.UpdateWorkflowStatusById(workflowDataRequest);

            return(Ok(workflowDataResponse));
        }
Пример #2
0
        public async Task <ActionResult> UpdateWorkflowStatusById([FromBody] WorkflowDataRequest workflowDataRequest)
        {
            _workflowService = new WorkflowService(this._context, this._addressBookService, this._entityValidationService);
            WorkflowDataResponse workflowDataResponse = _workflowService.UpdateWorkflowStatusById(workflowDataRequest);

            return(Ok(workflowDataResponse));
        }
Пример #3
0
        public WorkflowDataResponse UpdateWorkflowStatusById(WorkflowDataRequest WorkflowDataRequest)
        {
            WorkflowDataResponse workflowDataResponse = new WorkflowDataResponse();

            try
            {
                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();
                optionsBuilder.EnableSensitiveDataLogging(true);

                using (var context = new ApplicationDbContext(optionsBuilder.Options))
                {
                    WorkflowDataRequest data = context.workflowDataRequests.Where(s => s.ID == WorkflowDataRequest.ID).FirstOrDefault();
                    if (data != null)
                    {
                        data.ID         = WorkflowDataRequest.ID;
                        data.WFL_STA_TE = WorkflowDataRequest.WFL_STA_TE;
                        context.workflowDataRequests.Update(data);
                        context.Entry(WorkflowDataRequest).State = EntityState.Detached;
                        context.SaveChanges();
                        workflowDataResponse.Workflow = data;
                        workflowDataResponse.Success  = true;
                        return(workflowDataResponse);
                    }
                    workflowDataResponse.Success = false;
                }
            }
            catch (Exception ex)
            {
                workflowDataResponse.Success            = false;
                workflowDataResponse.OperationException = ex;
            }
            return(workflowDataResponse);
        }
Пример #4
0
        public WorkflowDataResponse UpdateWorkflowStatusById(WorkflowDataRequest WorkflowDataRequest)
        {
            WorkflowDataResponse workflowDataResponse = new WorkflowDataResponse();

            try
            {
                WorkflowDataRequest data = this.context.workflowDataRequests.Where(s => s.ID == WorkflowDataRequest.ID).FirstOrDefault();
                if (data != null)
                {
                    data.ID         = WorkflowDataRequest.ID;
                    data.WFL_STA_TE = WorkflowDataRequest.WFL_STA_TE;
                    this.context.workflowDataRequests.Update(data);
                    this.context.Entry(WorkflowDataRequest).State = EntityState.Detached;
                    this.context.SaveChanges();
                    workflowDataResponse.Workflow = data;
                    workflowDataResponse.Success  = true;
                    return(workflowDataResponse);
                }
                workflowDataResponse.Success = false;
            }
            catch (Exception ex)
            {
                workflowDataResponse.Success            = false;
                workflowDataResponse.OperationException = ex;
            }
            return(workflowDataResponse);
        }
Пример #5
0
        public WorkflowDataResponse InsertWorkflow(WorkflowDataRequest workflowData)
        {
            WorkflowDataResponse workflowtDataResponse = new WorkflowDataResponse();

            optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            using (var context = new ApplicationDbContext(optionsBuilder.Options))
            {
                try
                {
                    WorkflowDataRequest workflowDataRequest = new WorkflowDataRequest();
                    workflowDataRequest.FLE_NA     = workflowData.FLE_NA;
                    workflowDataRequest.WFL_STA_TE = workflowData.WFL_STA_TE;
                    workflowDataRequest.CRD_BY_NR  = workflowData.CRD_BY_NR;
                    workflowDataRequest.CRD_DT     = DateTime.Now;
                    //DateTime.ParseExact(DateTime.Now.ToShortDateString(), "yyyy-MM-dd HH:mm.ss.ffffff", CultureInfo.InvariantCulture);
                    context.workflowDataRequests.Add(workflowDataRequest);
                    context.Entry(workflowDataRequest).State = EntityState.Added;
                    context.SaveChanges();
                    workflowtDataResponse.Workflow = workflowDataRequest;
                    workflowtDataResponse.Success  = true;
                    return(workflowtDataResponse);
                }
                catch (Exception ex)
                {
                    workflowtDataResponse.Success            = true;
                    workflowtDataResponse.OperationException = ex;
                }
            }
            return(workflowtDataResponse);
        }
Пример #6
0
        public WorkflowDataResponse DeleteWorkflowById(int wid)
        {
            WorkflowDataResponse workflowDataResponse = new WorkflowDataResponse();

            try
            {
                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();
                optionsBuilder.EnableSensitiveDataLogging(true);

                using (var context = new ApplicationDbContext(optionsBuilder.Options))
                {
                    WorkflowDataRequest data = context.workflowDataRequests.Where(s => s.ID == wid).FirstOrDefault();
                    context.workflowDataRequests.Remove(data);
                    context.Entry(data).State = EntityState.Deleted;
                    context.SaveChanges();
                    workflowDataResponse.Success = true;
                    return(workflowDataResponse);
                }
            }
            catch (Exception ex)
            {
                workflowDataResponse.Success            = false;
                workflowDataResponse.OperationException = ex;
            }
            return(workflowDataResponse);
        }
Пример #7
0
        public ActionResult <WorkflowDataResponse> CreateWorkflow(IFormFile fromFile, int Emp_Id)
        {
            WorkflowDataResponse workflowDataResponse = new WorkflowDataResponse();
            WorkflowDataRequest  workflowDataRequest  = new WorkflowDataRequest();

            workflowDataRequest.FLE_NA     = fromFile.FileName;
            workflowDataRequest.CRD_BY_NR  = Emp_Id;
            workflowDataRequest.CRD_DT     = DateTime.Parse(DateTime.Now.ToString()).ToLocalTime();
            workflowDataRequest.WFL_STA_TE = 0;
            workflowService      = new WorkflowService();
            workflowDataResponse = workflowService.InsertWorkflow(workflowDataRequest);
            return(Ok(workflowDataResponse));
        }
Пример #8
0
        public ActionResult <WorkflowDataResponse> CreateWorkflow(IFormFile fromFile, int Emp_Id)
        {
            WorkflowDataResponse workflowDataResponse = new WorkflowDataResponse();
            WorkflowDataRequest  workflowDataRequest  = new WorkflowDataRequest();

            workflowDataRequest.FLE_NA     = fromFile.FileName;
            workflowDataRequest.CRD_BY_NR  = Emp_Id;
            workflowDataRequest.CRD_DT     = DateTime.Parse(DateTime.Now.ToString()).ToLocalTime();
            workflowDataRequest.WFL_STA_TE = 0;
            _workflowService     = new WorkflowService(this._context, this._addressBookService, this._entityValidationService);
            workflowDataResponse = _workflowService.InsertWorkflow(workflowDataRequest);
            return(Ok(workflowDataResponse));
        }
Пример #9
0
        public WorkflowDataResponse SelectWorkflows(User user)
        {
            WorkflowDataResponse workflowtDataResponse = new WorkflowDataResponse();

            try
            {
                workflowtDataResponse.Workflows = this.context.workflowDataRequests.Where(w => w.CRD_BY_NR == user.ID).ToList();
                workflowtDataResponse.Success   = true;
                return(workflowtDataResponse);
            }
            catch (Exception ex)
            {
                workflowtDataResponse.Success            = false;
                workflowtDataResponse.OperationException = ex;
            }
            return(workflowtDataResponse);
        }
Пример #10
0
        public WorkflowDataResponse SelectWorkflowById(int Id)
        {
            WorkflowDataResponse workflowtDataResponse = new WorkflowDataResponse();

            try
            {
                workflowtDataResponse.Workflow = this.context.workflowDataRequests.Where(w => w.ID == Id).FirstOrDefault();
                workflowtDataResponse.Success  = true;
                return(workflowtDataResponse);
            }
            catch (Exception ex)
            {
                workflowtDataResponse.Success            = false;
                workflowtDataResponse.OperationException = ex;
            }
            return(workflowtDataResponse);
        }
Пример #11
0
        //public ShipmentDataResponse UpdateShipmentAddressByIds(List<ShipmentDataRequest> shipmentDataRequest)
        //{
        //    ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();
        //    try
        //    {
        //        optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();


        //        optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();

        //        var this.context = new ApplicationDbContext(optionsBuilder.Options);

        //        List<ShipmentDataRequest> shipmentDetailsToUpdate = new List<ShipmentDataRequest>();
        //        foreach (ShipmentDataRequest request in shipmentDataRequest)
        //        {
        //            ShipmentDataRequest data = this.context.shipmentDataRequests.Where(s => s.ID == request.ID).FirstOrDefault();
        //            data.ID = request.ID;
        //            data.WFL_ID = request.WFL_ID;
        //            data.SHP_ADR_TR_TE = request.SHP_ADR_TR_TE;
        //            data.SMT_STA_NR = request.SMT_STA_NR;
        //            data.ACY_TE = request.ACY_TE;
        //            data.CON_NR = request.CON_NR;
        //            data.POD_RTN_SVC = request.POD_RTN_SVC;
        //            shipmentDetailsToUpdate.Add(data);
        //            //this.context.shipmentDataRequests.Update(data);
        //            //this.context.Entry(request).State = EntityState.Detached;
        //            //this.context.SaveChanges();
        //            shipmentDataResponse.Shipments = this.context.shipmentDataRequests;
        //        }
        //        this.context.BulkUpdate(shipmentDetailsToUpdate);
        //        //shipmentDataResponse.Shipments = this.context.shipmentDataRequests;
        //        shipmentDataResponse.Success = true;
        //        return shipmentDataResponse;
        //    }
        //    catch (Exception ex)
        //    {
        //        shipmentDataResponse.Success = false;
        //        shipmentDataResponse.OperationExceptionMsg = ex.Message;
        //    }
        //    return shipmentDataResponse;
        //}

        public ShipmentDataResponse DeleteShipments(List <ShipmentDataRequest> shipmentDataRequest)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                int?workflowID    = shipmentDataRequest?.FirstOrDefault().WFL_ID;
                int shipmentCount = 0;

                foreach (ShipmentDataRequest request in shipmentDataRequest)
                {
                    ShipmentDataRequest data = this.context.shipmentDataRequests.Where(s => s.ID == request.ID).FirstOrDefault();
                    this.context.shipmentDataRequests.Remove(data);
                    this.context.Entry(request).State = EntityState.Detached;
                    this.context.SaveChanges();
                }

                if (workflowID.HasValue)
                {
                    shipmentCount = this.context.shipmentDataRequests.Where(ship => ship.WFL_ID == workflowID).Count();
                }

                if (shipmentCount == 0)
                {
                    WorkflowService      workflowService      = new WorkflowService(this.context, this.addressBookService, this.entityValidationService);
                    WorkflowDataResponse workflowDataResponse = workflowService.DeleteWorkflowById(workflowID.Value);
                    if (workflowDataResponse.Success)
                    {
                        shipmentDataResponse.HasWorkflow = false;
                    }
                }
                else
                {
                    shipmentDataResponse.HasWorkflow = true;
                }

                shipmentDataResponse.Success = true;
                return(shipmentDataResponse);
            }
            catch (Exception ex)
            {
                shipmentDataResponse.Success = false;
                shipmentDataResponse.OperationExceptionMsg = ex.Message;
            }
            return(shipmentDataResponse);
        }
Пример #12
0
        public WorkflowDataResponse DeleteWorkflowById(int wid)
        {
            WorkflowDataResponse workflowDataResponse = new WorkflowDataResponse();

            try
            {
                WorkflowDataRequest data = this.context.workflowDataRequests.Where(s => s.ID == wid).FirstOrDefault();
                this.context.workflowDataRequests.Remove(data);
                this.context.Entry(data).State = EntityState.Deleted;
                this.context.SaveChanges();
                workflowDataResponse.Success = true;
                return(workflowDataResponse);
            }
            catch (Exception ex)
            {
                workflowDataResponse.Success            = false;
                workflowDataResponse.OperationException = ex;
            }
            return(workflowDataResponse);
        }
Пример #13
0
        //public WorkflowDataResponse CreateWorkflow(WorkflowDataRequest workflowData)
        //{
        //}

        public WorkflowDataResponse SelectWorkflows(USR user)
        {
            WorkflowDataResponse workflowtDataResponse = new WorkflowDataResponse();

            optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            using (var context = new ApplicationDbContext(optionsBuilder.Options))
            {
                try
                {
                    workflowtDataResponse.Workflows = context.workflowDataRequests.Where(w => w.CRD_BY_NR == user.ID).ToList();
                    workflowtDataResponse.Success   = true;
                    return(workflowtDataResponse);
                }
                catch (Exception ex)
                {
                    workflowtDataResponse.Success            = false;
                    workflowtDataResponse.OperationException = ex;
                }
            }
            return(workflowtDataResponse);
        }
        public List <ShipmentDataRequest> GetAllShipmentData(int wid)
        {
            //shipmentService = new ShipmentService();
            List <ShipmentDataRequest> shipmentDataRequests = _shipmentService.GetAllShipment(wid);

            //we need to update the workflow status
            int?                 workflowstatus       = _shipmentService.SelectShipmentTotalStatusByWorkflowId(wid);
            WorkflowService      workflowService      = new WorkflowService(_context, _addressBookService, _entityValidationService);
            WorkflowDataResponse workflowDataResponse = workflowService.SelectWorkflowById(wid);

            if (workflowDataResponse.Success && workflowDataResponse.Workflow != null)
            {
                if (workflowstatus != workflowDataResponse.Workflow.WFL_STA_TE)
                {
                    WorkflowDataRequest workflowDataRequest = new WorkflowDataRequest();
                    workflowDataRequest.ID         = wid;
                    workflowDataRequest.WFL_STA_TE = workflowstatus;
                    workflowService.UpdateWorkflowStatusById(workflowDataRequest);
                }
            }

            return(shipmentDataRequests);
        }
        public async Task <ActionResult> ExcelFile(IList <IFormFile> excelFileName)
        {
            string[] validationSet     = configuration.GetSection("ExcelFileValidation:mandatoryFields").GetChildren().Select(val => val.Value).ToArray();
            string[] cellValidationSet = configuration.GetSection("ExcelFileValidation:cellValidationFields").GetChildren().Select(val => val.Value).ToArray();
            string   addressBookEnable = configuration["AddressBook:Enable"];

            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                int userId = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(x => x.Type == JwtConstant.UserId).Value);
                ShipmentDataResponse result = null;
                //string response = string.Empty;
                if (excelFileName != null)
                {
                    //var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
                    foreach (var file in excelFileName)
                    {
                        if (file.Length > 0)
                        {
                            //string paths = hostingEnvironment.WebRootPath;

                            var filePath = Path.Combine(_hostingEnvironment.WebRootPath, file.FileName);

                            //var filePath = Path.Combine(@"D:\UserExcels", file.FileName);
                            using (var fileStream = new FileStream(filePath, FileMode.Create))
                            {
                                //FileStream stream = File.Open(fileName, FileMode.Open, FileAccess.Read);
                                //response = new ExcelExtension().Test(filePath);
                                await file.CopyToAsync(fileStream);
                            }


                            ExcelExtensionReponse excelExtensionReponse =
                                new ExcelExtension()
                                .Test(
                                    filePath,
                                    configuration.GetSection("ExcelFileValidation:mandatoryFields").GetChildren().Select(val => val.Value).ToArray(),
                                    configuration.GetSection("ColumnValidation:regexList").GetChildren().Select(val => val.Value).ToArray(),
                                    configuration.GetSection("ColumnValidation:columnLengths").GetChildren().Select(val => val.Value).ToArray());
                            if (excelExtensionReponse.success)
                            {
                                var excelDataObject2 = JsonConvert.DeserializeObject <List <ExcelDataObject> >(excelExtensionReponse.ExcelExtensionReponseData);
                                WorkflowController   workflowController = new WorkflowController(this._hostingEnvironment, this._context, this._addressBookService, this._entityValidationService);
                                WorkflowDataResponse response           = ((WorkflowDataResponse)((ObjectResult)(workflowController.CreateWorkflow(file, userId)).Result).Value);
                                _workflowID = response.Workflow.ID;
                                result      = _shipmentService.CreateShipments(excelDataObject2, _workflowID, addressBookEnable, out int?workflowStatus);
                                if (result.Success)
                                {
                                    shipmentDataResponse.Success   = true;
                                    shipmentDataResponse.Shipments = result.Shipments;
                                    WorkflowDataRequest workflowDataRequest = new WorkflowDataRequest();
                                    workflowDataRequest.ID         = _workflowID;
                                    workflowDataRequest.WFL_STA_TE = workflowStatus;
                                    _workflowService.UpdateWorkflowStatusById(workflowDataRequest);
                                }
                                else
                                {
                                    shipmentDataResponse.Success = false;
                                    shipmentDataResponse.OperationExceptionMsg = result.OperationExceptionMsg;
                                    WorkflowService workflowService = new WorkflowService(_context, _addressBookService, _entityValidationService);
                                    workflowService.DeleteWorkflowById(_workflowID);
                                }
                            }
                            else
                            {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                                Task.Run(() => iCustomLog.AddLogEntry(new UPS.DataObjects.LogData.LogDataModel()
                                {
                                    apiType        = Enum.GetName(typeof(UPS.DataObjects.LogData.APITypes), 7),
                                    dateTime       = System.DateTime.Now,
                                    LogInformation = new UPS.DataObjects.LogData.LogInformation()
                                    {
                                        LogException = string.Empty,
                                        LogRequest   = "Excel Uploaded",
                                        LogResponse  = JsonConvert.SerializeObject(excelExtensionReponse)
                                    }
                                }));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                                return(Ok(excelExtensionReponse));
                            }
                        }
                    }
                }

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                Task.Run(() => iCustomLog.AddLogEntry(new UPS.DataObjects.LogData.LogDataModel()
                {
                    apiTypes       = UPS.DataObjects.LogData.APITypes.ExcelUpload,
                    apiType        = Enum.GetName(typeof(UPS.DataObjects.LogData.APITypes), 7),
                    dateTime       = System.DateTime.Now,
                    LogInformation = new UPS.DataObjects.LogData.LogInformation()
                    {
                        LogException = null,
                        LogRequest   = "Excel Uploaded",
                        LogResponse  = JsonConvert.SerializeObject(shipmentDataResponse)
                    }
                }));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                return(Ok(shipmentDataResponse));
            }
            catch (Exception ex)
            {
                // new AuditEventEntry.WriteEntry(new Exception(ex.Message));
                AuditEventEntry.WriteEntry(ex);
                return(Ok(shipmentDataResponse.OperationExceptionMsg = ex.Message));
            }
        }
Пример #16
0
        public async Task <ActionResult> ExcelFile(IList <IFormFile> excelFileName, int Emp_Id)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                ShipmentDataResponse result = null;
                //string response = string.Empty;
                if (excelFileName != null)
                {
                    //var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
                    foreach (var file in excelFileName)
                    {
                        if (file.Length > 0)
                        {
                            //string paths = hostingEnvironment.WebRootPath;

                            var filePath = Path.Combine(hostingEnvironment.WebRootPath, file.FileName);

                            //var filePath = Path.Combine(@"D:\UserExcels", file.FileName);
                            using (var fileStream = new FileStream(filePath, FileMode.Create))
                            {
                                //FileStream stream = File.Open(fileName, FileMode.Open, FileAccess.Read);
                                //response = new ExcelExtension().Test(filePath);
                                await file.CopyToAsync(fileStream);
                            }


                            ExcelExtensionReponse excelExtensionReponse = new ExcelExtension().Test(filePath);
                            if (excelExtensionReponse.success)
                            {
                                var excelDataObject2 = JsonConvert.DeserializeObject <List <ExcelDataObject> >(excelExtensionReponse.ExcelExtensionReponseData);
                                WorkflowController   workflowController = new WorkflowController();
                                WorkflowDataResponse response           = ((WorkflowDataResponse)((ObjectResult)(workflowController.CreateWorkflow(file, Emp_Id)).Result).Value);
                                _workflowID = response.Workflow.ID;
                                result      = this.CreateShipments(excelDataObject2, _workflowID);
                                if (result.Success)
                                {
                                    shipmentDataResponse.Success   = true;
                                    shipmentDataResponse.Shipments = result.Shipments;
                                }
                                else
                                {
                                    shipmentDataResponse.Success = false;
                                    shipmentDataResponse.OperationExceptionMsg = result.OperationExceptionMsg;
                                    WorkflowService workflowService = new WorkflowService();
                                    workflowService.DeleteWorkflowById(_workflowID);
                                }
                            }
                            else
                            {
                                return(Ok(excelExtensionReponse));
                            }
                        }
                    }
                }

                return(Ok(shipmentDataResponse));
            }
            catch (Exception ex)
            {
                AuditEventEntry.WriteEntry(new Exception(ex.Message));
                return(Ok(shipmentDataResponse.OperationExceptionMsg = ex.Message));
            }
        }