示例#1
0
        //return a token info with username password pair
        public string Login(Dtos loginInfo)
        {
            var user = _users.Where(x => x.Username == loginInfo.Username && x.Password == loginInfo.Password).SingleOrDefault();

            if (user == null)
            {
                return(null);
            }

            var signingKey     = Convert.FromBase64String(_configuration["Jwt:SigningSecret"]);
            var expirationTime = int.Parse(_configuration["Jwt:ExpirationDate"]);

            var tokenDescription = new Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor
            {
                //One can add new paramaters in the token Description
                Issuer    = null,
                Audience  = null,
                IssuedAt  = DateTime.UtcNow,
                NotBefore = DateTime.UtcNow,
                Expires   = DateTime.UtcNow.AddMinutes(expirationTime),
                //define the cypher method
                SigningCredentials = new Microsoft.IdentityModel.Tokens.SigningCredentials(new SymmetricSecurityKey(signingKey), SecurityAlgorithms.HmacSha256Signature)
            };
            var jwtTokenHandler = new JwtSecurityTokenHandler();
            var jwtToken        = jwtTokenHandler.CreateJwtSecurityToken(tokenDescription);
            var token           = jwtTokenHandler.WriteToken(jwtToken);

            return(token);
        }
示例#2
0
 public void Process(Dtos.Strategy obj)
 {
     obj.UnitStrategies.Select(x => x.Value)
         .Where(x => x.MakeAttackSense && x.Situation != Enum.Situation.Attacking)
         .Select(GetUnitAttacksEvent)
         .ForEach(_eventStoreService.Store);
 }
示例#3
0
 private Infantery GetInfantery(Dtos.Strategy strategy)
 {
     return _componentService.Get<Infantery>()
         .Where(x => strategy.UnitStrategies[x.Id].Situation == Enum.Situation.DoNothing)
         .Shuffle()
         .First();
 }
 public bool IsUsed(Dtos.Strategy obj)
 {
     return _componentService.Get<HeadQuater>().Any() && _componentService.Get<Barrack>().Any() &&
            _componentService.Get<UnitBase>().Count() > 1 &&
            GetLowLifeInfantery(obj.UnitStrategies.Select(x => x.Value.Target)).Any() &&
            obj.UnitStrategies.Select(x => x.Value).Any(y => y.Target is IAttacker && y.Situation == Enum.Situation.DoNothing);
 }
 public CompanyConfigsDto GetCompanyConfig(Dtos.GetCompanyInput input)
 {
     var companyConfig = _companyConfigRepository.GetCompanyConfigurations(Guid.Parse(input.CompanyId));
     CompanyConfigsDto configList = new CompanyConfigsDto();
     configList.CompanyConfigList = Mapper.Map<List<CompanyConfigDto>>(companyConfig);
     return configList;
 }
示例#6
0
 public void Process(Dtos.Strategy obj)
 {
     var victimPosition = GetEnemiesNearBarrack().First().Position;
     _componentService.Get<UnitBase>()
         .Where(x => x is IAttacker)
         .Where(x => obj.UnitStrategies[x.Id].Situation == Enum.Situation.DoNothing)
         .Select(x => GetMoveUnitEvent(x, victimPosition))
         .ForEach(_eventStoreService.Store);
 }
示例#7
0
        public IActionResult Login(Dtos log)
        {
            var jwtToken = _authentication.Login(log);

            if (jwtToken == null)
            {
                return(Unauthorized());
            }
            return(Ok(jwtToken));
        }
        public void Cadastrar(Dtos.SolicitacaoDto solicitacaoDto)
        {
            var solicitacaoEntity = SolicitacaoFactory.Create(
                solicitacaoDto.Nome, solicitacaoDto.CodigoObjetivo,
                solicitacaoDto.Descricao, solicitacaoDto.CodigoUsuarioCriacao,
                solicitacaoDto.AreaAtualUsuarioCriacao, _usuarioRepository);

            Begin();
            _solicitacaoDomainService
                .Cadastrar(solicitacaoEntity);
            SaveChanges();
        }
        public Dtos.GetTipsCategoriesOutput GetTipsCategories(Dtos.GetTipsCategoriesInput input)
        {
            //Called specific GetAllWithPeople method of task repository.
            var types = _tipsCategoriesRepository.GetAll();

            //Used AutoMapper to automatically convert List<Task> to List<TaskDto>.
            //We must declare mappings to be able to use AutoMapper
            return new Dtos.GetTipsCategoriesOutput
            {
                TipsCategories = Mapper.Map<List<Dtos.TipsCategoriesDto>>(types)
            };
        }
        public Dtos.GetLocationOutput GetLocations(Dtos.GetLocationInput input)
        {
            //Called specific GetAllWithPeople method of task repository.
            var types = _locationRepository.GetAll();

            //Used AutoMapper to automatically convert List<Task> to List<TaskDto>.
            //We must declare mappings to be able to use AutoMapper
            return new Dtos.GetLocationOutput
            {
                Locations = Mapper.Map<List<Dtos.LocationDto>>(types)
            };
        }
        /// <summary>
        /// Receives search criteria parameters (key/value pair) and returns a list of matching Subscribers
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Dtos.NotificationResults SendNotification(Dtos.NotificationInput input)
        {
            Logger.ErrorFormat("CH000:START5a1");
            Dtos.NotificationResults returnResults = new Dtos.NotificationResults();
            returnResults.ResponseMessage = String.Empty;
            List<string> recipients = new List<string>();
            List<CompanyConfig> companyConfig = new List<CompanyConfig>();
            try
            {
                Logger.ErrorFormat("CH000:START5a2");
                companyConfig = _companyConfigRepository.GetCompanyConfigurations(input.CompanyId);
                Logger.ErrorFormat("CH000:START5a3");

                try
                {
                    // Find your Account Sid and Auth Token at twilio.com/user/account 
                    string AccountSid = companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero_Twilio:AccountSid"])).Value != null
                        ? companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero_Twilio:AccountSid"])).Value : "";
                    string AuthToken = companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero_Twilio:AuthToken"])).Value != null
                        ? companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero_Twilio:AuthToken"])).Value : "";
                    var twilio = new TwilioRestClient(AccountSid, AuthToken);
                    string statusCallback = "";

                    string isActive = companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero_Twilio:IsActive"])).Value != null
                    ? companyConfig.Find(cc => cc.Name.Equals(System.Configuration.ConfigurationSettings.AppSettings["creditsHero_Twilio:IsActive"])).Value
                    : "false";
                    if (isActive == "true")
                    {
                        //var response = twilio.SendMessage("+17209999740", input.EmailTo, input.EmailMessage, null, statusCallback);
                        twilio.SendMessage("+17209999740", input.EmailTo, input.EmailMessage, string.Empty, null);
                    }

                    returnResults.ResponseMessage = "Text Message Send Successful";

                    return returnResults;
                }
                catch (System.Exception exc)
                {
                    Logger.ErrorFormat("CH000", String.Format("CH000:{0}---->{1}", exc.Message, exc.StackTrace));
                    returnResults.ResponseMessage = exc.InnerException.Message;
                    return returnResults;
                }

            }
            catch (System.Exception exc)
            {
                Logger.ErrorFormat("CH000", String.Format("CH000:{0}---->{1}", exc.Message, exc.StackTrace));
                returnResults.ResponseMessage = exc.InnerException.Message;
                return returnResults;
            }
        }
        public void Atualizar(Dtos.SolicitacaoDto solicitacaoDto)
        {
            var solicitacaoEntity =
                _solicitacaoRepository.GetByCodigo(solicitacaoDto.Codigo);

            solicitacaoEntity.Descricao = solicitacaoDto.Descricao;
            solicitacaoEntity.HorasEstimadas = solicitacaoDto.HorasEstimadas;
            solicitacaoEntity.MotivoRecusa = solicitacaoDto.MotivoRecusa;

            Begin();
            _solicitacaoRepository
                .Update(solicitacaoEntity);
            SaveChanges();
        }
示例#13
0
        public IActionResult Get(string id)
        {
            var response = new HttpResponseMessage(HttpStatusCode.OK);

            try
            {
                MatchedProfile matchedProfile = _matcher.GetMatchedProfile(id);
                return(new JsonResult(Dtos.ToDto(matchedProfile)));
            }
            catch (Exception)
            {
                //Log
                throw;
            }
        }
 public void Process(Dtos.Strategy obj)
 {
     var enumerable = _componentService.Get<UnitBase>();
     lock(enumerable) {
         var units = enumerable.ToList();
         var attackerUnits = units.Where(x => x is IAttacker)
             .Where(x => obj.UnitStrategies[x.Id].Situation == Enum.Situation.DoNothing)
             .ToList();
         GetLowLifeInfantery(units)
             .Where(x => obj.UnitStrategies[x.Id].Situation == Enum.Situation.DoNothing)
             .Select(x => GetWalkGroup(GetPreferedUnitToWalkWith(x, attackerUnits)))
             .DistinctMerge((a, b) => new WalkGroup(a.Content.Concat(b.Content).ToList()), _walkGroupUnitEqualityComparer)
             .SelectMany(GetWalkEvents)
             .ForEach(_eventStoreService.Store);
     }
 }
        public void CreateTips(Dtos.CreateTipsInput input)
        {
            //We can use Logger, it's defined in ApplicationService class.
            //ERROR:  Logger.Info("Creating a task for input: " + input);

            //Creating a new Task entity with given input's properties
            var type = new Tips { 
                Title = input.Title,
                Description = input.Description,
                TipsCategoriesRefId = input.TipsCategoriesRefId,
                IsDeleted = input.IsDeleted
            };

            //Saving entity with standard Insert method of repositories.
            _tipsRepository.Insert(type);
        }
 public int InsertarAlmacen(Dtos.almacenDTO dto)
 {
     try
     {
         using (var modelo = new PersistenciaDatos.BDlogisticaEntities())
         {
             var entity = dto.ToEntity();
             modelo.almacen.Add(entity);
             modelo.SaveChanges();
             return entity.ID_Almacen;
         }
     }
     catch (Exception)
     {
         throw new NotImplementedException();
     }
 }
 public int InsertarRequerimientoDetalle(Dtos.requerimiento_detalleDTO dto)
 {
     try
     {
         using (var modelo = new PersistenciaDatos.BDlogisticaEntities())
         {
             var entity = dto.ToEntity();
             modelo.requerimiento_detalle.Add(entity);
             modelo.SaveChanges();
             return entity.ID_RequerimientoDetalle;
         }
     }
     catch (Exception)
     {
         throw new NotImplementedException();
     }
 }
 public bool InsertarEntidad(Dtos.entidadDTO dto)
 {
     try
     {
         using (var modelo = new PersistenciaDatos.BDlogisticaEntities())
         {
             var entity = dto.ToEntity();
             modelo.entidad.Add(entity);
             modelo.SaveChanges();
             return true;
         }
     }
     catch (Exception)
     {
         throw new NotImplementedException();
     }
 }
示例#19
0
        public Cicada.Core.Ret<int> Add(Dtos.CustomerPostParam item)
        {
            if (item == null || string.IsNullOrWhiteSpace(item.Name)) return new Cicada.Core.Ret<int> { Status = 1, Message = "用户名无效" };

            if (string.IsNullOrWhiteSpace(item.Phone) || !StringUtil.IsPhone(item.Phone)) return new Cicada.Core.Ret<int> { Status = 2, Message = "手机号无效" };

            var newCustomer = new Customer
            {
                Name = item.Name.Trim(),
                Phone = item.Phone,
            };

            if (_dbContext.Set<Customer>().FirstOrDefault(w => w.Name == item.Name) != null) return new Ret<int> { Status = 3, Message = "用户名已存在" };

            _dbContext.Set<Customer>().Add(newCustomer);
            _dbContext.SaveChanges();
            return new Ret<int> { Data = newCustomer .CustomerId};
        }
 public bool ActualizarProyecto(Dtos.proyectoDTO dto)
 {
     try
     {
         using (var modelo = new PersistenciaDatos.BDlogisticaEntities())
         {
             var w = modelo.proyecto.Where(q => q.ID_Proyecto == dto.ID_Proyecto).Select(q => q).FirstOrDefault();
             if (w == null) return false;
             Dominio.Convertidores.proyectoAssembler.Actualizar(dto, w);
             modelo.SaveChanges();
             return true;
         }
     }
     catch (Exception)
     {
         throw new NotImplementedException();
     }
 }
示例#21
0
        public long InsertarPersona(Dtos.personDTO dto)
        {
            try
            {
                using (var modelo = new dbSEACEappEntities())
                {
                    var entity = dto.ToEntity();
                    modelo.persons.Add(entity);
                    modelo.SaveChanges();

                    return entity.idPerson;

                }
            }
            catch (Exception)
            {
                throw new NotImplementedException();
            }
        }
        public async Task<Dtos.GetCriteriaOutput> GetCriteria(Dtos.GetCriteriaInput input)
        {
            try
            {
                //Called specific GetAllWithPeople method of task repository.
                var criteria = _criteriaRepository.GetAll();

                if (input.CompanyId.HasValue) criteria = criteria.Where(c => c.CompanyRefId == input.CompanyId.Value);

                return new Dtos.GetCriteriaOutput
                {
                    Criteria = Mapper.Map<List<Dtos.CriteriaDto>>(criteria.OrderByDescending(c => c.CreationTime))
                };
            }
            catch (System.Exception exc)
            {
                throw exc;
            }
        }
        public Dtos.CustomersDto GetCustomer(Dtos.GetCustomersInput input)
        {
            //Get the Customer  
            Customer customer = new Customer();
            try
            {
                if (input.CustomersEmail != string.Empty)
                {
                    customer = _customerRepository.GetCustomerByEmail(input.CustomersEmail, input.CompanyId.Value);
                }

                return Mapper.Map<Dtos.CustomersDto>(customer);
            }
            catch (System.Exception exc)
            {
                Logger.ErrorFormat("CH_CAS_000", exc.StackTrace);
                throw exc;
            }
        }
        public Dtos.GetCustomersOutput GetCustomers(Dtos.GetCustomerInput input)
        {
            if (input.CustomerId != null)
            {
                //TODO:  Get unique CreditsHero requests' emails for passed in email.
                var customers = _customerRepository.GetCustomersByUserId(input.CustomerId.Value);

                return new Dtos.GetCustomersOutput
                {
                    Customers = Mapper.Map<List<Dtos.CustomerDto>>(customers)
                };
            }
            else
            {
                if (input.CompanyId.HasValue)
                {
                    //TODO:  Get list of unique CreditsHero requests' emails.
                    CreditsHero.Customers.Dtos.GetCustomersInput inputCustomer = 
                        new CreditsHero.Customers.Dtos.GetCustomersInput() { CompanyId = input.CompanyId };
                    CreditsHero.Customers.Dtos.GetCustomersOutput results = new CreditsHero.Customers.Dtos.GetCustomersOutput();
                    var customersCreditsHero = (GetCustomersOutput)_creditsHeroConnect.CallCreditsHeroService<GetCustomersOutput>(
                        results, inputCustomer,
                        "api/services/app/Customer/GetCustomers");

                    var customerUsers = _userManager.Users.Where(u => results.Customers.Any(a => a.Email == u.EmailAddress));  //results.Customers.Where(c => _userManager.Users.Contains(c.Email));

                    Dtos.GetCustomersOutput customerList = new Dtos.GetCustomersOutput();
                    
                    foreach(var item in results.Customers)
                    {
                        Dtos.CustomerDto customer = new Dtos.CustomerDto();
                        customer.CellPhone = item.SmsNumber;
                        customer.Email = item.Email;
                        customer.FullName = item.FullName;
                        customerList.Customers.Add(customer);
                    }

                    return customerList;
                }
            }
            return null;
        }
示例#25
0
        public bool ActualizarPersona(Dtos.personDTO dto)
        {
            try
            {
                using (var modelo = new dbSEACEappEntities())
                {
                    var w = modelo.persons.Where(q => q.idPerson == dto.idPerson).Select(q => q).FirstOrDefault();
                    if (w == null) return false;

                    SeaceWCF.Assembler.personAssembler.Actualizar(dto, w);
                    modelo.SaveChanges();

                    return true;
                }
            }
            catch (Exception)
            {
                throw new NotImplementedException();
            }
        }
示例#26
0
 public IActionResult Get(Dtos.SelectFileInput input)
 {
     try
     {
         if (input.SelectType?.ToLower() == "file")
         {
             var result = _fileManager.GetFile(input.Path);
             return Json(new { success = 1, result = result });
         }
         else
         {
             var result = _fileManager.GetFolder(input.Path);
             return Json(new { success = 1, result = result });
         }
     }
     catch (Exception ex)
     {
         return Json(new { success = 0, message = ex.Message, data = ex.StackTrace });
     }
 }
        public void UpdateTips(Dtos.UpdateTipsInput input)
        {
            //We can use Logger, it's defined in ApplicationService base class.
            //ERROR: Logger doesn't exist in ApplicationService base Logger.Info("Updating a task for input: " + input);

            //Retrieving a task entity with given id using standard Get method of repositories.
            var type = _tipsRepository.Get(input.Id.Value);

            //Updating changed properties of the retrieved task entity.
            //if (input.FirstName != string.Empty) customer.FirstName = input.FirstName.Value;
            type.Title = input.Title;
            type.Description = input.Description;
            type.TipsCategoriesRefId = input.TipsCategoriesRefId;
            type.IsDeleted = input.IsDeleted;
                //customer.Id = _productRepository.Load(input.AssignedPersonId.Value);
                //customer.Purchases = _productRepository.Load(input.CustomerId.Value);
        
            //We even do not call Update method of the repository.
            //Because an application service method is a 'unit of work' scope as default.
            //ABP automatically saves all changes when a 'unit of work' scope ends (without any exception).
        }
        public Dtos.GetCustomersOutput GetCustomers(Dtos.GetCustomersInput input)
        {
            try
            {
                if (input.CompanyId.HasValue)
                {
                    var customers = _customerRepository.GetCustomersByCompany(input.CompanyId.Value);

                    return new Dtos.GetCustomersOutput
                    {
                        Customers = Mapper.Map<List<Dtos.CustomersDto>>(customers)
                    };
                }
                return new Dtos.GetCustomersOutput();
            }
            catch (System.Exception exc)
            {
                Logger.Error("Error getting customer list", exc);
                return new Dtos.GetCustomersOutput();
            }
        }
        public async Task<Dtos.GetCompaniesOutput> GetCompanies(Dtos.GetCompanyInput input)
        {
            Dtos.GetCompaniesOutput output;
            if (input.TenantId.HasValue)
            {
                CurrentUnitOfWork.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, input.TenantId);
                //var users = _userRepository.Users.Where(u => u.TenantId == input.TenantId.Value).Select(cu => cu.Id).ToList();
                var users = _userRepository.Users.Select(cu => cu.Id).ToList();

                output = new Dtos.GetCompaniesOutput
                {
                    Companies = (await _companyRepository.GetAllByUser(users)).MapTo<List<Dtos.CompanyDto>>()
                };
            }
            else
            {
                output = new Dtos.GetCompaniesOutput
                {
                    Companies = (await _companyRepository.GetAllListAsync()).MapTo<List<Dtos.CompanyDto>>()
                };
            }
            return output;
        }
        public async Task<List<string>> GetCriteriaValuesNames(Dtos.GetCriteriaInput input)
        {
            try
            {
                List<CriteriaValues> criteriaValues = new List<CriteriaValues>();
                List<string> criteriaValueNames = new List<string>();
                //Called specific GetAllWithPeople method of task repository.
                if ((input.CompanyId.HasValue && input.CompanyId.HasValue) && (input.CriteriaId.HasValue && input.CriteriaId > 0))
                    criteriaValues = _criteriaValuesRepository.GetAllCriteriaValues(input.CompanyId.Value, input.CriteriaId.Value);
                else
                    criteriaValues = _criteriaValuesRepository.GetAllCriteriaValues(input.CompanyId.Value);

                foreach(var item in criteriaValues)
                {
                    criteriaValueNames.Add(item.Name);
                }
                
                return criteriaValueNames;
            }
            catch (System.Exception exc)
            {
                throw exc;
            }
        }
        public async Task<Dtos.GetCriteriaValuesOutput> GetCriteriaValues(Dtos.GetCriteriaInput input)
        {
            try
            {
                List<CriteriaValues> criteriaValues = new List<CriteriaValues>();
                //Called specific GetAllWithPeople method of task repository.
                if ((input.CompanyId.HasValue && input.CompanyId.HasValue) && (input.CriteriaId.HasValue && input.CriteriaId > 0))
                    criteriaValues = _criteriaValuesRepository.GetAllCriteriaValues(input.CompanyId.Value, input.CriteriaId.Value);
                else
                    criteriaValues = _criteriaValuesRepository.GetAllCriteriaValues(input.CompanyId.Value);


                var results = new Dtos.GetCriteriaValuesOutput
                {
                    CriteriaValues = Mapper.Map<List<Dtos.CriteriaValuesDto>>(criteriaValues)
                };

                return results;
            }
            catch(System.Exception exc)
            {
                throw exc;
            }
        }
        public void CreateLocation(Dtos.CreateLocationInput input)
        {
            //We can use Logger, it's defined in ApplicationService class.
            //ERROR:  Logger.Info("Creating a task for input: " + input);

            //Creating a new Task entity with given input's properties
            var type = new LocationType { 
                City = input.City,
                State = input.State
            };

            //Saving entity with standard Insert method of repositories.
            _locationRepository.Insert(type);
        }
示例#33
0
 public void Process(Dtos.Strategy obj)
 {
     var barrack = _componentService.Get<Barrack>().Shuffle().First();
     var position = barrack.Position;
     _eventStoreService.Store(GetProduceEvent(barrack, position));
 }
示例#34
0
        /// <summary>
        /// Creates a service.
        /// </summary>
        public ServiceInfo(string name, IEnumerable <IServiceMemberInfo> members = null, IEnumerable <ServiceAttributeInfo> attributes = null, string summary = null, IEnumerable <string> remarks = null, NamedTextPosition position = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            Name       = name;
            Members    = members.ToReadOnlyList();
            Attributes = attributes.ToReadOnlyList();
            Summary    = summary ?? "";
            Remarks    = remarks.ToReadOnlyList();
            Position   = position;

            ServiceDefinitionUtility.ValidateName(Name, Position);

            foreach (var member in Members)
            {
                if (!(member is ServiceMethodInfo) && !(member is ServiceDtoInfo) && !(member is ServiceEnumInfo) && !(member is ServiceErrorSetInfo))
                {
                    throw new ServiceDefinitionException($"Unsupported member type '{member.GetType()}'.");
                }
            }

            ServiceDefinitionUtility.ValidateNoDuplicateNames(Members, "service member");
            m_membersByName = new ReadOnlyDictionary <string, IServiceMemberInfo>(Members.ToDictionary(x => x.Name, x => x));

            foreach (var field in Methods.SelectMany(x => x.RequestFields.Concat(x.ResponseFields)).Concat(Dtos.SelectMany(x => x.Fields)))
            {
                GetFieldType(field);
            }
        }