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

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

Report Entity Framework class for Fixed Telecommunications Network (FTN) entity model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.ComponentModel.DataAnnotations.Schema;
    4: using System.Linq;
    5: using System.Threading;
    6: using System.Threading.Tasks;
    7:  
    8: namespace Ia.Ftn.Cl.Models
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     /// Report Entity Framework class for Fixed Telecommunications Network (FTN) entity model.
   14:     /// </summary>
   15:     /// 
   16:     /// <remarks> 
   17:     /// Copyright © 2006-2024 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   18:     /// </remarks> 
   19:     public class Report
   20:     {
   21:         /// <summary/>
   22:         public Report()
   23:         {
   24:             // this.ReportHistories = new List<ReportHistory>();
   25:         }
   26:  
   27:         /// <summary/>
   28:         public int Id { get; set; }
   29:  
   30:         /// <summary/>
   31:         public string Service { get; set; }
   32:  
   33:         /// <summary/>
   34:         public int ServiceType { get; set; }
   35:  
   36:         /// <summary/>
   37:         public int State { get; set; }
   38:  
   39:         /// <summary/>
   40:         public int Status { get; set; }
   41:  
   42:         /// <summary/>
   43:         public int Category { get; set; }
   44:  
   45:         /// <summary/>
   46:         public int Area { get; set; }
   47:  
   48:         /// <summary/>
   49:         public int Priority { get; set; }
   50:  
   51:         /// <summary/>
   52:         public int Severity { get; set; }
   53:  
   54:         /// <summary/>
   55:         public string Detail { get; set; }
   56:  
   57:         /// <summary/>
   58:         public string Contact { get; set; }
   59:  
   60:         /// <summary/>
   61:         public string Note { get; set; }
   62:  
   63:         /// <summary/>
   64:         public DateTime Created { get; set; }
   65:  
   66:         /// <summary/>
   67:         public DateTime Updated { get; set; }
   68:  
   69:         /// <summary/>
   70:         public string FrameworkId { get; set; }
   71:  
   72:         /// <summary/>
   73:         [ForeignKey("StaffIdentityUser_Id")]
   74:         public virtual StaffIdentityUser StaffIdentityUser { get; set; }
   75:  
   76:         /// <summary/>
   77:         public virtual ICollection<ReportHistory> ReportHistories { get; set; }
   78:  
   79:         ////////////////////////////////////////////////////////////////////////////
   80:  
   81:         /// <summary>
   82:         ///
   83:         /// </summary>
   84:         [NotMapped]
   85:         public bool StatusIsOpen
   86:         {
   87:             get
   88:             {
   89:                 return this.Status == (int)Ia.Ftn.Cl.Models.Business.Report.Status.Open;
   90:             }
   91:         }
   92:  
   93:         ////////////////////////////////////////////////////////////////////////////
   94:  
   95:         /// <summary>
   96:         ///
   97:         /// </summary>
   98:         [NotMapped]
   99:         public bool HasHistories
  100:         {
  101:             get
  102:             {
  103:                 return ReportHistories != null && ReportHistories.Count > 0;
  104:             }
  105:         }
  106:  
  107:         ////////////////////////////////////////////////////////////////////////////
  108:  
  109:         /// <summary>
  110:         ///
  111:         /// </summary>
  112:         [NotMapped]
  113:         public ReportHistory LastReportHistory
  114:         {
  115:             get
  116:             {
  117:                 ReportHistory reportHistory;
  118:  
  119:                 reportHistory = null;
  120:  
  121:                 if (this.ReportHistories != null)
  122:                 {
  123:                     if (this.ReportHistories.Count > 0)
  124:                     {
  125:                         reportHistory = this.ReportHistories.Skip(this.ReportHistories.Count - 1).FirstOrDefault();
  126:                     }
  127:                     else reportHistory = null;
  128:                 }
  129:                 else reportHistory = null;
  130:  
  131:                 return reportHistory;
  132:             }
  133:         }
  134:  
  135:         ////////////////////////////////////////////////////////////////////////////
  136:  
  137:         /// <summary>
  138:         ///
  139:         /// </summary>
  140:         [NotMapped]
  141:         public ReportHistory SecondToLastReportHistory
  142:         {
  143:             get
  144:             {
  145:                 ReportHistory reportHistory;
  146:  
  147:                 reportHistory = null;
  148:  
  149:                 if (this.ReportHistories != null)
  150:                 {
  151:                     if (this.ReportHistories.Count > 1)
  152:                     {
  153:                         reportHistory = this.ReportHistories.Skip(this.ReportHistories.Count - 2).FirstOrDefault();
  154:                     }
  155:                     else reportHistory = null;
  156:                 }
  157:                 else reportHistory = null;
  158:  
  159:                 return reportHistory;
  160:             }
  161:         }
  162:  
  163:         ////////////////////////////////////////////////////////////////////////////
  164:  
  165:         /// <summary>
  166:         ///
  167:         /// </summary>
  168:         public bool UpdateMigrated(Report updatedReport)
  169:         {
  170:             // below: this will not update Id, Created
  171:             bool updated;
  172:  
  173:             updated = false;
  174:  
  175:             if (this.Area != updatedReport.Area) { this.Area = updatedReport.Area; updated = true; }
  176:             if (this.Category != updatedReport.Category) { this.Category = updatedReport.Category; updated = true; }
  177:             if (this.Contact != updatedReport.Contact) { this.Contact = updatedReport.Contact; updated = true; }
  178:             if (this.Detail != updatedReport.Detail) { this.Detail = updatedReport.Detail; updated = true; }
  179:             if (this.Note != updatedReport.Note) { this.Note = updatedReport.Note; updated = true; }
  180:             if (this.Priority != updatedReport.Priority) { this.Priority = updatedReport.Priority; updated = true; }
  181:             if (this.Service != updatedReport.Service) { this.Service = updatedReport.Service; updated = true; }
  182:  
  183:             if (this.ServiceType != updatedReport.ServiceType) { this.ServiceType = updatedReport.ServiceType; updated = true; }
  184:             if (this.ReportHistories != updatedReport.ReportHistories) { this.ReportHistories = updatedReport.ReportHistories; updated = true; }
  185:             if (this.Severity != updatedReport.Severity) { this.Severity = updatedReport.Severity; updated = true; }
  186:             if (this.State != updatedReport.State) { this.State = updatedReport.State; updated = true; }
  187:             if (this.Status != updatedReport.Status) { this.Status = updatedReport.Status; updated = true; }
  188:  
  189:             if (this.StaffIdentityUser.Id != updatedReport.StaffIdentityUser.Id) { this.StaffIdentityUser.Id = updatedReport.StaffIdentityUser.Id; updated = true; }
  190:  
  191:             // below: this is an update of migrated data
  192:             if (this.Created != updatedReport.Created) { this.Created = updatedReport.Created; updated = true; }
  193:             if (this.Updated != updatedReport.Updated) { this.Updated = updatedReport.Updated; updated = true; }
  194:  
  195:             //if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
  196:  
  197:             return updated;
  198:         }
  199:  
  200:         ////////////////////////////////////////////////////////////////////////////
  201:         ////////////////////////////////////////////////////////////////////////////
  202:     }
  203:  
  204:     ////////////////////////////////////////////////////////////////////////////
  205:     ////////////////////////////////////////////////////////////////////////////
  206: }