예제 #1
0
        public static Models.Area GetCurrentArea()
        {
            var file = new FileInfo(FilePath);
            Models.Area result;
            if (!file.Exists)
            {
                //文件不存在就返回一个默认值,默认是成都
                result = new Models.Area();
                result.ID = 250;
                result.Name = "成都";
                result.ZoneID = 23;
                //area.Zone = new Models.Zone() { ID = 23, Name = "四川" };
                result.AreaCode = "56294";
            }
            else
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Models.Area));
                using (var stream = file.Open(FileMode.Open, FileAccess.Read))
                {
                    result = (Models.Area)ser.ReadObject(stream);
                }
            }
            return result;

            var area = new Models.Area();
            area.ID = 250;
            area.Name = "成都";
            area.ZoneID = 23;
            //area.Zone = new Models.Zone() { ID = 23, Name = "四川" };
            area.AreaCode = "56294";
            return area;
        }
        /// <summary>
        /// 从DataSet中加载城市信息
        /// </summary>
        /// <param name="ds"></param>
        void InitZoneFromDataSet(DataSet ds)
        {
            var dtZone = ds.Tables[0];
            var dtArea = ds.Tables[1];

            this.ZoneList.Clear();
            foreach (DataRow dr in dtZone.Rows)
            {
                var zone = new Models.Zone()
                {
                    ID   = Convert.ToInt32(dr["ID"]),
                    Name = dr["Zone"].ToString()
                };
                var drAreas = dtArea.Select("ZoneID=" + zone.ID);
                foreach (DataRow drArea in drAreas)
                {
                    var area = new Models.Area()
                    {
                        ID       = Convert.ToInt32(drArea["ID"]),
                        ZoneID   = Convert.ToInt32(drArea["ZoneID"]),
                        Name     = drArea["Area"].ToString(),
                        AreaCode = drArea["AreaCode"].ToString()
                                   //Zone = zone
                    };
                    zone.AreaList.Add(area);
                }

                this.ZoneList.Add(zone);
            }
        }
예제 #3
0
        public ActionResult AddAreas(Models.Area area, string AreaList)
        {
            var areas          = TempData["Areas"] as List <string>;
            var processedAreas = TempData["ProcessedAreas"] as List <Area>;

            if (ModelState.IsValid)
            {
                // If "--Add New Area--"
                if (AreaList == "")
                {
                    // Check that we can access git, gic, and are data
                    if (processedAreas != null)
                    {
                        area.Gic = processedAreas[processedAreas.Count - 1].Gic;
                        area.Git = processedAreas[processedAreas.Count - 1].Git;
                        area.Are = processedAreas[processedAreas.Count - 1].Are;
                    }
                    else
                    {
                        throw new FileNotFoundException("Could not access gic, git or are data.");
                    }

                    // Add new area
                    db.Areas.Add(area);
                    db.SaveChanges();

                    // Process next item or go to cleanup if no more items
                    if (areas.Count == 0)
                    {
                        return(RedirectToAction("UploadDone"));
                    }
                    return(RedirectToAction("AddAreas"));
                }
                // Else update pre-existing area with new gic, git, are data

                // Get area to be updated
                var updateArea = db.Areas.Find(Convert.ToInt32(AreaList));
                // Update git, gic and are data ensuring that our new values aren't null
                if (processedAreas != null)
                {
                    updateArea.Gic          = processedAreas[processedAreas.Count - 1].Gic;
                    updateArea.Git          = processedAreas[processedAreas.Count - 1].Git;
                    updateArea.Are          = processedAreas[processedAreas.Count - 1].Are;
                    updateArea.LastModified = DateTime.Now;
                }
                // Save area back to db
                db.Entry(updateArea).State = EntityState.Modified;
                db.SaveChanges();

                // Process next item or go to cleanup if no more items
                if (areas.Count == 0)
                {
                    return(RedirectToAction("UploadDone"));
                }
                return(RedirectToAction("AddAreas"));
            }
            return(View(area));
        }
예제 #4
0
        /// <summary>
        /// 根据id修改地区区域
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static async Task SetArea(int id, Models.Area model)
        {
            using (var db = new DAL.AreaDAL())
            {
                var data = await db.GetAll().FirstAsync(m => m.Id == id);

                await db.EditAsync(data);
            }
        }
예제 #5
0
 public static Area ToAreaContract(Models.Area from)
 {
     return(new Area
     {
         SeatList = from.List.Select(x => SeatParser.ToSeatContract(x)).ToArray(),
         CoordX = from.Column,
         CoordY = from.Row,
         Description = from.Description,
         Id = from.Id,
         LayoutId = from.LayoutId
     });
 }
예제 #6
0
 public ActionResult Post(Models.Area model)
 {
     Models.Area registro;
     if (string.IsNullOrEmpty(model.Id)) //Inserir
     {
         registro = _rep.Area.Inserir(model);
     }
     else //Atualizar
     {
         _rep.Area.Atualizar(model.Id, model);
         return(Ok(model));
     }
     return(Ok(registro));
 }
        // POST: api/Area
        public bool Post(C_Area area)
        {
            Boolean guardar = false;

            using (CursoEscolarEntities contexto = new CursoEscolarEntities())
            {
                Models.Area area1 = new Models.Area {
                    Area_Nombre = area.Nombre
                };
                contexto.Area.Add(area1);
                contexto.SaveChanges();
                guardar = true;
            }
            return(guardar);
        }
예제 #8
0
        public override Models.ILiiteriMarker Create(DbDataReader rdr)
        {
            var obj = new Models.Area();

            obj.Id            = (int)this.GetNumber(rdr, "AreaId");
            obj.Name          = rdr["AreaName"].ToString();
            obj.AlternativeId = rdr["AlternativeId"].ToString();
            obj.AreaType      = rdr["AreaType"].ToString();
            obj.Year          = (int?)this.GetValueOrNull(rdr, "Year");
            obj.OrderNumber   = (int)this.GetNumber(rdr, "OrderNumber");

            List <Models.Area> parentAreas = new List <Models.Area>();

            obj.ParentAreas = parentAreas;
            return(obj);
        }
예제 #9
0
        public static void SaveCurrentArea(Models.Area area)
        {
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Models.Area));
            var        file = new FileInfo(FilePath);
            FileStream stream;

            if (file.Exists)
            {
                stream = file.Open(FileMode.Truncate, FileAccess.Write);
            }
            else
            {
                stream = file.Open(FileMode.Create, FileAccess.Write);
            }
            using (stream)
            {
                ser.WriteObject(stream, area);
            }
        }
예제 #10
0
        public void OnGet()
        {
            List <Models.Area> areaList = new List <Models.Area>();

            // clear exception:
            EX = null;

            // try query
            try {
                string sql = string.Format(@"
                DECLARE @totalNumCrimes INT = (SELECT Count(*) FROM Crimes)

                SELECT Areas.AreaName, Areas.Area, COUNT(IUCR) AS numCrimes, 
                       CONVERT(decimal(4,2), ( CONVERT( float, COUNT(IUCR))/@totalNumCrimes ) * 100 ) AS crimePercentage
                FROM Areas
                FULL OUTER JOIN Crimes ON Crimes.Area = Areas.Area
                GROUP BY Areas.AreaName, Areas.Area
                ORDER BY Areas.AreaName ASC;
                ");

                DataSet ds = DataAccessTier.DB.ExecuteNonScalarQuery(sql);

                foreach (DataRow row in ds.Tables["TABLE"].Rows)
                {
                    Models.Area a = new Models.Area();

                    a.AreaName        = Convert.ToString(row["AreaName"]);
                    a.AreaNum         = Convert.ToInt32(row["Area"]);
                    a.NumCrimes       = Convert.ToInt32(row["numCrimes"]);
                    a.CrimePercentage = Convert.ToSingle(row["crimePercentage"]);

                    areaList.Add(a);
                }
            } // end try
            catch (Exception ex) {
                EX = ex;
            }
            finally
            {
                AreaList = areaList;
            }
        } // end OnGet()
예제 #11
0
        public static Models.Area Load(Models.Area area, GomObjectData obj)
        {
            if (obj == null)
            {
                return(area);
            }
            if (area == null)
            {
                return(null);
            }

            IDictionary <string, object> objAsDict = obj.Dictionary;

            if (objAsDict.ContainsKey("mapAreasDataDisplayNameId") && objAsDict.ContainsKey("mapAreasDataDefaultZoneName"))
            {
                area.DisplayNameId = obj.ValueOrDefault <long>("mapAreasDataDisplayNameId", 0);
                area.Id            = (int)(area.DisplayNameId & 0x7FFFFFFF);
                area.CommentableId = Guid.NewGuid();
                area.Name          = strTable.GetText(area.DisplayNameId, "MapArea." + area.DisplayNameId);
                area.AreaId        = obj.ValueOrDefault <ulong>("mapAreasDataAreaId", 0);
                area.ZoneName      = obj.ValueOrDefault <string>("mapAreasDataDefaultZoneName", null);

                string mapDataPath = String.Format("world.areas.{0}.mapdata", area.AreaId);
                var    mapDataObj  = DataObjectModel.GetObject(mapDataPath);
                if (mapDataObj != null)
                {
                    LoadMapdata(area, mapDataObj);
                }
                else
                {
                    Console.WriteLine("No MapData for " + area.Name);
                    area.Id = 0;
                }
            }
            else
            {
                area.Id = 0;
            }

            return(area);
        }
예제 #12
0
        public static void Load()
        {
            Cache.Clear();
            var reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM area_data");

            while (reader.Read())
            {
                var area = new Models.Area()
                {
                    val        = reader.GetInt32("superarea"),
                    ID         = reader.GetInt32("id"),
                    Name       = reader.GetString("name"),
                    Alignement = reader.GetInt32("align"),
                    Prisme     = reader.GetInt64("prisme"),
                };
                area.Intialize();
                Cache.Add(area.ID, area);
            }
            reader.Close();

            Logger.Info("Loaded @'" + Cache.Count + "'@ Area");
        }
예제 #13
0
        public static Models.Area GetCurrentArea()
        {
            var file = new FileInfo(FilePath);

            Models.Area result;
            if (!file.Exists)
            {
                //文件不存在就返回一个默认值,默认是成都
                result        = new Models.Area();
                result.ID     = 250;
                result.Name   = "成都";
                result.ZoneID = 23;
                //area.Zone = new Models.Zone() { ID = 23, Name = "四川" };
                result.AreaCode = "56294";
            }
            else
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Models.Area));
                using (var stream = file.Open(FileMode.Open, FileAccess.Read))
                {
                    result = (Models.Area)ser.ReadObject(stream);
                }
            }
            return(result);



            var area = new Models.Area();

            area.ID     = 250;
            area.Name   = "成都";
            area.ZoneID = 23;
            //area.Zone = new Models.Zone() { ID = 23, Name = "四川" };
            area.AreaCode = "56294";
            return(area);
        }
예제 #14
0
 public Index()
 {
     this.InitializeComponent();
     GastroCloud.Models.Area area = new Models.Area();
     gridAreas.ItemsSource = area.getDescuento();
 }
예제 #15
0
        private static void LoadMapdata(Models.Area area, GomObject obj)
        {
            List <object> mapPages = (List <object>)obj.Data.ValueOrDefault <List <object> >("mapDataContainerMapDataList", null);
            Dictionary <long, MapPage> pageLookup = new Dictionary <long, MapPage>();

            if (mapPages != null)
            {
                area.MapPages = new List <MapPage>();
                foreach (GomObjectData mapPage in mapPages)
                {
                    MapPage page = new MapPage();
                    page.Area = area;
                    page.Guid = mapPage.ValueOrDefault <long>("mapPageGUID", 0);
                    page.Id   = (int)(page.Guid & 0x7FFFFFFF);
                    var minCoord = mapPage.ValueOrDefault <List <float> >("mapPageMinCoord", null);
                    if (minCoord != null)
                    {
                        page.MinX = minCoord[0];
                        page.MinY = minCoord[1];
                        page.MinZ = minCoord[2];
                    }
                    var maxCoord = mapPage.ValueOrDefault <List <float> >("mapPageMaxCoord", null);
                    if (maxCoord != null)
                    {
                        page.MaxX = maxCoord[0];
                        page.MaxY = maxCoord[1];
                        page.MaxZ = maxCoord[2];
                    }
                    var miniMinCoord = mapPage.ValueOrDefault <List <float> >("mapPageMiniMinCoord", null);
                    if (miniMinCoord != null)
                    {
                        page.MiniMapMinX = miniMinCoord[0];
                        page.MiniMapMinZ = miniMinCoord[2];
                    }
                    var miniMaxCoord = mapPage.ValueOrDefault <List <float> >("mapPageMiniMaxCoord", null);
                    if (miniMaxCoord != null)
                    {
                        page.MiniMapMaxX = miniMaxCoord[0];
                        page.MiniMapMaxZ = miniMaxCoord[2];
                    }
                    page.CalculateVolume();
                    page.MountAllowed = mapPage.ValueOrDefault <bool>("mapMountAllowed", false);
                    page.IsHeroic     = mapPage.ValueOrDefault <bool>("mapIsHeroic", false);
                    page.ParentId     = mapPage.ValueOrDefault <long>("mapParentNameSId", 0);
                    page.SId          = mapPage.ValueOrDefault <long>("mapNameSId", 0);
                    page.MapName      = mapPage.ValueOrDefault <string>("mapName", null);

                    string mapImagePath = String.Format("/resources/world/areas/{0}/{1}_r.dds", area.AreaId, page.MapName);
                    page.HasImage = TorLib.Assets.HasFile(mapImagePath);

                    TorLib.Icons.AddMap(area.AreaId, page.MapName);

                    page.Name            = strTable.GetText(page.Guid, "MapPage." + page.MapName);
                    pageLookup[page.SId] = page;
                    area.MapPages.Add(page);
                }

                foreach (var p in area.MapPages)
                {
                    if (p.ParentId == 0)
                    {
                        continue;                  // MapPage has no parent (this is a world map)
                    }
                    MapPage parent;
                    if (pageLookup.TryGetValue(p.ParentId, out parent))
                    {
                        p.Parent = parent;
                    }
                    else
                    {
                        throw new InvalidOperationException("Unable to find parent map page");
                    }
                }
            }
        }
예제 #16
0
        public void OnGet()  
        {  
				  List<Models.Area> Areas = new List<Models.Area>();
					
					// clear exception:
					EX = null;
					
					try                                                  
					{
                        totalAreas=0;
                        
                        string sql = string.Format(@"
	SELECT AreaName, Area
    FROM Areas
    ORDER BY AreaName ASC;
	");
    
                        string sql2 = string.Format(@"
	SELECT Count(*) as numTimes, AreaName
    FROM Crimes
    INNER JOIN Areas ON Crimes.Area = Areas.Area
    GROUP BY AreaName
    ORDER BY AreaName
	");
    
                        string sql3 = string.Format(@"
    SELECT Count(*) AS total
    FROM Crimes;
    ");
                        object result = DataAccessTier.DB.ExecuteScalarQuery(sql3);
                        double totalCrimes = Convert.ToDouble(result);
    
    
						DataSet ds = DataAccessTier.DB.ExecuteNonScalarQuery(sql);
                        
                        DataSet ds2 = DataAccessTier.DB.ExecuteNonScalarQuery(sql2);
                        
                          
                        foreach (DataRow row in ds.Tables["TABLE"].Rows)
						{
							Models.Area m = new Models.Area();

							m.AreaName = Convert.ToString(row["AreaName"]);
							m.AreaNum = Convert.ToInt32(row["Area"]);
                    
							Areas.Add(m);
                            totalAreas++;
						}
                        
                        foreach (DataRow row in ds2.Tables["TABLE"].Rows)
						{                            
							double numcrimes = Convert.ToDouble(row["numTimes"]);
                            string area = Convert.ToString(row["AreaName"]);
                            
                            //double percentChicago = Convert.ToDouble(row["Area"]);
                            
                            foreach(Models.Area c in Areas) 
                            {
                                if(c.AreaName == area){ 
                                    c.numCrimes = (int)numcrimes;
                                    c.percentChicago = ((numcrimes/totalCrimes) *100);
                                    
                                }
                            }
						}
   
                        
					}
					catch(Exception ex)
					{
					  EX = ex;
					}
					finally
					{
                        AreaList = Areas;  
                    }
        }  
        /// <summary>
        /// 从DataSet中加载城市信息
        /// </summary>
        /// <param name="ds"></param>
        void InitZoneFromDataSet(DataSet ds)
        {
            var dtZone = ds.Tables[0];
            var dtArea = ds.Tables[1];
            this.ZoneList.Clear();
            foreach (DataRow dr in dtZone.Rows)
            {
                var zone = new Models.Zone()
                {
                    ID = Convert.ToInt32(dr["ID"]),
                    Name = dr["Zone"].ToString()
                };
                var drAreas = dtArea.Select("ZoneID=" + zone.ID);
                foreach (DataRow drArea in drAreas)
                {
                    var area = new Models.Area()
                    {
                        ID = Convert.ToInt32(drArea["ID"]),
                        ZoneID = Convert.ToInt32(drArea["ZoneID"]),
                        Name = drArea["Area"].ToString(),
                        AreaCode = drArea["AreaCode"].ToString()
                        //Zone = zone
                    };
                    zone.AreaList.Add(area);
                }

                this.ZoneList.Add(zone);
            }
        }