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

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

Cache support class for the Next Generation Network data model

    1: using System.Data;
    2: using System.Linq;
    3: using System.Collections.Generic;
    4: using Microsoft.EntityFrameworkCore;
    5: using System.Diagnostics;
    6: using System;
    7:  
    8: namespace Ia.Ngn.Cl.Model.Data.Maintenance
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     /// Cache support class for the Next Generation Network data model
   14:     /// </summary>
   15:     /// 
   16:     /// <remarks> 
   17:     /// Copyright © 2006-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 Cache
   30:     {
   31:         private static Ia.Cl.Models.TimestampedList<string> serviceIdTimestampedList = new Ia.Cl.Models.TimestampedList<string>();
   32:  
   33:         private static readonly object objectLock = new object();
   34:  
   35:         ////////////////////////////////////////////////////////////////////////////
   36:  
   37:         /// <summary>
   38:         ///
   39:         /// </summary>
   40:         public Cache() { }
   41:  
   42:         ////////////////////////////////////////////////////////////////////////////
   43:  
   44:         /// <summary>
   45:         ///
   46:         /// </summary>
   47:         public static Ia.Cl.Models.TimestampedList<string> ServiceIdTimestampedList
   48:         {
   49:             get
   50:             {
   51:                 lock (objectLock)
   52:                 {
   53:                     if (serviceIdTimestampedList.Timestamp <= Ia.Ngn.Cl.Model.Service2.LastCreateUpdateDelete || serviceIdTimestampedList.List.Count == 0)
   54:                     {
   55:                         using (var db = new Ia.Ngn.Cl.Model.Ngn())
   56:                         {
   57:                             serviceIdTimestampedList.List = (from s in db.Service2
   58:                                                              select s.Id).AsNoTracking().ToList();
   59:  
   60:                             serviceIdTimestampedList.Timestamp = DateTime.UtcNow.AddHours(3);
   61:                         }
   62:                     }
   63:  
   64:                     return serviceIdTimestampedList;
   65:                 }
   66:             }
   67:         }
   68:  
   69:         ////////////////////////////////////////////////////////////////////////////
   70:         ////////////////////////////////////////////////////////////////////////////   
   71:     }
   72:  
   73:     ////////////////////////////////////////////////////////////////////////////
   74:     ////////////////////////////////////////////////////////////////////////////   
   75: }