Esempio n. 1
0
        public SdbConnector(string host, bool cache)
        {
            Name = host;

            var client = new EncryptedTcpClient(host);

            //_service = new MysqlDataService("Server=localhost;Database=sdb;User ID=root;CharSet=utf8");
            //_service = new MemoryDataService();
            DataService = new TcpDataService(client);

            if (cache)
                DataService = new CacheDataService(DataService);

            var authenticator = new TcpBasicClientAuthenticator(DataService, client);

            DataService = new AuthDataService(DataService, authenticator);

            try
            {
                authenticator.Login("sorenhk", "abc");
            }
            catch (AuthException e)
            {
                MessageBox.Show(e.Message);
                return;
            }

            ObjectMapper = new ObjectMapper(DataService, authenticator.UserWorkspaceContainerId);
        }
        public void CopyTestSimilar()
        {
            var copier = new ObjectMapper<A, B>();

              A a1 = new A();
              B b1 = copier.Copy(a1);

              Assert.IsNotNull(b1);
              Assert.AreEqual(a1.PropA, b1.PropA);
              Assert.AreEqual(B.PropBValue, b1.GetB());
              Assert.AreEqual(B.PropDValue, b1.GetD());
              Assert.AreEqual((int)a1.PropC, (int)b1.PropC);

              B b2 = new B();
              A a2 = copier.Copy(b2);

              Assert.IsNotNull(a2);
              Assert.AreEqual(b2.PropA, a2.PropA);
              Assert.AreEqual(A.PropBValue, a2.GetB());
              Assert.AreEqual(A.PropDValue, a2.GetD());
              Assert.AreEqual((int)b2.PropC, (int)a2.PropC);

              A a3 = new A {PropC = null};
              B b3 = copier.Copy(a3);
              Assert.IsFalse(b3.PropC.HasValue);
        }
Esempio n. 3
0
 public ProxyImpl(ObjectMapper objectMapper)
 {
     _stringPropertyHandler = new ClassPropertyLoadHandler<string>(this, "StringProperty", objectMapper);
     _integerPropertyHandler = new StructPropertyLoadHandler<int>(this, "IntegerProperty", objectMapper);
     _enumPropertyHandler = new StructPropertyLoadHandler<TestEnumImpl>(this, "EnumProperty", objectMapper);
     _dateTimePropertyHandler = new StructPropertyLoadHandler<DateTime>(this, "DateTimeProperty", objectMapper);
     _collectionPropertyHandler = new CollectionPropertyLoadHandler<ICollection<TestClass>, TestClass>(this, "CollectionProperty", objectMapper);
 }
		private static object GetValue(ObjectMapper mapper, MemberAccessor member, string elemName, out bool isSet)
		{
			object value = mapper.Extension[member.Name][elemName].Value;

			isSet = value != null;

			return value;
		}
Esempio n. 5
0
		public virtual bool GetIgnore(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			isSet = false;

			return
				TypeHelper.IsScalar(member.Type) == false;// ||
				//(member.MemberInfo is FieldInfo && ((FieldInfo)member.MemberInfo).IsLiteral);
		}
		private void EnsureMapper(ObjectMapper mapper)
		{
			if (_mapper != mapper)
			{
				_mapper             = mapper;
				_mapFieldAttributes = null;
			}
		}
Esempio n. 7
0
		protected static MemberMapper[] GetFieldList(ObjectMapper om)
		{
			List<MemberMapper> list = new List<MemberMapper>();

			foreach (MemberMapper mm in om)
				list.Add(mm);

			return list.ToArray();
		}
		private object[] GetMapFieldAttributes(ObjectMapper mapper)
		{
			EnsureMapper(mapper);

			if (_mapFieldAttributes == null)
				_mapFieldAttributes = TypeHelper.GetAttributes(mapper.TypeAccessor.Type, typeof(MapFieldAttribute));

			return _mapFieldAttributes;
		}
		public override string GetFieldName(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			object value = GetValue(mapper, member, "MapField", out isSet);

			if (value != null)
				return value.ToString();

			return base.GetFieldName(mapper, member, out isSet);
		}
		public override bool GetIgnore(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			object value = GetValue(mapper, member, "MapIgnore", out isSet);

			if (value != null)
				return TypeExtension.ToBoolean(value);

			return base.GetIgnore(mapper, member, out isSet);
		}
Esempio n. 11
0
		protected virtual MemberMapper[] GetFieldList(ObjectMapper om)
		{
			var list = new List<MemberMapper>(om.Count);

			foreach (MemberMapper mm in om)
				if (mm.MapMemberInfo.SqlIgnore == false)
					list.Add(mm);

			return list.ToArray();
		}
		public DictionaryListMapper(
			IDictionary          dic,
			NameOrIndexParameter keyField,
			ObjectMapper         objectMapper)
		{
			_dic        = dic;
			_mapper     = objectMapper;
			_fromSource = keyField.ByName && keyField.Name[0] == '@';
			_keyField   = _fromSource? keyField.Name.Substring(1): keyField;
		}
Esempio n. 13
0
		public override bool GetIgnore(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			if (IsLinqObject(mapper.TypeAccessor.Type))
			{
				isSet = true;
				return member.GetAttribute<ColumnAttribute>() == null;
			}

			return base.GetIgnore(mapper, member, out isSet);
		}
        public void CopyTestDifferent()
        {
            var copier = new ObjectMapper<C, D>();

              C c1 = new C();
              D d1 = copier.Copy(c1);

              Assert.IsNotNull(d1);
              Assert.AreEqual(c1.PropA, d1.PropA);
              Assert.AreEqual(c1.PropB, d1.PropB);
        }
		public virtual void InitMapping(InitContext initContext)
		{
			var sm = _dic as ISupportMapping;

			if (sm != null)
			{
				sm.BeginMapping(initContext);

				if (_mapper != initContext.ObjectMapper)
					_mapper = initContext.ObjectMapper;
			}
		}
Esempio n. 16
0
		public override string GetFieldName(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			foreach (MetadataProviderBase p in _list)
			{
				string name = p.GetFieldName(mapper, member, out isSet);

				if (isSet)
					return name;
			}

			return base.GetFieldName(mapper, member, out isSet);
		}
Esempio n. 17
0
		void IMapDataDestinationList.InitMapping(InitContext initContext)
		{
			ISupportMapping sm = _list as ISupportMapping;

			if (sm != null)
			{
				sm.BeginMapping(initContext);

				if (initContext.ObjectMapper != null && _mapper != initContext.ObjectMapper)
					_mapper = initContext.ObjectMapper;
			}
		}
		public override bool GetTrimmable(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			if (member.Type == typeof(string))
			{
				object value = GetValue(mapper, member, "Trimmable", out isSet);

				if (value != null)
					return TypeExtension.ToBoolean(value);
			}

			return base.GetTrimmable(mapper, member, out isSet);
		}
Esempio n. 19
0
		public override bool GetIgnore(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			foreach (MetadataProviderBase p in _list)
			{
				bool ignore = p.GetIgnore(mapper, member, out isSet);

				if (isSet)
					return ignore;
			}

			return base.GetIgnore(mapper, member, out isSet);
		}
Esempio n. 20
0
        internal static object CastValue(ObjectMapper om, string column, object value)
        {

            PropertyMapper pm;
            if (om == null)
                return value;
            pm = om[column];
            if (pm != null && pm.Cast != null)
                return pm.Cast.ToColumn(value, pm.Handler.Property.PropertyType, null);


            return value;
        }
Esempio n. 21
0
		public override bool GetNullable(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			if (IsLinqObject(mapper.TypeAccessor.Type))
			{
				var attr = member.GetAttribute<ColumnAttribute>();

				if (attr != null)
				{
					isSet = true;
					return attr.CanBeNull;
				}
			}

			return base.GetNullable(mapper, member, out isSet);
		}
Esempio n. 22
0
		public override string GetFieldName(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			if (IsLinqObject(mapper.TypeAccessor.Type))
			{
				ColumnAttribute a = member.GetAttribute<ColumnAttribute>();

				if (a != null && !string.IsNullOrEmpty(a.Name))
				{
					isSet = true;
					return a.Name;
				}
			}

			return base.GetFieldName(mapper, member, out isSet);
		}
Esempio n. 23
0
        static void Main(string[] args)
        {
            ObjectMapper mapper = new ObjectMapper();
            mapper.AddClassMapFromFile("Goods.xml");

            mapper.ClassMaps[0].ToXmlFile(@"C:\test.xml");
            mapper.ClassMaps[1].ToXmlFile(@"C:\test1.xml");

            mapper.ClassMaps.Clear();

            mapper.AddClassMapFromXmlFile(@"C:\test.xml");
            mapper.AddClassMapFromXmlFile(@"C:\test1.xml");

            Console.WriteLine(mapper.ClassMaps[1].ClassType.ToString());

            KmlDocument kdoc = new KmlDocument();
            kdoc.LoadFromFile("Goods.txt");

            //clone first node

            kdoc.ChildNodes.Add(kdoc.ChildNodes[0].Clone());

            List<Goods> goodsList = mapper.LoadList<Goods>(kdoc.SelectNodes("goods"));

            foreach (Goods goods in goodsList)
            {

               Console.WriteLine("Index: {0}", goods.Index);

                Console.WriteLine("Items =>");
                foreach (GoodsItem goodsItem in goods.Items)
                {
                    Console.WriteLine("   Value1: {0}", goodsItem.Value1);
                    Console.WriteLine("   Value2: {0}", goodsItem.Value2);
                    Console.WriteLine("   Value3: {0}", goodsItem.Value3);
                }
            }

            Console.WriteLine("KML > Object done.");

            Goods goods0 = goodsList[0];
            KmlNode goodsKml = mapper.Save(goods0);

            Console.WriteLine(goodsKml);

            Console.ReadLine();
        }
Esempio n. 24
0
		protected MemberMapper[] GetNonKeyFieldList(ObjectMapper om)
		{
			TypeExtension      typeExt = TypeExtension.GetTypeExtension(om.TypeAccessor.OriginalType, Extensions);
			List<MemberMapper> list    = new List<MemberMapper>();

			foreach (MemberMapper mm in om)
			{
				MemberAccessor ma = mm.MemberAccessor;

				bool isSet;
				MappingSchema.MetadataProvider.GetPrimaryKeyOrder(om.TypeAccessor.OriginalType, typeExt, ma, out isSet);

				if (!isSet)
					list.Add(mm);
			}

			return list.ToArray();
		}
Esempio n. 25
0
		protected virtual MemberMapper[] GetNonKeyFieldList(ObjectMapper om)
		{
			var typeExt = TypeExtension.GetTypeExtension(om.TypeAccessor.OriginalType, Extensions);
			var list    = new List<MemberMapper>();

			foreach (MemberMapper mm in om)
			{
				if (mm.MapMemberInfo.SqlIgnore)
					continue;

				var ma = mm.MapMemberInfo.MemberAccessor;

				bool isSet;
				MappingSchema.MetadataProvider.GetPrimaryKeyOrder(om.TypeAccessor.OriginalType, typeExt, ma, out isSet);

				if (!isSet)
					list.Add(mm);
			}

			return list.ToArray();
		}
		public DictionaryIndexListMapper(
			IDictionary  dic,
			MapIndex     index,
			ObjectMapper objectMapper)
		{
			_dic    = dic;
			_mapper = objectMapper;

			_fields = new NameOrIndexParameter[index.Fields.Length];
			_fromSource = new bool[index.Fields.Length];

			for (int i = 0; i < _fields.Length; i++)
			{
				bool fromSource = index.Fields[i].ByName && index.Fields[i].Name[0] == '@';

				_fields[i]     = fromSource? index.Fields[i].Name.Substring(1): index.Fields[i];
				_fromSource[i] = fromSource;
				_isFromSource  = _isFromSource ||  fromSource;
				_isFromDest    = _isFromDest   || !fromSource;
			}
		}
		public override bool GetIgnore(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			MapIgnoreAttribute attr = member.GetAttribute<MapIgnoreAttribute>();

			if (attr == null)
				attr = (MapIgnoreAttribute)TypeHelper.GetFirstAttribute(member.Type, typeof(MapIgnoreAttribute));

			if (attr != null)
			{
				isSet = true;
				return attr.Ignore;
			}

			if (member.GetAttribute<MapImplicitAttribute>() != null ||
				TypeHelper.GetFirstAttribute(member.Type, typeof(MapImplicitAttribute)) != null)
			{
				isSet = true;
				return false;
			}

			return base.GetIgnore(mapper, member, out isSet);
		}
		public override string GetFieldName(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			MapFieldAttribute a = member.GetAttribute<MapFieldAttribute>();

			if (a != null)
			{
				isSet = true;
				return a.MapName;
			}

			string name = member.Name.ToLower();

			foreach (MapFieldAttribute attr in GetMapFieldAttributes(mapper))
			{
				if (attr.OrigName.ToLower() == name)
				{
					isSet = true;
					return attr.MapName;
				}
			}

			return base.GetFieldName(mapper, member, out isSet);
		}
		public override MapValue[] GetMapValues(ObjectMapper mapper, MemberAccessor member, out bool isSet)
		{
			AttributeExtensionCollection extList = mapper.Extension[member.Name]["MapValue"];

			if (extList == AttributeExtensionCollection.Null)
				return GetMapValues(mapper.Extension, member.Type, out isSet);

			List<MapValue> list = new List<MapValue>(extList.Count);

			foreach (AttributeExtension ext in extList)
			{
				object origValue = ext["OrigValue"];

				if (origValue != null)
				{
					origValue = TypeExtension.ChangeType(origValue, member.Type);
					list.Add(new MapValue(origValue, ext.Value));
				}
			}

			isSet = true;

			return list.ToArray();
		}
Esempio n. 30
0
 public async Task <Attendance_Dto> GetCustomAsync(int id)
 {
     return(ObjectMapper.Map <Attendance, Attendance_Dto>(await Repository.GetAsync(id, true)));
 }
Esempio n. 31
0
        public async Task <ListResultDto <JobDto> > GetAllJobs()
        {
            var jobs = await _repository.GetListAsync();

            return(new ListResultDto <JobDto>(ObjectMapper.Map <List <Job>, List <JobDto> >(jobs)));
        }
Esempio n. 32
0
        public async Task <OrganizationDto> Get(Guid id)
        {
            var result = await _repository.GetAsync(id);

            return(ObjectMapper.Map <Organization, OrganizationDto>(result));
        }
        public virtual async Task <ActionResult> Register(RegisterTenantInput model)
        {
            try
            {
                if (UseCaptchaOnRegistration())
                {
                    model.CaptchaResponse = HttpContext.Request.Form[RecaptchaValidator.RecaptchaResponseKey];
                }

                var result = await _tenantRegistrationAppService.RegisterTenant(model);

                CurrentUnitOfWork.SetTenantId(result.TenantId);

                var user = await _userManager.FindByNameAsync(AbpUserBase.AdminUserName);

                //Directly login if possible
                if (result.IsTenantActive && result.IsActive && !result.IsEmailConfirmationRequired &&
                    !_webUrlService.SupportsTenancyNameInUrl)
                {
                    var loginResult = await GetLoginResultAsync(user.UserName, model.AdminPassword, model.TenancyName);

                    if (loginResult.Result == AbpLoginResultType.Success)
                    {
                        await _signInManager.SignOutAsync();

                        await _signInManager.SignInAsync(loginResult.Identity, false);

                        SetTenantIdCookie(result.TenantId);

                        return(Redirect(Url.Action("Index", "Home", new { area = "Sys" })));
                    }

                    Logger.Warn("New registered user could not be login. This should not be normally. login result: " + loginResult.Result);
                }

                //Show result page
                var resultModel = ObjectMapper.Map <TenantRegisterResultViewModel>(result);

                resultModel.TenantLoginAddress = _webUrlService.SupportsTenancyNameInUrl
                    ? _webUrlService.GetSiteRootAddress(model.TenancyName).EnsureEndsWith('/') + "Account/Login"
                    : "";

                return(View("RegisterResult", resultModel));
            }
            catch (UserFriendlyException ex)
            {
                ViewBag.UseCaptcha   = UseCaptchaOnRegistration();
                ViewBag.ErrorMessage = ex.Message;

                var viewModel = new TenantRegisterViewModel
                {
                    PasswordComplexitySetting = await _passwordComplexitySettingStore.GetSettingsAsync(),
                    EditionId             = model.EditionId,
                    SubscriptionStartType = model.SubscriptionStartType,
                    EditionPaymentType    = EditionPaymentType.NewRegistration,
                    Gateway   = model.Gateway,
                    PaymentId = model.PaymentId
                };

                if (model.EditionId.HasValue)
                {
                    viewModel.Edition = await _tenantRegistrationAppService.GetEdition(model.EditionId.Value);

                    viewModel.EditionId = model.EditionId.Value;
                }

                return(View("Register", viewModel));
            }
        }
        private async Task Update(CreateOrEditDepartamentoDto input)
        {
            var departamento = await _departamentoRepository.FirstOrDefaultAsync((long)input.Id);

            ObjectMapper.Map(input, departamento);
        }
Esempio n. 35
0
        public async Task OnGetAsync()
        {
            var blog = await BlogAdminAppService.GetAsync(Id);

            ViewModel = ObjectMapper.Map <BlogDto, UpdateBlogViewModel>(blog);
        }
Esempio n. 36
0
        public override async Task <OcelotDto> GetAsync(Guid id)
        {
            var entity = await OcelotRepository.GetAsync(id).ConfigureAwait(false);

            return(ObjectMapper.Map <Ocelot, OcelotDto>(entity));
        }
Esempio n. 37
0
        protected override User MapToEntity(CreateUserDto createInput)
        {
            var user = ObjectMapper.Map <User>(createInput);

            return(user);
        }
Esempio n. 38
0
        public async Task OnGetAsync()
        {
            var bookDto = await _bookAppService.GetAsync(Id);

            Book = ObjectMapper.Map <BookDto, CreateUpdateBookDto>(bookDto);
        }
Esempio n. 39
0
        public virtual async Task <List <OcelotRouteDto> > GetRoutesAsync(Guid id)
        {
            var routes = await OcelotRepository.GetRoutesAsync(id);

            return(ObjectMapper.Map <List <OcelotRoute>, List <OcelotRouteDto> >(routes));
        }
Esempio n. 40
0
        public PagedResultDto <VW_SJMX> GetPagedVwSjmxs(GetVwSjmxsInput input)
        {
            /* 方法一
             * Expression condition = null;
             * ParameterExpression param = Expression.Parameter(typeof(VW_SJMX), "p");
             * Expression right = Expression.Constant("-1");
             * Expression left = Expression.Property(param, typeof(VW_SJMX).GetProperty("送检单号"));
             * Expression filter = Expression.NotEqual(left, right); // 送检单号 != -1
             * condition = filter;
             *
             * right = Expression.Constant("12345");
             * left = Expression.Property(param, typeof(VW_SJMX).GetProperty("送检单号"));
             * filter = Expression.Equal(left, right);
             * condition = Expression.And(condition, filter);
             * var predicate = Expression.Lambda<Func<VW_SJMX, bool>>(condition, param);
             */

            /* 方法二 */

            Expression <Func <VW_SJMX, bool> > predicate = p => p.器具名称 == "全站仪";

            //if (input.From != null) // DateTime? 会有问题
            if (input.From > DateTime.MinValue)
            {
                predicate = predicate.And(p => p.送检日期 >= DateTime.Parse(input.From.ToString())); // input.From
            }
            if (input.To > DateTime.MinValue)                                                    // != null
            {
                predicate = predicate.And(p => p.送检日期 <= DateTime.Parse(input.To.ToString()));   // input.To
            }

            //if (!input.Filter.IsNullOrWhiteSpace())
            if (!input.WTDH.IsNullOrWhiteSpace())
            {
                predicate = predicate.And(p => p.送检单号.Contains(input.WTDH));
            }

            if (!input.WTDW.IsNullOrWhiteSpace())
            {
                predicate = predicate.And(p => p.单位名称.Contains(input.WTDW));
            }

            var totalCount = _vwsjmxDapperRepository.Count(predicate);

            /* - 固定查询条件
             * var totalCount1 = _vwsjmxDapperRepository.Count(
             *  a => (a.器具名称 == "全站仪") &&
             *  a.送检单号.Contains(input.FilterText) &&
             *  a.送检日期 >= input.From &&
             *  a.送检日期 <= input.To
             *  );
             * //IEnumerable<VW_SJMX> ret = _vwsjmxDapperRepository.GetAllPaged(x => x.器具名称 == "全站仪", 2, 20, "ID");
             * //IEnumerable<VW_SJMX> ret = _vwsjmxDapperRepository.GetAllPaged(a =>(a.器具名称 == "全站仪") && a.送检单号.Contains(input.FilterText), input.SkipCount/input.MaxResultCount, input.MaxResultCount, input.Sorting);
             */

            //Logger.Info("input.Filter.IsNullOrWhiteSpace():" + input.Filter.IsNullOrWhiteSpace());
            //Logger.Info("input.Filter.IsNullOrEmpty():" + input.Filter.IsNullOrEmpty());
            //Logger.Info("input.Filter == ''" + (input.Filter == ""));
            //Logger.Info(predicate.Body.ToString());

            //Logger.Info(predicate.Body.ToString());

            IEnumerable <VW_SJMX> ret = _vwsjmxDapperRepository.GetAllPaged(
                predicate,
                input.SkipCount / input.MaxResultCount,
                input.MaxResultCount,
                input.Sorting, input.Order == "asc"); // input.Order=="asc"  true/false

            /*
             * List<VW_SJMX> tempList = new List<VW_SJMX>();
             * IEnumerator<VW_SJMX> currentEnumerator = ret.GetEnumerator();
             * if (currentEnumerator != null)
             * {
             *  for (int count = 0; currentEnumerator.MoveNext(); count++)
             *  {
             *      tempList.Add(currentEnumerator.Current);
             *  }
             * }
             */

            List <VW_SJMX> tempList2 = ObjectMapper.Map <List <VW_SJMX> >(ret);

            return(new PagedResultDto <VW_SJMX>(
                       totalCount,
                       tempList2
                       ));
        }
Esempio n. 41
0
 protected override void MapToEntity(UserDto input, User user)
 {
     ObjectMapper.Map(input, user);
     user.SetNormalizedNames();
 }
Esempio n. 42
0
        public async Task <ListResultDto <RoleDto> > GetRoles()
        {
            var roles = await _roleRepository.GetAllListAsync();

            return(new ListResultDto <RoleDto>(ObjectMapper.Map <List <RoleDto> >(roles)));
        }
Esempio n. 43
0
        public async Task <JobDto> Get(Guid id)
        {
            var result = await _repository.GetAsync(id);

            return(ObjectMapper.Map <Job, JobDto>(result));
        }
Esempio n. 44
0
    public async Task <AuthorDto> GetAsync(Guid id)
    {
        var author = await _authorRepository.GetAsync(id);

        return(ObjectMapper.Map <Author, AuthorDto>(author));
    }
Esempio n. 45
0
        public async Task <GetUserForEditOutput> GetUserForEdit(NullableIdDto <long> input)
        {
            //Getting all available roles
            var userRoleDtos = await _roleManager.Roles
                               .OrderBy(r => r.DisplayName)
                               .Select(r => new UserRoleDto
            {
                RoleId          = r.Id,
                RoleName        = r.Name,
                RoleDisplayName = r.DisplayName
            })
                               .ToArrayAsync();

            var allOrganizationUnits = await _organizationUnitRepository.GetAllListAsync();

            var output = new GetUserForEditOutput
            {
                Roles = userRoleDtos,
                AllOrganizationUnits      = ObjectMapper.Map <List <OrganizationUnitDto> >(allOrganizationUnits),
                MemberedOrganizationUnits = new List <string>()
            };

            if (!input.Id.HasValue)
            {
                //Creating a new user
                output.User = new UserEditDto
                {
                    IsActive = true,
                    ShouldChangePasswordOnNextLogin = true,
                    IsTwoFactorEnabled = await SettingManager.GetSettingValueAsync <bool>(AbpZeroSettingNames.UserManagement.TwoFactorLogin.IsEnabled),
                    IsLockoutEnabled   = await SettingManager.GetSettingValueAsync <bool>(AbpZeroSettingNames.UserManagement.UserLockOut.IsEnabled)
                };

                foreach (var defaultRole in await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync())
                {
                    var defaultUserRole = userRoleDtos.FirstOrDefault(ur => ur.RoleName == defaultRole.Name);
                    if (defaultUserRole != null)
                    {
                        defaultUserRole.IsAssigned = true;
                    }
                }
            }
            else
            {
                //Editing an existing user
                var user = await UserManager.GetUserByIdAsync(input.Id.Value);

                output.User             = ObjectMapper.Map <UserEditDto>(user);
                output.ProfilePictureId = user.ProfilePictureId;

                foreach (var userRoleDto in userRoleDtos)
                {
                    userRoleDto.IsAssigned = await UserManager.IsInRoleAsync(user, userRoleDto.RoleName);
                }

                var organizationUnits = await UserManager.GetOrganizationUnitsAsync(user);

                output.MemberedOrganizationUnits = organizationUnits.Select(ou => ou.Code).ToList();
            }

            return(output);
        }
        protected virtual async Task Update(CreateOrEditCruiseContractCommissionsDto input)
        {
            var cruiseContractCommissions = await _cruiseContractCommissionsRepository.FirstOrDefaultAsync((int)input.Id);

            ObjectMapper.Map(input, cruiseContractCommissions);
        }
Esempio n. 47
0
        public virtual async Task <OcelotWithDetailsDto> FindByNameAsync(string name)
        {
            var config = await OcelotRepository.FindByNameAsync(name);

            return(ObjectMapper.Map <Ocelot, OcelotWithDetailsDto>(config));
        }
        public async Task <ListResultDto <AggregateReRouteDto> > GetAsync(AggregateRouteGetByAppIdInputDto input)
        {
            var reroutes = await _aggregateReRouteRepository.GetByAppIdAsync(input.AppId);

            return(new ListResultDto <AggregateReRouteDto>(ObjectMapper.Map <List <AggregateReRoute>, List <AggregateReRouteDto> >(reroutes)));
        }
Esempio n. 49
0
    public async Task <List <TodoDto> > GetListAsync()
    {
        var items = await _todoRepository.GetListAsync();

        return(ObjectMapper.Map <List <Todo>, List <TodoDto> >(items));
    }
        public async Task <EditionSelectDto> GetEdition(int editionId)
        {
            var edition = await _editionManager.GetByIdAsync(editionId);

            var editionDto = ObjectMapper.Map <EditionSelectDto>(edition);

            foreach (var paymentGateway in Enum.GetValues(typeof(SubscriptionPaymentGatewayType)).Cast <SubscriptionPaymentGatewayType>())
            {
                using (var paymentGatewayManager = _paymentGatewayManagerFactory.Create(paymentGateway))
                {
                    var additionalData = await paymentGatewayManager.Object.GetAdditionalPaymentData(ObjectMapper.Map <SubscribableEdition>(edition));

                    editionDto.AdditionalData.Add(paymentGateway, additionalData);
                }
            }

            return(editionDto);
        }
 static Context()
 {
     ObjectMapper.MapObjects();
 }
Esempio n. 52
0
        private async Task Update(CreateOrEditQuotationDto input)
        {
            var quotation = await _quotationRepository.FirstOrDefaultAsync((int)input.Id);

            ObjectMapper.Map(input, quotation);
        }
Esempio n. 53
0
 public GroupQueryDto(ObjectMapper objectMapper, MultivaluedMap <string, string> queryParameters) : base(objectMapper, queryParameters)
 {
 }
Esempio n. 54
0
		public SqlQueryInfo(ObjectMapper objectMapper)
		{
			ObjectMapper = objectMapper;
		}
        protected virtual async Task CreateUserAsync(CreateOrUpdateUserInput input)
        {
            if (AbpSession.TenantId.HasValue)
            {
                await _userPolicy.CheckMaxUserCountAsync(AbpSession.GetTenantId());
            }

            var user = ObjectMapper.Map <User>(input.User); //Passwords is not mapped (see mapping configuration)

            user.TenantId = AbpSession.TenantId;

            //Set password
            if (input.SetRandomPassword)
            {
                var randomPassword = await _userManager.CreateRandomPassword();

                user.Password       = _passwordHasher.HashPassword(user, randomPassword);
                input.User.Password = randomPassword;
            }
            else if (!input.User.Password.IsNullOrEmpty())
            {
                await UserManager.InitializeOptionsAsync(AbpSession.TenantId);

                foreach (var validator in _passwordValidators)
                {
                    CheckErrors(await validator.ValidateAsync(UserManager, user, input.User.Password));
                }

                user.Password = _passwordHasher.HashPassword(user, input.User.Password);
            }

            user.ShouldChangePasswordOnNextLogin = input.User.ShouldChangePasswordOnNextLogin;

            //Assign roles
            user.Roles = new Collection <UserRole>();
            foreach (var roleName in input.AssignedRoleNames)
            {
                var role = await _roleManager.GetRoleByNameAsync(roleName);

                user.Roles.Add(new UserRole(AbpSession.TenantId, user.Id, role.Id));
            }

            CheckErrors(await UserManager.CreateAsync(user));
            await CurrentUnitOfWork.SaveChangesAsync(); //To get new user's Id.

            //Notifications
            await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());

            await _appNotifier.WelcomeToTheApplicationAsync(user);

            //Organization Units
            await UserManager.SetOrganizationUnitsAsync(user, input.OrganizationUnits.ToArray());

            //Send activation email
            if (input.SendActivationEmail)
            {
                user.SetNewEmailConfirmationCode();
                await _userEmailer.SendEmailActivationLinkAsync(
                    user,
                    AppUrlService.CreateEmailActivationUrlFormat(AbpSession.TenantId),
                    input.User.Password
                    );
            }
        }
 internal static void SetMapper()
 {
     Mapper = new ObjectMapper <IIPagedItemsRowSets, IPagedItemsRowSets>(src => src == null ? null : ((IPagedItemsRowSetsWrapper)src).r_Instance, src => new IPagedItemsRowSetsWrapper(src));
 }
Esempio n. 57
0
 public List <ExternalLoginProviderInfoModel> GetExternalAuthenticationProviders()
 {
     return(ObjectMapper.Map <List <ExternalLoginProviderInfoModel> >(_externalAuthConfiguration.Providers));
 }
Esempio n. 58
0
		 protected virtual async Task Update(CreateOrEditTestEntityDto input)
         {
            var testEntity = await _testEntityRepository.FirstOrDefaultAsync((int)input.Id);
             ObjectMapper.Map(input, testEntity);
         }
Esempio n. 59
0
        public async Task <EntityDynamicParameterValueDto> Get(int id)
        {
            var entity = await _entityDynamicParameterValueManager.GetAsync(id);

            return(ObjectMapper.Map <EntityDynamicParameterValueDto>(entity));
        }
Esempio n. 60
0
 protected override void MapToEntity(UpdateUserDto input, User user)
 {
     ObjectMapper.Map(input, user);
 }