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

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

    1: using Microsoft.AspNetCore.Mvc.Rendering;
    2: using System.Data;
    3: using System.Net;
    4: using System.Text;
    5:  
    6: namespace Ia.Ftn.Wa.Models.Provision
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     ///
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright © 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   16:     ///
   17:     /// 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
   18:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   19:     ///
   20:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   22:     /// 
   23:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   24:     /// 
   25:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   26:     /// </remarks> 
   27:     public static class Lic
   28:     {
   29:         private static StringBuilder logStringBuilder = new StringBuilder();
   30:  
   31:         ////////////////////////////////////////////////////////////////////////////
   32:  
   33:         /// <summary>
   34:         ///
   35:         /// </summary>
   36:         public static void ViewModel(ref Ia.Ftn.Wa.Models.Provision.LicViewModel currentLicViewModel, ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
   37:         {
   38:             CompareCurrentAndNewViewModels(ref currentLicViewModel, ref licViewModel);
   39:  
   40:             /*
   41:             // http://ftn/provision/lic.aspx?msanDevId=msanDevId&cabinet=cabinet&frame=frame&fn=fn&sn=sn&pn=pn&service=service
   42: 
   43:             var msanDevId = Request.QueryString["msanDevId"] != null ? WebUtility.HtmlDecode(Request.QueryString["msanDevId"].ToString()) : string.Empty;
   44:             var cabinet = Request.QueryString["cabinet"] != null ? WebUtility.HtmlDecode(Request.QueryString["cabinet"].ToString()) : string.Empty;
   45:             var frame = Request.QueryString["frame"] != null ? WebUtility.HtmlDecode(Request.QueryString["frame"].ToString()) : string.Empty;
   46:             var fn = Request.QueryString["fn"] != null ? WebUtility.HtmlDecode(Request.QueryString["fn"].ToString()) : string.Empty;
   47:             var card = Request.QueryString["sn"] != null ? WebUtility.HtmlDecode(Request.QueryString["sn"].ToString()) : string.Empty;
   48:             var port = Request.QueryString["pn"] != null ? WebUtility.HtmlDecode(Request.QueryString["pn"].ToString()) : string.Empty;
   49:             var service = Request.QueryString["service"] != null ? WebUtility.HtmlDecode(Request.QueryString["service"].ToString()) : string.Empty;
   50: 
   51:             if (!string.IsNullOrEmpty(msanDevId) && !string.IsNullOrEmpty(cabinet) && !string.IsNullOrEmpty(frame) && !string.IsNullOrEmpty(fn) && !string.IsNullOrEmpty(card) && !string.IsNullOrEmpty(port) && !string.IsNullOrEmpty(service))
   52:             {
   53:                 Page_ViewModel();// 2(msanDevId, cabinet, frame, fn, card, port, service);
   54:             }
   55:             else Page_ViewModel();
   56:             */
   57:  
   58:             var list = (from m in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.MsanList
   59:                         select new
   60:                         {
   61:                             m.Site.Id,
   62:                             m.Site.NameArabicName,
   63:                             SiteNameArabicNameMsanNameSymbol = m.Site.NameArabicName + " (" + m.NameSymbol + ")"
   64:                         }).OrderBy(u => u.NameArabicName).ToList();
   65:  
   66:             if (!string.IsNullOrEmpty(licViewModel.MsanSiteSelectedValue))
   67:             {
   68:                 licViewModel.MsanSiteSelectList = new SelectList(list, "Id", "SiteNameArabicNameMsanNameSymbol", licViewModel.MsanSiteSelectedValue);
   69:             }
   70:             else
   71:             {
   72:                 licViewModel.MsanSiteSelectList = new SelectList(list, "Id", "SiteNameArabicNameMsanNameSymbol", list[0].Id.ToString());
   73:                 licViewModel.MsanSiteSelectedValue = list[0].Id.ToString();
   74:             }
   75:  
   76:             CabinetSelectList(ref licViewModel);
   77:  
   78:             var msanSiteId = int.Parse(licViewModel.MsanSiteSelectedValue);
   79:  
   80:             var msan = (from s in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList
   81:                         where s.Id == msanSiteId
   82:                         select s.Msans.First()).Single();
   83:  
   84:             licViewModel.InsertButtonEnabled = licViewModel.DeleteButtonEnabled = (Ia.Ftn.Cl.Models.Business.Authority.StaffCanCreateDeleteLicList(Ia.Ftn.Cl.Models.Business.Authority.PersistentStorageFunction.Create, licViewModel.CurrentStaffIdentityUser, msan)) ? true : false;
   85:  
   86:             licViewModel.BulkInserButtonEnabled = Ia.Ftn.Cl.Models.Business.Authority.StaffCanCreateBulkLicList(Ia.Ftn.Cl.Models.Business.Authority.PersistentStorageFunction.Create, licViewModel.CurrentStaffIdentityUser) ? true : false;
   87:  
   88:             currentLicViewModel.MsanSiteSelectedValue = licViewModel.MsanSiteSelectedValue;
   89:             currentLicViewModel.CabinetSelectedValue = licViewModel.CabinetSelectedValue;
   90:             currentLicViewModel.FrameSelectedValue = licViewModel.FrameSelectedValue;
   91:             currentLicViewModel.CardSelectedValue = licViewModel.CardSelectedValue;
   92:             currentLicViewModel.PortSelectedValue = licViewModel.PortSelectedValue;
   93:  
   94:             licViewModel.LogLabel = logStringBuilder.ToString();
   95:         }
   96:  
   97:         ////////////////////////////////////////////////////////////////////////////
   98:  
   99:         /// <summary>
  100:         ///
  101:         /// </summary>
  102:         private static void CabinetSelectList(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  103:         {
  104:             if (licViewModel.MsanSiteSelectList.Count() > 0)
  105:             {
  106:                 if (!string.IsNullOrEmpty(licViewModel.MsanSiteSelectedValue))
  107:                 {
  108:                     var msanSiteId = int.Parse(licViewModel.MsanSiteSelectedValue);
  109:  
  110:                     var list = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
  111:                                 where m.Msan.Site.Id == msanSiteId
  112:                                 select new { Text = m.Cabinet, Value = m.Cabinet }).Distinct().OrderBy(u => u.Text).ToList();
  113:  
  114:                     if (list.Count > 0)
  115:                     {
  116:                         if (!string.IsNullOrEmpty(licViewModel.CabinetSelectedValue))
  117:                         {
  118:                             licViewModel.CabinetSelectList = new SelectList(list, "Value", "Text", licViewModel.CabinetSelectedValue);
  119:                         }
  120:                         else
  121:                         {
  122:                             licViewModel.CabinetSelectList = new SelectList(list, "Value", "Text", list[0].Value.ToString());
  123:                             licViewModel.CabinetSelectedValue = list[0].Value.ToString();
  124:                         }
  125:  
  126:                         FrameSelectList(ref licViewModel);
  127:                     }
  128:                 }
  129:             }
  130:             /*
  131:             private static void MsanSiteSelectList_SelectedIndexChanged(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  132:             {
  133:                 int msanSiteId;
  134: 
  135:                 if (msanSiteSelectList.Items.Count > 0)
  136:                 {
  137:                     msanSiteId = int.Parse(msanSiteSelectList.SelectedValue);
  138: 
  139:                     ViewState["msanSiteId"] = msanSiteId;
  140: 
  141:                     var list = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
  142:                                 where m.Msan.Site.Id == msanSiteId
  143:                                 select new { Text = m.Cabinet, Value = m.Cabinet }).Distinct().OrderBy(u => u.Text).ToList();
  144: 
  145:                     cabinetSelectList.DataSource = list;
  146:                     cabinetSelectList.DataTextField = "Text";
  147:                     cabinetSelectList.DataValueField = "Value";
  148:                     cabinetSelectList.ViewModel();
  149: 
  150:                     CabinetSelectList_SelectedIndexChanged(ref licViewModel);
  151:                 }
  152:                 else insertButton.Enabled = deleteButton.Enabled = false;
  153:             }
  154:             */
  155:         }
  156:  
  157:         ////////////////////////////////////////////////////////////////////////////
  158:  
  159:         /// <summary>
  160:         ///
  161:         /// </summary>
  162:         private static void FrameSelectList(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  163:         {
  164:             if (licViewModel.CabinetSelectList.Count() > 0)
  165:             {
  166:                 if (!string.IsNullOrEmpty(licViewModel.CabinetSelectedValue))
  167:                 {
  168:                     var msanSiteId = int.Parse(licViewModel.MsanSiteSelectedValue);
  169:                     var cabinet = int.Parse(licViewModel.CabinetSelectedValue);
  170:  
  171:                     var list = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
  172:                                 where m.Msan.Site.Id == msanSiteId && m.Cabinet == cabinet
  173:                                 select new { Text = m.Frame, Value = m.Frame }).Distinct().OrderBy(u => u.Text).ToList();
  174:  
  175:                     if (list.Count > 0)
  176:                     {
  177:                         if (!string.IsNullOrEmpty(licViewModel.FrameSelectedValue))
  178:                         {
  179:                             licViewModel.FrameSelectList = new SelectList(list, "Value", "Text", licViewModel.FrameSelectedValue);
  180:                         }
  181:                         else
  182:                         {
  183:                             licViewModel.FrameSelectList = new SelectList(list, "Value", "Text", list[0].Value.ToString());
  184:                             licViewModel.FrameSelectedValue = list[0].Value.ToString();
  185:                         }
  186:  
  187:                         CardSelectList(ref licViewModel);
  188:                     }
  189:                 }
  190:             }
  191:             /*
  192:             private static void CabinetSelectList_SelectedIndexChanged(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  193:             {
  194:                 int cabinet, msanSiteId;
  195: 
  196:                 if (cabinetSelectList.Items.Count > 0)
  197:                 {
  198:                     msanSiteId = int.Parse(msanSiteSelectList.SelectedValue);
  199:                     cabinet = int.Parse(cabinetSelectList.SelectedValue);
  200: 
  201:                     ViewState["cabinet"] = cabinet;
  202: 
  203:                     var list = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
  204:                                 where m.Msan.Site.Id == msanSiteId && m.Cabinet == cabinet
  205:                                 select new { Text = m.Frame, Value = m.Frame }).Distinct().OrderBy(u => u.Text).ToList();
  206: 
  207:                     frameSelectList.DataSource = list;
  208:                     frameSelectList.DataTextField = "Text";
  209:                     frameSelectList.DataValueField = "Value";
  210:                     frameSelectList.ViewModel();
  211: 
  212:                     FrameSelectList_SelectedIndexChanged(ref licViewModel);
  213:                 }
  214:                 else insertButton.Enabled = deleteButton.Enabled = false;
  215:             }
  216:             */
  217:         }
  218:  
  219:         ////////////////////////////////////////////////////////////////////////////
  220:  
  221:         /// <summary>
  222:         ///
  223:         /// </summary>
  224:         private static void CardSelectList(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  225:         {
  226:             if (licViewModel.CardSelectList.Count() > 0)
  227:             {
  228:                 if (!string.IsNullOrEmpty(licViewModel.CardSelectedValue))
  229:                 {
  230:                     var frame = int.Parse(licViewModel.FrameSelectedValue);
  231:  
  232:                     var list = (from s in Ia.Ftn.Cl.Models.Business.Huawei.Ems.PossibleSnForMsanDevList
  233:                                 select new { Text = s, Value = s }).Distinct().OrderBy(u => u.Text).ToList();
  234:  
  235:                     if (list.Count > 0)
  236:                     {
  237:                         if (!string.IsNullOrEmpty(licViewModel.CardSelectedValue))
  238:                         {
  239:                             licViewModel.CardSelectList = new SelectList(list, "Value", "Text", licViewModel.CardSelectedValue);
  240:                         }
  241:                         else
  242:                         {
  243:                             licViewModel.CardSelectList = new SelectList(list, "Value", "Text", list[0].Value.ToString());
  244:                             licViewModel.CardSelectedValue = list[0].Value.ToString();
  245:                         }
  246:  
  247:                         PortSelectList(ref licViewModel);
  248:                     }
  249:                 }
  250:             }
  251:             /*
  252:             private static void FrameSelectList_SelectedIndexChanged(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  253: {
  254:     int frame;
  255: 
  256:     if (frameSelectList.Items.Count > 0)
  257:     {
  258:         frame = int.Parse(frameSelectList.SelectedValue);
  259: 
  260:         ViewState["frame"] = frame;
  261: 
  262:         var list = (from s in Ia.Ftn.Cl.Models.Business.Huawei.Ems.PossibleSnForMsanDevList
  263:                     select new { Text = s, Value = s }).Distinct().OrderBy(u => u.Text).ToList();
  264: 
  265:         cardSelectList.DataSource = list;
  266:         cardSelectList.DataTextField = "Text";
  267:         cardSelectList.DataValueField = "Value";
  268:         cardSelectList.ViewModel();
  269: 
  270:         CardSelectList_SelectedIndexChanged(ref licViewModel);
  271:     }
  272:     else insertButton.Enabled = deleteButton.Enabled = false;
  273: }
  274: */
  275:  
  276:         }
  277:  
  278:         ////////////////////////////////////////////////////////////////////////////
  279:  
  280:         /// <summary>
  281:         ///
  282:         /// </summary>
  283:         private static void PortSelectList(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  284:         {
  285:             string service;
  286:  
  287:             List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont> ontList;
  288:  
  289:             if (licViewModel.CardSelectList.Count() > 0)
  290:             {
  291:                 if (!string.IsNullOrEmpty(licViewModel.CardSelectedValue))
  292:                 {
  293:                     var msanSiteId = int.Parse(licViewModel.MsanSiteSelectedValue);
  294:                     var cabinet = int.Parse(licViewModel.CabinetSelectedValue);
  295:                     var frame = int.Parse(licViewModel.FrameSelectedValue);
  296:                     var card = int.Parse(licViewModel.CardSelectedValue);
  297:  
  298:                     var listItemList = new List<SelectListItem>();
  299:  
  300:                     var msan = (from s in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList
  301:                                 where s.Id == msanSiteId
  302:                                 select s.Msans.First()).Single();
  303:  
  304:                     var licList = Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevLicListByNddMsanAndCabinetAndFrameAndFnAndSn(msan, cabinet, frame, 0, card);
  305:  
  306:                     foreach (var p in Ia.Ftn.Cl.Models.Business.Huawei.Ems.PossiblePnForMsanDevList)
  307:                     {
  308:                         service = (from m in licList where m.Pn == p select m.Service).FirstOrDefault();
  309:  
  310:                         if (!string.IsNullOrEmpty(service)) listItemList.Add(new SelectListItem(p + ": " + service, p.ToString()));
  311:                         else listItemList.Add(new SelectListItem(p + ":", p.ToString()));
  312:                     }
  313:  
  314:  
  315:  
  316:  
  317:                 }
  318:             }
  319:             /*
  320:             private static void CardSelectList_SelectedIndexChanged(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  321:             {
  322:                 int msanSiteId, cabinet, frame, card;
  323:                 string service;
  324: 
  325:                 if (cardSelectList.Items.Count > 0)
  326:                 {
  327:                     msanSiteId = int.Parse(msanSiteSelectList.SelectedValue);
  328:                     cabinet = int.Parse(cabinetSelectList.SelectedValue);
  329:                     frame = int.Parse(frameSelectList.SelectedValue);
  330:                     card = int.Parse(cardSelectList.SelectedValue);
  331: 
  332:                     ViewState["card"] = card;
  333: 
  334:                     var listItemList = new List<ListItem>();
  335: 
  336:                     var msan = (from s in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList
  337:                                 where s.Id == msanSiteId
  338:                                 select s.Msans.First()).Single();
  339: 
  340:                     var licList = Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevLicListByNddMsanAndCabinetAndFrameAndFnAndSn(msan, cabinet, frame, 0, card);
  341: 
  342:                     foreach (var p in Ia.Ftn.Cl.Models.Business.Huawei.Ems.PossiblePnForMsanDevList)
  343:                     {
  344:                         service = (from m in licList where m.Pn == p select m.Service).FirstOrDefault();
  345: 
  346:                         if (!string.IsNullOrEmpty(service)) listItemList.Add(new ListItem(p + ": " + service, p.ToString()));
  347:                         else listItemList.Add(new ListItem(p + ":", p.ToString()));
  348:                     }
  349: 
  350:                     portSelectList.DataSource = listItemList;
  351:                     portSelectList.DataTextField = "Text";
  352:                     portSelectList.DataValueField = "Value";
  353:                     portSelectList.ViewModel();
  354: 
  355:                     PortSelectList_SelectedIndexChanged(ref licViewModel);
  356:                 }
  357:                 else insertButton.Enabled = deleteButton.Enabled = false;
  358:             }
  359:             */
  360:         }
  361:  
  362:         ////////////////////////////////////////////////////////////////////////////
  363:  
  364:         /// <summary>
  365:         ///
  366:         /// </summary>
  367:         private static void OntSelectList(ref Ia.Ftn.Wa.Models.Administration.AccessNetworkViewModel accessNetworkViewModel)
  368:         {
  369:             List<Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont> ontList;
  370:  
  371:             if (accessNetworkViewModel.PonSelectList.Count() > 0)
  372:             {
  373:                 if (!string.IsNullOrEmpty(accessNetworkViewModel.PonSelectedValue))
  374:                 {
  375:                     var ponId = accessNetworkViewModel.PonSelectedValue;
  376:  
  377:                     ontList = (from o in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntList where o.Pon.Id == ponId select o).ToList();
  378:  
  379:                     var ontText = string.Empty;
  380:  
  381:                     foreach (Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont ont in ontList)
  382:                     {
  383:                         ontText += ont.Access.Name.PadRight(11, ' ') + "    " + ont.Position.PadRight(15, ' ') + "    " + ont.Ip + "   " + "\n";
  384:                     }
  385:  
  386:                     accessNetworkViewModel.OntText = ontText;
  387:                 }
  388:             }
  389:             /*
  390:             private static void PortSelectList_SelectedIndexChanged(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  391:             {
  392:                 int msanSiteId, cabinet, frame, card, port;
  393:                 string msanDevId, emsVoipPstnUserId;
  394: 
  395:                 if (portSelectList.Items.Count > 0)
  396:                 {
  397:                     msanSiteId = int.Parse(msanSiteSelectList.SelectedValue);
  398:                     cabinet = int.Parse(cabinetSelectList.SelectedValue);
  399:                     frame = int.Parse(frameSelectList.SelectedValue);
  400:                     card = int.Parse(cardSelectList.SelectedValue);
  401: 
  402:                     port = int.Parse(portSelectList.SelectedValue);
  403: 
  404:                     ViewState["port"] = port;
  405: 
  406:                     var msan = (from s in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList
  407:                                 where s.Id == msanSiteId
  408:                                 select s.Msans.First()).Single();
  409: 
  410:                     msanDevId = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
  411:                                  where m.Msan.Site.Id == msanSiteId && m.Cabinet == cabinet && m.Frame == frame
  412:                                  select m.Id).Single();
  413: 
  414:                     ViewState["msanDevId"] = msanDevId;
  415: 
  416:                     var licList = Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevLicListByNddMsanAndCabinetAndFrameAndFnAndSn(msan, cabinet, frame, 0, card);
  417: 
  418:                     var lic = (from u in licList where u.Pn == port select u).SingleOrDefault();
  419: 
  420:                     if (lic == null)
  421:                     {
  422:                         // show insert button
  423: 
  424:                         serviceTextBox.Text = string.Empty;
  425:                         serviceTextBox.ReadOnly = false;
  426:                         serviceTextBox.Enabled = true;
  427: 
  428:                         insertButton.Visible = true;
  429:                         deleteButton.Visible = false;
  430:                     }
  431:                     else
  432:                     {
  433:                         // show delete button
  434: 
  435:                         serviceTextBox.Text = lic.Service;
  436:                         serviceTextBox.ReadOnly = true;
  437:                         serviceTextBox.Enabled = false;
  438: 
  439:                         emsVoipPstnUserId = lic.EmsVoipPstnUserId;
  440: 
  441:                         ViewState["emsVoipPstnUserId"] = emsVoipPstnUserId;
  442: 
  443:                         insertButton.Visible = false;
  444:                         deleteButton.Visible = true;
  445:                     }
  446:                 }
  447:                 else insertButton.Enabled = deleteButton.Enabled = false;
  448:             }
  449:             */
  450:         }
  451:  
  452:         ////////////////////////////////////////////////////////////////////////////
  453:  
  454:         /// <summary>
  455:         ///
  456:         /// </summary>
  457:         public static void Post(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel, string commandName, string inputTextArea)
  458:         {
  459:             if (commandName == "insert") Insert(ref licViewModel);
  460:             else if (commandName == "delete") Delete(ref licViewModel);
  461:             else if (commandName == "bulkInsert") BulkInsert(ref licViewModel);
  462:             else
  463:             {
  464:             }
  465:         }
  466:  
  467:         ////////////////////////////////////////////////////////////////////////////
  468:         ////////////////////////////////////////////////////////////////////////////
  469:  
  470:         /// <summary>
  471:         ///
  472:         /// </summary>
  473:         private static void Insert(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  474:         {
  475:             var result = new Ia.Cl.Models.Result();
  476:  
  477:             var msanSiteId = int.Parse(licViewModel.MsanSiteSelectedValue);
  478:             var cabinet = int.Parse(licViewModel.CabinetSelectedValue);
  479:             var frame = int.Parse(licViewModel.FrameSelectedValue);
  480:             var card = int.Parse(licViewModel.CardSelectedValue);
  481:             var port = int.Parse(licViewModel.PortSelectedValue);
  482:             var service = licViewModel.ServiceInput;
  483:  
  484:             service = WebUtility.HtmlDecode(service);
  485:             service = service.Trim();
  486:  
  487:             var msanDevId = licViewModel.MsanDevId;
  488:  
  489:             var msan = (from s in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList
  490:                         where s.Id == msanSiteId
  491:                         select s.Msans.First()).Single();
  492:  
  493:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanCreateDeleteLicList(Ia.Ftn.Cl.Models.Business.Authority.PersistentStorageFunction.Create, licViewModel.CurrentStaffIdentityUser, msan))
  494:             {
  495:                 result = Ia.Ftn.Cl.Models.Business.Huawei.Default.InsertLic(msan, msanDevId, cabinet, frame, card, port, service, licViewModel.CurrentStaffIdentityUser);
  496:  
  497:                 if (result.IsSuccessful)
  498:                 {
  499:                     logStringBuilder.AppendLine(DateTime.UtcNow.AddHours(3).ToString("yyyy-MM-dd HH:mm")
  500:                         + ": " + licViewModel.CurrentStaffIdentityUser.FirstAndMiddleName + " inserted " + service + " at " + msan.NameSymbol + "-" + cabinet + "-" + frame + "-" + card + "-" + port
  501:                         + "\r\n<br/>");
  502:                 }
  503:             }
  504:             else result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة).");
  505:  
  506:             licViewModel.Result = result;
  507:  
  508:             licViewModel.LogLabel = logStringBuilder.ToString();
  509:         }
  510:  
  511:         ////////////////////////////////////////////////////////////////////////////
  512:  
  513:         /// <summary>
  514:         ///
  515:         /// </summary>
  516:         private static void Delete(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  517:         {
  518:             var result = new Ia.Cl.Models.Result();
  519:  
  520:             var msanSiteId = int.Parse(licViewModel.MsanSiteSelectedValue);
  521:  
  522:             var msan = (from s in Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SiteList
  523:                         where s.Id == msanSiteId
  524:                         select s.Msans.First()).Single();
  525:  
  526:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanCreateDeleteLicList(Ia.Ftn.Cl.Models.Business.Authority.PersistentStorageFunction.Delete, licViewModel.CurrentStaffIdentityUser, msan))
  527:             {
  528:                 var emsVoipPstnUserId = licViewModel.EmsVoipPstnUserId;
  529:  
  530:                 if (!string.IsNullOrEmpty(emsVoipPstnUserId))
  531:                 {
  532:                     result = Ia.Ftn.Cl.Models.Business.Huawei.Default.DeleteLic(msan, emsVoipPstnUserId, licViewModel.CurrentStaffIdentityUser, out Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic msanDevLic);
  533:  
  534:                     if (result.IsSuccessful)
  535:                     {
  536:                         logStringBuilder.AppendLine(DateTime.UtcNow.AddHours(3).ToString("yyyy-MM-dd HH:mm")
  537:                             + ": " + licViewModel.CurrentStaffIdentityUser.FirstAndMiddleName + " deleted " + msanDevLic.Service + " from " + msanDevLic.ToMsanNameSymbolCabinetFrameSnPnTextString()
  538:                             + "\r\n<br/>");
  539:                     }
  540:                 }
  541:                 else result.AddError("emsVoipPstnUserId is null or empty.");
  542:             }
  543:             else result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة).");
  544:  
  545:             licViewModel.Result = result;
  546:  
  547:             licViewModel.LogLabel = logStringBuilder.ToString();
  548:         }
  549:  
  550:         ////////////////////////////////////////////////////////////////////////////
  551:         ////////////////////////////////////////////////////////////////////////////
  552:  
  553:         /// <summary>
  554:         ///
  555:         /// </summary>
  556:         private static void BulkInsert(ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  557:         {
  558:             var result = new Ia.Cl.Models.Result();
  559:  
  560:             var input = licViewModel.InputTextArea;
  561:  
  562:             input = WebUtility.HtmlDecode(input);
  563:             input = input.Trim();
  564:  
  565:             if (Ia.Ftn.Cl.Models.Business.Authority.StaffCanCreateBulkLicList(Ia.Ftn.Cl.Models.Business.Authority.PersistentStorageFunction.Create, licViewModel.CurrentStaffIdentityUser))
  566:             {
  567:                 result = Ia.Ftn.Cl.Models.Business.Huawei.Default.BulkInsertLic(input, licViewModel.CurrentStaffIdentityUser, out StringBuilder stringBuilder);
  568:  
  569:                 if (result.IsSuccessful)
  570:                 {
  571:                     result.AddSuccess("Bulk insert was successfull (تم إدخال القائمة بنجاح)");
  572:                 }
  573:             }
  574:             else result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة)");
  575:  
  576:             licViewModel.BulkResult = result;
  577:  
  578:             //logLabel.Text = logStringBuilder.ToString();
  579:         }
  580:  
  581:         ////////////////////////////////////////////////////////////////////////////
  582:         ////////////////////////////////////////////////////////////////////////////
  583:  
  584:         /// <summary>
  585:         ///
  586:         /// </summary>
  587:         private static void CompareCurrentAndNewViewModels(ref Ia.Ftn.Wa.Models.Provision.LicViewModel currentLicViewModel, ref Ia.Ftn.Wa.Models.Provision.LicViewModel licViewModel)
  588:         {
  589:             if (licViewModel.MsanSiteSelectedValue != currentLicViewModel.MsanSiteSelectedValue)
  590:             {
  591:                 licViewModel.CabinetSelectedValue = string.Empty;
  592:                 licViewModel.FrameSelectedValue = string.Empty;
  593:                 licViewModel.CardSelectedValue = string.Empty;
  594:                 licViewModel.PortSelectedValue = string.Empty;
  595:             }
  596:             else if (licViewModel.CabinetSelectedValue != currentLicViewModel.CabinetSelectedValue)
  597:             {
  598:                 licViewModel.FrameSelectedValue = string.Empty;
  599:                 licViewModel.CardSelectedValue = string.Empty;
  600:                 licViewModel.PortSelectedValue = string.Empty;
  601:             }
  602:             else if (licViewModel.FrameSelectedValue != currentLicViewModel.FrameSelectedValue)
  603:             {
  604:                 licViewModel.CardSelectedValue = string.Empty;
  605:                 licViewModel.PortSelectedValue = string.Empty;
  606:             }
  607:             else if (licViewModel.CardSelectedValue != currentLicViewModel.CardSelectedValue)
  608:             {
  609:                 licViewModel.PortSelectedValue = string.Empty;
  610:             }
  611:             else if (licViewModel.PortSelectedValue != currentLicViewModel.PortSelectedValue)
  612:             {
  613:             }
  614:             else
  615:             {
  616:             }
  617:         }
  618:  
  619:         ////////////////////////////////////////////////////////////////////////////
  620:  
  621:         /// <summary>
  622:         ///
  623:         /// </summary>
  624:         private static void Page_ViewModel2(string msanDevId, string cabinet, string frame, string fn, string card, string port, string service)
  625:         {
  626:             var msanDev = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
  627:                            where m.Id == msanDevId
  628:                            select m).Single();
  629:  
  630:             //ViewState["msanDevId"] = msanDevId;
  631:             //ViewState["cabinet"] = msanDev.Cabinet;
  632:             //ViewState["frame"] = msanDev.Frame;
  633:  
  634:             //msanSiteSelectList.SelectedValue = msanDev.Msan.Site.Id;
  635:  
  636:             //insertButton.Enabled = deleteButton.Enabled = (Ia.Ftn.Cl.Models.Business.Authority.StaffCanCreateDeleteLicList(Ia.Ftn.Cl.Models.Business.Authority.PersistentStorageFunction.Create, staff, msanDev)) ? true : false;
  637:  
  638:             //bulkInsertButton.Enabled = (Ia.Ftn.Cl.Models.Business.Authority.StaffCanCreateBulkLicList(Ia.Ftn.Cl.Models.Business.Authority.PersistentStorageFunction.Create, staff)) ? true : false;
  639:         }
  640:  
  641:         ////////////////////////////////////////////////////////////////////////////
  642:         ////////////////////////////////////////////////////////////////////////////
  643:     }
  644:  
  645:     ////////////////////////////////////////////////////////////////////////////
  646:     ////////////////////////////////////////////////////////////////////////////
  647: }