Ejemplo n.º 1
0
        [HttpPost]//creates new hierarchy
        public async Task Post([FromBody] List <HierarchyUser> hierarchyUsers)
        {
            var requestId           = DateTime.UtcNow.ToFileTime().ToString();
            var genericSchedulesLog = new GenericSchedulesLog();

            genericSchedulesLog.GenericScheduleDateTime = DateTime.UtcNow;
            genericSchedulesLog.GenericScheduleId       = 1;
            genericSchedulesLog.OrganizationId          = hierarchyUsers.FirstOrDefault().OrganizationId;

            genericSchedulesLog.Log = "Info : Create Organization Hierarchy User Started.";
            _dbLoggerService.LogInfo(genericSchedulesLog);


            _logger.LogInformation("Request:{0} HttpReqeustType:{1}", requestId, HttpRequestType.GET);
            try
            {
                //await Task.Delay(0hierarchyUsers
                //await _hierarchyUserService.SaveOrganizationHierarchyUserAssignment(hierarchyUser, genericSchedulesLog);
                _logger.LogInformation("Response:{0}  is succeed", requestId);
            }
            catch (Exception ex)
            {
                await Task.Delay(0);

                _logger.LogError("Response:{0}  is failed Error : {1}", requestId, ex);
                NotFound();
            }
        }
Ejemplo n.º 2
0
        public async Task SaveOrganizationHierarchyVehicleAssignment(List <HierarchyVehicle> hierarchyVehicles, GenericSchedulesLog genericSchedulesLog)
        {
            try
            {
                _logger.LogInformation("Vehicle Assignment started");
                await Task.Delay(0);

                var organizationId = hierarchyVehicles.FirstOrDefault().OrganizationId;
                //DateTime? _lastfrom = _hierarchyVehicleRepository.GetLastEffectiveFrom(organizationId);

                try
                {
                    _hierarchyVehicleRepository.SetOrganizationHierarchyAssignmentExpireDateTime(organizationId, DateTime.Now);
                }

                catch (Exception ex)
                {
                    _logger.LogInformation("Vehicle Assignment abrupted due to error SetOrganizationHierarchyAssignmentExpireDateTime : {0} ", ex.ToString());
                }

                try
                {
                    _hierarchyVehicleRepository.DeleteOrganizationHierarchyFleetVehicles(organizationId);
                }
                catch (Exception ex)
                {
                    _logger.LogInformation("Vehicle Assignment abrupted due to error DeleteOrganizationHierarchyFleetVehicles : {0} ", ex.ToString());
                }
                foreach (HierarchyVehicle hierarchyVehicle in hierarchyVehicles)
                {
                    //_oh.SaveOrganizationHierarchy(organizationId, row);
                    try
                    {
                        _hierarchyVehicleRepository.SaveOrganizationHierarchyAssignmentByVehicleDescription(organizationId, hierarchyVehicle);
                    }

                    catch (Exception ex)
                    {
                        genericSchedulesLog.Log = "Module : Vehicle Assignment Function : SaveOrganizationHierarchyVehicleAssignment  Error : " + ex.ToString() + " Object No : " + ex.ToString() + " Node Code: " + hierarchyVehicle.NodeCode + " vehicle description: " + hierarchyVehicle.Description;
                        _dbLoggerService.LogInfo(genericSchedulesLog);
                        //_logger.LogInformation("Vehicle Assignment abrupted due to error SaveOrganizationHierarchyAssignmentByVehicleDescription : {0} ", ex.ToString());
                    }
                }

                _logger.LogInformation("Vehicle Assignment ended");
            }
            catch (Exception ex)
            {
                _logger.LogInformation("Vehicle Assignment abrupted due to error : {0} ", ex.ToString());
            }
        }
Ejemplo n.º 3
0
        public async Task CreateHierarchy(HierarchyContainer hierarchyContainer, GenericSchedulesLog genericSchedulesLog)
        {
            try
            {
                _scheduleService.UpdateScheduleTask(hierarchyContainer.schedule.Id);
                switch (hierarchyContainer.schedule.ServiceSubTypeId)
                {
                case 1:     // Organization Hieararchy
                    await CreateOrganizationHierarchy(hierarchyContainer.hierarchies, hierarchyContainer.hierarchiesVehicles, genericSchedulesLog);

                    break;

                case 2:     //ServiceSubType.Hierarchy
                            //CreateHirarchy(schedule.Params);
                    break;

                case 3:     //ServiceSubType.HierarchyUser
                            //SaveOrganizationHierarchyUserAssignment(schedule.Params);
                    break;

                case 4:     //ServiceSubType.HierarchyVehicle
                            //Console.WriteLine("Case 4");
                    break;

                default:
                    Console.WriteLine("Default case");
                    break;
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation("Hierarchy Exception No :{0} ", ex.ToString());
                genericSchedulesLog.Log = "Hierarchy Exception No: " + ex.ToString();

                _dbLoggerService.LogInfo(genericSchedulesLog);
            }
        }
Ejemplo n.º 4
0
        [HttpPost]//creates new hierarchy
        public async Task Post([FromBody] HierarchyContainer hierarchiesContainer)
        {
            _logger.LogInformation("Create Hierarchy Started");

            if (hierarchiesContainer.hierarchies != null)
            {
                _logger.LogInformation("Total hierarchy :{0} ", hierarchiesContainer.hierarchies.Count.ToString());
            }
            else
            {
                _logger.LogInformation("Total hierarchy : 0 ");
            }

            if (hierarchiesContainer.hierarchiesVehicles != null)
            {
                _logger.LogInformation("Total vehicles :{0} ", hierarchiesContainer.hierarchiesVehicles.Count.ToString());
            }
            else
            {
                _logger.LogInformation("Total vehicles : 0 ");
            }


            var requestId = DateTime.UtcNow.ToFileTime().ToString();

            var genericSchedulesLog = new GenericSchedulesLog();

            genericSchedulesLog.GenericScheduleDateTime = DateTime.UtcNow;
            genericSchedulesLog.GenericScheduleId       = hierarchiesContainer.schedule.Id;

            if (hierarchiesContainer.hierarchies != null)
            {
                genericSchedulesLog.OrganizationId = hierarchiesContainer.hierarchies.FirstOrDefault().OrganizationId;
            }

            genericSchedulesLog.Log = "Info : Create Organization Hierarchy Started.";


            _logger.LogInformation("Request:{0} HttpReqeustType:{1}", requestId, HttpRequestType.GET);
            try
            {
                genericSchedulesLog.Log     = MessageType.INFO + " :Service Started at" + DateTime.UtcNow;
                genericSchedulesLog.LogType = 1;
                _dbLoggerService.LogInfo(genericSchedulesLog);
                genericSchedulesLog.LogType = 0;

                genericSchedulesLog.Log     = MessageType.INFO + " :Total hierarchy records :" + hierarchiesContainer.hierarchies.Count.ToString() + " :Total vehicle records :" + hierarchiesContainer.hierarchiesVehicles.Count.ToString();
                genericSchedulesLog.LogType = 1;
                _dbLoggerService.LogInfo(genericSchedulesLog);
                genericSchedulesLog.LogType = 0;


                var task = _hierarchyService.CreateHierarchy(hierarchiesContainer, genericSchedulesLog);
                _logger.LogInformation("Response:{0}  is succeed", requestId);

                if (task.IsCompleted)
                {
                    genericSchedulesLog.Log = MessageType.INFO + " :Create Organization Hierarchy Ended.";
                    _dbLoggerService.LogInfo(genericSchedulesLog);
                }
            }
            catch (Exception ex)
            {
                await Task.Delay(0);

                genericSchedulesLog.Log = MessageType.ERR + " :Create Organization Hierarchy Failed. " + ex.ToString();
                _dbLoggerService.LogInfo(genericSchedulesLog);
                genericSchedulesLog.LogType = 0;
                NotFound();
            }
            finally
            {
                genericSchedulesLog.Log     = MessageType.INFO + " :Service ended at" + DateTime.UtcNow;
                genericSchedulesLog.LogType = 1;
                _dbLoggerService.LogInfo(genericSchedulesLog);
                genericSchedulesLog.LogType = 0;
            }
        }