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
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Administration support class for Next Generation Network (NGN) 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 Administration
29: {
30: ////////////////////////////////////////////////////////////////////////////
31:
32: /// <summary>
33: ///
34: /// </summary>
35: public Administration() { }
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: string content, subject;
46: DateTime now;
47:
48: now = DateTime.UtcNow.AddHours(3);
49:
50: // subject can't have \r\n
51: subject = "Daily Optical Fiber Network (OFN) Status Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
52:
53: content = "Daily Optical Fiber Network (OFN) Status Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
54: + "Status: undefined.\r\n"
55: + @"For help send ""help"" in an email." + "\r\n";
56:
57: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
58: }
59:
60: /////////////////////////////////////////////////////////////////////////////////
61:
62: /// <summary>
63: ///
64: /// </summary>
65: public static void EmailListWithOntListProvisionedAndReadyButDoNotExistInCustomerDepartmentDatabaseReport(string name, string email, out Ia.Cl.Model.Result result)
66: {
67: //bool b;
68: string content, subject;
69: DataTable accessDataTable;
70: DateTime now;
71:
72: now = DateTime.UtcNow.AddHours(3);
73:
74: 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") + ")";
75:
76: accessDataTable = Ia.Ngn.Cl.Model.Ui.Access.ReadListWithOntListProvisionedAndReadyButDoNotExistInCustomerDepartmentDatabaseDataTable(100);
77:
78: 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") + ")";
79:
80: content += "\r\n";
81: content += "\r\n";
82:
83: content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDataTable(accessDataTable);
84:
85: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
86: }
87:
88: /////////////////////////////////////////////////////////////////////////////////
89:
90: /// <summary>
91: ///
92: /// </summary>
93: public static void EmailStatisticReport(string name, string email, out Ia.Cl.Model.Result result)
94: {
95: //bool b;
96: string subject;
97: StringBuilder stringBuilder;
98: DateTime now;
99: List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.Site> siteList;
100: List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> serviceList;
101:
102: now = DateTime.UtcNow.AddHours(3);
103: stringBuilder = new StringBuilder();
104:
105: subject = "Statistics of Site, Access, and Service usage within the Optical Fiber Network (OFN) (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
106:
107: siteList = Ia.Ngn.Cl.Model.Data.Administration.SiteStatistic();
108: serviceList = Ia.Ngn.Cl.Model.Data.Administration.ServiceAccessStatisticWithinKuwaitNgnArea();
109:
110: stringBuilder.AppendLine("Statistics of Site, Access, and Service usage within the Optical Fiber Network (OFN) (" + now.ToString("yyyy-MM-dd HH:mm") + ")");
111:
112: stringBuilder.AppendLine();
113: stringBuilder.AppendLine();
114:
115: foreach (var s in siteList)
116: {
117: stringBuilder.AppendLine();
118: stringBuilder.AppendLine(s.ToSimpleTextString());
119: }
120:
121: stringBuilder.AppendLine();
122: stringBuilder.AppendLine();
123:
124: foreach (var s in serviceList)
125: {
126: stringBuilder.AppendLine();
127: stringBuilder.AppendLine(s.ToSimpleTextString());
128: }
129:
130: stringBuilder.AppendLine();
131: stringBuilder.AppendLine();
132:
133: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, stringBuilder.ToString(), out result);
134: }
135:
136: /////////////////////////////////////////////////////////////////////////////////
137:
138: /// <summary>
139: ///
140: /// </summary>
141: public static void EmailListOfNumberOfAgcfGatewayRecordInGroupOfMgcIp(string name, string email, out Ia.Cl.Model.Result result)
142: {
143: string content, subject;
144: Dictionary<string, int> dictionary;
145: DateTime now;
146:
147: now = DateTime.UtcNow.AddHours(3);
148:
149: subject = "List of the number of AGCF gateway records in groups of MGC IP (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
150:
151: dictionary = Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfAgcfGatewayRecordInGroupOfMgcIpDictionary.OrderBy(u => u.Key).ToDictionary(u => u.Key, u => u.Value);
152:
153: content = "List of the number of AGCF gateway records in groups of MGC IP (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
154:
155: content += "\r\n";
156: content += "\r\n";
157:
158: content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDictionary(dictionary);
159:
160: content += "\r\n";
161: content += "Total number of AGCF gateway records: " + dictionary.Sum(u => u.Value) + ". ";
162:
163: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
164: }
165:
166: /////////////////////////////////////////////////////////////////////////////////
167:
168: /// <summary>
169: ///
170: /// </summary>
171: public static void EmailNokiaReport(string name, string email, out Ia.Cl.Model.Result result)
172: {
173: string content, subject;
174: DateTime now;
175: List<string> list;
176: SortedDictionary<string, int> sortedDictionary;
177:
178: now = DateTime.UtcNow.AddHours(3);
179:
180: // subject can't have \r\n
181: subject = "Weekly Optical Fiber Network (OFN) Nokia Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
182:
183: content = "Weekly Optical Fiber Network (OFN) Nokia Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
184: + "Status: Normal\r\n"
185: + @"Please contact Jasem for any specific data that you may need on a weekly bases." + "\r\n";
186:
187: content += "\r\n";
188: content += "\r\n";
189:
190:
191: content += "List of the number of AGCF gateway records in groups of MGC IP: ";
192:
193: content += "\r\n";
194: content += "\r\n";
195:
196: sortedDictionary = new SortedDictionary<string, int>(Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfAgcfGatewayRecordInGroupOfMgcIpDictionary);
197:
198: content += Ia.Cl.Model.Default.GenerateTabSeparatedTextFromDictionary(sortedDictionary);
199:
200: content += "\r\n";
201: content += "\r\n";
202:
203:
204: content += "List of the number of AGCF gateway records in IMS pairs of MGC IP: ";
205:
206: content += "\r\n";
207: content += "\r\n";
208:
209: foreach (Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicService imsBasicService in Ia.Ngn.Cl.Model.Business.Nokia.Ims.ImsBasicServiceList)
210: {
211: content += imsBasicService.MgcIp + ", " + imsBasicService.MgcSecondaryIp + "\t" + (sortedDictionary[imsBasicService.MgcIp] + sortedDictionary[imsBasicService.MgcSecondaryIp]);
212: content += "\r\n";
213: }
214:
215: content += "\r\n";
216: content += "\r\n";
217:
218:
219: content += "Number of Nokia subscribers per FSDB: ";
220:
221: content += "\r\n";
222: content += "\r\n";
223:
224: list = Ia.Ngn.Cl.Model.Business.Nokia.Ims.NumberOfNokiaSubsribersPerFsdb();
225:
226: content += string.Join("\r\n", list.ToArray());
227: content += "\r\n";
228:
229: content += "\r\n";
230: content += "\r\n";
231:
232:
233: content += "Service and access name list where subscriber's AlternateOtasRealm group number is not equal to subparties AssocOtasRealm group number: ";
234:
235: content += "\r\n";
236: content += "\r\n";
237:
238: list.Clear();
239:
240: foreach (var w in Ia.Ngn.Cl.Model.Data.Nokia.Ims.ServiceWhereSubscriberAlternateOtasRealmGroupNumberDoesNotEqualSubPartyAssocOtasRealmGroupNumberList())
241: {
242: if (w.Access != null)
243: {
244: list.Add(w.Service + ": " + w.Access.Name);
245: }
246: else list.Add(w.Service + ": ");
247: }
248:
249: if (list.Count > 0)
250: {
251: content += string.Join("\r\n", list.ToArray());
252: }
253: else content += "None";
254:
255: content += "\r\n";
256:
257: content += "\r\n";
258: content += "\r\n";
259:
260:
261: content += "AGCF gateway records within NDD ONT list with wrong secondary IP: ";
262:
263: content += "\r\n";
264: content += "\r\n";
265:
266: list.Clear();
267:
268: var agcfGatewayRecordsWithinNddOntListWithWrongSecondaryIpList = Ia.Ngn.Cl.Model.Data.Nokia.Ims.AgcfGatewayRecordsWithinNddOntListWithWrongSecondaryIpList();
269:
270: foreach (var w in agcfGatewayRecordsWithinNddOntListWithWrongSecondaryIpList)
271: {
272: list.Add(w.GwId.ToString());
273: }
274:
275: content += string.Join(", ", list.ToArray());
276:
277: content += "\r\n";
278: content += "\r\n";
279: content += "\r\n";
280:
281:
282: content += "SubParties' PrimaryPUIDCPEProfileNumber count distribution: ";
283:
284: content += "\r\n";
285: content += "\r\n";
286:
287: list.Clear();
288:
289: foreach (KeyValuePair<int, int> w in Ia.Ngn.Cl.Model.Data.Nokia.SubParty.PrimaryPuidCpeProfileNumberCountDistributionDictionary)
290: {
291: list.Add(w.Key + "\t" + w.Value);
292: }
293:
294: content += string.Join("\r\n", list.ToArray());
295:
296: content += "\r\n";
297: content += "\r\n";
298:
299:
300: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
301: }
302:
303: /////////////////////////////////////////////////////////////////////////////////
304:
305: /// <summary>
306: ///
307: /// </summary>
308: public static void EmailHuaweiReport(string name, string email, out Ia.Cl.Model.Result result)
309: {
310: string content, subject;
311: DateTime now;
312:
313: now = DateTime.UtcNow.AddHours(3);
314:
315: // subject can't have \r\n
316: subject = "Weekly Optical Fiber Network (OFN) Huawei Report (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
317:
318: content = "Weekly Optical Fiber Network (OFN) Huawei Report: " + now.ToString("yyyy-MM-dd HH:mm") + "\r\n"
319: + "Status:.\r\n"
320: + @"Please contact Jasem for any specific data that you may need on a weekly bases." + "\r\n";
321:
322: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(name, email, subject, content, out result);
323: }
324:
325: /////////////////////////////////////////////////////////////////////////////////
326:
327: /// <summary>
328: ///
329: /// </summary>
330: public static void EmailListOfPstnToGponMigratedAndProvisionedServiceInAllowedToBeMigratedOltReport(string emailRecipientName, string email, out Ia.Cl.Model.Result result)
331: {
332: EmailListOfPstnToGponMigratedAndProvisionedServiceInAllowedToBeMigratedOltReport(string.Empty, emailRecipientName, email, out result);
333: }
334:
335: /////////////////////////////////////////////////////////////////////////////////
336:
337: /// <summary>
338: ///
339: /// </summary>
340: public static void EmailListOfPstnToGponMigratedAndProvisionedServiceInAllowedToBeMigratedOltReport(string pstnName, string emailRecipientName, string email, out Ia.Cl.Model.Result result)
341: {
342: string content, subject;
343: StringBuilder stringBuilder;
344: DateTime now;
345: Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Pstn pstn;
346: Dictionary<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Site> dictionary;
347:
348: now = DateTime.UtcNow.AddHours(3);
349:
350: var dictionary0 = Ia.Ngn.Cl.Model.Data.Service.GponServiceToOntSiteInAllowedToBeMigratedOltDictionary;
351:
352: if (string.IsNullOrEmpty(pstnName))
353: {
354: // all sites
355:
356: dictionary = dictionary0;
357:
358: subject = "قائمة بالأرقام المرحّلة من النحاس إلى الفايبر، والأرقام المركبة حديثاً في جميع شبكات الفايبر المسموح فيها بترحيل الأرقام";
359: subject += " " + now.ToString("yyyy-MM-dd HH:mm");
360:
361: content = "قائمة بالأرقام المرحّلة من النحاس إلى الفايبر، والأرقام المركبة حديثاً في جميع شبكات الفايبر المسموح فيها بترحيل الأرقام";
362: content += "\r\n";
363: content += "List of PSTN to GPON migrated and provisioned services in allowed to be migrated OLTs";
364: content += "\r\n";
365: content += now.ToString("yyyy-MM-dd HH:mm");
366:
367: content += "\r\n";
368: content += "\r\n";
369: }
370: else
371: {
372: pstn = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.PstnList where s.Name == pstnName select s).Single();
373:
374: dictionary = (from d in dictionary0
375: where d.Value == pstn.Site && pstn.DomainList.Any(u => d.Key.StartsWith(u.ToString()))
376: select d).ToDictionary(u => u.Key, u => u.Value);
377:
378: subject = "قائمة بأرقام مقسم " + pstn.ArabicName + " المرحّلة من النحاس إلى الفايبر، والأرقام المركبة حديثاً في جميع شبكات الفايبر التابعة للمقسم والمسموح فيها بترحيل الأرقام";
379: subject += " " + now.ToString("yyyy-MM-dd HH:mm");
380:
381: content = "قائمة بأرقام مقسم " + pstn.ArabicName + " المرحّلة من النحاس إلى الفايبر، والأرقام المركبة حديثاً في جميع شبكات الفايبر التابعة للمقسم والمسموح فيها بترحيل الأرقام";
382: content += "\r\n";
383: content += "List of " + pstn.Name + " PSTN to GPON migrated and provisioned services in allowed to be migrated OLTs within site";
384: content += "\r\n";
385: content += now.ToString("yyyy-MM-dd HH:mm");
386:
387: content += "\r\n";
388: content += "\r\n";
389: }
390:
391: stringBuilder = new StringBuilder(dictionary.Count * 64);
392:
393: if (dictionary.Count > 0)
394: {
395: stringBuilder.AppendLine("List count: " + dictionary.Count);
396: stringBuilder.AppendLine(" ");
397:
398: /*
399: foreach (KeyValuePair<string, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Vendor> kvp in dictionary)
400: {
401: stringBuilder.Append(kvp.Key + ", ");
402: }
403: */
404:
405: stringBuilder.Append(string.Join(", ", dictionary.Keys));
406: }
407: else
408: {
409: }
410:
411: content += stringBuilder.ToString().Trim();
412:
413: content += "\r\n";
414: content += "\r\n";
415:
416: Ia.Ngn.Cl.Model.Ui.Mail.SendPlainMail(emailRecipientName, email, subject, content, out result);
417: }
418:
419: ////////////////////////////////////////////////////////////////////////////
420: ////////////////////////////////////////////////////////////////////////////
421:
422: /// <summary>
423: ///
424: /// </summary>
425: public static string FrameworkStructureDataTable()
426: {
427: string htmlTable;
428: List<Ia.Ngn.Cl.Model.Business.Administration.Framework> frameworkList;
429:
430: frameworkList = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList where f.Type == "ministry" || f.Type == "supplier" select f).ToList();
431:
432: htmlTable = @"<div id=""framework-structure"">";
433:
434: foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework framework in frameworkList)
435: {
436: htmlTable += FrameworkStructureDataTableIteration(framework);
437: }
438:
439: htmlTable += "</div>";
440:
441: return htmlTable;
442: }
443:
444: ////////////////////////////////////////////////////////////////////////////
445:
446: /// <summary>
447: ///
448: /// </summary>
449: private static string FrameworkStructureDataTableIteration(Ia.Ngn.Cl.Model.Business.Administration.Framework framework)
450: {
451: string htmlTable;
452: Ia.Ngn.Cl.Model.Staff headStaff;
453: List<Ia.Ngn.Cl.Model.Staff> staffList;
454:
455: htmlTable = null;
456:
457: if (framework != null)
458: {
459: headStaff = (from s in Ia.Ngn.Cl.Model.Data.Staff.List where s.Framework != null && s.Framework.Id == framework.Id && s.IsHead select s).SingleOrDefault();
460:
461: htmlTable = "<table>";
462:
463: if (framework.Children != null && framework.Children.Count > 0)
464: {
465: htmlTable += "<tr>";
466:
467: htmlTable += @"<td class=""" + framework.Type + @""" colspan=""" + framework.Children.Count + @""">" + framework.ArabicName;
468: if (headStaff != null) htmlTable += @"<span class=""head"">" + headStaff.FirstAndMiddleName + "</span>";
469: htmlTable += @"</td>";
470:
471: htmlTable += "</tr>";
472:
473: htmlTable += "<tr>";
474:
475: foreach (Ia.Ngn.Cl.Model.Business.Administration.Framework f in framework.Children)
476: {
477: htmlTable += @"<td class=""" + f.Type + @""">" + FrameworkStructureDataTableIteration(f) + "</td>";
478: }
479:
480: htmlTable += "</tr>";
481: }
482: else
483: {
484: staffList = (from s in Ia.Ngn.Cl.Model.Data.Staff.List where s.Framework != null && s.Framework.Id == framework.Id && !s.IsHead select s).ToList();
485:
486: htmlTable += "<tr>";
487:
488: htmlTable += @"<td class=""" + framework.Type + @""">" + framework.ArabicName;
489: if (headStaff != null) htmlTable += @"<span class=""head"">" + headStaff.FirstAndMiddleName + "</span>";
490:
491: foreach (Ia.Ngn.Cl.Model.Staff staff in staffList)
492: {
493: htmlTable += @"<span class=""staff"">" + staff.FirstAndMiddleName + "</span>";
494: }
495:
496: htmlTable += @"</td>";
497:
498: htmlTable += "</tr>";
499: }
500:
501: htmlTable += "</table>";
502: }
503:
504: return htmlTable;
505: }
506:
507: /////////////////////////////////////////////////////////////////////////////////
508: /////////////////////////////////////////////////////////////////////////////////
509:
510: /// <summary>
511: ///
512: /// </summary>
513: public static void StatisticsListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, out string subject, out string content)
514: {
515: string inputType, horizontalRule;
516: StringBuilder stringBuilder;
517: DateTime now;
518:
519: inputType = string.Empty;
520: horizontalRule = " ";
521:
522: now = DateTime.UtcNow.AddHours(3);
523:
524: // subject can't have \r\n
525: subject = string.Empty; // "Optical Fiber Network (OFN) TNMD list: ";
526:
527: if (Ia.Ngn.Cl.Model.Business.Authority.FrameworkCanReadStatistics(framework))
528: {
529: opcode = opcode.ToLower();
530:
531: StatisticListForTelegramBotApiAndMailSimpleText(opcode, inputType, horizontalRule, out stringBuilder);
532:
533: stringBuilder.AppendLine(horizontalRule);
534: stringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
535: stringBuilder.AppendLine(horizontalRule);
536: stringBuilder.AppendLine();
537:
538: content = stringBuilder.ToString();
539: }
540: else
541: {
542: content = "\r\n";
543: content += "You are not authorized to modify this value. ";
544: content += "\r\n";
545: }
546: }
547:
548: ////////////////////////////////////////////////////////////////////////////
549:
550: /// <summary>
551: ///
552: /// </summary>
553: public static void StatisticListForTelegramBotApiAndMailSimpleText(string opcode, string inputType, string horizontalRule, out StringBuilder contentStringBuilder)
554: {
555: StringBuilder stringBuilder;
556: DateTime now;
557: List<Ia.Ngn.Cl.Model.Business.Administration.Statistic.KuwaitArea> statisticList;
558:
559: stringBuilder = new StringBuilder();
560: now = DateTime.UtcNow.AddHours(3);
561:
562: //stringBuilder.AppendLine("Optical Fiber Network (OFN) Find Result: " + now.ToString("yyyy-MM-dd HH:mm"));
563:
564: //stringBuilder.AppendLine(@"Opcode: """ + opcode + @""".");
565: //responseContent += @"Operand: """ + operand + @"""." + "\r\n";
566: //stringBuilder.AppendLine();
567:
568: if (opcode.Contains("statistics"))
569: {
570: statisticList = Ia.Ngn.Cl.Model.Data.Administration.ServiceAccessStatisticWithinKuwaitNgnAreaCachedDaily;
571:
572: if (statisticList != null && statisticList.Count > 0)
573: {
574: stringBuilder.AppendLine(horizontalRule);
575: stringBuilder.AppendLine("Statistics:");
576: stringBuilder.AppendLine();
577: foreach (var s in statisticList) stringBuilder.AppendLine(s.ToSimpleTextString());
578: stringBuilder.AppendLine(horizontalRule);
579: stringBuilder.AppendLine();
580: }
581: else
582: {
583: stringBuilder.AppendLine(horizontalRule);
584: stringBuilder.AppendLine();
585: }
586: }
587: else
588: {
589: stringBuilder.AppendLine(horizontalRule);
590: stringBuilder.AppendLine("Error: opcode: [" + opcode + "] is unrecognized. ");
591: stringBuilder.AppendLine(horizontalRule);
592: stringBuilder.AppendLine();
593: }
594:
595: contentStringBuilder = stringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
596: }
597:
598: ////////////////////////////////////////////////////////////////////////////
599: ////////////////////////////////////////////////////////////////////////////
600: }
601:
602: ////////////////////////////////////////////////////////////////////////////
603: ////////////////////////////////////////////////////////////////////////////
604: }