Ejemplo n.º 1
0
 public void CreateNewUnit(EditUnitModel model)
 {
     var trans = TransactionManager.BeginTransaction();
     try
     {
         var unit = new Unit()
         {
             Name = model.FormData.Name,
             IsFlowUint = model.FormData.IsFlowUnit,
             IsWebUint = model.FormData.IsWebUnit,
             ParentUint = model.ParentId.HasValue ? _unitRepository.Find(model.ParentId.Value) : null
         };
         _unitRepository.Save(unit);
         var user = new User()
         {
             Account = "admin",
             Name = "管理员",
             Pwd = Md5Utility.GetMd5HashCode("admin"),
             Unit = unit
         };
         InitUnitPermissions(unit, user);
         _userRepository.Save(user);
         trans.Commit();
     }
     catch (Exception)
     {
         trans.Rollback();
         throw;
     }
 }
Ejemplo n.º 2
0
 public void TestAdd()
 {
     var unitRepository = new UnitRepository();
     Unit unit = new Unit();
     unit.Name = "平湖市人大";
     unit.BannerImgUrl = "dd";
     unitRepository.Save(unit);
 }
Ejemplo n.º 3
0
 public static User GetNpcAuditJieKouRen(Unit unit)
 {
     if (unit.UnitFlowSettings == null)
         throw new ArgumentException(unit.Name + "未设置审批单位相关信息,无法发起议案建议!请联系管理员进行设置");
     var targetUnit = unit.UnitFlowSettings.NpcUnit;
     if (targetUnit.JieKouRen == null)
         throw new ArgumentException(targetUnit.Name + "未设置审批议案建议的接口人,请联系该单位或管理员进行设置");
     return targetUnit.JieKouRen;
 }
Ejemplo n.º 4
0
 public PhoneBook CreateOrGetDefaultPhoneBook(Unit unit)
 {
     var phoneBook = _phoneBookRepository.GetDefaultPhoneBook(unit.Id);
     if (phoneBook == null)
     {
         var newDefaultPhoneBook = new PhoneBook();
         newDefaultPhoneBook.Name = "默认";
         newDefaultPhoneBook.Unit = unit;
         newDefaultPhoneBook.IsDefault = true;
         newDefaultPhoneBook.PhoneBookType = PhoneBookType.Unit;
         newDefaultPhoneBook.RecordDescription.CreateBy(null);
         _phoneBookRepository.Save(newDefaultPhoneBook);
         return newDefaultPhoneBook;
     }
     return phoneBook;
 }
Ejemplo n.º 5
0
        public EditOpenMasConfigModel InitializeEditOpenMasConfigModel(Unit unit)
        {
            var model = new EditOpenMasConfigModel();
            var config = _openMasConfigRepository.GetOpenMasConfigByUnit(unit.Id);
            if (config == null)
                return model;
            model.MmsAppAccount = config.MmsAppAccount;
            model.MmsAppPwd = config.MmsAppPwd;
            model.MmsExtensionNo = config.MmsExtensionNo;
            model.MmsMasService = config.MmsMasService;

            model.SmsAppAccount = config.SmsAppAccount;
            model.SmsAppPwd = config.SmsAppPwd;
            model.SmsExtensionNo = config.SmsExtensionNo;
            model.SmsMasService = config.SmsMasService;

            model.Signature = config.Signature;
            return model;
        }
Ejemplo n.º 6
0
 private static SelectUserOptionsComponent ConvertUnit2SelectUserOptionsRow(Unit unit)
 {
     return new SelectUserOptionsComponent()
     {
         Id = unit.Id,
         Name = unit.Name,
         NodeType = 0,
         IconCls = ApplicationConst.TreeParentNode
     };
 }
Ejemplo n.º 7
0
 private void InitUnitPermissions(Unit unit, User admin)
 {
     var privilegeRepository = new PrivilegeRepository();
     var privileges = privilegeRepository.GetAllPrivileges();
     var roleRepository = new RoleRepository();
     var roles = roleRepository.GetAllRoleByUnitId(unit.Id);
     var role = roles.FirstOrDefault(r => r.Code == "SuperAdmin");
     if (role == null)
     {
         role = new Role();
         role.Name = "超级管理员";
         role.Code = "SuperAdmin";
         role.UnitId = unit.Id;
         privileges.ToList().ForEach(privilege => role.Privileges.Add(privilege));
         roleRepository.Save(role);
     }
     var roleUserRepository = new RoleUserRepository();
     var roleUser = roleUserRepository.GetRoleUserByUserId(admin.Id);
     if (roleUser == null)
     {
         roleUser = new RoleUser();
         roleUser.UserId = admin.Id;
         roleUser.Roles.Add(role);
         roleUserRepository.Save(roleUser);
     }
 }
Ejemplo n.º 8
0
 private UnitTreeModelComponent ConvertUnitToModel(Unit unit, bool isNeedSub)
 {
     var model = new UnitTreeModelComponent()
     {
         Id = unit.Id,
         Name = unit.Name,
         IsFlowUnit = unit.IsFlowUint,
         IsWebUnit = unit.IsWebUint,
         IconCls = ApplicationConst.TreeLeafCls,
     };
     var childrens = _unitRepository.GetSubUnit(unit.Id).ToList();
     if (childrens.Any())
     {
         if (isNeedSub)
         {
             childrens.ForEach(o => model.Childrens.Add(ConvertUnitToModel(o, true)));
         }
         model.IconCls = ApplicationConst.TreeParentNode;
         model.State = isNeedSub ? "open" : "closed";
     }
     return model;
 }