Exemple #1
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);
            }
        }
Exemple #2
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;
            }
        }