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

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

Service Request Type support class of Fixed Telecommunications Network (FTN) business model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Data;
    4: using System.Globalization;
    5: using System.Linq;
    6:  
    7: namespace Ia.Ftn.Cl.Models.Business
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     /// Service Request Type support class of Fixed Telecommunications Network (FTN) business model.
   13:     /// </summary>
   14:     /// 
   15:     /// <remarks> 
   16:     /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   17:     /// </remarks> 
   18:     public class ServiceRequestType
   19:     {
   20:         /// <summary/>
   21:         public ServiceRequestType() { }
   22:  
   23:         ////////////////////////////////////////////////////////////////////////////    
   24:  
   25:         /// <summary>
   26:         ///
   27:         /// </summary>
   28:         public static string OracleSqlCommandForGivenDateTime(DateTime dateTime)
   29:         {
   30:             string sql;
   31:  
   32:             sql = @"select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID where REQ_DATE >= '" + dateTime.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + @"' and REQ_DATE < '" + dateTime.AddDays(1).ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) + @"' and SRV_REQ_FIPER_TECH.SRV_REQ_ID is not null and SRV_REQ_FIPER_TECH.TECH_TYPE_ID is not null and SRV_REQ_FIPER_TECH.VAL is not null order by SRV_REQ_FIPER.SRV_REQ_ID asc";
   33:  
   34:             return sql;
   35:         }
   36:  
   37:         ////////////////////////////////////////////////////////////////////////////    
   38:  
   39:         /// <summary>
   40:         ///
   41:         /// </summary>
   42:         public static string OracleSqlCommandForServiceRequestIdRange(Tuple<int, int> startEndRange)
   43:         {
   44:             return OracleSqlCommandForServiceRequestIdRange(startEndRange.Item1, startEndRange.Item2);
   45:         }
   46:  
   47:         ////////////////////////////////////////////////////////////////////////////    
   48:  
   49:         /// <summary>
   50:         ///
   51:         /// </summary>
   52:         public static string OracleSqlCommandForServiceRequestIdRange(int start, int end)
   53:         {
   54:             string sql;
   55:  
   56:             sql = @"select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID where SRV_REQ_FIPER_TECH.SRV_REQ_ID >= " + start + " and SRV_REQ_FIPER_TECH.SRV_REQ_ID <= " + end + " and SRV_REQ_FIPER_TECH.SRV_REQ_ID is not null and SRV_REQ_FIPER_TECH.TECH_TYPE_ID is not null and SRV_REQ_FIPER_TECH.VAL is not null order by SRV_REQ_FIPER.SRV_REQ_ID asc";
   57:  
   58:             return sql;
   59:         }
   60:  
   61:         ////////////////////////////////////////////////////////////////////////////    
   62:  
   63:         /// <summary>
   64:         ///
   65:         /// </summary>
   66:         public static string OracleSqlCommandForServiceRequestByService(string service)
   67:         {
   68:             string sql;
   69:  
   70:             if (!string.IsNullOrEmpty(service))
   71:             {
   72:                 sql = @"select SRV_REQ_FIPER_TECH.SRV_REQ_ID, SRV_REQ_FIPER_TECH.TECH_TYPE_ID, SRV_REQ_FIPER_TECH.VAL from SRV_REQ_FIPER 
   73: left outer join SRV_REQ_FIPER_TECH on SRV_REQ_FIPER_TECH.SRV_REQ_ID = SRV_REQ_FIPER.SRV_REQ_ID 
   74: where SRV_REQ_FIPER.SRV_NO = " + service + @" and SRV_REQ_FIPER_TECH.SRV_REQ_ID is not null and SRV_REQ_FIPER_TECH.TECH_TYPE_ID is not null and SRV_REQ_FIPER_TECH.VAL is not null 
   75: order by SRV_REQ_FIPER.SRV_REQ_ID asc";
   76:             }
   77:             else sql = string.Empty;
   78:  
   79:             return sql;
   80:         }
   81:  
   82:         ////////////////////////////////////////////////////////////////////////////
   83:  
   84:         /// <summary>
   85:         ///
   86:         /// </summary>
   87:         public static List<int> ChangedNumberList()
   88:         {
   89:             List<int> numberList;
   90:             List<string> stringNumberList;
   91:  
   92:             numberList = new List<int>();
   93:  
   94:             using (var db = new Ia.Ftn.Cl.Db())
   95:             {
   96:                 stringNumberList = (from srt in db.ServiceRequestTypes where srt.TypeId == 11 select srt.Value).ToList();
   97:             }
   98:  
   99:             if (stringNumberList.Count > 0)
  100:             {
  101:                 foreach (string u in stringNumberList)
  102:                 {
  103:                     if (int.TryParse(u, out int i)) numberList.Add(i);
  104:                 }
  105:             }
  106:             else
  107:             {
  108:             }
  109:  
  110:             return numberList;
  111:         }
  112:  
  113:         ////////////////////////////////////////////////////////////////////////////
  114:  
  115:         /// <summary>
  116:         ///
  117:         /// </summary>
  118:         public static List<int> ChangedNumberList(List<Ia.Ftn.Cl.Models.ServiceRequestType> serviceRequestTypeList)
  119:         {
  120:             List<int> numberList;
  121:             List<string> stringNumberList;
  122:  
  123:             if (serviceRequestTypeList.Count > 0)
  124:             {
  125:                 stringNumberList = (from srt in serviceRequestTypeList where srt.TypeId == 11 select srt.Value).ToList();
  126:  
  127:                 if (stringNumberList.Count > 0)
  128:                 {
  129:                     numberList = new List<int>();
  130:  
  131:                     foreach (string u in stringNumberList)
  132:                     {
  133:                         if (int.TryParse(u, out int i)) numberList.Add(i);
  134:                     }
  135:                 }
  136:                 else numberList = new List<int>();
  137:             }
  138:             else numberList = new List<int>();
  139:  
  140:             return numberList;
  141:         }
  142:  
  143:         ////////////////////////////////////////////////////////////////////////////
  144:  
  145:         /// <summary>
  146:         ///
  147:         /// </summary>
  148:         public static Ia.Ftn.Cl.Models.Access ExtractAccess(int serviceRequestId, List<Ia.Ftn.Cl.Models.ServiceRequestType> serviceRequestTypeList)
  149:         {
  150:             Ia.Ftn.Cl.Models.Access access;
  151:             List<Ia.Ftn.Cl.Models.ServiceRequestType> subtypeSrtList;
  152:  
  153:             if (serviceRequestTypeList.Count > 0)
  154:             {
  155:                 subtypeSrtList = (from srt in serviceRequestTypeList
  156:                                   where srt.ServiceRequest.Id == serviceRequestId
  157:                                   select srt).ToList();
  158:  
  159:                 access = ExtractAccess(subtypeSrtList);
  160:             }
  161:             else access = null;
  162:  
  163:             return access;
  164:         }
  165:  
  166:         ////////////////////////////////////////////////////////////////////////////
  167:  
  168:         /// <summary>
  169:         ///
  170:         /// </summary>
  171:         private static Ia.Ftn.Cl.Models.Access ExtractAccess(List<Ia.Ftn.Cl.Models.ServiceRequestType> serviceRequestTypeList)
  172:         {
  173:             Dictionary<int, string> typeDictionary;
  174:             Ia.Ftn.Cl.Models.Access access;
  175:  
  176:             typeDictionary = TypeDictionary(serviceRequestTypeList);
  177:  
  178:             var nddOnt = Ia.Ftn.Cl.Models.Business.Default.NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(typeDictionary);
  179:  
  180:             access = (nddOnt != null) ? Ia.Ftn.Cl.Models.Data.Access.Read(nddOnt.Pon.PonGroup.Olt.Id, nddOnt.Pon.Number, nddOnt.Number) : null;
  181:  
  182:             return access;
  183:         }
  184:  
  185:         ////////////////////////////////////////////////////////////////////////////
  186:  
  187:         /// <summary>
  188:         ///
  189:         /// </summary>
  190:         public static Ia.Ftn.Cl.Models.Access ExtractAccess(Db db, string value)
  191:         {
  192:             Dictionary<int, string> typeDictionary;
  193:             Ia.Ftn.Cl.Models.Access access;
  194:  
  195:             typeDictionary = new Dictionary<int, string>(1);
  196:             typeDictionary.Add(1, value);
  197:  
  198:             var nddOnt = Ia.Ftn.Cl.Models.Business.Default.NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromDictionaryValueList(typeDictionary);
  199:  
  200:             access = Ia.Ftn.Cl.Models.Data.Access.Read(db, nddOnt.Pon.PonGroup.Olt.Id, nddOnt.Pon.Number, nddOnt.Number);
  201:  
  202:             return access;
  203:         }
  204:  
  205:         ////////////////////////////////////////////////////////////////////////////
  206:  
  207:         /// <summary>
  208:         ///
  209:         /// </summary>
  210:         public static Dictionary<int, string> TypeDictionary(List<Ia.Ftn.Cl.Models.ServiceRequestType> serviceRequestTypeList)
  211:         {
  212:             Dictionary<int, string> typeDictionary;
  213:  
  214:             typeDictionary = new Dictionary<int, string>(63); // <serviceRequestType> <typeList> <type> has about 63 types max
  215:  
  216:             foreach (Ia.Ftn.Cl.Models.ServiceRequestType serviceRequestType in serviceRequestTypeList)
  217:             {
  218:                 typeDictionary.Add(serviceRequestType.TypeId, serviceRequestType.Value);
  219:             }
  220:  
  221:             return typeDictionary;
  222:         }
  223:  
  224:         ////////////////////////////////////////////////////////////////////////////    
  225:         ////////////////////////////////////////////////////////////////////////////    
  226:     }
  227:  
  228:     ////////////////////////////////////////////////////////////////////////////
  229:     ////////////////////////////////////////////////////////////////////////////
  230: }