1: using System;
2: using System.Collections.Generic;
3: using System.Data;
4: using System.Linq;
5: using System.Text;
6:
7: namespace Ia.Ngn.Cl.Model.Ui.Administration
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Administration support class for Optical Fiber Network (OFN) ui model.
13: /// </summary>
14: ///
15: /// <remarks>
16: /// Copyright © 2006-2021 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 EmailStatusReport(string name, string email, out Ia.Cl.Model.Result result)
43: {
44: //bool b;
45: int withinLastNMinutes;
46: string content, subject;
47: DateTime now;
48:
49: withinLastNMinutes = 20;
50: now = DateTime.UtcNow.AddHours(3);
51:
52: // subject can't have \r\n
53: subject = "Daily Optical Fiber Network's Operations Support System (OFN OSS) Status Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
54:
55: content = "Daily Optical Fiber Network's Operations Support System (OFN OSS) Status Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
56: + "\r\n"
57: + "Status:\r\n"
58: + "\r\n"
59: + "\r\n"
60: + "System Monitor:\r\n"
61: + "\r\n"
62: + "System application status within the last " + withinLastNMinutes + " minutes:\r\n"
63: + "\r\n"
64: + "Application name(assembly) active status\r\n"
65: + "\r\n"
66: + Ia.Ngn.Cl.Model.Business.Heartbeat.HearbeatsWithinLastNMinutesTextAsync(withinLastNMinutes).Result + "\r\n"
67: + "\r\n"
68: + "\r\n"
69: + "\r\n"
70:
71: + @"For help send ""help"" in an email." + "\r\n";
72:
73: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
74: }
75:
76: /////////////////////////////////////////////////////////////////////////////////
77:
78: /// <summary>
79: ///
80: /// </summary>
81: public static void EmailListWithOntListProvisionedAndReadyButDoNotExistInCustomerDepartmentDatabaseReport(string name, string email, out Ia.Cl.Model.Result result)
82: {
83: //bool b;
84: string content, subject;
85: DataTable accessDataTable;
86: DateTime now;
87:
88: now = DateTime.UtcNow.AddHours(3);
89:
90: subject = "Table of latest 100 ONTs that are provisioned and ready within NGN access network but do not exist in the Customer Department's database (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
91:
92: accessDataTable = Ia.Ngn.Cl.Model.Ui.Access.ReadListWithOntListProvisionedAndReadyButDoNotExistInCustomerDepartmentDatabaseDataTable(100);
93:
94: content = "Table of latest 100 ONTs that are provisioned and ready within NGN access network but do not exist in the Customer Department's database (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
95:
96: content += "\r\n";
97: content += "\r\n";
98:
99: content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDataTable(accessDataTable);
100:
101: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
102: }
103:
104: /////////////////////////////////////////////////////////////////////////////////
105:
106: /// <summary>
107: ///
108: /// </summary>
109: public static void EmailStatisticReport(string name, string email, out Ia.Cl.Model.Result result)
110: {
111: //bool b;
112: string subject;
113: StringBuilder stringBuilder;
114: DateTime now;
115: List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site> siteList;
116: List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> serviceList;
117:
118: now = DateTime.UtcNow.AddHours(3);
119: stringBuilder = new StringBuilder();
120:
121: subject = "Statistics of Site, Access, and Service usage within the Optical Fiber Network's Operations Support System (OFN OSS) (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
122:
123: siteList = Ia.Ngn.Cl.Model.Data.Administration.SiteStatistic();
124: serviceList = Ia.Ngn.Cl.Model.Data.Administration.ServiceAccessStatisticWithinKuwaitNgnArea();
125:
126: stringBuilder.AppendLine("Statistics of Site, Access, and Service usage within the Optical Fiber Network's Operations Support System (OFN OSS) (" + now.ToString("yyyy-MM-dd HH:mm") + ")");
127:
128: stringBuilder.AppendLine();
129: stringBuilder.AppendLine("============================================================");
130:
131: foreach (var s in siteList)
132: {
133: stringBuilder.AppendLine(s.ToSimpleTextString());
134: }
135:
136: stringBuilder.AppendLine("============================================================");
137:
138: foreach (var s in serviceList)
139: {
140: stringBuilder.AppendLine(s.ToSimpleTextString());
141: }
142:
143: stringBuilder.AppendLine();
144:
145: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, stringBuilder.ToString(), out result);
146: }
147:
148: /////////////////////////////////////////////////////////////////////////////////
149:
150: /// <summary>
151: ///
152: /// </summary>
153: public static void EmailListOfNumberOfAgcfGatewayRecordInGroupOfMgcIp(string name, string email, out Ia.Cl.Model.Result result)
154: {
155: string content, subject;
156: Dictionary<string, int> dictionary;
157: DateTime now;
158:
159: now = DateTime.UtcNow.AddHours(3);
160:
161: subject = "List of the number of AGCF gateway records in groups of MGC IP (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
162:
163: dictionary = Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfAgcfGatewayRecordInGroupOfMgcIpDictionary.OrderBy(u => u.Key).ToDictionary(u => u.Key, u => u.Value);
164:
165: content = "List of the number of AGCF gateway records in groups of MGC IP (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
166:
167: content += "\r\n";
168: content += "\r\n";
169:
170: content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDictionary(dictionary);
171:
172: content += "\r\n";
173: content += "Total number of AGCF gateway records: " + dictionary.Sum(u => u.Value) + ". ";
174:
175: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
176: }
177:
178: /////////////////////////////////////////////////////////////////////////////////
179:
180: /// <summary>
181: ///
182: /// </summary>
183: public static void EmailNokiaReport(string name, string email, out Ia.Cl.Model.Result result)
184: {
185: string content, subject;
186: DateTime now;
187: List<string> list;
188: SortedDictionary<string, int> sortedDictionary;
189:
190: now = DateTime.UtcNow.AddHours(3);
191:
192: // subject can't have \r\n
193: subject = "Weekly Optical Fiber Network's Operations Support System (OFN OSS) Nokia Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
194:
195: content = "Weekly Optical Fiber Network's Operations Support System (OFN OSS) Nokia Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
196: + "Status: Normal\r\n";
197:
198: content += "\r\n";
199: content += "\r\n";
200:
201:
202: content += "List of the number of AGCF gateway records in groups of MGC IP: ";
203:
204: content += "\r\n";
205: content += "\r\n";
206:
207: sortedDictionary = new SortedDictionary<string, int>(Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfAgcfGatewayRecordInGroupOfMgcIpDictionary);
208:
209: content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDictionary(sortedDictionary);
210:
211: content += "\r\n";
212: content += "\r\n";
213:
214:
215: content += "List of the number of AGCF gateway records in IMS pairs of MGC IP: ";
216:
217: content += "\r\n";
218: content += "\r\n";
219:
220: foreach (Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicService imsBasicService in Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicServiceList)
221: {
222: content += imsBasicService.MgcIp + ", " + imsBasicService.MgcSecondaryIp + "\t" + (sortedDictionary[imsBasicService.MgcIp] + sortedDictionary[imsBasicService.MgcSecondaryIp]);
223: content += "\r\n";
224: }
225:
226: content += "\r\n";
227: content += "\r\n";
228:
229:
230: content += "Number of Nokia H.248 subscribers per FSDB: ";
231:
232: content += "\r\n";
233: content += "\r\n";
234:
235: list = Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfNokiaH248SubsribersPerFsdb();
236:
237: content += string.Join("\r\n", list.ToArray());
238: content += "\r\n";
239:
240: content += "\r\n";
241: content += "\r\n";
242:
243:
244: content += "Number of Nokia SIP subscribers per FSDB: ";
245:
246: content += "\r\n";
247: content += "\r\n";
248:
249: list = Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfNokiaSipSubsribersPerFsdb();
250:
251: content += string.Join("\r\n", list.ToArray());
252: content += "\r\n";
253:
254: content += "\r\n";
255: content += "\r\n";
256:
257:
258: content += "Service and access name list where subscriber's AlternateOtasRealm group number is not equal to subparties AssocOtasRealm group number: ";
259:
260: content += "\r\n";
261: content += "\r\n";
262:
263: list.Clear();
264:
265: foreach (var s in Ia.Ngn.Cl.Model.Data.Nokia.Ims.ServiceWhereSubscriberAlternateOtasRealmGroupNumberDoesNotEqualSubPartyAssocOtasRealmGroupNumberList())
266: {
267: list.Add(Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(s));
268: }
269:
270: if (list.Count > 0)
271: {
272: content += string.Join("\r\n", list.ToArray());
273: }
274: else content += "None";
275:
276: content += "\r\n";
277:
278: content += "\r\n";
279: content += "\r\n";
280:
281:
282: content += "AGCF gateway records within NDD ONT list with wrong secondary IP: ";
283:
284: content += "\r\n";
285: content += "\r\n";
286:
287: list.Clear();
288:
289: var agcfGatewayRecordsWithinNddOntListWithWrongSecondaryIpList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.AgcfGatewayRecordsWithinNddOntListWithWrongSecondaryIpList();
290:
291: foreach (var w in agcfGatewayRecordsWithinNddOntListWithWrongSecondaryIpList)
292: {
293: list.Add(w.GwId.ToString());
294: }
295:
296: content += string.Join(", ", list.ToArray());
297:
298: content += "\r\n";
299: content += "\r\n";
300: content += "\r\n";
301:
302:
303: content += "SubParties' PrimaryPUIDCPEProfileNumber count distribution: ";
304:
305: content += "\r\n";
306: content += "\r\n";
307:
308: list.Clear();
309:
310: foreach (KeyValuePair<int, int> w in Ia.Ngn.Cl.Model.Data.Nokia.SubParty.PrimaryPuidCpeProfileNumberCountDistributionDictionary)
311: {
312: list.Add(w.Key + "\t" + w.Value);
313: }
314:
315: content += string.Join("\r\n", list.ToArray());
316:
317: content += "\r\n";
318: content += "\r\n";
319:
320:
321: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
322: }
323:
324: /////////////////////////////////////////////////////////////////////////////////
325:
326: /// <summary>
327: ///
328: /// </summary>
329: public static void EmailHuaweiReport(string name, string email, out Ia.Cl.Model.Result result)
330: {
331: string content, subject;
332: DateTime now;
333:
334: now = DateTime.UtcNow.AddHours(3);
335:
336: // subject can't have \r\n
337: subject = "Weekly Optical Fiber Network's Operations Support System (OFN OSS) Huawei Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
338:
339: content = "Weekly Optical Fiber Network's Operations Support System (OFN OSS) Huawei Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
340: + "Status:.\r\n";
341:
342: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
343: }
344:
345: /////////////////////////////////////////////////////////////////////////////////
346:
347: /// <summary>
348: ///
349: /// </summary>
350: public static void EmailListOfPreviouslyPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport(string emailRecipientName, string email, out Ia.Cl.Model.Result result)
351: {
352: EmailListOfPreviouslyPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport(string.Empty, emailRecipientName, email, out result);
353: }
354:
355: /////////////////////////////////////////////////////////////////////////////////
356:
357: /// <summary>
358: ///
359: /// </summary>
360: public static void EmailListOfPreviouslyPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport(string pstnName, string emailRecipientName, string email, out Ia.Cl.Model.Result result)
361: {
362: string title, content, subject;
363: StringBuilder stringBuilder;
364: DateTime now;
365: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
366: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
367:
368: now = DateTime.UtcNow.AddHours(3);
369:
370: var dictionary0 = Ia.Ngn.Cl.Model.Data.Service.ImsServiceToOntAndMsanSiteInAllowedToBeMigratedOltAndDomainDictionary;
371:
372: if (string.IsNullOrEmpty(pstnName))
373: {
374: // all sites
375:
376: dictionary = dictionary0;
377:
378: title = "قائمة بأرقام المقاسم المحلية المرحّلة إلى شبكة الألياف الضوئية والأرقام التي تتبع نطاق المقاسم المحلية وتم تركيبها حديثاً على أجهزة نهايات رقمية أو أمسان";
379:
380: subject = title + " " + now.ToString("yyyy-MM-dd HH:mm");
381:
382: content = title + "\r\n";
383: content += "\r\n";
384: content += "List of local PSTN domain services migrated or provisioned into IMS fiber or IMS MSAN services";
385: content += "\r\n";
386: content += "\r\n";
387: content += now.ToString("yyyy-MM-dd HH:mm");
388:
389: content += "\r\n";
390: content += "\r\n";
391: }
392: else
393: {
394: pstn = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList where s.Name == pstnName select s).Single();
395:
396: dictionary = (from d in dictionary0
397: where d.Value == pstn.Site && pstn.DomainList.Any(u => d.Key.StartsWith(u.ToString()))
398: select d).ToDictionary(u => u.Key, u => u.Value);
399:
400: title = "قائمة بأرقام مقسم " + pstn.ArabicName + " المرحّلة إلى شبكة الألياف الضوئية والأرقام التي تتبع نطاق المقسم وتم تركيبها حديثاً على أجهزة نهايات رقمية أو أمسان";
401:
402: subject = title + " " + now.ToString("yyyy-MM-dd HH:mm");
403:
404: content = title + "\r\n";
405: content += "\r\n";
406: content += "List of " + pstn.Name + " PSTN domain services migrated or provisioned into IMS fiber or IMS MSAN services";
407: content += "\r\n";
408: content += "\r\n";
409: content += now.ToString("yyyy-MM-dd HH:mm");
410:
411: content += "\r\n";
412: content += "\r\n";
413: }
414:
415: stringBuilder = new StringBuilder(dictionary.Count * 64);
416:
417: if (dictionary.Count > 0)
418: {
419: stringBuilder.AppendLine("List count: " + dictionary.Count);
420: stringBuilder.AppendLine(" ");
421:
422: stringBuilder.Append(string.Join(", ", dictionary.Keys));
423: }
424: else
425: {
426: stringBuilder.AppendLine("List count: zero");
427: stringBuilder.AppendLine(" ");
428: }
429:
430: content += stringBuilder.ToString().Trim();
431:
432: content += "\r\n";
433: content += "\r\n";
434:
435: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(emailRecipientName, email, subject, content, out result);
436: }
437:
438: /////////////////////////////////////////////////////////////////////////////////
439: /////////////////////////////////////////////////////////////////////////////////
440:
441: /// <summary>
442: ///
443: /// </summary>
444: public static void StatisticsListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, out string subject, out string content)
445: {
446: string inputType, horizontalRule;
447: StringBuilder stringBuilder;
448: DateTime now;
449:
450: inputType = string.Empty;
451: horizontalRule = " ";
452:
453: now = DateTime.UtcNow.AddHours(3);
454:
455: // subject can't have \r\n
456: subject = string.Empty; // "Optical Fiber Network's Operations Support System (OFN OSS) TNMD list: ";
457:
458: if (Ia.Ngn.Cl.Model.Business.Authority.FrameworkCanReadStatistics(framework))
459: {
460: opcode = opcode.ToLower();
461:
462: StatisticListForTelegramBotApiAndMailSimpleText(opcode, inputType, horizontalRule, out stringBuilder);
463:
464: stringBuilder.AppendLine(horizontalRule);
465: stringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
466: stringBuilder.AppendLine(horizontalRule);
467: stringBuilder.AppendLine();
468:
469: content = stringBuilder.ToString();
470: }
471: else
472: {
473: content = "\r\n";
474: content += "You are not authorized to modify this value. ";
475: content += "\r\n";
476: }
477: }
478:
479: ////////////////////////////////////////////////////////////////////////////
480:
481: /// <summary>
482: ///
483: /// </summary>
484: public static void StatisticListForTelegramBotApiAndMailSimpleText(string opcode, string inputType, string horizontalRule, out StringBuilder contentStringBuilder)
485: {
486: StringBuilder stringBuilder;
487: DateTime now;
488: List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> statisticList;
489:
490: stringBuilder = new StringBuilder();
491: now = DateTime.UtcNow.AddHours(3);
492:
493: //stringBuilder.AppendLine("Optical Fiber Network's Operations Support System (OFN OSS) Find Result: " + now.ToString("yyyy-MM-dd HH:mm"));
494:
495: //stringBuilder.AppendLine(@"Opcode: """ + opcode + @""".");
496: //responseContent += @"Operand: """ + operand + @"""." + "\r\n";
497: //stringBuilder.AppendLine();
498:
499: if (opcode.Contains("statistics"))
500: {
501: statisticList = Ia.Ngn.Cl.Model.Data.Administration.ServiceAccessStatisticWithinKuwaitNgnAreaCachedDaily;
502:
503: if (statisticList != null && statisticList.Count > 0)
504: {
505: stringBuilder.AppendLine(horizontalRule);
506: stringBuilder.AppendLine("Statistics:");
507: stringBuilder.AppendLine();
508: foreach (var s in statisticList) stringBuilder.AppendLine(s.ToSimpleTextString());
509: stringBuilder.AppendLine(horizontalRule);
510: stringBuilder.AppendLine();
511: }
512: else
513: {
514: stringBuilder.AppendLine(horizontalRule);
515: stringBuilder.AppendLine();
516: }
517: }
518: else
519: {
520: stringBuilder.AppendLine(horizontalRule);
521: stringBuilder.AppendLine("Error: opcode: [" + opcode + "] is unrecognized. ");
522: stringBuilder.AppendLine(horizontalRule);
523: stringBuilder.AppendLine();
524: }
525:
526: contentStringBuilder = stringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
527: }
528:
529: ////////////////////////////////////////////////////////////////////////////
530: ////////////////////////////////////////////////////////////////////////////
531: }
532:
533: ////////////////////////////////////////////////////////////////////////////
534: ////////////////////////////////////////////////////////////////////////////
535: }