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

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

    1: using Ia.Ftn.Wa.Models;
    2: using Microsoft.AspNetCore.Authorization;
    3: using Microsoft.AspNetCore.Mvc;
    4: using Microsoft.AspNetCore.Mvc.Rendering;
    5: using System.Diagnostics;
    6: using System.Net;
    7:  
    8: namespace Ia.Ftn.Wa.Controllers
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     ///
   14:     /// </summary>
   15:     /// 
   16:     /// <remarks> 
   17:     /// Copyright © 2006-2025 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:     [Authorize]
   30:     public class MaintenanceEventController : Controller
   31:     {
   32:         ////////////////////////////////////////////////////////////////////////////
   33:  
   34:         /// <summary>
   35:         /// 
   36:         /// </summary>
   37:         [Route("/maintenance/event")]
   38:         public IActionResult Index()
   39:         {
   40:             var maintenanceEventViewModel = new Ia.Ftn.Wa.Models.Maintenance.MaintenanceEventViewModel();
   41:  
   42:             SelectList_ViewModel(ref maintenanceEventViewModel);
   43:  
   44:             return View(maintenanceEventViewModel);
   45:         }
   46:  
   47:         ////////////////////////////////////////////////////////////////////////////
   48:  
   49:         /// <summary>
   50:         /// 
   51:         /// </summary>
   52:         [Route("/maintenance/event/ams")]
   53:         public IActionResult Ams()
   54:         {
   55:             var maintenanceEventViewModel = new Ia.Ftn.Wa.Models.Maintenance.MaintenanceEventViewModel();
   56:  
   57:             SelectList_ViewModel(ref maintenanceEventViewModel);
   58:  
   59:             return View(maintenanceEventViewModel);
   60:         }
   61:  
   62:         ////////////////////////////////////////////////////////////////////////////
   63:  
   64:         /// <summary>
   65:         /// 
   66:         /// </summary>
   67:         [HttpPost]
   68:         [Route("/maintenance/event/ams")]
   69:         public IActionResult Search(Ia.Ftn.Wa.Models.Maintenance.MaintenanceEventViewModel maintenanceEventViewModel)
   70:         {
   71:             SelectList_ViewModel(ref maintenanceEventViewModel);
   72:  
   73:             var rawInput = WebUtility.HtmlDecode(maintenanceEventViewModel.TextInput);
   74:  
   75:             var result = new Ia.Cl.Models.Result();
   76:  
   77:             if (string.IsNullOrEmpty(rawInput))
   78:             {
   79:                 if (maintenanceEventViewModel.CauseSelectList.Count() > 0)
   80:                 {
   81:                     if (maintenanceEventViewModel.SeveritySelectList.Count() > 0)
   82:                     {
   83:                         if (maintenanceEventViewModel.ServiceEffectSelectList.Count() > 0)
   84:                         {
   85:                             if (maintenanceEventViewModel.CauseSelectList.Count() > 0)
   86:                             {
   87:                                 var classId = maintenanceEventViewModel.ClassSelectedValue;
   88:                                 var severityId = maintenanceEventViewModel.SeveritySelectedValue;
   89:                                 var serviceEffectId = maintenanceEventViewModel.ServiceEffectSelectedValue;
   90:                                 var causeId = maintenanceEventViewModel.CauseSelectedValue;
   91:  
   92:                                 // to send string.Empty if the value is '*'
   93:                                 if (classId == "All") classId = string.Empty;
   94:                                 if (severityId == "All") severityId = string.Empty;
   95:                                 if (serviceEffectId == "All") serviceEffectId = string.Empty;
   96:                                 if (causeId == "All") causeId = string.Empty;
   97:  
   98:                                 var list = Ia.Ftn.Cl.Models.Data.Event.ReadTakeNOrderByIdDescendingListFromNddOntId(string.Empty, classId, severityId, serviceEffectId, causeId, 100);
   99:  
  100:                                 if (list.Count > 0)
  101:                                 {
  102:                                     maintenanceEventViewModel.EventList = list;
  103:  
  104:                                     result.AddSuccess("Search for Nokia AMS events returned " + list.Count + " records.");
  105:                                 }
  106:                                 else
  107:                                 {
  108:                                     result.AddWarning("No event records were found (لا توجد أحداث قريبة العهد).");
  109:                                 }
  110:                             }
  111:                             else
  112:                             {
  113:                                 result.AddError("causeDropDownList contains not items.");
  114:                             }
  115:                         }
  116:                         else
  117:                         {
  118:                             result.AddError("serviceEffectDropDownList contains not items.");
  119:                         }
  120:                     }
  121:                     else
  122:                     {
  123:                         result.AddError("severityDropDownList contains not items.");
  124:                     }
  125:                 }
  126:                 else
  127:                 {
  128:                     result.AddError("classDropDownList contains not items.");
  129:                 }
  130:             }
  131:             else
  132:             {
  133:                 var input = rawInput.Trim();
  134:  
  135:                 if (Ia.Ftn.Cl.Models.Business.Access.AccessNameIsInAValidFormat(input))
  136:                 {
  137:                     if (maintenanceEventViewModel.CauseSelectList.Count() > 0)
  138:                     {
  139:                         if (maintenanceEventViewModel.SeveritySelectList.Count() > 0)
  140:                         {
  141:                             if (maintenanceEventViewModel.ServiceEffectSelectList.Count() > 0)
  142:                             {
  143:                                 if (maintenanceEventViewModel.CauseSelectList.Count() > 0)
  144:                                 {
  145:                                     var nddOnt = Ia.Ftn.Cl.Models.Business.Default.NddOntUsingExtractedAccessNameWithValidSymbolAndLegalFormatForPonAndOntFromValue(input);
  146:  
  147:                                     if (nddOnt != null)
  148:                                     {
  149:                                         if (nddOnt.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Vendor.Nokia)
  150:                                         {
  151:                                             var classId = maintenanceEventViewModel.ClassSelectedValue;
  152:                                             var severityId = maintenanceEventViewModel.SeveritySelectedValue;
  153:                                             var serviceEffectId = maintenanceEventViewModel.ServiceEffectSelectedValue;
  154:                                             var causeId = maintenanceEventViewModel.CauseSelectedValue;
  155:  
  156:                                             // to send string.Empty if the value is '*'
  157:                                             if (classId == "All") classId = string.Empty;
  158:                                             if (severityId == "All") severityId = string.Empty;
  159:                                             if (serviceEffectId == "All") serviceEffectId = string.Empty;
  160:                                             if (causeId == "All") causeId = string.Empty;
  161:  
  162:                                             var list = Ia.Ftn.Cl.Models.Data.Event.ReadTakeNOrderByIdDescendingListFromNddOntId(nddOnt.Id, classId, severityId, serviceEffectId, causeId, 100);
  163:  
  164:                                             if (list.Count > 0)
  165:                                             {
  166:                                                 maintenanceEventViewModel.EventList = list;
  167:  
  168:                                                 result.AddSuccess("Search for \"" + rawInput + "\" Nokia AMS events returned " + list.Count + " records.");
  169:                                             }
  170:                                             else
  171:                                             {
  172:                                                 result.AddWarning("No event records were found for \"" + rawInput + "\" (لا توجد أحداث قريبة العهد للجهاز).");
  173:                                             }
  174:                                         }
  175:                                         else
  176:                                         {
  177:                                             result.AddError("The ONT \"" + input + "\" does not belong to Nokia Access network (الجهاز لا ينتمي لشبكة الخطوط الطرفية التابعة لنوكيا).");
  178:                                         }
  179:                                     }
  180:                                     else
  181:                                     {
  182:                                         result.AddError("The ONT \"" + input + "\" does not belong to the network (الجهاز لا ينتمي للشبكة).");
  183:                                     }
  184:                                 }
  185:                                 else
  186:                                 {
  187:                                     result.AddError("causeDropDownList contains not items.");
  188:                                 }
  189:                             }
  190:                             else
  191:                             {
  192:                                 result.AddError("serviceEffectDropDownList contains not items.");
  193:                             }
  194:                         }
  195:                         else
  196:                         {
  197:                             result.AddError("severityDropDownList contains not items.");
  198:                         }
  199:                     }
  200:                     else
  201:                     {
  202:                         result.AddError("classDropDownList contains not items.");
  203:                     }
  204:                 }
  205:                 else
  206:                 {
  207:                     result.AddError("Input format is unknown (قيمة غير مفهومة). ");
  208:                 }
  209:             }
  210:  
  211:             maintenanceEventViewModel.Result = result;
  212:  
  213:             return View("Ams", maintenanceEventViewModel);
  214:         }
  215:  
  216:         ////////////////////////////////////////////////////////////////////////////
  217:         ////////////////////////////////////////////////////////////////////////////
  218:  
  219:         /// <summary>
  220:         ///
  221:         /// </summary>
  222:         public void SelectList_ViewModel(ref Ia.Ftn.Wa.Models.Maintenance.MaintenanceEventViewModel maintenanceEventViewModel)
  223:         {
  224:             ClassList(ref maintenanceEventViewModel);
  225:             SeverityList(ref maintenanceEventViewModel);
  226:             ServiceEffectList(ref maintenanceEventViewModel);
  227:             CauseList(ref maintenanceEventViewModel);
  228:         }
  229:  
  230:         ////////////////////////////////////////////////////////////////////////////
  231:  
  232:         /// <summary>
  233:         ///
  234:         /// </summary>
  235:         protected void ClassList(ref Ia.Ftn.Wa.Models.Maintenance.MaintenanceEventViewModel maintenanceEventViewModel)
  236:         {
  237:             var list = Ia.Ftn.Cl.Models.Data.Event.ClassList;
  238:             list.Insert(0, "All");
  239:  
  240:             maintenanceEventViewModel.ClassSelectList = new SelectList(list);
  241:  
  242:             maintenanceEventViewModel.ButtonEnabled = true; // (Ia.Ftn.Cl.Model.Business.Authority.StaffCanExecuteTasks(staff)) ? true : false;
  243:         }
  244:  
  245:         ////////////////////////////////////////////////////////////////////////////
  246:  
  247:         /// <summary>
  248:         ///
  249:         /// </summary>
  250:         protected void SeverityList(ref Ia.Ftn.Wa.Models.Maintenance.MaintenanceEventViewModel maintenanceEventViewModel)
  251:         {
  252:             var list = Ia.Ftn.Cl.Models.Data.Event.SeverityList;
  253:             list.Insert(0, new Ia.Ftn.Cl.Models.Data.Event.Severity("All", "All"));
  254:  
  255:             maintenanceEventViewModel.SeveritySelectList = new SelectList(list, "Id", "Name");
  256:  
  257:             maintenanceEventViewModel.ButtonEnabled = true; // (Ia.Ftn.Cl.Model.Business.Authority.StaffCanExecuteTasks(staff)) ? true : false;
  258:         }
  259:  
  260:         ////////////////////////////////////////////////////////////////////////////
  261:  
  262:         /// <summary>
  263:         ///
  264:         /// </summary>
  265:         protected void ServiceEffectList(ref Ia.Ftn.Wa.Models.Maintenance.MaintenanceEventViewModel maintenanceEventViewModel)
  266:         {
  267:             var list = Ia.Ftn.Cl.Models.Data.Event.ServiceEffectList;
  268:             list.Insert(0, new Ia.Ftn.Cl.Models.Data.Event.ServiceEffect("All", "All"));
  269:  
  270:             maintenanceEventViewModel.ServiceEffectSelectList = new SelectList(list, "Id", "Name");
  271:  
  272:             maintenanceEventViewModel.ButtonEnabled = true; // (Ia.Ftn.Cl.Model.Business.Authority.StaffCanExecuteTasks(staff)) ? true : false;
  273:         }
  274:  
  275:         ////////////////////////////////////////////////////////////////////////////
  276:  
  277:         /// <summary>
  278:         ///
  279:         /// </summary>
  280:         protected void CauseList(ref Ia.Ftn.Wa.Models.Maintenance.MaintenanceEventViewModel maintenanceEventViewModel)
  281:         {
  282:             var list = Ia.Ftn.Cl.Models.Data.Event.CauseList;
  283:             list.Insert(0, "All");
  284:  
  285:             maintenanceEventViewModel.CauseSelectList = new SelectList(list);
  286:  
  287:             maintenanceEventViewModel.ButtonEnabled = true; // (Ia.Ftn.Cl.Model.Business.Authority.StaffCanExecuteTasks(staff)) ? true : false;
  288:         }
  289:  
  290:         ////////////////////////////////////////////////////////////////////////////
  291:         ////////////////////////////////////////////////////////////////////////////
  292:  
  293:         /// <summary>
  294:         ///
  295:         /// </summary>
  296:         [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
  297:         public IActionResult Error()
  298:         {
  299:             return View(new Ia.Ftn.Wa.Models.ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
  300:         }
  301:  
  302:         ////////////////////////////////////////////////////////////////////////////
  303:         ////////////////////////////////////////////////////////////////////////////
  304:     }
  305:  
  306:     ////////////////////////////////////////////////////////////////////////////
  307:     ////////////////////////////////////////////////////////////////////////////
  308: }