1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Text.RegularExpressions;
5: using System.Threading.Tasks;
6:
7: namespace Ia.Ngn.Cl.Model.Business.Maintenance
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Default maintenance network information support class for the Optical Fiber Network business model
13: /// </summary>
14: ///
15: /// <remarks>
16: /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
17: ///
18: /// 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
19: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
20: ///
21: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
23: ///
24: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
25: ///
26: /// Copyright notice: This notice may not be removed or altered from any source distribution.
27: /// </remarks>
28: public class Default
29: {
30: ////////////////////////////////////////////////////////////////////////////
31:
32: /// <summary>
33: ///
34: /// </summary>
35: public Default() { }
36:
37: ////////////////////////////////////////////////////////////////////////////
38:
39: /// <summary>
40: ///
41: /// </summary>
42: public static void BulkQueue(string input, out Ia.Cl.Model.Result result)
43: {
44: List<string> list;
45:
46: result = new Ia.Cl.Model.Result();
47:
48: if (!string.IsNullOrEmpty(input))
49: {
50: input = Regex.Replace(input, @"\s+", " "); // to handle any type of space, including newlines
51: input = input.Trim().ToLower();
52:
53: if (input.Length > 0)
54: {
55: list = input.Split(new char[] { ',', ' ' }).ToList();
56:
57: if (list.Count > 0)
58: {
59: Ia.Ngn.Cl.Model.Business.Maintenance.Default.InsertServiceAccessListIntoQueue(list, out result);
60: }
61: else
62: {
63: result.AddError("List is empty. ");
64: }
65: }
66: else
67: {
68: result.AddError("No input was entered. ");
69: }
70: }
71: else
72: {
73: result.AddError("Input is null or empty. ");
74: }
75: }
76:
77: ////////////////////////////////////////////////////////////////////////////
78:
79: /// <summary>
80: ///
81: /// </summary>
82: public static void InsertServiceAccessListIntoQueue(List<string> list, out Ia.Cl.Model.Result result)
83: {
84: string service, accessName;
85: result = new Ia.Cl.Model.Result();
86:
87: foreach (string item in list)
88: {
89: if (!string.IsNullOrEmpty(item))
90: {
91: service = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(item);
92:
93: if (!string.IsNullOrEmpty(service))
94: {
95: if (Ia.Ngn.Cl.Model.Business.Service.ServiceHasEightDigitsAndIsWithinAllowedDomainList(item))
96: {
97: Ia.Ngn.Cl.Model.Data.Msmq.SecretaryApplication.Enqueue(Ia.Ngn.Cl.Model.Business.Msmq.Application.OfnApplication, Ia.Ngn.Cl.Model.Business.Msmq.Process.ReadService, item);
98:
99: result.AddSuccess("The number \"" + item + "\" inserted into queue. ");
100: }
101: else
102: {
103: result.AddWarning("The number \"" + item + "\" does not belong to the network. ");
104: }
105: }
106: else
107: {
108: if (Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.AccessNameIsWithinAllowedOntList(item, out accessName))
109: {
110: Ia.Ngn.Cl.Model.Data.Msmq.SecretaryApplication.Enqueue(Ia.Ngn.Cl.Model.Business.Msmq.Application.OfnApplication, Ia.Ngn.Cl.Model.Business.Msmq.Process.ReadAccess, accessName);
111:
112: result.AddSuccess("The access name \"" + accessName + "\" inserted into queue. ");
113: }
114: else
115: {
116: //result.AddWarning("The access name \"" + item + "\" does not belong to the network. ");
117: result.AddWarning("The number or access name \"" + item + "\" is not recognized or does not belong to the network. ");
118: }
119: }
120: }
121: else
122: {
123:
124: }
125: }
126: }
127:
128: ////////////////////////////////////////////////////////////////////////////
129: ////////////////////////////////////////////////////////////////////////////
130: }
131:
132: ////////////////////////////////////////////////////////////////////////////
133: ////////////////////////////////////////////////////////////////////////////
134: }