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

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

SubParty support class for Nokia's Fixed Telecommunications Network (FTN) data model.

    1: using Microsoft.EntityFrameworkCore;
    2: using System;
    3: using System.Collections.Generic;
    4: using System.Linq;
    5:  
    6: namespace Ia.Ftn.Cl.Models.Data.Nokia
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     /// SubParty support class for Nokia's Fixed Telecommunications Network (FTN) data model.
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright � 2014-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   16:     /// </remarks> 
   17:     public class SubParty
   18:     {
   19:         public SubParty() { }
   20:  
   21:         ////////////////////////////////////////////////////////////////////////////
   22:  
   23:         /// <summary>
   24:         ///
   25:         /// </summary>
   26:         public static bool Create(Ia.Ftn.Cl.Models.Nokia.SubParty subParty, out string result)
   27:         {
   28:             bool b;
   29:  
   30:             b = false;
   31:             result = string.Empty;
   32:  
   33:             using (var db = new Ia.Ftn.Cl.Db())
   34:             {
   35:                 subParty.Created = subParty.Updated = DateTime.UtcNow.AddHours(3);
   36:  
   37:                 db.SubParties.Add(subParty);
   38:                 db.SaveChanges();
   39:  
   40:                 b = true;
   41:             }
   42:  
   43:             return b;
   44:         }
   45:  
   46:         ////////////////////////////////////////////////////////////////////////////
   47:  
   48:         /// <summary>
   49:         ///
   50:         /// </summary>
   51:         public static Ia.Ftn.Cl.Models.Nokia.SubParty Read(string id)
   52:         {
   53:             Ia.Ftn.Cl.Models.Nokia.SubParty subParty;
   54:  
   55:             using (var db = new Ia.Ftn.Cl.Db())
   56:             {
   57:                 subParty = (from sp in db.SubParties
   58:                             where sp.Id == id
   59:                             select sp).AsNoTracking().SingleOrDefault();
   60:             }
   61:  
   62:             return subParty;
   63:         }
   64:  
   65:         ////////////////////////////////////////////////////////////////////////////
   66:  
   67:         /// <summary>
   68:         ///
   69:         /// </summary>
   70:         public static List<Ia.Ftn.Cl.Models.Nokia.SubParty> ReadList()
   71:         {
   72:             List<Ia.Ftn.Cl.Models.Nokia.SubParty> subPartyList;
   73:  
   74:             using (var db = new Ia.Ftn.Cl.Db())
   75:             {
   76:                 subPartyList = (from sp in db.SubParties select sp).ToList();
   77:             }
   78:  
   79:             return subPartyList;
   80:         }
   81:  
   82:         ////////////////////////////////////////////////////////////////////////////
   83:  
   84:         /// <summary>
   85:         ///
   86:         /// </summary>
   87:         public static bool Update(Ia.Ftn.Cl.Models.Nokia.SubParty subParty, out string result)
   88:         {
   89:             bool b;
   90:  
   91:             b = false;
   92:             result = string.Empty;
   93:  
   94:             using (var db = new Ia.Ftn.Cl.Db())
   95:             {
   96:                 subParty = (from sp in db.SubParties where sp.Id == subParty.Id select sp).SingleOrDefault();
   97:  
   98:                 subParty.Updated = DateTime.UtcNow.AddHours(3);
   99:  
  100:                 db.SubParties.Attach(subParty);
  101:  
  102:                 db.Entry(subParty).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  103:                 db.SaveChanges();
  104:  
  105:                 b = true;
  106:             }
  107:  
  108:             return b;
  109:         }
  110:  
  111:         ////////////////////////////////////////////////////////////////////////////
  112:  
  113:         /// <summary>
  114:         ///
  115:         /// </summary>
  116:         public static bool Delete(string id, out string result)
  117:         {
  118:             bool b;
  119:  
  120:             b = false;
  121:             result = string.Empty;
  122:  
  123:             using (var db = new Ia.Ftn.Cl.Db())
  124:             {
  125:                 var v = (from sp in db.SubParties where sp.Id == id select sp).FirstOrDefault();
  126:  
  127:                 db.SubParties.Remove(v);
  128:                 db.SaveChanges();
  129:  
  130:                 b = true;
  131:             }
  132:  
  133:             return b;
  134:         }
  135:  
  136:         ////////////////////////////////////////////////////////////////////////////
  137:  
  138:         /// <summary>
  139:         /// Read list of service PBX numbers that have Category == "SERVICEBUNDLE2"
  140:         /// </summary>
  141:         public static List<string> ServicePbxList()
  142:         {
  143:             var servicePbxList = new List<string>();
  144:  
  145:             using (var db = new Ia.Ftn.Cl.Db())
  146:             {
  147:                 var list = (from sp in db.SubParties
  148:                             where sp.Category == "SERVICEBUNDLE2"
  149:                             select sp.PartyId).AsNoTracking().ToList();
  150:  
  151:                 if (list.Count > 0)
  152:                 {
  153:                     foreach (string s in list) servicePbxList.Add(Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(s));
  154:                 }
  155:             }
  156:  
  157:             return servicePbxList;
  158:         }
  159:  
  160:         ////////////////////////////////////////////////////////////////////////////
  161:  
  162:         /// <summary>
  163:         /// Read list of service Id PBX numbers that have Category == "SERVICEBUNDLE2"
  164:         /// </summary>
  165:         public static List<string> ServiceIdPbxList()
  166:         {
  167:             int serviceType;
  168:             string service, serviceId;
  169:             List<string> l1, l2;
  170:  
  171:             serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  172:             l1 = l2 = null;
  173:  
  174:             using (var db = new Ia.Ftn.Cl.Db())
  175:             {
  176:                 l1 = (from sp in db.SubParties where sp.Category == "SERVICEBUNDLE2" select sp.PartyId).ToList();
  177:  
  178:                 if (l1.Count > 0)
  179:                 {
  180:                     l2 = new List<string>(l1.Count);
  181:  
  182:                     foreach (string u in l1)
  183:                     {
  184:                         service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(u);
  185:  
  186:                         serviceId = Ia.Ftn.Cl.Models.Business.Service2.ServiceId(service, serviceType);
  187:  
  188:                         l2.Add(serviceId);
  189:                     }
  190:                 }
  191:             }
  192:  
  193:             return l2;
  194:         }
  195:  
  196:         ////////////////////////////////////////////////////////////////////////////
  197:  
  198:         /// <summary>
  199:         /// select PrimaryPUIDCPEProfileNumber, count(0) as Count from SubParties group by PrimaryPUIDCPEProfileNumber
  200:         /// </summary>
  201:         public static Dictionary<int, int> PrimaryPuidCpeProfileNumberCountDistributionDictionary
  202:         {
  203:             get
  204:             {
  205:                 Dictionary<int, int> dictionary;
  206:  
  207:                 using (var db = new Ia.Ftn.Cl.Db())
  208:                 {
  209:                     var v = (from sp in db.SubParties
  210:                              group sp by sp.PrimaryPUIDCPEProfileNumber into g
  211:                              select new { PrimaryPuidCpeProfileNumber = g.Key, Count = g.Count() }).AsNoTracking();
  212:  
  213:                     dictionary = v.ToDictionary(u => u.PrimaryPuidCpeProfileNumber, u => u.Count);
  214:                 }
  215:  
  216:                 return dictionary;
  217:             }
  218:         }
  219:  
  220:         ////////////////////////////////////////////////////////////////////////////
  221:  
  222:         /// <summary>
  223:         /// SIP numbers with AssocOtasRealm from SubParties
  224:         /// </summary>
  225:         public static Dictionary<string, string> SipNumberWithAssocOtasRealmList
  226:         {
  227:             get
  228:             {
  229:                 Dictionary<string, string> dictionary;
  230:  
  231:                 using (var db = new Ia.Ftn.Cl.Db())
  232:                 {
  233:                     var v = (from sp in db.SubParties where sp.PrimaryPUIDCPEProfileNumber == Ia.Ftn.Cl.Models.Business.Nokia.Ims.PrimaryPUIDCPEProfileNumberForSip select new { sp.DisplayName, sp.AssocOtasRealm });
  234:  
  235:                     dictionary = v.ToDictionary(u => u.DisplayName, u => u.AssocOtasRealm);
  236:                 }
  237:  
  238:                 return dictionary;
  239:             }
  240:         }
  241:  
  242:         ////////////////////////////////////////////////////////////////////////////
  243:         ////////////////////////////////////////////////////////////////////////////
  244:     }
  245:  
  246:     ////////////////////////////////////////////////////////////////////////////
  247:     ////////////////////////////////////////////////////////////////////////////
  248: }