شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة ش.ش.و.

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Access

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

Access Entity Framework class for Optical Fiber Network (OFN) entity model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.ComponentModel.DataAnnotations;
   4:  using System.ComponentModel.DataAnnotations.Schema;
   5:  using System.Linq;
   6:  using System.Threading;
   7:  using System.Threading.Tasks;
   8:   
   9:  namespace Ia.Ngn.Cl.Model
  10:  {
  11:      ////////////////////////////////////////////////////////////////////////////
  12:   
  13:      /// <summary publish="true">
  14:      /// Access Entity Framework class for Optical Fiber Network (OFN) entity model.
  15:      /// </summary>
  16:      /// 
  17:      /// <remarks> 
  18:      /// Copyright © 2006-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  19:      ///
  20:      /// 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
  21:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  22:      ///
  23:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  24:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  25:      /// 
  26:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  27:      /// 
  28:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  29:      /// </remarks> 
  30:      public class Access
  31:      {
  32:          /// <summary/>
  33:          public Access() { }
  34:   
  35:          /// <summary/>
  36:          [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
  37:          public string Id { get; set; }
  38:   
  39:          /// <summary/>
  40:          public int Olt { get; set; }
  41:   
  42:          /// <summary/>
  43:          public int Pon { get; set; }
  44:   
  45:          /// <summary/>
  46:          public int Ont { get; set; }
  47:   
  48:          /// <summary/>
  49:          public string Odf { get; set; }
  50:   
  51:          /// <summary/>
  52:          public int AreaId { get; set; }
  53:   
  54:          /// <summary/>
  55:          public string Block { get; set; }
  56:   
  57:          /// <summary/>
  58:          public string Street { get; set; }
  59:   
  60:          /// <summary/>
  61:          public string PremisesOld { get; set; }
  62:   
  63:          /// <summary/>
  64:          public string PremisesNew { get; set; }
  65:   
  66:          /// <summary/>
  67:          public string Paci { get; set; }
  68:   
  69:          /// <summary/>
  70:          public string Note { get; set; }
  71:   
  72:          /// <summary/>
  73:          public DateTime Created { get; set; }
  74:   
  75:          /// <summary/>
  76:          public DateTime Updated { get; set; }
  77:   
  78:          /// <summary/>
  79:          public System.Guid UserId { get; set; }
  80:   
  81:          /// <summary/>
  82:          public virtual ICollection<Ont> Onts { get; set; }
  83:   
  84:          /// <summary/>
  85:          public virtual ICollection<Ia.Ngn.Cl.Model.Huawei.EmsOnt> EmsOnts { get; set; }
  86:   
  87:          /// <summary/>
  88:          public virtual ICollection<Ia.Ngn.Cl.Model.Huawei.EmsDev> EmsDevs { get; set; }
  89:   
  90:          /// <summary/>
  91:          [NotMapped]
  92:          public string Name
  93:          {
  94:              get
  95:              {
  96:                  return Ia.Ngn.Cl.Model.Business.Access.Name(this);
  97:              }
  98:          }
  99:   
 100:          /// <summary/>
 101:          [NotMapped]
 102:          public string Position
 103:          {
 104:              get
 105:              {
 106:                  string position;
 107:   
 108:                  position = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList
 109:                              where o.Pon.PonGroup.Olt.Id == this.Olt && o.Pon.Number == this.Pon && o.Number == this.Ont
 110:                              select o.Position).SingleOrDefault();
 111:   
 112:                  return position;
 113:              }
 114:          }
 115:   
 116:          ////////////////////////////////////////////////////////////////////////////
 117:   
 118:          /// <summary>
 119:          ///
 120:          /// </summary>
 121:          [NotMapped]
 122:          public string Address
 123:          {
 124:              get
 125:              {
 126:                  string address;
 127:   
 128:                  var kuwaitOfnArea = Ia.Ngn.Cl.Model.Data.Service.KuwaitOfnAreaById(this.AreaId);
 129:   
 130:                  if (kuwaitOfnArea != null)
 131:                  {
 132:                      address = kuwaitOfnArea.Name + ", block " + this.Block + ", street " + this.Street + ", old premises " + this.PremisesOld + ", new premises " + this.PremisesNew;
 133:                  }
 134:                  else address = string.Empty;
 135:   
 136:                  return address;
 137:              }
 138:          }
 139:   
 140:          ////////////////////////////////////////////////////////////////////////////
 141:   
 142:          /// <summary>
 143:          ///
 144:          /// </summary>
 145:          [NotMapped]
 146:          public string ArabicAddress
 147:          {
 148:              get
 149:              {
 150:                  string address;
 151:   
 152:                  var kuwaitOfnArea = Ia.Ngn.Cl.Model.Data.Service.KuwaitOfnAreaById(this.AreaId);
 153:   
 154:                  if (kuwaitOfnArea != null)
 155:                  {
 156:                      address = kuwaitOfnArea.ArabicName + ", قطعة " + this.Block + ", شارع " + this.Street + ", قسيمة " + this.PremisesOld + ", منزل " + this.PremisesNew;
 157:                  }
 158:                  else address = string.Empty;
 159:   
 160:                  return address;
 161:              }
 162:          }
 163:   
 164:          ////////////////////////////////////////////////////////////////////////////
 165:   
 166:          /// <summary>
 167:          ///
 168:          /// </summary>
 169:          public bool Update(Access updatedAccess)
 170:          {
 171:              // below: this will not update Id, Created
 172:              bool updated;
 173:   
 174:              updated = false;
 175:   
 176:              if (this.AreaId != updatedAccess.AreaId) { this.AreaId = updatedAccess.AreaId; updated = true; }
 177:              if (this.Block != updatedAccess.Block) { this.Block = updatedAccess.Block; updated = true; }
 178:              //if (this.Name != updatedAccess.Name) { this.Name = updatedAccess.Name; updated = true; }
 179:              if (this.Odf != updatedAccess.Odf) { this.Odf = updatedAccess.Odf; updated = true; }
 180:              if (this.Olt != updatedAccess.Olt) { this.Olt = updatedAccess.Olt; updated = true; }
 181:              if (this.Ont != updatedAccess.Ont) { this.Ont = updatedAccess.Ont; updated = true; }
 182:              if (this.Pon != updatedAccess.Pon) { this.Pon = updatedAccess.Pon; updated = true; }
 183:              //if (this.Position != updatedAccess.Position) { this.Position = updatedAccess.Position; updated = true; }
 184:              if (this.PremisesOld != updatedAccess.PremisesOld) { this.PremisesOld = updatedAccess.PremisesOld; updated = true; }
 185:              if (this.PremisesNew != updatedAccess.PremisesNew) { this.PremisesNew = updatedAccess.PremisesNew; updated = true; }
 186:              if (this.Paci != updatedAccess.Paci) { this.Paci = updatedAccess.Paci; updated = true; }
 187:              if (this.Note != updatedAccess.Note) { this.Note = updatedAccess.Note; updated = true; }
 188:              if (this.Street != updatedAccess.Street) { this.Street = updatedAccess.Street; updated = true; }
 189:              if (this.UserId != updatedAccess.UserId) { this.UserId = updatedAccess.UserId; updated = true; }
 190:   
 191:              if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
 192:   
 193:              return updated;
 194:          }
 195:   
 196:          ////////////////////////////////////////////////////////////////////////////
 197:          ////////////////////////////////////////////////////////////////////////////
 198:   
 199:          /// <summary>
 200:          ///
 201:          /// </summary>
 202:          public string ToSimpleTextString()
 203:          {
 204:              return Ia.Ngn.Cl.Model.Data.Access.ToSimpleTextString(this);
 205:          }
 206:   
 207:          ////////////////////////////////////////////////////////////////////////////
 208:          ////////////////////////////////////////////////////////////////////////////
 209:      }
 210:   
 211:      ////////////////////////////////////////////////////////////////////////////
 212:      ////////////////////////////////////////////////////////////////////////////
 213:  }