Exemplo n.º 1
0
        /// <inheritdoc />
        Task <IEnumerable <CakeDto> > ICakeApi.GetNearbyCakes(DbPosition argPosition)
        {
            var arguments = new object[] { argPosition };
            var func      = requestBuilder.BuildRestResultFuncForMethod("GetNearbyCakes", new Type[] { typeof(DbPosition) });

            return((Task <IEnumerable <CakeDto> >)func(Client, arguments));
        }
Exemplo n.º 2
0
        public void CreateBitmexTrade(DbPosition pos)
        {
            var stopLoss = GetAlignedStopLoss(Convert.ToDouble(lblBidPrice.Content));

            if (stopLoss.HasValue)
            {
                MainWnd.Controller.CreateBitmexTrade(pos, stopLoss.Value, Convert.ToDouble(tbRiskPcnt.Text), 0, 0);//!! _posWatcher.StopPrice.Value, _posWatcher.StartWatchingPrice.Value);
            }
        }
Exemplo n.º 3
0
        public void CreateBitmexTrade(DbPosition position, double stopValue, double riskPercent, double stopPrice, double startWatchPrice)
        {
            Position        = position;
            StopValue       = stopValue;
            StopPrice       = stopPrice;
            RiskPercent     = riskPercent;
            StartWatchPrice = startWatchPrice;

            _api.UserQuery("/v1/trade", HttpMethod.Post, JsonConvert.SerializeObject(this), true);
        }
Exemplo n.º 4
0
        public async Task <TokenDTO> LoginAsync(string Username, string Password)
        {
            try
            {
                Employee user = Context.Employee.Where(x => x.Username == Username).FirstOrDefault();
                if (user == null)
                {
                    EmployeeDTO ADUser = LDAPService.LDAP_Authenticate(Username, Password);
                    if (ADUser.Username == null)
                    {
                        tokens.Message = "ไม่พบข้อมูลผู้ใช้งาน";
                        return(tokens);
                    }
                    else
                    {
                        string SystemCode = await CreateNewUserAsync(ADUser);

                        tokens.empCode = SystemCode;
                        tokens.Message = "Login Success";
                        return(tokens);
                    }
                }
                else
                {
                    Password = EncryptionService.HashToMD5(Password + user.Passwordsalt);
                    Employee        users           = Context.Employee.Where(x => x.Username == Username && x.Password == Password).FirstOrDefault();
                    EmployeeProfile employeeProfile = Context.EmployeeProfile.Where(x => x.Empcode == user.Empcode).FirstOrDefault();
                    DbPosition      dbPosition      = Context.DbPosition.Where(x => x.PositonCode == employeeProfile.PositionCode).FirstOrDefault();
                    if (users == null)
                    {
                        //user.UpdDate = DateTime.Now;
                        //Context.Employee.Update(user);
                        //Context.SaveChanges();
                        tokens.Message = "ชื่อผู้ใช้ และ รหัสผ่านไม่ถูกต้อง";
                        return(tokens);
                    }
                    else
                    {
                        //TOKEN
                        tokens.empCode      = user.Empcode;
                        tokens.Username     = users.Username;
                        tokens.Firstname    = employeeProfile.FirstnameEn;
                        tokens.Lastname     = employeeProfile.LastnameEn;
                        tokens.PositionCode = dbPosition.PositonCode;
                        tokens.Token        = GenerateToken(user.Empcode);
                        tokens.Message      = "Login Success";
                        return(tokens);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 5
0
        public async Task <string> CreateNewUserAsync(EmployeeDTO ADUser)
        {
            try
            {
                Employee        user            = new Employee();
                EmployeeProfile employeeProfile = Context.EmployeeProfile.Where(x => x.Empcode == ADUser.Empcode).FirstOrDefault();
                DbPosition      dbPosition      = Context.DbPosition.Where(x => x.PositionName == ADUser.Position).FirstOrDefault();

                user.Empcode      = ADUser.Empcode;
                user.Username     = ADUser.Username;
                user.Passwordsalt = EncryptionService.GeneratePasswordSalt();
                user.Password     = EncryptionService.HashToMD5(ADUser.Password + user.Passwordsalt);

                user.Active = true;
                user.CrBy   = "LDAP";
                user.CrDate = DateTime.Now;

                Context.Employee.Add(user);
                Context.SaveChanges();

                if (employeeProfile == null)
                {
                    employeeProfile.Empcode     = ADUser.Empcode;
                    employeeProfile.FirstnameTh = ADUser.FirstnameEn;
                    employeeProfile.LastnameEn  = ADUser.LastnameEn;
                    employeeProfile.Tel         = ADUser.Tel;
                    employeeProfile.Email       = ADUser.Email;
                    employeeProfile.Position    = ADUser.Position;

                    if (dbPosition != null)
                    {
                        employeeProfile.PositionCode = dbPosition.PositonCode;
                    }

                    Context.EmployeeProfile.Add(employeeProfile);
                    Context.SaveChanges();
                }


                //TOKEN
                tokens.empCode      = ADUser.Empcode;
                tokens.Username     = ADUser.Username;
                tokens.Firstname    = ADUser.FirstnameEn;
                tokens.Lastname     = ADUser.LastnameEn;
                tokens.PositionCode = dbPosition.PositonCode;
                tokens.Token        = GenerateToken(user.Empcode);

                return(user.Empcode);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 6
0
        /// <inheritdoc/>
        public void NewPosition(NewPositionRequest request)
        {
            if (request.Grade < 0 || request.Grade > 15 || request.Name == string.Empty)
            {
                throw new ArgumentException();
            }
            DbPosition dbPosition = _mapper.Map <NewPositionRequest, DbPosition>(request);

            dbPosition.Id = Guid.NewGuid();
            _positionRepository.NewPosition(dbPosition);
        }
Exemplo n.º 7
0
 public async Task <IEnumerable <CakeDto> > GetNearbyCakes(DbPosition position)
 {
     try
     {
         return(await Api.GetNearbyCakes(position));
     }
     catch (Exception ex)
     {
         Logger.Error(ex, nameof(GetNearbyCakes));
         return(new List <CakeDto>());
     }
 }
Exemplo n.º 8
0
 public Task <IEnumerable <CakeDto> > GetNearbyCakes(DbPosition argPosition)
 {
     return(Task.FromResult(_testCakes));
 }
 public void InsertPosition(DbPosition position)
 {
     gridPositions.Items.Insert(0, position);
 }
Exemplo n.º 10
0
 public void CreateBitmexTrade(DbPosition position, double stopValue, double riskPercent, double stopPrice, double startWatchPrice)
 {
     createTradeRequest().CreateBitmexTrade(position, stopValue, riskPercent, stopPrice, startWatchPrice);
 }
Exemplo n.º 11
0
 ///<inheritdoc/>
 public void UpdatePosition(DbPosition position)
 {
     _db.Execute("UPDATE position SET name = @Name, grade = @Grade WHERE id = @Id", position);
 }
Exemplo n.º 12
0
 ///<inheritdoc/>
 public void NewPosition(DbPosition dbPosition)
 {
     _db.Execute(@"INSERT INTO position 
                    VALUES (@Id, @Name, @Grade)", dbPosition);
 }