1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Runtime.Serialization;
5: using System.Text;
6:
7: namespace Ia.Ngn.Cl.Model.Ui.Maintenance.Report
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Maintenance Report data support class for the Optical Fiber Network ui model
13: /// </summary>
14: ///
15: /// <remarks>
16: /// Copyright © 2017-2018 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: [DataContract(IsReference = true, Namespace = "kw.com.ia.ngn.api", Name = "apiMaintenanceReport")]
29: public class Default
30: {
31: private static List<Ia.Ngn.Cl.Model.Ui.ReportAccessServiceRequest> reportAccessServiceRequestList;
32:
33: /// <summary/>
34: [DataMember(Name = "result")]
35: public Ia.Cl.Model.Result Result { get; set; }
36:
37: /////////////////////////////////////////////////////////////////////////////////
38:
39: /// <summary>
40: ///
41: /// </summary>
42: public static void TnmdListForMail(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, string operand, out string subject, out string content)
43: {
44: string inputType, horizontalRule;
45: StringBuilder stringBuilder;
46: DateTime now;
47:
48: inputType = string.Empty;
49: horizontalRule = "===============================================";
50:
51: now = DateTime.UtcNow.AddHours(3);
52:
53: // subject can't have \r\n
54: subject = "Optical Fiber Network's Operations Support System (OFN OSS) Find Result (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
55: content = string.Empty;
56:
57: if (Ia.Ngn.Cl.Model.Business.Authority.FrameworkCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, framework))
58: {
59: opcode = opcode.ToLower();
60:
61: FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, operand, inputType, horizontalRule, out stringBuilder);
62:
63: stringBuilder.AppendLine(horizontalRule);
64: stringBuilder.AppendLine(@"Help? Send message with ""mail/maintenance/find/help""");
65: stringBuilder.AppendLine(horizontalRule);
66: stringBuilder.AppendLine();
67:
68: content = stringBuilder.ToString();
69: }
70: else
71: {
72: content += "\r\n";
73: content += "You are not authorized to modify this value. ";
74: content += "\r\n";
75: }
76: }
77:
78: /////////////////////////////////////////////////////////////////////////////////
79:
80: /// <summary>
81: ///
82: /// </summary>
83: public static void TnmdListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, out string subject, out string content)
84: {
85: string inputType, horizontalRule;
86: StringBuilder contentStringBuilder;
87: DateTime now;
88:
89: inputType = string.Empty;
90: horizontalRule = " ";
91:
92: now = DateTime.UtcNow.AddHours(3);
93:
94: // subject can't have \r\n
95: subject = string.Empty; // "Optical Fiber Network's Operations Support System (OFN OSS) TNMD list: ";
96:
97: //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
98: //{
99: opcode = opcode.ToLower();
100:
101: FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, string.Empty, inputType, horizontalRule, out contentStringBuilder);
102:
103: contentStringBuilder.AppendLine(horizontalRule);
104: contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
105: contentStringBuilder.AppendLine(horizontalRule);
106: contentStringBuilder.AppendLine();
107:
108: content = contentStringBuilder.ToString();
109: //}
110: //else
111: //{
112: // responseContent += "\r\n";
113: // responseContent += "You are not authorized to modify this value. ";
114: // responseContent += "\r\n";
115: //}
116: }
117:
118: /////////////////////////////////////////////////////////////////////////////////
119:
120: /// <summary>
121: ///
122: /// </summary>
123: public static void FieldListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, string operand, out string subject, out string content)
124: {
125: string inputType, horizontalRule;
126: StringBuilder contentStringBuilder;
127: DateTime now;
128:
129: inputType = string.Empty;
130: horizontalRule = " ";
131:
132: now = DateTime.UtcNow.AddHours(3);
133:
134: // subject can't have \r\n
135: subject = string.Empty; // "Optical Fiber Network's Operations Support System (OFN OSS) Field list: ";
136:
137: //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
138: //{
139: opcode = opcode.ToLower();
140: operand = operand.ToLower();
141:
142: FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, operand, inputType, horizontalRule, out contentStringBuilder);
143:
144: contentStringBuilder.AppendLine(horizontalRule);
145: contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
146: contentStringBuilder.AppendLine(horizontalRule);
147: contentStringBuilder.AppendLine();
148:
149: content = contentStringBuilder.ToString();
150: //}
151: //else
152: //{
153: // responseContent += "\r\n";
154: // responseContent += "You are not authorized to modify this value. ";
155: // responseContent += "\r\n";
156: //}
157: }
158:
159: /////////////////////////////////////////////////////////////////////////////////
160:
161: /// <summary>
162: ///
163: /// </summary>
164: public static void ReportForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, string operand, out string subject, out string content)
165: {
166: string inputType, horizontalRule;
167: StringBuilder contentStringBuilder;
168: DateTime now;
169:
170: inputType = string.Empty;
171: horizontalRule = " ";
172:
173: now = DateTime.UtcNow.AddHours(3);
174:
175: // subject can't have \r\n
176: subject = string.Empty; // "Optical Fiber Network's Operations Support System (OFN OSS) Field list: ";
177:
178: //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
179: //{
180: opcode = opcode.ToLower();
181: operand = operand.ToLower();
182:
183: ReportForTelegramBotApiAndMailSimpleText(framework, opcode, operand, inputType, horizontalRule, out contentStringBuilder);
184:
185: contentStringBuilder.AppendLine(horizontalRule);
186: contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
187: contentStringBuilder.AppendLine(horizontalRule);
188: contentStringBuilder.AppendLine();
189:
190: content = contentStringBuilder.ToString();
191: //}
192: //else
193: //{
194: // responseContent += "\r\n";
195: // responseContent += "You are not authorized to modify this value. ";
196: // responseContent += "\r\n";
197: //}
198: }
199:
200: /////////////////////////////////////////////////////////////////////////////////
201:
202: /// <summary>
203: ///
204: /// </summary>
205: public static void NokiaListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, out string subject, out string content)
206: {
207: string inputType, horizontalRule;
208: StringBuilder contentStringBuilder;
209: DateTime now;
210:
211: inputType = string.Empty;
212: horizontalRule = " ";
213:
214: now = DateTime.UtcNow.AddHours(3);
215:
216: // subject can't have \r\n
217: subject = string.Empty; // "Optical Fiber Network's Operations Support System (OFN OSS) TNMD list: ";
218:
219: //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
220: //{
221: opcode = opcode.ToLower();
222:
223: FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, string.Empty, inputType, horizontalRule, out contentStringBuilder);
224:
225: contentStringBuilder.AppendLine(horizontalRule);
226: contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
227: contentStringBuilder.AppendLine(horizontalRule);
228: contentStringBuilder.AppendLine();
229:
230: content = contentStringBuilder.ToString();
231: //}
232: //else
233: //{
234: // responseContent += "\r\n";
235: // responseContent += "You are not authorized to modify this value. ";
236: // responseContent += "\r\n";
237: //}
238: }
239:
240: /////////////////////////////////////////////////////////////////////////////////
241:
242: /// <summary>
243: ///
244: /// </summary>
245: public static void HuaweiListForTelegramBotApi(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, out string subject, out string content)
246: {
247: string inputType, horizontalRule;
248: StringBuilder contentStringBuilder;
249: DateTime now;
250:
251: inputType = string.Empty;
252: horizontalRule = " ";
253:
254: now = DateTime.UtcNow.AddHours(3);
255:
256: // subject can't have \r\n
257: subject = string.Empty; // "Optical Fiber Network's Operations Support System (OFN OSS) TNMD list: ";
258:
259: //if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
260: //{
261: opcode = opcode.ToLower();
262:
263: FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(framework, opcode, string.Empty, inputType, horizontalRule, out contentStringBuilder);
264:
265: contentStringBuilder.AppendLine(horizontalRule);
266: contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
267: contentStringBuilder.AppendLine(horizontalRule);
268: contentStringBuilder.AppendLine();
269:
270: content = contentStringBuilder.ToString();
271: //}
272: //else
273: //{
274: // responseContent += "\r\n";
275: // responseContent += "You are not authorized to modify this value. ";
276: // responseContent += "\r\n";
277: //}
278: }
279:
280: /////////////////////////////////////////////////////////////////////////////////
281:
282: /// <summary>
283: ///
284: /// </summary>
285: public static void NetworkDesignDocumentForTelegramBotApi(out string subject, out string content)
286: {
287: string horizontalRule;
288: StringBuilder contentStringBuilder;
289: DateTime now;
290:
291: horizontalRule = " ";
292: now = DateTime.UtcNow.AddHours(3);
293:
294: // subject can't have \r\n
295: subject = "Network Design Document (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
296:
297: contentStringBuilder = new StringBuilder();
298:
299: contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Ui.NetworkDesignDocument.StructureToSimpleTextString());
300: contentStringBuilder.AppendLine(horizontalRule);
301: contentStringBuilder.AppendLine();
302:
303: contentStringBuilder.AppendLine(horizontalRule);
304: contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
305: contentStringBuilder.AppendLine(horizontalRule);
306: contentStringBuilder.AppendLine();
307:
308: contentStringBuilder = contentStringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
309:
310: content = contentStringBuilder.ToString();
311: }
312:
313: /////////////////////////////////////////////////////////////////////////////////
314:
315: /// <summary>
316: ///
317: /// </summary>
318: public static void ServiceRequestFromTodayForTelegramBotApi(out string subject, out string content)
319: {
320: string horizontalRule;
321: StringBuilder contentStringBuilder;
322: DateTime now;
323:
324: horizontalRule = " ";
325:
326: contentStringBuilder = new StringBuilder();
327:
328: now = DateTime.UtcNow.AddHours(3);
329:
330: // subject can't have \r\n
331: subject = "Service Requests from Today (" + now.ToString("yyyy-MM-dd HH:mm") + ")";
332:
333: var serviceRequestList = Ia.Ngn.Cl.Model.Data.ServiceRequest.ForRequestDate(now).OrderBy(u => u.Id).ToList();
334:
335: if (serviceRequestList.Count > 0)
336: {
337: if (serviceRequestList != null && serviceRequestList.Count > 0)
338: {
339: foreach (var sr in serviceRequestList) contentStringBuilder.AppendLine(sr.ToSimpleTextString());
340: contentStringBuilder.AppendLine(horizontalRule);
341: contentStringBuilder.AppendLine();
342: }
343: }
344: else
345: {
346: contentStringBuilder.AppendLine(horizontalRule);
347: contentStringBuilder.AppendLine("No results. ");
348: contentStringBuilder.AppendLine();
349: }
350:
351: contentStringBuilder.AppendLine(horizontalRule);
352: contentStringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.NeedHelpSendCommandSlashHelp));
353: contentStringBuilder.AppendLine(horizontalRule);
354: contentStringBuilder.AppendLine();
355:
356: contentStringBuilder = contentStringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
357:
358: content = contentStringBuilder.ToString();
359: }
360:
361: ////////////////////////////////////////////////////////////////////////////
362:
363: /// <summary>
364: ///
365: /// </summary>
366: public static void FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, string operand, string inputType, string horizontalRule, out StringBuilder contentStringBuilder)
367: {
368: List<int> siteIdList;
369: StringBuilder stringBuilder;
370: DateTime now;
371:
372: stringBuilder = new StringBuilder();
373: now = DateTime.UtcNow.AddHours(3);
374:
375: //stringBuilder.AppendLine("Optical Fiber Network's Operations Support System (OFN OSS) Find Result: " + now.ToString("yyyy-MM-dd HH:mm"));
376:
377: //stringBuilder.AppendLine(@"Opcode: """ + opcode + @""".");
378: //responseContent += @"Operand: """ + operand + @"""." + "\r\n";
379: //stringBuilder.AppendLine();
380:
381: if (opcode.Contains("division"))
382: {
383: if (!string.IsNullOrEmpty(operand))
384: {
385: // get the siteId from the site name in operand
386: siteIdList = (from s in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.SiteList where s.Name.ToLower() == operand select s.Id).ToList();
387:
388: if (framework == null || framework != null && framework.Sites.Count > 0 && framework.Sites.Any(u => siteIdList.Contains(u.Id)))
389: {
390: _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Administration.Framework.CustomerServiceSectorSectionDivisionFrameworkAndStaffGuidList(), siteIdList, "Field List:", horizontalRule, ref stringBuilder);
391: }
392: else
393: {
394: stringBuilder.AppendLine(horizontalRule);
395: stringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.FrameworkNotAuthorized));
396: }
397:
398: stringBuilder.AppendLine(horizontalRule);
399: }
400: else
401: {
402: siteIdList = (framework != null && framework.Sites.Count > 0) ? framework.Sites.Select(u => u.Id).ToList() : new List<int>();
403:
404: _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Administration.Framework.CustomerServiceSectorSectionDivisionFrameworkAndStaffGuidList(), siteIdList, "Field List:", horizontalRule, ref stringBuilder);
405: }
406: }
407: else if (opcode.Contains("tnmd000")) // dummy
408: {
409: siteIdList = (framework != null && framework.Sites.Count > 0) ? framework.Sites.Select(u => u.Id).ToList() : new List<int>();
410:
411: _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Administration.Framework.TelephoneNetworkMaintenanceDepartmentFrameworkAndStaffGuidList(), siteIdList, "TNMD List:", horizontalRule, ref stringBuilder);
412: }
413: else if (opcode.Contains("nokia"))
414: {
415: siteIdList = (framework != null && framework.Sites.Count > 0) ? framework.Sites.Select(u => u.Id).ToList() : new List<int>();
416:
417: _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Administration.Framework.NokiaFrameworkAndStaffGuidList(), siteIdList, "Nokia List:", horizontalRule, ref stringBuilder);
418: }
419: else if (opcode.Contains("huawei"))
420: {
421: siteIdList = (framework != null && framework.Sites.Count > 0) ? framework.Sites.Select(u => u.Id).ToList() : new List<int>();
422:
423: _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Administration.Framework.HuaweiFrameworkAndStaffGuidList(), siteIdList, "Huawei List:", horizontalRule, ref stringBuilder);
424: }
425: else
426: {
427: stringBuilder.AppendLine(horizontalRule);
428: stringBuilder.AppendLine("Error: opcode: [" + opcode + "] is unrecognized. ");
429: stringBuilder.AppendLine(horizontalRule);
430: }
431:
432: contentStringBuilder = stringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
433: }
434:
435: ////////////////////////////////////////////////////////////////////////////
436:
437: /// <summary>
438: ///
439: /// </summary>
440: private static void _FieldTnmdSupplierListForTelegramBotApiAndMailSimpleText(List<Guid> frameworkAndStaffGuidList, List<int> siteIdList, string caption, string horizontalRule, ref StringBuilder stringBuilder)
441: {
442: string text;
443:
444: reportAccessServiceRequestList = Ia.Ngn.Cl.Model.Ui.Report.ReportWithReportOpenStatusByUserIdListAndFrameworkIdList(frameworkAndStaffGuidList, siteIdList);
445:
446: stringBuilder.AppendLine(horizontalRule);
447: stringBuilder.AppendLine(caption);
448: stringBuilder.AppendLine();
449:
450: if (reportAccessServiceRequestList != null && reportAccessServiceRequestList.Count > 0)
451: {
452: foreach (var rasr in reportAccessServiceRequestList)
453: {
454: text = rasr.ToSimpleTextString();
455: text = text.Replace("{report}", "/report_");
456:
457: stringBuilder.AppendLine(text);
458: }
459:
460: }
461: else stringBuilder.AppendLine("No records were found. ");
462:
463: stringBuilder.AppendLine(horizontalRule);
464: }
465:
466: ////////////////////////////////////////////////////////////////////////////
467:
468: /// <summary>
469: ///
470: /// </summary>
471: public static void ReportForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string opcode, string operand, string inputType, string horizontalRule, out StringBuilder contentStringBuilder)
472: {
473: StringBuilder stringBuilder;
474: DateTime now;
475:
476: stringBuilder = new StringBuilder();
477: now = DateTime.UtcNow.AddHours(3);
478:
479: if (opcode.Contains("report"))
480: {
481: if (!string.IsNullOrEmpty(operand))
482: {
483: if (framework == null || framework != null && framework.Sites.Count > 0)
484: {
485: _ReportForTelegramBotApiAndMailSimpleText(Ia.Ngn.Cl.Model.Business.Administration.Framework.CustomerServiceSectorSectionDivisionFrameworkAndStaffGuidList(), "Report:", horizontalRule, ref stringBuilder);
486: }
487: else
488: {
489: stringBuilder.AppendLine(horizontalRule);
490: stringBuilder.AppendLine(Ia.Ngn.Cl.Model.Data.Help.Text(Ia.Ngn.Cl.Model.Data.Help.TelegramString.FrameworkNotAuthorized));
491: }
492:
493: stringBuilder.AppendLine(horizontalRule);
494: }
495: else
496: {
497: stringBuilder.AppendLine(horizontalRule);
498: stringBuilder.AppendLine("Error: operand: is null. ");
499: stringBuilder.AppendLine(horizontalRule);
500: }
501: }
502: else
503: {
504: stringBuilder.AppendLine(horizontalRule);
505: stringBuilder.AppendLine("Error: opcode: [" + opcode + "] is unrecognized. ");
506: stringBuilder.AppendLine(horizontalRule);
507: }
508:
509: contentStringBuilder = stringBuilder.Replace(Environment.NewLine + horizontalRule, horizontalRule);
510: }
511:
512: ////////////////////////////////////////////////////////////////////////////
513:
514: /// <summary>
515: ///
516: /// </summary>
517: private static void _ReportForTelegramBotApiAndMailSimpleText(List<Guid> frameworkAndStaffGuidList, string caption, string horizontalRule, ref StringBuilder stringBuilder)
518: {
519: string text;
520:
521: stringBuilder.AppendLine(horizontalRule);
522: stringBuilder.AppendLine(caption);
523: stringBuilder.AppendLine();
524:
525: text = "Hi";
526:
527: stringBuilder.AppendLine(text);
528:
529: stringBuilder.AppendLine(horizontalRule);
530: }
531:
532: ////////////////////////////////////////////////////////////////////////////
533: ////////////////////////////////////////////////////////////////////////////
534: }
535:
536: ////////////////////////////////////////////////////////////////////////////
537: ////////////////////////////////////////////////////////////////////////////
538: }