Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » FeatureDesignation

Public general use code classes and xml files that we've compiled and used over the years:

FeatureDesignation Support class for TentPlay Trek data model

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Text;
   5:  using System.Data.Linq.Mapping;
   6:  using System.Xml.Linq;
   7:  using System.IO;
   8:  using System.Reflection;
   9:  using System.Collections;
  10:   
  11:  namespace Ia.TentPlay.Cl.Model.Data.Trek
  12:  {
  13:      ////////////////////////////////////////////////////////////////////////////
  14:   
  15:      /// <summary publish="true">
  16:      /// FeatureDesignation Support class for TentPlay Trek data model
  17:      /// </summary>
  18:      /// 
  19:      /// <remarks> 
  20:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  21:      ///
  22:      /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  23:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  24:      ///
  25:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  26:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  27:      /// 
  28:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  29:      /// 
  30:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  31:      /// </remarks> 
  32:      public class FeatureDesignation
  33:      {
  34:          private static XDocument xDocument;
  35:          private static List<Ia.TentPlay.Cl.Model.Trek.FeatureDesignation> list;
  36:          private static List<Ia.Cl.Model.Language> languageList;
  37:   
  38:          ////////////////////////////////////////////////////////////////////////////
  39:   
  40:          /// <summary>
  41:          ///
  42:          /// </summary>
  43:          public FeatureDesignation() { }
  44:   
  45:          ////////////////////////////////////////////////////////////////////////////
  46:   
  47:          /// <summary>
  48:          ///
  49:          /// </summary>
  50:          public static List<Ia.TentPlay.Cl.Model.Trek.FeatureDesignation> ListFromDatabase(out Ia.Cl.Model.Result result)
  51:          {
  52:              result = new Ia.Cl.Model.Result();
  53:   
  54:              list = new List<Ia.TentPlay.Cl.Model.Trek.FeatureDesignation>();
  55:   
  56:              using (var db = new Ia.TentPlay.Db.Trek())
  57:              {
  58:                  list = (from nfdc in db.FeatureDesignations select nfdc).ToList();
  59:              }
  60:   
  61:              result.AddSuccess("FeatureDesignation count: " + list.Count);
  62:   
  63:              return list;
  64:          }
  65:   
  66:          ////////////////////////////////////////////////////////////////////////////
  67:   
  68:          /// <summary>
  69:          ///
  70:          /// </summary>
  71:          public static List<Ia.Cl.Model.Language> LanguageList
  72:          {
  73:              get
  74:              {
  75:                  if (languageList == null || languageList.Count == 0)
  76:                  {
  77:                      languageList = new List<Ia.Cl.Model.Language>();
  78:   
  79:                      languageList.Add(new Ia.Cl.Model.Language("en"));
  80:                      languageList.Add(new Ia.Cl.Model.Language("ar"));
  81:                      languageList.Add(new Ia.Cl.Model.Language("da"));
  82:   
  83:                      languageList.Add(new Ia.Cl.Model.Language("zh_traditional"));
  84:                      languageList.Add(new Ia.Cl.Model.Language("zh_simplified"));
  85:   
  86:                      languageList.Add(new Ia.Cl.Model.Language("hi"));
  87:                      languageList.Add(new Ia.Cl.Model.Language("ja"));
  88:                      languageList.Add(new Ia.Cl.Model.Language("de"));
  89:                      languageList.Add(new Ia.Cl.Model.Language("ru"));
  90:                      languageList.Add(new Ia.Cl.Model.Language("pt"));
  91:                      languageList.Add(new Ia.Cl.Model.Language("id"));
  92:                      languageList.Add(new Ia.Cl.Model.Language("fr"));
  93:                      languageList.Add(new Ia.Cl.Model.Language("es"));
  94:                      languageList.Add(new Ia.Cl.Model.Language("it"));
  95:                      languageList.Add(new Ia.Cl.Model.Language("ko"));
  96:                      languageList.Add(new Ia.Cl.Model.Language("tr"));
  97:                      languageList.Add(new Ia.Cl.Model.Language("fa"));
  98:                      languageList.Add(new Ia.Cl.Model.Language("th"));
  99:                      languageList.Add(new Ia.Cl.Model.Language("ha"));
 100:                      languageList.Add(new Ia.Cl.Model.Language("ig"));
 101:                      languageList.Add(new Ia.Cl.Model.Language("yo"));
 102:                      languageList.Add(new Ia.Cl.Model.Language("pl"));
 103:                      languageList.Add(new Ia.Cl.Model.Language("ur"));
 104:                      languageList.Add(new Ia.Cl.Model.Language("nl"));
 105:                      languageList.Add(new Ia.Cl.Model.Language("ms"));
 106:                      languageList.Add(new Ia.Cl.Model.Language("tl"));
 107:                      languageList.Add(new Ia.Cl.Model.Language("af"));
 108:                      languageList.Add(new Ia.Cl.Model.Language("zu"));
 109:                      languageList.Add(new Ia.Cl.Model.Language("xh"));
 110:                      languageList.Add(new Ia.Cl.Model.Language("bn"));
 111:                      languageList.Add(new Ia.Cl.Model.Language("vi"));
 112:                      languageList.Add(new Ia.Cl.Model.Language("kk"));
 113:                      languageList.Add(new Ia.Cl.Model.Language("ro"));
 114:                      languageList.Add(new Ia.Cl.Model.Language("no"));
 115:                      languageList.Add(new Ia.Cl.Model.Language("uk"));
 116:                      languageList.Add(new Ia.Cl.Model.Language("cs"));
 117:                      languageList.Add(new Ia.Cl.Model.Language("he"));
 118:                      languageList.Add(new Ia.Cl.Model.Language("el"));
 119:                      languageList.Add(new Ia.Cl.Model.Language("my"));
 120:                      languageList.Add(new Ia.Cl.Model.Language("hu"));
 121:                      languageList.Add(new Ia.Cl.Model.Language("ga"));
 122:                      languageList.Add(new Ia.Cl.Model.Language("si"));
 123:                      languageList.Add(new Ia.Cl.Model.Language("ta"));
 124:                      languageList.Add(new Ia.Cl.Model.Language("fi"));
 125:                      languageList.Add(new Ia.Cl.Model.Language("uz"));
 126:                      languageList.Add(new Ia.Cl.Model.Language("az"));
 127:                      languageList.Add(new Ia.Cl.Model.Language("be"));
 128:                      languageList.Add(new Ia.Cl.Model.Language("sk"));
 129:                      languageList.Add(new Ia.Cl.Model.Language("am"));
 130:                      languageList.Add(new Ia.Cl.Model.Language("sw"));
 131:                      languageList.Add(new Ia.Cl.Model.Language("bg"));
 132:                      languageList.Add(new Ia.Cl.Model.Language("hr"));
 133:                      languageList.Add(new Ia.Cl.Model.Language("lt"));
 134:                      languageList.Add(new Ia.Cl.Model.Language("ne"));
 135:                      languageList.Add(new Ia.Cl.Model.Language("sl"));
 136:                      languageList.Add(new Ia.Cl.Model.Language("ps"));
 137:                      languageList.Add(new Ia.Cl.Model.Language("lb"));
 138:                      languageList.Add(new Ia.Cl.Model.Language("km"));
 139:                      languageList.Add(new Ia.Cl.Model.Language("lv"));
 140:                      languageList.Add(new Ia.Cl.Model.Language("bs"));
 141:                      languageList.Add(new Ia.Cl.Model.Language("et"));
 142:                      languageList.Add(new Ia.Cl.Model.Language("lo"));
 143:                      languageList.Add(new Ia.Cl.Model.Language("mn"));
 144:                      languageList.Add(new Ia.Cl.Model.Language("mg"));
 145:                      languageList.Add(new Ia.Cl.Model.Language("ka"));
 146:                      languageList.Add(new Ia.Cl.Model.Language("sq"));
 147:                      languageList.Add(new Ia.Cl.Model.Language("mk"));
 148:                      languageList.Add(new Ia.Cl.Model.Language("hy"));
 149:                      languageList.Add(new Ia.Cl.Model.Language("tg"));
 150:                      languageList.Add(new Ia.Cl.Model.Language("ky"));
 151:                      languageList.Add(new Ia.Cl.Model.Language("is"));
 152:                      languageList.Add(new Ia.Cl.Model.Language("mt"));
 153:                      languageList.Add(new Ia.Cl.Model.Language("ca"));
 154:                  }
 155:   
 156:                  return languageList;
 157:              }
 158:          }
 159:   
 160:          ////////////////////////////////////////////////////////////////////////////
 161:   
 162:          /// <summary>
 163:          ///
 164:          /// </summary>
 165:          public static List<Ia.TentPlay.Cl.Model.Trek.FeatureDesignation> List
 166:          {
 167:              get
 168:              {
 169:                  if (list == null || list.Count == 0)
 170:                  {
 171:                      Ia.TentPlay.Cl.Model.Trek.FeatureDesignation featureDesignationCode;
 172:   
 173:                      list = new List<Ia.TentPlay.Cl.Model.Trek.FeatureDesignation>();
 174:   
 175:                      foreach (XElement xe in XDocument.Element("featureDesignationList").Elements("featureDesignation"))
 176:                      {
 177:                          featureDesignationCode = new Ia.TentPlay.Cl.Model.Trek.FeatureDesignation();
 178:   
 179:                          featureDesignationCode.Id = xe.Attribute("id").Value;
 180:   
 181:                          featureDesignationCode.En = xe.Attribute("en").Value;
 182:                          featureDesignationCode.Ar = xe.Attribute("ar").Value;
 183:                          featureDesignationCode.Da = xe.Attribute("da").Value;
 184:                          featureDesignationCode.Zh_Simplified = xe.Attribute("zh_simplified").Value;
 185:                          featureDesignationCode.Zh_Traditional = xe.Attribute("zh_traditional").Value;
 186:                          featureDesignationCode.Hi = xe.Attribute("hi").Value;
 187:                          featureDesignationCode.Ja = xe.Attribute("ja").Value;
 188:                          featureDesignationCode.De = xe.Attribute("de").Value;
 189:                          featureDesignationCode.Ru = xe.Attribute("ru").Value;
 190:                          featureDesignationCode.Pt = xe.Attribute("pt").Value;
 191:                          featureDesignationCode._Id = xe.Attribute("_id").Value;
 192:                          featureDesignationCode.Fr = xe.Attribute("fr").Value;
 193:                          featureDesignationCode.Es = xe.Attribute("es").Value;
 194:                          featureDesignationCode.It = xe.Attribute("it").Value;
 195:                          featureDesignationCode.Ko = xe.Attribute("ko").Value;
 196:                          featureDesignationCode.Tr = xe.Attribute("tr").Value;
 197:                          featureDesignationCode.Fa = xe.Attribute("fa").Value;
 198:                          featureDesignationCode.Th = xe.Attribute("th").Value;
 199:                          featureDesignationCode.Ha = xe.Attribute("ha").Value;
 200:                          featureDesignationCode.Ig = xe.Attribute("ig").Value;
 201:                          featureDesignationCode.Yo = xe.Attribute("yo").Value;
 202:                          featureDesignationCode.Pl = xe.Attribute("pl").Value;
 203:                          featureDesignationCode.Ur = xe.Attribute("ur").Value;
 204:                          featureDesignationCode.Nl = xe.Attribute("nl").Value;
 205:                          featureDesignationCode.Ms = xe.Attribute("ms").Value;
 206:                          featureDesignationCode.Tl = xe.Attribute("tl").Value;
 207:                          featureDesignationCode.Af = xe.Attribute("af").Value;
 208:                          featureDesignationCode.Zu = xe.Attribute("zu").Value;
 209:                          featureDesignationCode.Xh = xe.Attribute("xh").Value;
 210:                          featureDesignationCode.Bn = xe.Attribute("bn").Value;
 211:                          featureDesignationCode.Vi = xe.Attribute("vi").Value;
 212:                          featureDesignationCode.Kk = xe.Attribute("kk").Value;
 213:                          featureDesignationCode.Ro = xe.Attribute("ro").Value;
 214:                          featureDesignationCode.No = xe.Attribute("no").Value;
 215:                          featureDesignationCode.Uk = xe.Attribute("uk").Value;
 216:                          featureDesignationCode.Cs = xe.Attribute("cs").Value;
 217:                          featureDesignationCode.He = xe.Attribute("he").Value;
 218:                          featureDesignationCode.El = xe.Attribute("el").Value;
 219:                          featureDesignationCode.My = xe.Attribute("my").Value;
 220:                          featureDesignationCode.Hu = xe.Attribute("hu").Value;
 221:                          featureDesignationCode.Ga = xe.Attribute("ga").Value;
 222:                          featureDesignationCode.Si = xe.Attribute("si").Value;
 223:                          featureDesignationCode.Ta = xe.Attribute("ta").Value;
 224:                          featureDesignationCode.Fi = xe.Attribute("fi").Value;
 225:                          featureDesignationCode.Uz = xe.Attribute("uz").Value;
 226:                          featureDesignationCode.Az = xe.Attribute("az").Value;
 227:                          featureDesignationCode.Be = xe.Attribute("be").Value;
 228:                          featureDesignationCode.Sk = xe.Attribute("sk").Value;
 229:                          featureDesignationCode.Am = xe.Attribute("am").Value;
 230:                          featureDesignationCode.Sw = xe.Attribute("sw").Value;
 231:                          featureDesignationCode.Bg = xe.Attribute("bg").Value;
 232:                          featureDesignationCode.Hr = xe.Attribute("hr").Value;
 233:                          featureDesignationCode.Lt = xe.Attribute("lt").Value;
 234:                          featureDesignationCode.Ne = xe.Attribute("ne").Value;
 235:                          featureDesignationCode.Sl = xe.Attribute("sl").Value;
 236:                          featureDesignationCode.Ps = xe.Attribute("ps").Value;
 237:                          featureDesignationCode.Lb = xe.Attribute("lb").Value;
 238:                          featureDesignationCode.Km = xe.Attribute("km").Value;
 239:                          featureDesignationCode.Lv = xe.Attribute("lv").Value;
 240:                          featureDesignationCode.Bs = xe.Attribute("bs").Value;
 241:                          featureDesignationCode.Et = xe.Attribute("et").Value;
 242:                          featureDesignationCode.Lo = xe.Attribute("lo").Value;
 243:                          featureDesignationCode.Mn = xe.Attribute("mn").Value;
 244:                          featureDesignationCode.Mg = xe.Attribute("mg").Value;
 245:                          featureDesignationCode.Ka = xe.Attribute("ka").Value;
 246:                          featureDesignationCode.Sq = xe.Attribute("sq").Value;
 247:                          featureDesignationCode.Mk = xe.Attribute("mk").Value;
 248:                          featureDesignationCode.Hy = xe.Attribute("hy").Value;
 249:                          featureDesignationCode.Tg = xe.Attribute("tg").Value;
 250:                          featureDesignationCode.Ky = xe.Attribute("ky").Value;
 251:                          featureDesignationCode.Is = xe.Attribute("is").Value;
 252:                          featureDesignationCode.Mt = xe.Attribute("mt").Value;
 253:                          featureDesignationCode.Ca = xe.Attribute("ca").Value;
 254:                          featureDesignationCode.Description = xe.Attribute("enDescription").Value;
 255:                          featureDesignationCode.Class = xe.Attribute("class").Value.Substring(0, 1); // read just the first letter of, say, "A - Administrative"
 256:   
 257:                          featureDesignationCode.Created = DateTime.UtcNow.AddHours(3);
 258:                          featureDesignationCode.Updated = DateTime.UtcNow.AddHours(3);
 259:   
 260:                          list.Add(featureDesignationCode);
 261:                      }
 262:                  }
 263:   
 264:                  return list;
 265:              }
 266:          }
 267:   
 268:          ////////////////////////////////////////////////////////////////////////////
 269:   
 270:          /// <summary>
 271:          ///
 272:          /// </summary>
 273:          public static Hashtable DesignationIdToClassIdHashtable
 274:          {
 275:              get
 276:              {
 277:                  Hashtable ht;
 278:   
 279:                  ht = new Hashtable();
 280:   
 281:                  foreach (Ia.TentPlay.Cl.Model.Trek.FeatureDesignation fd in Ia.TentPlay.Cl.Model.Data.Trek.FeatureDesignation.List)
 282:                  {
 283:                      ht[fd.Id] = fd.Class;
 284:                  }
 285:   
 286:                  return ht;
 287:              }
 288:          }
 289:   
 290:          ////////////////////////////////////////////////////////////////////////////
 291:   
 292:          /// <summary>
 293:          ///
 294:          /// </summary>
 295:          public static Hashtable DesignationIdToDesignationCaptionHashtable(string languageIso6391)
 296:          {
 297:              Hashtable ht;
 298:   
 299:              ht = new Hashtable();
 300:   
 301:              foreach (Ia.TentPlay.Cl.Model.Trek.FeatureDesignation fd in Ia.TentPlay.Cl.Model.Data.Trek.FeatureDesignation.List)
 302:              {
 303:                  switch (languageIso6391)
 304:                  {
 305:                      case "en": ht[fd.Id] = fd.En; break;
 306:                      case "ar": ht[fd.Id] = fd.Ar; break;
 307:                      case "da": ht[fd.Id] = fd.Da; break;
 308:                      case "zh_simplified": ht[fd.Id] = fd.Zh_Simplified; break;
 309:                      case "zh_traditional": ht[fd.Id] = fd.Zh_Traditional; break;
 310:                      case "hi": ht[fd.Id] = fd.Hi; break;
 311:                      case "ja": ht[fd.Id] = fd.Ja; break;
 312:                      case "de": ht[fd.Id] = fd.De; break;
 313:                      case "ru": ht[fd.Id] = fd.Ru; break;
 314:                      case "pt": ht[fd.Id] = fd.Pt; break;
 315:                      case "fr": ht[fd.Id] = fd.Fr; break;
 316:                      case "es": ht[fd.Id] = fd.Es; break;
 317:                      case "it": ht[fd.Id] = fd.It; break;
 318:                      case "ko": ht[fd.Id] = fd.Ko; break;
 319:                      case "tr": ht[fd.Id] = fd.Tr; break;
 320:                      case "fa": ht[fd.Id] = fd.Fa; break;
 321:                      case "th": ht[fd.Id] = fd.Th; break;
 322:                      case "ha": ht[fd.Id] = fd.Ha; break;
 323:                      case "ig": ht[fd.Id] = fd.Ig; break;
 324:                      case "yo": ht[fd.Id] = fd.Yo; break;
 325:                      case "pl": ht[fd.Id] = fd.Pl; break;
 326:                      case "ur": ht[fd.Id] = fd.Ur; break;
 327:                      case "nl": ht[fd.Id] = fd.Nl; break;
 328:                      case "ms": ht[fd.Id] = fd.Ms; break;
 329:                      case "tl": ht[fd.Id] = fd.Tl; break;
 330:                      case "af": ht[fd.Id] = fd.Af; break;
 331:                      case "zu": ht[fd.Id] = fd.Zu; break;
 332:                      case "xh": ht[fd.Id] = fd.Xh; break;
 333:                      case "bn": ht[fd.Id] = fd.Bn; break;
 334:                      case "vi": ht[fd.Id] = fd.Vi; break;
 335:                      case "kk": ht[fd.Id] = fd.Kk; break;
 336:                      case "ro": ht[fd.Id] = fd.Ro; break;
 337:                      case "no": ht[fd.Id] = fd.No; break;
 338:                      case "uk": ht[fd.Id] = fd.Uk; break;
 339:                      case "cs": ht[fd.Id] = fd.Cs; break;
 340:                      case "he": ht[fd.Id] = fd.He; break;
 341:                      case "el": ht[fd.Id] = fd.El; break;
 342:                      case "my": ht[fd.Id] = fd.My; break;
 343:                      case "hu": ht[fd.Id] = fd.Hu; break;
 344:                      case "ga": ht[fd.Id] = fd.Ga; break;
 345:                      case "si": ht[fd.Id] = fd.Si; break;
 346:                      case "ta": ht[fd.Id] = fd.Ta; break;
 347:                      case "fi": ht[fd.Id] = fd.Fi; break;
 348:                      case "uz": ht[fd.Id] = fd.Uz; break;
 349:                      case "az": ht[fd.Id] = fd.Az; break;
 350:                      case "be": ht[fd.Id] = fd.Be; break;
 351:                      case "sk": ht[fd.Id] = fd.Sk; break;
 352:                      case "am": ht[fd.Id] = fd.Am; break;
 353:                      case "sw": ht[fd.Id] = fd.Sw; break;
 354:                      case "bg": ht[fd.Id] = fd.Bg; break;
 355:                      case "hr": ht[fd.Id] = fd.Hr; break;
 356:                      case "lt": ht[fd.Id] = fd.Lt; break;
 357:                      case "ne": ht[fd.Id] = fd.Ne; break;
 358:                      case "sl": ht[fd.Id] = fd.Sl; break;
 359:                      case "ps": ht[fd.Id] = fd.Ps; break;
 360:                      case "lb": ht[fd.Id] = fd.Lb; break;
 361:                      case "km": ht[fd.Id] = fd.Km; break;
 362:                      case "lv": ht[fd.Id] = fd.Lv; break;
 363:                      case "bs": ht[fd.Id] = fd.Bs; break;
 364:                      case "et": ht[fd.Id] = fd.Et; break;
 365:                      case "lo": ht[fd.Id] = fd.Lo; break;
 366:                      case "mn": ht[fd.Id] = fd.Mn; break;
 367:                      case "mg": ht[fd.Id] = fd.Mg; break;
 368:                      case "ka": ht[fd.Id] = fd.Ka; break;
 369:                      case "sq": ht[fd.Id] = fd.Sq; break;
 370:                      case "mk": ht[fd.Id] = fd.Mk; break;
 371:                      case "hy": ht[fd.Id] = fd.Hy; break;
 372:                      case "tg": ht[fd.Id] = fd.Tg; break;
 373:                      case "ky": ht[fd.Id] = fd.Ky; break;
 374:                      case "is": ht[fd.Id] = fd.Is; break;
 375:                      case "mt": ht[fd.Id] = fd.Mt; break;
 376:                      case "ca": ht[fd.Id] = fd.Ca; break;
 377:   
 378:                      default: ht[fd.Id] = fd.En; break;
 379:                  }
 380:              }
 381:   
 382:              return ht;
 383:          }
 384:   
 385:          ////////////////////////////////////////////////////////////////////////////
 386:          ////////////////////////////////////////////////////////////////////////////
 387:   
 388:          /// <summary>
 389:          /// 
 390:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 391:          /// 
 392:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 393:          /// 2. Add "using System.Reflection".
 394:          /// 3. See sample below.
 395:          /// 
 396:          /// </summary>
 397:   
 398:          private static XDocument XDocument
 399:          {
 400:              get
 401:              {
 402:                  Assembly _assembly;
 403:                  StreamReader streamReader;
 404:   
 405:                  if (xDocument == null)
 406:                  {
 407:                      _assembly = Assembly.GetExecutingAssembly();
 408:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.TentPlay.Cl.model.data.trek.feature-designation.xml"));
 409:   
 410:                      try
 411:                      {
 412:                          if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 413:                      }
 414:                      catch (Exception)
 415:                      {
 416:                      }
 417:                      finally
 418:                      {
 419:                      }
 420:                  }
 421:   
 422:                  return xDocument;
 423:              }
 424:          }
 425:   
 426:          ////////////////////////////////////////////////////////////////////////////
 427:          ////////////////////////////////////////////////////////////////////////////    
 428:      }
 429:  }