예제 #1
0
        static void Main(string[] args)
        {
            var filePath = @"F:\国有资产展示系统\QZCHY.QZStatePropertyManagementSystem\Presentation\QZCHY.API\App_Data\import.xls";

            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + filePath + ";" + "Extended Properties=Excel 8.0;";

            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(strConn);
            conn.Open();
            string strExcel = "";

            System.Data.OleDb.OleDbDataAdapter myCommand = null;
            System.Data.DataSet ds = null;
            strExcel  = "select * from [sheet1$]";
            myCommand = new System.Data.OleDb.OleDbDataAdapter(strExcel, strConn);
            ds        = new System.Data.DataSet(); myCommand.Fill(ds, "table1");

            var table = ds.Tables[0];

            for (var i = 1; i < table.Rows.Count; i++)
            {
                var row = table.Rows[i];

                string governmentName       = row[1].ToString();
                string parentGovernmentName = row[2].ToString();

                //判断是否存在
                var government = new GovernmentUnit {
                };

                var property = new Property {
                };
            }
        }
예제 #2
0
        public void UpdateGovernmentUnit(GovernmentUnit governmentUnit)
        {
            if (governmentUnit == null)
            {
                throw new ArgumentNullException("governmentUnit");
            }

            _governmentUnitRepository.Update(governmentUnit);

            //cache
            _cacheManager.RemoveByPattern(GOVERNMENTUNITS_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityUpdated(governmentUnit);
        }
예제 #3
0
        public void InsertGovernmentUnit(GovernmentUnit governmentUnit)
        {
            if (governmentUnit == null)
            {
                throw new ArgumentNullException("governmentUnit");
            }

            //插入前名称唯一性判断
            //if (!NameUniqueCheck(governmentUnit.Name)) throw new ArgumentException(string.Format("商家名称 {0} 已经存在", governmentUnit.Name));

            _governmentUnitRepository.Insert(governmentUnit);

            //cache
            _cacheManager.RemoveByPattern(GOVERNMENTUNITS_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityInserted(governmentUnit);
        }
예제 #4
0
        /// <summary>
        /// 删除店铺
        /// </summary>
        /// <param name="governmentUnit"></param>
        public void DeleteGovernmentUnit(GovernmentUnit governmentUnit)
        {
            if (governmentUnit == null)
            {
                throw new ArgumentNullException("governmentUnit is null");
            }

            governmentUnit.Deleted = true;
            UpdateGovernmentUnit(governmentUnit);

            //父节点单位删除或,子节点单位一并删除
            var subGovernments = GetAllGovernmentsByParentGovernmentId(governmentUnit.Id);

            foreach (var subGovernment in subGovernments)
            {
                subGovernment.Deleted = true;
                UpdateGovernmentUnit(subGovernment);
            }
        }
예제 #5
0
        public void DeleteGovernmentUsers(GovernmentUnit governmentUnit)
        {
            if (governmentUnit == null)
            {
                throw new ArgumentNullException("要删除的部门不存在");
            }

            if (governmentUnit.Deleted)
            {
                var query = from au in _accountUserRepository.Table
                            where au.Government.Id == governmentUnit.Id
                            select au;

                var accountUsers = query.ToList();

                foreach (var accountUser in accountUsers)
                {
                    DeleteAccountUser(accountUser);
                }
            }
        }
예제 #6
0
 public static GovernmentUnit ToEntity(this GovernmentUnitModel model, GovernmentUnit destination)
 {
     return(model.MapTo(destination));
 }
예제 #7
0
 public static GeoGorvernmentModel ToGeoModel(this GovernmentUnit entity)
 {
     return(entity.MapTo <GovernmentUnit, GeoGorvernmentModel>());
 }
예제 #8
0
        public IHttpActionResult SetRoles()
        {
            //  return BadRequest("角色配置 cloesd");
            #region 用户角色创建

            var crAdministrators = new AccountUserRole();
            var crRegistered     = new AccountUserRole();

            var roleNames = new List <string> {
                SystemAccountUserRoleNames.Administrators,
                SystemAccountUserRoleNames.DataReviewer,
                SystemAccountUserRoleNames.GovAuditor,
                SystemAccountUserRoleNames.StateOwnerAuditor,
                SystemAccountUserRoleNames.ParentGovernmentorAuditor,
                SystemAccountUserRoleNames.Registered
            };

            foreach (var roleName in roleNames)
            {
                var role = _accountUserService.GetAccountUserRoleBySystemName(roleName);
                if (role == null)
                {
                    role = new AccountUserRole
                    {
                        Name         = roleName,
                        Active       = true,
                        IsSystemRole = true,
                        SystemName   = roleName
                    };

                    _accountUserService.InsertAccountUserRole(role);
                }
                if (roleName == SystemAccountUserRoleNames.Administrators)
                {
                    crAdministrators = role;
                }
                if (roleName == SystemAccountUserRoleNames.Registered)
                {
                    crRegistered = role;
                }
            }
            #endregion
            #region 测试组织机构

            var cz = new GovernmentUnit
            {
                Name           = "县财政局",
                GovernmentType = GovernmentType.Government,
                Person         = "联系人",
                Tel            = "0570-5062456"
            };
            _governmentService.InsertGovernmentUnit(cz);

            #endregion

            #region 用户创建

            var user = new AccountUser()
            {
                UserName         = "******",
                AccountUserGuid  = Guid.NewGuid(),
                Active           = true,
                CreatedOn        = DateTime.Now,
                IsSystemAccount  = false,
                Password         = "******",
                PasswordFormat   = PasswordFormat.Clear,
                LastActivityDate = DateTime.Now,
                Deleted          = false,
                UpdatedOn        = DateTime.Now,
                Government       = cz
            };
            user.AccountUserRoles.Add(crAdministrators);
            user.AccountUserRoles.Add(crRegistered);
            _accountUserService.InsertAccountUser(user);

            user = new AccountUser()
            {
                UserName         = "******",
                AccountUserGuid  = Guid.NewGuid(),
                Active           = true,
                CreatedOn        = DateTime.Now,
                IsSystemAccount  = false,
                Password         = "******",
                PasswordFormat   = PasswordFormat.Clear,
                LastActivityDate = DateTime.Now,
                Deleted          = false,
                UpdatedOn        = DateTime.Now,
                Government       = cz
            };
            _accountUserService.InsertAccountUser(user);

            #endregion

            return(Ok("角色配置完成"));
        }