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

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

Huawei's EMS VOIP PSTN User support class of Fixed Telecommunications Network (FTN) data model.

    1: using Microsoft.EntityFrameworkCore;
    2: using System;
    3: using System.Collections.Generic;
    4: using System.Data;
    5: using System.Linq;
    6: using System.Text;
    7:  
    8: namespace Ia.Ftn.Cl.Models.Data.Huawei
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     /// Huawei's EMS VOIP PSTN User support class of Fixed Telecommunications Network (FTN) data model.
   14:     /// </summary>
   15:     /// 
   16:     /// <remarks> 
   17:     /// Copyright © 2017-2022 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 VoipPstnUser
   30:     {
   31:         /// <summary/>
   32:         public VoipPstnUser() { }
   33:  
   34:         ////////////////////////////////////////////////////////////////////////////
   35:  
   36:         /// <summary>
   37:         ///
   38:         /// </summary>
   39:         public static bool Update(Ia.Ftn.Cl.Models.Business.Huawei.Ems.Response response, out Ia.Cl.Models.Result result)
   40:         {
   41:             bool isUpdated;
   42:             int did, queryFn, querySn, queryPn, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount, fn, sn, pn;
   43:             string id, queryCommand, queryDev, dn, nddOntIdOrMsanDevId;
   44:             DataColumnCollection columns;
   45:             DataRow columnDataRow;
   46:             Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont nddOnt;
   47:             Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser voipPstnUser, newVoipPstnUser;
   48:             Ia.Ftn.Cl.Models.Huawei.EmsOnt emsOnt;
   49:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type emsDevType;
   50:             List<string> itemIdList;
   51:             List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser> voipPstnUserList;
   52:  
   53:             isUpdated = false;
   54:             readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
   55:  
   56:             result = new Ia.Cl.Models.Result(); // remove initially then add to test all return paths
   57:  
   58:             queryCommand = response.CommandFromCorrelationTagDictionaryByCtag;
   59:  
   60:             //queryCommand = "LST-VOIPPSTNUSER::DEV=ARD_MSAN_Cabinet 1_Frame 0,FN=0,SN=2,PN=0:{ctag}::;";
   61:             //queryCommand = "LST-VOIPPSTNUSER::DEV=SAB_MSAN_Cabinet 4_Frame 0,FN=0,SN=3,PN=58:{ctag}::;";
   62:  
   63:             // LST-VOIPPSTNUSER::DEV=MDU-JBA-943-002,FN=0,SN=3,PN=10:{ctag}::;
   64:             // LST-VOIPPSTNUSER::DEV=ARD_MSAN_Cabinet 1_Frame 0,FN=0,SN=2,PN=0:{ctag}::;
   65:             queryDev = Ia.Cl.Models.Default.Match(queryCommand, @"DEV=(.+?),");
   66:             queryFn = int.Parse(Ia.Cl.Models.Default.Match(queryCommand, @"FN=(\d+)"));
   67:             querySn = int.Parse(Ia.Cl.Models.Default.Match(queryCommand, @"SN=(\d+)"));
   68:             queryPn = int.Parse(Ia.Cl.Models.Default.Match(queryCommand, @"PN=(\d+)"));
   69:  
   70:             using (var db = new Ia.Ftn.Cl.Db())
   71:             {
   72:                 if (response.CompletionCode == "COMPLD")
   73:                 {
   74:                     emsDevType = Ia.Ftn.Cl.Models.Data.Huawei.Dev.ReadTypeByDev(queryDev);
   75:  
   76:                     if (emsDevType == Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Mdu || emsDevType == Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Msan)
   77:                     {
   78:                         if (emsDevType == Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Mdu)
   79:                         {
   80:                             nddOnt = Ia.Ftn.Cl.Models.Business.Default.NddOntFromHuaweiEmsAccessNameFormat(queryDev);
   81:  
   82:                             if (nddOnt != null)
   83:                             {
   84:                                 emsOnt = (from eo in db.EmsOnts where eo.Id == nddOnt.Id select eo).SingleOrDefault();
   85:  
   86:                                 if (emsOnt != null)
   87:                                 {
   88:                                     // this should always give a single value or none
   89:                                     voipPstnUserList = (from evpu in db.EmsVoipPstnUsers
   90:                                                         where evpu.EmsOnt != null && evpu.EmsOnt.Id == emsOnt.Id && evpu.SN == querySn && evpu.PN == queryPn
   91:                                                         select evpu).ToList();
   92:  
   93:                                     nddOntIdOrMsanDevId = nddOnt.Id;
   94:                                 }
   95:                                 else
   96:                                 {
   97:                                     voipPstnUserList = null;
   98:                                     nddOntIdOrMsanDevId = string.Empty;
   99:  
  100:                                     result.AddWarning("EmsOnt is null for ont.Access.Name: " + nddOnt.Access.Name);
  101:                                 }
  102:                             }
  103:                             else
  104:                             {
  105:                                 voipPstnUserList = null;
  106:                                 nddOntIdOrMsanDevId = string.Empty;
  107:                             }
  108:                         }
  109:                         else //if (emsDevType == Ia.Ftn.Cl.Model.Business.Huawei.Dev.Type.Msan)
  110:                         {
  111:                             var msanDev = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
  112:                                            where m.Dev == queryDev
  113:                                            select m).SingleOrDefault();
  114:  
  115:                             nddOntIdOrMsanDevId = (msanDev != null) ? msanDev.Id : string.Empty;
  116:  
  117:                             voipPstnUserList = (from evpu in db.EmsVoipPstnUsers
  118:                                                 where evpu.EmsOnt == null && evpu.Id.StartsWith(nddOntIdOrMsanDevId) && evpu.SN == querySn && evpu.PN == queryPn
  119:                                                 select evpu).ToList();
  120:                         }
  121:  
  122:                         if (voipPstnUserList != null)
  123:                         {
  124:                             existingItemCount = voipPstnUserList.Count;
  125:  
  126:                             if (response.QueryDataTable != null)
  127:                             {
  128:                                 if (response.QueryDataTable.Rows.Count >= 1)
  129:                                 {
  130:                                     itemIdList = new List<string>(response.QueryDataTable.Rows.Count + 1);
  131:  
  132:                                     columns = response.QueryDataTable.Columns;
  133:                                     readItemCount = response.QueryDataTable.Rows.Count;
  134:  
  135:                                     columnDataRow = response.QueryDataTable.Rows[0];
  136:  
  137:                                     foreach (DataRow dataRow in response.QueryDataTable.Rows)
  138:                                     {
  139:                                         did = int.Parse(dataRow[columns.IndexOf("DID")].ToString());
  140:                                         fn = int.Parse(dataRow[columns.IndexOf("FN")].ToString());
  141:                                         sn = int.Parse(dataRow[columns.IndexOf("SN")].ToString());
  142:                                         pn = int.Parse(dataRow[columns.IndexOf("PN")].ToString());
  143:  
  144:                                         dn = columns.Contains("DN") ? dataRow[columns.IndexOf("DN")].ToString() : string.Empty;
  145:  
  146:                                         if (dn != "--") // "--" means empty
  147:                                         {
  148:                                             if (pn == queryPn && sn == querySn)
  149:                                             {
  150:                                                 // I'll check that the records are for a real 11 digit number, otherwise we will not send it to the database
  151:                                                 // for MDUs numbers will look like 96524805054
  152:                                                 // for MSAN numbers will look like +96524805054
  153:                                                 //if (
  154:                                                 //    Ia.Ftn.Cl.Model.Business.NumberFormatConverter.IsMatchToServiceWithCountryCode(dn) && emsDevType == Ia.Ftn.Cl.Model.Business.Huawei.Dev.Type.Mdu
  155:                                                 //    ||
  156:                                                 //    Ia.Ftn.Cl.Model.Business.NumberFormatConverter.IsMatchToImpuAid(dn) && emsDevType == Ia.Ftn.Cl.Model.Business.Huawei.Dev.Type.Msan
  157:                                                 //    )
  158:                                                 //{
  159:                                                 id = Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.VoipPstnUserId(nddOntIdOrMsanDevId, sn, pn);
  160:  
  161:                                                 voipPstnUser = (from eo in voipPstnUserList where eo.Id == id select eo).SingleOrDefault();
  162:  
  163:                                                 newVoipPstnUser = new Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser()
  164:                                                 {
  165:                                                     Id = id,
  166:                                                     DID = did,
  167:                                                     FN = fn,
  168:                                                     SN = sn,
  169:                                                     PN = pn,
  170:                                                     DN = dn.ToString(),
  171:                                                     MGID = columns.Contains("MGID") ? int.Parse(dataRow[columns.IndexOf("MGID")].ToString()) : 0,
  172:                                                     MGNAME = columns.Contains("MGNAME") ? dataRow[columns.IndexOf("MGNAME")].ToString() : string.Empty,
  173:                                                     TID = columns.Contains("TID") ? Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.SpecialIntegerParameterHandling("TID", dataRow[columns.IndexOf("TID")].ToString()) : 0,
  174:                                                     LayeredConf = columns.Contains("LayeredConf") ? dataRow[columns.IndexOf("LayeredConf")].ToString() : string.Empty,
  175:                                                     HighLevelWidth = columns.Contains("HighLevelWidth") ? int.Parse(dataRow[columns.IndexOf("HighLevelWidth")].ToString()) : 0,
  176:                                                     LowerLevelWidth = columns.Contains("LowerLevelWidth") ? int.Parse(dataRow[columns.IndexOf("LowerLevelWidth")].ToString()) : 0,
  177:                                                     Voltage = columns.Contains("Voltage") ? dataRow[columns.IndexOf("Voltage")].ToString() : string.Empty,
  178:                                                     KCType = columns.Contains("KCType") ? dataRow[columns.IndexOf("KCType")].ToString() : string.Empty,
  179:                                                     VoiceGain = columns.Contains("VoiceGain") ? dataRow[columns.IndexOf("VoiceGain")].ToString() : string.Empty,
  180:                                                     LimitPulseDial = columns.Contains("LimitPulseDial") ? dataRow[columns.IndexOf("LimitPulseDial")].ToString() : string.Empty,
  181:                                                     RevPolarity = columns.Contains("RevPolarity") ? dataRow[columns.IndexOf("RevPolarity")].ToString() : string.Empty,
  182:                                                     RevPoleLevel = columns.Contains("RevPoleLevel") ? int.Parse(dataRow[columns.IndexOf("RevPoleLevel")].ToString()) : 0,
  183:                                                     RevPolePulse = columns.Contains("RevPolePulse") ? dataRow[columns.IndexOf("RevPolePulse")].ToString() : string.Empty,
  184:                                                     PSTAT = columns.Contains("PSTAT") ? dataRow[columns.IndexOf("PSTAT")].ToString() : string.Empty,
  185:                                                     ConfigStatus = columns.Contains("ConfigStatus") ? dataRow[columns.IndexOf("ConfigStatus")].ToString() : string.Empty,
  186:                                                     ServiceStatus = columns.Contains("ServiceStatus") ? dataRow[columns.IndexOf("ServiceStatus")].ToString() : string.Empty,
  187:                                                     ServiceType = columns.Contains("ServiceType") ? dataRow[columns.IndexOf("ServiceType")].ToString() : string.Empty,
  188:                                                     ALIAS = columns.Contains("ALIAS") ? dataRow[columns.IndexOf("ALIAS")].ToString() : string.Empty,
  189:                                                     UserType = columns.Contains("UserType") ? dataRow[columns.IndexOf("UserType")].ToString() : string.Empty,
  190:                                                     Impedance = columns.Contains("Impedance") ? dataRow[columns.IndexOf("Impedance")].ToString() : string.Empty,
  191:                                                     Current = columns.Contains("Current") ? dataRow[columns.IndexOf("Current")].ToString() : string.Empty,
  192:                                                     DCTime = columns.Contains("DCTime") ? int.Parse(dataRow[columns.IndexOf("DCTime")].ToString()) : 0,
  193:                                                     PITime = columns.Contains("PITime") ? Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.SpecialIntegerParameterHandling("PITime", dataRow[columns.IndexOf("PITime")].ToString()) : 0,
  194:                                                     FSKDelayInterval = columns.Contains("FSKDelayInterval") ? int.Parse(dataRow[columns.IndexOf("FSKDelayInterval")].ToString()) : 0,
  195:                                                     ActualVoiceGain = columns.Contains("ActualVoiceGain") ? dataRow[columns.IndexOf("ActualVoiceGain")].ToString() : string.Empty,
  196:                                                     CidTransWhen = columns.Contains("CidTransWhen") ? dataRow[columns.IndexOf("CidTransWhen")].ToString() : string.Empty,
  197:                                                     CidFormat = columns.Contains("CidFormat") ? dataRow[columns.IndexOf("CidFormat")].ToString() : string.Empty,
  198:                                                     OverloadPRI = columns.Contains("OverloadPRI") ? dataRow[columns.IndexOf("OverloadPRI")].ToString() : string.Empty,
  199:                                                     ImpedanceProfile = columns.Contains("ImpedanceProfile") ? dataRow[columns.IndexOf("ImpedanceProfile")].ToString() : string.Empty,
  200:                                                     SendVoiceGain = columns.Contains("SendVoiceGain") ? dataRow[columns.IndexOf("SendVoiceGain")].ToString() : string.Empty,
  201:                                                     RecvVoiceGain = columns.Contains("RecvVoiceGain") ? dataRow[columns.IndexOf("RecvVoiceGain")].ToString() : string.Empty,
  202:                                                     RevPolarityMode = columns.Contains("RevPolarityMode") ? dataRow[columns.IndexOf("RevPolarityMode")].ToString() : string.Empty,
  203:                                                     PortRunState = columns.Contains("PortRunState") ? dataRow[columns.IndexOf("PortRunState")].ToString() : string.Empty,
  204:                                                     PortTestState = columns.Contains("PortTestState") ? dataRow[columns.IndexOf("PortTestState")].ToString() : string.Empty,
  205:                                                     PortLineState = columns.Contains("PortLineState") ? dataRow[columns.IndexOf("PortLineState")].ToString() : string.Empty,
  206:                                                     PortLoopState = columns.Contains("PortLoopState") ? dataRow[columns.IndexOf("PortLoopState")].ToString() : string.Empty,
  207:                                                     ServiceRunState = columns.Contains("ServiceRunState") ? dataRow[columns.IndexOf("ServiceRunState")].ToString() : string.Empty,
  208:                                                     ServiceAdminState = columns.Contains("ServiceAdminState") ? dataRow[columns.IndexOf("ServiceAdminState")].ToString() : string.Empty,
  209:                                                     ActualSendVoiceGain = columns.Contains("ActualSendVoiceGain") ? dataRow[columns.IndexOf("ActualSendVoiceGain")].ToString() : string.Empty,
  210:                                                     ActualRecvVo = columns.Contains("ActualRecvVo") ? dataRow[columns.IndexOf("ActualRecvVo")].ToString() : string.Empty,
  211:                                                     AGCEnable = columns.Contains("AGCEnable") ? dataRow[columns.IndexOf("AGCEnable")].ToString() : string.Empty,
  212:                                                     AGCEnableLevel = columns.Contains("AGCEnableLevel") ? int.Parse(dataRow[columns.IndexOf("AGCEnableLevel")].ToString()) : 0,
  213:                                                     SNSEnable = columns.Contains("SNSEnable") ? dataRow[columns.IndexOf("SNSEnable")].ToString() : string.Empty,
  214:                                                     SNSEnableLevel = columns.Contains("SNSEnableLevel") ? int.Parse(dataRow[columns.IndexOf("SNSEnableLevel")].ToString()) : 0,
  215:                                                     NlpMode = columns.Contains("NlpMode") ? dataRow[columns.IndexOf("NlpMode")].ToString() : string.Empty,
  216:                                                     LineLockEnable = columns.Contains("LineLockEnable") ? dataRow[columns.IndexOf("LineLockEnable")].ToString() : string.Empty,
  217:                                                     DspInputGain = columns.Contains("DspInputGain") ? dataRow[columns.IndexOf("DspInputGain")].ToString() : string.Empty,
  218:                                                     DspOutputGain = columns.Contains("DspOutputGain") ? dataRow[columns.IndexOf("DspOutputGain")].ToString() : string.Empty,
  219:                                                     ClipReversePole = columns.Contains("ClipReversePole") ? dataRow[columns.IndexOf("ClipReversePole")].ToString() : string.Empty,
  220:                                                     DEFAULTCLI = columns.Contains("DEFAULTCLI") ? dataRow[columns.IndexOf("DEFAULTCLI")].ToString() : string.Empty,
  221:                                                     USERGROUPID = columns.Contains("USERGROUPID") ? int.Parse(dataRow[columns.IndexOf("USERGROUPID")].ToString()) : 0,
  222:                                                     ADJUSTFACTOR = columns.Contains("ADJUSTFACTOR") ? int.Parse(dataRow[columns.IndexOf("ADJUSTFACTOR")].ToString()) : 0,
  223:                                                     DSPPROFILE = columns.Contains("DSPPROFILE") ? dataRow[columns.IndexOf("DSPPROFILE")].ToString() : string.Empty,
  224:  
  225:                                                     EmsOnt = (emsDevType == Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Mdu) ? (from eo in db.EmsOnts where eo.Id == nddOntIdOrMsanDevId select eo).SingleOrDefault() : null
  226:                                                 };
  227:  
  228:                                                 if (voipPstnUser == null)
  229:                                                 {
  230:                                                     newVoipPstnUser.Created = newVoipPstnUser.Updated = DateTime.UtcNow.AddHours(3);
  231:  
  232:                                                     db.EmsVoipPstnUsers.Add(newVoipPstnUser);
  233:  
  234:                                                     insertedItemCount++;
  235:                                                 }
  236:                                                 else // update
  237:                                                 {
  238:                                                     // below: copy values from newVoipPstnUser to voipPstnUser
  239:  
  240:                                                     if (voipPstnUser.Update(newVoipPstnUser))
  241:                                                     {
  242:                                                         db.EmsVoipPstnUsers.Attach(voipPstnUser);
  243:                                                         db.Entry(voipPstnUser).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  244:  
  245:                                                         updatedItemCount++;
  246:                                                     }
  247:                                                 }
  248:  
  249:                                                 itemIdList.Add(id); // keep at the end
  250:                                                 //}
  251:                                                 //else
  252:                                                 //{
  253:                                                 //    result.AddError("dn:" + dn + ", emsDevType:" + emsDevType.ToString() + ". dn and emsDevtype values are inconsistent.");
  254:                                                 //}
  255:                                             }
  256:                                             else
  257:                                             {
  258:                                                 result.AddError("LST-VOIPPSTNUSER (" + response.Ctag + "): pn != queryPn and/or sn != querySn.");
  259:                                             }
  260:                                         }
  261:                                         else
  262:                                         {
  263:                                             result.AddWarning("LST-VOIPPSTNUSER (" + response.Ctag + "): dn is -- empty.");
  264:                                         }
  265:                                     }
  266:  
  267:                                     // below: this function will remove values that were not present in the reading
  268:                                     if (voipPstnUserList.Count > 0)
  269:                                     {
  270:                                         foreach (Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser v in voipPstnUserList)
  271:                                         {
  272:                                             if (!itemIdList.Contains(v.Id))
  273:                                             {
  274:                                                 voipPstnUser = (from evpu in db.EmsVoipPstnUsers
  275:                                                                 where /*evpu.EmsOnt != null &&*/ evpu.Id == v.Id
  276:                                                                 select evpu).SingleOrDefault();
  277:  
  278:                                                 db.EmsVoipPstnUsers.Remove(voipPstnUser);
  279:  
  280:                                                 deletedItemCount++;
  281:                                             }
  282:                                         }
  283:                                     }
  284:                                 }
  285:                                 else //if (response.QueryDataTable.Rows.Count == 0)
  286:                                 {
  287:                                     if (voipPstnUserList.Count > 0)
  288:                                     {
  289:                                         foreach (Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser v in voipPstnUserList)
  290:                                         {
  291:                                             voipPstnUser = (from evpu in db.EmsVoipPstnUsers
  292:                                                             where /*evpu.EmsOnt != null &&*/ evpu.Id == v.Id
  293:                                                             select evpu).SingleOrDefault();
  294:  
  295:                                             db.EmsVoipPstnUsers.Remove(voipPstnUser);
  296:  
  297:                                             deletedItemCount++;
  298:                                         }
  299:                                     }
  300:                                 }
  301:  
  302:                                 db.SaveChanges();
  303:  
  304:                                 if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
  305:                                 else isUpdated = false;
  306:  
  307:                                 result.AddSuccess("LST-VOIPPSTNUSER (" + response.Ctag + "): (" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ")");
  308:                             }
  309:                             else
  310:                             {
  311:                                 result.AddWarning("LST-VOIPPSTNUSER (" + response.Ctag + "): (" + response.CompletionCode + ", " + response.ResultCode.ToString() + ")");
  312:                             }
  313:                         }
  314:                         else
  315:                         {
  316:                             result.AddError("LST-VOIPPSTNUSER (" + response.Ctag + "): voipPstnUserList is null.");
  317:                         }
  318:                     }
  319:                     else
  320:                     {
  321:                         result.AddError("LST-VOIPPSTNUSER (" + response.Ctag + "): for DEV: " + queryDev + " emsDevType is neither MDU nor MSAN.");
  322:                     }
  323:                 }
  324:                 else
  325:                 {
  326:                     result.AddError("LST-VOIPPSTNUSER (" + response.Ctag + "): (" + response.CompletionCode + ", " + response.ResultCode.ToString() + ")");
  327:                 }
  328:             }
  329:  
  330:             return isUpdated;
  331:         }
  332:  
  333:         ////////////////////////////////////////////////////////////////////////////
  334:  
  335:         /// <summary>
  336:         ///
  337:         /// </summary>
  338:         public static bool UpdateByDn(Ia.Ftn.Cl.Models.Business.Huawei.Ems.Response response, out string updatedService, out Ia.Cl.Models.Result result)
  339:         {
  340:             bool isUpdated;
  341:             int did, readItemCount, existingItemCount, insertedItemCount, updatedItemCount, deletedItemCount, fn, sn, pn;
  342:             string id, queryCommand, queryDn, dn, dev, nddOntIdOrMsanDevId;
  343:             DataColumnCollection columns;
  344:             DataRow columnDataRow;
  345:             Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Ont nddOnt;
  346:             Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser voipPstnUser, newVoipPstnUser;
  347:             Ia.Ftn.Cl.Models.Huawei.EmsOnt emsOnt;
  348:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type emsDevType;
  349:             List<string> itemIdList;
  350:             List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser> voipPstnUserList;
  351:  
  352:             isUpdated = false;
  353:             updatedService = string.Empty;
  354:             readItemCount = existingItemCount = insertedItemCount = updatedItemCount = deletedItemCount = 0;
  355:  
  356:             result = new Ia.Cl.Models.Result(); // remove initially then add to test all return paths
  357:  
  358:             using (var db = new Ia.Ftn.Cl.Db())
  359:             {
  360:                 if (response.CompletionCode == "COMPLD")
  361:                 {
  362:                     //if (response.ResultCode == Ia.Ftn.Cl.Model.Client.Huawei.Ems.ResultCode.NoMatchingPortPleaseCheckTheDataSetting)
  363:                     //{
  364:                     //    result.AddWarning("LST-VOIPPSTNUSER: (" + response.CompletionCode + ", " + response.ResultCode.ToString() + ")");
  365:                     //}
  366:                     //else //if (response.ResultCode == Ia.Ftn.Cl.Model.Client.Huawei.Ems.ResultCode.Succeeded)
  367:                     //{
  368:                     queryCommand = response.CommandFromCorrelationTagDictionaryByCtag;
  369:  
  370:                     //queryCommand = "LST-VOIPPSTNUSER::DN=96524805054:{ctag}::;";
  371:  
  372:                     // LST-VOIPPSTNUSER::DN=+96524805054:{ctag}::;
  373:                     // LST-VOIPPSTNUSER::DN=96524805054:{ctag}::;
  374:                     queryDn = Ia.Cl.Models.Default.Match(queryCommand, @"DN=(.+?):");
  375:  
  376:                     // VoIP PSTN user of the device ARD_MSAN_Cabinet 1_Frame 0
  377:                     // VoIP PSTN user of the device MDU-MHL-2101-004
  378:                     dev = response.Title.Replace("VoIP PSTN user of the device ", "");
  379:  
  380:                     emsDevType = Ia.Ftn.Cl.Models.Data.Huawei.Dev.ReadTypeByDev(dev);
  381:  
  382:                     if (emsDevType != Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Mdu && emsDevType != Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Msan)
  383:                     {
  384:                         emsDevType = Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.DevTypeFromDn(queryDn);
  385:                     }
  386:  
  387:                     if (emsDevType == Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Mdu || emsDevType == Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Msan)
  388:                     {
  389:                         if (emsDevType == Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Mdu)
  390:                         {
  391:                             nddOnt = Ia.Ftn.Cl.Models.Business.Default.NddOntFromHuaweiEmsAccessNameFormat(dev);
  392:  
  393:                             nddOntIdOrMsanDevId = (nddOnt != null) ? nddOnt.Id : string.Empty;
  394:  
  395:                             if (nddOnt != null)
  396:                             {
  397:                                 emsOnt = (from eo in db.EmsOnts where eo.Id == nddOnt.Id select eo).SingleOrDefault();
  398:  
  399:                                 if (emsOnt != null)
  400:                                 {
  401:                                     // this should always give a single value or none
  402:                                     voipPstnUserList = (from evpu in db.EmsVoipPstnUsers
  403:                                                         where evpu.EmsOnt != null && evpu.EmsOnt.Id == emsOnt.Id && evpu.DN == queryDn
  404:                                                         select evpu).ToList();
  405:                                 }
  406:                                 else
  407:                                 {
  408:                                     voipPstnUserList = new List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser>();
  409:                                 }
  410:                             }
  411:                             else
  412:                             {
  413:                                 voipPstnUserList = new List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser>();
  414:                             }
  415:                         }
  416:                         else //if (emsDevType == Ia.Ftn.Cl.Model.Business.Huawei.Dev.Type.Msan)
  417:                         {
  418:                             var msanDev = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
  419:                                            where m.Dev == dev
  420:                                            select m).SingleOrDefault();
  421:  
  422:                             nddOntIdOrMsanDevId = (msanDev != null) ? msanDev.Id : string.Empty;
  423:  
  424:                             voipPstnUserList = (from evpu in db.EmsVoipPstnUsers
  425:                                                 where evpu.EmsOnt == null && evpu.Id.StartsWith(nddOntIdOrMsanDevId) && evpu.DN == queryDn
  426:                                                 select evpu).ToList();
  427:                         }
  428:  
  429:                         if (voipPstnUserList != null)
  430:                         {
  431:                             existingItemCount = voipPstnUserList.Count;
  432:  
  433:                             if (response.QueryDataTable != null)
  434:                             {
  435:                                 if (response.QueryDataTable.Rows.Count >= 1)
  436:                                 {
  437:                                     itemIdList = new List<string>(response.QueryDataTable.Rows.Count + 1);
  438:  
  439:                                     columns = response.QueryDataTable.Columns;
  440:                                     readItemCount = response.QueryDataTable.Rows.Count;
  441:  
  442:                                     columnDataRow = response.QueryDataTable.Rows[0];
  443:  
  444:                                     foreach (DataRow dataRow in response.QueryDataTable.Rows)
  445:                                     {
  446:                                         did = int.Parse(dataRow[columns.IndexOf("DID")].ToString());
  447:                                         fn = int.Parse(dataRow[columns.IndexOf("FN")].ToString());
  448:                                         sn = int.Parse(dataRow[columns.IndexOf("SN")].ToString());
  449:                                         pn = int.Parse(dataRow[columns.IndexOf("PN")].ToString());
  450:  
  451:                                         dn = columns.Contains("DN") ? dataRow[columns.IndexOf("DN")].ToString() : string.Empty;
  452:  
  453:                                         if (dn != "--") // "--" means empty
  454:                                         {
  455:                                             if (dn == queryDn)
  456:                                             {
  457:                                                 id = Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.VoipPstnUserId(nddOntIdOrMsanDevId, sn, pn);
  458:  
  459:                                                 voipPstnUser = (from eo in voipPstnUserList where eo.Id == id select eo).SingleOrDefault();
  460:  
  461:                                                 newVoipPstnUser = new Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser()
  462:                                                 {
  463:                                                     Id = id,
  464:                                                     DID = did,
  465:                                                     FN = fn,
  466:                                                     SN = sn,
  467:                                                     PN = pn,
  468:                                                     DN = dn.ToString(),
  469:                                                     MGID = columns.Contains("MGID") ? int.Parse(dataRow[columns.IndexOf("MGID")].ToString()) : 0,
  470:                                                     MGNAME = columns.Contains("MGNAME") ? dataRow[columns.IndexOf("MGNAME")].ToString() : string.Empty,
  471:                                                     TID = columns.Contains("TID") ? Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.SpecialIntegerParameterHandling("TID", dataRow[columns.IndexOf("TID")].ToString()) : 0,
  472:                                                     LayeredConf = columns.Contains("LayeredConf") ? dataRow[columns.IndexOf("LayeredConf")].ToString() : string.Empty,
  473:                                                     HighLevelWidth = columns.Contains("HighLevelWidth") ? int.Parse(dataRow[columns.IndexOf("HighLevelWidth")].ToString()) : 0,
  474:                                                     LowerLevelWidth = columns.Contains("LowerLevelWidth") ? int.Parse(dataRow[columns.IndexOf("LowerLevelWidth")].ToString()) : 0,
  475:                                                     Voltage = columns.Contains("Voltage") ? dataRow[columns.IndexOf("Voltage")].ToString() : string.Empty,
  476:                                                     KCType = columns.Contains("KCType") ? dataRow[columns.IndexOf("KCType")].ToString() : string.Empty,
  477:                                                     VoiceGain = columns.Contains("VoiceGain") ? dataRow[columns.IndexOf("VoiceGain")].ToString() : string.Empty,
  478:                                                     LimitPulseDial = columns.Contains("LimitPulseDial") ? dataRow[columns.IndexOf("LimitPulseDial")].ToString() : string.Empty,
  479:                                                     RevPolarity = columns.Contains("RevPolarity") ? dataRow[columns.IndexOf("RevPolarity")].ToString() : string.Empty,
  480:                                                     RevPoleLevel = columns.Contains("RevPoleLevel") ? int.Parse(dataRow[columns.IndexOf("RevPoleLevel")].ToString()) : 0,
  481:                                                     RevPolePulse = columns.Contains("RevPolePulse") ? dataRow[columns.IndexOf("RevPolePulse")].ToString() : string.Empty,
  482:                                                     PSTAT = columns.Contains("PSTAT") ? dataRow[columns.IndexOf("PSTAT")].ToString() : string.Empty,
  483:                                                     ConfigStatus = columns.Contains("ConfigStatus") ? dataRow[columns.IndexOf("ConfigStatus")].ToString() : string.Empty,
  484:                                                     ServiceStatus = columns.Contains("ServiceStatus") ? dataRow[columns.IndexOf("ServiceStatus")].ToString() : string.Empty,
  485:                                                     ServiceType = columns.Contains("ServiceType") ? dataRow[columns.IndexOf("ServiceType")].ToString() : string.Empty,
  486:                                                     ALIAS = columns.Contains("ALIAS") ? dataRow[columns.IndexOf("ALIAS")].ToString() : string.Empty,
  487:                                                     UserType = columns.Contains("UserType") ? dataRow[columns.IndexOf("UserType")].ToString() : string.Empty,
  488:                                                     Impedance = columns.Contains("Impedance") ? dataRow[columns.IndexOf("Impedance")].ToString() : string.Empty,
  489:                                                     Current = columns.Contains("Current") ? dataRow[columns.IndexOf("Current")].ToString() : string.Empty,
  490:                                                     DCTime = columns.Contains("DCTime") ? int.Parse(dataRow[columns.IndexOf("DCTime")].ToString()) : 0,
  491:                                                     PITime = columns.Contains("PITime") ? Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.SpecialIntegerParameterHandling("PITime", dataRow[columns.IndexOf("PITime")].ToString()) : 0,
  492:                                                     FSKDelayInterval = columns.Contains("FSKDelayInterval") ? int.Parse(dataRow[columns.IndexOf("FSKDelayInterval")].ToString()) : 0,
  493:                                                     ActualVoiceGain = columns.Contains("ActualVoiceGain") ? dataRow[columns.IndexOf("ActualVoiceGain")].ToString() : string.Empty,
  494:                                                     CidTransWhen = columns.Contains("CidTransWhen") ? dataRow[columns.IndexOf("CidTransWhen")].ToString() : string.Empty,
  495:                                                     CidFormat = columns.Contains("CidFormat") ? dataRow[columns.IndexOf("CidFormat")].ToString() : string.Empty,
  496:                                                     OverloadPRI = columns.Contains("OverloadPRI") ? dataRow[columns.IndexOf("OverloadPRI")].ToString() : string.Empty,
  497:                                                     ImpedanceProfile = columns.Contains("ImpedanceProfile") ? dataRow[columns.IndexOf("ImpedanceProfile")].ToString() : string.Empty,
  498:                                                     SendVoiceGain = columns.Contains("SendVoiceGain") ? dataRow[columns.IndexOf("SendVoiceGain")].ToString() : string.Empty,
  499:                                                     RecvVoiceGain = columns.Contains("RecvVoiceGain") ? dataRow[columns.IndexOf("RecvVoiceGain")].ToString() : string.Empty,
  500:                                                     RevPolarityMode = columns.Contains("RevPolarityMode") ? dataRow[columns.IndexOf("RevPolarityMode")].ToString() : string.Empty,
  501:                                                     PortRunState = columns.Contains("PortRunState") ? dataRow[columns.IndexOf("PortRunState")].ToString() : string.Empty,
  502:                                                     PortTestState = columns.Contains("PortTestState") ? dataRow[columns.IndexOf("PortTestState")].ToString() : string.Empty,
  503:                                                     PortLineState = columns.Contains("PortLineState") ? dataRow[columns.IndexOf("PortLineState")].ToString() : string.Empty,
  504:                                                     PortLoopState = columns.Contains("PortLoopState") ? dataRow[columns.IndexOf("PortLoopState")].ToString() : string.Empty,
  505:                                                     ServiceRunState = columns.Contains("ServiceRunState") ? dataRow[columns.IndexOf("ServiceRunState")].ToString() : string.Empty,
  506:                                                     ServiceAdminState = columns.Contains("ServiceAdminState") ? dataRow[columns.IndexOf("ServiceAdminState")].ToString() : string.Empty,
  507:                                                     ActualSendVoiceGain = columns.Contains("ActualSendVoiceGain") ? dataRow[columns.IndexOf("ActualSendVoiceGain")].ToString() : string.Empty,
  508:                                                     ActualRecvVo = columns.Contains("ActualRecvVo") ? dataRow[columns.IndexOf("ActualRecvVo")].ToString() : string.Empty,
  509:                                                     AGCEnable = columns.Contains("AGCEnable") ? dataRow[columns.IndexOf("AGCEnable")].ToString() : string.Empty,
  510:                                                     AGCEnableLevel = columns.Contains("AGCEnableLevel") ? int.Parse(dataRow[columns.IndexOf("AGCEnableLevel")].ToString()) : 0,
  511:                                                     SNSEnable = columns.Contains("SNSEnable") ? dataRow[columns.IndexOf("SNSEnable")].ToString() : string.Empty,
  512:                                                     SNSEnableLevel = columns.Contains("SNSEnableLevel") ? int.Parse(dataRow[columns.IndexOf("SNSEnableLevel")].ToString()) : 0,
  513:                                                     NlpMode = columns.Contains("NlpMode") ? dataRow[columns.IndexOf("NlpMode")].ToString() : string.Empty,
  514:                                                     LineLockEnable = columns.Contains("LineLockEnable") ? dataRow[columns.IndexOf("LineLockEnable")].ToString() : string.Empty,
  515:                                                     DspInputGain = columns.Contains("DspInputGain") ? dataRow[columns.IndexOf("DspInputGain")].ToString() : string.Empty,
  516:                                                     DspOutputGain = columns.Contains("DspOutputGain") ? dataRow[columns.IndexOf("DspOutputGain")].ToString() : string.Empty,
  517:                                                     ClipReversePole = columns.Contains("ClipReversePole") ? dataRow[columns.IndexOf("ClipReversePole")].ToString() : string.Empty,
  518:                                                     DEFAULTCLI = columns.Contains("DEFAULTCLI") ? dataRow[columns.IndexOf("DEFAULTCLI")].ToString() : string.Empty,
  519:                                                     USERGROUPID = columns.Contains("USERGROUPID") ? int.Parse(dataRow[columns.IndexOf("USERGROUPID")].ToString()) : 0,
  520:                                                     ADJUSTFACTOR = columns.Contains("ADJUSTFACTOR") ? int.Parse(dataRow[columns.IndexOf("ADJUSTFACTOR")].ToString()) : 0,
  521:                                                     DSPPROFILE = columns.Contains("DSPPROFILE") ? dataRow[columns.IndexOf("DSPPROFILE")].ToString() : string.Empty,
  522:  
  523:                                                     EmsOnt = (emsDevType == Ia.Ftn.Cl.Models.Business.Huawei.Dev.Type.Mdu) ? (from eo in db.EmsOnts where eo.Id == nddOntIdOrMsanDevId select eo).SingleOrDefault() : null
  524:                                                 };
  525:  
  526:                                                 if (voipPstnUser == null)
  527:                                                 {
  528:                                                     newVoipPstnUser.Created = newVoipPstnUser.Updated = DateTime.UtcNow.AddHours(3);
  529:  
  530:                                                     db.EmsVoipPstnUsers.Add(newVoipPstnUser);
  531:  
  532:                                                     insertedItemCount++;
  533:                                                 }
  534:                                                 else // update
  535:                                                 {
  536:                                                     // below: copy values from newVoipPstnUser to ontSipInfo
  537:  
  538:                                                     if (voipPstnUser.Update(newVoipPstnUser))
  539:                                                     {
  540:                                                         db.EmsVoipPstnUsers.Attach(voipPstnUser);
  541:                                                         db.Entry(voipPstnUser).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  542:  
  543:                                                         updatedItemCount++;
  544:                                                     }
  545:                                                 }
  546:  
  547:                                                 itemIdList.Add(id); // keep at the end
  548:  
  549:                                                 updatedService = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(dn);
  550:                                             }
  551:                                             else result.AddError("LST-VOIPPSTNUSER (" + response.Ctag + "): dn not equal to queryDn.");
  552:                                         }
  553:                                         else result.AddWarning("LST-VOIPPSTNUSER (" + response.Ctag + "): dn is -- empty.");
  554:                                     }
  555:  
  556:                                     // below: this function will remove values that were not present in the reading
  557:                                     if (voipPstnUserList.Count > 0)
  558:                                     {
  559:                                         foreach (Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser v in voipPstnUserList)
  560:                                         {
  561:                                             if (!itemIdList.Contains(v.Id))
  562:                                             {
  563:                                                 voipPstnUser = (from evpu in db.EmsVoipPstnUsers
  564:                                                                 where /*evpu.EmsOnt != null &&*/ evpu.Id == v.Id
  565:                                                                 select evpu).SingleOrDefault();
  566:  
  567:                                                 db.EmsVoipPstnUsers.Remove(voipPstnUser);
  568:  
  569:                                                 deletedItemCount++;
  570:  
  571:                                                 updatedService = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(voipPstnUser.DN);
  572:                                             }
  573:                                         }
  574:                                     }
  575:                                 }
  576:                                 else //if (response.QueryDataTable.Rows.Count == 0)
  577:                                 {
  578:                                     if (voipPstnUserList.Count > 0)
  579:                                     {
  580:                                         foreach (Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser v in voipPstnUserList)
  581:                                         {
  582:                                             voipPstnUser = (from evpu in db.EmsVoipPstnUsers
  583:                                                             where /*evpu.EmsOnt != null &&*/ evpu.Id == v.Id
  584:                                                             select evpu).SingleOrDefault();
  585:  
  586:                                             db.EmsVoipPstnUsers.Remove(voipPstnUser);
  587:  
  588:                                             deletedItemCount++;
  589:  
  590:                                             updatedService = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(voipPstnUser.DN);
  591:                                         }
  592:                                     }
  593:                                 }
  594:                             }
  595:                             else
  596:                             {
  597:                                 if (voipPstnUserList.Count > 0)
  598:                                 {
  599:                                     foreach (Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser v in voipPstnUserList)
  600:                                     {
  601:                                         voipPstnUser = (from evpu in db.EmsVoipPstnUsers
  602:                                                         where /*evpu.EmsOnt != null &&*/ evpu.Id == v.Id
  603:                                                         select evpu).SingleOrDefault();
  604:  
  605:                                         db.EmsVoipPstnUsers.Remove(voipPstnUser);
  606:  
  607:                                         deletedItemCount++;
  608:  
  609:                                         updatedService = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(voipPstnUser.DN);
  610:                                     }
  611:                                 }
  612:                             }
  613:  
  614:                             db.SaveChanges();
  615:  
  616:                             if (insertedItemCount != 0 || updatedItemCount != 0 || deletedItemCount != 0) isUpdated = true;
  617:                             else isUpdated = false;
  618:  
  619:                             result.AddSuccess("LST-VOIPPSTNUSER (" + response.Ctag + "): (" + readItemCount + "/" + existingItemCount + "/" + insertedItemCount + "," + updatedItemCount + "," + deletedItemCount + ")");
  620:                         }
  621:                         else
  622:                         {
  623:                             result.AddError("LST-VOIPPSTNUSER (" + response.Ctag + "): voipPstnUserList is null.");
  624:                         }
  625:                     }
  626:                     else
  627:                     {
  628:                         result.AddError("LST-VOIPPSTNUSER (" + response.Ctag + "): for DEV: " + dev + " emsDevType is neither MDU nor MSAN.");
  629:                     }
  630:                     //}
  631:                     //else
  632:                     //{
  633:                     //    result.AddError("LST-VOIPPSTNUSER: (" + response.CompletionCode + ", " + response.ResultCode.ToString() + ")");
  634:                     //}
  635:                 }
  636:                 else
  637:                 {
  638:                     result.AddError("LST-VOIPPSTNUSER (" + response.Ctag + "): (" + response.CompletionCode + ", " + response.ResultCode.ToString() + ")");
  639:                 }
  640:             }
  641:  
  642:             return isUpdated;
  643:         }
  644:  
  645:         ////////////////////////////////////////////////////////////////////////////
  646:  
  647:         /// <summary>
  648:         ///
  649:         /// </summary>
  650:         public static List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser> List()
  651:         {
  652:             List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser> list;
  653:  
  654:             using (var db = new Ia.Ftn.Cl.Db())
  655:             {
  656:                 list = (from evpu in db.EmsVoipPstnUsers
  657:                             //where evpu.EmsOnt != null
  658:                         select evpu).ToList();
  659:             }
  660:  
  661:             return list;
  662:         }
  663:  
  664:         ////////////////////////////////////////////////////////////////////////////
  665:  
  666:         /// <summary>
  667:         ///
  668:         /// </summary>
  669:         public static List<string> ServiceList()
  670:         {
  671:             List<string> list;
  672:  
  673:             using (var db = new Ia.Ftn.Cl.Db())
  674:             {
  675:                 var list0 = (from evpu in db.EmsVoipPstnUsers select evpu.DN).AsNoTracking().ToList();
  676:  
  677:                 list = (from l in list0 select Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(l)).Distinct().ToList();
  678:             }
  679:  
  680:             return list;
  681:         }
  682:  
  683:         ////////////////////////////////////////////////////////////////////////////
  684:  
  685:         /// <summary>
  686:         ///
  687:         /// </summary>
  688:         public static List<string> DuplicateMduDnServiceWithCountryCodeOrMsanDnServiceImpuAidServiceList()
  689:         {
  690:             List<string> list;
  691:  
  692:             //var dummy = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.ImpuAid("");
  693:  
  694:             // I'll check that the records are for a real 11 digit number, otherwise we will not send it to the database
  695:             // for MDUs numbers will look like 96524805054 Ia.Ftn.Cl.Model.Business.NumberFormatConverter.IsMatchToServiceWithCountryCode(dn);
  696:             // for MSAN numbers will look like +96524805054 Ia.Ftn.Cl.Model.Business.NumberFormatConverter.IsMatchToImpuAid(dn)
  697:  
  698:             using (var db = new Ia.Ftn.Cl.Db())
  699:             {
  700:                 var list0 = (from evpu1 in db.EmsVoipPstnUsers
  701:                              join evpu2 in db.EmsVoipPstnUsers on evpu1.DN equals evpu2.DN
  702:                              where evpu1.Id != evpu2.Id
  703:                              select new { Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(evpu1.DN) }).Distinct().ToList();
  704:  
  705:                 var list1 = (from evpu1 in db.EmsVoipPstnUsers
  706:                              join evpu2 in db.EmsVoipPstnUsers on evpu1.DN equals "+" + evpu2.DN
  707:                              where evpu1.Id != evpu2.Id
  708:                              select new { Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(evpu1.DN) }).Distinct().ToList();
  709:  
  710:                 var list2 = list0.Union(list1).Distinct().ToList();
  711:  
  712:                 list = (from l in list2 select l.Service).ToList();
  713:             }
  714:  
  715:             return list;
  716:         }
  717:  
  718:         ////////////////////////////////////////////////////////////////////////////
  719:  
  720:         /// <summary>
  721:         ///
  722:         /// </summary>
  723:         public static List<string> InconsistentRecordsWhereEmsOntIsNullAndDnIsImpuAidHasPlusFormatOrEmsOntIsNotNullAndDnIsInServiceWithCountryCodeNoPlusFormatList()
  724:         {
  725:             List<string> list;
  726:  
  727:             //var dummy = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.ImpuAid("");
  728:  
  729:             // for MDUs numbers will look like 96524805054 Ia.Ftn.Cl.Model.Business.NumberFormatConverter.IsMatchToServiceWithCountryCode(dn);
  730:             // for MSAN numbers will look like +96524805054 Ia.Ftn.Cl.Model.Business.NumberFormatConverter.IsMatchToImpuAid(dn)
  731:  
  732:             using (var db = new Ia.Ftn.Cl.Db())
  733:             {
  734:                 // select * from EmsVoipPstnUsers where EmsOnt_Id is not null and dn like '+%'
  735:                 var list0 = (from evpu in db.EmsVoipPstnUsers
  736:                              where evpu.EmsOnt != null && evpu.DN.StartsWith("+")
  737:                              select new { Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(evpu.DN) }).Distinct().ToList();
  738:  
  739:                 // select * from EmsVoipPstnUsers where EmsOnt_Id is null and dn not like '+%'
  740:                 var list1 = (from evpu in db.EmsVoipPstnUsers
  741:                              where evpu.EmsOnt == null && !evpu.DN.StartsWith("+")
  742:                              select new { Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(evpu.DN) }).Distinct().ToList();
  743:  
  744:                 var list2 = list0.Union(list1).Distinct().ToList();
  745:  
  746:                 list = (from l in list2 select l.Service).ToList();
  747:             }
  748:  
  749:             return list;
  750:         }
  751:  
  752:         ////////////////////////////////////////////////////////////////////////////
  753:  
  754:         /// <summary>
  755:         ///
  756:         /// </summary>
  757:         public static List<string> ServiceIdWithinSipOltList()
  758:         {
  759:             int serviceType;
  760:             string service, serviceId;
  761:             List<int> sipOltIdList;
  762:             List<string> list, serviceIdList;
  763:  
  764:             serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  765:             sipOltIdList = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.SipOltIdList;
  766:  
  767:             using (var db = new Ia.Ftn.Cl.Db())
  768:             {
  769:                 list = (from evpu in db.EmsVoipPstnUsers
  770:                         where evpu.EmsOnt != null && evpu.EmsOnt.Access != null && sipOltIdList.Contains(evpu.EmsOnt.Access.Olt)
  771:                         select evpu.DN).AsNoTracking().ToList();
  772:             }
  773:  
  774:             if (list != null && list.Count > 0)
  775:             {
  776:                 serviceIdList = new List<string>(list.Count);
  777:  
  778:                 foreach (string s in list)
  779:                 {
  780:                     service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(s);
  781:  
  782:                     serviceId = Ia.Ftn.Cl.Models.Business.Service.ServiceToServiceId(service, serviceType);
  783:  
  784:                     serviceIdList.Add(serviceId);
  785:                 }
  786:             }
  787:             else
  788:             {
  789:                 serviceIdList = new List<string>();
  790:             }
  791:  
  792:             return serviceIdList;
  793:         }
  794:  
  795:         ////////////////////////////////////////////////////////////////////////////
  796:  
  797:         /// <summary>
  798:         ///
  799:         /// </summary>
  800:         public static List<string> ServiceWithinEmsVoipPstnUserWhereEmsDevResultCodeDeviceOfflineError()
  801:         {
  802:             string service;
  803:             List<string> serviceList;
  804:  
  805:             using (var db = new Ia.Ftn.Cl.Db())
  806:             {
  807:                 var list = (from evpu in db.EmsVoipPstnUsers
  808:                             where evpu.EmsOnt != null && evpu.EmsOnt.Access != null
  809:                             select new { evpu.DN, evpu.DID }).AsNoTracking().ToList();
  810:  
  811:                 if (list != null && list.Count > 0)
  812:                 {
  813:                     serviceList = new List<string>(list.Count);
  814:  
  815:                     var didToResultCodeDictionary = Ia.Ftn.Cl.Models.Data.Huawei.Dev.DidToResultCodeDictionary;
  816:  
  817:                     foreach (var evpu in list)
  818:                     {
  819:                         if (didToResultCodeDictionary.ContainsKey(evpu.DID))
  820:                         {
  821:                             var resultCode = didToResultCodeDictionary[evpu.DID];
  822:  
  823:                             if (resultCode == (long)Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.DeviceOfflineError)
  824:                             {
  825:                                 service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(evpu.DN);
  826:  
  827:                                 serviceList.Add(service);
  828:                             }
  829:                         }
  830:                     }
  831:                 }
  832:                 else
  833:                 {
  834:                     serviceList = new List<string>();
  835:                 }
  836:             }
  837:  
  838:             return serviceList;
  839:         }
  840:  
  841:         ////////////////////////////////////////////////////////////////////////////
  842:  
  843:         /// <summary>
  844:         ///
  845:         /// </summary>
  846:         public static List<string> AccessNameWithinEmsVoipPstnUserWhereEmsDevResultCodeDeviceOfflineError()
  847:         {
  848:             string accessName;
  849:             List<string> accessNameList;
  850:  
  851:             using (var db = new Ia.Ftn.Cl.Db())
  852:             {
  853:                 var list = (from evpu in db.EmsVoipPstnUsers
  854:                             where evpu.EmsOnt != null && evpu.EmsOnt.Access != null
  855:                             select new { evpu.EmsOnt.Access.Id, evpu.DID }).AsNoTracking().ToList();
  856:  
  857:                 if (list != null && list.Count > 0)
  858:                 {
  859:                     accessNameList = new List<string>(list.Count);
  860:  
  861:                     var didToResultCodeDictionary = Ia.Ftn.Cl.Models.Data.Huawei.Dev.DidToResultCodeDictionary;
  862:                     var ontAccessIdToOntAccessNameDictionary = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary;
  863:  
  864:                     foreach (var accessIdDid in list)
  865:                     {
  866:                         if (didToResultCodeDictionary.ContainsKey(accessIdDid.DID))
  867:                         {
  868:                             var resultCode = didToResultCodeDictionary[accessIdDid.DID];
  869:  
  870:                             if (resultCode == (long)Ia.Ftn.Cl.Models.Client.Huawei.Ems.ResultCode.DeviceOfflineError)
  871:                             {
  872:                                 if (ontAccessIdToOntAccessNameDictionary.ContainsKey(accessIdDid.Id))
  873:                                 {
  874:                                     accessName = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntAccessIdToOntAccessNameDictionary[accessIdDid.Id];
  875:  
  876:                                     if (!accessNameList.Contains(accessName))
  877:                                     {
  878:                                         accessNameList.Add(accessName);
  879:                                     }
  880:                                 }
  881:                             }
  882:                         }
  883:                     }
  884:                 }
  885:                 else
  886:                 {
  887:                     accessNameList = new List<string>();
  888:                 }
  889:             }
  890:  
  891:             return accessNameList;
  892:         }
  893:  
  894:         ////////////////////////////////////////////////////////////////////////////
  895:  
  896:         /// <summary>
  897:         ///
  898:         /// </summary>
  899:         public static List<string> ServiceIdWithinAllowedSipOltToBeProvisionedOrMigratedList()
  900:         {
  901:             int serviceType;
  902:             string service, serviceId;
  903:             List<int> sipOltIdList;
  904:             List<string> list, serviceIdList;
  905:  
  906:             serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  907:             sipOltIdList = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeProvisionedSipOltIdList.Union(Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedSipOltIdList).ToList();
  908:  
  909:             using (var db = new Ia.Ftn.Cl.Db())
  910:             {
  911:                 list = (from evpu in db.EmsVoipPstnUsers
  912:                         where evpu.EmsOnt != null && evpu.EmsOnt.Access != null && sipOltIdList.Contains(evpu.EmsOnt.Access.Olt)
  913:                         select evpu.DN).ToList();
  914:             }
  915:  
  916:             if (list != null && list.Count > 0)
  917:             {
  918:                 serviceIdList = new List<string>(list.Count);
  919:  
  920:                 foreach (string s in list)
  921:                 {
  922:                     service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(s);
  923:  
  924:                     serviceId = Ia.Ftn.Cl.Models.Business.Service.ServiceToServiceId(service, serviceType);
  925:  
  926:                     serviceIdList.Add(serviceId);
  927:                 }
  928:             }
  929:             else
  930:             {
  931:                 serviceIdList = new List<string>();
  932:             }
  933:  
  934:             return serviceIdList;
  935:         }
  936:  
  937:         ////////////////////////////////////////////////////////////////////////////
  938:  
  939:         /// <summary>
  940:         /// List of ServiceOnts within EmsVoipPstnUsers within a SIP allowed to be provisioned or migrated OLT
  941:         /// </summary>
  942:         public static List<Ia.Ftn.Cl.Models.Business.ServiceAccessIpOntCreated> ServiceOntWithinAllowedSipOltToBeProvisionedOrMigratedList()
  943:         {
  944:             int serviceType;
  945:             string service, serviceId;
  946:             List<int> sipOltIdList;
  947:             List<Ia.Ftn.Cl.Models.Business.ServiceAccessIpOntCreated> tempSipUserNamelist, serviceOntList;
  948:  
  949:             serviceType = Ia.Ftn.Cl.Models.Business.Service.ServiceType.ImsService;
  950:             sipOltIdList = Ia.Ftn.Cl.Models.Data.Service.AllowedToBeProvisionedSipOltIdList.Union(Ia.Ftn.Cl.Models.Data.Service.AllowedToBeMigratedSipOltIdList).ToList();
  951:  
  952:             var ontAccessIdToOntForOltIdListDictionary = Ia.Ftn.Cl.Models.Data.NetworkDesignDocument.OntAccessIdToOntForOltIdListDictionary(sipOltIdList);
  953:  
  954:             using (var db = new Ia.Ftn.Cl.Db())
  955:             {
  956:                 tempSipUserNamelist = (from evpu in db.EmsVoipPstnUsers
  957:                                        where evpu.EmsOnt != null && evpu.EmsOnt.Access != null && sipOltIdList.Contains(evpu.EmsOnt.Access.Olt)
  958:                                        // select vpu.DN).ToList();
  959:                                        select new Ia.Ftn.Cl.Models.Business.ServiceAccessIpOntCreated { Service = evpu.DN, AccessId = evpu.EmsOnt.Access.Id, CreatedDateTime = evpu.Created }).AsNoTracking().ToList();
  960:             }
  961:  
  962:             if (tempSipUserNamelist != null && tempSipUserNamelist.Count > 0)
  963:             {
  964:                 serviceOntList = new List<Ia.Ftn.Cl.Models.Business.ServiceAccessIpOntCreated>(tempSipUserNamelist.Count);
  965:  
  966:                 foreach (var so in tempSipUserNamelist)
  967:                 {
  968:                     service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(so.Service); // so.Service here is vpu.DN
  969:  
  970:                     serviceId = Ia.Ftn.Cl.Models.Business.Service.ServiceToServiceId(service, serviceType);
  971:  
  972:                     serviceOntList.Add(new Ia.Ftn.Cl.Models.Business.ServiceAccessIpOntCreated
  973:                     {
  974:                         ServiceId = serviceId,
  975:                         Service = service,
  976:                         AccessId = so.AccessId,
  977:                         Ont = ontAccessIdToOntForOltIdListDictionary.ContainsKey(so.AccessId) ? ontAccessIdToOntForOltIdListDictionary[so.AccessId] : null,
  978:                         CreatedDateTime = so.CreatedDateTime
  979:                     });
  980:                 }
  981:             }
  982:             else
  983:             {
  984:                 serviceOntList = new List<Ia.Ftn.Cl.Models.Business.ServiceAccessIpOntCreated>();
  985:             }
  986:  
  987:             return serviceOntList;
  988:         }
  989:  
  990:         ////////////////////////////////////////////////////////////////////////////
  991:  
  992:         /// <summary>
  993:         ///
  994:         /// </summary>
  995:         public static Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser Read(string id)
  996:         {
  997:             Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser item;
  998:  
  999:             using (var db = new Ia.Ftn.Cl.Db())
 1000:             {
 1001:                 item = (from evpu in db.EmsVoipPstnUsers
 1002:                         where evpu.EmsOnt != null && evpu.Id == id
 1003:                         select evpu).Include(o => o.EmsOnt).SingleOrDefault();
 1004:             }
 1005:  
 1006:             return item;
 1007:         }
 1008:  
 1009:         ////////////////////////////////////////////////////////////////////////////
 1010:  
 1011:         /// <summary>
 1012:         ///
 1013:         /// </summary>
 1014:         public static List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser> ReadByService(string service) //, Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
 1015:         {
 1016:             string dn;
 1017:             List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser> list;
 1018:  
 1019:             dn = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.ServiceWithCountryCode(service);
 1020:  
 1021:             using (var db = new Ia.Ftn.Cl.Db())
 1022:             {
 1023:                 list = (from evpu in db.EmsVoipPstnUsers
 1024:                         where evpu.EmsOnt != null && evpu.DN == dn
 1025:                         select evpu).Include(o => o.EmsOnt).ThenInclude(o => o.Access).ToList(); //.SingleOrDefault();
 1026:             }
 1027:  
 1028:             return list;
 1029:         }
 1030:  
 1031:         ////////////////////////////////////////////////////////////////////////////
 1032:  
 1033:         /// <summary>
 1034:         ///
 1035:         /// </summary>
 1036:         public static List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser> ReadByMsanService(string service)
 1037:         {
 1038:             string dn;
 1039:             List<Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser> list;
 1040:  
 1041:             dn = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.ImpuAid(service);
 1042:  
 1043:             using (var db = new Ia.Ftn.Cl.Db())
 1044:             {
 1045:                 list = (from evpu in db.EmsVoipPstnUsers
 1046:                         where /*evpu.EmsOnt != null &&*/ evpu.DN == dn
 1047:                         select evpu)/*.Include(o => o.EmsOnt).ThenInclude(o => o.Access)*/.ToList(); //.SingleOrDefault();
 1048:             }
 1049:  
 1050:             return list;
 1051:         }
 1052:  
 1053:         ////////////////////////////////////////////////////////////////////////////
 1054:  
 1055:         /// <summary>
 1056:         ///
 1057:         /// </summary>
 1058:         public static List<Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.DidFnSnPnDn> DidFnSnPnDnMsanList()
 1059:         {
 1060:             List<Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.DidFnSnPnDn> list;
 1061:  
 1062:             //var dummy = Ia.Ftn.Cl.Model.Business.NumberFormatConverter.ImpuAid("");
 1063:  
 1064:             using (var db = new Ia.Ftn.Cl.Db())
 1065:             {
 1066:                 list = (from evpu in db.EmsVoipPstnUsers
 1067:                         where evpu.DN.StartsWith("+" + Ia.Ftn.Cl.Models.Business.Service.CountryCode)
 1068:                         select new Ia.Ftn.Cl.Models.Business.Huawei.VoipPstnUser.DidFnSnPnDn
 1069:                         {
 1070:                             Did = evpu.DID,
 1071:                             Fn = evpu.FN,
 1072:                             Sn = evpu.SN,
 1073:                             Pn = evpu.PN,
 1074:                             Dn = evpu.DN,
 1075:                         }).ToList();
 1076:             }
 1077:  
 1078:             return list;
 1079:         }
 1080:  
 1081:         ////////////////////////////////////////////////////////////////////////////
 1082:  
 1083:         /// <summary>
 1084:         ///
 1085:         /// </summary>
 1086:         public static List<string> MsanServiceList
 1087:         {
 1088:             get
 1089:             {
 1090:                 List<string> list;
 1091:  
 1092: #if DEBUG
 1093:                 var dummyVarToDrawRefractorToBelow = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Dn("0000000");
 1094: #endif
 1095:  
 1096:                 using (var db = new Ia.Ftn.Cl.Db())
 1097:                 {
 1098:                     var list0 = (from evpu in db.EmsVoipPstnUsers
 1099:                                  where evpu.EmsOnt == null && evpu.DN.StartsWith("+965")
 1100:                                  select evpu.DN).ToList();
 1101:  
 1102:                     list = new List<string>();
 1103:  
 1104:                     foreach (var s in list0)
 1105:                     {
 1106:                         list.Add(Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(s));
 1107:                     }
 1108:                 }
 1109:  
 1110:                 return list;
 1111:             }
 1112:         }
 1113:  
 1114:         ////////////////////////////////////////////////////////////////////////////
 1115:  
 1116:         /// <summary>
 1117:         ///
 1118:         /// </summary>
 1119:         public static Dictionary<string, bool> MsanServiceDictionary
 1120:         {
 1121:             get
 1122:             {
 1123:                 string key;
 1124:                 Dictionary<string, bool> dictionary;
 1125:  
 1126: #if DEBUG
 1127:                 var dummyVarToDrawRefractorToBelow = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Dn("0000000");
 1128: #endif
 1129:  
 1130:                 var list = Ia.Ftn.Cl.Models.Data.Huawei.VoipPstnUser.MsanServiceList;
 1131:  
 1132:                 dictionary = new Dictionary<string, bool>();
 1133:  
 1134:                 foreach (var s in list)
 1135:                 {
 1136:                     key = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(s);
 1137:  
 1138:                     if (!string.IsNullOrEmpty(key)) dictionary[key] = true;
 1139:                 }
 1140:  
 1141:                 return dictionary;
 1142:             }
 1143:         }
 1144:  
 1145:         ////////////////////////////////////////////////////////////////////////////
 1146:  
 1147:         /// <summary>
 1148:         ///
 1149:         /// </summary>
 1150:         public static Dictionary<int, int> MsanDevDidToDnCountDictionary
 1151:         {
 1152:             get
 1153:             {
 1154:                 Dictionary<int, int> dictionary;
 1155:  
 1156:                 using (var db = new Ia.Ftn.Cl.Db())
 1157:                 {
 1158:                     /*
 1159: select ed.DID,count(0) from EmsVoipPstnUsers evpu
 1160: left outer join EmsDevs ed on ed.DID = evpu.DID 
 1161: where evpu.DN like '+%'
 1162: group by ed.DID
 1163:                      */
 1164:  
 1165:                     dictionary = (from evpu in db.EmsVoipPstnUsers
 1166:                                   join ed in db.EmsDevs on evpu.DID equals ed.DID
 1167:                                   where evpu.EmsOnt == null && evpu.DN.StartsWith("+965")
 1168:                                   group ed.DID by ed.DID into g
 1169:                                   select new { Did = g.Key, Count = g.Count() }).AsNoTracking().ToDictionary(u => u.Did, u => u.Count);
 1170:                 }
 1171:  
 1172:                 return dictionary.ToDictionary(u => u.Key, u => u.Value);
 1173:             }
 1174:         }
 1175:  
 1176:         ////////////////////////////////////////////////////////////////////////////
 1177:  
 1178:         /// <summary>
 1179:         ///
 1180:         /// </summary>
 1181:         public static List<string> DnServiceListByMsanDevDidList(List<int> didList)
 1182:         {
 1183:             List<string> list;
 1184:  
 1185:             using (var db = new Ia.Ftn.Cl.Db())
 1186:             {
 1187:                 var list0 = (from evpu in db.EmsVoipPstnUsers
 1188:                              join ed in db.EmsDevs on evpu.DID equals ed.DID
 1189:                              where evpu.EmsOnt == null && evpu.DN != null && evpu.DN.StartsWith("+965") && didList.Contains(ed.DID)
 1190:                              select evpu.DN).AsNoTracking().ToList();
 1191:  
 1192:                 list = new List<string>();
 1193:  
 1194:                 foreach (var s in list0)
 1195:                 {
 1196:                     list.Add(Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(s));
 1197:                 }
 1198:             }
 1199:  
 1200:             return list;
 1201:         }
 1202:  
 1203:         ////////////////////////////////////////////////////////////////////////////
 1204:  
 1205:         /// <summary>
 1206:         ///
 1207:         /// </summary>
 1208:         public static List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> MsanDevLicListByNddMsan(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Msan msan)
 1209:         {
 1210:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev msanDev;
 1211:             List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> list;
 1212:  
 1213:             var msanDevList = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
 1214:                                where m.Msan.Id == msan.Id
 1215:                                select m).ToList();
 1216:  
 1217:             var didList = msanDevList.Select(u => u.Did).ToList();
 1218:  
 1219:             using (var db = new Ia.Ftn.Cl.Db())
 1220:             {
 1221:                 list = (from evpu in db.EmsVoipPstnUsers
 1222:                         join ed in db.EmsDevs on evpu.DID equals ed.DID
 1223:                         where evpu.EmsOnt == null /*&& evpu.DN.StartsWith("+965")*/ && didList.Contains(ed.DID)
 1224:                         select new Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic
 1225:                         {
 1226:                             EmsVoipPstnUserId = evpu.Id,
 1227:                             Did = evpu.DID,
 1228:                             Fn = evpu.FN,
 1229:                             Sn = evpu.SN,
 1230:                             Pn = evpu.PN,
 1231:                             Dn = evpu.DN,
 1232:                             Created = evpu.Created,
 1233:                             Updated = evpu.Updated
 1234:                         }).AsNoTracking().ToList();
 1235:  
 1236:                 foreach (var l in list)
 1237:                 {
 1238:                     l.Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(l.Dn);
 1239:                     l.MsanId = msan.Id;
 1240:                     l.MsanNameSymbol = msan.NameSymbol;
 1241:  
 1242:                     msanDev = (from m in msanDevList where m.Did == l.Did select m).Single();
 1243:  
 1244:                     l.MsanDevId = msanDev.Id;
 1245:                     l.MsanDevDev = msanDev.Dev;
 1246:                     l.Cabinet = msanDev.Cabinet;
 1247:                     l.Frame = msanDev.Frame;
 1248:                 }
 1249:             }
 1250:  
 1251:             return list;
 1252:         }
 1253:  
 1254:         ////////////////////////////////////////////////////////////////////////////
 1255:  
 1256:         /// <summary>
 1257:         ///
 1258:         /// </summary>
 1259:         public static List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> MsanDevLicListByNddMsanAndCabinet(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Msan msan, int cabinet)
 1260:         {
 1261:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev msanDev;
 1262:             List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> list;
 1263:  
 1264:             var msanDevList = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
 1265:                                where m.Msan.Id == msan.Id && m.Cabinet == cabinet
 1266:                                select m).ToList();
 1267:  
 1268:             var didList = msanDevList.Select(u => u.Did).ToList();
 1269:  
 1270:             using (var db = new Ia.Ftn.Cl.Db())
 1271:             {
 1272:                 list = (from evpu in db.EmsVoipPstnUsers
 1273:                         join ed in db.EmsDevs on evpu.DID equals ed.DID
 1274:                         where evpu.EmsOnt == null /*&& evpu.DN.StartsWith("+965")*/ && didList.Contains(ed.DID)
 1275:                         select new Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic
 1276:                         {
 1277:                             EmsVoipPstnUserId = evpu.Id,
 1278:                             Did = evpu.DID,
 1279:                             Fn = evpu.FN,
 1280:                             Sn = evpu.SN,
 1281:                             Pn = evpu.PN,
 1282:                             Dn = evpu.DN,
 1283:                             Created = evpu.Created,
 1284:                             Updated = evpu.Updated
 1285:                         }).AsNoTracking().ToList();
 1286:  
 1287:                 foreach (var l in list)
 1288:                 {
 1289:                     l.Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(l.Dn);
 1290:                     l.MsanId = msan.Id;
 1291:                     l.MsanNameSymbol = msan.NameSymbol;
 1292:  
 1293:                     msanDev = (from m in msanDevList where m.Did == l.Did select m).Single();
 1294:  
 1295:                     l.MsanDevId = msanDev.Id;
 1296:                     l.MsanDevDev = msanDev.Dev;
 1297:                     l.Cabinet = msanDev.Cabinet;
 1298:                     l.Frame = msanDev.Frame;
 1299:                 }
 1300:             }
 1301:  
 1302:             return list;
 1303:         }
 1304:  
 1305:         ////////////////////////////////////////////////////////////////////////////
 1306:  
 1307:         /// <summary>
 1308:         ///
 1309:         /// </summary>
 1310:         public static List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> MsanDevLicListByNddMsanAndCabinetAndFrame(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Msan msan, int cabinet, int frame)
 1311:         {
 1312:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev msanDev;
 1313:             List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> list;
 1314:  
 1315:             var msanDevList = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
 1316:                                where m.Msan.Id == msan.Id && m.Cabinet == cabinet && m.Frame == frame
 1317:                                select m).ToList();
 1318:  
 1319:             var didList = msanDevList.Select(u => u.Did).ToList();
 1320:  
 1321:             using (var db = new Ia.Ftn.Cl.Db())
 1322:             {
 1323:                 list = (from evpu in db.EmsVoipPstnUsers
 1324:                         join ed in db.EmsDevs on evpu.DID equals ed.DID
 1325:                         where evpu.EmsOnt == null /*&& evpu.DN.StartsWith("+965")*/ && didList.Contains(ed.DID)
 1326:                         select new Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic
 1327:                         {
 1328:                             EmsVoipPstnUserId = evpu.Id,
 1329:                             Did = evpu.DID,
 1330:                             Fn = evpu.FN,
 1331:                             Sn = evpu.SN,
 1332:                             Pn = evpu.PN,
 1333:                             Dn = evpu.DN,
 1334:                             Created = evpu.Created,
 1335:                             Updated = evpu.Updated
 1336:                         }).AsNoTracking().ToList();
 1337:  
 1338:                 foreach (var l in list)
 1339:                 {
 1340:                     l.Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(l.Dn);
 1341:                     l.MsanId = msan.Id;
 1342:                     l.MsanNameSymbol = msan.NameSymbol;
 1343:  
 1344:                     msanDev = (from m in msanDevList where m.Did == l.Did select m).Single();
 1345:  
 1346:                     l.MsanDevId = msanDev.Id;
 1347:                     l.MsanDevDev = msanDev.Dev;
 1348:                     l.Cabinet = msanDev.Cabinet;
 1349:                     l.Frame = msanDev.Frame;
 1350:                 }
 1351:             }
 1352:  
 1353:             return list;
 1354:         }
 1355:  
 1356:         ////////////////////////////////////////////////////////////////////////////
 1357:  
 1358:         /// <summary>
 1359:         ///
 1360:         /// </summary>
 1361:         public static List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> MsanDevLicListByNddMsanAndCabinetAndFrameAndFn(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Msan msan, int cabinet, int frame, int fn)
 1362:         {
 1363:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev msanDev;
 1364:             List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> list;
 1365:  
 1366:             var msanDevList = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
 1367:                                where m.Msan.Id == msan.Id && m.Cabinet == cabinet && m.Frame == frame
 1368:                                select m).ToList();
 1369:  
 1370:             var didList = msanDevList.Select(u => u.Did).ToList();
 1371:  
 1372:             using (var db = new Ia.Ftn.Cl.Db())
 1373:             {
 1374:                 list = (from evpu in db.EmsVoipPstnUsers
 1375:                         join ed in db.EmsDevs on evpu.DID equals ed.DID
 1376:                         where evpu.EmsOnt == null /*&& evpu.DN.StartsWith("+965")*/ && didList.Contains(ed.DID) && evpu.FN == fn
 1377:                         select new Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic
 1378:                         {
 1379:                             EmsVoipPstnUserId = evpu.Id,
 1380:                             Did = evpu.DID,
 1381:                             Fn = evpu.FN,
 1382:                             Sn = evpu.SN,
 1383:                             Pn = evpu.PN,
 1384:                             Dn = evpu.DN,
 1385:                             Created = evpu.Created,
 1386:                             Updated = evpu.Updated
 1387:                         }).AsNoTracking().ToList();
 1388:  
 1389:                 foreach (var l in list)
 1390:                 {
 1391:                     l.Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(l.Dn);
 1392:                     l.MsanId = msan.Id;
 1393:                     l.MsanNameSymbol = msan.NameSymbol;
 1394:  
 1395:                     msanDev = (from m in msanDevList where m.Did == l.Did select m).Single();
 1396:  
 1397:                     l.MsanDevId = msanDev.Id;
 1398:                     l.MsanDevDev = msanDev.Dev;
 1399:                     l.Cabinet = msanDev.Cabinet;
 1400:                     l.Frame = msanDev.Frame;
 1401:                 }
 1402:             }
 1403:  
 1404:             return list;
 1405:         }
 1406:  
 1407:         ////////////////////////////////////////////////////////////////////////////
 1408:  
 1409:         /// <summary>
 1410:         ///
 1411:         /// </summary>
 1412:         public static List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> MsanDevLicListByNddMsanAndCabinetAndFrameAndFnAndSn(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Msan msan, int cabinet, int frame, int fn, int sn)
 1413:         {
 1414:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev msanDev;
 1415:             List<Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic> list;
 1416:  
 1417:             var msanDevList = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
 1418:                                where m.Msan.Id == msan.Id && m.Cabinet == cabinet && m.Frame == frame
 1419:                                select m).ToList();
 1420:  
 1421:             var didList = msanDevList.Select(u => u.Did).ToList();
 1422:  
 1423:             using (var db = new Ia.Ftn.Cl.Db())
 1424:             {
 1425:                 list = (from evpu in db.EmsVoipPstnUsers
 1426:                         join ed in db.EmsDevs on evpu.DID equals ed.DID
 1427:                         where evpu.EmsOnt == null /*&& evpu.DN.StartsWith("+965")*/ && didList.Contains(ed.DID) && evpu.FN == fn && evpu.SN == sn
 1428:                         select new Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic
 1429:                         {
 1430:                             EmsVoipPstnUserId = evpu.Id,
 1431:                             Did = evpu.DID,
 1432:                             Fn = evpu.FN,
 1433:                             Sn = evpu.SN,
 1434:                             Pn = evpu.PN,
 1435:                             Dn = evpu.DN,
 1436:                             Created = evpu.Created,
 1437:                             Updated = evpu.Updated
 1438:                         }).AsNoTracking().ToList();
 1439:  
 1440:                 foreach (var l in list)
 1441:                 {
 1442:                     l.Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(l.Dn);
 1443:                     l.MsanId = msan.Id;
 1444:                     l.MsanNameSymbol = msan.NameSymbol;
 1445:  
 1446:                     msanDev = (from m in msanDevList where m.Did == l.Did select m).Single();
 1447:  
 1448:                     l.MsanDevId = msanDev.Id;
 1449:                     l.MsanDevDev = msanDev.Dev;
 1450:                     l.Cabinet = msanDev.Cabinet;
 1451:                     l.Frame = msanDev.Frame;
 1452:                 }
 1453:             }
 1454:  
 1455:             return list;
 1456:         }
 1457:  
 1458:         ////////////////////////////////////////////////////////////////////////////
 1459:  
 1460:         /// <summary>
 1461:         ///
 1462:         /// </summary>
 1463:         public static Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic MsanDevLicByEmsVoipPstnUserId(string emsVoipPstnUserId)
 1464:         {
 1465:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic lic;
 1466:  
 1467:             using (var db = new Ia.Ftn.Cl.Db())
 1468:             {
 1469:                 lic = (from evpu in db.EmsVoipPstnUsers
 1470:                        where evpu.Id == emsVoipPstnUserId
 1471:                        select new Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic
 1472:                        {
 1473:                            EmsVoipPstnUserId = evpu.Id,
 1474:                            Did = evpu.DID,
 1475:                            Fn = evpu.FN,
 1476:                            Sn = evpu.SN,
 1477:                            Pn = evpu.PN,
 1478:                            Dn = evpu.DN,
 1479:                            Created = evpu.Created,
 1480:                            Updated = evpu.Updated
 1481:                        }).AsNoTracking().SingleOrDefault();
 1482:  
 1483:                 var msanDev = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
 1484:                                where m.Did == lic.Did
 1485:                                select m).Single();
 1486:  
 1487:                 lic.Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(lic.Dn);
 1488:                 lic.MsanId = msanDev.Msan.Id;
 1489:                 lic.MsanNameSymbol = msanDev.Msan.NameSymbol;
 1490:                 lic.MsanDevId = msanDev.Id;
 1491:                 lic.MsanDevDev = msanDev.Dev;
 1492:                 lic.Cabinet = msanDev.Cabinet;
 1493:                 lic.Frame = msanDev.Frame;
 1494:             }
 1495:  
 1496:             return lic;
 1497:         }
 1498:  
 1499:         ////////////////////////////////////////////////////////////////////////////
 1500:  
 1501:         /// <summary>
 1502:         ///
 1503:         /// </summary>
 1504:         public static Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic MsanDevLicByNddMsanAndCabinetAndFrameAndFnAndSnAndPn(Ia.Ftn.Cl.Models.Business.NetworkDesignDocument.Msan msan, int cabinet, int frame, int fn, int sn, int pn)
 1505:         {
 1506:             Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic lic;
 1507:  
 1508:             var msanDev = (from m in Ia.Ftn.Cl.Models.Data.Huawei.Default.MsanDevList
 1509:                            where m.Msan.Id == msan.Id && m.Cabinet == cabinet && m.Frame == frame
 1510:                            select m).SingleOrDefault();
 1511:  
 1512:             if (msanDev != null)
 1513:             {
 1514:                 using (var db = new Ia.Ftn.Cl.Db())
 1515:                 {
 1516:                     lic = (from evpu in db.EmsVoipPstnUsers
 1517:                            join ed in db.EmsDevs on evpu.DID equals ed.DID
 1518:                            where evpu.EmsOnt == null && msanDev.Did == ed.DID && evpu.FN == fn && evpu.SN == sn && evpu.PN == pn
 1519:                            select new Ia.Ftn.Cl.Models.Business.Huawei.Dev.MsanDev.Lic
 1520:                            {
 1521:                                EmsVoipPstnUserId = evpu.Id,
 1522:                                Did = evpu.DID,
 1523:                                Fn = evpu.FN,
 1524:                                Sn = evpu.SN,
 1525:                                Pn = evpu.PN,
 1526:                                Dn = evpu.DN,
 1527:                                Created = evpu.Created,
 1528:                                Updated = evpu.Updated
 1529:                            }).AsNoTracking().SingleOrDefault();
 1530:  
 1531:                     if (lic != null)
 1532:                     {
 1533:                         lic.Service = Ia.Ftn.Cl.Models.Business.NumberFormatConverter.Service(lic.Dn);
 1534:                         lic.MsanId = msanDev.Msan.Id;
 1535:                         lic.MsanNameSymbol = msanDev.Msan.NameSymbol;
 1536:                         lic.MsanDevId = msanDev.Id;
 1537:                         lic.MsanDevDev = msanDev.Dev;
 1538:                         lic.Cabinet = msanDev.Cabinet;
 1539:                         lic.Frame = msanDev.Frame;
 1540:                     }
 1541:                 }
 1542:             }
 1543:             else lic = null;
 1544:  
 1545:             return lic;
 1546:         }
 1547:  
 1548:         ////////////////////////////////////////////////////////////////////////////
 1549:  
 1550:         /// <summary>
 1551:         ///
 1552:         /// </summary>
 1553:         public static Dictionary<string, string> IdToOntIdDictionary
 1554:         {
 1555:             get
 1556:             {
 1557:                 Dictionary<string, string> dictionary;
 1558:  
 1559:                 using (var db = new Ia.Ftn.Cl.Db())
 1560:                 {
 1561:                     dictionary = (from evpu in db.EmsVoipPstnUsers
 1562:                                   where evpu.EmsOnt != null
 1563:                                   select new { evpu.Id, OntId = evpu.EmsOnt.Id }).ToDictionary(u => u.Id, u => u.OntId);
 1564:                 }
 1565:  
 1566:                 return dictionary.ToDictionary(u => u.Key, u => u.Value);
 1567:             }
 1568:         }
 1569:  
 1570:         ////////////////////////////////////////////////////////////////////////////
 1571:         ////////////////////////////////////////////////////////////////////////////
 1572:  
 1573:         /// <summary>
 1574:         ///
 1575:         /// </summary>
 1576:         public static string ToSimpleTextString(Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser emsVoipPstnUser)
 1577:         {
 1578:             StringBuilder sb;
 1579:  
 1580:             sb = new StringBuilder();
 1581:  
 1582:             //sb.AppendLine("Vendor: " + Ia.Ftn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei.Name);
 1583:             sb.AppendLine("DID: " + emsVoipPstnUser.DID);
 1584:             sb.AppendLine("FN: " + emsVoipPstnUser.FN);
 1585:             sb.AppendLine("SN: " + emsVoipPstnUser.SN);
 1586:             sb.AppendLine("PN: " + emsVoipPstnUser.PN);
 1587:             sb.AppendLine("MGID: " + emsVoipPstnUser.MGID);
 1588:             sb.AppendLine("MGNAME: " + emsVoipPstnUser.MGNAME);
 1589:             sb.AppendLine("TID: " + emsVoipPstnUser.TID);
 1590:             sb.AppendLine("DN: " + emsVoipPstnUser.DN);
 1591:             sb.AppendLine("LayeredConf: " + emsVoipPstnUser.LayeredConf);
 1592:             sb.AppendLine("HighLevelWidth: " + emsVoipPstnUser.HighLevelWidth);
 1593:             sb.AppendLine("LowerLevelWidth: " + emsVoipPstnUser.LowerLevelWidth);
 1594:             sb.AppendLine("Voltage: " + emsVoipPstnUser.Voltage);
 1595:             sb.AppendLine("KCType: " + emsVoipPstnUser.KCType);
 1596:             sb.AppendLine("VoiceGain: " + emsVoipPstnUser.VoiceGain);
 1597:             sb.AppendLine("LimitPulseDial: " + emsVoipPstnUser.LimitPulseDial);
 1598:             sb.AppendLine("RevPolarity: " + emsVoipPstnUser.RevPolarity);
 1599:             sb.AppendLine("RevPoleLevel: " + emsVoipPstnUser.RevPoleLevel);
 1600:             sb.AppendLine("RevPolePulse: " + emsVoipPstnUser.RevPolePulse);
 1601:             sb.AppendLine("PSTAT: " + emsVoipPstnUser.PSTAT);
 1602:             sb.AppendLine("ConfigStatus: " + emsVoipPstnUser.ConfigStatus);
 1603:             sb.AppendLine("ServiceStatus: " + emsVoipPstnUser.ServiceStatus);
 1604:             sb.AppendLine("ServiceType: " + emsVoipPstnUser.ServiceType);
 1605:             sb.AppendLine("ALIAS: " + emsVoipPstnUser.ALIAS);
 1606:             sb.AppendLine("UserType: " + emsVoipPstnUser.UserType);
 1607:             sb.AppendLine("Impedance: " + emsVoipPstnUser.Impedance);
 1608:             sb.AppendLine("Current: " + emsVoipPstnUser.Current);
 1609:             sb.AppendLine("DCTime: " + emsVoipPstnUser.DCTime);
 1610:             sb.AppendLine("PITime: " + emsVoipPstnUser.PITime);
 1611:             sb.AppendLine("FSKDelayInterval: " + emsVoipPstnUser.FSKDelayInterval);
 1612:             sb.AppendLine("ActualVoiceGain: " + emsVoipPstnUser.ActualVoiceGain);
 1613:             sb.AppendLine("CidTransWhen: " + emsVoipPstnUser.CidTransWhen);
 1614:             sb.AppendLine("CidFormat: " + emsVoipPstnUser.CidFormat);
 1615:             sb.AppendLine("OverloadPRI: " + emsVoipPstnUser.OverloadPRI);
 1616:             sb.AppendLine("ImpedanceProfile: " + emsVoipPstnUser.ImpedanceProfile);
 1617:             sb.AppendLine("SendVoiceGain: " + emsVoipPstnUser.SendVoiceGain);
 1618:             sb.AppendLine("RecvVoiceGain: " + emsVoipPstnUser.RecvVoiceGain);
 1619:             sb.AppendLine("RevPolarityMode: " + emsVoipPstnUser.RevPolarityMode);
 1620:             sb.AppendLine("PortRunState: " + emsVoipPstnUser.PortRunState);
 1621:             sb.AppendLine("PortTestState: " + emsVoipPstnUser.PortTestState);
 1622:             sb.AppendLine("PortLineState: " + emsVoipPstnUser.PortLineState);
 1623:             sb.AppendLine("PortLoopState: " + emsVoipPstnUser.PortLoopState);
 1624:             sb.AppendLine("ServiceRunState: " + emsVoipPstnUser.ServiceRunState);
 1625:             sb.AppendLine("ServiceAdminState: " + emsVoipPstnUser.ServiceAdminState);
 1626:             sb.AppendLine("ActualSendVoiceGain: " + emsVoipPstnUser.ActualSendVoiceGain);
 1627:             sb.AppendLine("ActualRecvVo: " + emsVoipPstnUser.ActualRecvVo);
 1628:             sb.AppendLine("AGCEnable: " + emsVoipPstnUser.AGCEnable);
 1629:             sb.AppendLine("AGCEnableLevel: " + emsVoipPstnUser.AGCEnableLevel);
 1630:             sb.AppendLine("SNSEnable: " + emsVoipPstnUser.SNSEnable);
 1631:             sb.AppendLine("SNSEnableLevel: " + emsVoipPstnUser.SNSEnableLevel);
 1632:             sb.AppendLine("NlpMode: " + emsVoipPstnUser.NlpMode);
 1633:             sb.AppendLine("LineLockEnable: " + emsVoipPstnUser.LineLockEnable);
 1634:             sb.AppendLine("DspInputGain: " + emsVoipPstnUser.DspInputGain);
 1635:             sb.AppendLine("DspOutputGain: " + emsVoipPstnUser.DspOutputGain);
 1636:             sb.AppendLine("ClipReversePole: " + emsVoipPstnUser.ClipReversePole);
 1637:             sb.AppendLine("DEFAULTCLI: " + emsVoipPstnUser.DEFAULTCLI);
 1638:             sb.AppendLine("USERGROUPID: " + emsVoipPstnUser.USERGROUPID);
 1639:             sb.AppendLine("ADJUSTFACTOR: " + emsVoipPstnUser.ADJUSTFACTOR);
 1640:             sb.AppendLine("DSPPROFILE: " + emsVoipPstnUser.DSPPROFILE);
 1641:  
 1642:             return sb.ToString();
 1643:         }
 1644:  
 1645:         ////////////////////////////////////////////////////////////////////////////
 1646:  
 1647:         /// <summary>
 1648:         ///
 1649:         /// </summary>
 1650:         public static string ToSimpleDidFnSnPnTextString(Ia.Ftn.Cl.Models.Huawei.EmsVoipPstnUser emsVoipPstnUser)
 1651:         {
 1652:             var s = "DID: " + emsVoipPstnUser.DID + ", FN: " + emsVoipPstnUser.FN + ", SN: " + emsVoipPstnUser.SN + ", PN: " + emsVoipPstnUser.PN;
 1653:  
 1654:             return s;
 1655:         }
 1656:  
 1657:         ////////////////////////////////////////////////////////////////////////////
 1658:         ////////////////////////////////////////////////////////////////////////////
 1659:     }
 1660:  
 1661:     ////////////////////////////////////////////////////////////////////////////
 1662:     ////////////////////////////////////////////////////////////////////////////
 1663: }