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

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

Koran Reference Network Class Library support functions: Business model

   1:  using System;
   2:  using System.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Linq;
   5:  using System.Web;
   6:  using System.Web.SessionState;
   7:  using System.Data;
   8:  using System.Text;
   9:  using System.Xml;
  10:  using System.Xml.Linq;
  11:  using System.Text.RegularExpressions;
  12:  using System.Globalization;
  13:   
  14:  namespace Ia.Islamic.Cl.Model.Business
  15:  {
  16:      ////////////////////////////////////////////////////////////////////////////
  17:   
  18:      /// <summary publish="true">
  19:      /// Koran Reference Network Class Library support functions: Business model
  20:      /// </summary>
  21:      /// <value>
  22:      /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
  23:      /// </value>
  24:      /// <remarks> 
  25:      /// Copyright © 2001-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  26:      ///
  27:      /// 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
  28:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  29:      ///
  30:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  31:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  32:      /// 
  33:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  34:      /// 
  35:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  36:      /// </remarks> 
  37:      public class Default
  38:      {
  39:          ////////////////////////////////////////////////////////////////////////////
  40:   
  41:          /// <summary>
  42:          ///
  43:          /// </summary>
  44:          public Default()
  45:          {
  46:          }
  47:   
  48:          /*
  49:          ////////////////////////////////////////////////////////////////////////////
  50:          ////////////////////////////////////////////////////////////////////////////
  51:  
  52:          /// <summary>
  53:          ///
  54:          /// </summary>
  55:          public DataTable Search(string line, Ia.Cl.Model.Language language, out int op, out string result)
  56:          {
  57:              string s, id, word, verse_li;
  58:              string[] sp;
  59:              DataTable dt;
  60:              StringBuilder sb;
  61:              Hashtable ht, word_ht, variant_ht, verse_ht, variant_verse_ht, word_verse_ht;
  62:              MatchCollection mc;
  63:  
  64:              dt = null;
  65:  
  66:              if (line != "")
  67:              {
  68:                  // below: replace all consecutive space characters with a single ' '
  69:                  line = Regex.Replace(line, @"\s+", " ");
  70:  
  71:                  // below: spaces at the start and end of string
  72:                  line = Regex.Replace(line, @"^\s+", "");
  73:                  line = Regex.Replace(line, @"\s+$", "");
  74:  
  75:                  // below: remove any possible consecutive * wildcards.
  76:                  //line = Regex.Replace(line, @"\*{2,}", @"\*");
  77:  
  78:                  word_ht = new Hashtable(10);
  79:                  variant_ht = new Hashtable(word_ht.Count);
  80:                  variant_verse_ht = new Hashtable(word_ht.Count);
  81:                  word_verse_ht = new Hashtable(word_ht.Count);
  82:  
  83:                  s = "[" + Ia.Cl.Model.Language.Word(language.Symbol) + "]+|[" + Ia.Cl.Model.Language.Ideograph(language.Symbol) + "]{1}";
  84:                  s = s.Replace("|[]{1}", "");
  85:  
  86:                  mc = Regex.Matches(line, @"(" + s + ")", RegexOptions.Compiled);
  87:                  foreach (Match m in mc)
  88:                  {
  89:                      word = m.Groups[1].Captures[0].Value;
  90:  
  91:                      // below: words regular
  92:                      word_ht[word] = null;
  93:                      variant_ht[word] = word;
  94:  
  95:                      // below: unaccented:
  96:                      variant_ht[this.Unaccent(word)] = word;
  97:  
  98:                      // below: basic form: lower case, no accents
  99:                      variant_ht[this.Basic(word)] = word;
 100:                  }
 101:  
 102:                  word_ht.Remove(" ");
 103:                  word_ht.Remove("");
 104:  
 105:                  variant_ht.Remove(" ");
 106:                  variant_ht.Remove("");
 107:  
 108:                  // below: collect info from hashtable to sql
 109:  
 110:                  if (word_ht.Count > 0)
 111:                  {
 112:                      dt = data.ReturnAllWordVerseForLanguageAndVariants(language, variant_ht);
 113:  
 114:                      try
 115:                      {
 116:                          if (dt != null)
 117:                          {
 118:                              if (dt.Rows.Count > 0)
 119:                              {
 120:                                  verse_li = "";
 121:  
 122:                                  foreach (DataRow ra in dt.Rows)
 123:                                  {
 124:                                      id = ra["id"].ToString();
 125:                                      word = ra["word"].ToString();
 126:  
 127:                                      verse_li = ra["ia_verse_lid"].ToString();
 128:                                      verse_li = Regex.Replace(verse_li, @"\s+$", "");
 129:  
 130:                                      if (verse_li.Length > 0)
 131:                                      {
 132:                                          sp = verse_li.Split(' ');
 133:  
 134:                                          if (sp.Length > 0)
 135:                                          {
 136:                                              // below: the Hashtable below is to make sure we do not copy similar positions into variant_verse_ht
 137:  
 138:                                              ht = new Hashtable(sp.Length);
 139:  
 140:                                              foreach (string t in sp)
 141:                                              {
 142:                                                  if (t.Length > 0 && !ht.ContainsKey(t))
 143:                                                  {
 144:                                                      if (variant_verse_ht[word] == null) variant_verse_ht[word] = t;
 145:                                                      else variant_verse_ht[word] = variant_verse_ht[word] + " " + t;
 146:  
 147:                                                      ht[t] = 1;
 148:                                                  }
 149:                                              }
 150:                                          }
 151:                                      }
 152:                                  }
 153:  
 154:                                  variant_verse_ht.Remove(" ");
 155:                                  variant_verse_ht.Remove("");
 156:  
 157:                                  // below: I will loop through original words, loop through their variants, collect all positions of
 158:                                  // variants, and the positions of words
 159:                                  foreach (string u in word_ht.Keys)
 160:                                  {
 161:                                      foreach (string v in variant_ht.Keys)
 162:                                      {
 163:                                          word = variant_ht[v].ToString();
 164:  
 165:                                          // below: check if variant belongs to word
 166:                                          if (u == word)
 167:                                          {
 168:                                              // below: add positions of variant to word
 169:                                              if (variant_verse_ht[v] != null)
 170:                                              {
 171:                                                  if (word_verse_ht[u] == null) word_verse_ht[u] = variant_verse_ht[v].ToString();
 172:                                                  else if (word_verse_ht[u].ToString().IndexOf(variant_verse_ht[v].ToString()) >= 0) { }
 173:                                                  else word_verse_ht[u] = word_verse_ht[u] + " " + variant_verse_ht[v].ToString();
 174:                                              }
 175:                                          }
 176:                                      }
 177:                                  }
 178:  
 179:                                  // below: remove duplicate positions from word_verse
 180:                                  foreach (string u in word_ht.Keys)
 181:                                  {
 182:                                      sp = word_verse_ht[u].ToString().Split(' ');
 183:  
 184:                                      ht = new Hashtable(sp.Length);
 185:  
 186:                                      // below: collect unique positions
 187:                                      foreach (string t in sp) if (t.Length > 0) ht[t] = 1;
 188:  
 189:                                      sb = new StringBuilder(ht.Count * 8);
 190:  
 191:                                      // below: build string and assign it again
 192:                                      foreach (string v in ht.Keys) sb.Append(v + " ");
 193:  
 194:                                      if (sb.Length > 0)
 195:                                      {
 196:                                          s = sb.ToString();
 197:                                          s = s.Remove(s.Length - 1, 1);
 198:                                      }
 199:  
 200:                                      word_verse_ht[u] = s;
 201:                                  }
 202:  
 203:                                  if (word_verse_ht.Count > 0)
 204:                                  {
 205:                                      // below: collect all locations from all words in one hashtable. Increment the value for every time the location is entered
 206:                                      // then delete all entries that do not have a value equal to the number of words
 207:  
 208:                                      verse_ht = new Hashtable(1000);
 209:  
 210:                                      foreach (string t in word_verse_ht.Keys)
 211:                                      {
 212:                                          verse_li = word_verse_ht[t].ToString();
 213:  
 214:                                          if (verse_li.Length > 0)
 215:                                          {
 216:                                              sp = verse_li.Split(' ');
 217:  
 218:                                              if (sp.Length > 0)
 219:                                              {
 220:                                                  foreach (string u in sp)
 221:                                                  {
 222:                                                      // below: this will increment the value of key every time it appears
 223:                                                      if (verse_ht[u] == null) verse_ht[u] = 1;
 224:                                                      else verse_ht[u] = (int)verse_ht[u] + 1;
 225:                                                  }
 226:                                              }
 227:                                          }
 228:                                      }
 229:  
 230:                                      verse_ht.Remove(" ");
 231:                                      verse_ht.Remove("");
 232:  
 233:                                      ht = new Hashtable(verse_ht.Count);
 234:  
 235:                                      // below: now I will remove all verse_ht values that are less than the number of words
 236:                                      foreach (string t in verse_ht.Keys)
 237:                                      {
 238:                                          if ((int)verse_ht[t] == word_ht.Count) ht[t] = 1;
 239:  
 240:                                          if (ht.Count >= 1000) break; // TEMP break at max of results
 241:                                      }
 242:  
 243:                                      ht.Remove(" ");
 244:                                      ht.Remove("");
 245:  
 246:                                      if (ht.Count > 0)
 247:                                      {
 248:                                          dt = data.ReturnAllVersesForLanguageAndId(language, ht);
 249:  
 250:                                          try
 251:                                          {
 252:                                              if (dt != null)
 253:                                              {
 254:                                                  if (dt.Rows.Count > 0)
 255:                                                  {
 256:                                                      // below: result text
 257:                                                      op = 1;
 258:  
 259:                                                      if (word_ht.Count == 1)
 260:                                                      {
 261:                                                          result = Text("search_for_word");
 262:                                                          //result = (from u in xd.Descendants("search_for_word") select u.Value).Single();
 263:                                                      }
 264:                                                      else if (word_ht.Count > 1)
 265:                                                      {
 266:                                                          result = Text("search_for_words");
 267:                                                      }
 268:  
 269:                                                      result = @": """ + line + @""" " + Text("number_of_appear_words") + " " + ht.Count;
 270:                                                  }
 271:                                                  else
 272:                                                  {
 273:                                                      op = -1;
 274:                                                      result = "Verse query returned no results";
 275:                                                  }
 276:                                              }
 277:                                              else
 278:                                              {
 279:                                                  op = -1;
 280:                                                  result = "SQL verse query returned null DataTable";
 281:                                              }
 282:                                          }
 283:                                          catch (Exception ex)
 284:                                          {
 285:                                              op = -1;
 286:                                              result = "Exception: " + ex.Message;
 287:                                          }
 288:                                      }
 289:                                      else
 290:                                      {
 291:                                          op = -1;
 292:                                          result = Text("the_words");
 293:                                          result = @" """ + line + @""" ";
 294:                                          result = Text("not_all_together");
 295:                                      }
 296:                                  }
 297:                                  else
 298:                                  {
 299:                                      op = -1;
 300:                                      result = "Word verse Hashtable length zero";
 301:                                  }
 302:                              }
 303:                              else
 304:                              {
 305:                                  op = -1;
 306:  
 307:                                  if (word_ht.Count == 1)
 308:                                  {
 309:                                      result = Text("the_word");
 310:                                  }
 311:                                  else if (word_ht.Count > 1)
 312:                                  {
 313:                                      result = Text("the_words");
 314:                                  }
 315:  
 316:                                  result = @" """ + line + @""" ";
 317:  
 318:                                  if (word_ht.Count == 1)
 319:                                  {
 320:                                      result = Text("was_not_found");
 321:                                  }
 322:                                  else if (word_ht.Count > 1)
 323:                                  {
 324:                                      result = Text("were_not_found");
 325:                                  }
 326:                              }
 327:                          }
 328:                          else
 329:                          {
 330:                              op = -1;
 331:                              result = "SQL query returned null DataTable";
 332:                          }
 333:                      }
 334:                      catch (Exception ex)
 335:                      {
 336:                          op = -1;
 337:                          result = "Exception: " + ex.Message;
 338:                      }
 339:                  }
 340:                  else
 341:                  {
 342:                      op = -1;
 343:                      result = "Could not parse words";
 344:                  }
 345:              }
 346:              else
 347:              {
 348:                  op = -1;
 349:                  result = Text("empty_field");
 350:              }
 351:  
 352:              return dt;
 353:          }
 354:           */
 355:   
 356:          /*
 357:          ////////////////////////////////////////////////////////////////////////////
 358:          ////////////////////////////////////////////////////////////////////////////
 359:  
 360:          /// <summary>
 361:          /// Return text according to language
 362:          /// </summary>
 363:          public string Text(string text)
 364:          {
 365:              /*
 366:          language = "de";
 367:          translation_xd = Ia.Cl.Model.Xml.ReturnXmlNode(@"app_data\translation.xml");
 368:          xd = translation_xd.SelectSingleNode("language/lang[@symbol='" + language + "']/search/result"); 
 369:               * /
 370:  
 371:              return "";
 372:          }
 373:           */
 374:   
 375:          ////////////////////////////////////////////////////////////////////////////
 376:          ////////////////////////////////////////////////////////////////////////////
 377:   
 378:   
 379:   
 380:   
 381:   
 382:          ////////////////////////////////////////////////////////////////////////////
 383:          ////////////////////////////////////////////////////////////////////////////
 384:   
 385:          /// <summary>
 386:          ///
 387:          /// </summary>
 388:          public static List<Ia.Islamic.Cl.Model.Ui.VerseUi> Search(string line, string language_, out int op, out string result)
 389:          {
 390:              const int maximumLengthOfVerseList = 100;
 391:              string regularExpression, word, basicWord;
 392:              Hashtable wordHashtable, variantHashtable, variantVerseHashtable, wordVerseHashtable;
 393:              MatchCollection mc;
 394:              Translation translation;
 395:              List<Ia.Islamic.Cl.Model.Ui.VerseUi> verseList;
 396:              Ia.Cl.Model.Language language;
 397:   
 398:              language = new Ia.Cl.Model.Language(language_);
 399:   
 400:              translation = new Translation(language.Id);
 401:   
 402:              verseList = null;
 403:   
 404:              if (line != "")
 405:              {
 406:                  // below: replace all consecutive space characters with a single ' '
 407:                  line = Regex.Replace(line, @"\s+", " ");
 408:   
 409:                  // below: spaces at the start and end of string
 410:                  line = line.Trim();
 411:   
 412:                  // below: remove any possible consecutive * wildcards.
 413:                  //line = Regex.Replace(line, @"\*{2,}", @"\*");
 414:   
 415:                  wordHashtable = new Hashtable(10);
 416:                  variantHashtable = new Hashtable(wordHashtable.Count);
 417:                  variantVerseHashtable = new Hashtable(wordHashtable.Count);
 418:                  wordVerseHashtable = new Hashtable(wordHashtable.Count);
 419:   
 420:                  if (language.Id == "ja" || language.Id == "ko")
 421:                  {
 422:                      regularExpression = Ia.Cl.Model.Language.BasicWordsRegularExpression(language.Symbol) + "|[" + Ia.Cl.Model.Language.Ideograph(language.Symbol) + "]{1}";
 423:                      regularExpression = regularExpression.Replace("|[]{1}", "");
 424:                  }
 425:                  else
 426:                  {
 427:                      regularExpression = Ia.Cl.Model.Language.BasicWordsRegularExpression(language.Symbol);
 428:                  }
 429:   
 430:                  mc = Regex.Matches(Ia.Cl.Model.Language.BasicForm(line), @"(" + regularExpression + ")", RegexOptions.Compiled);
 431:   
 432:                  foreach (Match m in mc)
 433:                  {
 434:                      word = m.Groups[1].Captures[0].Value;
 435:   
 436:                      basicWord = Ia.Cl.Model.Language.BasicForm(word);
 437:   
 438:                      // below: words regular
 439:                      wordHashtable[word] = null;
 440:                      variantHashtable[word] = word;
 441:   
 442:                      // below: unaccented:
 443:                      //variant_ht[Ia.Cl.Model.Language.RemoveAccent(word)] = word;
 444:   
 445:                      // below: basic form: lower case, no accents
 446:                      variantHashtable[word] = basicWord;
 447:   
 448:                      if (language.Id == "ar")
 449:                      {
 450:                          ArrayList al;
 451:                          al = Ia.Cl.Model.Language.ProduceSimilarArabicWords(word);
 452:   
 453:                          foreach (string u in al) variantHashtable[u] = basicWord;
 454:                      }
 455:                  }
 456:   
 457:                  wordHashtable.Remove(" ");
 458:                  wordHashtable.Remove("");
 459:   
 460:                  variantHashtable.Remove(" ");
 461:                  variantHashtable.Remove("");
 462:   
 463:                  // below: collect info from hashtable to sql
 464:   
 465:                  if (wordHashtable.Count > 0)
 466:                  {
 467:                      verseList = Ia.Islamic.Cl.Model.Data.Default.VerseList(language, variantHashtable, maximumLengthOfVerseList, out op, out result);
 468:   
 469:                      if (verseList != null)
 470:                      {
 471:                          if (verseList.Count() > 0)
 472:                          {
 473:                              //    verse_li = "";
 474:   
 475:                              //    foreach (Verse ra in verseList)
 476:                              //    {
 477:                              //        id = ra.Id.ToString();
 478:                              //        word = ""; // ra["word"].ToString();
 479:   
 480:                              //        verse_li = ""; // ra["ia_verse_lid"].ToString();
 481:                              //        verse_li = Regex.Replace(verse_li, @"\s+$", "");
 482:   
 483:                              //        if (verse_li.Length > 0)
 484:                              //        {
 485:                              //            sp = verse_li.Split(' ');
 486:   
 487:                              //            if (sp.Length > 0)
 488:                              //            {
 489:                              //                // below: the Hashtable below is to make sure we do not copy similar positions into variant_verse_ht
 490:   
 491:                              //                ht = new Hashtable(sp.Length);
 492:   
 493:                              //                foreach (string t in sp)
 494:                              //                {
 495:                              //                    if (t.Length > 0 && !ht.ContainsKey(t))
 496:                              //                    {
 497:                              //                        if (variant_verse_ht[word] == null) variant_verse_ht[word] = t;
 498:                              //                        else variant_verse_ht[word] = variant_verse_ht[word] + " " + t;
 499:   
 500:                              //                        ht[t] = 1;
 501:                              //                    }
 502:                              //                }
 503:                              //            }
 504:                              //        }
 505:                              //    }
 506:   
 507:                              //    variant_verse_ht.Remove(" ");
 508:                              //    variant_verse_ht.Remove("");
 509:   
 510:                              //    // below: I will loop through original words, loop through their variants, collect all positions of
 511:                              //    // variants, and the positions of words
 512:                              //    foreach (string u in word_ht.Keys)
 513:                              //    {
 514:                              //        foreach (string v in variant_ht.Keys)
 515:                              //        {
 516:                              //            word = variant_ht[v].ToString();
 517:   
 518:                              //            // below: check if variant belongs to word
 519:                              //            if (u == word)
 520:                              //            {
 521:                              //                // below: add positions of variant to word
 522:                              //                if (variant_verse_ht[v] != null)
 523:                              //                {
 524:                              //                    if (word_verse_ht[u] == null) word_verse_ht[u] = variant_verse_ht[v].ToString();
 525:                              //                    else if (word_verse_ht[u].ToString().IndexOf(variant_verse_ht[v].ToString()) >= 0) { }
 526:                              //                    else word_verse_ht[u] = word_verse_ht[u] + " " + variant_verse_ht[v].ToString();
 527:                              //                }
 528:                              //            }
 529:                              //        }
 530:                              //    }
 531:   
 532:                              //    // below: remove duplicate positions from word_verse
 533:                              //    foreach (string u in word_ht.Keys)
 534:                              //    {
 535:                              //        sp = word_verse_ht[u].ToString().Split(' ');
 536:   
 537:                              //        ht = new Hashtable(sp.Length);
 538:   
 539:                              //        // below: collect unique positions
 540:                              //        foreach (string t in sp) if (t.Length > 0) ht[t] = 1;
 541:   
 542:                              //        sb = new StringBuilder(ht.Count * 8);
 543:   
 544:                              //        // below: build string and assign it again
 545:                              //        foreach (string v in ht.Keys) sb.Append(v + " ");
 546:   
 547:                              //        if (sb.Length > 0)
 548:                              //        {
 549:                              //            s = sb.ToString();
 550:                              //            s = s.Remove(s.Length - 1, 1);
 551:                              //        }
 552:   
 553:                              //        word_verse_ht[u] = s;
 554:                              //    }
 555:   
 556:                              //    if (word_verse_ht.Count > 0)
 557:                              //    {
 558:                              //        // below: collect all locations from all words in one hashtable. Increment the value for every time the location is entered
 559:                              //        // then delete all entries that do not have a value equal to the number of words
 560:   
 561:                              //        verse_ht = new Hashtable(1000);
 562:   
 563:                              //        foreach (string t in word_verse_ht.Keys)
 564:                              //        {
 565:                              //            verse_li = word_verse_ht[t].ToString();
 566:   
 567:                              //            if (verse_li.Length > 0)
 568:                              //            {
 569:                              //                sp = verse_li.Split(' ');
 570:   
 571:                              //                if (sp.Length > 0)
 572:                              //                {
 573:                              //                    foreach (string u in sp)
 574:                              //                    {
 575:                              //                        // below: this will increment the value of key every time it appears
 576:                              //                        if (verse_ht[u] == null) verse_ht[u] = 1;
 577:                              //                        else verse_ht[u] = (int)verse_ht[u] + 1;
 578:                              //                    }
 579:                              //                }
 580:                              //            }
 581:                              //        }
 582:   
 583:                              //        verse_ht.Remove(" ");
 584:                              //        verse_ht.Remove("");
 585:   
 586:                              //        ht = new Hashtable(verse_ht.Count);
 587:   
 588:                              //        // below: now I will remove all verse_ht values that are less than the number of words
 589:                              //        foreach (string t in verse_ht.Keys)
 590:                              //        {
 591:                              //            if ((int)verse_ht[t] == word_ht.Count) ht[t] = 1;
 592:   
 593:                              //            if (ht.Count >= 1000) break; // TEMP break at max of results
 594:                              //        }
 595:   
 596:                              //        ht.Remove(" ");
 597:                              //        ht.Remove("");
 598:   
 599:                              //        if (ht.Count > 0)
 600:                              //        {
 601:   
 602:                              if (wordHashtable.Count == 1)
 603:                              {
 604:                                  result = translation.ResultSearchForWord + @": """ + line + @""". " + translation.ResultNumberOfAppearWords + " " + verseList.Count();
 605:                              }
 606:                              else if (wordHashtable.Count > 1)
 607:                              {
 608:                                  result = translation.ResultSearchForWords + @": """ + line + @""". " + translation.ResultNumberOfAppearWords + " " + verseList.Count();
 609:                              }
 610:   
 611:                              //        }
 612:                              //        else
 613:                              //        {
 614:                              //            op = -1;
 615:                              //            result = "";//data.TranslationForKey("the_words") + @" """ + line + @""" " + data.TranslationForKey("not_all_together");
 616:                              //        }
 617:                              //    }
 618:                              //    else
 619:                              //    {
 620:                              //        op = -1;
 621:                              //        result = "Word verse Hashtable length zero";
 622:                              //    }
 623:   
 624:                              op = 1;
 625:                          }
 626:                          else
 627:                          {
 628:                              op = -1;
 629:   
 630:                              if (wordHashtable.Count == 1)
 631:                              {
 632:                                  result = translation.ResultTheWord + @" """ + line + @""" " + translation.ResultWasNotFound;
 633:                              }
 634:                              else if (wordHashtable.Count > 1)
 635:                              {
 636:                                  result = translation.ResultTheWords + @" """ + line + @""" " + translation.ResultWereNotFound;
 637:                              }
 638:                          }
 639:                      }
 640:                      else
 641:                      {
 642:                      }
 643:                  }
 644:                  else
 645:                  {
 646:                      op = -1;
 647:                      result = "Could not parse words";
 648:                  }
 649:              }
 650:              else
 651:              {
 652:                  op = -1;
 653:                  result = translation.ResultEmptyField;
 654:              }
 655:   
 656:              return verseList;
 657:          }
 658:   
 659:          ////////////////////////////////////////////////////////////////////////////
 660:   
 661:          /// <summary>
 662:          ///
 663:          /// </summary>
 664:          public static Ia.Islamic.Cl.Model.Ui.VerseUi Verse(Ia.Cl.Model.Language language, int chapterNumber, int verseNumber, out int op, out string result)
 665:          {
 666:              return Ia.Islamic.Cl.Model.Data.Default.Verse(language, chapterNumber, verseNumber, out op, out result);
 667:          }
 668:   
 669:          ////////////////////////////////////////////////////////////////////////////
 670:   
 671:          /// <summary>
 672:          ///
 673:          /// </summary>
 674:          public static Ia.Islamic.Cl.Model.Ui.VerseTopicUi VerseSpan(Ia.Cl.Model.Language language, int chapterNumber, int verseNumber, int numberOfVerses, out int op, out string result)
 675:          {
 676:              return Ia.Islamic.Cl.Model.Ui.VerseTopicUi.VerseTopic(language, chapterNumber, verseNumber, numberOfVerses, out op, out result);
 677:          }
 678:   
 679:          ////////////////////////////////////////////////////////////////////////////
 680:   
 681:          /// <summary>
 682:          ///
 683:          /// <remarks>HttpApplication has both Request and Session variables</remarks>
 684:          /// </summary>
 685:          public static void GlobalSession_Start(HttpContext context)
 686:          {
 687:              string countryCode, languageCode;
 688:   
 689:              //System.Data.DataSet ds;
 690:              //System.Data.DataRow dr;
 691:   
 692:              countryCode = "";
 693:              languageCode = "";
 694:   
 695:              /*
 696:              try
 697:              {
 698:                  // below: find the Geoip information of this IP
 699:  
 700:                  Ia.Cs.Sr.GeoipClient sr = new Ia.Cs.Sr.GeoipClient();
 701:  
 702:                  ds = sr.Ip_Country(this.Context.Request.UserHostAddress);
 703:  
 704:                  if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count == 1)
 705:                  {
 706:                      dr = ds.Tables[0].Rows[0];
 707:  
 708:      #if DEBUG
 709:                      languageCode = "fa";
 710:      #else
 711:                      languageCode = Ia.Cs.Language.ReturnLanguageCodeUsedInCountryFromCountyCode(dr["country_code"].ToString());
 712:      #endif
 713:                  }
 714:                  else
 715:                  {
 716:                  }
 717:              }
 718:              catch (Exception)
 719:              {
 720:              }
 721:               */
 722:   
 723:              context.Session["countryCode"] = countryCode;
 724:              context.Session["languageCode"] = languageCode;
 725:          }
 726:   
 727:          ////////////////////////////////////////////////////////////////////////////
 728:          ////////////////////////////////////////////////////////////////////////////
 729:      }
 730:  }