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

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.Model
    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-2021 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 UserId { get; set; }
   81:  
   82:         /// <summary/>
   83:         public virtual ICollection<ReportHistory> ReportHistories { get; set; }
   84:  
   85:         ////////////////////////////////////////////////////////////////////////////
   86:  
   87:         /// <summary>
   88:         ///
   89:         /// </summary>
   90:         [NotMapped]
   91:         public bool StatusIsOpen
   92:         {
   93:             get
   94:             {
   95:                 return this.Status == (int)Ia.Ftn.Cl.Model.Business.Report.Status.Open;
   96:             }
   97:         }
   98:  
   99:         ////////////////////////////////////////////////////////////////////////////
  100:  
  101:         /// <summary>
  102:         ///
  103:         /// </summary>
  104:         [NotMapped]
  105:         public ReportHistory LastReportHistory
  106:         {
  107:             get
  108:             {
  109:                 ReportHistory reportHistory;
  110:  
  111:                 reportHistory = null;
  112:  
  113:                 if (this.ReportHistories != null)
  114:                 {
  115:                     if (this.ReportHistories.Count > 0)
  116:                     {
  117:                         reportHistory = this.ReportHistories.Skip(this.ReportHistories.Count - 1).FirstOrDefault();
  118:                     }
  119:                     else reportHistory = null;
  120:                 }
  121:                 else reportHistory = null;
  122:  
  123:                 return reportHistory;
  124:             }
  125:         }
  126:  
  127:         ////////////////////////////////////////////////////////////////////////////
  128:  
  129:         /// <summary>
  130:         ///
  131:         /// </summary>
  132:         [NotMapped]
  133:         public ReportHistory SecondToLastReportHistory
  134:         {
  135:             get
  136:             {
  137:                 ReportHistory reportHistory;
  138:  
  139:                 reportHistory = null;
  140:  
  141:                 if (this.ReportHistories != null)
  142:                 {
  143:                     if (this.ReportHistories.Count > 1)
  144:                     {
  145:                         reportHistory = this.ReportHistories.Skip(this.ReportHistories.Count - 2).FirstOrDefault();
  146:                     }
  147:                     else reportHistory = null;
  148:                 }
  149:                 else reportHistory = null;
  150:  
  151:                 return reportHistory;
  152:             }
  153:         }
  154:  
  155:         ////////////////////////////////////////////////////////////////////////////
  156:  
  157:         /// <summary>
  158:         ///
  159:         /// </summary>
  160:         public bool UpdateMigrated(Report updatedReport)
  161:         {
  162:             // below: this will not update Id, Created
  163:             bool updated;
  164:  
  165:             updated = false;
  166:  
  167:             if (this.Area != updatedReport.Area) { this.Area = updatedReport.Area; updated = true; }
  168:             if (this.Category != updatedReport.Category) { this.Category = updatedReport.Category; updated = true; }
  169:             if (this.Contact != updatedReport.Contact) { this.Contact = updatedReport.Contact; updated = true; }
  170:             if (this.Detail != updatedReport.Detail) { this.Detail = updatedReport.Detail; updated = true; }
  171:             if (this.Note != updatedReport.Note) { this.Note = updatedReport.Note; updated = true; }
  172:             if (this.Priority != updatedReport.Priority) { this.Priority = updatedReport.Priority; updated = true; }
  173:             if (this.Service != updatedReport.Service) { this.Service = updatedReport.Service; updated = true; }
  174:  
  175:             if (this.ServiceType != updatedReport.ServiceType) { this.ServiceType = updatedReport.ServiceType; updated = true; }
  176:             if (this.ReportHistories != updatedReport.ReportHistories) { this.ReportHistories = updatedReport.ReportHistories; updated = true; }
  177:             if (this.Severity != updatedReport.Severity) { this.Severity = updatedReport.Severity; updated = true; }
  178:             if (this.State != updatedReport.State) { this.State = updatedReport.State; updated = true; }
  179:             if (this.Status != updatedReport.Status) { this.Status = updatedReport.Status; updated = true; }
  180:  
  181:             if (this.UserId != updatedReport.UserId) { this.UserId = updatedReport.UserId; updated = true; }
  182:  
  183:             // below: this is an update of migrated data
  184:             if (this.Created != updatedReport.Created) { this.Created = updatedReport.Created; updated = true; }
  185:             if (this.Updated != updatedReport.Updated) { this.Updated = updatedReport.Updated; updated = true; }
  186:  
  187:             //if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
  188:  
  189:             return updated;
  190:         }
  191:  
  192:         ////////////////////////////////////////////////////////////////////////////
  193:         ////////////////////////////////////////////////////////////////////////////
  194:     }
  195:  
  196:     ////////////////////////////////////////////////////////////////////////////
  197:     ////////////////////////////////////////////////////////////////////////////
  198: }