Example #1
0
 private string GetArea(HttpContext context)
 {
     try
     {
         string type = ConvertUtility.Trim(context.Request.QueryString["type"]);
         string code = ConvertUtility.Trim(context.Request.QueryString["code"]);
         string json = string.Empty;
         if (string.IsNullOrEmpty(type) || string.IsNullOrEmpty(code))
         {
             return(json);
         }
         ScopeService service = ScopeService.Init();
         //{p:[{id:'',name:''}],c:[{id:'',name:''}],d:[{id:'',name:''}]}
         if (type == Architectures.CITY)
         {
             IList <RegionType> region = service.RegionCollection.FindAll(m => m.CityId.Equals(code));
             IList <ScopeType>  scope  = service.ScopeCollection.FindAll(m => m.RegionId.Equals(region[0].RegionId));;
             json = ToJson(null, region, scope);
         }
         else if (type == Architectures.REGION)
         {
             json = ToJson(null, null, service.ScopeCollection.FindAll(m => m.RegionId.Equals(code)));
         }
         return(json);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 protected void Application_Start(object sender, EventArgs e)
 {
     try
     {
         ScopeService.Init();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private string GetJSON(string type, string code)
 {
     try
     {
         if (string.IsNullOrEmpty(type) || string.IsNullOrEmpty(code))
         {
             List <CityType> cityCollection = ScopeService.Init().CityCollection;
             StringBuilder   builder        = new StringBuilder();
             int             mIndex         = 0;
             int             mCount         = cityCollection.Count;
             builder.Append("[");
             foreach (var cityType in cityCollection)
             {
                 mIndex++;
                 City city = new City(cityType.CityId);
                 builder.AppendFormat("{{\"text\":\"{0}\",\"attributes\":{{\"type\":\"{2}\",\"code\":\"{1}\"}},\"state\":\"closed\"}}", city.CityName, city.CityId, Architectures.CITY);
                 if (mIndex != mCount)
                 {
                     builder.Append(",");
                 }
             }
             builder.Append("]");
             return(builder.ToString());
         }
         if (type == Architectures.CITY)
         {
             City city = new City(code);
             return(city.ToTree());
         }
         else if (type == Architectures.REGION)
         {
             Region region = new Region(code);
             return(region.ToTree());
         }
         else
         {
             return(string.Empty);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }