Ejemplo n.º 1
0
        public static void DeleteDb(int type)
        {
            if (type == 0)
            {
                var db1        = new DbContext("LocationConnection");
                var delResult1 = db1.Database.Delete();

                var db2        = new DbContext("LocationHistoryConnection");
                var delResult2 = db2.Database.Delete();
            }
            else if (type == 1)
            {
                DirectoryInfo dirInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Data\\");
                FileInfo[]    files   = dirInfo.GetFiles("*.db");
                foreach (var file in files)
                {
                    file.Delete();
                }
            }
            else
            {
                LocationDb        Ldb  = new LocationDb();
                LocationHistoryDb Lhdb = new LocationHistoryDb();
                // Ldb.Database.ExecuteSqlCommand("drop database location");
                // Lhdb.Database.ExecuteSqlCommand("drop database locationhistory");
                Ldb.Database.Delete();
                Lhdb.Database.Delete();
            }
        }
    // Use this for initialization
    void Start()
    {
        LocationDb mLocationDb = new LocationDb();

        //Add Data
        mLocationDb.addData(new LocationEntity("0", "AR", "0.001", "0.007"));
        mLocationDb.addData(new LocationEntity("1", "AR", "0.002", "0.006"));
        mLocationDb.addData(new LocationEntity("2", "AR", "0.003", "0.005"));
        mLocationDb.addData(new LocationEntity("3", "AR", "0.004", "0.004"));
        mLocationDb.addData(new LocationEntity("4", "AR", "0.005", "0.003"));
        mLocationDb.addData(new LocationEntity("5", "AR", "0.006", "0.002"));
        mLocationDb.addData(new LocationEntity("6", "AR", "0.007", "0.001"));
        mLocationDb.close();


        //Fetch All Data
        LocationDb mLocationDb2 = new LocationDb();

        System.Data.IDataReader reader = mLocationDb2.getAllData();

        int fieldCount = reader.FieldCount;
        List <LocationEntity> myList = new List <LocationEntity>();

        while (reader.Read())
        {
            LocationEntity entity = new LocationEntity(reader[0].ToString(),
                                                       reader[1].ToString(),
                                                       reader[2].ToString(),
                                                       reader[3].ToString(),
                                                       reader[4].ToString());

            Debug.Log("id: " + entity._id);
            myList.Add(entity);
        }
    }
        /// <summary>
        /// Displays all <c>Location</c> in the database. Accepts console input to delete a location from the database.
        /// </summary>
        public void RemoveLocation()
        {
            Console.WriteLine("Remove a Location (WARNING: Will remove products and order history):\n");
            Console.WriteLine("0:\tReturn");
            try
            {
                //Loads locations from database.
                var locations = new LocationDb().GetLocations();
                foreach (var location in locations)
                {
                    Console.WriteLine(location);
                }

                //Console input.
                Console.Write("\nEnter Location ID:\n> ");
                var input = Int32.Parse(Console.ReadLine());
                Console.Clear();

                //0: Return
                if (input == 0)
                {
                    Continue();
                    return;
                }

                new LocationDb().RemoveLocation(input);
                Console.WriteLine("Location and products removed.");
                Continue();
            }
            catch (System.Exception)
            {
                CommandError();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Display all <c>Location</c> in the database.
        /// Accepts console input to view a <c>Location</c>.
        /// Sets appropriate field in <c>UserTerminal</c>.
        /// </summary>
        public void ViewLocations()
        {
            try
            {
                //Loads locations from database.
                ICollection <Location> locations = new LocationDb().GetLocations();
                Console.WriteLine("Choose a Location to View:\n");
                Console.WriteLine("0:\tReturn");
                foreach (Location location in locations)
                {
                    Console.WriteLine(location);
                }
                Console.Write("\nEnter Location Id:\n> ");

                //Console input.
                var input = Int32.Parse(Console.ReadLine());
                Console.Clear();

                //0: Return
                if (input == 0)
                {
                    GoBack();
                    return;
                }
                //Load location from database.
                UI.Location = new LocationDb().GetLocation(input);
            }
            catch (System.Exception)
            {
                CommandError();
            }
        }
    private void Start()
    {
        LocationDb mLocationDb = new LocationDb();

        //Add Data
        mLocationDb.addData(new LocationEntity("SPHERE 1", "5.000", "5.000"));
        mLocationDb.addData(new LocationEntity("SPHERE 2", "4.000", "4.000"));
        mLocationDb.addData(new LocationEntity("SPHERE 3", "3.000", "3.000"));
        mLocationDb.addData(new LocationEntity("SPHERE 4", "2.000", "2.000"));
        mLocationDb.addData(new LocationEntity("SPHERE 5", "1.000", "1.000"));
        mLocationDb.addData(new LocationEntity("SPHERE 6", "0.000", "0.000"));
        mLocationDb.Close();


        //Fetch All Data
        LocationDb  mLocationDb2 = new LocationDb();
        IDataReader reader       = mLocationDb2.GetAllData();

        int fieldCount = reader.FieldCount;
        List <LocationEntity> myList = new List <LocationEntity>();

        while (reader.Read())
        {
            LocationEntity entity = new LocationEntity(Convert.ToInt32(reader[0]),
                                                       reader[1].ToString(),
                                                       reader[2].ToString(),
                                                       reader[3].ToString(),
                                                       reader[4].ToString());

            Debug.Log("id: " + entity.Id);
            myList.Add(entity);
            Instantiate(GameObject.CreatePrimitive(PrimitiveType.Sphere), new Vector3((float)Convert.ToDouble(entity.Lat), (float)Convert.ToDouble(entity.Lon), 0), Quaternion.identity);
        }
    }
        private static LocationDb GetDb()
        {
            var db = new LocationDb();

            db.Configuration.AutoDetectChangesEnabled = false;
            db.Configuration.LazyLoadingEnabled       = false; //关闭延迟加载
            db.Configuration.ProxyCreationEnabled     = false;
            return(db);
        }
Ejemplo n.º 7
0
        public TestBll(bool autoDetectChangesEnabled, bool lazyLoadingEnabled, bool isCreateDb)
        {
            Db = new LocationDb(isCreateDb);
            Db.Configuration.AutoDetectChangesEnabled = autoDetectChangesEnabled;
            Db.Configuration.LazyLoadingEnabled       = lazyLoadingEnabled; //关闭延迟加载

            Maps                = new MapBll(Db);
            Areas               = new AreaBll(Db);
            Position            = new PositionBll(DbHistory);
            TagPositions        = new TagPositionBll(Db);
            Departments         = new DepartmentBll(Db);
            Users               = new UserBll(Db);
            Tags                = new TagBll(Db);
            Archors             = new ArchorBll(Db);
            KKSCodes            = new KKSCodeBll(Db);
            t_KKSCodes          = new t_KKSCodeBll(Dbtopviewxp);
            t_SetModels         = new t_SetModelBll(Db);
            t_TypeProperties    = new t_Template_TypePropertyBll(Db);
            TransformMs         = new TransformMBll(Db);
            DevInfos            = new DevInfoBll(Db);
            DevPos              = new DevPosBll(Db);
            U3DPositions        = new U3DPositionBll(DbHistory);
            PhysicalTopologys   = new PhysicalTopologyBll(Db);
            NodeKKSs            = new NodeKKSBll(Db);
            Personnels          = new PersonnelBll(Db);
            Posts               = new PostBll(Db);
            JurisDictions       = new JurisDictionBll(Db);
            JurisDictionRecords = new JurisDictionRecordBll(Db);
            Meterials           = new MeterialBll(Db);
            //U3DPositions.ToList();
            ConfigArgs                            = new ConfigArgBll(Db);
            Bounds                                = new BoundBll(Db);
            Points                                = new PointBll(Db);
            OperationTickets                      = new OperationTicketBll(Db);
            OperationItems                        = new OperationItemBll(Db);
            WorkTickets                           = new WorkTicketBll(Db);
            SafetyMeasuress                       = new SafetyMeasuresBll(Db);
            MobileInspections                     = new MobileInspectionBll(Db);
            MobileInspectionItems                 = new MobileInspectionItemBll(Db);
            MobileInspectionContents              = new MobileInspectionContentBll(Db);
            MobileInspectionDevs                  = new MobileInspectionDevBll(Db);
            PersonnelMobileInspections            = new PersonnelMobileInspectionBll(Db);
            PersonnelMobileInspectionItems        = new PersonnelMobileInspectionItemBll(Db);
            PersonnelMobileInspectionHistorys     = new PersonnelMobileInspectionHistoryBll(DbHistory);
            PersonnelMobileInspectionItemHistorys = new PersonnelMobileInspectionItemHistoryBll(DbHistory);
            OperationTicketHistorys               = new OperationTicketHistoryBll(DbHistory);
            OperationItemHistorys                 = new OperationItemHistoryBll(DbHistory);
            WorkTicketHistorys                    = new WorkTicketHistoryBll(DbHistory);
            SafetyMeasuresHistorys                = new SafetyMeasuresHistoryBll(DbHistory);
            Targets                               = new TargetBll(Db);
            Roles = new RoleBll(Db);
            Menus = new MenuBll(Db);

            Z.EntityFramework.Extensions.LicenseManager.AddLicense("34;100-LLHSWWHA", "384799A60700037CBFC0EB5E03A62474");
        }
 /// <summary>
 /// Creates a new <c>Location</c> and inserts into the database.
 /// </summary>
 public void AddLocation()
 {
     try
     {
         //New instance of LocationDb. Returns instance of Location.
         var location = new LocationDb().Build();
         Console.Clear();
         Console.WriteLine("New location added.\n");
         Console.WriteLine(location + "\n");
         Continue();
     }
     catch (System.Exception ex)
     {
         Console.Clear();
         Console.WriteLine(ex.Message);
         Continue();
     }
 }
Ejemplo n.º 9
0
        public static void LocationTestingData()
        {
            var locCount = TotalLocationCount();

            using (SQLiteConnection conn = new SQLiteConnection(DatabaseLocation))
            {
                conn.CreateTable <LocationDb>();

                var location = conn.Table <LocationDb>().ToList();

                if (locCount < 1)
                {
                    LocationDb newLocaiton = new LocationDb()
                    {
                        CurrentUser  = UserLoggedIn,
                        LocationName = "Favorite Hunting Spot",
                        Longitude    = -84.317241,
                        Latitude     = 34.736907,
                        EventType    = "Hunting",
                        CreatedDate  = DateTime.Today,
                        ReturnDate   = DateTime.Today,
                        Notification = "Enabled",
                        Notes        = "This testing data is for the assessor and is created at the login page with any new user created that doesn't contain any data"
                    };
                    conn.Insert(newLocaiton);

                    LocationDb newLocaiton2 = new LocationDb()
                    {
                        CurrentUser  = UserLoggedIn,
                        LocationName = "Favorite Hunting Spot 2",
                        Longitude    = -84.317241,
                        Latitude     = 34.736907,
                        EventType    = "Hunting",
                        CreatedDate  = DateTime.Today,
                        ReturnDate   = DateTime.Today,
                        Notification = "Enabled",
                        Notes        = "This testing data is for the assessor and is created at the login page with any new user created that doesn't contain any data"
                    };
                    conn.Insert(newLocaiton2);
                }
            }
        }
Ejemplo n.º 10
0
        private static List <object> GetList(PropertyInfo p, LocationDb db)
        {
            var ds = p.GetValue(db);
            //var ps = ds.GetType().GetProperties();
            //var ms = ds.GetType().GetMethods();
            var list  = ds as IEnumerable;
            var list2 = new List <object>();

            foreach (var item in list)
            {
                //if(item is IComparable)
                //{
                //    list2.Add(item as IComparable);
                //}
                //else
                {
                    list2.Add(item);
                }
            }
            return(list2);
        }
        async void Save_Clicked(System.Object sender, System.EventArgs e)
        {
            using (SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation))
            {
                conn.CreateTable <LocationDb>();

                // handles Longitude and Latitude input
                //double longitudeOut;
                //bool longParsed = double.TryParse(longitude.Text, out longitudeOut);
                //bool longValid = double.IsNaN(longitudeOut);

                if (string.IsNullOrWhiteSpace(locationName.Text) || string.IsNullOrWhiteSpace(Convert.ToString(eventTypePicker.SelectedItem)) ||
                    string.IsNullOrWhiteSpace(Convert.ToString(notificationStatus.SelectedItem)) || string.IsNullOrWhiteSpace(notes.Text))
                {
                    await DisplayAlert("Failure", "Please enter valid information for all location fields including only numbers/decimil for Longitude and Latitude.", "OK");
                }
                else
                {
                    LocationDb newLocation = new LocationDb
                    {
                        CurrentUser  = App.UserLoggedIn,
                        LocationName = locationName.Text,
                        Longitude    = Convert.ToDouble(longitude.Text),
                        Latitude     = Convert.ToDouble(latitude.Text),
                        EventType    = Convert.ToString(eventTypePicker.SelectedItem),
                        CreatedDate  = DateTime.Now,
                        ReturnDate   = returnDate.Date,
                        Notification = Convert.ToString(notificationStatus.SelectedItem),
                        Notes        = notes.Text
                    };
                    conn.Insert(newLocation);
                    await DisplayAlert("Success", "Location successfully created", "OK");

                    await Navigation.PopModalAsync();
                }
            }
        }
 public WarehouseRepository()
 {
     this.db         = new LocationDb();
     this.regionRepo = new RegionRepository(this.db);
 }
Ejemplo n.º 13
0
 internal RegionRepository(LocationDb context)
 {
     this.db = context;
 }
Ejemplo n.º 14
0
 public RegionRepository()
 {
     this.db = new LocationDb();
 }
Ejemplo n.º 15
0
 public EditLocationPage(LocationDb selectedLocation)
 {
     InitializeComponent();
     this.selectedLocation = selectedLocation;
 }
Ejemplo n.º 16
0
        public Manager()
        {
            var connection = DbConnectionFactory.CreateTransient();

            Db = new LocationDb(connection);
        }
 public ProvinceRepository()
 {
     this.db = new LocationDb();
 }
Ejemplo n.º 18
0
 public void AddEntity(LocationDb item)
 {
     Locations.Add(item);
 }
Ejemplo n.º 19
0
        public Bll(bool autoDetectChangesEnabled, bool lazyLoadingEnabled, bool isCreateDb, bool useProxy = true)
        {
            Db = new LocationDb(isCreateDb);
            Db.Configuration.AutoDetectChangesEnabled = autoDetectChangesEnabled;
            Db.Configuration.LazyLoadingEnabled       = lazyLoadingEnabled; //关闭延迟加载
            Db.Configuration.ProxyCreationEnabled     = useProxy;

            if (ShowLog)
            {
                Db.Database.Log = Log.Debug;
            }


            Archors                        = new ArchorBll(Db);
            Areas                          = new AreaBll(Db);
            Bounds                         = new BoundBll(Db);
            ConfigArgs                     = new ConfigArgBll(Db);
            Departments                    = new DepartmentBll(Db);
            DevAlarms                      = new DevAlarmBll(Db);
            DevInfos                       = new DevInfoBll(Db);
            Dev_DoorAccess                 = new Dev_DoorAccessBll(Db);
            Dev_CameraInfos                = new Dev_CameraInfoBll(Db);
            DevInstantDatas                = new DevInstantDataBll(Db);
            DevModels                      = new DevModelBll(Db);
            DevTypes                       = new DevTypeBll(Db);
            EntranceGuardCards             = new EntranceGuardCardBll(Db);
            EntranceGuardCardToPersonnels  = new EntranceGuardCardToPersonnelBll(Db);
            AreaAuthorizations             = new AreaAuthorizationBll(Db);
            AreaAuthorizationRecords       = new AreaAuthorizationRecordBll(Db);
            KKSCodes                       = new KKSCodeBll(Db);
            LocationAlarms                 = new LocationAlarmBll(Db);
            LocationCards                  = new LocationCardBll(Db);
            LocationCardPositions          = new LocationCardPositionBll(Db);
            LocationCardToPersonnels       = new LocationCardToPersonnelBll(Db);
            MobileInspections              = new MobileInspectionBll(Db);
            MobileInspectionContents       = new MobileInspectionContentBll(Db);
            MobileInspectionDevs           = new MobileInspectionDevBll(Db);
            MobileInspectionItems          = new MobileInspectionItemBll(Db);
            NodeKKSs                       = new NodeKKSBll(Db);
            OperationItems                 = new OperationItemBll(Db);
            OperationTickets               = new OperationTicketBll(Db);
            Personnels                     = new PersonnelBll(Db);
            PersonnelMobileInspections     = new PersonnelMobileInspectionBll(Db);
            PersonnelMobileInspectionItems = new PersonnelMobileInspectionItemBll(Db);
            Points                         = new PointBll(Db);
            Posts                          = new PostBll(Db);
            Roles                          = new RoleBll(Db);
            SafetyMeasuress                = new SafetyMeasuresBll(Db);
            WorkTickets                    = new WorkTicketBll(Db);
            Pictures                       = new PictureBll(Db);
            ArchorSettings                 = new ArchorSettingBll(Db);
            CardRoles                      = new CardRoleBll(Db);
            DevMonitorNodes                = new DevMonitorNodeBll(Db);
            //Shapes = new ShapeBll(Db);
            //ShapePoints = new ShapePointBll();

            DevAlarmHistorys                      = new DevAlarmHistoryBll(DbHistory);
            DevEntranceGuardCardActions           = new DevEntranceGuardCardActionBll(DbHistory);
            DevInfoHistorys                       = new DevInfoHistoryBll(DbHistory);
            DevInstantDataHistorys                = new DevInstantDataHistoryBll(DbHistory);
            EntranceGuardCardHistorys             = new EntranceGuardCardHistoryBll(DbHistory);
            EntranceGuardCardToPersonnelHistorys  = new EntranceGuardCardToPersonnelHistoryBll(DbHistory);
            LocationAlarmHistorys                 = new LocationAlarmHistoryBll(DbHistory);
            LocationCardHistorys                  = new LocationCardHistoryBll(DbHistory);
            LocationCardToPersonnelHistorys       = new LocationCardToPersonnelHistoryBll(DbHistory);
            OperationItemHistorys                 = new OperationItemHistoryBll(DbHistory);
            OperationTicketHistorys               = new OperationTicketHistoryBll(DbHistory);
            PersonnelHistorys                     = new PersonnelHistoryBll(DbHistory);
            PersonnelMobileInspectionHistorys     = new PersonnelMobileInspectionHistoryBll(DbHistory);
            PersonnelMobileInspectionItemHistorys = new PersonnelMobileInspectionItemHistoryBll(DbHistory);
            Positions = new PositionBll(DbHistory);
            SafetyMeasuresHistorys = new SafetyMeasuresHistoryBll(DbHistory);
            U3DPositions           = new U3DPositionBll(DbHistory);
            WorkTicketHistorys     = new WorkTicketHistoryBll(DbHistory);


            bus_anchors            = new bus_anchorBll(DbE);
            bus_tags               = new bus_tagBll(DbE);
            bus_anchor_config      = new bus_anchor_configBll(DbE);
            bus_anchor_switch_area = new bus_anchor_switch_areaBll(DbE);

            //LocationCards.ToList();
            //DevEntranceGuardCardActions.ToList();
            //bus_archors.ToList();

            Z.EntityFramework.Extensions.LicenseManager.AddLicense("34;100-LLHSWWHA", "384799A60700037CBFC0EB5E03A62474");
        }
 internal WarehouseRepository(LocationDb context, IRegionRepository repo)
 {
     this.db         = context;
     this.regionRepo = repo;
 }
 internal ProvinceRepository(LocationDb context)
 {
     db = context;
 }
 public LocationDetailsPage(LocationDb selectedLocation)
 {
     this.selectedLocation = selectedLocation;
     InitializeComponent();
 }