// GET: SecureNode/CheckListManagement
        public ActionResult CheckListManagement(string date)
        {
            var model = new SecureNodeModels.CheckListManagementDto();

            using (IRepository repo = new Repository())
            {
                List <CheckList> list;

                if (!string.IsNullOrEmpty(date) && DateTime.TryParse(date, out var operateDate))
                {
                    list = repo.Query <CheckList>(x => x.OperateDate >= operateDate.AddDays(-2) && x.OperateDate <= operateDate.AddDays(2))
                           .FindAll(x => x.OperateDate.Date == operateDate.Date && x.IsActive);

                    model.OperateDate = operateDate;
                }
                else
                {
                    // 为避免数据量过大,只显示7天内的检查记录
                    list = repo.Query <CheckList>(x => x.OperateDate >= DateTime.Now.AddDays(-7)).FindAll(x => x.IsActive);

                    model.OperateDate = null;
                }

                if (list.Count > 0)
                {
                    var mapper = CheckListDto.ConfigMapper().CreateMapper();

                    model.CheckLists = mapper.Map <IEnumerable <CheckListDto> >(list.AsEnumerable()).ToList();
                }
            }

            return(View(model));
        }
        public ActionResult ExportCheckLists(DateTime date)
        {
            using (IRepository repo = new Repository())
            {
                var list = repo.Query <CheckList>(x => x.OperateDate >= date.AddDays(-2) && x.OperateDate <= date.AddDays(2))
                           .FindAll(x => x.OperateDate.Date == date.Date && x.IsActive);

                if (list.Count > 0)
                {
                    var mapper     = CheckListDto.ConfigMapper().CreateMapper();
                    var checklists = mapper.Map <IEnumerable <CheckListDto> >(list.AsEnumerable()).ToList();

                    var book = ExcelManager.BuildCheckListWorkbook(checklists, date);

                    byte[] file;
                    using (var ms = new MemoryStream())
                    {
                        book.Write(ms);
                        file = ms.GetBuffer();
                    }

                    return(File(file, "application/vnd.ms-excel", $@"今日安全检查表-{date:yyyyMMdd}.xls"));
                }
            }

            return(RedirectToAction("CheckListManagement", "SecureNode", new { date }));
        }
        // GET: SecureNode/History
        public ActionResult History(string date)
        {
            var model = new SecureNodeModels.HistoryDto();

            using (IRepository repo = new Repository())
            {
                var list = repo.Query <CheckList>(x => x.UserGuid == _authorizedUser.ID).FindAll(x => x.IsActive);

                if (!string.IsNullOrEmpty(date) && DateTime.TryParse(date, out var operateDate))
                {
                    list = list.FindAll(x => x.OperateDate.Date == operateDate.Date);

                    model.OperateDate = operateDate;
                }
                else
                {
                    list = list.FindAll(x => x.OperateDate.Date == DateTime.Today.Date);

                    model.OperateDate = DateTime.Today;
                }

                if (list.Count > 0)
                {
                    var mapper = CheckListDto.ConfigMapper().CreateMapper();

                    model.MyCheckLists = mapper.Map <IEnumerable <CheckListDto> >(list.AsEnumerable()).ToList();
                }
            }

            return(View(model));
        }
Beispiel #4
0
        /// <summary>
        /// 获取检查单相关
        /// </summary>
        protected List <CheckListDto> GetCheckList()
        {
            List <CheckListDto> ckList = new List <CheckListDto>();

            #region 检查单相关
            var CheckListIds = Request.Form["CheckListIds"];  // 检查单Id
            if (!string.IsNullOrEmpty(CheckListIds))
            {
                var checkIdArr = CheckListIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                int sort       = 1;
                foreach (var checkId in checkIdArr)
                {
                    if (string.IsNullOrEmpty(Request.Form[checkId + "_item_name"]))  // 条目名称为空 不添加
                    {
                        continue;
                    }
                    var is_complete = Request.Form[checkId + "_is_complete"];
                    var is_import   = Request.Form[checkId + "_is_import"];
                    var sortOrder   = Request.Form[checkId + "_sort_order"];

                    var thisCheck = new CheckListDto()
                    {
                        ckId       = long.Parse(checkId),
                        isComplete = is_complete == "on",
                        itemName   = Request.Form[checkId + "_item_name"],
                        isImport   = is_import == "on",
                        sortOrder  = sort,
                    };
                    ckList.Add(thisCheck);
                    sort++;
                }
            }
            #endregion
            return(ckList);
        }
        public async Task <CheckListDto> Update(CheckListDto checkListDto)
        {
            var checkList = await _context.CheckLists.FindAsync(checkListDto.Id);

            checkList.HubName    = checkListDto.HubName;
            checkList.IsActive   = checkListDto.IsActive;
            checkList.SubAdminId = checkListDto.SubAdminId;
            await _context.SaveChangesAsync();

            return(checkListDto);
        }
        public JsonResult CheckList(CheckListDto model, int secureNodeId)
        {
            if (model != null && secureNodeId > 0 && model.CheckNodePoint > 0 &&
                !string.IsNullOrEmpty(model.CheckLocation) && model.CheckTime > DateTime.MinValue)
            {
                try
                {
                    var cl = new CheckList
                    {
                        SecureNodeId = secureNodeId,
                        // 如果在0~7点,属于前一天的晚班
                        OperateDate = model.CheckTime.Hour >= 0 &&
                                      model.CheckTime.Hour < ConfigGlobalSecureNode.ShiftDuration[0]
                            ? model.CheckTime.Date.AddDays(-1) : model.CheckTime.Date,
                        Shift = model.CheckTime.Hour >= ConfigGlobalSecureNode.ShiftDuration[0] &&
                                model.CheckTime.Hour <= ConfigGlobalSecureNode.ShiftDuration[1]
                            ? "daytime" : "night",
                        CheckTime      = model.CheckTime,
                        CheckLocation  = model.CheckLocation.Trim(),
                        CheckNodePoint = model.CheckNodePoint,
                        CheckResult    = model.CheckResult,
                        UserGuid       = _authorizedUser.ID,
                        EmployeeName   = _authorizedUser.EmployeeName,
                        EmployeeNo     = _authorizedUser.EmployeeNo,
                        IsActive       = true,
                        Remark         = !model.CheckResult ? model.Remark : string.Empty
                    };

                    using (IRepository repo = new Repository())
                    {
                        var count = repo.Query <CheckList>(x => x.UserGuid == _authorizedUser.ID && x.SecureNodeId == secureNodeId)
                                    .FindAll(x => x.OperateDate == cl.OperateDate && x.IsActive).Count;

                        if (count < ConfigGlobalSecureNode.DailyCheckLimit)
                        {
                            repo.Insert(cl);
                        }
                        else
                        {
                            return(Json(new { result = "failed", message = $"今天此节点已安全检查{count}次" }));
                        }

                        return(Json(new { result = "success", limit = count }));
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { result = "exception", message = ex.Message }));
                }
            }

            return(Json(new { result = "failed" }));
        }
Beispiel #7
0
        public async Task <IActionResult> UpdateChecklist([FromBody] CheckListDto checkListDto)
        {
            try
            {
                var result = await _checklistService.Update(checkListDto);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <CheckListDto> Create(CheckListDto checkListDto)
        {
            var checkList = new CheckList {
                CreatedOn = DateTime.Now, HubName = checkListDto.HubName, IsActive = true, SubAdminId = checkListDto.SubAdminId
            };
            var checkListResult = await _context.AddAsync(checkList);

            var heading = new Heading {
                CheckList = checkListResult.Entity, HeadingType = HeadingType.MainHeading, Content = checkListDto.Heading
            };
            var headingResult = await _context.AddAsync(heading);

            await _context.SaveChangesAsync();

            checkListDto.Id        = checkListResult.Entity.Id;
            checkListDto.HeadingId = headingResult.Entity.Id;
            return(checkListDto);
        }
        // GET: SecureNode
        public ActionResult Index(string date)
        {
            var model = new SecureNodeModels.IndexDto();

            using (IRepository repo = new Repository())
            {
                var relations = repo.Query <RelationUserOperationStandard>(x => x.UserGuid == _authorizedUser.ID);

                if (relations.Count > 0)
                {
                    var secureNodes = OperationStandard.Cache.OperationStandardList
                                      .FindAll(x => relations.Exists(rela => rela.OperationStandardId.Equals(x.ID)));

                    var mapper = OperationStandardDto.ConfigMapper().CreateMapper();

                    model.SecureNodes = mapper.Map <IEnumerable <OperationStandardDto> >(secureNodes.AsEnumerable())
                                        .ToList();
                }

                var list = repo.Query <CheckList>(x => x.UserGuid == _authorizedUser.ID).FindAll(x => x.IsActive);

                if (!string.IsNullOrEmpty(date) && DateTime.TryParse(date, out var operateDate))
                {
                    list = list.FindAll(x => x.OperateDate.Date == operateDate.Date);

                    model.OperateDate = operateDate;
                }
                else
                {
                    list = list.FindAll(x => x.OperateDate.Date == DateTime.Today.Date);

                    model.OperateDate = DateTime.Today;
                }

                if (list.Count > 0)
                {
                    var mapper = CheckListDto.ConfigMapper().CreateMapper();

                    model.MyCheckLists = mapper.Map <IEnumerable <CheckListDto> >(list.AsEnumerable()).ToList();
                }
            }

            return(View(model));
        }
Beispiel #10
0
        private static List <ExtensionsDataList> MappExtensionDataList(CheckListDto checkListDto)
        {
            var extensionsDataList = new List <ExtensionsDataList>();

            if (checkListDto.ExtensionsDataList.Count > 0)
            {
                checkListDto.ExtensionsDataList.ForEach(edl =>
                {
                    var attachedIssueIds = edl.AttachedIssues.Select(issue => issue.Id).ToList();

                    var extensionsDataListItem = new ExtensionsDataList
                    {
                        AttachedIssueIds = attachedIssueIds,
                        CheckListId      = checkListDto.Id,
                        Comment          = edl.Comment,
                        Name             = edl.Name,
                        Value            = edl.Value
                    };
                    extensionsDataList.Add(extensionsDataListItem);
                });
            }

            return(extensionsDataList);
        }
Beispiel #11
0
        /// <summary>
        ///  获取页面参数
        /// </summary>
        protected TicketManageDto GetParam()
        {
            // 为方便页面处理 owner_resource_id 存储的是 sys_resource_department 的id ,存储时需要转换
            long?owner_resource_id = null;
            long?role_id           = null;
            var  priResString      = Request.Form["owner_resource_id"];

            if (!string.IsNullOrEmpty(priResString))
            {
                var resDep = new sys_resource_department_dal().FindById(long.Parse(priResString));
                if (resDep != null)
                {
                    owner_resource_id = resDep.resource_id;
                    role_id           = resDep.role_id;
                }
            }
            TicketManageDto param      = new TicketManageDto();
            var             pageTicket = AssembleModel <sdk_task>();

            pageTicket.owner_resource_id = owner_resource_id;
            pageTicket.role_id           = role_id;
            var dueDate = Request.Form["DueDate"];
            var dueTime = Request.Form["DueTime"];

            if (!string.IsNullOrEmpty(dueTime) && !string.IsNullOrEmpty(dueDate))
            {
                var dueDateTime = dueDate + " " + dueTime; // 获取到截止时间
                var dueD        = DateTime.Parse(dueDateTime);
                pageTicket.estimated_end_time = Tools.Date.DateHelper.ToUniversalTimeStamp(dueD);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('未获取到相关截止时间,请重新填写!');</script>");
                return(null);
            }
            #region 如果sla设置自动计算截止时间 ,保存时计算出工单的结束时间
            if (pageTicket.sla_id != null)
            {
                var thisSla = new d_sla_dal().FindNoDeleteById((long)pageTicket.sla_id);
                if (thisSla != null && thisSla.set_ticket_due_date == 1)
                {
                    if (pageTicket.sla_start_time == null)
                    {
                        pageTicket.sla_start_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    }
                    var    slaValue     = new sdk_task_dal().GetSlaTime(pageTicket);
                    string slaTimeValue = "";
                    if (slaValue != null)
                    {
                        slaTimeValue = slaValue.ToString();
                    }
                    if (!string.IsNullOrEmpty(slaTimeValue) && slaTimeValue.Substring(0, 1) == "{")
                    {
                        var slaDic = new EMT.Tools.Serialize().JsonToDictionary(slaTimeValue);
                        if (slaDic != null && slaDic.Count > 0)
                        {
                            var duteDateDic = slaDic.FirstOrDefault(_ => _.Key == "截止时间");
                            if (!default(KeyValuePair <string, object>).Equals(duteDateDic))
                            {
                                var duteDate = DateTime.Parse(duteDateDic.Value.ToString());
                                pageTicket.estimated_end_time = Tools.Date.DateHelper.ToUniversalTimeStamp(duteDate);
                            }
                            var firstResponseDateDic = slaDic.FirstOrDefault(_ => _.Key == "响应时间");
                            if (!default(KeyValuePair <string, object>).Equals(firstResponseDateDic))
                            {
                                pageTicket.first_response_target_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(firstResponseDateDic.Value.ToString()));
                            }
                            var resoluTatgetDic = slaDic.FirstOrDefault(_ => _.Key == "解决时间");
                            if (!default(KeyValuePair <string, object>).Equals(resoluTatgetDic))
                            {
                                pageTicket.resolution_target_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(resoluTatgetDic.Value.ToString()));
                            }
                            var resoluPlanTatgetDic = slaDic.FirstOrDefault(_ => _.Key == "解决方案提供时间");
                            if (!default(KeyValuePair <string, object>).Equals(firstResponseDateDic))
                            {
                                pageTicket.resolution_plan_target_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(resoluPlanTatgetDic.Value.ToString()));
                            }
                        }
                    }
                }
            }
            #endregion

            if (isAdd)
            {
                pageTicket.type_id = (int)DTO.DicEnum.TASK_TYPE.SERVICE_DESK_TICKET;
                param.ticket       = pageTicket;
            }
            else
            {
                #region 获取页面相关值
                thisTicket.account_id           = pageTicket.account_id;
                thisTicket.contract_id          = pageTicket.contract_id;
                thisTicket.contact_id           = pageTicket.contact_id;
                thisTicket.status_id            = pageTicket.status_id;
                thisTicket.priority             = pageTicket.priority;
                thisTicket.issue_type_id        = pageTicket.issue_type_id;
                thisTicket.sub_issue_type_id    = pageTicket.sub_issue_type_id;
                thisTicket.source_type_id       = pageTicket.source_type_id;
                thisTicket.estimated_end_time   = pageTicket.estimated_end_time;
                thisTicket.estimated_hours      = pageTicket.estimated_hours;
                thisTicket.sla_id               = pageTicket.sla_id;
                thisTicket.department_id        = pageTicket.department_id;
                thisTicket.owner_resource_id    = pageTicket.owner_resource_id;
                thisTicket.role_id              = pageTicket.role_id;
                thisTicket.installed_product_id = pageTicket.installed_product_id;
                thisTicket.service_id           = pageTicket.service_id;
                thisTicket.cost_code_id         = pageTicket.cost_code_id;
                thisTicket.purchase_order_no    = pageTicket.purchase_order_no;
                thisTicket.cate_id              = pageTicket.cate_id;
                thisTicket.ticket_type_id       = pageTicket.ticket_type_id;
                thisTicket.title       = pageTicket.title;
                thisTicket.description = pageTicket.description;
                thisTicket.resolution  = pageTicket.resolution;

                thisTicket.sla_start_time              = pageTicket.sla_start_time;
                thisTicket.estimated_end_time          = pageTicket.estimated_end_time;
                thisTicket.first_response_target_time  = pageTicket.first_response_target_time;
                thisTicket.resolution_target_time      = pageTicket.resolution_target_time;
                thisTicket.resolution_plan_target_time = pageTicket.resolution_plan_target_time;
                #endregion
                param.ticket = thisTicket;
            }
            param.resDepIds = Request.Form["OtherResId"];
            var AddSoule = Request.Form["AddSoule"];
            if (AddSoule == "on")
            {
                param.isAppSlo = true;
            }
            param.completeReason = Request.Form["reason"];
            param.repeatReason   = Request.Form["RepeatReason"];
            #region 检查单相关
            var CheckListIds = Request.Form["CheckListIds"];  // 检查单Id
            if (!string.IsNullOrEmpty(CheckListIds))
            {
                List <CheckListDto> ckList = new List <CheckListDto>();
                var checkIdArr             = CheckListIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var checkId in checkIdArr)
                {
                    if (string.IsNullOrEmpty(Request.Form[checkId + "_item_name"]))  // 条目名称为空 不添加
                    {
                        continue;
                    }
                    var     is_complete = Request.Form[checkId + "_is_complete"];
                    var     is_import   = Request.Form[checkId + "_is_import"];
                    var     sortOrder   = Request.Form[checkId + "_sort_order"];
                    decimal?sort        = null;
                    if (!string.IsNullOrEmpty(sortOrder))
                    {
                        sort = decimal.Parse(sortOrder);
                    }
                    var thisCheck = new CheckListDto()
                    {
                        ckId       = long.Parse(checkId),
                        isComplete = is_complete == "on",
                        itemName   = Request.Form[checkId + "_item_name"],
                        isImport   = is_import == "on",
                        sortOrder  = sort,
                    };
                    ckList.Add(thisCheck);
                }
                param.ckList = ckList;
            }
            #endregion
            #region 工单自定义字段,页面暂无自定义
            if (tickUdfList != null && tickUdfList.Count > 0)
            {
                var list = new List <UserDefinedFieldValue>();
                foreach (var udf in tickUdfList)                            // 循环添加
                {
                    var new_udf = new UserDefinedFieldValue()
                    {
                        id    = udf.id,
                        value = string.IsNullOrEmpty(Request.Form[udf.id.ToString()]) ? null : Request.Form[udf.id.ToString()],
                    };
                    list.Add(new_udf);
                }
                if (isAdd)
                {
                    param.udfList = list;
                }
                else
                {
                    param.udfList = ticketUdfValueList;
                }
            }
            #endregion
            return(param);
        }
        private static async Task SeedChecklist(DataContext context, ILogger <DataContext> logger)
        {
            try
            {
                var anyCheckListExist = await context.CheckLists.AnyAsync();

                if (!anyCheckListExist)
                {
                    ChecklistService service = new ChecklistService(context);
                    int subAdminId           = service.GetSubAdminIdByText("Sub-Admin1");

                    var checkListDto = new CheckListDto {
                        HubName = "Indoctrination Form on Health, Safety and Environment for Hub 1, 健康安全与环境培训表",
                        Heading = "Emergency  Procedures/应急措施:", SubAdminId = subAdminId
                    };
                    var checklist = await service.Create(checkListDto);

                    #region/* Emergency  Procedures */
                    var question2 = new Question {
                        MainHeadingId = checklist.HeadingId, CheckListId = checklist.Id,
                        Content       = "⦁  1st Alarm,warning alarm – Wait for further instruction.第一次的铃声是警告警报—请大家等待进一步的指示。", HeaderText = "In the event of fire emergency/如果遇到火灾,"
                    };
                    await service.CreateQuestion(question2);

                    var question3 = new Question {
                        MainHeadingId = checklist.HeadingId, CheckListId = checklist.Id,
                        Content       = "⦁	  2nd Alarm, evacuation alarm – Proceed to assembly area in an orderly manner/ 第二次的铃声是疏散警报—请大家有序的走到集合点。",
                        FooterText    = "Note: Do not re-enter the premises or take the lift./注意:不要再次进入建筑物或搭乘电梯"
                    };
                    await service.CreateQuestion(question3);

                    #endregion

                    #region/* Company policies  */
                    var heading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Company policies/公司的政策"
                    };
                    var headingResult = await service.AddHeading(heading);

                    var question5 = new Question {
                        MainHeadingId = headingResult.Id, CheckListId = checklist.Id,
                        Content       = "Quality and performance policy/质量和绩效政策。"
                    };
                    await service.CreateQuestion(question5);

                    var question6 = new Question {
                        MainHeadingId = headingResult.Id, CheckListId = checklist.Id,
                        Content       = "Health, safety and environment policy/健康,安全和环境政策。"
                    };
                    await service.CreateQuestion(question6);

                    var question7 = new Question {
                        MainHeadingId = headingResult.Id, CheckListId = checklist.Id,
                        Content       = "Alcohol and substance abuse policy/酒精和药物滥用政策"
                    };
                    await service.CreateQuestion(question7);

                    var question8 = new Question {
                        MainHeadingId = headingResult.Id, CheckListId = checklist.Id,
                        Content       = "Security policy/ 保安政策。"
                    };
                    await service.CreateQuestion(question8);

                    #endregion

                    #region/* Associated Hazards - headings   */
                    var hazardHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Associated Hazards/相关危害"
                    };
                    var hazardResult = await service.AddHeading(hazardHeading);

                    var generalHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubHeading, Content = "General Hazard/般的危害"
                    };
                    var generalResult = await service.AddHeading(generalHeading);

                    var specificHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubHeading, Content = "Site Specific Hazards or Concern/具体危害以及关注的问题"
                    };
                    var specificResult = await service.AddHeading(specificHeading);

                    var healthHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubOfSubHeading, Content = "Health and Safety hazards/健康与安全危害类别:"
                    };
                    var healtResult = await service.AddHeading(healthHeading);

                    var warehouseHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubOfSubHeading, Content = "Warehouse/仓库:"
                    };
                    var warehouseResult = await service.AddHeading(warehouseHeading);

                    var bayHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubOfSubHeading, Content = "Loading bay/装卸区域:"
                    };
                    var bayResult = await service.AddHeading(bayHeading);

                    #endregion

                    #region /*  Health and Safety hazards  */
                    var question9 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Electrical hazards/电气危害。"
                    };
                    await service.CreateQuestion(question9);

                    var question10 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Fire hazards/火灾。"
                    };
                    await service.CreateQuestion(question10);

                    var question11 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Mechanical hazards/机械危害。"
                    };
                    await service.CreateQuestion(question11);

                    var question12 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Falls from height/Falling objects/高空坠落/ 东西坠落。"
                    };
                    await service.CreateQuestion(question12);

                    var question13 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Ergonomic hazards (manual handling hazards)/人体工程学危害 (人工搬运危害)。"
                    };
                    await service.CreateQuestion(question13);

                    var question14 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Slip, trip and fall/滑倒,绊倒和跌倒。"
                    };
                    await service.CreateQuestion(question14);

                    var question15 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Chemical hazards/化学危害"
                    };
                    await service.CreateQuestion(question15);

                    #endregion

                    #region /*  Warehouse  */
                    var question16 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = warehouseResult.Id, Content = "Forklift & MHE movement/叉车 & 物料搬运设备的移动。"
                    };
                    await service.CreateQuestion(question16);

                    var question17 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = warehouseResult.Id, Content = "Charging of Forklift and MHE/叉车 & 物料搬运设备充电。"
                    };
                    await service.CreateQuestion(question17);

                    var question18 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = warehouseResult.Id, Content = "Housekeeping/卫生管理。"
                    };
                    await service.CreateQuestion(question18);

                    var question19 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = warehouseResult.Id, Content = "Charging of micro-battery/ 给微电池充电。"
                    };
                    await service.CreateQuestion(question19);

                    #endregion

                    #region /*  Loading bay  */
                    var question20 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = bayResult.Id, Content = "Trip and fall over dock leveler/ 被装卸跳板绊倒。"
                    };
                    await service.CreateQuestion(question20);

                    var question21 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = bayResult.Id, Content = "Loading and unloading hazards/上下货的危险。"
                    };
                    await service.CreateQuestion(question21);

                    #endregion

                    #region Risk Assessment
                    var riskHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Risk Assessment/风险评估"
                    };
                    var riskResult = await service.AddHeading(riskHeading);

                    var question22 = new Question {
                        MainHeadingId = riskHeading.Id, CheckListId = checklist.Id,
                        Content       = "Understand hazard identification, risk evaluation and control measures/了解危害识别,评估风险,和控制措施。"
                    };
                    await service.CreateQuestion(question22);

                    #endregion

                    #region General Security, Health and Safety Rules
                    var securityHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "General Security, Health and Safety Rules/保安,健康与安全通则"
                    };
                    var securityResult = await service.AddHeading(securityHeading);

                    var question23 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "No obstruction of Fire Fighting equipment, Emergency Exit/ stairway and Fireman Access point/消防设备,紧急撤离通道/楼梯以及消防员接入点不被阻碍。"
                    };
                    await service.CreateQuestion(question23);

                    var question24 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "No smoking in the warehouse and office area/仓库和办公室严禁吸烟。"
                    };
                    await service.CreateQuestion(question24);

                    var question25 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "No operating of forklift without valid forklift license/没有叉车驾驶执照严禁驾驶叉车。"
                    };
                    await service.CreateQuestion(question25);

                    var question26 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "Always observe warning signs and notices/观察和遵守警告指示牌。"
                    };
                    await service.CreateQuestion(question26);

                    var question27 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "Comply with good housekeeping and hygiene habits/保持良好的内务管理和卫生习惯。"
                    };
                    await service.CreateQuestion(question27);

                    var question28 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "Report all accident, injuries or near miss to your supervisor or manager/向主管或经理报告所有的事故,伤害或险兆事故。"
                    };
                    await service.CreateQuestion(question28);

                    var question29 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "After any injuries, consult first aiders immediately. If required, visit the doctor with your immediate supervisor/受伤后,立刻去找急救员。如果需要看医生,主管必须跟着去。"
                    };
                    await service.CreateQuestion(question29);

                    var question30 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "No entry into quarantine or unauthorized area without the escort from host/不进未经授权的区域。"
                    };
                    await service.CreateQuestion(question30);

                    #endregion

                    #region Environmental Rules
                    var environmentHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Environmental Rules/环境通则"
                    };
                    var environmentResult = await service.AddHeading(environmentHeading);

                    var question31 = new Question {
                        MainHeadingId = environmentResult.Id, CheckListId = checklist.Id,
                        Content       = "Minimizing the environmental impact to our facility by reducing the consumption of natural resources, and the generation of waste and emissions related to the project, and practicing water conservation/通过减少对自然资源的耗损以及降低对废物的生成与排放来降低环境因素对设施的影响。 "
                    };
                    await service.CreateQuestion(question31);

                    var question32 = new Question {
                        MainHeadingId = environmentResult.Id, CheckListId = checklist.Id,
                        Content       = "Switch off vehicle engine when doing loading and unloading to reduce pollution/在上下货时,必须把引擎关掉来减少污染。"
                    };
                    await service.CreateQuestion(question32);

                    var question33 = new Question {
                        MainHeadingId = environmentResult.Id, CheckListId = checklist.Id,
                        Content       = "Comply with 3 Rs practice. (Reduce, Reuse & Recycle)/复3R准则 (减量化, 再使用, 循环处理)。"
                    };
                    await service.CreateQuestion(question33);

                    #endregion

                    #region Schedule of PPE in warehouse
                    var scheduleHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Schedule of PPE in warehouse/仓库必须使用的个人防护装备:"
                    };
                    var scheduleResult = await service.AddHeading(scheduleHeading);

                    var mandatoryHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubHeading, Content = "Mandatory/必须:"
                    };
                    var mandatoryResult = await service.AddHeading(mandatoryHeading);

                    var ifHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubHeading, Content = "If applicable/如有需要:"
                    };
                    var ifResult = await service.AddHeading(ifHeading);

                    var question34 = new Question {
                        MainHeadingId = scheduleResult.Id, CheckListId = checklist.Id, SubHeadingId = mandatoryResult.Id,
                        Content       = "Safety boots/安全鞋"
                    };
                    await service.CreateQuestion(question34);

                    var question35 = new Question {
                        MainHeadingId = scheduleResult.Id, CheckListId = checklist.Id, SubHeadingId = mandatoryResult.Id,
                        Content       = "Visibility Vest/ Bolloré Uniform/高能见度安全背心/ 公司制服"
                    };
                    await service.CreateQuestion(question35);

                    var question36 = new Question {
                        MainHeadingId = scheduleResult.Id, CheckListId = checklist.Id, SubHeadingId = ifResult.Id,
                        Content       = "Gloves/手套"
                    };
                    await service.CreateQuestion(question36);

                    #endregion

                    #region/* Legal Requirement  */
                    var legalHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Legal Requirement/法律要求"
                    };
                    var legalHeadingResult = await service.AddHeading(legalHeading);

                    var question37 = new Question {
                        MainHeadingId = legalHeadingResult.Id, CheckListId = checklist.Id,
                        Content       = "The main legal requirements that were complied (Fire Safety Act, Workplace Safety & Health act, Environmental Protection & Management Act)/主要法律要求已被遵守 (消防安全条例,工作安全于健康条例,环境保护和管理条例)。"
                    };
                    await service.CreateQuestion(question37);


                    #endregion
                }
            }
            catch (Exception ex)
            {
                logger.LogError("Error in checklist seed: ", ex);
            }
        }
Beispiel #13
0
        private static async Task SeedChecklist(DataContext context, ILogger <DataContext> logger)
        {
            try
            {
                var anyCheckListExist = await context.CheckLists.AnyAsync();

                if (!anyCheckListExist)
                {
                    ChecklistService service = new ChecklistService(context);
                    int subAdminId           = service.GetSubAdminIdByText("Sub-Admin1");

                    var checkListDto = new CheckListDto {
                        HubName = "Indoctrination Form on Health, Safety and Environment for Hub 1",
                        Heading = "Emergency  Procedures", SubAdminId = subAdminId
                    };
                    var checklist = await service.Create(checkListDto);

                    #region/* Emergency  Procedures */
                    var question2 = new Question {
                        MainHeadingId = checklist.HeadingId, CheckListId = checklist.Id,
                        Content       = "⦁  1st Alarm,warning alarm – Wait for further instruction.", HeaderText = "In the event of fire emergency"
                    };
                    await service.CreateQuestion(question2);

                    var question3 = new Question {
                        MainHeadingId = checklist.HeadingId, CheckListId = checklist.Id,
                        Content       = "⦁	  2nd Alarm, evacuation alarm – Proceed to assembly area in an orderly manner.",
                        FooterText    = "Note: Do not re-enter the premises or take the lift."
                    };
                    await service.CreateQuestion(question3);

                    #endregion

                    #region/* Company policies  */
                    var heading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Company policies"
                    };
                    var headingResult = await service.AddHeading(heading);

                    var question5 = new Question {
                        MainHeadingId = headingResult.Id, CheckListId = checklist.Id,
                        Content       = "Quality and performance policy."
                    };
                    await service.CreateQuestion(question5);

                    var question6 = new Question {
                        MainHeadingId = headingResult.Id, CheckListId = checklist.Id,
                        Content       = "Health, safety and environment policy."
                    };
                    await service.CreateQuestion(question6);

                    var question7 = new Question {
                        MainHeadingId = headingResult.Id, CheckListId = checklist.Id,
                        Content       = "Alcohol and substance abuse policy."
                    };
                    await service.CreateQuestion(question7);

                    var question8 = new Question {
                        MainHeadingId = headingResult.Id, CheckListId = checklist.Id,
                        Content       = "Security policy."
                    };
                    await service.CreateQuestion(question8);

                    #endregion

                    #region/* Associated Hazards - headings   */
                    var hazardHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Associated Hazards"
                    };
                    var hazardResult = await service.AddHeading(hazardHeading);

                    var generalHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubHeading, Content = "General Hazard"
                    };
                    var generalResult = await service.AddHeading(generalHeading);

                    var specificHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubHeading, Content = "Site Specific Hazards or Concern"
                    };
                    var specificResult = await service.AddHeading(specificHeading);

                    var healthHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubOfSubHeading, Content = "Health and Safety hazards"
                    };
                    var healtResult = await service.AddHeading(healthHeading);

                    var warehouseHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubOfSubHeading, Content = "Warehouse"
                    };
                    var warehouseResult = await service.AddHeading(warehouseHeading);

                    var bayHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubOfSubHeading, Content = "Loading bay"
                    };
                    var bayResult = await service.AddHeading(bayHeading);

                    #endregion

                    #region /*  Health and Safety hazards  */
                    var question9 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Electrical hazards."
                    };
                    await service.CreateQuestion(question9);

                    var question10 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Fire hazards."
                    };
                    await service.CreateQuestion(question10);

                    var question11 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Mechanical hazards."
                    };
                    await service.CreateQuestion(question11);

                    var question12 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Falls from height/Falling objects."
                    };
                    await service.CreateQuestion(question12);

                    var question13 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Ergonomic hazards (manual handling hazards)."
                    };
                    await service.CreateQuestion(question13);

                    var question14 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Slip, trip and fall."
                    };
                    await service.CreateQuestion(question14);

                    var question15 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = generalResult.Id,
                        SubOfSubHeadingId = healtResult.Id, Content = "Chemical hazards."
                    };
                    await service.CreateQuestion(question15);

                    #endregion

                    #region /*  Warehouse  */
                    var question16 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = warehouseResult.Id, Content = "Forklift & MHE movement."
                    };
                    await service.CreateQuestion(question16);

                    var question17 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = warehouseResult.Id, Content = "Charging of Forklift and MHE."
                    };
                    await service.CreateQuestion(question17);

                    var question18 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = warehouseResult.Id, Content = "Housekeeping."
                    };
                    await service.CreateQuestion(question18);

                    var question19 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = warehouseResult.Id, Content = "Charging of micro-battery."
                    };
                    await service.CreateQuestion(question19);

                    #endregion

                    #region /*  Loading bay  */
                    var question20 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = bayResult.Id, Content = "Trip and fall over dock leveler."
                    };
                    await service.CreateQuestion(question20);

                    var question21 = new Question {
                        MainHeadingId     = hazardResult.Id, CheckListId = checklist.Id, SubHeadingId = specificResult.Id,
                        SubOfSubHeadingId = bayResult.Id, Content = "Loading and unloading hazards."
                    };
                    await service.CreateQuestion(question21);

                    #endregion

                    #region Risk Assessment
                    var riskHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Risk Assessment"
                    };
                    var riskResult = await service.AddHeading(riskHeading);

                    var question22 = new Question {
                        MainHeadingId = riskHeading.Id, CheckListId = checklist.Id,
                        Content       = "Understand hazard identification, risk evaluation and control measures."
                    };
                    await service.CreateQuestion(question22);

                    #endregion

                    #region General Security, Health and Safety Rules
                    var securityHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "General Security, Health and Safety Rules"
                    };
                    var securityResult = await service.AddHeading(securityHeading);

                    var question23 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "No obstruction of Fire Fighting equipment, Emergency Exit/ stairway and Fireman Access point."
                    };
                    await service.CreateQuestion(question23);

                    var question24 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "No smoking in the warehouse and office area."
                    };
                    await service.CreateQuestion(question24);

                    var question25 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "No operating of forklift without valid forklift license."
                    };
                    await service.CreateQuestion(question25);

                    var question26 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "Always observe warning signs and notices."
                    };
                    await service.CreateQuestion(question26);

                    var question27 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "Comply with good housekeeping and hygiene habits."
                    };
                    await service.CreateQuestion(question27);

                    var question28 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "Report all accident, injuries or near miss to your supervisor or manager."
                    };
                    await service.CreateQuestion(question28);

                    var question29 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "After any injuries, consult first aiders immediately. If required, visit the doctor with your immediate supervisor."
                    };
                    await service.CreateQuestion(question29);

                    var question30 = new Question {
                        MainHeadingId = securityResult.Id, CheckListId = checklist.Id,
                        Content       = "No entry into quarantine or unauthorized area without the escort from host."
                    };
                    await service.CreateQuestion(question30);

                    #endregion

                    #region Environmental Rules
                    var environmentHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Environmental Rules"
                    };
                    var environmentResult = await service.AddHeading(environmentHeading);

                    var question31 = new Question {
                        MainHeadingId = environmentResult.Id, CheckListId = checklist.Id,
                        Content       = "Minimizing the environmental impact to our facility by reducing the consumption of natural resources, and the generation of waste and emissions related to the project, and practicing water conservation. "
                    };
                    await service.CreateQuestion(question31);

                    var question32 = new Question {
                        MainHeadingId = environmentResult.Id, CheckListId = checklist.Id,
                        Content       = "Switch off vehicle engine when doing loading and unloading to reduce pollution."
                    };
                    await service.CreateQuestion(question32);

                    var question33 = new Question {
                        MainHeadingId = environmentResult.Id, CheckListId = checklist.Id,
                        Content       = "Comply with 3 Rs practice. (Reduce, Reuse & Recycle)."
                    };
                    await service.CreateQuestion(question33);

                    #endregion

                    #region Schedule of PPE in warehouse
                    var scheduleHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Schedule of PPE in warehouse"
                    };
                    var scheduleResult = await service.AddHeading(scheduleHeading);

                    var mandatoryHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubHeading, Content = "Mandatory"
                    };
                    var mandatoryResult = await service.AddHeading(mandatoryHeading);

                    var ifHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.SubHeading, Content = "If applicable"
                    };
                    var ifResult = await service.AddHeading(ifHeading);

                    var question34 = new Question {
                        MainHeadingId = scheduleResult.Id, CheckListId = checklist.Id, SubHeadingId = mandatoryResult.Id,
                        Content       = "Safety boots"
                    };
                    await service.CreateQuestion(question34);

                    var question35 = new Question {
                        MainHeadingId = scheduleResult.Id, CheckListId = checklist.Id, SubHeadingId = mandatoryResult.Id,
                        Content       = "Visibility Vest/ Bolloré Uniform"
                    };
                    await service.CreateQuestion(question35);

                    var question36 = new Question {
                        MainHeadingId = scheduleResult.Id, CheckListId = checklist.Id, SubHeadingId = ifResult.Id,
                        Content       = "Gloves"
                    };
                    await service.CreateQuestion(question36);

                    #endregion

                    #region/* Legal Requirement  */
                    var legalHeading = new Heading {
                        CheckListId = checkListDto.Id, HeadingType = HeadingType.MainHeading, Content = "Legal Requirement"
                    };
                    var legalHeadingResult = await service.AddHeading(legalHeading);

                    var question37 = new Question {
                        MainHeadingId = legalHeadingResult.Id, CheckListId = checklist.Id,
                        Content       = "The main legal requirements that were complied (Fire Safety Act, Workplace Safety & Health act, Environmental Protection & Management Act)."
                    };
                    await service.CreateQuestion(question37);


                    #endregion
                }
            }
            catch (Exception ex)
            {
                logger.LogError("Error in checklist seed: ", ex);
            }
        }