示例#1
0
        public void InitialDepartmentCategoryIndicatorMap()
        {
            var           fileName      = HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["DepartmentCategoryIndicatorMap"]);
            ReadFromExcel readFromExcel = new ReadFromExcel();
            //按Row获取当前行的所有数据
            //第一行为列标题,第二行开始是数据
            int rowCount = readFromExcel.GetRowCount(fileName);

            for (int i = 2; i <= rowCount; i++)
            {
                var columnData = readFromExcel.ReadRowFromExcel((uint)i, fileName);
                //获取第一个数为科室类别
                if (columnData.Count >= 2)
                {
                    var firstData = columnData.First();

                    WriteBaseData      writeBaseData      = new WriteBaseData();
                    DepartmentCategory departmentCategory = new DepartmentCategory();
                    //将第一个数当作类别,找到科室类别
                    departmentCategory.Name = firstData;
                    departmentCategory      = writeBaseData.FindDepartmentCategoryByName(departmentCategory.Name);
                    if (departmentCategory == null)
                    {
                        return;
                    }
                    columnData.Remove(firstData);
                    //第二列及之后的数据为项目名称
                    foreach (var data in columnData)
                    {
                        //依次将第二个列之后的项目插入到科室类别项目表中
                        //如果该项目不在数据库,继续下一个数据
                        var indicator = writeBaseData.FindIndicatorByName(data);
                        if (indicator == null)
                        {
                            continue;
                        }
                        //将Indicator添加进去

                        DepartmentCategoryIndicatorMap item = new DepartmentCategoryIndicatorMap();
                        item.DepartmentCategoryID = departmentCategory.DepartmentCategoryID;
                        item.IndicatorID          = indicator.IndicatorID;
                        writeBaseData.AddDepartmentCategoryIndicatorMap(item);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 初始化科室.
        /// </summary>
        public void InitialDepartment()
        {
            var fileName = HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager
                                                              .AppSettings["Department"]);
            //第一列为科室名称,第二列所属科室类别,第三列为科室的Guid
            ReadFromExcel readFromExcel = new ReadFromExcel();
            //按Row获取当前行的所有数据
            int rowCount = readFromExcel.GetRowCount(fileName);

            for (int i = 2; i <= rowCount; i++)
            {
                var columnData = readFromExcel.ReadRowFromExcel((uint)i, fileName);
                //获取第一个数为科室名称
                //数据必须大于等3才是正确的
                if (columnData.Count >= 3)
                {
                    WriteBaseData writeBaseData = new WriteBaseData();
                    //DepartmentCategory departmentCategory = new DepartmentCategory();
                    //第二列为科室类别
                    var name = columnData.ElementAt(1);
                    var departmentCategory = writeBaseData.FindDepartmentCategoryByName(name);
                    if (departmentCategory == null)
                    {
                        return;
                    }
                    Department department = new Department();
                    //第一列为科室名称
                    department.DepartmentName = columnData.ElementAt(0);
                    //第三列为科室Guid
                    department.DepartmentID         = Guid.Parse(columnData.ElementAt(2));
                    department.DepartmentCategoryID = departmentCategory.DepartmentCategoryID;
                    //添加department
                    writeBaseData.AddDepartment(department);
                }
            }
        }