コード例 #1
0
        public async Task getPosition()
        {
            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("X-SFAPI-UserName", sunfishConfig.username);
                client.DefaultRequestHeaders.Add("X-SFAPI-AppName", sunfishConfig.appname);
                client.DefaultRequestHeaders.Add("X-SFAPI-RSAKey", sunfishConfig.RSAkey);
                client.DefaultRequestHeaders.Add("X-SFAPI-Account", sunfishConfig.account);
                // Make your request...

                try
                {
                    HttpResponseMessage message = client.GetAsync(sunfishConfig.Uri + "index.cfm?endpoint=/biensi_SFFULL_EO_getmasterstoreposition").Result;
                    if (message.IsSuccessStatusCode)
                    {
                        var             serializer = new DataContractJsonSerializer(typeof(SunfishPosition));
                        var             result     = message.Content.ReadAsStringAsync().Result;
                        byte[]          byteArray  = Encoding.UTF8.GetBytes(result);
                        MemoryStream    stream     = new MemoryStream(byteArray);
                        SunfishPosition resultData = serializer.ReadObject(stream) as SunfishPosition;
                        for (int i = 0; i < resultData.RESULT.Count; i++)
                        {
                            try
                            {
                                bool isPossitionex = _context.EmployeePossition.Any(c => c.PossitionId == resultData.RESULT[i].POSITION_CODE);
                                if (isPossitionex == false)
                                {
                                    EmployeePossition employee = new EmployeePossition();
                                    employee.PossitionId = resultData.RESULT[i].POSITION_CODE;
                                    employee.Name        = resultData.RESULT[i].POSITION_NAME;
                                    _context.EmployeePossition.Add(employee);
                                    _context.SaveChanges();
                                }
                                else
                                {
                                    EmployeePossition employee = _context.EmployeePossition.Where(x => x.PossitionId == resultData.RESULT[i].POSITION_CODE).First();
                                    employee.PossitionId = resultData.RESULT[i].POSITION_CODE;
                                    employee.Name        = resultData.RESULT[i].POSITION_NAME;
                                    _context.EmployeePossition.Update(employee);
                                    _context.SaveChanges();
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    else
                    {
                        String data = message.Headers.ToString();
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
コード例 #2
0
        //private List<BankMaster> masterBanks(int storeID)
        //{
        //    List<BankMaster> masterBankList = new List<BankMaster>();
        //    try
        //    {
        //        List<StorePaymentMethod> bankDb = _context.StorePaymentMethod.Where(c => c.StoreId == storeID).ToList();
        //        foreach (StorePaymentMethod b in bankDb)
        //        {
        //            Bank bankMaster = _context.Bank.Where(c => c.BankId == b.BankCode).First();
        //            BankMaster bank = new BankMaster();
        //            bank.bankId = bankMaster.BankId;
        //            bank.bankName = bankMaster.Name;
        //            masterBankList.Add(bank);
        //        }
        //    }
        //    catch
        //    {
        //    }
        //    return masterBankList;
        //}

        private List<EmployeeMaster> masterEmployeepost(int storeID)
        {
            List<EmployeeMaster> masterEmployeeList = new List<EmployeeMaster>();
            try
            {
                List<Employee> dbEmployee = _context.Employee.Where(c => c.StoreId == storeID).ToList();
                foreach (Employee b in dbEmployee)
                {
                    EmployeePossition employeePossition = _context.EmployeePossition.Where(c => c.Id == b.PossitionId).First();
                    Store store = _context.Store.Where(c => c.Id == b.StoreId).First();
                    EmployeeMaster employee = new EmployeeMaster
                    {

                        employeeId = b.EmployeeCode,
                        id = b.Id,
                        name = b.EmployeeName,
                        storeId = store.Id,
                        storeCode = store.Code,
                        storeName = store.Name,

                        possition = new Possition
                        {
                            id = employeePossition.Id,
                            possitionName = employeePossition.Name,
                            possitionId = employeePossition.PossitionId
                        }
                    };

                    masterEmployeeList.Add(employee);
                }
            }
            catch
            {

            }
            return masterEmployeeList;
        }
コード例 #3
0
        //private List<EmployeeMaster> masterEmployee(int storeID)
        //{
        //    List<EmployeeMaster> masterEmployeeList = new List<EmployeeMaster>();
        //    try
        //    {
        //        List<Employee> dbEmployee = _context.Employee.Where(c => c.StoreId == storeID).ToList();
        //        foreach (Employee b in dbEmployee)
        //        {
        //            EmployeePossition employeePossition = _context.EmployeePossition.Where(c => c.Id == b.PossitionId).First();
        //            EmployeeMaster employee = new EmployeeMaster
        //            {
        //                employeeId = b.EmployeeCode,
        //                id = b.Id,
        //                name = b.EmployeeName,
        //                possition = new Possition
        //                {
        //                    id = employeePossition.Id,
        //                    possitionName = employeePossition.Name,
        //                    possitionId = employeePossition.PossitionId
        //                }
        //            };
        //            try
        //            {
        //                employee.passwordHash = _context.UserLogin.Where(x => x.UserId == b.Id).FirstOrDefault().PasswordHash;
        //                employee.passwordSalt = _context.UserLogin.Where(x => x.UserId == b.Id).FirstOrDefault().PasswordSalt;
        //                employee.passwordaja = _context.UserLogin.Where(x => x.UserId == b.Id).FirstOrDefault().OldPassword;
        //            }
        //            catch
        //            {
        //                employee.passwordHash = null;
        //                employee.passwordSalt = null;
        //                employee.passwordaja = "";
        //            }
        //            masterEmployeeList.Add(employee);
        //        }
        //    }
        //    catch
        //    {

        //    }
        //    return masterEmployeeList;
        //}

        private List<EmployeeMaster> masterEmployee(int storeID)
        {
            List<EmployeeMaster> masterEmployeeList = new List<EmployeeMaster>();
            try
            {
                string city = _context.Store.Where(x => x.Id == storeID).First().City;
                List<Store> dbStores = _context.Store.ToList();
                //    List<Store> dbStores = _context.Store.Where(x => x.City == city).ToList();
                for (int i = 0; i < dbStores.Count; i++)
                {
                    List<Employee> dbEmployee = _context.Employee.Where(c => c.StoreId == dbStores[i].Id && c.Status == true).ToList();
                    foreach (Employee b in dbEmployee)
                    {
                        EmployeePossition employeePossition = _context.EmployeePossition.Where(c => c.Id == b.PossitionId).First();
                        EmployeeMaster employee = new EmployeeMaster
                        {
                            employeeId = b.EmployeeCode,
                            storeId = dbStores[i].Id,
                            storeCode = dbStores[i].Code,
                            storeName = dbStores[i].Name,
                            id = b.Id,
                            name = b.EmployeeName,
                            possition = new Possition
                            {
                                id = employeePossition.Id,
                                possitionName = employeePossition.Name,
                                possitionId = employeePossition.PossitionId
                            }
                        };
                        if (b.StoreId == storeID)
                        {
                            try
                            {
                                employee.passwordHash = _context.UserLogin.Where(x => x.UserId == b.Id).FirstOrDefault().PasswordHash;
                                employee.passwordSalt = _context.UserLogin.Where(x => x.UserId == b.Id).FirstOrDefault().PasswordSalt;
                                employee.passwordaja = _context.UserLogin.Where(x => x.UserId == b.Id).FirstOrDefault().OldPassword;
                            }
                            catch
                            {
                                employee.passwordHash = null;
                                employee.passwordSalt = null;
                                employee.passwordaja = "";
                            }
                        }
                        else
                        {

                            employee.passwordHash = null;
                            employee.passwordSalt = null;
                            employee.passwordaja = "GABOLEHLOGINASDASDASDA";
                        }

                        masterEmployeeList.Add(employee);
                    }

                }

            }
            catch
            {

            }
            return masterEmployeeList;
        }