)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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:     ///
   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 Report
   30:     {
   31:         /// <summary/>
   32:         public Report()
   33:         {
   34:             // this.ReportHistories = new List<ReportHistory>();
   35:         }
   36:  
   37:         /// <summary/>
   38:         public int Id { get; set; }
   39:  
   40:         /// <summary/>
   41:         public string Service { get; set; }
   42:  
   43:         /// <summary/>
   44:         public int ServiceType { get; set; }
   45:  
   46:         /// <summary/>
   47:         public int State { get; set; }
   48:  
   49:         /// <summary/>
   50:         public int Status { get; set; }
   51:  
   52:         /// <summary/>
   53:         public int Category { get; set; }
   54:  
   55:         /// <summary/>
   56:         public int Area { get; set; }
   57:  
   58:         /// <summary/>
   59:         public int Priority { get; set; }
   60:  
   61:         /// <summary/>
   62:         public int Severity { get; set; }
   63:  
   64:         /// <summary/>
   65:         public string Detail { get; set; }
   66:  
   67:         /// <summary/>
   68:         public string Contact { get; set; }
   69:  
   70:         /// <summary/>
   71:         public string Note { get; set; }
   72:  
   73:         /// <summary/>
   74:         public DateTime Created { get; set; }
   75:  
   76:         /// <summary/>
   77:         public DateTime Updated { get; set; }
   78:  
   79:         /// <summary/>
   80:         public string FrameworkId { get; set; }
   81:  
   82:         /// <summary/>
   83:         [ForeignKey("StaffIdentityUser_Id")]
   84:         public virtual StaffIdentityUser StaffIdentityUser { get; set; }
   85:  
   86:         /// <summary/>
   87:         public virtual ICollection<ReportHistory> ReportHistories { get; set; }
   88:  
   89:         ////////////////////////////////////////////////////////////////////////////
   90:  
   91:         /// <summary>
   92:         ///
   93:         /// </summary>
   94:         [NotMapped]
   95:         public bool StatusIsOpen
   96:         {
   97:             get
   98:             {
   99:                 return this.Status == (int)Ia.Ftn.Cl.Models.Business.Report.Status.Open;
  100:             }
  101:         }
  102:  
  103:         ////////////////////////////////////////////////////////////////////////////
  104:  
  105:         /// <summary>
  106:         ///
  107:         /// </summary>
  108:         [NotMapped]
  109:         public bool HasHistories
  110:         {
  111:             get
  112:             {
  113:                 return ReportHistories != null && ReportHistories.Count > 0;
  114:             }
  115:         }
  116:  
  117:         ////////////////////////////////////////////////////////////////////////////
  118:  
  119:         /// <summary>
  120:         ///
  121:         /// </summary>
  122:         [NotMapped]
  123:         public ReportHistory LastReportHistory
  124:         {
  125:             get
  126:             {
  127:                 ReportHistory reportHistory;
  128:  
  129:                 reportHistory = null;
  130:  
  131:                 if (this.ReportHistories != null)
  132:                 {
  133:                     if (this.ReportHistories.Count > 0)
  134:                     {
  135:                         reportHistory = this.ReportHistories.Skip(this.ReportHistories.Count - 1).FirstOrDefault();
  136:                     }
  137:                     else reportHistory = null;
  138:                 }
  139:                 else reportHistory = null;
  140:  
  141:                 return reportHistory;
  142:             }
  143:         }
  144:  
  145:         ////////////////////////////////////////////////////////////////////////////
  146:  
  147:         /// <summary>
  148:         ///
  149:         /// </summary>
  150:         [NotMapped]
  151:         public ReportHistory SecondToLastReportHistory
  152:         {
  153:             get
  154:             {
  155:                 ReportHistory reportHistory;
  156:  
  157:                 reportHistory = null;
  158:  
  159:                 if (this.ReportHistories != null)
  160:                 {
  161:                     if (this.ReportHistories.Count > 1)
  162:                     {
  163:                         reportHistory = this.ReportHistories.Skip(this.ReportHistories.Count - 2).FirstOrDefault();
  164:                     }
  165:                     else reportHistory = null;
  166:                 }
  167:                 else reportHistory = null;
  168:  
  169:                 return reportHistory;
  170:             }
  171:         }
  172:  
  173:         ////////////////////////////////////////////////////////////////////////////
  174:  
  175:         /// <summary>
  176:         ///
  177:         /// </summary>
  178:         public bool UpdateMigrated(Report updatedReport)
  179:         {
  180:             // below: this will not update Id, Created
  181:             bool updated;
  182:  
  183:             updated = false;
  184:  
  185:             if (this.Area != updatedReport.Area) { this.Area = updatedReport.Area; updated = true; }
  186:             if (this.Category != updatedReport.Category) { this.Category = updatedReport.Category; updated = true; }
  187:             if (this.Contact != updatedReport.Contact) { this.Contact = updatedReport.Contact; updated = true; }
  188:             if (this.Detail != updatedReport.Detail) { this.Detail = updatedReport.Detail; updated = true; }
  189:             if (this.Note != updatedReport.Note) { this.Note = updatedReport.Note; updated = true; }
  190:             if (this.Priority != updatedReport.Priority) { this.Priority = updatedReport.Priority; updated = true; }
  191:             if (this.Service != updatedReport.Service) { this.Service = updatedReport.Service; updated = true; }
  192:  
  193:             if (this.ServiceType != updatedReport.ServiceType) { this.ServiceType = updatedReport.ServiceType; updated = true; }
  194:             if (this.ReportHistories != updatedReport.ReportHistories) { this.ReportHistories = updatedReport.ReportHistories; updated = true; }
  195:             if (this.Severity != updatedReport.Severity) { this.Severity = updatedReport.Severity; updated = true; }
  196:             if (this.State != updatedReport.State) { this.State = updatedReport.State; updated = true; }
  197:             if (this.Status != updatedReport.Status) { this.Status = updatedReport.Status; updated = true; }
  198:  
  199:             if (this.StaffIdentityUser.Id != updatedReport.StaffIdentityUser.Id) { this.StaffIdentityUser.Id = updatedReport.StaffIdentityUser.Id; updated = true; }
  200:  
  201:             // below: this is an update of migrated data
  202:             if (this.Created != updatedReport.Created) { this.Created = updatedReport.Created; updated = true; }
  203:             if (this.Updated != updatedReport.Updated) { this.Updated = updatedReport.Updated; updated = true; }
  204:  
  205:             //if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
  206:  
  207:             return updated;
  208:         }
  209:  
  210:         ////////////////////////////////////////////////////////////////////////////
  211:         ////////////////////////////////////////////////////////////////////////////
  212:     }
  213:  
  214:     ////////////////////////////////////////////////////////////////////////////
  215:     ////////////////////////////////////////////////////////////////////////////
  216: }