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

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

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

   1:  using System;
   2:  using System.Collections;
   3:  using System.Collections.Generic;
   4:  using System.Linq;
   5:  using System.Data;
   6:   
   7:  namespace Ia.Ngn.Cl.Model.Data
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Service Request Ont Detail support class for Next Generation Network (NGN) data model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2017-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  17:      ///
  18:      /// 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
  19:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  20:      ///
  21:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  22:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  23:      /// 
  24:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  25:      /// 
  26:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  27:      /// </remarks> 
  28:      public partial class ServiceRequestOntDetail
  29:      {
  30:          private const int LengthOfRequestOntIdRange = 100;
  31:          private static Hashtable ontListAccessIdToAccessNameHashtable = new Hashtable();
  32:          private static Queue<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailNotInCustomerDepartmentDatabaseQueue = new Queue<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>();
  33:          private static Queue<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailNotUpdatedInCustomerDepartmentDatabaseQueue = new Queue<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>();
  34:          private static Queue<Tuple<string, string>> serviceRequestAccessIdOptimizedStartEndRangeTupleQueue = new Queue<Tuple<string, string>>();
  35:   
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          ///
  40:          /// </summary>
  41:          public ServiceRequestOntDetail() { }
  42:   
  43:          ////////////////////////////////////////////////////////////////////////////    
  44:   
  45:          /// <summary>
  46:          ///
  47:          /// </summary>
  48:          public static bool ServiceRequestOntDetailNotInCustomerDepartmentDatabaseQueueCountIsNotZero
  49:          {
  50:              get
  51:              {
  52:                  return serviceRequestOntDetailNotInCustomerDepartmentDatabaseQueue.Count > 0;
  53:              }
  54:          }
  55:   
  56:          ////////////////////////////////////////////////////////////////////////////    
  57:   
  58:          /// <summary>
  59:          ///
  60:          /// </summary>
  61:          public static Ia.Ngn.Cl.Model.ServiceRequestOntDetail ServiceRequestOntDetailNotInCustomerDepartmentDatabase(out Ia.Cl.Model.Result result)
  62:          {
  63:              int serviceType, servicePosition;
  64:              string id;
  65:              DateTime now;
  66:              Ia.Ngn.Cl.Model.ServiceRequestOntDetail serviceRequestOntDetail;
  67:              Ia.Ngn.Cl.Model.ServiceRequestOnt serviceRequestOnt;
  68:              List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList;
  69:              List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> list;
  70:   
  71:              result = new Ia.Cl.Model.Result();
  72:              now = DateTime.UtcNow.AddHours(3);
  73:   
  74:              if (serviceRequestOntDetailNotInCustomerDepartmentDatabaseQueue.Count == 0)
  75:              {
  76:                  serviceRequestOntDetailList = new List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>();
  77:   
  78:                  list = Ia.Ngn.Cl.Model.Data.Service.ListOfServiceServiceRequestOntDetailsThatDoNotExistInCustomerDepartmentDatabase();
  79:   
  80:                  foreach (Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt ssro in list)
  81:                  {
  82:                      serviceType = ssro.ServiceType;
  83:                      servicePosition = ssro.ServicePosition;
  84:                      serviceRequestOnt = ssro.ServiceRequestOnt;
  85:   
  86:                      id = Ia.Ngn.Cl.Model.Business.ServiceRequestOntDetail.ServiceRequestOntDetailId(serviceRequestOnt.Id, serviceType, servicePosition);
  87:   
  88:                      serviceRequestOntDetail = new Ia.Ngn.Cl.Model.ServiceRequestOntDetail()
  89:                      {
  90:                          Id = id,
  91:                          Service = ssro.Service,
  92:                          ServiceType = serviceType,
  93:                          ServicePosition = servicePosition,
  94:                          ServiceRequestOnt = serviceRequestOnt,
  95:                          Created = now,
  96:                          Updated = now
  97:                      };
  98:   
  99:                      serviceRequestOntDetailList.Add(serviceRequestOntDetail);
 100:                  }
 101:   
 102:                  serviceRequestOntDetailNotInCustomerDepartmentDatabaseQueue = new Queue<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>(serviceRequestOntDetailList);
 103:              }
 104:   
 105:              if (serviceRequestOntDetailNotInCustomerDepartmentDatabaseQueue.Count > 0)
 106:              {
 107:                  serviceRequestOntDetail = serviceRequestOntDetailNotInCustomerDepartmentDatabaseQueue.Dequeue();
 108:   
 109:                  result.AddSuccess("(" + serviceRequestOntDetail.ServiceRequestOnt.Name + "/" + serviceRequestOntDetailNotInCustomerDepartmentDatabaseQueue.Count + ")");
 110:              }
 111:              else
 112:              {
 113:                  serviceRequestOntDetail = null;
 114:   
 115:                  result.AddSuccess("No mismatch between OFN and billing database. ");
 116:              }
 117:   
 118:              return serviceRequestOntDetail;
 119:          }
 120:   
 121:          ////////////////////////////////////////////////////////////////////////////    
 122:   
 123:          /// <summary>
 124:          ///
 125:          /// </summary>
 126:          public static Ia.Ngn.Cl.Model.ServiceRequestOntDetail ServiceRequestOntDetailNotUpdatedInCustomerDepartmentDatabase(out Ia.Cl.Model.Result result)
 127:          {
 128:              int serviceType, servicePosition;
 129:              string id;
 130:              DateTime now;
 131:              Ia.Ngn.Cl.Model.ServiceRequestOntDetail serviceRequestOntDetail;
 132:              Ia.Ngn.Cl.Model.ServiceRequestOnt serviceRequestOnt;
 133:              List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList;
 134:              List<Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt> list;
 135:   
 136:              result = new Ia.Cl.Model.Result();
 137:              now = DateTime.UtcNow.AddHours(3);
 138:   
 139:              if (serviceRequestOntDetailNotUpdatedInCustomerDepartmentDatabaseQueue.Count == 0)
 140:              {
 141:                  serviceRequestOntDetailList = new List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>();
 142:   
 143:                  list = Ia.Ngn.Cl.Model.Data.Service.ServiceServiceRequestOntDetailWithMismatchedInformationInServiceRequestOntDetailList();
 144:   
 145:                  foreach (Ia.Ngn.Cl.Model.Business.ServiceServiceRequestOnt ssro in list)
 146:                  {
 147:                      serviceType = ssro.ServiceType;
 148:                      servicePosition = ssro.ServicePosition;
 149:                      serviceRequestOnt = ssro.ServiceRequestOnt;
 150:   
 151:                      id = Ia.Ngn.Cl.Model.Business.ServiceRequestOntDetail.ServiceRequestOntDetailId(serviceRequestOnt.Id, serviceType, servicePosition);
 152:   
 153:                      serviceRequestOntDetail = new Ia.Ngn.Cl.Model.ServiceRequestOntDetail()
 154:                      {
 155:                          Id = id,
 156:                          Service = ssro.Service,
 157:                          ServiceType = serviceType,
 158:                          ServicePosition = servicePosition,
 159:                          ServiceRequestOnt = serviceRequestOnt,
 160:                          Created = now,
 161:                          Updated = now
 162:                      };
 163:   
 164:                      serviceRequestOntDetailList.Add(serviceRequestOntDetail);
 165:                  }
 166:   
 167:                  serviceRequestOntDetailNotUpdatedInCustomerDepartmentDatabaseQueue = new Queue<Ia.Ngn.Cl.Model.ServiceRequestOntDetail>(serviceRequestOntDetailList);
 168:              }
 169:   
 170:              if (serviceRequestOntDetailNotUpdatedInCustomerDepartmentDatabaseQueue.Count > 0)
 171:              {
 172:                  serviceRequestOntDetail = serviceRequestOntDetailNotUpdatedInCustomerDepartmentDatabaseQueue.Dequeue();
 173:   
 174:                  result.AddSuccess("(" + serviceRequestOntDetail.ServiceRequestOnt.Name + "/" + serviceRequestOntDetailNotUpdatedInCustomerDepartmentDatabaseQueue.Count + ")");
 175:              }
 176:              else
 177:              {
 178:                  serviceRequestOntDetail = null;
 179:   
 180:                  result.AddSuccess("No mismatch in properties between OFN and billing database. ");
 181:              }
 182:   
 183:              return serviceRequestOntDetail;
 184:          }
 185:   
 186:          ////////////////////////////////////////////////////////////////////////////    
 187:   
 188:          /// <summary>
 189:          ///
 190:          /// </summary>
 191:          public static Tuple<string, string> ServiceRequestOntDetailIdStartEndRangeManager(out Ia.Cl.Model.Result result)
 192:          {
 193:              string startAccessName, endAccessName;
 194:              Tuple<string, string> tuple;
 195:              List<string> ontListAccessIdList;
 196:              List<Tuple<string, string>> tupleList;
 197:   
 198:              result = new Ia.Cl.Model.Result();
 199:   
 200:              if (serviceRequestAccessIdOptimizedStartEndRangeTupleQueue.Count == 0)
 201:              {
 202:                  ontListAccessIdList = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdList;
 203:                  ontListAccessIdToAccessNameHashtable = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntAccessIdToAccessNameHashtable;
 204:   
 205:                  tupleList = Ia.Cl.Model.Default.OptimizedStartEndRangeTupleList(ontListAccessIdList, LengthOfRequestOntIdRange);
 206:   
 207:                  serviceRequestAccessIdOptimizedStartEndRangeTupleQueue = new Queue<Tuple<string, string>>(tupleList);
 208:              }
 209:   
 210:              if (serviceRequestAccessIdOptimizedStartEndRangeTupleQueue.Count > 0)
 211:              {
 212:                  tuple = serviceRequestAccessIdOptimizedStartEndRangeTupleQueue.Dequeue();
 213:   
 214:                  // debug
 215:                  //tuple = new Tuple<string, string>("104010301512009", "104010301512019");
 216:   
 217:                  startAccessName = ontListAccessIdToAccessNameHashtable[tuple.Item1].ToString();
 218:                  endAccessName = ontListAccessIdToAccessNameHashtable[tuple.Item2].ToString();
 219:   
 220:                  result.AddSuccess("(" + startAccessName + " - " + endAccessName + "/" + serviceRequestAccessIdOptimizedStartEndRangeTupleQueue.Count + ")");
 221:              }
 222:              else
 223:              {
 224:                  tuple = null;
 225:   
 226:                  result.AddWarning("(0-0 0/0)");
 227:              }
 228:   
 229:              return tuple;
 230:          }
 231:   
 232:          ////////////////////////////////////////////////////////////////////////////    
 233:   
 234:          /// <summary>
 235:          ///
 236:          /// </summary>
 237:          public static string OracleSqlCommandSelectProperServiceRequestOntDetailRecordList(Tuple<string, string> startEndRangeTuple)
 238:          {
 239:              return OracleSqlCommandSelectProperServiceRequestOntDetailRecordList(startEndRangeTuple.Item1, startEndRangeTuple.Item2);
 240:          }
 241:   
 242:          ////////////////////////////////////////////////////////////////////////////    
 243:   
 244:          /// <summary>
 245:          ///
 246:          /// </summary>
 247:          public static string OracleSqlCommandSelectProperServiceRequestOntDetailRecordList(string start, string end)
 248:          {
 249:              string sql;
 250:   
 251:              // Note that ONT_DETAILS.ID is just the ServiceRequestOnt.Id
 252:   
 253:              if (!string.IsNullOrEmpty(start) && !string.IsNullOrEmpty(end)) sql = @"select id, line_ser, ethernet_ser, phone_no, internet_srv_no from ont_details where (id >= " + start + " and id <= " + end + @") order by id asc";
 254:              else sql = string.Empty;
 255:   
 256:              return sql;
 257:          }
 258:   
 259:          ////////////////////////////////////////////////////////////////////////////    
 260:   
 261:          /// <summary>
 262:          ///
 263:          /// </summary>
 264:          public static string OracleSqlCommandInsertServiceRequestOntDetailRecord(Ia.Ngn.Cl.Model.ServiceRequestOntDetail serviceRequestOntDetail)
 265:          {
 266:              int line_ser, ethernet_ser, phone_no;
 267:              string sql, internet_srv_no;
 268:   
 269:              // convert ServiceRequestOntDetail to the format needed in ONT_DETAILS
 270:   
 271:              if (serviceRequestOntDetail.ServiceType == 1)
 272:              {
 273:                  line_ser = serviceRequestOntDetail.ServicePosition;
 274:                  ethernet_ser = 0;
 275:                  phone_no = int.Parse(serviceRequestOntDetail.Service);
 276:                  internet_srv_no = string.Empty;
 277:              }
 278:              else //if (serviceRequestOntDetail.ServiceType == 2)
 279:              {
 280:                  line_ser = 0;
 281:                  ethernet_ser = serviceRequestOntDetail.ServicePosition;
 282:                  phone_no = 0;
 283:                  internet_srv_no = serviceRequestOntDetail.Service;
 284:              }
 285:   
 286:              sql = @"insert into ONT_DETAILS(ID, LINE_SER, ETHERNET_SER, PHONE_NO, INTERNET_SRV_NO) values "
 287:                           + @"("
 288:                           + @"N&quote;" + serviceRequestOntDetail.ServiceRequestOnt.Id + @"&quote;,"
 289:                           + @"N&quote;" + line_ser + @"&quote;,"
 290:                           + @"N&quote;" + ethernet_ser + @"&quote;,"
 291:                           + @"N&quote;" + phone_no + @"&quote;,"
 292:                           + @"N&quote;" + internet_srv_no + @"&quote;"
 293:                                                       + @")";
 294:   
 295:              sql = sql.Replace("'", " ");
 296:              sql = sql.Replace("&quote;", "'");
 297:   
 298:              return sql;
 299:          }
 300:   
 301:          ////////////////////////////////////////////////////////////////////////////    
 302:   
 303:          /// <summary>
 304:          ///
 305:          /// </summary>
 306:          public static string OracleSqlCommandUpdateServiceRequestOntDetailRecord(Ia.Ngn.Cl.Model.ServiceRequestOntDetail serviceRequestOntDetail)
 307:          {
 308:              int line_ser, ethernet_ser, phone_no;
 309:              string sql, internet_srv_no;
 310:   
 311:              // convert ServiceRequestOntDetail to the format needed in ONT_DETAILS
 312:   
 313:              if (serviceRequestOntDetail.ServiceType == 1)
 314:              {
 315:                  line_ser = serviceRequestOntDetail.ServicePosition;
 316:                  ethernet_ser = 0;
 317:                  phone_no = int.Parse(serviceRequestOntDetail.Service);
 318:                  internet_srv_no = string.Empty;
 319:              }
 320:              else //if (serviceRequestOntDetail.ServiceType == 2)
 321:              {
 322:                  line_ser = 0;
 323:                  ethernet_ser = serviceRequestOntDetail.ServicePosition;
 324:                  phone_no = 0;
 325:                  internet_srv_no = serviceRequestOntDetail.Service;
 326:              }
 327:   
 328:              sql = @"update ont_details set LINE_SER = " + line_ser + @", "
 329:  + @"ETHERNET_SER = " + ethernet_ser + @", "
 330:  + @"PHONE_NO = " + phone_no + @", "
 331:  + @"INTERNET_SRV_NO = N&quote;" + internet_srv_no + @"&quote; "
 332:  + @" where ID = N&quote;" + serviceRequestOntDetail.Id + @"&quote;";
 333:   
 334:              sql = sql.Replace("'", " ");
 335:              sql = sql.Replace("&quote;", "'");
 336:   
 337:              return sql;
 338:          }
 339:   
 340:          ////////////////////////////////////////////////////////////////////////////    
 341:   
 342:          /// <summary>
 343:          ///
 344:          /// </summary>
 345:          public static string OracleSqlCommandDeleteServiceRequestOntDetailRecord(Ia.Ngn.Cl.Model.ServiceRequestOntDetail serviceRequestOntDetail)
 346:          {
 347:              string sql;
 348:   
 349:              // Note that ONT_DETAILS.ID is just the ServiceRequestOnt.Id
 350:   
 351:              sql = @"delete from ont_details where ID = N&quote;" + serviceRequestOntDetail.Id + @"&quote;";
 352:   
 353:              return sql;
 354:          }
 355:   
 356:          ////////////////////////////////////////////////////////////////////////////    
 357:   
 358:          /// <summary>
 359:          ///
 360:          /// </summary>
 361:          public static string OracleSqlCommandDeleteServiceRequestOntDetailRecord(string sqlWhereString)
 362:          {
 363:              string sql;
 364:   
 365:              // Note that ONT_DETAILS.ID is just the ServiceRequestOnt.Id
 366:   
 367:              sql = @"delete from ont_details where " + sqlWhereString;
 368:   
 369:              return sql;
 370:          }
 371:   
 372:          ////////////////////////////////////////////////////////////////////////////
 373:   
 374:          /// <summary>
 375:          ///
 376:          /// </summary>
 377:          public static void UpdateForServiceRequestOntIdRangeWithOutputDataTable(DataTable dataTable, Tuple<string, string> startEndRangeTuple, out Ia.Cl.Model.Result result)
 378:          {
 379:              bool validRecord; // isUpdated;
 380:              int serviceType, servicePosition, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount;
 381:              string service, r, start, end, serviceRequestOntId, serviceRequestOntDetailId;
 382:              Ia.Ngn.Cl.Model.ServiceRequestOntDetail serviceRequestOntDetail, newServiceRequestOntDetail;
 383:              Ia.Ngn.Cl.Model.ServiceRequestOnt serviceRequestOnt;
 384:              List<string> insertedItemIdList, newServiceRequestOntDetailIdList;
 385:              List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList;
 386:   
 387:              validRecord = false; // isUpdated = false;
 388:              serviceType = servicePosition = 0;
 389:              readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
 390:              service = r = string.Empty;
 391:   
 392:              result = new Ia.Cl.Model.Result();
 393:              insertedItemIdList = new List<string>();
 394:              newServiceRequestOntDetailIdList = new List<string>();
 395:   
 396:              if (dataTable != null)
 397:              {
 398:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 399:                  {
 400:                      readItemCount = dataTable.Rows.Count;
 401:   
 402:                      start = startEndRangeTuple.Item1;
 403:                      end = startEndRangeTuple.Item2;
 404:   
 405:                      serviceRequestOntDetailList = Ia.Ngn.Cl.Model.Data.ServiceRequestOntDetail.ReadListWithinIdRange(start, end);
 406:                      existingItemCount = serviceRequestOntDetailList.Count;
 407:   
 408:                      insertedItemIdList = new List<string>(dataTable.Rows.Count + 1);
 409:   
 410:                      int line_ser, ethernet_ser, phone_no;
 411:                      string internet_srv_no;
 412:   
 413:                      foreach (DataRow dataRow in dataTable.Rows)
 414:                      {
 415:                          serviceRequestOntId = dataRow["Id"].ToString();
 416:   
 417:                          if (int.TryParse(dataRow["line_ser"].ToString(), out line_ser) && int.TryParse(dataRow["ethernet_ser"].ToString(), out ethernet_ser) && int.TryParse(dataRow["phone_no"].ToString(), out phone_no))
 418:                          {
 419:                              internet_srv_no = dataRow["internet_srv_no"].ToString();
 420:   
 421:                              // I will convert from the Customer department database convention to my own
 422:   
 423:                              if (line_ser != 0)
 424:                              {
 425:                                  serviceType = 1;
 426:                                  service = phone_no.ToString();
 427:                                  servicePosition = line_ser;
 428:   
 429:                                  validRecord = true;
 430:                              }
 431:                              else if (ethernet_ser != 0)
 432:                              {
 433:                                  serviceType = 2;
 434:                                  service = internet_srv_no;
 435:                                  servicePosition = ethernet_ser;
 436:   
 437:                                  validRecord = true;
 438:                              }
 439:                              else
 440:                              {
 441:                                  validRecord = false;
 442:                              }
 443:                          }
 444:                          else
 445:                          {
 446:                              validRecord = false;
 447:                          }
 448:   
 449:                          if (validRecord)
 450:                          {
 451:                              serviceRequestOntDetailId = Ia.Ngn.Cl.Model.Business.ServiceRequestOntDetail.ServiceRequestOntDetailId(serviceRequestOntId, serviceType, servicePosition);
 452:   
 453:                              serviceRequestOnt = (from sro in db.ServiceRequestOnts where sro.Id == serviceRequestOntId select sro).SingleOrDefault();
 454:   
 455:                              serviceRequestOntDetail = (from srod in db.ServiceRequestOntDetails where srod.Id == serviceRequestOntDetailId select srod).SingleOrDefault();
 456:   
 457:                              newServiceRequestOntDetail = new Ia.Ngn.Cl.Model.ServiceRequestOntDetail()
 458:                              {
 459:                                  Id = serviceRequestOntDetailId,
 460:                                  ServiceType = serviceType,
 461:                                  Service = service,
 462:                                  ServicePosition = servicePosition,
 463:                                  Created = DateTime.UtcNow.AddHours(3),
 464:                                  Updated = DateTime.UtcNow.AddHours(3),
 465:                                  ServiceRequestOnt = serviceRequestOnt,
 466:                              };
 467:   
 468:                              if (serviceRequestOntDetail == null)
 469:                              {
 470:                                  insertedItemIdList.Add(serviceRequestOntDetailId);
 471:   
 472:                                  db.ServiceRequestOntDetails.Add(newServiceRequestOntDetail);
 473:   
 474:                                  insertedItemCount++;
 475:                              }
 476:                              else
 477:                              {
 478:                                  // below: copy values from newServiceRequestOntDetail to serviceRequestOntDetail
 479:   
 480:                                  if (serviceRequestOntDetail.Update(newServiceRequestOntDetail))
 481:                                  {
 482:                                      db.ServiceRequestOntDetails.Attach(serviceRequestOntDetail);
 483:                                      db.Entry(serviceRequestOntDetail).State = System.Data.Entity.EntityState.Modified;
 484:   
 485:                                      updatedItemCount++;
 486:                                  }
 487:                              }
 488:   
 489:                              // below: this will enable the removal of records that don't have a valid record
 490:                              newServiceRequestOntDetailIdList.Add(serviceRequestOntDetailId);
 491:                          }
 492:                          else
 493:                          {
 494:   
 495:                          }
 496:                      }
 497:   
 498:                      //db.SaveChanges(); // I don't know the problem here keep this due to some strange errors
 499:   
 500:                      // below: this function will remove values that were not present in the reading
 501:                      if (serviceRequestOntDetailList.Count > 0)
 502:                      {
 503:                          foreach (Ia.Ngn.Cl.Model.ServiceRequestOntDetail srod in serviceRequestOntDetailList)
 504:                          {
 505:                              if (!newServiceRequestOntDetailIdList.Contains(srod.Id))
 506:                              {
 507:                                  serviceRequestOntDetail = (from srod2 in db.ServiceRequestOntDetails where srod2.Id == srod.Id select srod2).SingleOrDefault();
 508:   
 509:                                  if (serviceRequestOntDetail != null)
 510:                                  {
 511:                                      db.ServiceRequestOntDetails.Remove(serviceRequestOntDetail);
 512:                                      deletedItemCount++;
 513:                                  }
 514:                              }
 515:                          }
 516:   
 517:                          //db.SaveChanges(); // keep this due to some strange errors
 518:                      }
 519:   
 520:                      db.SaveChanges(); // keep this due to some strange errors
 521:   
 522:                      //if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
 523:                      //else isUpdated = false;
 524:   
 525:                      result.AddSuccess("(" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ") ");
 526:                  }
 527:              }
 528:              else
 529:              {
 530:                  result.AddWarning("(dataTable == null/?/?) ");
 531:              }
 532:          }
 533:   
 534:          ////////////////////////////////////////////////////////////////////////////
 535:   
 536:          /// <summary>
 537:          ///
 538:          /// </summary>
 539:          public static List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> ReadListWithinIdRange(string start, string end)
 540:          {
 541:              List<Ia.Ngn.Cl.Model.ServiceRequestOntDetail> serviceRequestOntDetailList;
 542:   
 543:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 544:              {
 545:                  serviceRequestOntDetailList = (from srod in db.ServiceRequestOntDetails where srod.Id.CompareTo(start) >= 0 && srod.Id.CompareTo(end) <= 0 select srod).ToList();
 546:              }
 547:   
 548:              return serviceRequestOntDetailList;
 549:          }
 550:   
 551:          ////////////////////////////////////////////////////////////////////////////    
 552:          ////////////////////////////////////////////////////////////////////////////    
 553:      }
 554:   
 555:      ////////////////////////////////////////////////////////////////////////////
 556:      ////////////////////////////////////////////////////////////////////////////
 557:  }