1: using System;
2: using System.Collections.Generic;
3: using System.Configuration;
4: using System.Diagnostics;
5: using System.Linq;
6:
7: namespace Ia.Ngn.Cl.Model.Business.Huawei
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Optical Fiber Network's Operations Support System Management Intranet (OFN OSS) support class for Huawei's Optical Fiber Network (OFN) business model
13: /// </summary>
14: ///
15: /// <value>
16: /// - Add:
17: /// <appSettings>
18: /// <add key = "nceServerHost" value="*.*.*.*" />
19: /// <add key = "nceServerPort" value="*" />
20: /// <add key = "nceServerLoginUser" value="LOGIN:::{ctag}::UN=*,PWD=*;" />
21: /// <add key = "nceServerLogoutUser" value="LOGOUT:::{ctag}::;" />
22: /// </appSettings>
23: /// </value>
24: ///
25: /// <remarks>
26: /// Copyright © 2014-2022 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
27: ///
28: /// 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
29: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
30: ///
31: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
32: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
33: ///
34: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
35: ///
36: /// Copyright notice: This notice may not be removed or altered from any source distribution.
37: /// </remarks>
38: public class Nce
39: {
40: private static int minute = 0;
41: private static readonly Dictionary<string, int> associateServiceIdAndPortBetweenCreateAndReadDictionary = new Dictionary<string, int>();
42: private static readonly Procedure serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastHourProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(1, Ia.Ngn.Cl.Model.Business.Provision.ServiceOntToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList);
43: private static readonly Procedure serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(24, Ia.Ngn.Cl.Model.Business.Provision.ServiceOntToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList);
44: private static readonly Procedure serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(0, Ia.Ngn.Cl.Model.Business.Provision.ServiceOntToCreateAndToDeleteInEmsOntSipInfoOrVoipPstnUserListFromThePastNHourList);
45: private static readonly Procedure updateEmsOntFromH248ToSipProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(Ia.Ngn.Cl.Model.Business.Provision.EmsOntToBeUpdatedFromH248ToSipList);
46: private static readonly Procedure createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(Ia.Ngn.Cl.Model.Business.Provision.OntSipInfoOrOntVoipPstnUserToBeCreatedForAnOntUpdatedFromH248ToSipList);
47:
48: private static readonly Procedure msanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceListProcedure = new Ia.Ngn.Cl.Model.Business.Procedure(Ia.Ngn.Cl.Model.Business.Provision.MsanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceList);
49:
50: private static Ia.Ngn.Cl.Model.Client.Huawei.Ems ems = new Ia.Ngn.Cl.Model.Client.Huawei.Ems();
51:
52: private static List<string> priorityServiceList = new List<string>();
53:
54: /// <summary/>
55: public static string UserName { get { return ConfigurationManager.AppSettings["nceHuaweiServerUser"].ToString(); } }
56:
57: /// <summary/>
58: public static string Password { get { return ConfigurationManager.AppSettings["nceHuaweiServerUserPassword"].ToString(); } }
59:
60: /// <summary/>
61: public static int SendReadOntSipInfoCommandAgainAfterNSeconds = 30;
62:
63: ////////////////////////////////////////////////////////////////////////////
64:
65: /// <summary>
66: ///
67: /// </summary>
68: public Nce()
69: {
70: }
71:
72: ////////////////////////////////////////////////////////////////////////////
73:
74: /// <summary>
75: ///
76: /// </summary>
77: public static void Connect(out Ia.Cl.Model.Result result)
78: {
79: if (ems != null && !ems.IsConnected)
80: {
81: ems.Connect(out result);
82: }
83: else
84: {
85: result = new Ia.Cl.Model.Result();
86:
87: result.AddWarning("Warning: ems is already connected. ");
88: }
89: }
90:
91: ////////////////////////////////////////////////////////////////////////////
92:
93: /// <summary>
94: ///
95: /// </summary>
96: public static void Disconnect(out Ia.Cl.Model.Result result)
97: {
98: if (ems != null && ems.IsConnected)
99: {
100: ems.Disconnect(out result);
101: }
102: else
103: {
104: result = new Ia.Cl.Model.Result();
105:
106: result.AddWarning("Warning: ems is already disconnected. ");
107: }
108: }
109:
110: ////////////////////////////////////////////////////////////////////////////
111:
112: /// <summary>
113: ///
114: /// </summary>
115: public static void Login()
116: {
117: ems.Login();
118: }
119:
120: ////////////////////////////////////////////////////////////////////////////
121:
122: /// <summary>
123: ///
124: /// </summary>
125: public static void Logout()
126: {
127: ems.Logout();
128: }
129:
130: ////////////////////////////////////////////////////////////////////////////
131:
132: /// <summary>
133: ///
134: /// </summary>
135: public static Queue<string> ReceiveQueue
136: {
137: get
138: {
139: return ems.ReceiveQueue;
140: }
141: }
142:
143: ////////////////////////////////////////////////////////////////////////////
144:
145: /// <summary>
146: ///
147: /// </summary>
148: public static Queue<string> SendQueue
149: {
150: get
151: {
152: return ems.SendQueue;
153: }
154: }
155:
156: ////////////////////////////////////////////////////////////////////////////
157:
158: /// <summary>
159: ///
160: /// </summary>
161: public static bool IsConnected
162: {
163: get
164: {
165: return ems != null && ems.IsConnected;
166: }
167: }
168:
169: ////////////////////////////////////////////////////////////////////////////
170:
171: /// <summary>
172: ///
173: /// </summary>
174: public static bool IsLoggedIn
175: {
176: get
177: {
178: return ems.IsLoggedIn;
179: }
180: }
181:
182: ////////////////////////////////////////////////////////////////////////////
183:
184: /// <summary>
185: ///
186: /// </summary>
187: public static void Dispose()
188: {
189: ems.Dispose();
190: }
191:
192: ////////////////////////////////////////////////////////////////////////////
193: ////////////////////////////////////////////////////////////////////////////
194:
195: /// <summary>
196: ///
197: /// </summary>
198: public static void ProcessReceiveQueue(out Ia.Cl.Model.Result result)
199: {
200: string rowString, formattedString;
201:
202: result = new Ia.Cl.Model.Result();
203:
204: formattedString = string.Empty;
205:
206: try
207: {
208: Debug.WriteLine("--------------------------------------");
209: Debug.WriteLine("ProcessReceiveQueue(): ReceiveQueue.Count: " + ems.ReceiveQueue.Count);
210:
211: while (ems.ReceiveQueue.Count > 0)
212: {
213: rowString = ems.ReceiveQueue.Dequeue();
214:
215: formattedString = rowString;
216:
217: Debug.WriteLine("ProcessReceiveQueue(): formattedString: " + formattedString);
218:
219: var r = ems.Update(formattedString, ref ems, out string systemIsBusyResponseCommand, out string ontLoadingCommandIsBeingExecutedNowResponseCommand);
220:
221: if (!string.IsNullOrEmpty(systemIsBusyResponseCommand))
222: {
223: ems.SystemIsBusyResendQueue.Enqueue(systemIsBusyResponseCommand);
224: }
225:
226: if (!string.IsNullOrEmpty(ontLoadingCommandIsBeingExecutedNowResponseCommand))
227: {
228: ems.OntLoadingCommandIsBeingExecutedNowResendQueue.Enqueue(ontLoadingCommandIsBeingExecutedNowResponseCommand);
229: }
230:
231: result.AddResult(r);
232: //result.AddWarning("Debugging: Start --------------------------------------");
233: //result.AddWarning(rowString);
234: //result.AddWarning("Debugging: End ----------------------------------------");
235: }
236:
237: Debug.WriteLine("--------------------------------------");
238: }
239: catch (Exception ex)
240: {
241: result.AddError("ProcessReceiveQueue(): Exception: " + ex.ToString() + "================= formattedString: [" + formattedString + "]"); //.Message);
242: }
243: }
244:
245: ////////////////////////////////////////////////////////////////////////////
246:
247: /// <summary>
248: ///
249: /// </summary>
250: public static string ProcessSendQueue(out Ia.Cl.Model.Result result)
251: {
252: string command;
253:
254: var skipSleep = true;
255: result = new Ia.Cl.Model.Result();
256:
257: try
258: {
259: Debug.WriteLine("--------------------------------------");
260:
261: if (ems.SystemIsBusyResendQueue.Count > 0) command = ems.SystemIsBusyResendQueue.Dequeue();
262: else if (ems.OntLoadingCommandIsBeingExecutedNowResendQueue.Count > 0) command = ems.OntLoadingCommandIsBeingExecutedNowResendQueue.Dequeue();
263: else if (ems.OntSipInfoCommandAgainAfterNSecondsResendQueue.Count > 0) command = ems.OntSipInfoCommandAgainAfterNSecondsResendQueue.Dequeue();
264: else if (ems.SendQueue.Count > 0) command = ems.SendQueue.Dequeue();
265: else command = string.Empty;
266:
267: if (!string.IsNullOrEmpty(command))
268: {
269: ems.Send(command, skipSleep, out Ia.Cl.Model.Result r);
270:
271: if (r.IsSuccessful) result.AddSuccess(r.Message);
272: else result.AddError(r.Message);
273: }
274:
275: EvaluateSendReadOntSipInfoCommandAgainAfterNSecondsResendQueue();
276:
277: Debug.WriteLine("--------------------------------------");
278: }
279: catch (Exception ex)
280: {
281: command = string.Empty;
282:
283: result.AddError("ProcessSendQueue(): Exception: " + ex.Message);
284: }
285:
286: return result.IsSuccessful ? command : string.Empty;
287: }
288:
289: ////////////////////////////////////////////////////////////////////////////
290:
291: /// <summary>
292: ///
293: /// </summary>
294: private static bool Minute()
295: {
296: bool b;
297:
298: var now = DateTime.UtcNow.AddHours(3);
299:
300: if (minute != now.Minute)
301: {
302: minute = now.Minute;
303:
304: b = true;
305: }
306: else b = false;
307:
308: return b;
309: }
310:
311: ////////////////////////////////////////////////////////////////////////////
312: ////////////////////////////////////////////////////////////////////////////
313:
314: /// <summary>
315: ///
316: /// </summary>
317: public static void CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, int port, out Ia.Cl.Model.Result result)
318: {
319: int serviceType;
320: string serviceId;
321: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt;
322:
323: result = new Ia.Cl.Model.Result();
324:
325: serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService;
326:
327: try
328: {
329: if (!string.IsNullOrEmpty(service))
330: {
331: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
332: {
333: serviceId = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
334:
335: if (!string.IsNullOrEmpty(accessName))
336: {
337: nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
338:
339: if (nddOnt != null)
340: {
341: Ia.Ngn.Cl.Model.Business.Huawei.Nce.CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, nddOnt, port, ref result);
342: }
343: else result.AddError("NDD ONT is null for access name: " + accessName + ".");
344: }
345: else result.AddError("AccessName null or empty.");
346: }
347: else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
348: }
349: else result.AddError("Service null or empty.");
350: }
351: catch (Exception ex)
352: {
353: result.AddError("Exception: " + ex.ToString() + ".");
354: }
355: }
356:
357: ////////////////////////////////////////////////////////////////////////////
358:
359: /// <summary>
360: ///
361: /// </summary>
362: public static void CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int port, ref Ia.Cl.Model.Result result)
363: {
364: Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPnPort fnSnPnPort;
365: Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
366: Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
367:
368: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
369: {
370: if (nddOnt != null)
371: {
372: if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
373: {
374: emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.ReadIncludeAccess(nddOnt.Id);
375:
376: if (emsOnt != null)
377: {
378: if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
379: {
380: if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
381: {
382: var accessNameToMduDevDictionary = Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary;
383:
384: if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
385: {
386: mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
387:
388: var vacantFnSnPnList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.VacantMduFnSnPnForOntList(mduDev, emsOnt);
389:
390: if (vacantFnSnPnList.Count > 0)
391: {
392: if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
393: {
394: fnSnPnPort = vacantFnSnPnList.Where(f => f.Port == port).SingleOrDefault();
395: }
396: else fnSnPnPort = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantMduFnSnPnForOnt(mduDev, emsOnt);
397:
398: if (fnSnPnPort != null)
399: {
400: var emsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
401:
402: if (emsVoipPstnUserList.Count == 0)
403: {
404: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnUser(ems, mduDev, nddOnt, service, fnSnPnPort.Sn, fnSnPnPort.Pn);
405:
406: if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
407: {
408: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateVoipPstnAccount(ems, mduDev, nddOnt, service, fnSnPnPort.Sn, fnSnPnPort.Pn);
409: }
410:
411: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, mduDev);
412:
413: associateServiceIdAndPortBetweenCreateAndReadDictionary[service] = fnSnPnPort.Port;
414:
415: result.AddSuccess("command(s) sent...");
416: }
417: else result.AddError("emsVoipPstnUserList count != 0. Value must be zero before the operation is executed for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
418: }
419: else result.AddError("MDU sn and/or tel is invalid or does not exist.");
420: }
421: else result.AddError("vacantFnSnPnList.Count is 0. There are no vacant ports in MDU.");
422: }
423: else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
424: }
425: else // SFU
426: {
427: var vacantList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.VacantTelForOntList(emsOnt);
428:
429: if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
430: {
431: port = vacantList.Contains(port) ? port : Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
432: }
433: else port = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantTelForOnt(emsOnt);
434:
435: if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
436: {
437: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateOntSipInfo(ems, nddOnt, service, port);
438:
439: // Don't use SAVE-DEV here
440: //Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, emsOnt.EmsPort.EmsBoard.EmsDev);
441:
442: associateServiceIdAndPortBetweenCreateAndReadDictionary[service] = port;
443:
444: result.AddSuccess("command(s) sent...");
445: }
446: else result.AddError("port is invalid or does not exist.");
447: }
448: }
449: else result.AddError("OLT is not SIP, its H.248.");
450: }
451: else result.AddError("emsOnt is null, does not exist for access: " + nddOnt.Access.Name + ".");
452: }
453: else result.AddError("access is not in an allowed to be provisioned OLT: " + nddOnt.Access.Name + ".");
454: }
455: else result.AddError("nddOnt is null, does not exist for service: " + service + ".");
456: }
457: else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
458: }
459:
460: ////////////////////////////////////////////////////////////////////////////
461:
462: /// <summary>
463: ///
464: /// </summary>
465: public static void ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, out Ia.Cl.Model.Result result)
466: {
467: ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, string.Empty, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, out result);
468: }
469:
470: ////////////////////////////////////////////////////////////////////////////
471:
472: /// <summary>
473: ///
474: /// </summary>
475: public static void ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, int port, out Ia.Cl.Model.Result result)
476: {
477: // see Ia.Ngn.Cl.Model.Business.Huawei.Nce.SendCommandAgainAfterNSeconds;
478:
479: ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, accessName, port, false, out result);
480: }
481:
482: ////////////////////////////////////////////////////////////////////////////
483:
484: /// <summary>
485: ///
486: /// </summary>
487: public static void ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, int port, bool sendReadOntSipInfoCommandAgainAfterNSeconds, out Ia.Cl.Model.Result result)
488: {
489: int serviceType;
490: string serviceId;
491:
492: result = new Ia.Cl.Model.Result();
493:
494: serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService;
495:
496: try
497: {
498: if (!string.IsNullOrEmpty(service))
499: {
500: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
501: {
502: serviceId = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
503:
504: if (!string.IsNullOrEmpty(accessName))
505: {
506: var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
507:
508: if (nddOnt != null)
509: {
510: Ia.Ngn.Cl.Model.Business.Huawei.Nce.ReadOntSipInfoOrVoipPstnUser(service, nddOnt, port, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
511: }
512: else result.AddError("NDD ONT is null for access name: " + accessName + ".");
513: }
514: else
515: {
516: Ia.Ngn.Cl.Model.Business.Huawei.Nce.ReadOntSipInfoOrVoipPstnUser(service, null, port, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
517: }
518: }
519: else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
520: }
521: else result.AddError("Service null or empty.");
522: }
523: catch (Exception ex)
524: {
525: result.AddError("Exception: " + ex.ToString() + ".");
526: }
527: }
528:
529: ////////////////////////////////////////////////////////////////////////////
530:
531: /// <summary>
532: ///
533: /// </summary>
534: public static void ReadOntSipInfoOrVoipPstnUser(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int port, ref Ia.Cl.Model.Result result)
535: {
536: // see Ia.Ngn.Cl.Model.Business.Huawei.Nce.SendCommandAgainAfterNSeconds;
537:
538: ReadOntSipInfoOrVoipPstnUser(service, nddOnt, port, false, ref result);
539: }
540:
541: ////////////////////////////////////////////////////////////////////////////
542:
543: /// <summary>
544: ///
545: /// </summary>
546: public static void ReadOntSipInfoOrVoipPstnUser(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int port, bool sendReadOntSipInfoCommandAgainAfterNSeconds, ref Ia.Cl.Model.Result result)
547: {
548: Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
549: Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
550:
551: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
552: {
553: if (nddOnt != null)
554: {
555: emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.Read(nddOnt.Id);
556:
557: if (emsOnt != null)
558: {
559: if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
560: {
561: var accessNameToMduDevDictionary = Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary;
562:
563: if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
564: {
565: mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
566:
567: if (port != Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
568: {
569: var fnSnPnPort = mduDev.PossibleFnSnPnPortList.Where(f => f.Port == port).SingleOrDefault();
570:
571: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev.Dev, fnSnPnPort.Sn, fnSnPnPort.Pn);
572: }
573: else if (associateServiceIdAndPortBetweenCreateAndReadDictionary.ContainsKey(service))
574: {
575: port = associateServiceIdAndPortBetweenCreateAndReadDictionary[service];
576:
577: var fnSnPnPort = mduDev.PossibleFnSnPnPortList.Where(f => f.Port == port).SingleOrDefault();
578:
579: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev.Dev, fnSnPnPort.Sn, fnSnPnPort.Pn);
580: }
581: else
582: {
583: foreach (var fnSnPnPort in mduDev.PossibleFnSnPnPortList)
584: {
585: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev.Dev, fnSnPnPort.Sn, fnSnPnPort.Pn);
586: }
587: }
588:
589: result.AddSuccess("command(s) sent...");
590: }
591: else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
592: }
593: else // SFU
594: {
595: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt, sendReadOntSipInfoCommandAgainAfterNSeconds);
596:
597: result.AddSuccess("command(s) sent...");
598: }
599: }
600: else result.AddError("emsOnt is null, does not exist for access: " + nddOnt.Access.Name + ".");
601: }
602: else
603: {
604: var emsOntSipInfoList = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ReadByServiceIncludeEmsOntAndAccess(service);
605:
606: if (emsOntSipInfoList.Count > 0)
607: {
608: // SFU
609:
610: foreach (var emsOntSipInfo in emsOntSipInfoList)
611: {
612: emsOnt = emsOntSipInfo.EmsOnt;
613:
614: if (emsOnt.Access != null)
615: {
616: nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(emsOnt.Access.Id);
617:
618: if (nddOnt != null)
619: {
620: if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
621: {
622: if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
623: {
624: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntSipInfo(ems, nddOnt, sendReadOntSipInfoCommandAgainAfterNSeconds);
625:
626: result.AddSuccess("command(s) sent...");
627: }
628: else result.AddError("OLT is not SIP, its H.248.");
629: }
630: else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
631: }
632: else result.AddError("nddOnt is null, does not exist for service " + service + ".");
633: }
634: else result.AddError("emsOnt.Access is null for service " + service + ".");
635: }
636: }
637:
638:
639: var emsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
640:
641: if (emsVoipPstnUserList.Count > 0)
642: {
643: // MDU
644:
645: foreach (var emsVoipPstnUser in emsVoipPstnUserList)
646: {
647: emsOnt = emsVoipPstnUser.EmsOnt;
648:
649: if (emsOnt.Access != null)
650: {
651: nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(emsOnt.Access.Id);
652:
653: if (nddOnt != null)
654: {
655: if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
656: {
657: if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
658: {
659: if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
660: {
661: var accessNameToMduDevDictionary = Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary;
662:
663: if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
664: {
665: mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
666:
667: foreach (var fnSnPnPort in mduDev.PossibleFnSnPnPortList)
668: {
669: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, mduDev.Dev, fnSnPnPort.Sn, fnSnPnPort.Pn);
670:
671: result.AddSuccess("command(s) sent...");
672: }
673: }
674: else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
675: }
676: else result.AddError("ONT family type is not MDU.");
677: }
678: else result.AddError("OLT is not SIP, its H.248.");
679: }
680: else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
681: }
682: else result.AddError("nddOnt is null, does not exist for service " + service + ".");
683: }
684: else result.AddError("emsOnt.Access is null for service " + service + ".");
685: }
686:
687:
688: var msanEmsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByMsanService(service);
689:
690: if (msanEmsVoipPstnUserList.Count > 0)
691: {
692: // MSAN
693:
694: foreach (var emsVoipPstnUser in msanEmsVoipPstnUserList)
695: {
696: ReadVoipPstnUser(emsVoipPstnUser.DID, emsVoipPstnUser.FN, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
697: }
698:
699: result.AddSuccess("command(s) sent...");
700: }
701: }
702: }
703: }
704: else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
705: }
706:
707: ////////////////////////////////////////////////////////////////////////////
708:
709: /// <summary>
710: ///
711: /// </summary>
712: public static string DeleteOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(string service, string accessName, int port, out Ia.Cl.Model.Result result)
713: {
714: int serviceType;
715: string serviceId, vacatedAccessName;
716: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont vacatedNddOnt;
717:
718: result = new Ia.Cl.Model.Result();
719:
720: serviceType = Ia.Ngn.Cl.Model.Business.Service.ServiceType.ImsService;
721:
722: vacatedAccessName = string.Empty;
723:
724: try
725: {
726: if (!string.IsNullOrEmpty(service))
727: {
728: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
729: {
730: serviceId = Ia.Ngn.Cl.Model.Business.Service.ServiceToServiceId(service, serviceType);
731:
732: if (!string.IsNullOrEmpty(accessName))
733: {
734: var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
735:
736: if (nddOnt != null)
737: {
738: vacatedNddOnt = Ia.Ngn.Cl.Model.Business.Huawei.Nce.VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(service, nddOnt, port, ref result);
739:
740: vacatedAccessName = (vacatedNddOnt != null) ? vacatedNddOnt.Access.Name : string.Empty;
741: }
742: else result.AddError("NDD ONT is null for access name: " + accessName + ".");
743: }
744: else if (port == Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
745: {
746: vacatedNddOnt = Ia.Ngn.Cl.Model.Business.Huawei.Nce.VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(service, null, port, ref result);
747:
748: vacatedAccessName = (vacatedNddOnt != null) ? vacatedNddOnt.Access.Name : string.Empty;
749: }
750: else result.AddError("accessName is empty or null and port is not PortUndefinedOrInvalidOrUnknown. NCE does not know how to handle vacation where nddOnt is null and port is defined.");
751: }
752: else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
753: }
754: else result.AddError("Service null or empty.");
755: }
756: catch (Exception ex)
757: {
758: result.AddError("Exception: " + ex.ToString() + ".");
759: }
760:
761: return vacatedAccessName;
762: }
763:
764: ////////////////////////////////////////////////////////////////////////////
765:
766: /// <summary>
767: ///
768: /// </summary>
769: public static Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(string service, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt, int port, ref Ia.Cl.Model.Result result)
770: {
771: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont vacatedNddOnt;
772: Ia.Ngn.Cl.Model.Business.Huawei.Dev.MduDev mduDev;
773: Ia.Ngn.Cl.Model.Huawei.EmsOnt emsOnt;
774:
775: vacatedNddOnt = nddOnt;
776:
777: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
778: {
779: if (nddOnt != null)
780: {
781: if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
782: {
783: if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
784: {
785: emsOnt = Ia.Ngn.Cl.Model.Data.Huawei.Ont.ReadIncludeAccess(nddOnt.Id);
786:
787: if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
788: {
789: var accessNameToMduDevDictionary = Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary;
790:
791: if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
792: {
793: mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
794:
795: if (port == Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
796: {
797: var emsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
798:
799: foreach (var emsVoipPstnUser in emsVoipPstnUserList)
800: {
801: if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
802: {
803: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
804: }
805:
806: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
807:
808: result.AddSuccess("command(s) sent...");
809: }
810: }
811: else
812: {
813: var fnSnPnPort = mduDev.PossibleFnSnPnPortList.Where(f => f.Port == port).SingleOrDefault();
814:
815: if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
816: {
817: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, mduDev, nddOnt, service, mduDev.FirstFnSnPnPort.Sn, fnSnPnPort.Pn);
818: }
819:
820: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, mduDev, nddOnt, service, mduDev.FirstFnSnPnPort.Sn, fnSnPnPort.Pn);
821:
822: result.AddSuccess("command(s) sent...");
823: }
824:
825: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, mduDev);
826: }
827: else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service " + service + " and access " + nddOnt.Access.Name + ".");
828: }
829: else // SFU
830: {
831: if (port == Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown)
832: {
833: var emsOntSipInfoList = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ReadByService(service);
834:
835: foreach (var emsOntSipInfo in emsOntSipInfoList)
836: {
837: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateOntSipInfo(ems, nddOnt, service, emsOntSipInfo.TEL);
838: }
839:
840: result.AddSuccess("command(s) sent...");
841: }
842: else
843: {
844: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateOntSipInfo(ems, nddOnt, service, port);
845:
846: result.AddSuccess("command(s) sent...");
847: }
848: }
849: }
850: else result.AddError("OLT is not SIP, its H.248.");
851: }
852: else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
853: }
854: else
855: {
856: var emsOntSipInfoList = Ia.Ngn.Cl.Model.Data.Huawei.OntSipInfo.ReadByServiceIncludeEmsOntAndAccess(service);
857:
858: if (emsOntSipInfoList.Count > 0)
859: {
860: // SFU
861:
862: foreach (var emsOntSipInfo in emsOntSipInfoList)
863: {
864: emsOnt = emsOntSipInfo.EmsOnt;
865:
866: if (emsOnt.Access != null)
867: {
868: nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(emsOnt.Access.Id);
869:
870: if (nddOnt != null)
871: {
872: if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
873: {
874: if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
875: {
876: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateOntSipInfo(ems, nddOnt, service, emsOntSipInfo.TEL);
877:
878: result.AddSuccess("command(s) sent...");
879: }
880: else result.AddError("OLT is not SIP, its H.248.");
881: }
882: else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
883: }
884: else result.AddError("nddOnt is null, does not exist for service " + service + ".");
885:
886: vacatedNddOnt = nddOnt;
887: }
888: else result.AddError("emsOnt.Access is null for service " + service + ".");
889: }
890: }
891:
892:
893: var emsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
894:
895: if (emsVoipPstnUserList.Count > 0)
896: {
897: // MDU
898:
899: foreach (var emsVoipPstnUser in emsVoipPstnUserList)
900: {
901: emsOnt = emsVoipPstnUser.EmsOnt;
902:
903: if (emsOnt.Access != null)
904: {
905: nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByOntAccessId(emsOnt.Access.Id);
906:
907: if (nddOnt != null)
908: {
909: if (Ia.Ngn.Cl.Model.Business.Service.OltIsWithinAllowedToBeProvisionedOrMigratedOltList(nddOnt.Pon.PonGroup.Olt))
910: {
911: if (nddOnt.Pon.PonGroup.Olt.IsSip == true)
912: {
913: if (emsOnt.FamilyType == Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu)
914: {
915: var accessNameToMduDevDictionary = Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionary;
916:
917: if (accessNameToMduDevDictionary.ContainsKey(nddOnt.Access.Name))
918: {
919: mduDev = accessNameToMduDevDictionary[nddOnt.Access.Name];
920:
921: if (nddOnt.Pon.PonGroup.Olt.Odf.Router.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Nokia)
922: {
923: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
924: }
925:
926: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, mduDev, nddOnt, service, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
927:
928: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, mduDev);
929:
930: result.AddSuccess("command(s) sent...");
931: }
932: else result.AddError("emsOnt.FamilyType is MDU but AccessNameToMduDevDictionary does not contain key: " + nddOnt.Access.Name + " for service: " + service + ", and access: " + nddOnt.Access.Name + ".");
933: }
934: else result.AddError("ONT family type is not MDU.");
935: }
936: else result.AddError("OLT is not SIP, its H.248.");
937: }
938: else result.AddError("nddOnt.Access.Name " + nddOnt.Access.Name + " is not in an allowed to be provisioned OLT.");
939: }
940: else result.AddError("nddOnt is null, does not exist for service " + service + ".");
941:
942: vacatedNddOnt = nddOnt;
943: }
944: else result.AddError("emsOnt.Access is null for service " + service + ".");
945: }
946: }
947: else
948: {
949: var msanEmsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByMsanService(service);
950:
951: if (msanEmsVoipPstnUserList.Count > 0)
952: {
953: // MSAN
954:
955: foreach (var emsVoipPstnUser in msanEmsVoipPstnUserList)
956: {
957: DeleteVoipPstnUserAndOrVacateVoipPstnAccount(emsVoipPstnUser.DID, emsVoipPstnUser.FN, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
958: }
959:
960: result.AddSuccess("command(s) sent...");
961: }
962: else result.AddWarning("Could not find service " + service + ".");
963: }
964: }
965: }
966: else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
967:
968: return vacatedNddOnt;
969: }
970:
971: ////////////////////////////////////////////////////////////////////////////
972:
973: /// <summary>
974: ///
975: /// </summary>
976: public static List<Ia.Ngn.Cl.Model.Business.Huawei.Dev.MsanDev.Lic> DeleteMsanVoipPstnUser2(string service, out Ia.Cl.Model.Result result)
977: {
978: Ia.Ngn.Cl.Model.Business.Huawei.Dev.MsanDev.Lic lic;
979:
980: result = new Ia.Cl.Model.Result();
981:
982: var licList = new List<Ia.Ngn.Cl.Model.Business.Huawei.Dev.MsanDev.Lic>();
983:
984: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
985: {
986: var msanEmsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByMsanService(service);
987:
988: if (msanEmsVoipPstnUserList.Count > 0)
989: {
990: // MSAN
991:
992: foreach (var emsVoipPstnUser in msanEmsVoipPstnUserList)
993: {
994: DeleteVoipPstnUserAndOrVacateVoipPstnAccount(emsVoipPstnUser.DID, emsVoipPstnUser.FN, emsVoipPstnUser.SN, emsVoipPstnUser.PN);
995:
996: lic = Ia.Ngn.Cl.Model.Data.Huawei.Default.MsanDevLicByEmsVoipPstnUserId(emsVoipPstnUser.Id);
997:
998: licList.Add(lic);
999: }
1000:
1001: result.AddSuccess("command(s) sent...");
1002: }
1003: else result.AddWarning("Could not find service " + service + ".");
1004: }
1005: else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
1006:
1007: return licList;
1008: }
1009:
1010: ////////////////////////////////////////////////////////////////////////////
1011:
1012: /// <summary>
1013: ///
1014: /// </summary>
1015: public static void DeleteVoipPstnUserAndOrVacateVoipPstnAccount(string dev, int fn, int sn, int pn)
1016: {
1017: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, dev, fn, sn, pn);
1018:
1019: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, dev, fn, sn, pn);
1020:
1021: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, dev);
1022: }
1023:
1024: ////////////////////////////////////////////////////////////////////////////
1025:
1026: /// <summary>
1027: ///
1028: /// </summary>
1029: private static void DeleteVoipPstnUserAndOrVacateVoipPstnAccount(int did, int fn, int sn, int pn)
1030: {
1031: var dev = Ia.Ngn.Cl.Model.Data.Huawei.Dev.DidToDevDictionary[did];
1032:
1033: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendVacateVoipPstnAccount(ems, dev, fn, sn, pn);
1034:
1035: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, dev, fn, sn, pn);
1036:
1037: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, dev);
1038: }
1039:
1040: ////////////////////////////////////////////////////////////////////////////
1041: ////////////////////////////////////////////////////////////////////////////
1042:
1043: /// <summary>
1044: ///
1045: /// </summary>
1046: public static Ia.Cl.Model.Result CreateMsanVoipPstnUser(string msanDevId, int fn, int sn, int pn, string service)
1047: {
1048: Ia.Ngn.Cl.Model.Business.Huawei.Default.FnSnPnPort fnSnPn;
1049:
1050: var result = new Ia.Cl.Model.Result();
1051:
1052: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
1053: {
1054: var msanDev = (from m in Ia.Ngn.Cl.Model.Data.Huawei.Default.MsanDevList where m.Id == msanDevId select m).Single();
1055:
1056: var vacantFnSnPnList = Ia.Ngn.Cl.Model.Data.Huawei.Ems.VacantMsanFnSnPnListForMsanDev(msanDev);
1057:
1058: if (vacantFnSnPnList.Count > 0)
1059: {
1060: fnSnPn = vacantFnSnPnList.Where(f => f.Fn == fn && f.Sn == sn && f.Pn == pn).SingleOrDefault();
1061:
1062: if (fnSnPn == null) fnSnPn = Ia.Ngn.Cl.Model.Data.Huawei.Ems.NextVacantMsanFnSnPnForMsanDev(msanDev);
1063:
1064: if (fnSnPn != null)
1065: {
1066: var emsVoipPstnUserList = Ia.Ngn.Cl.Model.Data.Huawei.VoipPstnUser.ReadByService(service);
1067:
1068: if (emsVoipPstnUserList.Count == 0)
1069: {
1070: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendCreateMsanVoipPstnUser(ems, msanDev, fnSnPn.Fn, fnSnPn.Sn, fnSnPn.Pn, service);
1071:
1072: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, msanDev);
1073:
1074: result.AddSuccess("command(s) sent...");
1075: }
1076: else result.AddError("emsVoipPstnUserList count != 0. Value must be zero before the operation is executed for service: " + service + ".");
1077: }
1078: else result.AddError("MDU sn and/or tel is invalid or does not exist.");
1079: }
1080: else result.AddError("vacantFnSnPnList.Count is 0. There are no vacant ports in MSAN.");
1081: }
1082: else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
1083:
1084: return result;
1085: }
1086:
1087: ////////////////////////////////////////////////////////////////////////////
1088:
1089: /// <summary>
1090: ///
1091: /// </summary>
1092: public static void ReadVoipPstnUser(string dev, int fn, int sn, int pn)
1093: {
1094: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, dev, sn, pn);
1095: }
1096:
1097: ////////////////////////////////////////////////////////////////////////////
1098:
1099: /// <summary>
1100: ///
1101: /// </summary>
1102: public static void ReadMsanVoipPstnUser(Ia.Ngn.Cl.Model.Business.Huawei.Dev.MsanDev.Lic lic)
1103: {
1104: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, lic.MsanDevDev, lic.Sn, lic.Pn);
1105: }
1106:
1107: ////////////////////////////////////////////////////////////////////////////
1108:
1109: /// <summary>
1110: ///
1111: /// </summary>
1112: public static void ReadVoipPstnUser(string service)
1113: {
1114: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, service);
1115: }
1116:
1117: ////////////////////////////////////////////////////////////////////////////
1118:
1119: /// <summary>
1120: ///
1121: /// </summary>
1122: private static void ReadVoipPstnUser(int did, int fn, int sn, int pn)
1123: {
1124: var dev = Ia.Ngn.Cl.Model.Data.Huawei.Dev.DidToDevDictionary[did];
1125:
1126: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, dev, sn, pn);
1127: }
1128:
1129: ////////////////////////////////////////////////////////////////////////////
1130:
1131: /// <summary>
1132: ///
1133: /// </summary>
1134: public static void DeleteVoipPstnUser(string dev, int fn, int sn, int pn)
1135: {
1136: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendDeleteVoipPstnUser(ems, dev, fn, sn, pn);
1137:
1138: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendSaveDev(ems, dev);
1139: }
1140:
1141: ////////////////////////////////////////////////////////////////////////////
1142:
1143: /// <summary>
1144: ///
1145: /// </summary>
1146: public static List<Ia.Ngn.Cl.Model.Business.Huawei.Dev.MsanDev.Lic> DeleteMsanVoipPstnUser(string service, out Ia.Cl.Model.Result result)
1147: {
1148: var licList = new List<Ia.Ngn.Cl.Model.Business.Huawei.Dev.MsanDev.Lic>();
1149:
1150: result = new Ia.Cl.Model.Result();
1151:
1152: try
1153: {
1154: if (!string.IsNullOrEmpty(service))
1155: {
1156: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(service))
1157: {
1158: licList = Ia.Ngn.Cl.Model.Business.Huawei.Nce.DeleteMsanVoipPstnUser2(service, out result);
1159: }
1160: else result.AddError("Service number " + service + " does not belong to allowed domain lists.");
1161: }
1162: else result.AddError("Service null or empty.");
1163: }
1164: catch (Exception ex)
1165: {
1166: result.AddError("Exception: " + ex.ToString() + ".");
1167: }
1168:
1169: return licList;
1170: }
1171:
1172: ////////////////////////////////////////////////////////////////////////////
1173: ////////////////////////////////////////////////////////////////////////////
1174:
1175: /// <summary>
1176: ///
1177: /// </summary>
1178: public static Ia.Cl.Model.Result ResetOnt(string accessName)
1179: {
1180: var result = new Ia.Cl.Model.Result();
1181:
1182: try
1183: {
1184: if (!string.IsNullOrEmpty(accessName))
1185: {
1186: var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
1187:
1188: if (nddOnt != null)
1189: {
1190: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendResetOnt(ems, nddOnt);
1191: }
1192: else result.AddError("NDD ONT is null for access name: " + accessName);
1193: }
1194: else
1195: {
1196: result.AddError("AccessName null or empty");
1197: }
1198: }
1199: catch (Exception ex)
1200: {
1201: result.AddError("Exception: " + ex.ToString());
1202: }
1203:
1204: return result;
1205: }
1206:
1207: ////////////////////////////////////////////////////////////////////////////
1208: ////////////////////////////////////////////////////////////////////////////
1209:
1210: /// <summary>
1211: ///
1212: /// </summary>
1213: public static Ia.Cl.Model.Result ManageSynchronizationBetweenAccessAndSwitchPastHour()
1214: {
1215: // See: ManageSynchronizationBetweenAccessAndSwitchPastHour(), ManageSynchronizationBetweenAccessAndSwitchPast24Hours(), ManageSynchronizationBetweenAccessAndSwitch()
1216:
1217: Ia.Ngn.Cl.Model.Business.Procedure.Process process;
1218:
1219: var sendReadOntSipInfoCommandAgainAfterNSeconds = true; // later remove latestProcess from inside function and make this true
1220: var result = new Ia.Cl.Model.Result();
1221:
1222: // problem: I have put empty new List<string>() here because there is an exception: System.Exception: Undefined function
1223: process = serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePastHourProcedure.NextProcess(new List<string>());
1224:
1225: if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
1226: {
1227: if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Create)
1228: {
1229: result.AddSuccess("create: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
1230:
1231: CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
1232: }
1233: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
1234: {
1235: result.AddSuccess("read: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
1236:
1237: ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
1238: }
1239: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Delete)
1240: {
1241: result.AddSuccess("delete: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
1242:
1243: _ = VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
1244: }
1245: else result.AddError("sync: undefined procedure. ");
1246:
1247: // Ia.Ngn.Cl.Model.Data.Msmq.SecretaryApplication.Updated() is in Ia.Ngn.Cl.Model.Business.Huawei.Ems.UpdateDatabaseWithEmsCommandOutput();
1248: }
1249: else result.AddWarning("sync: nothing to create or delete");
1250:
1251: return result;
1252: }
1253:
1254: ////////////////////////////////////////////////////////////////////////////
1255:
1256: /// <summary>
1257: ///
1258: /// </summary>
1259: public static Ia.Cl.Model.Result ManageSynchronizationBetweenAccessAndSwitchPast24Hours()
1260: {
1261: // See: ManageSynchronizationBetweenAccessAndSwitchPastHour(), ManageSynchronizationBetweenAccessAndSwitchPast24Hours(), ManageSynchronizationBetweenAccessAndSwitch()
1262:
1263: Ia.Ngn.Cl.Model.Business.Procedure.Process process;
1264:
1265: var sendReadOntSipInfoCommandAgainAfterNSeconds = true; // later remove latestProcess from inside function and make this true
1266: var result = new Ia.Cl.Model.Result();
1267:
1268: process = serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.NextProcess(priorityServiceList);
1269:
1270: if (priorityServiceList.Count > 50) priorityServiceList.Clear();
1271:
1272: if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
1273: {
1274: if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Create)
1275: {
1276: result.AddSuccess("create: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
1277:
1278: CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
1279: }
1280: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
1281: {
1282: result.AddSuccess("read: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
1283:
1284: ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
1285: }
1286: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Delete)
1287: {
1288: result.AddSuccess("delete: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserOfServiceFromThePast24HourProcedure.ProgressCounterString);
1289:
1290: _ = VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
1291: }
1292: else result.AddError("sync: undefined procedure. ");
1293:
1294: // Ia.Ngn.Cl.Model.Data.Msmq.SecretaryApplication.Updated() is in Ia.Ngn.Cl.Model.Business.Huawei.Ems.UpdateDatabaseWithEmsCommandOutput();
1295: }
1296: else result.AddWarning("sync: nothing to create or delete");
1297:
1298: return result;
1299: }
1300:
1301: ////////////////////////////////////////////////////////////////////////////
1302:
1303: /// <summary>
1304: ///
1305: /// </summary>
1306: public static Ia.Cl.Model.Result ManageSynchronizationBetweenAccessAndSwitch()
1307: {
1308: // See: ManageSynchronizationBetweenAccessAndSwitchPastHour(), ManageSynchronizationBetweenAccessAndSwitchPast24Hours(), ManageSynchronizationBetweenAccessAndSwitch()
1309:
1310: Ia.Ngn.Cl.Model.Business.Procedure.Process process;
1311:
1312: var sendReadOntSipInfoCommandAgainAfterNSeconds = true; // later remove latestProcess from inside function and make this true
1313: var result = new Ia.Cl.Model.Result();
1314:
1315: // problem: I have put empty new List<string>() here because there is an exception: System.Exception: Undefined function
1316: process = serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure.NextProcess(new List<string>());
1317:
1318: if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
1319: {
1320: if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Create)
1321: {
1322: result.AddSuccess("create: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure.ProgressCounterString);
1323:
1324: CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
1325: }
1326: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
1327: {
1328: result.AddSuccess("read: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure.ProgressCounterString);
1329:
1330: ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, sendReadOntSipInfoCommandAgainAfterNSeconds, ref result);
1331: }
1332: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Delete)
1333: {
1334: result.AddSuccess("delete: " + process.ServiceId + " " + serviceOntToCreateOrDeleteInEmsOntSipInfoOrVoipPstnUserProcedure.ProgressCounterString);
1335:
1336: _ = VacateOntSipInfoOrDeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.Service, process.Ont, Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown, ref result);
1337: }
1338: else result.AddError("sync: undefined procedure. ");
1339:
1340: // Ia.Ngn.Cl.Model.Data.Msmq.SecretaryApplication.Updated() is in Ia.Ngn.Cl.Model.Business.Huawei.Ems.UpdateDatabaseWithEmsCommandOutput();
1341: }
1342: else result.AddWarning("sync: nothing to create or delete");
1343:
1344: return result;
1345: }
1346:
1347: ////////////////////////////////////////////////////////////////////////////
1348: ////////////////////////////////////////////////////////////////////////////
1349:
1350: /// <summary>
1351: ///
1352: /// </summary>
1353: public static Ia.Cl.Model.Result ManageDeleteMsanOfProvisionedImsServiceOrWithNoEquivalentInService()
1354: {
1355: Ia.Ngn.Cl.Model.Business.Procedure.Process process;
1356:
1357: var result = new Ia.Cl.Model.Result();
1358:
1359: process = msanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceListProcedure.NextProcess();
1360:
1361: if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
1362: {
1363: if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Delete)
1364: {
1365: result.AddSuccess("delete: " + process.Service + " " + process.EmsVoipPstnUserDidFnSnPnDn.ToSimpleDidFnSnPnDnTextString() + " " + msanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceListProcedure.ProgressCounterString);
1366:
1367: DeleteVoipPstnUserAndOrVacateVoipPstnAccount(process.EmsVoipPstnUserDidFnSnPnDn.Did, process.EmsVoipPstnUserDidFnSnPnDn.Fn, process.EmsVoipPstnUserDidFnSnPnDn.Sn, process.EmsVoipPstnUserDidFnSnPnDn.Pn);
1368: }
1369: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
1370: {
1371: result.AddSuccess("read: " + process.Service + " " + process.EmsVoipPstnUserDidFnSnPnDn.ToSimpleDidFnSnPnDnTextString() + " " + msanServiceEmsVoipPstnUserDidFnSnPnDnToDeleteBecauseItHasProvisionedImsServiceOrHasNoEquivalentInServiceListProcedure.ProgressCounterString);
1372:
1373: ReadVoipPstnUser(process.EmsVoipPstnUserDidFnSnPnDn.Did, process.EmsVoipPstnUserDidFnSnPnDn.Fn, process.EmsVoipPstnUserDidFnSnPnDn.Sn, process.EmsVoipPstnUserDidFnSnPnDn.Pn);
1374: }
1375: else result.AddError("sync: undefined procedure. ");
1376:
1377: // Ia.Ngn.Cl.Model.Data.Msmq.SecretaryApplication.Updated() is in Ia.Ngn.Cl.Model.Business.Huawei.Ems.UpdateDatabaseWithEmsCommandOutput();
1378: }
1379: else result.AddWarning("sync: nothing to delete");
1380:
1381: return result;
1382: }
1383:
1384: ////////////////////////////////////////////////////////////////////////////
1385: ////////////////////////////////////////////////////////////////////////////
1386:
1387: /// <summary>
1388: ///
1389: /// </summary>
1390: public static void ManageUpdateOfOntFromH248ToSip(out Ia.Cl.Model.Result result)
1391: {
1392: Ia.Ngn.Cl.Model.Business.Procedure.Process process;
1393:
1394: result = new Ia.Cl.Model.Result();
1395:
1396: process = updateEmsOntFromH248ToSipProcedure.NextProcess();
1397:
1398: if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
1399: {
1400: if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update)
1401: {
1402: result.AddSuccess("update: " + process.Ont.Access.Name + " " + updateEmsOntFromH248ToSipProcedure.ProgressCounterString);
1403:
1404: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendUpdateOntFromH248ToSip(ems, process.Ont);
1405: }
1406: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
1407: {
1408: result.AddSuccess("read: " + process.Ont.Access.Name + " " + updateEmsOntFromH248ToSipProcedure.ProgressCounterString);
1409:
1410: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOnt(ems, process.Ont);
1411: }
1412: else result.AddSuccess("update: undefined procedure. ");
1413: }
1414: else result.AddSuccess("update: nothing to update");
1415: }
1416:
1417: ////////////////////////////////////////////////////////////////////////////
1418:
1419: /// <summary>
1420: ///
1421: /// </summary>
1422: public static void ManageCreateOntSipInfoOrOntVoipPstnUserForOntUpdatedFromH248ToSip(out Ia.Cl.Model.Result result)
1423: {
1424: Ia.Ngn.Cl.Model.Business.Procedure.Process process;
1425:
1426: result = new Ia.Cl.Model.Result();
1427:
1428: process = createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.NextProcess();
1429:
1430: if (process.Type != Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.None)
1431: {
1432: if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Update)
1433: {
1434: result.AddSuccess("create: " + process.Ont.Access.Name + " " + process.Service + " " + createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.ProgressCounterString);
1435:
1436: CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(process.Service, process.Ont, process.Port, ref result);
1437: }
1438: else if (process.Type == Ia.Ngn.Cl.Model.Business.Procedure.ProcessType.Read)
1439: {
1440: result.AddSuccess("read: " + process.Ont.Access.Name + " " + process.Service + " " + createOntSipInfoOrOntVoipPstnUserForAnOntUpdatedFromH248ToSipProcedure.ProgressCounterString);
1441:
1442: ReadOntSipInfoOrVoipPstnUser(process.Service, process.Ont, process.Port, ref result);
1443: }
1444: else result.AddSuccess("create: undefined procedure. ");
1445: }
1446: else result.AddSuccess("create: nothing to create");
1447: }
1448:
1449: ////////////////////////////////////////////////////////////////////////////
1450:
1451: /// <summary>
1452: ///
1453: /// </summary>
1454: public static Ia.Cl.Model.Result ManageMsmqQueue()
1455: {
1456: List<string> list;
1457:
1458: var result = new Ia.Cl.Model.Result();
1459:
1460: var queueCount = Ia.Ngn.Cl.Model.Data.Msmq.NceApplication.Count;
1461:
1462: if (queueCount > 0)
1463: {
1464: var message = Ia.Ngn.Cl.Model.Data.Msmq.NceApplication.Dequeue;
1465:
1466: if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.ReadService)
1467: {
1468: var service = message.Service;
1469:
1470: list = Ia.Ngn.Cl.Model.Business.Huawei.Ems.EmsCommandsToRetriveOntNetworkElementDataByService(service);
1471:
1472: foreach (string s in list) ems.SendQueue.Enqueue(s);
1473:
1474: if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
1475: }
1476: else if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.ReadAccess)
1477: {
1478: list = Ia.Ngn.Cl.Model.Business.Huawei.Ems.EmsCommandsToRetriveOntNetworkElementDataByAccessName(message.AccessName);
1479:
1480: foreach (string s in list) ems.SendQueue.Enqueue(s);
1481: }
1482: else if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.ResetAccess)
1483: {
1484: var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(message.AccessName);
1485:
1486: if (nddOnt != null)
1487: {
1488: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendResetOnt(ems, nddOnt);
1489: }
1490: else result.AddError("NDD ONT is null for access name: " + message.AccessName);
1491: }
1492: else if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.CreateReadServiceAccessPort || message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.CreateReadNceOrAmsServiceAccessPort)
1493: {
1494: var service = message.Service;
1495: var accessName = message.AccessName;
1496: var port = (message.Port > 0) ? message.Port : Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
1497:
1498: var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
1499:
1500: var sendReadOntSipInfoCommandAgainAfterNSeconds = true;
1501:
1502: if (nddOnt != null)
1503: {
1504: if (nddOnt.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1505: {
1506: Ia.Ngn.Cl.Model.Business.Huawei.Nce.CreateOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, accessName, port, out Ia.Cl.Model.Result createResult);
1507:
1508: Ia.Ngn.Cl.Model.Business.Huawei.Nce.ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, accessName, port, sendReadOntSipInfoCommandAgainAfterNSeconds, out Ia.Cl.Model.Result readResult);
1509:
1510: result.AddSuccess("Create/Read: " + service + "|" + accessName + "|" + port + ": " + createResult.Message + "," + readResult.Message);
1511:
1512: if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
1513: }
1514: else result.AddError("Access vendor is not Huawei. Access name: " + accessName + ".");
1515: }
1516: else result.AddError("NDD ONT is null for access name: " + accessName + ".");
1517: }
1518: else if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.DeleteReadServiceAccess || message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.DeleteReadNceOrAmsServiceAccessPort)
1519: {
1520: var service = message.Service;
1521: var accessName = message.AccessName;
1522: var port = (message.Port > 0) ? message.Port : Ia.Ngn.Cl.Model.Business.Default.PortUndefinedOrInvalidOrUnknown;
1523:
1524: var nddOnt = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntByAccessName(accessName);
1525:
1526: var sendReadOntSipInfoCommandAgainAfterNSeconds = true;
1527:
1528: if (nddOnt != null)
1529: {
1530: if (nddOnt.Pon.PonGroup.Olt.Odf.Vendor == Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor.Huawei)
1531: {
1532: var vacatedAccessName = Ia.Ngn.Cl.Model.Business.Huawei.Nce.DeleteOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, accessName, port, out Ia.Cl.Model.Result deleteResult);
1533:
1534: Ia.Ngn.Cl.Model.Business.Huawei.Nce.ReadOntSipInfoOrVoipPstnUserAndOrVoipPstnAccount(service, vacatedAccessName, port, sendReadOntSipInfoCommandAgainAfterNSeconds, out Ia.Cl.Model.Result readResult);
1535:
1536: result.AddSuccess("Delete/Read: " + service + "|" + accessName + "|" + port + ": " + deleteResult.Message + "," + readResult.Message);
1537:
1538: if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
1539: }
1540: else result.AddError("Access vendor is not Huawei. Access name: " + accessName + ".");
1541: }
1542: else result.AddError("NDD ONT is null for access name: " + accessName + ".");
1543: }
1544: else if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.CreateReadNceMsanServiceMsanCabinetFrameFnSnPn)
1545: {
1546: var msanDevId = message.MsanDevId;
1547: var fn = message.Fn;
1548: var sn = message.Sn;
1549: var pn = message.Pn;
1550: var service = message.Service;
1551:
1552: var msanDev = (from m in Ia.Ngn.Cl.Model.Data.Huawei.Default.MsanDevList where m.Id == msanDevId select m).Single();
1553:
1554: result = Ia.Ngn.Cl.Model.Business.Huawei.Nce.CreateMsanVoipPstnUser(msanDevId, fn, sn, pn, service);
1555:
1556: Ia.Ngn.Cl.Model.Business.Huawei.Nce.ReadVoipPstnUser(service);
1557:
1558: result.AddSuccess("Create/Read: " + msanDev.Dev + "-" + fn + "-" + sn + "-" + pn + "|" + service + ": " + result.Message);
1559:
1560: if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
1561: }
1562: else if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.DeleteReadNceMsanService)
1563: {
1564: var service = message.Service;
1565:
1566: var readResult = new Ia.Cl.Model.Result();
1567:
1568: var vacatedLicList = Ia.Ngn.Cl.Model.Business.Huawei.Nce.DeleteMsanVoipPstnUser(service, out result);
1569:
1570: foreach (var vacatedLic in vacatedLicList)
1571: {
1572: Ia.Ngn.Cl.Model.Business.Huawei.Nce.ReadMsanVoipPstnUser(vacatedLic);
1573: }
1574:
1575: result.AddSuccess("Delete/Read: " + service + ": " + result.Message + "," + readResult.Message);
1576:
1577: if (!priorityServiceList.Contains(service)) priorityServiceList.Add(service);
1578: }
1579: else if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.AccessCreated)
1580: {
1581: Ia.Ngn.Cl.Model.Data.Huawei.Default.AccessNameToMduDevDictionaryReset();
1582:
1583: result.AddSuccess("Access created: AccessNameToMduDevDictionary reset.");
1584: }
1585: else if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.Synchronize)
1586: {
1587: var r = Ia.Ngn.Cl.Model.Business.Huawei.Nce.ManageSynchronizationBetweenAccessAndSwitchPast24Hours();
1588: result.AddResult("Manage: Synchronization: Access with Switch", r);
1589:
1590: var r2 = Ia.Ngn.Cl.Model.Business.Huawei.Nce.ManageDeleteMsanOfProvisionedImsServiceOrWithNoEquivalentInService();
1591: result.AddResult("Manage: Synchronization: Delete MSAN of provisioned IMS service", r2);
1592: }
1593: else if (message.Process == Ia.Ngn.Cl.Model.Business.Msmq.Process.ActiveApplicationRunningPermissionState)
1594: {
1595: Ia.Ngn.Cl.Model.Business.Default.PermitActiveApplicationsToRun = message.State;
1596:
1597: result.AddSuccess("PermitActiveApplicationsToRun: " + message.State);
1598: }
1599: else
1600: {
1601: throw new ArgumentOutOfRangeException("MSMQ process " + message.Process.ToString() + " is undefined");
1602: }
1603:
1604: result.AddSuccess(message.AccessName + ":" + message.Service);
1605: }
1606:
1607: return result;
1608: }
1609:
1610: ////////////////////////////////////////////////////////////////////////////
1611:
1612: /// <summary>
1613: ///
1614: /// </summary>
1615: public static void ManageProperly(out Ia.Cl.Model.Result result)
1616: {
1617: string command;
1618:
1619: result = new Ia.Cl.Model.Result();
1620:
1621: command = Ia.Ngn.Cl.Model.Business.Huawei.Ems.ProperlySelectedSingleEmsCommandToManageOntNetworkElements;
1622:
1623: ems.SendQueue.Enqueue(command);
1624:
1625: result.AddSuccess(command);
1626: }
1627:
1628: ////////////////////////////////////////////////////////////////////////////
1629: ////////////////////////////////////////////////////////////////////////////
1630:
1631: /// <summary>
1632: ///
1633: /// </summary>
1634: public static void ReadDevList(out Ia.Cl.Model.Result result)
1635: {
1636: string command;
1637:
1638: result = new Ia.Cl.Model.Result();
1639:
1640: var redundantDevList = Ia.Ngn.Cl.Model.Data.Huawei.Dev.RedundantDevList();
1641:
1642: if (redundantDevList.Count == 0)
1643: {
1644: /*
1645: * List DEVs with DT: MA5600T (OLTs) (LST-DEV::DT=249:{ctag}::;)
1646: * List DEVs with DT: MA5603T (OLTs) (LST-DEV::DT=95:{ctag}::;)
1647: * List DEVs with DT: MA5616 (MDUs) (LST-DEV::DT=100:{ctag}::;)
1648: *
1649: * I can't read MA5878 using LST-DEV::DT, I have to use LST-DEV::DEV
1650: * e.g. LST-DEV::DEV=MDU-SAB-1443-001:{ctag}::;
1651: */
1652:
1653: switch (Ia.Cl.Model.Default.Random(99) % 3)
1654: {
1655: case 0: command = Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadDevListByDt(ems, "MA5600T"); break;
1656: case 1: command = Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadDevListByDt(ems, "MA5603T"); break;
1657: case 2: command = Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadDevListByDt(ems, "MA5616"); ; break;
1658: default: command = string.Empty; break;
1659: }
1660:
1661: // delay to prevent mixing of next command output with this long LST-DEV command
1662: Ia.Ngn.Cl.Model.Business.Huawei.Nce.DelaySendQueue(10);
1663:
1664: result.AddSuccess("Reading Devs with devTypes: " + command);
1665: }
1666: else
1667: {
1668: throw new Exception("ReadDevList(): redundantDevList.Count != 0 there are duplicate names in EmsDev");
1669: }
1670: }
1671:
1672: ////////////////////////////////////////////////////////////////////////////
1673:
1674: /// <summary>
1675: ///
1676: /// </summary>
1677: public static void SequentiallyReadBoardListForDevAndOntListForMduDev(out Ia.Cl.Model.Result result)
1678: {
1679: result = new Ia.Cl.Model.Result();
1680:
1681: var dev = Ia.Ngn.Cl.Model.Business.Huawei.Dev.SequentialEmsDevListItem(out _, out string progressCounterString);
1682:
1683: if (dev != null)
1684: {
1685: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadBoardList(ems, dev.DEV);
1686:
1687: if (dev.Type == Ia.Ngn.Cl.Model.Business.Huawei.Dev.Type.Mdu) //&List DEVs with DT: MA5616 (MDUs) (LST-DEV::DT=100:{ctag}::;)
1688: {
1689: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadOntList(ems, dev.DID);
1690: }
1691:
1692: result.AddSuccess("dev: " + dev.DEV + ", " + progressCounterString);
1693: }
1694: else result.AddError("Dev is null.");
1695: }
1696:
1697: ////////////////////////////////////////////////////////////////////////////
1698:
1699: /// <summary>
1700: ///
1701: /// </summary>
1702: public static void SequentiallyReadPortListForBoard(out Ia.Cl.Model.Result result)
1703: {
1704: result = new Ia.Cl.Model.Result();
1705:
1706: var board = Ia.Ngn.Cl.Model.Business.Huawei.Board.SequentialEmsBoardListItem(out _, out string progressCounterString);
1707:
1708: if (board != null)
1709: {
1710: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadPortList(ems, board.EmsDev.DEV, board.FN, board.SN);
1711:
1712: result.AddSuccess("DEV: " + board.EmsDev.DEV + ", SN: " + board.SN + " " + progressCounterString);
1713: }
1714: else result.AddError("Board is null.");
1715: }
1716:
1717: ////////////////////////////////////////////////////////////////////////////
1718:
1719: /// <summary>
1720: ///
1721: /// </summary>
1722: public static void SequentiallyReadPortForMsan(out Ia.Cl.Model.Result result)
1723: {
1724: result = new Ia.Cl.Model.Result();
1725:
1726: var port = Ia.Ngn.Cl.Model.Business.Huawei.Dev.SequentialEmsMsanDevPortListItem(out _, out string progressCounterString);
1727:
1728: if (port != null)
1729: {
1730: Ia.Ngn.Cl.Model.Data.Huawei.Ems.SendReadVoipPstnUser(ems, port.EmsBoard.EmsDev.DEV, port.SN, port.PN);
1731:
1732: result.AddSuccess("DEV: " + port.EmsBoard.EmsDev.DEV + ", SN: " + port.SN + " " + progressCounterString);
1733: }
1734: else result.AddError("port is null.");
1735: }
1736:
1737: ////////////////////////////////////////////////////////////////////////////
1738:
1739: /// <summary>
1740: ///
1741: /// </summary>
1742: public static void DelaySendQueue(int count)
1743: {
1744: if (count > 0)
1745: {
1746: for (var i = 0; i < count; i++)
1747: {
1748: ems.SendQueue.Enqueue(string.Empty);
1749: }
1750: }
1751: }
1752:
1753: ////////////////////////////////////////////////////////////////////////////
1754:
1755: /// <summary>
1756: ///
1757: /// </summary>
1758: public static void DelaySystemIsBusyResendQueue(int count)
1759: {
1760: if (count > 0)
1761: {
1762: for (var i = 0; i < count; i++)
1763: {
1764: ems.SystemIsBusyResendQueue.Enqueue(string.Empty);
1765: }
1766: }
1767: }
1768:
1769: ////////////////////////////////////////////////////////////////////////////
1770:
1771: /// <summary>
1772: ///
1773: /// </summary>
1774: public static void DelaySystemIsBusyResendQueueByEmsKeepAlive(int count)
1775: {
1776: if (count > 0)
1777: {
1778: for (var i = 0; i < count; i++)
1779: {
1780: ems.SystemIsBusyResendQueue.Enqueue(Ia.Ngn.Cl.Model.Business.Huawei.Ems.EmsKeepAliveCommand);
1781: }
1782: }
1783: }
1784:
1785: ////////////////////////////////////////////////////////////////////////////
1786:
1787: /// <summary>
1788: ///
1789: /// </summary>
1790: private static void EvaluateSendReadOntSipInfoCommandAgainAfterNSecondsResendQueue()
1791: {
1792: var nowDataTime = DateTime.UtcNow.AddHours(3);
1793: var commandsToRemoveList = new List<string>();
1794:
1795: foreach (var kvp in ems.OntSipInfoCommandAgainAfterNSecondsToDateTimeDictionary)
1796: {
1797: var dateTime = kvp.Value.AddSeconds(Ia.Ngn.Cl.Model.Business.Huawei.Nce.SendReadOntSipInfoCommandAgainAfterNSeconds);
1798:
1799: if (dateTime < nowDataTime)
1800: {
1801: var command = kvp.Key;
1802:
1803: ems.OntSipInfoCommandAgainAfterNSecondsResendQueue.Enqueue(command);
1804:
1805: commandsToRemoveList.Add(command);
1806: }
1807: }
1808:
1809: foreach (var command in commandsToRemoveList)
1810: {
1811: ems.OntSipInfoCommandAgainAfterNSecondsToDateTimeDictionary.Remove(command);
1812: }
1813: }
1814:
1815: ////////////////////////////////////////////////////////////////////////////
1816:
1817: /// <summary>
1818: ///
1819: /// </summary>
1820: public static void TestService(string service)
1821: {
1822: var list = Ia.Ngn.Cl.Model.Business.Huawei.Ems.EmsCommandsToRetriveOntNetworkElementDataByService(service);
1823:
1824: foreach (string s in list) ems.SendQueue.Enqueue(s);
1825: }
1826:
1827: ////////////////////////////////////////////////////////////////////////////
1828:
1829: /// <summary>
1830: ///
1831: /// </summary>
1832: public static void TestAccess(string accessName)
1833: {
1834: var list = Ia.Ngn.Cl.Model.Business.Huawei.Ems.EmsCommandsToRetriveOntNetworkElementDataByAccessName(accessName);
1835:
1836: foreach (string s in list) ems.SendQueue.Enqueue(s);
1837: }
1838:
1839: ////////////////////////////////////////////////////////////////////////////
1840: ////////////////////////////////////////////////////////////////////////////
1841: }
1842:
1843: ////////////////////////////////////////////////////////////////////////////
1844: ////////////////////////////////////////////////////////////////////////////
1845: }