Ejemplo n.º 1
0
        public static void downloadUsers()
        {
            String           StationID      = ManageLOG.getValueFromRegistry(Configurations.AppRegName, "StationID");
            int              total          = 0;
            int              success        = 0;
            UserDao          dao            = new UserDao();
            List <ModelUser> listAccessCode = dao.Select(" Where u.station_id=" + StationID);

            if (listAccessCode != null)
            {
                total = listAccessCode.Count;
                logger.Debug("# Start Download [USER] from server.");

                foreach (ModelUser model in listAccessCode)
                {
                    List <ModelUser> tmp = dao.SelectOffine(" Where user_name='" + model.user_name + "'");
                    if (tmp != null)
                    {
                        if (tmp.Count > 0)
                        {
                        }
                        else
                        {
                            if (dao.InsertOffline(model))
                            {
                                success++;
                            }
                        }
                    }
                }


                logger.Debug("# Summary=> Total Download total: " + total + " success: " + success + " fail: " + (total - success));
                logger.Debug("# End Download data from server.");
            }
            StaffDao          staffDao  = new StaffDao();
            List <ModelStaff> listStaff = staffDao.Select(" Where staff_station=" + StationID);

            if (listStaff != null)
            {
                total = listStaff.Count;
                logger.Debug("# Start Download [STAFF PROFILE] from server.");

                foreach (ModelStaff model in listStaff)
                {
                    List <ModelStaff> tmp = staffDao.SelectOffline(" Where staff_name='" + model.staff_name + "'");
                    if (tmp != null)
                    {
                        if (tmp.Count > 0)
                        {
                        }
                        else
                        {
                            if (staffDao.InsertOffline(model))
                            {
                                success++;
                            }
                        }
                    }
                }



                logger.Debug("# Summary=> Total Download total: " + total + " success: " + success + " fail: " + (total - success));
                logger.Debug("# End Download data from server.");
            }
        }