)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » SubParty (Ia.Ftn.Cl.Model.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.Model.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:     ///
   17:     /// 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
   18:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   19:     ///
   20:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   22:     /// 
   23:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   24:     /// 
   25:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   26:     /// </remarks> 
   27:     public class SubParty
   28:     {
   29:         public SubParty() { }
   30:  
   31:         ////////////////////////////////////////////////////////////////////////////
   32:  
   33:         /// <summary>
   34:         ///
   35:         /// </summary>
   36:         public static bool Create(Ia.Ftn.Cl.Model.Nokia.SubParty subParty, out string result)
   37:         {
   38:             bool b;
   39:  
   40:             b = false;
   41:             result = string.Empty;
   42:  
   43:             using (var db = new Ia.Ftn.Cl.Model.Db())
   44:             {
   45:                 subParty.Created = subParty.Updated = DateTime.UtcNow.AddHours(3);
   46:  
   47:                 db.SubParties.Add(subParty);
   48:                 db.SaveChanges();
   49:  
   50:                 b = true;
   51:             }
   52:  
   53:             return b;
   54:         }
   55:  
   56:         ////////////////////////////////////////////////////////////////////////////
   57:  
   58:         /// <summary>
   59:         ///
   60:         /// </summary>
   61:         public static Ia.Ftn.Cl.Model.Nokia.SubParty Read(string id)
   62:         {
   63:             Ia.Ftn.Cl.Model.Nokia.SubParty subParty;
   64:  
   65:             using (var db = new Ia.Ftn.Cl.Model.Db())
   66:             {
   67:                 subParty = (from sp in db.SubParties 
   68:                             where sp.Id == id 
   69:                             select sp).AsNoTracking().SingleOrDefault();
   70:             }
   71:  
   72:             return subParty;
   73:         }
   74:  
   75:         ////////////////////////////////////////////////////////////////////////////
   76:  
   77:         /// <summary>
   78:         ///
   79:         /// </summary>
   80:         public static List<Ia.Ftn.Cl.Model.Nokia.SubParty> ReadList()
   81:         {
   82:             List<Ia.Ftn.Cl.Model.Nokia.SubParty> subPartyList;
   83:  
   84:             using (var db = new Ia.Ftn.Cl.Model.Db())
   85:             {
   86:                 subPartyList = (from sp in db.SubParties select sp).ToList();
   87:             }
   88:  
   89:             return subPartyList;
   90:         }
   91:  
   92:         ////////////////////////////////////////////////////////////////////////////
   93:  
   94:         /// <summary>
   95:         ///
   96:         /// </summary>
   97:         public static bool Update(Ia.Ftn.Cl.Model.Nokia.SubParty subParty, out string result)
   98:         {
   99:             bool b;
  100:  
  101:             b = false;
  102:             result = string.Empty;
  103:  
  104:             using (var db = new Ia.Ftn.Cl.Model.Db())
  105:             {
  106:                 subParty = (from sp in db.SubParties where sp.Id == subParty.Id select sp).SingleOrDefault();
  107:  
  108:                 subParty.Updated = DateTime.UtcNow.AddHours(3);
  109:  
  110:                 db.SubParties.Attach(subParty);
  111:  
  112:                 db.Entry(subParty).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  113:                 db.SaveChanges();
  114:  
  115:                 b = true;
  116:             }
  117:  
  118:             return b;
  119:         }
  120:  
  121:         ////////////////////////////////////////////////////////////////////////////
  122:  
  123:         /// <summary>
  124:         ///
  125:         /// </summary>
  126:         public static bool Delete(string id, out string result)
  127:         {
  128:             bool b;
  129:  
  130:             b = false;
  131:             result = string.Empty;
  132:  
  133:             using (var db = new Ia.Ftn.Cl.Model.Db())
  134:             {
  135:                 var v = (from sp in db.SubParties where sp.Id == id select sp).FirstOrDefault();
  136:  
  137:                 db.SubParties.Remove(v);
  138:                 db.SaveChanges();
  139:  
  140:                 b = true;
  141:             }
  142:  
  143:             return b;
  144:         }
  145:  
  146:         ////////////////////////////////////////////////////////////////////////////
  147:  
  148:         /// <summary>
  149:         /// Read list of service PBX numbers that have Category == "SERVICEBUNDLE2"
  150:         /// </summary>
  151:         public static List<string> ServicePbxList()
  152:         {
  153:             List<string> l1, l2;
  154:  
  155:             l1 = l2 = null;
  156:  
  157:             using (var db = new Ia.Ftn.Cl.Model.Db())
  158:             {
  159:                 l1 = (from sp in db.SubParties 
  160:                       where sp.Category == "SERVICEBUNDLE2" 
  161:                       select sp.PartyId).AsNoTracking().ToList();
  162:  
  163:                 if (l1.Count > 0)
  164:                 {
  165:                     l2 = new List<string>(l1.Count);
  166:  
  167:                     foreach (string s in l1) l2.Add(Ia.Ftn.Cl.Model.Business.NumberFormatConverter.Service(s));
  168:                 }
  169:             }
  170:  
  171:             return l2;
  172:         }
  173:  
  174:         ////////////////////////////////////////////////////////////////////////////
  175:  
  176:         /// <summary>
  177:         /// Read list of service Id PBX numbers that have Category == "SERVICEBUNDLE2"
  178:         /// </summary>
  179:         public static List<string> ServiceIdPbxList()
  180:         {
  181:             int serviceType;
  182:             string service, serviceId;
  183:             List<string> l1, l2;
  184:  
  185:             serviceType = Ia.Ftn.Cl.Model.Business.Service.ServiceType.ImsService;
  186:             l1 = l2 = null;
  187:  
  188:             using (var db = new Ia.Ftn.Cl.Model.Db())
  189:             {
  190:                 l1 = (from sp in db.SubParties where sp.Category == "SERVICEBUNDLE2" select sp.PartyId).ToList();
  191:  
  192:                 if (l1.Count > 0)
  193:                 {
  194:                     l2 = new List<string>(l1.Count);
  195:  
  196:                     foreach (string u in l1)
  197:                     {
  198:                         service = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.Service(u);
  199:  
  200:                         serviceId = Ia.Ftn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
  201:  
  202:                         l2.Add(serviceId);
  203:                     }
  204:                 }
  205:             }
  206:  
  207:             return l2;
  208:         }
  209:  
  210:         ////////////////////////////////////////////////////////////////////////////
  211:  
  212:         /// <summary>
  213:         /// select PrimaryPUIDCPEProfileNumber, count(0) as Count from SubParties group by PrimaryPUIDCPEProfileNumber
  214:         /// </summary>
  215:         public static Dictionary<int, int> PrimaryPuidCpeProfileNumberCountDistributionDictionary
  216:         {
  217:             get
  218:             {
  219:                 Dictionary<int, int> dictionary;
  220:  
  221:                 using (var db = new Ia.Ftn.Cl.Model.Db())
  222:                 {
  223:                     var v = (from sp in db.SubParties 
  224:                              group sp by sp.PrimaryPUIDCPEProfileNumber into g 
  225:                              select new { PrimaryPuidCpeProfileNumber = g.Key, Count = g.Count() }).AsNoTracking();
  226:  
  227:                     dictionary = v.ToDictionary(u => u.PrimaryPuidCpeProfileNumber, u => u.Count);
  228:                 }
  229:  
  230:                 return dictionary;
  231:             }
  232:         }
  233:  
  234:         ////////////////////////////////////////////////////////////////////////////
  235:  
  236:         /// <summary>
  237:         /// SIP numbers with AssocOtasRealm from SubParties
  238:         /// </summary>
  239:         public static Dictionary<string, string> SipNumberWithAssocOtasRealmList
  240:         {
  241:             get
  242:             {
  243:                 Dictionary<string, string> dictionary;
  244:  
  245:                 using (var db = new Ia.Ftn.Cl.Model.Db())
  246:                 {
  247:                     var v = (from sp in db.SubParties where sp.PrimaryPUIDCPEProfileNumber == Ia.Ftn.Cl.Model.Business.Nokia.Ims.PrimaryPUIDCPEProfileNumberForSip select new { sp.DisplayName, sp.AssocOtasRealm });
  248:  
  249:                     dictionary = v.ToDictionary(u => u.DisplayName, u => u.AssocOtasRealm);
  250:                 }
  251:  
  252:                 return dictionary;
  253:             }
  254:         }
  255:  
  256:         ////////////////////////////////////////////////////////////////////////////
  257:         ////////////////////////////////////////////////////////////////////////////
  258:     }
  259:  
  260:     ////////////////////////////////////////////////////////////////////////////
  261:     ////////////////////////////////////////////////////////////////////////////
  262: }