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

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 Ia.Ngn.Cl.Model.Business; // Needed for ServerExtension
   2:  using System;
   3:  using System.Collections;
   4:  using System.Collections.Generic;
   5:  using System.Data;
   6:  using System.Data.Entity;
   7:  using System.Linq;
   8:  using System.Text.RegularExpressions;
   9:   
  10:  namespace Ia.Ngn.Cl.Model.Data
  11:  {
  12:      ////////////////////////////////////////////////////////////////////////////
  13:   
  14:      /// <summary publish="true">
  15:      /// Service Request Type support class for Next Generation Network (NGN) data model.
  16:      /// </summary>
  17:      /// 
  18:      /// <remarks> 
  19:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  20:      ///
  21:      /// 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
  22:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  23:      ///
  24:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  25:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  26:      /// 
  27:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  28:      /// 
  29:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  30:      /// </remarks> 
  31:      public partial class ServiceRequestType
  32:      {
  33:          /// <summary/>
  34:          public ServiceRequestType() { }
  35:   
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          ///
  40:          /// </summary>
  41:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> List()
  42:          {
  43:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
  44:   
  45:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  46:              {
  47:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes select srt).ToList();
  48:              }
  49:   
  50:              return serviceRequestTypeList;
  51:          }
  52:   
  53:          ////////////////////////////////////////////////////////////////////////////
  54:   
  55:          /// <summary>
  56:          /// Return a list of service request types for service requests that has the same number as the one passed
  57:          /// </summary>
  58:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> List(int number)
  59:          {
  60:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
  61:   
  62:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  63:              {
  64:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes where srt.ServiceRequest.Number == number select srt).Include(x => x.ServiceRequest).ToList();
  65:              }
  66:   
  67:              return serviceRequestTypeList;
  68:          }
  69:   
  70:          ////////////////////////////////////////////////////////////////////////////
  71:   
  72:          /// <summary>
  73:          /// Return a list of service request types for service requests that has the same service as the one passed
  74:          /// </summary>
  75:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> List(string service)
  76:          {
  77:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
  78:   
  79:              if (!string.IsNullOrEmpty(service))
  80:              {
  81:                  if (int.TryParse(service, out int number))
  82:                  {
  83:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
  84:                      {
  85:                          serviceRequestTypeList = (from srt in db.ServiceRequestTypes where srt.ServiceRequest.Number == number select srt).Include(x => x.ServiceRequest).ToList();
  86:                      }
  87:                  }
  88:                  else
  89:                  {
  90:                      throw new ArgumentException(@"List(): service is not a number, service: " + service);
  91:                  }
  92:              }
  93:              else serviceRequestTypeList = new List<Ia.Ngn.Cl.Model.ServiceRequestType>();
  94:   
  95:              return serviceRequestTypeList;
  96:          }
  97:   
  98:          ////////////////////////////////////////////////////////////////////////////
  99:   
 100:          /// <summary>
 101:          ///
 102:          /// </summary>
 103:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> ReadListThatHasServiceRequestIdsWithinIdRange(int start, int end)
 104:          {
 105:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 106:   
 107:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 108:              {
 109:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes
 110:                                            join sr in db.ServiceRequests
 111:                                            on srt.ServiceRequest.Id equals sr.Id
 112:                                            where sr.Id >= start && sr.Id <= end
 113:                                            select srt).ToList();
 114:              }
 115:   
 116:              return serviceRequestTypeList;
 117:          }
 118:   
 119:          ////////////////////////////////////////////////////////////////////////////
 120:   
 121:          /// <summary>
 122:          ///
 123:          /// </summary>
 124:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> ReadListThatHaveServiceRequestsWithinGivenDateRange(DateTime startDateTime, DateTime endDateTime)
 125:          {
 126:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 127:   
 128:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 129:              {
 130:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes
 131:                                            join sr in db.ServiceRequests
 132:                                            on srt.ServiceRequest.Id equals sr.Id
 133:                                            where sr.RequestDateTime >= startDateTime && sr.RequestDateTime < endDateTime
 134:                                            select srt).ToList();
 135:              }
 136:   
 137:              return serviceRequestTypeList;
 138:          }
 139:   
 140:          ////////////////////////////////////////////////////////////////////////////
 141:   
 142:          /// <summary>
 143:          /// Return a list of service request types for service requests that have numbers within the passed number-serial list
 144:          /// </summary>
 145:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> List(List<Ia.Ngn.Cl.Model.Business.ServiceRequest.NumberSerial> numberSerialList)
 146:          {
 147:              List<long> idList;
 148:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 149:   
 150:              idList = numberSerialList.IdList();
 151:   
 152:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 153:              {
 154:                  serviceRequestTypeList = (from srt in db.ServiceRequestTypes
 155:                                            where
 156:                                            //numberSerialList.Contains(q.ServiceRequest.Number, q.ServiceRequest.Serial) 
 157:                                            idList.Contains((long)srt.ServiceRequest.Number * 100 + srt.ServiceRequest.Serial)
 158:                                            select srt).Include(x => x.ServiceRequest).ToList();
 159:              }
 160:   
 161:              return serviceRequestTypeList;
 162:          }
 163:   
 164:          ////////////////////////////////////////////////////////////////////////////
 165:   
 166:          /// <summary>
 167:          /// Return a list of service request types for service requests that have numbers (including changed-to numbers) within the passed number list
 168:          /// </summary>
 169:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> List(List<int> numberList)
 170:          {
 171:              List<string> serviceList;
 172:              List<Ia.Ngn.Cl.Model.ServiceRequestType> list;
 173:   
 174:              serviceList = (from n in numberList select n.ToString()).ToList();
 175:   
 176:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 177:              {
 178:                  if (serviceList.Count <= 32)
 179:                  {
 180:                      list = (from srt in db.ServiceRequestTypes
 181:                              where numberList.Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.Contains(srt.Value))
 182:                              select srt).Include(x => x.ServiceRequest).ToList();
 183:                  }
 184:                  else if (serviceList.Count <= 64)
 185:                  {
 186:                      try
 187:                      {
 188:                          list = (from srt in db.ServiceRequestTypes
 189:                                  where numberList.GetRange(0, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(0, 32).Contains(srt.Value))
 190:                                  select srt).Include(x => x.ServiceRequest).ToList();
 191:   
 192:                          list = list.Union(
 193:                              (from srt in db.ServiceRequestTypes
 194:                               where numberList.GetRange(32, numberList.Count - 32 - 1).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(32, serviceList.Count - 32 - 1).Contains(srt.Value))
 195:                               select srt).Include(x => x.ServiceRequest)//.ToList()
 196:                                  ).ToList();
 197:                      }
 198:                      catch (Exception ex)
 199:                      {
 200:                          list = new List<Model.ServiceRequestType>();
 201:   
 202:                          string r = "Error: Exception: " + ex.ToString();
 203:                      }
 204:   
 205:                  }
 206:                  else if (serviceList.Count <= 96)
 207:                  {
 208:                      list = (from srt in db.ServiceRequestTypes
 209:                              where numberList.GetRange(0, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(0, 32).Contains(srt.Value))
 210:                              select srt).Include(x => x.ServiceRequest).ToList();
 211:   
 212:                      list = list.Union(
 213:                          (from srt in db.ServiceRequestTypes
 214:                           where numberList.GetRange(32, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(32, 32).Contains(srt.Value))
 215:                           select srt).Include(x => x.ServiceRequest)//.ToList()
 216:                              ).ToList();
 217:   
 218:                      list = list.Union(
 219:                          (from srt in db.ServiceRequestTypes
 220:                           where numberList.GetRange(64, numberList.Count - 64 - 1).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(64, serviceList.Count - 64 - 1).Contains(srt.Value))
 221:                           select srt).Include(x => x.ServiceRequest)//.ToList()
 222:                              ).ToList();
 223:                  }
 224:                  else if (serviceList.Count <= 128)
 225:                  {
 226:                      list = (from srt in db.ServiceRequestTypes
 227:                              where numberList.GetRange(0, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(0, 32).Contains(srt.Value))
 228:                              select srt).Include(x => x.ServiceRequest).ToList();
 229:   
 230:                      list = list.Union(
 231:                          (from srt in db.ServiceRequestTypes
 232:                           where numberList.GetRange(32, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(32, 32).Contains(srt.Value))
 233:                           select srt).Include(x => x.ServiceRequest)//.ToList()
 234:                              ).ToList();
 235:   
 236:                      list = list.Union(
 237:                          (from srt in db.ServiceRequestTypes
 238:                           where numberList.GetRange(64, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(64, 32).Contains(srt.Value))
 239:                           select srt).Include(x => x.ServiceRequest)//.ToList()
 240:                              ).ToList();
 241:   
 242:                      list = list.Union(
 243:                          (from srt in db.ServiceRequestTypes
 244:                           where numberList.GetRange(96, numberList.Count - 96 - 1).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(96, serviceList.Count - 96 - 1).Contains(srt.Value))
 245:                           select srt).Include(x => x.ServiceRequest)//.ToList()
 246:                              ).ToList();
 247:                  }
 248:                  else //if (serviceList.Count <= 160)
 249:                  {
 250:                      list = (from srt in db.ServiceRequestTypes
 251:                              where numberList.GetRange(0, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(0, 32).Contains(srt.Value))
 252:                              select srt).Include(x => x.ServiceRequest).ToList();
 253:   
 254:                      list = list.Union(
 255:                          (from srt in db.ServiceRequestTypes
 256:                           where numberList.GetRange(32, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(32, 32).Contains(srt.Value))
 257:                           select srt).Include(x => x.ServiceRequest)//.ToList()
 258:                              ).ToList();
 259:   
 260:                      list = list.Union(
 261:                          (from srt in db.ServiceRequestTypes
 262:                           where numberList.GetRange(64, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(64, 32).Contains(srt.Value))
 263:                           select srt).Include(x => x.ServiceRequest)//.ToList()
 264:                              ).ToList();
 265:   
 266:                      list = list.Union(
 267:                          (from srt in db.ServiceRequestTypes
 268:                           where numberList.GetRange(96, 32).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(96, 32).Contains(srt.Value))
 269:                           select srt).Include(x => x.ServiceRequest)//.ToList()
 270:                              ).ToList();
 271:   
 272:                      list = list.Union(
 273:                          (from srt in db.ServiceRequestTypes
 274:                           where numberList.GetRange(128, numberList.Count - 128 - 1).Contains(srt.ServiceRequest.Number) || (srt.TypeId == 11 && serviceList.GetRange(128, serviceList.Count - 128 - 1).Contains(srt.Value))
 275:                           select srt).Include(x => x.ServiceRequest)//.ToList()
 276:                              ).ToList();
 277:                  }
 278:              }
 279:   
 280:              /*
 281:               * For the corrections of //.ToList() above see https://stackoverflow.com/questions/18086005/linq-to-entities-does-not-recognize-the-method-generic-listint-to-generic-ienu
 282:               */
 283:   
 284:              return list.Distinct().ToList();
 285:          }
 286:   
 287:          /*
 288:           * For referecne only and copy to above. Remove later
 289:          ////////////////////////////////////////////////////////////////////////////
 290:  
 291:          /// <summary>
 292:          /// 
 293:          /// </summary>
 294:          public static List<Ia.Ngn.Cl.Model.ServiceRequestType> ServiceRequestTypeList(List<int> serviceRequestTypeIdList)
 295:          {
 296:              List<Ia.Ngn.Cl.Model.ServiceRequestType> list;
 297:  
 298:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 299:              {
 300:                  if (serviceRequestTypeIdList.Count <= 32)
 301:                  {
 302:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList on srt.Id equals srtid select srt).ToList();
 303:                  }
 304:                  else if (serviceRequestTypeIdList.Count <= 64)
 305:                  {
 306:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 307:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, serviceRequestTypeIdList.Count - 32 - 1) on srt.Id equals srtid select srt).ToList();
 308:                  }
 309:                  else if (serviceRequestTypeIdList.Count <= 96)
 310:                  {
 311:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 312:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 313:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, serviceRequestTypeIdList.Count - 64 - 1) on srt.Id equals srtid select srt).ToList();
 314:                  }
 315:                  else if (serviceRequestTypeIdList.Count <= 128)
 316:                  {
 317:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 318:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 319:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 320:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, serviceRequestTypeIdList.Count - 96 - 1) on srt.Id equals srtid select srt).ToList();
 321:                  }
 322:                  else if (serviceRequestTypeIdList.Count <= 160)
 323:                  {
 324:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 325:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 326:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 327:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 328:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, serviceRequestTypeIdList.Count - 128 - 1) on srt.Id equals srtid select srt).ToList();
 329:                  }
 330:                  else if (serviceRequestTypeIdList.Count <= 192)
 331:                  {
 332:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 333:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 334:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 335:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 336:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 337:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, serviceRequestTypeIdList.Count - 160 - 1) on srt.Id equals srtid select srt).ToList();
 338:                  }
 339:                  else if (serviceRequestTypeIdList.Count <= 224)
 340:                  {
 341:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 342:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 343:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 344:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 345:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 346:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 347:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, serviceRequestTypeIdList.Count - 192 - 1) on srt.Id equals srtid select srt).ToList();
 348:                  }
 349:                  else if (serviceRequestTypeIdList.Count <= 256)
 350:                  {
 351:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 352:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 353:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 354:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 355:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 356:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 357:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 358:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, serviceRequestTypeIdList.Count - 224 - 1) on srt.Id equals srtid select srt).ToList();
 359:                  }
 360:                  else if (serviceRequestTypeIdList.Count <= 288)
 361:                  {
 362:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 363:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 364:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 365:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 366:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 367:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 368:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 369:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 370:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, serviceRequestTypeIdList.Count - 256 - 1) on srt.Id equals srtid select srt).ToList();
 371:                  }
 372:                  else if (serviceRequestTypeIdList.Count <= 320)
 373:                  {
 374:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 375:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 376:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 377:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 378:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 379:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 380:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 381:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 382:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 383:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, serviceRequestTypeIdList.Count - 288 - 1) on srt.Id equals srtid select srt).ToList();
 384:                  }
 385:                  else if (serviceRequestTypeIdList.Count <= 352)
 386:                  {
 387:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 388:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 389:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 390:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 391:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 392:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 393:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 394:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 395:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 396:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 397:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, serviceRequestTypeIdList.Count - 320 - 1) on srt.Id equals srtid select srt).ToList();
 398:                  }
 399:                  else if (serviceRequestTypeIdList.Count <= 384)
 400:                  {
 401:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 402:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 403:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 404:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 405:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 406:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 407:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 408:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 409:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 410:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 411:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 412:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, serviceRequestTypeIdList.Count - 352 - 1) on srt.Id equals srtid select srt).ToList();
 413:                  }
 414:                  else if (serviceRequestTypeIdList.Count <= 416)
 415:                  {
 416:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 417:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 418:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 419:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 420:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 421:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 422:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 423:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 424:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 425:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 426:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 427:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 428:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, serviceRequestTypeIdList.Count - 384 - 1) on srt.Id equals srtid select srt).ToList();
 429:                  }
 430:                  else if (serviceRequestTypeIdList.Count <= 448)
 431:                  {
 432:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 433:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 434:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 435:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 436:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 437:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 438:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 439:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 440:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 441:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 442:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 443:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 444:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 445:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, serviceRequestTypeIdList.Count - 416 - 1) on srt.Id equals srtid select srt).ToList();
 446:                  }
 447:                  else if (serviceRequestTypeIdList.Count <= 480)
 448:                  {
 449:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 450:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 451:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 452:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 453:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 454:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 455:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 456:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 457:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 458:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 459:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 460:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 461:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 462:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 463:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, serviceRequestTypeIdList.Count - 448 - 1) on srt.Id equals srtid select srt).ToList();
 464:                  }
 465:                  else if (serviceRequestTypeIdList.Count <= 512)
 466:                  {
 467:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 468:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 469:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 470:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 471:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 472:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 473:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 474:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 475:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 476:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 477:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 478:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 479:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 480:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 481:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 482:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, serviceRequestTypeIdList.Count - 480 - 1) on srt.Id equals srtid select srt).ToList();
 483:                  }
 484:                  else if (serviceRequestTypeIdList.Count <= 544)
 485:                  {
 486:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 487:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 488:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 489:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 490:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 491:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 492:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 493:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 494:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 495:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 496:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 497:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 498:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 499:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 500:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 501:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 502:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, serviceRequestTypeIdList.Count - 512 - 1) on srt.Id equals srtid select srt).ToList();
 503:                  }
 504:                  else if (serviceRequestTypeIdList.Count <= 576)
 505:                  {
 506:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 507:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 508:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 509:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 510:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 511:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 512:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 513:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 514:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 515:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 516:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 517:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 518:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 519:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 520:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 521:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 522:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, 32) on srt.Id equals srtid select srt).ToList();
 523:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(544, serviceRequestTypeIdList.Count - 544 - 1) on srt.Id equals srtid select srt).ToList();
 524:                  }
 525:                  else if (serviceRequestTypeIdList.Count <= 608)
 526:                  {
 527:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 528:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 529:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 530:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 531:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 532:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 533:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 534:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 535:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 536:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 537:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 538:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 539:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 540:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 541:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 542:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 543:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, 32) on srt.Id equals srtid select srt).ToList();
 544:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(544, 32) on srt.Id equals srtid select srt).ToList();
 545:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(576, serviceRequestTypeIdList.Count - 576 - 1) on srt.Id equals srtid select srt).ToList();
 546:                  }
 547:                  else if (serviceRequestTypeIdList.Count <= 640)
 548:                  {
 549:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 550:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 551:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 552:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 553:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 554:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 555:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 556:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 557:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 558:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 559:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 560:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 561:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 562:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 563:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 564:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 565:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, 32) on srt.Id equals srtid select srt).ToList();
 566:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(544, 32) on srt.Id equals srtid select srt).ToList();
 567:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(576, 32) on srt.Id equals srtid select srt).ToList();
 568:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(608, serviceRequestTypeIdList.Count - 608 - 1) on srt.Id equals srtid select srt).ToList();
 569:                  }
 570:                  else if (serviceRequestTypeIdList.Count <= 672)
 571:                  {
 572:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 573:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 574:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 575:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 576:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 577:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 578:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 579:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 580:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 581:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 582:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 583:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 584:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 585:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 586:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 587:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 588:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, 32) on srt.Id equals srtid select srt).ToList();
 589:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(544, 32) on srt.Id equals srtid select srt).ToList();
 590:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(576, 32) on srt.Id equals srtid select srt).ToList();
 591:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(608, 32) on srt.Id equals srtid select srt).ToList();
 592:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(640, serviceRequestTypeIdList.Count - 640 - 1) on srt.Id equals srtid select srt).ToList();
 593:                  }
 594:                  else if (serviceRequestTypeIdList.Count <= 704)
 595:                  {
 596:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 597:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 598:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 599:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 600:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 601:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 602:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 603:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 604:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 605:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 606:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 607:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 608:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 609:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 610:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 611:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 612:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, 32) on srt.Id equals srtid select srt).ToList();
 613:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(544, 32) on srt.Id equals srtid select srt).ToList();
 614:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(576, 32) on srt.Id equals srtid select srt).ToList();
 615:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(608, 32) on srt.Id equals srtid select srt).ToList();
 616:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(640, 32) on srt.Id equals srtid select srt).ToList();
 617:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(672, serviceRequestTypeIdList.Count - 672 - 1) on srt.Id equals srtid select srt).ToList();
 618:                  }
 619:                  else if (serviceRequestTypeIdList.Count <= 736)
 620:                  {
 621:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 622:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 623:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 624:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 625:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 626:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 627:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 628:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 629:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 630:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 631:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 632:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 633:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 634:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 635:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 636:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 637:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, 32) on srt.Id equals srtid select srt).ToList();
 638:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(544, 32) on srt.Id equals srtid select srt).ToList();
 639:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(576, 32) on srt.Id equals srtid select srt).ToList();
 640:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(608, 32) on srt.Id equals srtid select srt).ToList();
 641:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(640, 32) on srt.Id equals srtid select srt).ToList();
 642:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(672, 32) on srt.Id equals srtid select srt).ToList();
 643:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(704, serviceRequestTypeIdList.Count - 704 - 1) on srt.Id equals srtid select srt).ToList();
 644:                  }
 645:                  else if (serviceRequestTypeIdList.Count <= 768)
 646:                  {
 647:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 648:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 649:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 650:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 651:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 652:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 653:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 654:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 655:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 656:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 657:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 658:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 659:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 660:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 661:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 662:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 663:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, 32) on srt.Id equals srtid select srt).ToList();
 664:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(544, 32) on srt.Id equals srtid select srt).ToList();
 665:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(576, 32) on srt.Id equals srtid select srt).ToList();
 666:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(608, 32) on srt.Id equals srtid select srt).ToList();
 667:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(640, 32) on srt.Id equals srtid select srt).ToList();
 668:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(672, 32) on srt.Id equals srtid select srt).ToList();
 669:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(704, 32) on srt.Id equals srtid select srt).ToList();
 670:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(736, serviceRequestTypeIdList.Count - 736 - 1) on srt.Id equals srtid select srt).ToList();
 671:                  }
 672:                  else if (serviceRequestTypeIdList.Count <= 800)
 673:                  {
 674:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 675:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 676:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 677:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 678:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 679:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 680:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 681:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 682:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 683:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 684:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 685:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 686:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 687:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 688:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 689:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 690:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, 32) on srt.Id equals srtid select srt).ToList();
 691:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(544, 32) on srt.Id equals srtid select srt).ToList();
 692:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(576, 32) on srt.Id equals srtid select srt).ToList();
 693:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(608, 32) on srt.Id equals srtid select srt).ToList();
 694:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(640, 32) on srt.Id equals srtid select srt).ToList();
 695:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(672, 32) on srt.Id equals srtid select srt).ToList();
 696:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(704, 32) on srt.Id equals srtid select srt).ToList();
 697:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(736, 32) on srt.Id equals srtid select srt).ToList();
 698:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(768, serviceRequestTypeIdList.Count - 768 - 1) on srt.Id equals srtid select srt).ToList();
 699:                  }
 700:                  else //if (serviceRequestTypeIdList.Count <= 832)
 701:                  {
 702:                      list = (from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(0, 32) on srt.Id equals srtid select srt).ToList();
 703:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(32, 32) on srt.Id equals srtid select srt).ToList();
 704:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(64, 32) on srt.Id equals srtid select srt).ToList();
 705:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(96, 32) on srt.Id equals srtid select srt).ToList();
 706:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(128, 32) on srt.Id equals srtid select srt).ToList();
 707:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(160, 32) on srt.Id equals srtid select srt).ToList();
 708:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(192, 32) on srt.Id equals srtid select srt).ToList();
 709:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(224, 32) on srt.Id equals srtid select srt).ToList();
 710:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(256, 32) on srt.Id equals srtid select srt).ToList();
 711:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(288, 32) on srt.Id equals srtid select srt).ToList();
 712:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(320, 32) on srt.Id equals srtid select srt).ToList();
 713:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(352, 32) on srt.Id equals srtid select srt).ToList();
 714:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(384, 32) on srt.Id equals srtid select srt).ToList();
 715:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(416, 32) on srt.Id equals srtid select srt).ToList();
 716:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(448, 32) on srt.Id equals srtid select srt).ToList();
 717:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(480, 32) on srt.Id equals srtid select srt).ToList();
 718:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(512, 32) on srt.Id equals srtid select srt).ToList();
 719:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(544, 32) on srt.Id equals srtid select srt).ToList();
 720:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(576, 32) on srt.Id equals srtid select srt).ToList();
 721:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(608, 32) on srt.Id equals srtid select srt).ToList();
 722:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(640, 32) on srt.Id equals srtid select srt).ToList();
 723:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(672, 32) on srt.Id equals srtid select srt).ToList();
 724:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(704, 32) on srt.Id equals srtid select srt).ToList();
 725:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(736, 32) on srt.Id equals srtid select srt).ToList();
 726:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(768, 32) on srt.Id equals srtid select srt).ToList();
 727:                      list = list.Union(from srt in db.ServiceRequestTypes join srtid in serviceRequestTypeIdList.GetRange(800, serviceRequestTypeIdList.Count - 800 - 1) on srt.Id equals srtid select srt).ToList();
 728:                  }
 729:              }
 730:  
 731:              return list.Distinct().ToList();
 732:          }
 733:          */
 734:   
 735:          ////////////////////////////////////////////////////////////////////////////
 736:   
 737:          /// <summary>
 738:          ///
 739:          /// </summary>
 740:          public static string UpdateForServiceRequestIdRangeWithOutputDataTable(DataTable dataTable, out List<string> insertedOrUpdatedOrDeletedServiceList)
 741:          {
 742:              // below: the SQL statement should be within the dataTable.TableName variable
 743:              int serviceRequestId, serviceRequestTypeId, start, end, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
 744:              string sql, r, result;
 745:              ArrayList newServiceRequestTypeIdArryList;
 746:              Match match;
 747:              Ia.Ngn.Cl.Model.ServiceRequestType serviceRequestType, newServiceRequestType;
 748:              List<int> serviceRequestTypeWithNoServiceRequestIdList;
 749:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 750:   
 751:              readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
 752:              result = r = string.Empty;
 753:              serviceRequestTypeWithNoServiceRequestIdList = new List<int>();
 754:   
 755:              insertedOrUpdatedOrDeletedServiceList = new List<string>();
 756:   
 757:              if (dataTable != null)
 758:              {
 759:                  sql = dataTable.TableName;
 760:   
 761:                  // 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
 762:                  match = Regex.Match(sql, @"SRV_REQ_FIPER_TECH\.SRV_REQ_ID >= (\d+) and SRV_REQ_FIPER_TECH\.SRV_REQ_ID <= (\d+) ", RegexOptions.Singleline);
 763:   
 764:                  if (match.Success)
 765:                  {
 766:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
 767:                      {
 768:                          readItemCount = dataTable.Rows.Count;
 769:   
 770:                          start = int.Parse(match.Groups[1].Value);
 771:                          end = int.Parse(match.Groups[2].Value);
 772:   
 773:                          serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.ServiceRequestType.ReadListThatHasServiceRequestIdsWithinIdRange(start, end);
 774:                          existingItemCount = serviceRequestTypeList.Count;
 775:   
 776:                          newServiceRequestTypeIdArryList = new ArrayList(dataTable.Rows.Count + 1);
 777:   
 778:                          foreach (DataRow dataRow in dataTable.Rows)
 779:                          {
 780:                              serviceRequestId = int.Parse(dataRow["SRV_REQ_ID"].ToString());
 781:   
 782:                              if (Ia.Ngn.Cl.Model.Business.ServiceRequest.ServiceRequestIdIsAllowedForProcessing(serviceRequestId))
 783:                              {
 784:                                  serviceRequestTypeId = int.Parse(serviceRequestId.ToString() + dataRow["TECH_TYPE_ID"].ToString().PadLeft(2, '0'));
 785:   
 786:                                  newServiceRequestType = new Ia.Ngn.Cl.Model.ServiceRequestType();
 787:   
 788:                                  newServiceRequestType.Id = serviceRequestTypeId;
 789:   
 790:                                  newServiceRequestType.ServiceRequest = (from sr in db.ServiceRequests where sr.Id == serviceRequestId select sr).SingleOrDefault();
 791:   
 792:                                  // below: we will not add any type that does not have a service request
 793:                                  if (newServiceRequestType.ServiceRequest != null)
 794:                                  {
 795:                                      newServiceRequestType.TypeId = int.Parse(dataRow["TECH_TYPE_ID"].ToString());
 796:                                      newServiceRequestType.Value = dataRow["VAL"].ToString();
 797:   
 798:                                      FixCommonMistakesAndCheckValidityOfServiceRequestTypeRecords(ref newServiceRequestType);
 799:   
 800:                                      serviceRequestType = (from srt in serviceRequestTypeList where srt.Id == newServiceRequestType.Id select srt).SingleOrDefault();
 801:   
 802:                                      if (serviceRequestType == null)
 803:                                      {
 804:                                          newServiceRequestType.Created = newServiceRequestType.Updated = DateTime.UtcNow.AddHours(3);
 805:   
 806:                                          db.ServiceRequestTypes.Add(newServiceRequestType);
 807:   
 808:                                          insertedOrUpdatedOrDeletedServiceList.Add(newServiceRequestType.ServiceRequest.Number.ToString());
 809:                                          insertedItemCount++;
 810:                                      }
 811:                                      else
 812:                                      {
 813:                                          // below: copy values from newServiceRequestType to serviceRequestType
 814:   
 815:                                          if (serviceRequestType.Update(newServiceRequestType))
 816:                                          {
 817:                                              db.ServiceRequestTypes.Attach(serviceRequestType);
 818:                                              db.Entry(serviceRequestType).State = System.Data.Entity.EntityState.Modified;
 819:   
 820:                                              insertedOrUpdatedOrDeletedServiceList.Add(serviceRequestType.ServiceRequest.Number.ToString());
 821:                                              updatedItemCount++;
 822:                                          }
 823:                                      }
 824:   
 825:                                      // below: this will enable the removal of SRT that don't have a valid SR
 826:                                      newServiceRequestTypeIdArryList.Add(serviceRequestTypeId);
 827:                                  }
 828:                                  else
 829:                                  {
 830:                                      serviceRequestTypeWithNoServiceRequestIdList.Add(newServiceRequestType.Id);
 831:                                  }
 832:                              }
 833:                              else
 834:                              {
 835:   
 836:                              }
 837:                          }
 838:   
 839:                          /*
 840:                          if (serviceRequestTypeWithNoServiceRequestIdList.Count > 0)
 841:                          {
 842:                              r = "SRT with no SR: ";
 843:  
 844:                              foreach (int n in serviceRequestTypeWithNoServiceRequestIdList) r += n + ",";
 845:  
 846:                              r = r.Trim(',');
 847:                          }
 848:                          */
 849:   
 850:                          // below: this function will remove values that were not present in the reading
 851:                          if (serviceRequestTypeList.Count > 0)
 852:                          {
 853:                              foreach (Ia.Ngn.Cl.Model.ServiceRequestType srt in serviceRequestTypeList)
 854:                              {
 855:                                  if (!newServiceRequestTypeIdArryList.Contains(srt.Id))
 856:                                  {
 857:                                      serviceRequestType = (from srt2 in db.ServiceRequestTypes where srt2.Id == srt.Id select srt2).SingleOrDefault();
 858:   
 859:                                      db.ServiceRequestTypes.Remove(serviceRequestType);
 860:   
 861:                                      insertedOrUpdatedOrDeletedServiceList.Add(serviceRequestType.ServiceRequest.Number.ToString());
 862:                                      deletedItemCount++;
 863:                                  }
 864:                              }
 865:                          }
 866:   
 867:                          db.SaveChanges();
 868:   
 869:                          //if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
 870:                          //else isUpdated = false;
 871:   
 872:                          result = "(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ") " + r;
 873:                      }
 874:                  }
 875:                  else
 876:                  {
 877:                      result = "(?/?/?: SQL in TableName is unmatched) ";
 878:                  }
 879:              }
 880:              else
 881:              {
 882:                  result = "(dataTable == null/?/?) ";
 883:              }
 884:   
 885:              return result;
 886:          }
 887:   
 888:          ////////////////////////////////////////////////////////////////////////////
 889:   
 890:          /// <summary>
 891:          ///
 892:          /// </summary>
 893:          public static void UpdateForServiceRequestTypeWithOutputDataTableService(DataTable dataTable, string service, out bool isUpdated, out string result)
 894:          {
 895:              int serviceRequestId, serviceRequestTypeId, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
 896:              string sql, sqlService, exception;
 897:              ArrayList newServiceRequestTypeIdArryList;
 898:              Match match;
 899:              Ia.Ngn.Cl.Model.ServiceRequestType serviceRequestType, newServiceRequestType;
 900:              List<int> serviceRequestTypeWithNoServiceRequestIdList;
 901:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
 902:   
 903:              isUpdated = false;
 904:              readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
 905:              result = exception = string.Empty;
 906:              serviceRequestTypeWithNoServiceRequestIdList = new List<int>();
 907:   
 908:              if (dataTable != null)
 909:              {
 910:                  // below: the SQL statement should be within the dataTable.TableName variable
 911:                  sql = dataTable.TableName;
 912:   
 913:                  /*
 914:  select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER 
 915:  left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID 
 916:  where SRV_REQ_FIPER.SRV_NO = " + service + @" 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 
 917:  order by SRV_REQ_FIPER.SRV_REQ_ID asc
 918:  */
 919:                  match = Regex.Match(sql, @"SRV_REQ_FIPER.SRV_NO = (\d+) and SRV_REQ_FIPER_TECH.SRV_REQ_ID", RegexOptions.Singleline);
 920:   
 921:                  if (match.Success)
 922:                  {
 923:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
 924:                      {
 925:                          readItemCount = dataTable.Rows.Count;
 926:   
 927:                          sqlService = match.Groups[1].Value;
 928:   
 929:                          if (service == sqlService)
 930:                          {
 931:                              serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.ServiceRequestType.List(service);
 932:                              existingItemCount = serviceRequestTypeList.Count;
 933:   
 934:                              newServiceRequestTypeIdArryList = new ArrayList(dataTable.Rows.Count + 1);
 935:   
 936:                              foreach (DataRow dataRow in dataTable.Rows)
 937:                              {
 938:                                  serviceRequestId = int.Parse(dataRow["SRV_REQ_ID"].ToString());
 939:                                  serviceRequestTypeId = int.Parse(serviceRequestId.ToString() + dataRow["TECH_TYPE_ID"].ToString().PadLeft(2, '0'));
 940:   
 941:                                  newServiceRequestType = new Ia.Ngn.Cl.Model.ServiceRequestType();
 942:   
 943:                                  newServiceRequestType.Id = serviceRequestTypeId;
 944:   
 945:                                  newServiceRequestType.ServiceRequest = (from sr in db.ServiceRequests/*.AsNoTracking()*/ where sr.Id == serviceRequestId select sr).SingleOrDefault();
 946:                                  // System.InvalidOperationException: Attaching an entity of type 'Ia.Ngn.Cl.Model.ServiceRequest' failed because another entity of the same type already has the same primary key value.
 947:                                  // .AsNoTracking() see https://stackoverflow.com/questions/41376161/attaching-an-entity-of-type-x-failed-because-another-entity-of-the-same-type-a?rq=1
 948:                                  // and see https://stackoverflow.com/questions/18122723/asnotracking-using-linq-query-syntax-instead-of-method-syntax/18125658
 949:                                  // https://stackoverflow.com/questions/23201907/asp-net-mvc-attaching-an-entity-of-type-modelname-failed-because-another-ent
 950:   
 951:                                  try
 952:                                  {
 953:                                      // below: we will not add any type that does not have a service request
 954:                                      if (newServiceRequestType.ServiceRequest != null)
 955:                                      {
 956:                                          newServiceRequestType.TypeId = int.Parse(dataRow["TECH_TYPE_ID"].ToString());
 957:                                          newServiceRequestType.Value = dataRow["VAL"].ToString();
 958:   
 959:                                          FixCommonMistakesAndCheckValidityOfServiceRequestTypeRecords(ref newServiceRequestType);
 960:   
 961:                                          serviceRequestType = (from srt in serviceRequestTypeList where srt.Id == newServiceRequestType.Id select srt).SingleOrDefault();
 962:   
 963:                                          if (serviceRequestType == null)
 964:                                          {
 965:                                              newServiceRequestType.Created = newServiceRequestType.Updated = DateTime.UtcNow.AddHours(3);
 966:   
 967:                                              db.ServiceRequestTypes.Add(newServiceRequestType);
 968:   
 969:                                              insertedItemCount++;
 970:                                          }
 971:                                          else
 972:                                          {
 973:                                              // below: copy values from newServiceRequestType to serviceRequestType
 974:   
 975:                                              if (serviceRequestType.Update(newServiceRequestType))
 976:                                              {
 977:                                                  db.Entry(serviceRequestType).State = System.Data.Entity.EntityState.Modified;
 978:                                                  db.ServiceRequestTypes.Attach(serviceRequestType);
 979:   
 980:                                                  updatedItemCount++;
 981:                                              }
 982:                                          }
 983:   
 984:                                          // below: this will enable the removal of SRT that don't have a valid SR
 985:                                          newServiceRequestTypeIdArryList.Add(serviceRequestTypeId);
 986:                                      }
 987:                                      else
 988:                                      {
 989:                                          serviceRequestTypeWithNoServiceRequestIdList.Add(newServiceRequestType.Id);
 990:                                      }
 991:                                  }
 992:                                  catch (Exception ex)
 993:                                  {
 994:                                      exception += "Exception: serviceRequestId: " + serviceRequestId + ", exception:" + ex.ToString();
 995:                                  }
 996:                              }
 997:   
 998:                              /*
 999:                              if (serviceRequestTypeWithNoServiceRequestIdList.Count > 0)
1000:                              {
1001:                                  r = "SRT with no SR: ";
1002:  
1003:                                  foreach (int n in serviceRequestTypeWithNoServiceRequestIdList) r += n + ",";
1004:  
1005:                                  r = r.Trim(',');
1006:                              }
1007:                              */
1008:   
1009:                              // below: this function will remove values that were not present in the reading
1010:                              if (serviceRequestTypeList.Count > 0)
1011:                              {
1012:                                  foreach (Ia.Ngn.Cl.Model.ServiceRequestType srt in serviceRequestTypeList)
1013:                                  {
1014:                                      if (!newServiceRequestTypeIdArryList.Contains(srt.Id))
1015:                                      {
1016:                                          serviceRequestType = (from srt2 in db.ServiceRequestTypes where srt2.Id == srt.Id select srt2).SingleOrDefault();
1017:   
1018:                                          db.ServiceRequestTypes.Remove(serviceRequestType);
1019:   
1020:                                          deletedItemCount++;
1021:                                      }
1022:                                  }
1023:                              }
1024:   
1025:                              db.SaveChanges();
1026:   
1027:                              if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
1028:                              else isUpdated = false;
1029:   
1030:                              result = "(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ") (" + exception + ")";
1031:                          }
1032:                          else
1033:                          {
1034:                              throw new ArgumentException(@"UpdateForServiceRequestWithOutputDataTableService(): service != sqlService, service: " + service + ", sqlService: " + sqlService);
1035:                          }
1036:                      }
1037:                  }
1038:                  else
1039:                  {
1040:                      result = "(?/?/?: SQL in TableName is unmatched) ";
1041:                  }
1042:              }
1043:              else
1044:              {
1045:                  result = "(dataTable == null/?/?) ";
1046:              }
1047:          }
1048:   
1049:          ////////////////////////////////////////////////////////////////////////////
1050:   
1051:          /// <summary>
1052:          ///
1053:          /// </summary>
1054:          public static void UpdateForADateTimeRangeWithOutputDataTable(DataTable dataTable, Tuple<int, int> dateTime, out string result)
1055:          {
1056:              // below: the SQL statement should be within the dataTable.TableName variable
1057:              int readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
1058:              int serviceRequestId, serviceRequestTypeId;
1059:              string sql, r;
1060:              ArrayList newServiceRequestTypeIdArryList;
1061:              DateTime startDateTime, endDateTime;
1062:              Match match;
1063:              Ia.Ngn.Cl.Model.ServiceRequestType serviceRequestType, newServiceRequestType;
1064:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
1065:   
1066:              readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
1067:              result = r = string.Empty;
1068:   
1069:              startDateTime = endDateTime = DateTime.MinValue;
1070:   
1071:              if (dataTable != null)
1072:              {
1073:                  sql = dataTable.TableName;
1074:   
1075:                  // 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
1076:   
1077:                  match = Regex.Match(sql, @".+'(\d{2})\/(\d{2})\/(\d{4})'.+'(\d{2})\/(\d{2})\/(\d{4})'.+", RegexOptions.Singleline);
1078:                  //                             1        2        3        4          5        6
1079:   
1080:                  if (match.Success)
1081:                  {
1082:                      using (var db = new Ia.Ngn.Cl.Model.Ngn())
1083:                      {
1084:                          readItemCount = dataTable.Rows.Count;
1085:   
1086:                          //if (dataTable.Rows.Count > 0)
1087:                          //{
1088:                          startDateTime = DateTime.Parse(match.Groups[3].Value + "-" + match.Groups[2].Value + "-" + match.Groups[1].Value);
1089:                          endDateTime = DateTime.Parse(match.Groups[6].Value + "-" + match.Groups[5].Value + "-" + match.Groups[4].Value);
1090:   
1091:                          serviceRequestTypeList = Ia.Ngn.Cl.Model.Data.ServiceRequestType.ReadListThatHaveServiceRequestsWithinGivenDateRange(startDateTime, endDateTime);
1092:                          existingItemCount = serviceRequestTypeList.Count;
1093:   
1094:                          newServiceRequestTypeIdArryList = new ArrayList(dataTable.Rows.Count + 1);
1095:   
1096:                          foreach (DataRow dataRow in dataTable.Rows)
1097:                          {
1098:                              serviceRequestId = int.Parse(dataRow["SRV_REQ_ID"].ToString());
1099:                              serviceRequestTypeId = int.Parse(serviceRequestId.ToString() + dataRow["TECH_TYPE_ID"].ToString().PadLeft(2, '0'));
1100:   
1101:                              newServiceRequestType = new Ia.Ngn.Cl.Model.ServiceRequestType();
1102:   
1103:                              newServiceRequestType.Id = serviceRequestTypeId;
1104:   
1105:                              newServiceRequestType.ServiceRequest = (from sr in db.ServiceRequests where sr.Id == serviceRequestId select sr).SingleOrDefault();
1106:   
1107:                              // below: we will not add any type that does not have a service request
1108:                              if (newServiceRequestType.ServiceRequest != null)
1109:                              {
1110:                                  newServiceRequestType.TypeId = int.Parse(dataRow["TECH_TYPE_ID"].ToString());
1111:                                  newServiceRequestType.Value = dataRow["VAL"].ToString();
1112:   
1113:                                  FixCommonMistakesAndCheckValidityOfServiceRequestTypeRecords(ref newServiceRequestType);
1114:   
1115:                                  serviceRequestType = (from srt in serviceRequestTypeList where srt.Id == newServiceRequestType.Id select srt).SingleOrDefault();
1116:   
1117:                                  if (serviceRequestType == null)
1118:                                  {
1119:                                      newServiceRequestType.Created = newServiceRequestType.Updated = DateTime.UtcNow.AddHours(3);
1120:   
1121:                                      db.ServiceRequestTypes.Add(newServiceRequestType);
1122:   
1123:                                      insertedItemCount++;
1124:                                  }
1125:                                  else
1126:                                  {
1127:                                      // below: copy values from newServiceRequestType to serviceRequestType
1128:   
1129:                                      if (serviceRequestType.Update(newServiceRequestType))
1130:                                      {
1131:                                          db.ServiceRequestTypes.Attach(serviceRequestType);
1132:                                          db.Entry(serviceRequestType).State = System.Data.Entity.EntityState.Modified;
1133:   
1134:                                          updatedItemCount++;
1135:                                      }
1136:                                  }
1137:   
1138:                                  // below: this will enable the removal of SRT that don't have a valid SR
1139:                                  newServiceRequestTypeIdArryList.Add(serviceRequestTypeId);
1140:                              }
1141:                              else
1142:                              {
1143:                                  r += "newServiceRequestType.Id: " + newServiceRequestType.Id + " newServiceRequestType.ServiceRequest == null, ";
1144:                              }
1145:                          }
1146:   
1147:                          // below: this function will remove values that were not present in the reading
1148:                          if (serviceRequestTypeList.Count > 0)
1149:                          {
1150:                              foreach (Ia.Ngn.Cl.Model.ServiceRequestType srt in serviceRequestTypeList)
1151:                              {
1152:                                  if (!newServiceRequestTypeIdArryList.Contains(srt.Id))
1153:                                  {
1154:                                      serviceRequestType = (from srt2 in db.ServiceRequestTypes where srt2.Id == srt.Id select srt2).SingleOrDefault();
1155:   
1156:                                      db.ServiceRequestTypes.Remove(srt);
1157:   
1158:                                      deletedItemCount++;
1159:                                  }
1160:                              }
1161:                          }
1162:   
1163:                          db.SaveChanges();
1164:   
1165:                          result = "(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ") " + r;
1166:                          //}
1167:                          //else
1168:                          //{
1169:                          //    result = "(" + readItemCount + "/?/?) ";
1170:                          //}
1171:                      }
1172:                  }
1173:                  else
1174:                  {
1175:                      result = "(?/?/?: SQL in TableName is unmatched) ";
1176:                  }
1177:              }
1178:              else
1179:              {
1180:                  result = "(dataTable == null/?/?) ";
1181:              }
1182:          }
1183:   
1184:          ////////////////////////////////////////////////////////////////////////////    
1185:   
1186:          /// <summary>
1187:          ///
1188:          /// </summary>
1189:          private static void FixCommonMistakesAndCheckValidityOfServiceRequestTypeRecords(ref Ia.Ngn.Cl.Model.ServiceRequestType serviceRequestType)
1190:          {
1191:              // below: procedure to fix service request records from the common mistakes
1192:   
1193:              bool b;
1194:              int number;
1195:   
1196:              // below: convert 7 digit numbers to 8 digits
1197:              // <type id="11" name="dn" arabicName="dn" oracleFieldName="الرقم الجديد"/>
1198:              if (serviceRequestType.TypeId == 11)
1199:              {
1200:                  b = int.TryParse(serviceRequestType.Value.Trim(), out number);
1201:   
1202:                  if (b)
1203:                  {
1204:                      number = Ia.Ngn.Cl.Model.Business.Default.ChangeOldSevenDigitNumbersToEightDigitFormat(number);
1205:   
1206:                      if (Ia.Ngn.Cl.Model.Business.Service.NumberIsWithinAllowedDomainList(number))
1207:                      {
1208:                          serviceRequestType.Value = number.ToString();
1209:                      }
1210:                      else serviceRequestType.Value = null;
1211:                  }
1212:                  else serviceRequestType.Value = null;
1213:              }
1214:          }
1215:   
1216:          ////////////////////////////////////////////////////////////////////////////
1217:   
1218:          /// <summary>
1219:          ///
1220:          /// </summary>
1221:          public static Dictionary<int, string> NumberToServiceRequestTypeStringDictionary(List<int> domainList)
1222:          {
1223:              int number;
1224:              Dictionary<int, string> dictionary;
1225:              List<Ia.Ngn.Cl.Model.ServiceRequestType> serviceRequestTypeList;
1226:   
1227:              dictionary = new Dictionary<int, string>();
1228:   
1229:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
1230:              {
1231:                  if (domainList != null)
1232:                  {
1233:                      serviceRequestTypeList = (from srt in db.ServiceRequestTypes where domainList.Contains(srt.ServiceRequest.Number / 10000) || domainList.Contains(srt.ServiceRequest.Number / 1000) select srt).ToList();
1234:   
1235:                      if (serviceRequestTypeList != null)
1236:                      {
1237:                          dictionary = new Dictionary<int, string>(serviceRequestTypeList.Count);
1238:   
1239:                          foreach (Ia.Ngn.Cl.Model.ServiceRequestType srt in serviceRequestTypeList.OrderBy(u => u.Id))
1240:                          {
1241:                              number = int.Parse(srt.ServiceRequest.Number.ToString());
1242:   
1243:                              if (dictionary.ContainsKey(number)) dictionary[number] = dictionary[number] + "," + srt.Value;
1244:                              else dictionary[number] = srt.Value;
1245:                          }
1246:                      }
1247:                  }
1248:              }
1249:   
1250:              return dictionary;
1251:          }
1252:   
1253:          ////////////////////////////////////////////////////////////////////////////    
1254:          ////////////////////////////////////////////////////////////////////////////    
1255:      }
1256:   
1257:      ////////////////////////////////////////////////////////////////////////////
1258:      ////////////////////////////////////////////////////////////////////////////
1259:  }