)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Skip Navigation LinksHome » Code Library » ServiceInitialState

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

Service Initial State Framework 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.ComponentModel.DataAnnotations;
    6: using System.ComponentModel.DataAnnotations.Schema;
    7: using System.Data;
    8: using System.Data.Entity;
    9: using EntityFramework.Triggers;
   10:  
   11: namespace Ia.Ngn.Cl.Model.Data
   12: {
   13:     ////////////////////////////////////////////////////////////////////////////
   14:  
   15:     /// <summary publish="true">
   16:     /// Service Initial State Framework class for Next Generation Network (NGN) data model.
   17:     /// </summary>
   18:     /// 
   19:     /// <remarks> 
   20:     /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   21:     ///
   22:     /// 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
   23:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   24:     ///
   25:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   26:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   27:     /// 
   28:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   29:     /// 
   30:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   31:     /// </remarks> 
   32:     public partial class ServiceInitialState
   33:     {
   34:         ////////////////////////////////////////////////////////////////////////////
   35:  
   36:         /// <summary>
   37:         /// Read service using id
   38:         /// </summary>
   39:         public static Ia.Ngn.Cl.Model.ServiceInitialState Read(string id)
   40:         {
   41:             Ia.Ngn.Cl.Model.ServiceInitialState serviceInitialState;
   42:  
   43:             using (var db = new Ia.Ngn.Cl.Model.Ngn())
   44:             {
   45:                 serviceInitialState = (from s in db.ServiceInitialStates where s.Id == id select s).SingleOrDefault();
   46:             }
   47:  
   48:             return serviceInitialState;
   49:         }
   50:  
   51:         ////////////////////////////////////////////////////////////////////////////
   52:  
   53:         /// <summary>
   54:         /// Read service of a number
   55:         /// </summary>
   56:         public static Ia.Ngn.Cl.Model.ServiceInitialState Read(long number)
   57:         {
   58:             Ia.Ngn.Cl.Model.ServiceInitialState serviceInitialState;
   59:  
   60:             using (var db = new Ia.Ngn.Cl.Model.Ngn())
   61:             {
   62:                 serviceInitialState = (from s in db.ServiceInitialStates where s.Service == number.ToString() select s).SingleOrDefault();
   63:             }
   64:  
   65:             return serviceInitialState;
   66:         }
   67:  
   68:         ////////////////////////////////////////////////////////////////////////////
   69:  
   70:         /// <summary>
   71:         /// Read all services for a number list
   72:         /// </summary>
   73:         public static List<Ia.Ngn.Cl.Model.ServiceInitialState> ReadList(List<int> numberList)
   74:         {
   75:             long i;
   76:             long[] sp;
   77:             List<Ia.Ngn.Cl.Model.ServiceInitialState> serviceInitialStateList;
   78:  
   79:             i = 0;
   80:             sp = new long[numberList.Count];
   81:  
   82:             foreach (long l in numberList) sp[i++] = l;
   83:  
   84:             using (var db = new Ia.Ngn.Cl.Model.Ngn())
   85:             {
   86:                 //serviceList = (from q in db.Services where dnList.Contains(q.DN) select q).ToList();
   87:  
   88:                 // var pages = context.Pages.Where(x => keys.Any(key => x.Title.Contains(key)));
   89:                 serviceInitialStateList = db.ServiceInitialStates.Where(q => sp.Any(v => q.Service == v.ToString())).ToList();
   90:             }
   91:  
   92:             return serviceInitialStateList;
   93:         }
   94:  
   95:         ////////////////////////////////////////////////////////////////////////////
   96:  
   97:         /// <summary>
   98:         /// Delete record if equivalent service request service entry exists 
   99:         /// </summary>
  100:         public static void DeleteIfServiceRequestServiceExistsList(List<Ia.Ngn.Cl.Model.ServiceRequestService> serviceRequestServiceList, out string result)
  101:         {
  102:             int readItemCount, existingItemCount, deletedItemCount;
  103:             Ia.Ngn.Cl.Model.ServiceInitialState serviceInitialState;
  104:  
  105:             readItemCount = existingItemCount = deletedItemCount = 0;
  106:             result = string.Empty;
  107:  
  108:             readItemCount = serviceRequestServiceList.Count;
  109:  
  110:             if (serviceRequestServiceList.Count > 0)
  111:             {
  112:                 using (var db = new Ia.Ngn.Cl.Model.Ngn())
  113:                 {
  114:                     foreach (Ia.Ngn.Cl.Model.ServiceRequestService srs in serviceRequestServiceList)
  115:                     {
  116:                         serviceInitialState = (from s in db.ServiceInitialStates where s.Service == srs.Service select s).SingleOrDefault();
  117:  
  118:                         if (serviceInitialState != null)
  119:                         {
  120:                             db.ServiceInitialStates.Remove(serviceInitialState);
  121:  
  122:                             deletedItemCount++;
  123:                         }
  124:                     }
  125:  
  126:                     db.SaveChanges();
  127:                 }
  128:  
  129:                 result = "(" + readItemCount + "/?/" + deletedItemCount + ") ";
  130:             }
  131:             else
  132:             {
  133:             }
  134:         }
  135:  
  136:         ////////////////////////////////////////////////////////////////////////////
  137:         ////////////////////////////////////////////////////////////////////////////
  138:     }
  139:  
  140:     ////////////////////////////////////////////////////////////////////////////
  141:     ////////////////////////////////////////////////////////////////////////////
  142: }