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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » ServiceRequestType

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

Service Request Type support class for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Linq;
   5:  using System.Globalization;
   6:  using System.Text.RegularExpressions;
   7:  using System.Data;
   8:  using System.Data.Entity;
   9:  using Ia.Ngn.Cl.Model.Business; // Needed for ServerExtension
  10:   
  11:  namespace Ia.Ngn.Cl.Model.Data
  12:  {
  13:      ////////////////////////////////////////////////////////////////////////////
  14:   
  15:      /// <summary publish="true">
  16:      /// Service Request Type support class for Next Generation Network (NGN) data model.
  17:      /// </summary>
  18:      /// 
  19:      /// <remarks> 
  20:      /// Copyright © 2006-2019 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 partial class ServiceRequestType
  33:      {
  34:          /// <summary/>
  35:          public ServiceRequestType() { }
  36:   
  37:          ////////////////////////////////////////////////////////////////////////////
  38:   
  39:          /// <summary>
  40:          ///
  41:          /// </summary>
  42:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> List()
  43:          {
  44:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
  45:   
  46:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  47:              {
  48:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes select srt).ToList();
  49:              }
  50:   
  51:              return serviceRequestTypeList;
  52:          }
  53:   
  54:          ////////////////////////////////////////////////////////////////////////////
  55:   
  56:          /// <summary>
  57:          ///
  58:          /// </summary>
  59:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> ReadListThatHasServiceRequestIdsWithinIdRange(int start, int end)
  60:          {
  61:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
  62:   
  63:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  64:              {
  65:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes
  66:                                            join sr in db.ServiceRequests
  67:                                            on srt.ServiceRequest.Id equals sr.Id
  68:                                            where sr.Id >= start && sr.Id <= end
  69:                                            select srt).ToList();
  70:              }
  71:   
  72:              return serviceRequestTypeList;
  73:          }
  74:   
  75:          ////////////////////////////////////////////////////////////////////////////
  76:   
  77:          /// <summary>
  78:          ///
  79:          /// </summary>
  80:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> ReadListThatHaveServiceRequestsWithinGivenDateRange(DateTime startDateTime, DateTime endDateTime)
  81:          {
  82:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
  83:   
  84:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  85:              {
  86:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes
  87:                                            join sr in db.ServiceRequests
  88:                                            on srt.ServiceRequest.Id equals sr.Id
  89:                                            where sr.RequestDateTime >= startDateTime && sr.RequestDateTime < endDateTime
  90:                                            select srt).ToList();
  91:              }
  92:   
  93:              return serviceRequestTypeList;
  94:          }
  95:   
  96:          ////////////////////////////////////////////////////////////////////////////
  97:   
  98:          /// <summary>
  99:          /// Return a list of service request types for service requests that has the same number as the one passed
 100:          /// </summary>
 101:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> RelatedToServiceRequestNumberList(int number)
 102:          {
 103:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 104:   
 105:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 106:              {
 107:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes where srt.ServiceRequest.Number == number select srt).Include(x => x.ServiceRequest).ToList();
 108:              }
 109:   
 110:              return serviceRequestTypeList;
 111:          }
 112:   
 113:          ////////////////////////////////////////////////////////////////////////////
 114:   
 115:          /// <summary>
 116:          /// Return a list of service request types for service requests that have numbers within the passed number-serial list
 117:          /// </summary>
 118:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> ReadListRelatedToServiceRequestNumberList(List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> numberSerialList)
 119:          {
 120:              List<long> idList;
 121:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 122:   
 123:              idList = numberSerialList.IdList();
 124:   
 125:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 126:              {
 127:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes
 128:                                            where
 129:                                            //numberSerialList.Contains(q.ServiceRequest.Number, q.ServiceRequest.Serial) 
 130:                                            idList.Contains((long)srt.ServiceRequest.Number * 100 + srt.ServiceRequest.Serial)
 131:                                            select srt).Include(x => x.ServiceRequest).ToList();
 132:              }
 133:   
 134:              return serviceRequestTypeList;
 135:          }
 136:   
 137:          ////////////////////////////////////////////////////////////////////////////
 138:   
 139:          /// <summary>
 140:          /// Return a list of service request types for service requests that have numbers (including changed-to numbers) within the passed number list
 141:          /// </summary>
 142:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> RelatedToServiceRequestNumberList(List<int> numberList)
 143:          {
 144:              List<string> serviceList;
 145:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 146:   
 147:              serviceList = (from n in numberList select n.ToString()).ToList();
 148:   
 149:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 150:              {
 151:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes
 152:                                            where numberList.Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.Contains(srt.Value))
 153:                                            select srt).Include(x => x.ServiceRequest).ToList();
 154:              }
 155:   
 156:              return serviceRequestTypeList;
 157:          }
 158:   
 159:          ////////////////////////////////////////////////////////////////////////////    
 160:   
 161:          /// <summary>
 162:          ///
 163:          /// </summary>
 164:          public static string OracleSqlCommandForGivenDateTime(DateTime dateTime)
 165:          {
 166:              string sql;
 167:   
 168:              sql = @"select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID where REQ_DATE >= '" + dateTime.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + @"' and REQ_DATE < '" + dateTime.AddDays(1).ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + @"' and SRV_REQ_FIPER_TECH.SRV_REQ_ID is not null and SRV_REQ_FIPER_TECH.TECH_TYPE_ID is not null and SRV_REQ_FIPER_TECH.VAL is not null order by SRV_REQ_FIPER.SRV_REQ_ID asc";
 169:   
 170:              return sql;
 171:          }
 172:   
 173:          ////////////////////////////////////////////////////////////////////////////    
 174:   
 175:          /// <summary>
 176:          ///
 177:          /// </summary>
 178:          public static string OracleSqlCommandForServiceRequestIdRange(Tuple<int, int> startEndRange)
 179:          {
 180:              return OracleSqlCommandForServiceRequestIdRange(startEndRange.Item1, startEndRange.Item2);
 181:          }
 182:   
 183:          ////////////////////////////////////////////////////////////////////////////    
 184:   
 185:          /// <summary>
 186:          ///
 187:          /// </summary>
 188:          public static string OracleSqlCommandForServiceRequestIdRange(int start, int end)
 189:          {
 190:              string sql;
 191:   
 192:              sql = @"select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID where SRV_REQ_FIPER_TECH.SRV_REQ_ID >= " + start + " and SRV_REQ_FIPER_TECH.SRV_REQ_ID <= " + end + " and SRV_REQ_FIPER_TECH.SRV_REQ_ID is not null and SRV_REQ_FIPER_TECH.TECH_TYPE_ID is not null and SRV_REQ_FIPER_TECH.VAL is not null order by SRV_REQ_FIPER.SRV_REQ_ID asc";
 193:   
 194:              return sql;
 195:          }
 196:   
 197:          ////////////////////////////////////////////////////////////////////////////
 198:   
 199:          /// <summary>
 200:          ///
 201:          /// </summary>
 202:          public static void UpdateForServiceRequestIdRangeWithOutputDataTable(DataTable dataTable, Tuple<int, int> startEndRange, out bool isUpdated, out string result)
 203:          {
 204:              // below: the SQL statement should be within the dataTable.TableName variable
 205:              int serviceRequestId, serviceRequestTypeId, start, end, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
 206:              string sql, r;
 207:              ArrayList newServiceRequestTypeIdArryList;
 208:              Match match;
 209:              Ia.Ngn.Cl.Model.ServiceRequestType serviceRequestType, newServiceRequestType;
 210:              List<int> serviceRequestTypeWithNoServiceRequestIdList;
 211:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 212:   
 213:              isUpdated = false;
 214:              readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
 215:              result = r = "";
 216:              serviceRequestTypeWithNoServiceRequestIdList = new List<int>();
 217:   
 218:              if (dataTable != null)
 219:              {
 220:                  sql = dataTable.TableName;
 221:   
 222:                  // select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID where SRV_REQ_FIPER_TECH.SRV_REQ_ID >= 110000 and SRV_REQ_FIPER_TECH.SRV_REQ_ID <= 321203 and SRV_REQ_FIPER_TECH.SRV_REQ_ID is not null and SRV_REQ_FIPER_TECH.TECH_TYPE_ID is not null and SRV_REQ_FIPER_TECH.VAL is not null order by REQ_DATE asc, SRV_REQ_FIPER.SRV_REQ_ID asc
 223:                  match = Regex.Match(sql, @"SRV_REQ_FIPER_TECH\.SRV_REQ_ID >= (\d+) and SRV_REQ_FIPER_TECH\.SRV_REQ_ID <= (\d+) ", RegexOptions.Singleline);
 224:                  //                                       1                       2
 225:   
 226:                  if (match.Success)
 227:                  {
 228:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
 229:                      {
 230:                          readItemCount = dataTable.Rows.Count;
 231:   
 232:                          start = int.Parse(match.Groups[1].Value);
 233:                          end = int.Parse(match.Groups[2].Value);
 234:   
 235:                          serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.ServiceRequestType.ReadListThatHasServiceRequestIdsWithinIdRange(start, end);
 236:                          existingItemCount = serviceRequestTypeList.Count;
 237:   
 238:                          newServiceRequestTypeIdArryList = new ArrayList(dataTable.Rows.Count + 1);
 239:   
 240:                          foreach (DataRow dataRow in dataTable.Rows)
 241:                          {
 242:                              serviceRequestId = int.Parse(dataRow["SRV_REQ_ID"].ToString());
 243:                              serviceRequestTypeId = int.Parse(serviceRequestId.ToString() + dataRow["TECH_TYPE_ID"].ToString().PadLeft(2, '0'));
 244:   
 245:                              newServiceRequestType = new Ia.Ngn.Cl.Model.ServiceRequestType();
 246:   
 247:                              newServiceRequestType.Id = serviceRequestTypeId;
 248:   
 249:                              newServiceRequestType.ServiceRequest = (from sr in db.ServiceRequests where sr.Id == serviceRequestId select sr).SingleOrDefault();
 250:   
 251:                              // below: we will not add any type that does not have a service request
 252:                              if (newServiceRequestType.ServiceRequest != null)
 253:                              {
 254:                                  newServiceRequestType.TypeId = int.Parse(dataRow["TECH_TYPE_ID"].ToString());
 255:                                  newServiceRequestType.Value = dataRow["VAL"].ToString();
 256:   
 257:                                  FixCommonMistakesAndCheckValidityOfServiceRequestTypeRecords(ref newServiceRequestType);
 258:   
 259:                                  serviceRequestType = (from srt in serviceRequestTypeList where srt.Id == newServiceRequestType.Id select srt).SingleOrDefault();
 260:   
 261:                                  if (serviceRequestType == null)
 262:                                  {
 263:                                      newServiceRequestType.Created = newServiceRequestType.Updated = DateTime.UtcNow.AddHours(3);
 264:   
 265:                                      db.ServiceRequestTypes.Add(newServiceRequestType);
 266:   
 267:                                      insertedItemCount++;
 268:                                  }
 269:                                  else
 270:                                  {
 271:                                      // below: copy values from newServiceRequestType to serviceRequestType
 272:   
 273:                                      if (serviceRequestType.Update(newServiceRequestType))
 274:                                      {
 275:                                          db.ServiceRequestTypes.Attach(serviceRequestType);
 276:                                          db.Entry(serviceRequestType).State = System.Data.Entity.EntityState.Modified;
 277:   
 278:                                          updatedItemCount++;
 279:                                      }
 280:                                  }
 281:   
 282:                                  // below: this will enable the removal of SRT that don't have a valid SR
 283:                                  newServiceRequestTypeIdArryList.Add(serviceRequestTypeId);
 284:                              }
 285:                              else
 286:                              {
 287:                                  serviceRequestTypeWithNoServiceRequestIdList.Add(newServiceRequestType.Id);
 288:                              }
 289:                          }
 290:   
 291:                          /*
 292:                          if (serviceRequestTypeWithNoServiceRequestIdList.Count > 0)
 293:                          {
 294:                              r = "SRT with no SR: ";
 295:  
 296:                              foreach (int n in serviceRequestTypeWithNoServiceRequestIdList) r += n + ",";
 297:  
 298:                              r = r.Trim(',');
 299:                          }
 300:                          */
 301:   
 302:                          // below: this function will remove values that were not present in the reading
 303:                          if (serviceRequestTypeList.Count > 0)
 304:                          {
 305:                              foreach (Ia.Ngn.Cl.Model.ServiceRequestType srt in serviceRequestTypeList)
 306:                              {
 307:                                  if (!newServiceRequestTypeIdArryList.Contains(srt.Id))
 308:                                  {
 309:                                      serviceRequestType = (from srt2 in db.ServiceRequestTypes where srt2.Id == srt.Id select srt2).SingleOrDefault();
 310:   
 311:                                      db.ServiceRequestTypes.Remove(serviceRequestType);
 312:   
 313:                                      deletedItemCount++;
 314:                                  }
 315:                              }
 316:                          }
 317:   
 318:                          db.SaveChanges();
 319:   
 320:                          if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
 321:                          else isUpdated = false;
 322:   
 323:                          result = "(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ") " + r;
 324:                      }
 325:                  }
 326:                  else
 327:                  {
 328:                      result = "(?/?/?: SQL in TableName is unmatched) ";
 329:                  }
 330:              }
 331:              else
 332:              {
 333:                  result = "(dataTable == null/?/?) ";
 334:              }
 335:          }
 336:   
 337:          ////////////////////////////////////////////////////////////////////////////
 338:   
 339:          /// <summary>
 340:          ///
 341:          /// </summary>
 342:          public static void UpdateForADateTimeRangeWithOutputDataTable(DataTable dataTable, Tuple<int, int> dateTime, out string result)
 343:          {
 344:              // below: the SQL statement should be within the dataTable.TableName variable
 345:              int readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
 346:              int serviceRequestId, serviceRequestTypeId;
 347:              string sql, r;
 348:              ArrayList newServiceRequestTypeIdArryList;
 349:              DateTime startDateTime, endDateTime;
 350:              Match match;
 351:              Ia.Ngn.Cl.Model.ServiceRequestType serviceRequestType, newServiceRequestType;
 352:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 353:   
 354:              readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
 355:              result = r = "";
 356:   
 357:              startDateTime = endDateTime = DateTime.MinValue;
 358:   
 359:              if (dataTable != null)
 360:              {
 361:                  sql = dataTable.TableName;
 362:   
 363:                  // select * from SRV_REQ_FIPER LEFT OUTER JOIN SRV_REQ_FIPER_TECH ON SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID where REQ_DATE >= '06/01/2007' and REQ_DATE < '07/01/2007'  order by REQ_DATE asc, SRV_REQ_FIPER.SRV_REQ_ID asc
 364:   
 365:                  match = Regex.Match(sql, @".+'(\d{2})\/(\d{2})\/(\d{4})'.+'(\d{2})\/(\d{2})\/(\d{4})'.+", RegexOptions.Singleline);
 366:                  //                             1        2        3        4          5        6
 367:   
 368:                  if (match.Success)
 369:                  {
 370:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
 371:                      {
 372:                          readItemCount = dataTable.Rows.Count;
 373:   
 374:                          //if (dataTable.Rows.Count > 0)
 375:                          //{
 376:                          startDateTime = DateTime.Parse(match.Groups[3].Value + "-" + match.Groups[2].Value + "-" + match.Groups[1].Value);
 377:                          endDateTime = DateTime.Parse(match.Groups[6].Value + "-" + match.Groups[5].Value + "-" + match.Groups[4].Value);
 378:   
 379:                          serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.ServiceRequestType.ReadListThatHaveServiceRequestsWithinGivenDateRange(startDateTime, endDateTime);
 380:                          existingItemCount = serviceRequestTypeList.Count;
 381:   
 382:                          newServiceRequestTypeIdArryList = new ArrayList(dataTable.Rows.Count + 1);
 383:   
 384:                          foreach (DataRow dataRow in dataTable.Rows)
 385:                          {
 386:                              serviceRequestId = int.Parse(dataRow["SRV_REQ_ID"].ToString());
 387:                              serviceRequestTypeId = int.Parse(serviceRequestId.ToString() + dataRow["TECH_TYPE_ID"].ToString().PadLeft(2, '0'));
 388:   
 389:                              newServiceRequestType = new Ia.Ngn.Cl.Model.ServiceRequestType();
 390:   
 391:                              newServiceRequestType.Id = serviceRequestTypeId;
 392:   
 393:                              newServiceRequestType.ServiceRequest = (from sr in db.ServiceRequests where sr.Id == serviceRequestId select sr).SingleOrDefault();
 394:   
 395:                              // below: we will not add any type that does not have a service request
 396:                              if (newServiceRequestType.ServiceRequest != null)
 397:                              {
 398:                                  newServiceRequestType.TypeId = int.Parse(dataRow["TECH_TYPE_ID"].ToString());
 399:                                  newServiceRequestType.Value = dataRow["VAL"].ToString();
 400:   
 401:                                  FixCommonMistakesAndCheckValidityOfServiceRequestTypeRecords(ref newServiceRequestType);
 402:   
 403:                                  serviceRequestType = (from srt in serviceRequestTypeList where srt.Id == newServiceRequestType.Id select srt).SingleOrDefault();
 404:   
 405:                                  if (serviceRequestType == null)
 406:                                  {
 407:                                      newServiceRequestType.Created = newServiceRequestType.Updated = DateTime.UtcNow.AddHours(3);
 408:   
 409:                                      db.ServiceRequestTypes.Add(newServiceRequestType);
 410:   
 411:                                      insertedItemCount++;
 412:                                  }
 413:                                  else
 414:                                  {
 415:                                      // below: copy values from newServiceRequestType to serviceRequestType
 416:   
 417:                                      if (serviceRequestType.Update(newServiceRequestType))
 418:                                      {
 419:                                          db.ServiceRequestTypes.Attach(serviceRequestType);
 420:                                          db.Entry(serviceRequestType).State = System.Data.Entity.EntityState.Modified;
 421:   
 422:                                          updatedItemCount++;
 423:                                      }
 424:                                  }
 425:   
 426:                                  // below: this will enable the removal of SRT that don't have a valid SR
 427:                                  newServiceRequestTypeIdArryList.Add(serviceRequestTypeId);
 428:                              }
 429:                              else
 430:                              {
 431:                                  r += "newServiceRequestType.Id: " + newServiceRequestType.Id + " newServiceRequestType.ServiceRequest == null, ";
 432:                              }
 433:                          }
 434:   
 435:                          // below: this function will remove values that were not present in the reading
 436:                          if (serviceRequestTypeList.Count > 0)
 437:                          {
 438:                              foreach (Ia.Ngn.Cl.Model.ServiceRequestType srt in serviceRequestTypeList)
 439:                              {
 440:                                  if (!newServiceRequestTypeIdArryList.Contains(srt.Id))
 441:                                  {
 442:                                      serviceRequestType = (from srt2 in db.ServiceRequestTypes where srt2.Id == srt.Id select srt2).SingleOrDefault();
 443:   
 444:                                      db.ServiceRequestTypes.Remove(srt);
 445:   
 446:                                      deletedItemCount++;
 447:                                  }
 448:                              }
 449:                          }
 450:   
 451:                          db.SaveChanges();
 452:   
 453:                          result = "(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ") " + r;
 454:                          //}
 455:                          //else
 456:                          //{
 457:                          //    result = "(" + readItemCount + "/?/?) ";
 458:                          //}
 459:                      }
 460:                  }
 461:                  else
 462:                  {
 463:                      result = "(?/?/?: SQL in TableName is unmatched) ";
 464:                  }
 465:              }
 466:              else
 467:              {
 468:                  result = "(dataTable == null/?/?) ";
 469:              }
 470:          }
 471:   
 472:          ////////////////////////////////////////////////////////////////////////////    
 473:   
 474:          /// <summary>
 475:          ///
 476:          /// </summary>
 477:          private static void FixCommonMistakesAndCheckValidityOfServiceRequestTypeRecords(ref Ia.Ngn.Cl.Model.ServiceRequestType serviceRequestType)
 478:          {
 479:              // below: procedure to fix service request records from the common mistakes
 480:   
 481:              bool b;
 482:              int number;
 483:   
 484:              // below: convert 7 digit numbers to 8 digits
 485:              // <type id="11" name="dn" arabicName="dn" oracleFieldName="الرقم الجديد"/>
 486:              if (serviceRequestType.TypeId == 11)
 487:              {
 488:                  b = int.TryParse(serviceRequestType.Value.Trim(), out number);
 489:   
 490:                  if (b)
 491:                  {
 492:                      number = Ia.Ngn.Cl.Model.Business.Default.ChangeOldSevenDigitNumbersToEightDigitFormat(number);
 493:   
 494:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(number))
 495:                      {
 496:                          serviceRequestType.Value = number.ToString();
 497:                      }
 498:                      else serviceRequestType.Value = null;
 499:                  }
 500:                  else serviceRequestType.Value = null;
 501:              }
 502:          }
 503:   
 504:          ////////////////////////////////////////////////////////////////////////////
 505:   
 506:          /// <summary>
 507:          ///
 508:          /// </summary>
 509:          public static Dictionary<int, string> NumberToServiceRequestTypeStringDictionary(List<int> domainList)
 510:          {
 511:              int number;
 512:              Dictionary<int, string> dictionary;
 513:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 514:   
 515:              dictionary = new Dictionary<int, string>();
 516:   
 517:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 518:              {
 519:                  if (domainList != null)
 520:                  {
 521:                      serviceRequestTypeList = (from srt in db.ServiceRequestTypes where domainList.Contains(srt.ServiceRequest.Number / 10000) || domainList.Contains(srt.ServiceRequest.Number / 1000) select srt).ToList();
 522:   
 523:                      if (serviceRequestTypeList != null)
 524:                      {
 525:                          dictionary = new Dictionary<int, string>(serviceRequestTypeList.Count);
 526:   
 527:                          foreach (Ia.Ngn.Cl.Model.ServiceRequestType srt in serviceRequestTypeList.OrderBy(u => u.Id))
 528:                          {
 529:                              number = int.Parse(srt.ServiceRequest.Number.ToString());
 530:   
 531:                              if (dictionary.ContainsKey(number)) dictionary[number] = dictionary[number] + "," + srt.Value;
 532:                              else dictionary[number] = srt.Value;
 533:                          }
 534:                      }
 535:                  }
 536:              }
 537:   
 538:              return dictionary;
 539:          }
 540:   
 541:          ////////////////////////////////////////////////////////////////////////////    
 542:          ////////////////////////////////////////////////////////////////////////////    
 543:      }
 544:   
 545:      ////////////////////////////////////////////////////////////////////////////
 546:      ////////////////////////////////////////////////////////////////////////////
 547:  }