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

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

    1: using Microsoft.AspNetCore.Mvc.Rendering;
    2:  
    3: namespace Ia.Ftn.Wa.Models.Administration
    4: {
    5:     ////////////////////////////////////////////////////////////////////////////
    6:  
    7:     /// <summary publish="true">
    8:     ///
    9:     /// </summary>
   10:     /// 
   11:     /// <remarks> 
   12:     /// Copyright � 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   13:     ///
   14:     /// 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
   15:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   16:     ///
   17:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   18:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   19:     /// 
   20:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   21:     /// 
   22:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   23:     /// </remarks> 
   24:     public class AccessNetwork
   25:     {
   26:         ////////////////////////////////////////////////////////////////////////////
   27:  
   28:         /// <summary>
   29:         ///
   30:         /// </summary>
   31:         public static void ViewModel(ref Ia.Ftn.Wa.Models.Administration.AccessNetworkViewModel currentAccessNetworkViewModel, ref Ia.Ftn.Wa.Models.Administration.AccessNetworkViewModel accessNetworkViewModel)
   32:         {
   33:             CompareCurrentAndNewViewModels(ref currentAccessNetworkViewModel, ref accessNetworkViewModel);
   34:  
   35:             var list = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList;
   36:  
   37:             if (!string.IsNullOrEmpty(accessNetworkViewModel.SiteSelectedValue))
   38:             {
   39:                 accessNetworkViewModel.SiteSelectList = new SelectList(list, "Id", "NameArabicName", accessNetworkViewModel.SiteSelectedValue);
   40:             }
   41:             else
   42:             {
   43:                 accessNetworkViewModel.SiteSelectList = new SelectList(list, "Id", "NameArabicName", list[0].Id.ToString());
   44:                 accessNetworkViewModel.SiteSelectedValue = list[0].Id.ToString();
   45:             }
   46:  
   47:             OdfSelectList(ref accessNetworkViewModel);
   48:  
   49:             currentAccessNetworkViewModel.SiteSelectedValue = accessNetworkViewModel.SiteSelectedValue;
   50:             currentAccessNetworkViewModel.OdfSelectedValue = accessNetworkViewModel.OdfSelectedValue;
   51:             currentAccessNetworkViewModel.OltSelectedValue = accessNetworkViewModel.OltSelectedValue;
   52:             currentAccessNetworkViewModel.PonSelectedValue = accessNetworkViewModel.PonSelectedValue;
   53:         }
   54:  
   55:         ////////////////////////////////////////////////////////////////////////////
   56:  
   57:         /// <summary>
   58:         ///
   59:         /// </summary>
   60:         private static void OdfSelectList(ref Ia.Ftn.Wa.Models.Administration.AccessNetworkViewModel accessNetworkViewModel)
   61:         {
   62:             if (accessNetworkViewModel.SiteSelectList.Count() > 0)
   63:             {
   64:                 if (!string.IsNullOrEmpty(accessNetworkViewModel.SiteSelectedValue))
   65:                 {
   66:                     var siteId = int.Parse(accessNetworkViewModel.SiteSelectedValue);
   67:  
   68:                     var list = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OdfList where o.Router.Site.Id == siteId select o).ToList();
   69:  
   70:                     if (list.Count > 0)
   71:                     {
   72:                         if (!string.IsNullOrEmpty(accessNetworkViewModel.OdfSelectedValue))
   73:                         {
   74:                             accessNetworkViewModel.OdfSelectList = new SelectList(list, "Id", "Name", accessNetworkViewModel.OdfSelectedValue);
   75:                         }
   76:                         else
   77:                         {
   78:                             accessNetworkViewModel.OdfSelectList = new SelectList(list, "Id", "Name", list[0].Id.ToString());
   79:                             accessNetworkViewModel.OdfSelectedValue = list[0].Id.ToString();
   80:                         }
   81:  
   82:                         OltSelectList(ref accessNetworkViewModel);
   83:                     }
   84:                 }
   85:             }
   86:         }
   87:  
   88:         ////////////////////////////////////////////////////////////////////////////
   89:  
   90:         /// <summary>
   91:         ///
   92:         /// </summary>
   93:         private static void OltSelectList(ref Ia.Ftn.Wa.Models.Administration.AccessNetworkViewModel accessNetworkViewModel)
   94:         {
   95:             if (accessNetworkViewModel.OdfSelectList.Count() > 0)
   96:             {
   97:                 if (!string.IsNullOrEmpty(accessNetworkViewModel.OdfSelectedValue))
   98:                 {
   99:                     var odfId = int.Parse(accessNetworkViewModel.OdfSelectedValue);
  100:  
  101:                     var list = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OltList where o.Odf != null && o.Odf.Id == odfId select new { Value = o.Id, Text = o.Symbol + " (" + o.AmsName + ")" }).ToList();
  102:  
  103:                     if (list.Count > 0)
  104:                     {
  105:                         if (!string.IsNullOrEmpty(accessNetworkViewModel.OltSelectedValue))
  106:                         {
  107:                             accessNetworkViewModel.OltSelectList = new SelectList(list, "Value", "Text", accessNetworkViewModel.OltSelectedValue);
  108:                         }
  109:                         else
  110:                         {
  111:                             accessNetworkViewModel.OltSelectList = new SelectList(list, "Value", "Text", list[0].Value.ToString());
  112:                             accessNetworkViewModel.OltSelectedValue = list[0].Value.ToString();
  113:                         }
  114:  
  115:                         PonSelectList(ref accessNetworkViewModel);
  116:                     }
  117:                 }
  118:             }
  119:         }
  120:  
  121:         ////////////////////////////////////////////////////////////////////////////
  122:  
  123:         /// <summary>
  124:         ///
  125:         /// </summary>
  126:         private static void PonSelectList(ref Ia.Ftn.Wa.Models.Administration.AccessNetworkViewModel accessNetworkViewModel)
  127:         {
  128:             if (accessNetworkViewModel.OltSelectList.Count() > 0)
  129:             {
  130:                 if (!string.IsNullOrEmpty(accessNetworkViewModel.OltSelectedValue))
  131:                 {
  132:                     var oltId = int.Parse(accessNetworkViewModel.OltSelectedValue);
  133:  
  134:                     var list = (from p in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.PonList where p.PonGroup.Olt.Id == oltId select p).ToList();
  135:  
  136:                     if (list.Count > 0)
  137:                     {
  138:                         if (!string.IsNullOrEmpty(accessNetworkViewModel.PonSelectedValue))
  139:                         {
  140:                             accessNetworkViewModel.PonSelectList = new SelectList(list, "Id", "Number", accessNetworkViewModel.PonSelectedValue);
  141:                         }
  142:                         else
  143:                         {
  144:                             accessNetworkViewModel.PonSelectList = new SelectList(list, "Id", "Number", list[0].Id.ToString());
  145:                             accessNetworkViewModel.PonSelectedValue = list[0].Id.ToString();
  146:                         }
  147:  
  148:                         OntSelectList(ref accessNetworkViewModel);
  149:                     }
  150:                 }
  151:             }
  152:         }
  153:  
  154:         ////////////////////////////////////////////////////////////////////////////
  155:  
  156:         /// <summary>
  157:         ///
  158:         /// </summary>
  159:         private static void OntSelectList(ref Ia.Ftn.Wa.Models.Administration.AccessNetworkViewModel accessNetworkViewModel)
  160:         {
  161:             List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont> ontList;
  162:  
  163:             if (accessNetworkViewModel.PonSelectList.Count() > 0)
  164:             {
  165:                 if (!string.IsNullOrEmpty(accessNetworkViewModel.PonSelectedValue))
  166:                 {
  167:                     var ponId = accessNetworkViewModel.PonSelectedValue;
  168:  
  169:                     ontList = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntList where o.Pon.Id == ponId select o).ToList();
  170:  
  171:                     var ontText = string.Empty;
  172:  
  173:                     foreach (Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont ont in ontList)
  174:                     {
  175:                         ontText += ont.Access.Name.PadRight(11, ' ') + "    " + ont.Position.PadRight(15, ' ') + "    " + ont.Ip + "   " + "\n";
  176:                     }
  177:  
  178:                     accessNetworkViewModel.OntText = ontText;
  179:                 }
  180:             }
  181:         }
  182:  
  183:         ////////////////////////////////////////////////////////////////////////////
  184:  
  185:         /// <summary>
  186:         ///
  187:         /// </summary>
  188:         private static void CompareCurrentAndNewViewModels(ref Ia.Ftn.Wa.Models.Administration.AccessNetworkViewModel currentAccessNetworkViewModel, ref Ia.Ftn.Wa.Models.Administration.AccessNetworkViewModel accessNetworkViewModel)
  189:         {
  190:             if (accessNetworkViewModel.SiteSelectedValue != currentAccessNetworkViewModel.SiteSelectedValue)
  191:             {
  192:                 accessNetworkViewModel.OdfSelectedValue = string.Empty;
  193:                 accessNetworkViewModel.OltSelectedValue = string.Empty;
  194:                 accessNetworkViewModel.PonSelectedValue = string.Empty;
  195:                 accessNetworkViewModel.OntText = string.Empty;
  196:             }
  197:             else if (accessNetworkViewModel.OdfSelectedValue != currentAccessNetworkViewModel.OdfSelectedValue)
  198:             {
  199:                 accessNetworkViewModel.OltSelectedValue = string.Empty;
  200:                 accessNetworkViewModel.PonSelectedValue = string.Empty;
  201:                 accessNetworkViewModel.OntText = string.Empty;
  202:             }
  203:             else if (accessNetworkViewModel.OltSelectedValue != currentAccessNetworkViewModel.OltSelectedValue)
  204:             {
  205:                 accessNetworkViewModel.PonSelectedValue = string.Empty;
  206:                 accessNetworkViewModel.OntText = string.Empty;
  207:             }
  208:             else if (accessNetworkViewModel.PonSelectedValue != currentAccessNetworkViewModel.PonSelectedValue)
  209:             {
  210:                 accessNetworkViewModel.OntText = string.Empty;
  211:             }
  212:             else
  213:             {
  214:             }
  215:         }
  216:  
  217:         ////////////////////////////////////////////////////////////////////////////
  218:         ////////////////////////////////////////////////////////////////////////////
  219:     }
  220:  
  221:     ////////////////////////////////////////////////////////////////////////////
  222:     ////////////////////////////////////////////////////////////////////////////
  223: }