شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة ش.ش.و.

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Business

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

Default business support class.

   1:  using System;
   2:  using System.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Linq;
   5:  using System.Web;
   6:  using System.Data;
   7:  using System.Text;
   8:  using System.Xml;
   9:  using System.Xml.Linq;
  10:  using System.Text.RegularExpressions;
  11:   
  12:  namespace Ia.Learning.Kafiya.Model
  13:  {
  14:      ////////////////////////////////////////////////////////////////////////////
  15:   
  16:      /// <summary publish="true">
  17:      /// Default business support class.
  18:      /// </summary>
  19:      /// <value>
  20:      /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
  21:      /// </value>
  22:      /// <remarks> 
  23:      /// Copyright © 2008-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  24:      ///
  25:      /// 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
  26:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  27:      ///
  28:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  29:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  30:      /// 
  31:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  32:      /// 
  33:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  34:      /// </remarks> 
  35:      public class Business
  36:      {
  37:          ////////////////////////////////////////////////////////////////////////////
  38:   
  39:          /// <summary>
  40:          ///
  41:          /// </summary>
  42:          public Business()
  43:          {
  44:          }
  45:   
  46:          ////////////////////////////////////////////////////////////////////////////
  47:   
  48:          /// <summary>
  49:          ///
  50:          /// </summary>
  51:          public static void Search(System.Web.UI.Page page, string prefix, string middle, string postfix, string maxNumberOfLetters, out StringBuilder resultWords, out int resultState, out string result)
  52:          {
  53:              int maxNumberOfLettersInt;
  54:              ArrayList wordsArrayList;
  55:   
  56:              resultState = 0;
  57:              result = "";
  58:   
  59:              resultWords = null;
  60:   
  61:              try
  62:              {
  63:                  if (prefix.Length == 0 && middle.Length == 0 && postfix.Length == 0 && maxNumberOfLetters.Length == 0)
  64:                  {
  65:                      result = "خطأ: لم تدخل أي قيم. ";
  66:                      resultState = -1;
  67:                  }
  68:                  else
  69:                  {
  70:                      if (maxNumberOfLetters.Length > 0 && !Ia.Cl.Model.Default.IsInt(maxNumberOfLetters))
  71:                      {
  72:                          result = "خطأ: عدد حروف الكلمات غير منطقي. ";
  73:                          resultState = -1;
  74:                      }
  75:                      else
  76:                      {
  77:                          if (page.Session["wordsArrayList"] == null) wordsArrayList = Ia.Cl.Model.Language.ListOfAllArabicWords;
  78:                          else wordsArrayList = (ArrayList)page.Session["wordsArrayList"];
  79:   
  80:                          resultWords = new StringBuilder(wordsArrayList.Count);
  81:   
  82:                          if (maxNumberOfLetters.Length == 0) maxNumberOfLettersInt = 100;
  83:                          else maxNumberOfLettersInt = int.Parse(maxNumberOfLetters);
  84:   
  85:                          var r = from string word in wordsArrayList
  86:                                  where word.StartsWith(prefix) && word.Contains(middle) && word.EndsWith(postfix) && word.Length <= maxNumberOfLettersInt 
  87:                                  orderby word 
  88:                                  select word;
  89:   
  90:                          if (r.Count() > 0)
  91:                          {
  92:                              foreach (string u in r) resultWords.Append(u + ", ");
  93:   
  94:                              resultWords = resultWords.Remove(resultWords.Length - 2, 2);
  95:   
  96:                              result = @"توجد " + r.Count() + @" كلمة تتوافر بها شروط البحث. ";
  97:                              resultState = 1;
  98:                          }
  99:                          else
 100:                          {
 101:                              result = @"لا توجد كلمات عربية تلبي شروط البحث. ";
 102:                              resultState = 0;
 103:                          }
 104:                      }
 105:                  }
 106:              }
 107:              catch (Exception ex)
 108:              {
 109:                  result = "خطأ استثنائي: " + ex.Message;
 110:                  resultState = -1;
 111:              }
 112:          }
 113:   
 114:          ////////////////////////////////////////////////////////////////////////////
 115:          ////////////////////////////////////////////////////////////////////////////
 116:      }
 117:  }