)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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:     ///
   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.Models.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.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.Models.Nokia.SubParty Read(string id)
   62:         {
   63:             Ia.Ftn.Cl.Models.Nokia.SubParty subParty;
   64:  
   65:             using (var db = new Ia.Ftn.Cl.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.Models.Nokia.SubParty> ReadList()
   81:         {
   82:             List<Ia.Ftn.Cl.Models.Nokia.SubParty> subPartyList;
   83:  
   84:             using (var db = new Ia.Ftn.Cl.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.Models.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.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.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:             var servicePbxList = new List<string>();
  154:  
  155:             using (var db = new Ia.Ftn.Cl.Db())
  156:             {
  157:                 var list = (from sp in db.SubParties
  158:                             where sp.Category == "SERVICEBUNDLE2"
  159:                             select sp.PartyId).AsNoTracking().ToList();
  160:  
  161:                 if (list.Count > 0)
  162:                 {
  163:                     foreach (string s in list) servicePbxList.Add(Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(s));
  164:                 }
  165:             }
  166:  
  167:             return servicePbxList;
  168:         }
  169:  
  170:         ////////////////////////////////////////////////////////////////////////////
  171:  
  172:         /// <summary>
  173:         /// Read list of service Id PBX numbers that have Category == "SERVICEBUNDLE2"
  174:         /// </summary>
  175:         public static List<string> ServiceIdPbxList()
  176:         {
  177:             int serviceType;
  178:             string service, serviceId;
  179:             List<string> l1, l2;
  180:  
  181:             serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  182:             l1 = l2 = null;
  183:  
  184:             using (var db = new Ia.Ftn.Cl.Db())
  185:             {
  186:                 l1 = (from sp in db.SubParties where sp.Category == "SERVICEBUNDLE2" select sp.PartyId).ToList();
  187:  
  188:                 if (l1.Count > 0)
  189:                 {
  190:                     l2 = new List<string>(l1.Count);
  191:  
  192:                     foreach (string u in l1)
  193:                     {
  194:                         service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(u);
  195:  
  196:                         serviceId = Ia.Ftn.Cl.Models.Business.Service2.ServiceId(service, serviceType);
  197:  
  198:                         l2.Add(serviceId);
  199:                     }
  200:                 }
  201:             }
  202:  
  203:             return l2;
  204:         }
  205:  
  206:         ////////////////////////////////////////////////////////////////////////////
  207:  
  208:         /// <summary>
  209:         /// select PrimaryPUIDCPEProfileNumber, count(0) as Count from SubParties group by PrimaryPUIDCPEProfileNumber
  210:         /// </summary>
  211:         public static Dictionary<int, int> PrimaryPuidCpeProfileNumberCountDistributionDictionary
  212:         {
  213:             get
  214:             {
  215:                 Dictionary<int, int> dictionary;
  216:  
  217:                 using (var db = new Ia.Ftn.Cl.Db())
  218:                 {
  219:                     var v = (from sp in db.SubParties
  220:                              group sp by sp.PrimaryPUIDCPEProfileNumber into g
  221:                              select new { PrimaryPuidCpeProfileNumber = g.Key, Count = g.Count() }).AsNoTracking();
  222:  
  223:                     dictionary = v.ToDictionary(u => u.PrimaryPuidCpeProfileNumber, u => u.Count);
  224:                 }
  225:  
  226:                 return dictionary;
  227:             }
  228:         }
  229:  
  230:         ////////////////////////////////////////////////////////////////////////////
  231:  
  232:         /// <summary>
  233:         /// SIP numbers with AssocOtasRealm from SubParties
  234:         /// </summary>
  235:         public static Dictionary<string, string> SipNumberWithAssocOtasRealmList
  236:         {
  237:             get
  238:             {
  239:                 Dictionary<string, string> dictionary;
  240:  
  241:                 using (var db = new Ia.Ftn.Cl.Db())
  242:                 {
  243:                     var v = (from sp in db.SubParties where sp.PrimaryPUIDCPEProfileNumber == Ia.Ftn.Cl.Models.Business.Nokia.Ims.PrimaryPUIDCPEProfileNumberForSip select new { sp.DisplayName, sp.AssocOtasRealm });
  244:  
  245:                     dictionary = v.ToDictionary(u => u.DisplayName, u => u.AssocOtasRealm);
  246:                 }
  247:  
  248:                 return dictionary;
  249:             }
  250:         }
  251:  
  252:         ////////////////////////////////////////////////////////////////////////////
  253:         ////////////////////////////////////////////////////////////////////////////
  254:     }
  255:  
  256:     ////////////////////////////////////////////////////////////////////////////
  257:     ////////////////////////////////////////////////////////////////////////////
  258: }