)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » ServiceRequestAdministrativeIssue (Ia.Ftn.Cl.Models.Data)

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

Service Request Administrative Issue support class for Fixed Telecommunications Network (FTN) data model.

    1: using Microsoft.EntityFrameworkCore;
    2: using System;
    3: using System.Collections.Generic;
    4: using System.Data;
    5: using System.Linq;
    6: using System.Text;
    7:  
    8: namespace Ia.Ftn.Cl.Models.Data
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     /// Service Request Administrative Issue support class for Fixed Telecommunications Network (FTN) data model.
   14:     /// </summary>
   15:     /// 
   16:     /// <remarks> 
   17:     /// Copyright © 2019-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   18:     ///
   19:     /// 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
   20:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   21:     ///
   22:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   23:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   24:     /// 
   25:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   26:     /// 
   27:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   28:     /// </remarks> 
   29:     public class ServiceRequestAdministrativeIssue
   30:     {
   31:         private static readonly object objectLock = new object();
   32:  
   33:         ////////////////////////////////////////////////////////////////////////////
   34:  
   35:         /// <summary>
   36:         ///
   37:         /// </summary>
   38:         public ServiceRequestAdministrativeIssue() { }
   39:  
   40:         ////////////////////////////////////////////////////////////////////////////
   41:  
   42:         /// <summary>
   43:         ///
   44:         /// </summary>
   45:         public static Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue Read(string service, out Ia.Cl.Models.Result result)
   46:         {
   47:             Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue serviceRequestAdministrativeIssue;
   48:  
   49:             result = new Ia.Cl.Models.Result();
   50:  
   51:             if (!string.IsNullOrEmpty(service))
   52:             {
   53:                 if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
   54:                 {
   55:                     var isPstnService = Ia.Ftn.Cl.Models.Data.Service2.IsPstnService(service);
   56:  
   57:                     if (!isPstnService)
   58:                     {
   59:                         using (var db = new Ia.Ftn.Cl.Db())
   60:                         {
   61:                             var serviceRequestAdministrativeIssueId = Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueId(service, Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService);
   62:  
   63:                             serviceRequestAdministrativeIssue = (from srai in db.ServiceRequestAdministrativeIssues
   64:                                                                  where srai.Id == serviceRequestAdministrativeIssueId
   65:                                                                  select srai).SingleOrDefault();
   66:  
   67:                             if (serviceRequestAdministrativeIssue != null)
   68:                             {
   69:                                 result.AddSuccess(@"The number " + service + @" exists in table.");
   70:                             }
   71:                             else result.AddSuccess(@"The number " + service + @" does not exist in table.");
   72:                         }
   73:                     }
   74:                     else
   75:                     {
   76:                         serviceRequestAdministrativeIssue = null;
   77:                         result.AddError("Service number " + service + " is a PSTN number.");
   78:                     }
   79:                 }
   80:                 else
   81:                 {
   82:                     serviceRequestAdministrativeIssue = null;
   83:                     result.AddError("Service number " + service + " does not belong to the network.");
   84:                 }
   85:             }
   86:             else
   87:             {
   88:                 serviceRequestAdministrativeIssue = null;
   89:                 result.AddError("Input is null or empty.");
   90:             }
   91:  
   92:             return serviceRequestAdministrativeIssue;
   93:         }
   94:  
   95:         ////////////////////////////////////////////////////////////////////////////
   96:  
   97:         /// <summary>
   98:         ///
   99:         /// </summary>
  100:         public static bool IsPendingIssue(Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType disconnectionType, string service)
  101:         {
  102:             bool isPendingIssue;
  103:  
  104:             using (var db = new Ia.Ftn.Cl.Db())
  105:             {
  106:                 isPendingIssue = (from srai in db.ServiceRequestAdministrativeIssues
  107:                                   where srai.Service == service && srai.Type == (int)disconnectionType
  108:                                   select srai.Service).Any();
  109:             }
  110:  
  111:             return isPendingIssue;
  112:         }
  113:  
  114:         ////////////////////////////////////////////////////////////////////////////
  115:  
  116:         /// <summary>
  117:         ///
  118:         /// </summary>
  119:         public static List<string> ServiceList(List<string> serviceList)
  120:         {
  121:             List<string> list;
  122:  
  123:             using (var db = new Ia.Ftn.Cl.Db())
  124:             {
  125:                 if (serviceList.Count > 0)
  126:                 {
  127:                     list = (from srai in db.ServiceRequestAdministrativeIssues
  128:                             where serviceList.Contains(srai.Service)
  129:                             select srai.Service).AsNoTracking().ToList();
  130:                 }
  131:                 else list = new List<string>();
  132:             }
  133:  
  134:             return list;
  135:         }
  136:  
  137:         ////////////////////////////////////////////////////////////////////////////
  138:  
  139:         /// <summary>
  140:         ///
  141:         /// </summary>
  142:         public static List<Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue> List()
  143:         {
  144:             List<Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue> list;
  145:  
  146:             using (var db = new Ia.Ftn.Cl.Db())
  147:             {
  148:                 list = (from srai in db.ServiceRequestAdministrativeIssues
  149:                         select srai).AsNoTracking().ToList();
  150:             }
  151:  
  152:             return list;
  153:         }
  154:  
  155:         ////////////////////////////////////////////////////////////////////////////
  156:  
  157:         /// <summary>
  158:         ///
  159:         /// </summary>
  160:         public static List<string> ServiceList()
  161:         {
  162:             List<string> list;
  163:  
  164:             using (var db = new Ia.Ftn.Cl.Db())
  165:             {
  166:                 list = (from srai in db.ServiceRequestAdministrativeIssues
  167:                         select srai.Service).AsNoTracking().ToList();
  168:             }
  169:  
  170:             return list;
  171:         }
  172:  
  173:         ////////////////////////////////////////////////////////////////////////////
  174:  
  175:         /// <summary>
  176:         ///
  177:         /// </summary>
  178:         public static List<string> ServiceList(Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType disconnectionType)
  179:         {
  180:             List<string> list;
  181:  
  182:             using (var db = new Ia.Ftn.Cl.Db())
  183:             {
  184:                 list = (from srai in db.ServiceRequestAdministrativeIssues
  185:                         where srai.Type == (int)disconnectionType
  186:                         select srai.Service).AsNoTracking().ToList();
  187:             }
  188:  
  189:             return list;
  190:         }
  191:  
  192:         ////////////////////////////////////////////////////////////////////////////
  193:  
  194:         /// <summary>
  195:         ///
  196:         /// </summary>
  197:         public static Dictionary<string, string> ServiceDictionary()
  198:         {
  199:             Dictionary<string, string> dictionary;
  200:  
  201:             using (var db = new Ia.Ftn.Cl.Db())
  202:             {
  203:                 dictionary = (from srai in db.ServiceRequestAdministrativeIssues
  204:                               select new { srai.Service }).AsNoTracking().ToDictionary(u => u.Service, u => u.Service);
  205:             }
  206:  
  207:             return dictionary.ToDictionary(u => u.Key, u => u.Value);
  208:         }
  209:  
  210:         ////////////////////////////////////////////////////////////////////////////
  211:  
  212:         /// <summary>
  213:         ///
  214:         /// </summary>
  215:         public static List<string> IdList()
  216:         {
  217:             List<string> list;
  218:  
  219:             using (var db = new Ia.Ftn.Cl.Db())
  220:             {
  221:                 list = (from srai in db.ServiceRequestAdministrativeIssues
  222:                         select srai.Id).AsNoTracking().ToList();
  223:             }
  224:  
  225:             return list;
  226:         }
  227:  
  228:         ////////////////////////////////////////////////////////////////////////////
  229:  
  230:         /// <summary>
  231:         ///
  232:         /// </summary>
  233:         public static Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue Update(string service, Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueType serviceRequestAdministrativeIssueType, bool serviceMustBeWithinNokiaSwitchDomainList, out Ia.Cl.Models.Result result)
  234:         {
  235:             Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue serviceRequestAdministrativeIssue;
  236:  
  237:             result = new Ia.Cl.Models.Result();
  238:  
  239:             if (!string.IsNullOrEmpty(service))
  240:             {
  241:                 if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  242:                 {
  243:                     if (!serviceMustBeWithinNokiaSwitchDomainList || serviceMustBeWithinNokiaSwitchDomainList && Ia.Ftn.Cl.Models.Data.Service.ServiceIsWithinNokiaSwitchDomainList(service)) // temp
  244:                     {
  245:                         var isPstnService = Ia.Ftn.Cl.Models.Data.Service2.IsPstnService(service);
  246:  
  247:                         if (!isPstnService)
  248:                         {
  249:                             using (var db = new Ia.Ftn.Cl.Db())
  250:                             {
  251:                                 result = new Ia.Cl.Models.Result();
  252:  
  253:                                 var serviceRequestAdministrativeIssueId = Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueId(service, Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService);
  254:  
  255:                                 serviceRequestAdministrativeIssue = (from srai in db.ServiceRequestAdministrativeIssues
  256:                                                                      where srai.Id == serviceRequestAdministrativeIssueId
  257:                                                                      select srai).SingleOrDefault();
  258:  
  259:                                 if (serviceRequestAdministrativeIssue != null)
  260:                                 {
  261:                                     if (serviceRequestAdministrativeIssueType.DisconnectionType == Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType.None)
  262:                                     {
  263:                                         db.ServiceRequestAdministrativeIssues.Remove(serviceRequestAdministrativeIssue);
  264:                                         db.SaveChanges();
  265:  
  266:                                         serviceRequestAdministrativeIssue = Ia.Ftn.Cl.Models.Data.ServiceRequestAdministrativeIssue.Read(service, out _);
  267:  
  268:                                         Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ServiceInServiceRequestAdministrativeIssuesUpdated, service);
  269:  
  270:                                         result.AddSuccess("Entry for " + service + " was deleted.");
  271:                                     }
  272:                                     else if (serviceRequestAdministrativeIssue.Type != (int)serviceRequestAdministrativeIssueType.DisconnectionType)
  273:                                     {
  274:                                         serviceRequestAdministrativeIssue.Type = (int)serviceRequestAdministrativeIssueType.DisconnectionType;
  275:                                         serviceRequestAdministrativeIssue.Updated = DateTime.UtcNow.AddHours(3);
  276:                                         // serviceRequestAdministrativeIssue.StaffIdentityUser.Id = string.Empty;
  277:  
  278:                                         db.ServiceRequestAdministrativeIssues.Attach(serviceRequestAdministrativeIssue);
  279:                                         db.Entry(serviceRequestAdministrativeIssue).Property(u => u.Type).IsModified = true;
  280:                                         db.SaveChanges();
  281:  
  282:                                         serviceRequestAdministrativeIssue = Ia.Ftn.Cl.Models.Data.ServiceRequestAdministrativeIssue.Read(service, out _);
  283:  
  284:                                         Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ServiceInServiceRequestAdministrativeIssuesUpdated, service);
  285:  
  286:                                         result.AddSuccess("Entry for " + service + " was updated.");
  287:                                     }
  288:                                     else
  289:                                     {
  290:                                         result.AddWarning("Entry for " + service + " was not updated because it was not changed.");
  291:                                     }
  292:                                 }
  293:                                 else
  294:                                 {
  295:                                     if (serviceRequestAdministrativeIssueType.DisconnectionType == Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType.None)
  296:                                     {
  297:                                         result.AddWarning("Entry for " + service + " was not removed because it did not exist.");
  298:                                     }
  299:                                     else
  300:                                     {
  301:                                         serviceRequestAdministrativeIssue = new Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue
  302:                                         {
  303:                                             Id = serviceRequestAdministrativeIssueId,
  304:                                             Service = service,
  305:                                             Type = (int)serviceRequestAdministrativeIssueType.DisconnectionType,
  306:                                             Value = String.Empty,
  307:                                             Created = DateTime.UtcNow.AddHours(3),
  308:                                             Updated = DateTime.UtcNow.AddHours(3),
  309:                                             StaffIdentityUser = null,
  310:                                         };
  311:  
  312:                                         db.ServiceRequestAdministrativeIssues.Add(serviceRequestAdministrativeIssue);
  313:                                         db.SaveChanges();
  314:  
  315:                                         serviceRequestAdministrativeIssue = Ia.Ftn.Cl.Models.Data.ServiceRequestAdministrativeIssue.Read(service, out _);
  316:  
  317:                                         Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ServiceInServiceRequestAdministrativeIssuesUpdated, service);
  318:  
  319:                                         result.AddSuccess("Entry for " + service + " was created.");
  320:                                     }
  321:                                 }
  322:                             }
  323:                         }
  324:                         else
  325:                         {
  326:                             serviceRequestAdministrativeIssue = null;
  327:                             result.AddError("Service number " + service + " is a PSTN number.");
  328:                         }
  329:                     }
  330:                     else
  331:                     {
  332:                         serviceRequestAdministrativeIssue = null;
  333:                         result.AddError("Service number " + service + " does not belong to a Nokia switch.");
  334:                     }
  335:                 }
  336:                 else
  337:                 {
  338:                     serviceRequestAdministrativeIssue = null;
  339:                     result.AddError("Service number " + service + " does not belong to the network.");
  340:                 }
  341:             }
  342:             else
  343:             {
  344:                 serviceRequestAdministrativeIssue = null;
  345:                 result.AddError("Input is null or empty.");
  346:             }
  347:  
  348:             return serviceRequestAdministrativeIssue;
  349:         }
  350:  
  351:         ////////////////////////////////////////////////////////////////////////////
  352:  
  353:         /// <summary>
  354:         ///
  355:         /// </summary>
  356:         public static bool Update2(Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType disconnectionType, string service, out Ia.Cl.Models.Result result)
  357:         {
  358:             bool isUpdated;
  359:             Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue serviceRequestAdministrativeIssue;
  360:  
  361:             result = new Ia.Cl.Models.Result();
  362:  
  363:             if (!string.IsNullOrEmpty(service))
  364:             {
  365:                 if (Ia.Ftn.Cl.Models.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
  366:                 {
  367:                     var isPstnService = Ia.Ftn.Cl.Models.Data.Service2.IsPstnService(service);
  368:  
  369:                     if (!isPstnService)
  370:                     {
  371:                         using (var db = new Ia.Ftn.Cl.Db())
  372:                         {
  373:                             var serviceRequestAdministrativeIssueId = Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueId(service, Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService);
  374:  
  375:                             serviceRequestAdministrativeIssue = (from srai in db.ServiceRequestAdministrativeIssues
  376:                                                                  where srai.Id == serviceRequestAdministrativeIssueId
  377:                                                                  select srai).SingleOrDefault();
  378:  
  379:                             if (serviceRequestAdministrativeIssue != null)
  380:                             {
  381:                                 if (disconnectionType == Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType.None)
  382:                                 {
  383:                                     db.ServiceRequestAdministrativeIssues.Remove(serviceRequestAdministrativeIssue);
  384:                                     db.SaveChanges();
  385:  
  386:                                     serviceRequestAdministrativeIssue = Ia.Ftn.Cl.Models.Data.ServiceRequestAdministrativeIssue.Read(service, out _);
  387:  
  388:                                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ServiceInServiceRequestAdministrativeIssuesUpdated, service);
  389:  
  390:                                     isUpdated = true;
  391:                                     result.AddSuccess("Entry for " + service + " was deleted.");
  392:                                 }
  393:                                 else if (serviceRequestAdministrativeIssue.Type != (int)disconnectionType)
  394:                                 {
  395:                                     serviceRequestAdministrativeIssue.Type = (int)disconnectionType;
  396:                                     serviceRequestAdministrativeIssue.Updated = DateTime.UtcNow.AddHours(3);
  397:                                     // serviceRequestAdministrativeIssue.StaffIdentityUser.Id = string.Empty;
  398:  
  399:                                     db.ServiceRequestAdministrativeIssues.Attach(serviceRequestAdministrativeIssue);
  400:                                     db.Entry(serviceRequestAdministrativeIssue).Property(u => u.Type).IsModified = true;
  401:                                     db.SaveChanges();
  402:  
  403:                                     serviceRequestAdministrativeIssue = Ia.Ftn.Cl.Models.Data.ServiceRequestAdministrativeIssue.Read(service, out _);
  404:  
  405:                                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ServiceInServiceRequestAdministrativeIssuesUpdated, service);
  406:  
  407:                                     isUpdated = true;
  408:                                     result.AddSuccess("Entry for " + service + " was updated.");
  409:                                 }
  410:                                 else
  411:                                 {
  412:                                     isUpdated = false;
  413:                                     result.AddWarning("Entry for " + service + " was not updated because it was not changed.");
  414:                                 }
  415:                             }
  416:                             else
  417:                             {
  418:                                 if (disconnectionType == Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.DisconnectionType.None)
  419:                                 {
  420:                                     isUpdated = false;
  421:                                     result.AddWarning("Entry for " + service + " was not removed because it did not exist.");
  422:                                 }
  423:                                 else
  424:                                 {
  425:                                     serviceRequestAdministrativeIssue = new Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue
  426:                                     {
  427:                                         Id = serviceRequestAdministrativeIssueId,
  428:                                         Service = service,
  429:                                         Type = (int)disconnectionType,
  430:                                         Value = String.Empty,
  431:                                         Created = DateTime.UtcNow.AddHours(3),
  432:                                         Updated = DateTime.UtcNow.AddHours(3),
  433:                                         StaffIdentityUser = null,
  434:                                     };
  435:  
  436:                                     db.ServiceRequestAdministrativeIssues.Add(serviceRequestAdministrativeIssue);
  437:                                     db.SaveChanges();
  438:  
  439:                                     serviceRequestAdministrativeIssue = Ia.Ftn.Cl.Models.Data.ServiceRequestAdministrativeIssue.Read(service, out _);
  440:  
  441:                                     Ia.Ftn.Cl.Models.Data.MessageQueue.SecretaryApplication.Enqueue(Ia.Ftn.Cl.Models.Business.MessageQueue.Application.FtnApplication, Ia.Ftn.Cl.Models.Business.MessageQueue.Process.ServiceInServiceRequestAdministrativeIssuesUpdated, service);
  442:  
  443:                                     isUpdated = true;
  444:                                     result.AddSuccess("Entry for " + service + " was created.");
  445:                                 }
  446:                             }
  447:                         }
  448:                     }
  449:                     else
  450:                     {
  451:                         isUpdated = false;
  452:                         result.AddError("Service number " + service + " is a PSTN number.");
  453:                     }
  454:                 }
  455:                 else
  456:                 {
  457:                     isUpdated = false;
  458:                     result.AddError("Service number " + service + " does not belong to the network.");
  459:                 }
  460:             }
  461:             else
  462:             {
  463:                 isUpdated = false;
  464:                 result.AddError("Input is null or empty.");
  465:             }
  466:  
  467:             return isUpdated;
  468:         }
  469:  
  470:         ////////////////////////////////////////////////////////////////////////////
  471:         ////////////////////////////////////////////////////////////////////////////
  472:  
  473:         /// <summary>
  474:         ///
  475:         /// </summary>
  476:         public static string ToSimpleTextString(Ia.Ftn.Cl.Models.ServiceRequestAdministrativeIssue serviceRequestAdministrativeIssue)
  477:         {
  478:             var sb = new StringBuilder();
  479:  
  480:             sb.AppendLine("Service: " + serviceRequestAdministrativeIssue.Service);
  481:  
  482:             var typeName = Ia.Ftn.Cl.Models.Business.ServiceRequestAdministrativeIssue.ServiceRequestAdministrativeIssueTypeList.Where(u => (int)u.DisconnectionType == serviceRequestAdministrativeIssue.Type).Select(u => u.Name).SingleOrDefault();
  483:             sb.AppendLine("Type: " + typeName);
  484:  
  485:             sb.AppendLine("Value: " + serviceRequestAdministrativeIssue.Value);
  486:  
  487:             return sb.ToString();
  488:         }
  489:  
  490:         ////////////////////////////////////////////////////////////////////////////
  491:         ////////////////////////////////////////////////////////////////////////////
  492:     }
  493:  
  494:     ////////////////////////////////////////////////////////////////////////////
  495:     ////////////////////////////////////////////////////////////////////////////
  496: }