1: using System;
2: using System.Collections.Generic;
3: using System.Data;
4: using System.Linq;
5: using System.Web.Security;
6:
7: namespace Ia.Ngn.Cl.Model.Business
8: {
9: ////////////////////////////////////////////////////////////////////////////
10:
11: /// <summary publish="true">
12: /// Authority support class of Optical Fiber Network (OFN) business model.
13: /// </summary>
14: ///
15: /// <remarks>
16: /// Copyright © 2006-2020 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 Authority
29: {
30: public enum SchedularFunction
31: {
32: ListOfPreviouslyPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport = 1,
33: ListOfPreviouslyQrnPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport,
34: ListOfPreviouslyJblPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport,
35: ListOfPreviouslySsbPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport,
36: ListOfPreviouslySlmaPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport,
37: ListOfPreviouslySlmbPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport,
38: ListOfPreviouslyMsfPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport,
39: ListOfPreviouslyFhhPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport,
40: StatusReport,
41: StatisticsReport,
42: NokiaReport,
43: HuaweiReport,
44: Maintenance,
45: Heartbeat,
46: };
47:
48: public enum PersistentStorageFunction { Create = 1, Read, Update, Delete };
49:
50: /// <summary/>
51: public int Id { get; set; }
52:
53: /// <summary/>
54: public string Name { get; set; }
55:
56: /// <summary/>
57: public string ArabicName { get; set; }
58:
59: /// <summary/>
60: public string AllowedFrameworkArabicName { get; set; }
61:
62: /// <summary/>
63: public bool HeadOnly { get; set; }
64:
65: /// <summary/>
66: public string Medium { get; set; }
67:
68: /// <summary/>
69: public string System { get; set; }
70:
71: /// <summary/>
72: public string Process { get; set; }
73:
74: /// <summary/>
75: public string Function { get; set; }
76:
77: /// <summary/>
78: public string ParameterRegex { get; set; }
79:
80: /// <summary/>
81: public string ResponseRegex { get; set; }
82:
83: /// <summary/>
84: public string Help { get; set; }
85:
86: ////////////////////////////////////////////////////////////////////////////
87:
88: /// <summary>
89: ///
90: /// </summary>
91: public Authority() { }
92:
93: ////////////////////////////////////////////////////////////////////////////
94:
95: /// <summary>
96: ///
97: /// </summary>
98: public int AuthorityId(int parentId, int authorityId)
99: {
100: return parentId * 10 + authorityId;
101: }
102:
103: ////////////////////////////////////////////////////////////////////////////
104:
105: /// <summary>
106: ///
107: /// </summary>
108: public int ParentId(long authorityId)
109: {
110: int i;
111: string s;
112:
113: s = authorityId.ToString();
114:
115: if (s.Length > 2)
116: {
117: s = s.Substring(0, s.Length - 2);
118:
119: i = (int.TryParse(s, out i)) ? i : 0;
120: }
121: else i = 0;
122:
123: return i;
124: }
125:
126: ////////////////////////////////////////////////////////////////////////////
127:
128: /// <summary>
129: ///
130: /// </summary>
131: public static List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework> StaffFrameworkListOfAllowedReportAssignsByStaff(Ia.Ngn.Cl.Model.Report report, Ia.Ngn.Cl.Model.Staff staff)
132: {
133: List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework> frameworkList, specialList, special2List, special3List, special4List, list;
134:
135: var staffList = new List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework>();
136: var staffHead = new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework();
137:
138: if (staff.Head != null) staffHead = new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
139: {
140: Guid = staff.Head.UserId,
141: IsStaff = true,
142: Name = staff.Head.FirstAndMiddleNameBracketFrameworkArabicNameAndFrameworkParentArabicNameBracket
143: };
144:
145: var subordinatesList = (from s in staff.Subordinates
146: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
147: {
148: Guid = s.UserId,
149: IsStaff = true,
150: Name = s.FirstAndMiddleNameBracketFrameworkArabicNameAndFrameworkParentArabicNameBracket
151: }).ToList();
152:
153: var colleagueList = (from s in staff.Colleagues
154: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
155: {
156: Guid = s.UserId,
157: IsStaff = true,
158: Name = s.FirstAndMiddleNameBracketFrameworkArabicNameAndFrameworkParentArabicNameBracket
159: }).ToList();
160:
161: staffList.Add(staffHead);
162: staffList = staffList.Union(subordinatesList).Union(colleagueList).ToList();
163:
164:
165: // framework list: framework descendants, siblings and uncles (for head staff only)
166: if (staff.Framework.Parent != null)
167: {
168: if (staff.IsHead)
169: {
170: frameworkList = (from f in staff.Framework.Siblings.Union(staff.Framework.Descendants).Union(staff.Framework.Parent.Siblings).Concat(new[] { staff.Framework.Parent })
171: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
172: {
173: Guid = f.Guid,
174: IsFramework = true,
175: Name = f.FullyQualifiedArabicName //.ArabicName
176: }
177: ).OrderBy(c => c.Guid).ToList();
178: }
179: else
180: {
181: frameworkList = (from f in staff.Framework.Siblings.Union(staff.Framework.Descendants).Concat(new[] { staff.Framework.Parent })
182: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
183: {
184: Guid = f.Guid,
185: IsFramework = true,
186: Name = f.FullyQualifiedArabicName //.ArabicName
187: }
188: ).OrderBy(c => c.Guid).ToList();
189: }
190: }
191: else
192: {
193: frameworkList = (from f in staff.Framework.Descendants
194: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
195: {
196: Guid = f.Guid,
197: IsFramework = true,
198: Name = f.FullyQualifiedArabicName //.ArabicName
199: }
200: ).OrderBy(c => c.Guid).ToList();
201: }
202:
203: // special list: list of special administrative assignments to certain staff and frameworks
204: if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة" || staff.Framework.ArabicName == "قسم تشغيل الخدمات")
205: {
206: specialList = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList
207: where
208: f.FullyQualifiedArabicName == "وزارة الإتصالات وتكنولوجيا المعلومات | قطاع الاتصالات والخدمات المساندة | إدارة صيانة الشبكة الهاتفية | مراقبة الصيانة | قسم الصيانة"
209: || f.FullyQualifiedArabicName == "نوكيا"
210: || f.FullyQualifiedArabicName == "هواوي"
211: || f.FullyQualifiedArabicName == "التطبيقات المتكاملة"
212: || f.FullyQualifiedArabicName.Contains("وزارة الإتصالات وتكنولوجيا المعلومات | قطاع الاتصالات والخدمات المساندة | إدارة شبكة الألياف الضوئية")
213: || (f.FullyQualifiedArabicName.Contains("قسم الصيانة وتركيبات الهاتف") && f.FullyQualifiedArabicName.Contains("وزارة الإتصالات وتكنولوجيا المعلومات | قطاع خدمات المشتركين"))
214: || (f.FullyQualifiedArabicName.Contains("قسم الفحص والشكاوى") && f.FullyQualifiedArabicName.Contains("وزارة الإتصالات وتكنولوجيا المعلومات | قطاع خدمات المشتركين"))
215: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
216: {
217: Guid = f.Guid,
218: IsFramework = true,
219: Name = f.FullyQualifiedArabicName //.ArabicName
220: }
221: ).OrderBy(c => c.Guid).ToList();
222: }
223: else if (staff.Framework.FullyQualifiedArabicName.Contains("وزارة الإتصالات وتكنولوجيا المعلومات | قطاع خدمات المشتركين"))
224: {
225: // قطاع خدمات المشتركين need to assign to قسم الدعم الفني للشبك
226: specialList = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList
227: where f.ArabicName == "قسم الدعم الفني للشبكة" || f.ArabicName == "قسم تشغيل الخدمات"
228: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
229: {
230: Guid = f.Guid,
231: IsFramework = true,
232: Name = f.FullyQualifiedArabicName //.ArabicName
233: }
234: ).OrderBy(c => c.Guid).ToList();
235: }
236: else
237: {
238: specialList = new List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework>();
239: }
240:
241: // special: ability to assign to report creator
242: special2List = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList
243: join s in Ia.Ngn.Cl.Model.Data.Staff.List on f.Id equals s.Framework.Id
244: where s.UserId == report.UserId
245: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
246: {
247: Guid = f.Guid,
248: IsFramework = true,
249: Name = f.FullyQualifiedArabicName //.ArabicName
250: }
251: ).OrderBy(c => c.Guid).ToList();
252:
253: // list of all staff members already report history excluding self
254: if (report.ReportHistories != null && report.ReportHistories.Count > 0)
255: {
256: special3List = (from s in Ia.Ngn.Cl.Model.Data.Staff.List
257: where (report.ReportHistories.Any(u => u.UserId == s.UserId)) && staff.UserId != s.UserId
258: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
259: {
260: Guid = s.UserId,
261: IsStaff = true,
262: Name = s.FirstAndMiddleNameBracketFrameworkArabicNameAndFrameworkParentArabicNameBracket
263: }
264: ).OrderBy(c => c.Guid).ToList();
265: }
266: else
267: {
268: special3List = new List<Ia.Ngn.Cl.Model.Business.Administration.StaffFramework>();
269: }
270:
271: // list of staff member who created report excluding self
272: special4List = (from s in Ia.Ngn.Cl.Model.Data.Staff.List
273: where report.UserId == s.UserId && staff.UserId != s.UserId
274: select new Ia.Ngn.Cl.Model.Business.Administration.StaffFramework
275: {
276: Guid = s.UserId,
277: IsStaff = true,
278: Name = s.FirstAndMiddleNameBracketFrameworkArabicNameAndFrameworkParentArabicNameBracket
279: }
280: ).OrderBy(c => c.Guid).ToList();
281:
282: list = staffList.Union(frameworkList).Union(specialList).Union(special2List).Union(special3List).Union(special4List).ToList();
283:
284: list = list.GroupBy(u => u.Guid).Select(u => u.FirstOrDefault()).ToList(); // returns distinct records
285:
286: list = list.Where(u => u.Guid != Guid.Empty).ToList();
287:
288: return list.OrderBy(c => c.IsFramework).ToList();
289: }
290:
291: ////////////////////////////////////////////////////////////////////////////
292:
293: /// <summary>
294: ///
295: /// </summary>
296: public static bool StaffCanCreateReadUpdateDeleteReport(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction persistentStorageFunction, Ia.Ngn.Cl.Model.Report report, Ia.Ngn.Cl.Model.Staff staff)
297: {
298: bool isAllowed;
299:
300: if (staff != null)
301: {
302: if (StaffIsSuperUser(staff)) isAllowed = true;
303: else
304: {
305: if (persistentStorageFunction == PersistentStorageFunction.Delete)
306: {
307: /*
308: // below: a report can only be deleted by:
309: // - one of the heads of the reporter.
310: // - the reporter if he is a head
311:
312: if (report.LastReportHistory == null && staff.UserId == report.UserId && staff.IsHead) isAllowed = true;
313: else if (report.LastReportHistory != null && staff.UserId == report.LastReportHistory.UserId && staff.IsHead) isAllowed = true;
314: else if (report.LastReportHistory == null && staff.IsHead) isAllowed = true;
315: else if (staff.Subordinates != null)
316: {
317: if (report.LastReportHistory != null) isAllowed = staff.Subordinates.Any(i => i.UserId == report.LastReportHistory.UserId);
318: else isAllowed = staff.Subordinates.Any(i => i.UserId == report.UserId);
319: }
320: else isAllowed = false;
321: */
322:
323: isAllowed = false; // reports can't be deleted by staff other than super user
324: }
325: else
326: {
327: /*
328: // below: a report can be CRUD if
329: // - last report does not exist
330: // - last report exists and its UserId is same as staffs
331: // - report owner is subordinate of staff
332: // - report framework is within users frameworks
333:
334: if (report.ReportHistories.Count == 0)
335: {
336: isAllowed = report.LastReportHistory.UserId == staff.UserId || staff.Subordinates != null && staff.Subordinates.Any(i => i.UserId == report.LastReportHistory.UserId);
337:
338: if (Ia.Ngn.Cl.Model.Business.Administration.IsFrameworkGuid(report.LastReportHistory.UserId))
339: {
340: isAllowed = staff.Framework.Guid == report.LastReportHistory.UserId
341: || staff.Framework.Descendants != null && staff.Framework.Descendants.Any(i => i.Guid == report.LastReportHistory.UserId);
342: }
343: }
344: else
345: {
346: isAllowed = true; // report.UserId == staff.UserId || staff.Subordinates != null && staff.Subordinates.Any(i => i.UserId == report.UserId);
347:
348: / *
349: if (Ia.Ngn.Cl.Model.Business.Administration.IsFrameworkGuid(report.UserId))
350: {
351: isAllowed = staff.Framework.Guid == report.UserId
352: || staff.Framework.Descendants != null && staff.Framework.Descendants.Any(i => i.Guid == report.UserId);
353: }
354: * /
355: }
356: */
357:
358: isAllowed = false; // undefined CRU
359: }
360: }
361: }
362: else isAllowed = false;
363:
364: return isAllowed;
365: }
366:
367: ////////////////////////////////////////////////////////////////////////////
368:
369: /// <summary>
370: ///
371: /// </summary>
372: public static bool StaffCanSendFieldTnmdSupplierWorkorderEmail(Ia.Ngn.Cl.Model.Staff staff)
373: {
374: bool isAllowed;
375:
376: if (staff != null)
377: {
378: if (staff.IsHead) isAllowed = true;
379: else if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
380: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
381: else isAllowed = false;
382: }
383: else isAllowed = false;
384:
385: return isAllowed;
386: }
387:
388: ////////////////////////////////////////////////////////////////////////////
389:
390: /// <summary>
391: ///
392: /// </summary>
393: public static bool StaffCanCreateReadUpdateDeleteReportHistory(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Report report, Ia.Ngn.Cl.Model.ReportHistory reportHistory, Ia.Ngn.Cl.Model.Staff staff)
394: {
395: // below: I have to pass both Report and ReportHistory objects separately
396:
397: bool isAllowed;
398:
399: if (staff != null)
400: {
401: if (StaffIsSuperUser(staff)) isAllowed = true;
402: else
403: {
404: if (function == PersistentStorageFunction.Delete)
405: {
406: // below: a report history can only be deleted by:
407: // - one of the heads of the history user
408: // - the history user if he is a head
409:
410: /*
411: if (reportHistory != null)
412: {
413: if (reportHistory.Report.ReportHistories.Max(r => r.Id) != reportHistory.Id) isAllowed = false;
414: else
415: {
416: if (staff.UserId == reportHistory.UserId && staff.IsHead) isAllowed = true;
417: else if (staff.Subordinates != null) isAllowed = staff.Subordinates.Any(i => i.UserId == reportHistory.UserId);
418: else isAllowed = false;
419: }
420: }
421: else isAllowed = false;
422: */
423:
424: isAllowed = false; // report history can't be deleted by staff other than super user
425: }
426: else if (function == PersistentStorageFunction.Create)
427: {
428: // below: for create reportHistory must be null
429:
430: // below: a report history can be created if:
431: // - report userid is subordinate of staff
432: // - report history userid framework is within staff frameworks
433:
434: if (staff.IsHead && staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
435: else if (staff.IsHead && staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
436: else if (report != null && reportHistory == null)
437: {
438: if (report.ReportHistories.Count == 0 && staff.UserId == report.UserId) isAllowed = true;
439: else if (report.ReportHistories.Count == 0 && report.StatusIsOpen) isAllowed = true;
440:
441: //else if (report.LastReportHistory != null && !staff.Colleagues.Any(r => r.UserId == report.LastReportHistory.UserId) && staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true; // temp
442:
443: else if (report.LastReportHistory != null && staff.SubordinatesOrSelf.Any(i => i.UserId == report.LastReportHistory.UserId)) isAllowed = true;
444: else if (Ia.Ngn.Cl.Model.Business.Administration.IsFrameworkGuid(report.UserId) && staff.Framework.DescendantsOrSelf.Any(u => u.Guid == report.UserId)) isAllowed = true;
445: else if (Ia.Ngn.Cl.Model.Business.Administration.IsFrameworkGuid(report.LastReportHistory.UserId) && report.LastReportHistory != null && (staff.Framework.DescendantsOrSelf.Any(u => u.Guid == report.LastReportHistory.UserId) || staff.Framework.Ancestors.Any(u => u.Guid == report.LastReportHistory.UserId))) isAllowed = true;
446: else isAllowed = false;
447: }
448: else isAllowed = false;
449: }
450: else
451: {
452: // below: a report history can be read, and updated if:
453: // - report history UserId is same as staff's
454: // - report userid is subordinate of staff
455: // - report history userid framework is within staff frameworks
456:
457: if (staff.IsHead && staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
458: else if (staff.IsHead && staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
459: else if (reportHistory != null)
460: {
461: if (staff.UserId == reportHistory.UserId) isAllowed = true;
462: else if (staff.Subordinates.Any(u => u.UserId == reportHistory.UserId)) isAllowed = true;
463: else if (Ia.Ngn.Cl.Model.Business.Administration.IsFrameworkGuid(reportHistory.UserId))
464: {
465: if (staff.Framework.DescendantsOrSelf.Any(u => u.Guid == reportHistory.UserId)) isAllowed = true;
466: else isAllowed = false;
467: }
468: else isAllowed = false;
469: }
470: else isAllowed = false;
471: }
472: }
473: }
474: else isAllowed = false;
475:
476: return isAllowed;
477: }
478:
479: ////////////////////////////////////////////////////////////////////////////
480:
481: /// <summary>
482: ///
483: /// </summary>
484: public static bool StaffCanReopenClosedReport(Ia.Ngn.Cl.Model.Report report, Ia.Ngn.Cl.Model.Staff staff)
485: {
486: return StaffCanCloseReport(report, staff);
487: }
488:
489: ////////////////////////////////////////////////////////////////////////////
490:
491: /// <summary>
492: ///
493: /// </summary>
494: public static bool StaffCanCloseReport(Ia.Ngn.Cl.Model.Report report, Ia.Ngn.Cl.Model.Staff staff)
495: {
496: bool canClose;
497:
498: if (staff != null)
499: {
500: if (StaffIsSuperUser(staff)) canClose = true;
501: //else if (FrameworkCanCloseReport(staff.Framework)) canClose = true; // make dedicated users to check with subscribers if reports are resolved
502: else
503: {
504: if (report.LastReportHistory != null)
505: {
506: if (staff.IsHead)
507: {
508: if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") canClose = true;
509: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات") canClose = true;
510: else if (staff.UserId == report.UserId) canClose = true; // the report closer staff is himself
511: else if (
512: (staff.Framework.AncestorsOrSelf.Any(u => u.ArabicName == "قسم الفحص والشكاوى") || staff.Framework.AncestorsOrSelf.Any(u => u.ArabicName == "قسم الصيانة وتركيبات الهاتف"))
513: && staff.Framework.AncestorsOrSelf.Any(u => u.ArabicName == "قطاع خدمات المشتركين")
514: && (staff.SubordinatesOrSelf.Any(u => u.UserId == report.UserId)))
515: canClose = true;
516: else if (staff.Subordinates.Any(u => u.UserId == report.LastReportHistory.UserId)) canClose = true; // the report history closer staff is himself or a head
517: else canClose = false;
518: }
519: else canClose = false;
520: }
521: else canClose = false;
522: }
523: }
524: else canClose = false;
525:
526: return canClose;
527: }
528:
529: ////////////////////////////////////////////////////////////////////////////
530:
531: /// <summary>
532: ///
533: /// </summary>
534: public static bool StaffCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Staff staff)
535: {
536: bool isAllowed;
537:
538: if (staff != null)
539: {
540: if (function == PersistentStorageFunction.Create || function == PersistentStorageFunction.Read)
541: {
542: if (StaffIsSuperUser(staff)) isAllowed = true;
543: else if (staff.Framework.ArabicName == "قسم الخطوط الطرفية") isAllowed = true;
544: else if (staff.Framework.ArabicName == "نوكيا") isAllowed = true;
545: else if (staff.Framework.ArabicName == "هواوي") isAllowed = true;
546: else isAllowed = false;
547: }
548: else if (function == PersistentStorageFunction.Update)
549: {
550: if (StaffIsSuperUser(staff)) isAllowed = true;
551: else if (staff.Framework.ArabicName == "قسم الخطوط الطرفية") isAllowed = true;
552: else isAllowed = false;
553: }
554: else if (function == PersistentStorageFunction.Delete)
555: {
556: if (StaffIsSuperUser(staff)) isAllowed = true;
557: else isAllowed = false;
558: }
559: else isAllowed = false;
560: }
561: else isAllowed = false;
562:
563: return isAllowed;
564: }
565:
566: ////////////////////////////////////////////////////////////////////////////
567:
568: /// <summary>
569: ///
570: /// </summary>
571: public static bool StaffCanCreateDeleteLicList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Staff staff, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Msan msan)
572: {
573: bool isAllowed;
574:
575: if (staff != null)
576: {
577: if (function == PersistentStorageFunction.Create || function == PersistentStorageFunction.Delete)
578: {
579: if (Ia.Ngn.Cl.Model.Business.Authority.StaffCanExecuteTasks(staff, true))
580: {
581: if (StaffIsSuperUser(staff)) isAllowed = true;
582: else if (staff.Framework.ArabicName == "مراقبة خدمات الشبكة") isAllowed = true;
583: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
584: else if (staff.Framework.ArabicName == "مراقبة تشغيل الشبكة") isAllowed = true;
585: else if (staff.Framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isAllowed = true;
586: else if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
587: else if (staff.Framework.ArabicName == "قسم تقنية المعلومات" && staff.IsHead) isAllowed = true;
588: else if (staff.Framework != null && staff.Framework.Sites.Count > 0)
589: {
590: isAllowed = false;// staff.Framework.Sites.Any(u => u.Id == msan.Site.Id);
591: }
592: else isAllowed = false;
593: }
594: else isAllowed = false;
595: }
596: else isAllowed = false;
597: }
598: else isAllowed = false;
599:
600: return isAllowed;
601: }
602:
603: ////////////////////////////////////////////////////////////////////////////
604:
605: /// <summary>
606: ///
607: /// </summary>
608: public static bool StaffCanCreateBulkLicList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Staff staff)
609: {
610: bool isAllowed;
611:
612: if (staff != null)
613: {
614: if (function == PersistentStorageFunction.Create)
615: {
616: if (Ia.Ngn.Cl.Model.Business.Authority.StaffCanExecuteTasks(staff, true))
617: {
618: if (StaffIsSuperUser(staff)) isAllowed = true;
619: else if (staff.Framework.ArabicName == "مراقبة خدمات الشبكة") isAllowed = true;
620: else if (staff.Framework.ArabicName == "مراقبة تشغيل الشبكة") isAllowed = true;
621: else if (staff.Framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isAllowed = true;
622: else isAllowed = false;
623: }
624: else isAllowed = false;
625: }
626: else isAllowed = false;
627: }
628: else isAllowed = false;
629:
630: return isAllowed;
631: }
632:
633: ////////////////////////////////////////////////////////////////////////////
634:
635: /// <summary>
636: ///
637: /// </summary>
638: public static bool StaffCanCreateReadUpdateDeleteInventoryList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Staff staff)
639: {
640: bool isAllowed;
641:
642: if (staff != null)
643: {
644: if (function == PersistentStorageFunction.Create || function == PersistentStorageFunction.Read || function == PersistentStorageFunction.Update || function == PersistentStorageFunction.Delete)
645: {
646: if (StaffIsSuperUser(staff)) isAllowed = true;
647: else if (staff.Framework.ArabicName == "قسم الخطوط الطرفية") isAllowed = true;
648: else isAllowed = false;
649: }
650: else isAllowed = false;
651: }
652: else isAllowed = false;
653:
654: return isAllowed;
655: }
656:
657: ////////////////////////////////////////////////////////////////////////////
658:
659: /// <summary>
660: ///
661: /// </summary>
662: public static bool StaffContactCanCreateReadUpdateDeleteNetworkDesignDocument(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact)
663: {
664: bool isAllowed;
665:
666: if (staffContact != null)
667: {
668: if (function == PersistentStorageFunction.Create) isAllowed = false;
669: else if (function == PersistentStorageFunction.Read) isAllowed = true;
670: else if (function == PersistentStorageFunction.Update) isAllowed = false;
671: else if (function == PersistentStorageFunction.Delete) isAllowed = false;
672: else isAllowed = false;
673: }
674: else isAllowed = false;
675:
676: return isAllowed;
677: }
678:
679: ////////////////////////////////////////////////////////////////////////////
680:
681: /// <summary>
682: ///
683: /// </summary>
684: public static bool StaffContactCanCreateReadUpdateDeleteMaintenanceFind(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact)
685: {
686: bool isAllowed;
687:
688: if (staffContact != null)
689: {
690: if (function == PersistentStorageFunction.Create) isAllowed = false;
691: else if (function == PersistentStorageFunction.Read) isAllowed = true;
692: else if (function == PersistentStorageFunction.Update) isAllowed = false;
693: else if (function == PersistentStorageFunction.Delete) isAllowed = false;
694: else isAllowed = false;
695: }
696: else isAllowed = false;
697:
698: return isAllowed;
699: }
700:
701: ////////////////////////////////////////////////////////////////////////////
702:
703: /// <summary>
704: ///
705: /// </summary>
706: public static bool FrameworkCanCreateReadUpdateDeleteMaintenanceFind(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Business.Administration.Framework framework)
707: {
708: bool isAllowed;
709:
710: if (framework != null)
711: {
712: if (function == PersistentStorageFunction.Create) isAllowed = false;
713: else if (function == PersistentStorageFunction.Read) isAllowed = true;
714: else if (function == PersistentStorageFunction.Update) isAllowed = false;
715: else if (function == PersistentStorageFunction.Delete) isAllowed = false;
716: else isAllowed = false;
717: }
718: else isAllowed = false;
719:
720: return isAllowed;
721: }
722:
723: ////////////////////////////////////////////////////////////////////////////
724:
725: /// <summary>
726: ///
727: /// </summary>
728: public static bool StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact)
729: {
730: bool isAllowed;
731:
732: if (staffContact != null)
733: {
734: if (function == PersistentStorageFunction.Create) isAllowed = true;
735: else if (function == PersistentStorageFunction.Read) isAllowed = true;
736: else if (function == PersistentStorageFunction.Update) isAllowed = false;
737: else if (function == PersistentStorageFunction.Delete) isAllowed = false;
738: else isAllowed = false;
739: }
740: else isAllowed = false;
741:
742: return isAllowed;
743: }
744:
745: ////////////////////////////////////////////////////////////////////////////
746:
747: /// <summary>
748: ///
749: /// </summary>
750: public static bool FrameworkCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Business.Administration.Framework framework)
751: {
752: bool isAllowed;
753:
754: if (framework != null)
755: {
756: if (function == PersistentStorageFunction.Create) isAllowed = true;
757: else if (function == PersistentStorageFunction.Read) isAllowed = true;
758: else if (function == PersistentStorageFunction.Update) isAllowed = false;
759: else if (function == PersistentStorageFunction.Delete) isAllowed = false;
760: else isAllowed = false;
761: }
762: else isAllowed = false;
763:
764: return isAllowed;
765: }
766:
767: ////////////////////////////////////////////////////////////////////////////
768: ////////////////////////////////////////////////////////////////////////////
769:
770: /// <summary>
771: ///
772: /// </summary>
773: public static bool StaffCanCreateReadUpdateDeleteServicePort(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Staff staff)
774: {
775: bool isAllowed;
776:
777: if (staff != null)
778: {
779: if (StaffIsSuperUser(staff)) isAllowed = true;
780: else isAllowed = false;
781: }
782: else isAllowed = false;
783:
784: return isAllowed;
785: }
786:
787: ////////////////////////////////////////////////////////////////////////////
788: ////////////////////////////////////////////////////////////////////////////
789:
790: /// <summary>
791: ///
792: /// </summary>
793: public static bool StaffCanReadUpdateServiceRequestAdministrativeIssue(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Staff staff)
794: {
795: bool isAllowed;
796:
797: if (staff != null)
798: {
799: if (function == PersistentStorageFunction.Read)
800: {
801: isAllowed = true;
802: }
803: else if (function == PersistentStorageFunction.Update)
804: {
805: if (StaffIsSuperUser(staff)) isAllowed = true;
806: else isAllowed = false;
807: }
808: else
809: {
810: isAllowed = false;
811: }
812: }
813: else isAllowed = false;
814:
815: return isAllowed;
816: }
817:
818: ////////////////////////////////////////////////////////////////////////////
819:
820: /// <summary>
821: ///
822: /// </summary>
823: public static bool StaffContactCanReadUpdateServiceRequestAdministrativeIssue(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction persistentStorageFunction, Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact)
824: {
825: bool isAllowed;
826:
827: if (staffContact != null)
828: {
829: if (persistentStorageFunction == PersistentStorageFunction.Read)
830: {
831: if (StaffIsSuperUser(staffContact.Staff)) isAllowed = true;
832: else if (staffContact.Contact != null && staffContact.Contact.FirstName == "Samih") isAllowed = true;
833: else isAllowed = false;
834: }
835: else if (persistentStorageFunction == PersistentStorageFunction.Update)
836: {
837: if (StaffIsSuperUser(staffContact.Staff)) isAllowed = true;
838: else if (staffContact.Contact != null && staffContact.Contact.FirstName == "Samih") isAllowed = true;
839: else isAllowed = false;
840: }
841: else
842: {
843: isAllowed = false;
844: }
845: }
846: else isAllowed = false;
847:
848: return isAllowed;
849: }
850:
851: ////////////////////////////////////////////////////////////////////////////
852: ////////////////////////////////////////////////////////////////////////////
853:
854: /// <summary>
855: ///
856: /// </summary>
857: public static bool StaffUserNameCanLogFromAnyPcIp(string userName)
858: {
859: bool isAllowed;
860:
861: if (!string.IsNullOrEmpty(userName))
862: {
863: if (userName == "jasem") isAllowed = true;
864: else if (userName == "mohammad") isAllowed = true;
865: else isAllowed = false;
866: }
867: else isAllowed = false;
868:
869: return isAllowed;
870: }
871:
872: ////////////////////////////////////////////////////////////////////////////
873: ////////////////////////////////////////////////////////////////////////////
874:
875: /// <summary>
876: ///
877: /// </summary>
878: public static Ia.Ngn.Cl.Model.Business.Administration.Framework FrameworkParentOfAllReportsThatWillBeHandledInReportSection
879: {
880: get
881: {
882: Ia.Ngn.Cl.Model.Business.Administration.Framework framework;
883:
884: framework = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList where f.ArabicName == "وزارة الإتصالات وتكنولوجيا المعلومات" select f).FirstOrDefault(); //.SingleOrDefault();
885:
886: return framework;
887: }
888: }
889:
890: ////////////////////////////////////////////////////////////////////////////
891:
892: /// <summary>
893: ///
894: /// </summary>
895: public static bool FrameworkIsResponsibleForAllOpenReportWithNoReportHistory(Ia.Ngn.Cl.Model.Business.Administration.Framework framework)
896: {
897: bool isResponsible;
898:
899: if (framework.ArabicName == "قسم الدعم الفني للشبكة") isResponsible = true;
900: else if (framework.ArabicName == "قسم تشغيل الخدمات") isResponsible = true;
901: else if (framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isResponsible = true;
902: else if (framework.ArabicName == "مراقبة تشغيل الشبكة") isResponsible = true;
903: //else if (framework.ArabicName == "مراقبة تقنية المعلومات") isResponsible = true;
904: else if (framework.ArabicName == "مراقبة خدمات الشبكة") isResponsible = true;
905: else if (framework.ArabicName == "إدارة شبكة الألياف الضوئية") isResponsible = true;
906: else isResponsible = false;
907:
908: return isResponsible;
909: }
910:
911: ////////////////////////////////////////////////////////////////////////////
912:
913: /// <summary>
914: ///
915: /// </summary>
916: public static bool FrameworkIsResponsibleForMissingLic(Ia.Ngn.Cl.Model.Business.Administration.Framework framework)
917: {
918: bool isResponsible;
919:
920: if (framework.ArabicName == "قسم تشغيل الخدمات") isResponsible = true;
921: else if (framework.ArabicName == "قسم خدمات الشبكة") isResponsible = true;
922: else if (framework.ArabicName == "مراقبة خدمات الشبكة") isResponsible = true;
923: else if (framework.ArabicName == "إدارة شبكة الألياف الضوئية") isResponsible = true;
924: else isResponsible = false;
925:
926: return isResponsible;
927: }
928:
929: ////////////////////////////////////////////////////////////////////////////
930:
931: /// <summary>
932: ///
933: /// </summary>
934: public static bool FrameworkCanCloseReport(Ia.Ngn.Cl.Model.Business.Administration.Framework framework)
935: {
936: bool canClose;
937:
938: canClose = framework.ArabicName == "قسم الدعم الفني للشبكة";
939:
940: return canClose;
941: }
942:
943: ////////////////////////////////////////////////////////////////////////////
944:
945: /// <summary>
946: ///
947: /// </summary>
948: public static bool StaffIsResponsibleForAllOpenReportWithNoReportHistory(Ia.Ngn.Cl.Model.Staff staff)
949: {
950: bool isResponsible;
951:
952: isResponsible = FrameworkIsResponsibleForAllOpenReportWithNoReportHistory(staff.Framework);
953:
954: return isResponsible;
955: }
956:
957: ////////////////////////////////////////////////////////////////////////////
958: ////////////////////////////////////////////////////////////////////////////
959:
960: /// <summary>
961: ///
962: /// </summary>
963: public static bool StaffIsSuperUser(Ia.Ngn.Cl.Model.Staff staff)
964: {
965: bool isSuperUser;
966:
967: if (staff != null)
968: {
969: isSuperUser = (SuperStaff != null && SuperStaff.Id == staff.Id || ApplicationStaff != null && ApplicationStaff.Id == staff.Id);
970: }
971: else isSuperUser = false;
972:
973: return isSuperUser;
974: }
975:
976: ////////////////////////////////////////////////////////////////////////////
977:
978: /// <summary>
979: ///
980: /// </summary>
981: public static bool StaffIsSuperOrDeputyUser(Ia.Ngn.Cl.Model.Staff staff)
982: {
983: bool isSuperOrDeputyUser;
984:
985: if (staff != null)
986: {
987: isSuperOrDeputyUser = (SuperStaff != null && SuperStaff.Id == staff.Id || DeputyStaff != null && DeputyStaff.Id == staff.Id);
988: }
989: else isSuperOrDeputyUser = false;
990:
991: return isSuperOrDeputyUser;
992: }
993:
994: ////////////////////////////////////////////////////////////////////////////
995:
996: /// <summary>
997: ///
998: /// </summary>
999: public static bool FrameworkIsSuperFramework(Ia.Ngn.Cl.Model.Business.Administration.Framework framework)
1000: {
1001: bool isSuperFramework;
1002:
1003: if (framework != null)
1004: {
1005: if (framework.ArabicName == "قسم دعم تشغيل الشبكة") isSuperFramework = true;
1006: else if (framework.ArabicName == "التطبيقات المتكاملة") isSuperFramework = true;
1007: else isSuperFramework = false;
1008: }
1009: else isSuperFramework = false;
1010:
1011: return isSuperFramework;
1012: }
1013:
1014: ////////////////////////////////////////////////////////////////////////////
1015:
1016: /// <summary>
1017: ///
1018: /// </summary>
1019: public static bool FrameworkIsApplication(Ia.Ngn.Cl.Model.Business.Administration.Framework framework)
1020: {
1021: bool isSuperFramework;
1022:
1023: if (framework != null)
1024: {
1025: if (framework.ArabicName == "التطبيقات المتكاملة") isSuperFramework = true;
1026: else isSuperFramework = false;
1027: }
1028: else isSuperFramework = false;
1029:
1030: return isSuperFramework;
1031: }
1032:
1033: ////////////////////////////////////////////////////////////////////////////
1034:
1035: /// <summary>
1036: ///
1037: /// </summary>
1038: public static Ia.Ngn.Cl.Model.Staff SuperStaff
1039: {
1040: get
1041: {
1042: var staff = (from s in Ia.Ngn.Cl.Model.Data.Staff.List
1043: where s.Framework.ArabicName == "قسم دعم تشغيل الشبكة" && s.IsHead
1044: select s).SingleOrDefault();
1045:
1046: return staff;
1047: }
1048: }
1049:
1050: ////////////////////////////////////////////////////////////////////////////
1051:
1052: /// <summary>
1053: ///
1054: /// </summary>
1055: public static Ia.Ngn.Cl.Model.Staff ApplicationStaff
1056: {
1057: get
1058: {
1059: var staff = (from s in Ia.Ngn.Cl.Model.Data.Staff.List
1060: where s.Framework.ArabicName == "التطبيقات المتكاملة" && s.IsHead
1061: select s).SingleOrDefault(); // me!
1062:
1063: return staff;
1064: }
1065: }
1066:
1067: ////////////////////////////////////////////////////////////////////////////
1068:
1069: /// <summary>
1070: ///
1071: /// </summary>
1072: public static Ia.Ngn.Cl.Model.Staff DeputyStaff
1073: {
1074: get
1075: {
1076: var staff = (from s in Ia.Ngn.Cl.Model.Data.Staff.List
1077: where s.Framework.ArabicName == "قسم تقنية المعلومات" && s.IsHead
1078: select s).SingleOrDefault();
1079:
1080: return staff;
1081: }
1082: }
1083:
1084: ////////////////////////////////////////////////////////////////////////////
1085:
1086: /// <summary>
1087: ///
1088: /// </summary>
1089: public static Ia.Ngn.Cl.Model.Business.Administration.Framework SuperFramework
1090: {
1091: get
1092: {
1093: Ia.Ngn.Cl.Model.Business.Administration.Framework framework;
1094:
1095: framework = (from f in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList
1096: where f.ArabicName == "قسم دعم تشغيل الشبكة" || f.ArabicName == "التطبيقات المتكاملة"
1097: select f).Single();
1098:
1099: return framework;
1100: }
1101: }
1102:
1103: ////////////////////////////////////////////////////////////////////////////
1104: ////////////////////////////////////////////////////////////////////////////
1105:
1106: /// <summary>
1107: ///
1108: /// </summary>
1109: public static bool StaffCanInsertUpdateDeleteServiceExemption(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Staff staff)
1110: {
1111: bool isAllowed;
1112:
1113: if (staff != null)
1114: {
1115: if (function == PersistentStorageFunction.Read)
1116: {
1117: isAllowed = true;
1118: }
1119: else if (function == PersistentStorageFunction.Create)
1120: {
1121: if (StaffIsSuperUser(staff)) isAllowed = true;
1122: else if (staff.Framework.ArabicName == "قسم تقنية المعلومات") isAllowed = true;
1123: else if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
1124: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
1125: else if (staff.Framework.ArabicName == "مراقبة تقنية المعلومات") isAllowed = true;
1126: else if (staff.Framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isAllowed = true;
1127: else if (staff.Framework.ArabicName == "مراقبة تشغيل الشبكة") isAllowed = true;
1128: else if (staff.Framework.ArabicName == "مراقبة خدمات الشبكة") isAllowed = true;
1129: else if (staff.Framework.ArabicName == "التطبيقات المتكاملة") isAllowed = true;
1130: else isAllowed = false;
1131: }
1132: else if (function == PersistentStorageFunction.Update)
1133: {
1134: if (StaffIsSuperUser(staff)) isAllowed = true;
1135: else isAllowed = false;
1136: }
1137: else if (function == PersistentStorageFunction.Delete)
1138: {
1139: if (StaffIsSuperUser(staff)) isAllowed = true;
1140: else isAllowed = false;
1141: }
1142: else
1143: {
1144: isAllowed = false;
1145: }
1146: }
1147: else isAllowed = false;
1148:
1149: return isAllowed;
1150: }
1151:
1152: ////////////////////////////////////////////////////////////////////////////
1153:
1154: /// <summary>
1155: ///
1156: /// </summary>
1157: public static bool StaffCanCreateReadUpdateAccessMail(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Staff staff)
1158: {
1159: bool isAllowed;
1160:
1161: if (staff != null)
1162: {
1163: if (function == PersistentStorageFunction.Read)
1164: {
1165: isAllowed = true;
1166: }
1167: else if (function == PersistentStorageFunction.Update)
1168: {
1169: if (StaffIsSuperUser(staff)) isAllowed = true;
1170: else if (staff.IsHead && staff.Framework.ArabicName == "قسم الخطوط الطرفية") isAllowed = true;
1171: else isAllowed = false;
1172: }
1173: else
1174: {
1175: isAllowed = false;
1176: }
1177: }
1178: else isAllowed = false;
1179:
1180: return isAllowed;
1181: }
1182:
1183: ////////////////////////////////////////////////////////////////////////////
1184:
1185: /// <summary>
1186: ///
1187: /// </summary>
1188: public static bool StaffCanUploadAmsTransactionCsvFile(Ia.Ngn.Cl.Model.Staff staff)
1189: {
1190: bool isAllowed;
1191:
1192: if (staff != null)
1193: {
1194: if (StaffIsSuperUser(staff)) isAllowed = true;
1195: else isAllowed = false;
1196: }
1197: else isAllowed = false;
1198:
1199: return isAllowed;
1200: }
1201:
1202: ////////////////////////////////////////////////////////////////////////////
1203:
1204: /// <summary>
1205: ///
1206: /// </summary>
1207: public static bool StaffCanUploadGponPhaseIiHomeConnectionAndMigrationCsvFile(Ia.Ngn.Cl.Model.Staff staff)
1208: {
1209: bool isAllowed;
1210:
1211: if (staff != null)
1212: {
1213: if (StaffIsSuperUser(staff)) isAllowed = true;
1214: else isAllowed = false;
1215: }
1216: else isAllowed = false;
1217:
1218: return isAllowed;
1219: }
1220:
1221: ////////////////////////////////////////////////////////////////////////////
1222:
1223: /// <summary>
1224: ///
1225: /// </summary>
1226: public static bool FrameworkCanReadStatistics(Ia.Ngn.Cl.Model.Business.Administration.Framework framework)
1227: {
1228: bool isAllowed;
1229:
1230: if (framework != null)
1231: {
1232: if (FrameworkIsSuperFramework(framework)) isAllowed = true;
1233: else isAllowed = false;
1234: }
1235: else isAllowed = true; // for now I will allow users with framework = null coming form telegram
1236:
1237: return isAllowed;
1238: }
1239:
1240: ////////////////////////////////////////////////////////////////////////////
1241:
1242: /// <summary>
1243: ///
1244: /// </summary>
1245: public static bool StaffContactCanInsertAmsTransactionCsvFile(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction function, Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact)
1246: {
1247: bool isAllowed;
1248:
1249: if (staffContact != null)
1250: {
1251: if (function == PersistentStorageFunction.Create) isAllowed = true;
1252: else if (function == PersistentStorageFunction.Read) isAllowed = true;
1253: else if (function == PersistentStorageFunction.Update) isAllowed = false;
1254: else if (function == PersistentStorageFunction.Delete) isAllowed = false;
1255: else isAllowed = false;
1256: }
1257: else isAllowed = false;
1258:
1259: return isAllowed;
1260: }
1261:
1262: ////////////////////////////////////////////////////////////////////////////
1263: ////////////////////////////////////////////////////////////////////////////
1264:
1265: /// <summary>
1266: ///
1267: /// </summary>
1268: public static bool StaffCanReadUpdateServiceRequestServiceAccess(Ia.Ngn.Cl.Model.Staff staff)
1269: {
1270: bool isAllowed;
1271:
1272: if (staff != null)
1273: {
1274: if (StaffIsSuperUser(staff)) isAllowed = true;
1275: else if (staff.Framework.ArabicName == "قسم تقنية المعلومات") isAllowed = true;
1276: else if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
1277: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
1278: else if (staff.Framework.ArabicName == "مراقبة تقنية المعلومات") isAllowed = true;
1279: else if (staff.Framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isAllowed = true;
1280: else if (staff.Framework.ArabicName == "مراقبة تشغيل الشبكة") isAllowed = true;
1281: else if (staff.Framework.ArabicName == "مراقبة خدمات الشبكة") isAllowed = true;
1282: else if (staff.Framework.ArabicName == "التطبيقات المتكاملة") isAllowed = true;
1283: else isAllowed = false;
1284: }
1285: else isAllowed = false;
1286:
1287: return isAllowed;
1288: }
1289:
1290: ////////////////////////////////////////////////////////////////////////////
1291:
1292: /// <summary>
1293: ///
1294: /// </summary>
1295: public static bool StaffCanOverrideRouterDomainRestrictionInCreatingService(Ia.Ngn.Cl.Model.Staff staff)
1296: {
1297: bool isAllowed;
1298:
1299: if (staff != null)
1300: {
1301: if (StaffIsSuperUser(staff)) isAllowed = true;
1302: else if (staff.Framework.ArabicName == "مراقبة تقنية المعلومات") isAllowed = true;
1303: else if (staff.Framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isAllowed = true;
1304: else if (staff.Framework.ArabicName == "مراقبة تشغيل الشبكة") isAllowed = true;
1305: else if (staff.Framework.ArabicName == "مراقبة خدمات الشبكة") isAllowed = true;
1306: else if (staff.Framework.ArabicName == "التطبيقات المتكاملة") isAllowed = true;
1307: else isAllowed = false;
1308: }
1309: else isAllowed = false;
1310:
1311: return isAllowed;
1312: }
1313:
1314: ////////////////////////////////////////////////////////////////////////////
1315:
1316: /// <summary>
1317: ///
1318: /// </summary>
1319: public static bool StaffCanReadUpdateService2Access(Ia.Ngn.Cl.Model.Staff staff)
1320: {
1321: bool isAllowed;
1322:
1323: if (staff != null)
1324: {
1325: if (StaffIsSuperUser(staff)) isAllowed = true;
1326: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات" && staff.IsHead) isAllowed = true;
1327: //else if (staff.Framework.ArabicName == "هواوي" && staff.IsHead) isAllowed = true;
1328: else isAllowed = false;
1329: }
1330: else isAllowed = false;
1331:
1332: return isAllowed;
1333: }
1334:
1335: ////////////////////////////////////////////////////////////////////////////
1336:
1337: /// <summary>
1338: ///
1339: /// </summary>
1340: public static bool StaffCanMigratePremisesFromPstnToFiber(Ia.Ngn.Cl.Model.Staff staff)
1341: {
1342: // see related sister function StaffCanMigratePremisesFromPstnToFiberForNddOnt()
1343: bool isAllowed;
1344:
1345: if (staff != null)
1346: {
1347: if (StaffIsSuperUser(staff)) isAllowed = true;
1348: else if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
1349: else if (staff.Framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isAllowed = true;
1350: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
1351: else if (staff.Framework.ArabicName == "مراقبة خدمات الشبكة") isAllowed = true;
1352: else if (staff.Framework.ArabicName == "مراقبة تشغيل الشبكة") isAllowed = true;
1353: else if (staff.Framework.Ancestors.Any(u => u.ArabicName == "مراقبة تقنية المعلومات")) isAllowed = true;
1354: else if (staff.Framework.ArabicName == "التطبيقات المتكاملة") isAllowed = true;
1355: else
1356: {
1357: if (staff.Framework != null && staff.Framework.Sites.Count > 0)
1358: {
1359: var list = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
1360:
1361: isAllowed = staff.Framework.Sites.Any(u => u.Routers.Any(v => v.Odfs.Any(w => w.Olts.Any(x => list.Contains(x.Id)))));
1362: }
1363: else isAllowed = false;
1364: }
1365: }
1366: else isAllowed = false;
1367:
1368: return isAllowed;
1369: }
1370:
1371: ////////////////////////////////////////////////////////////////////////////
1372:
1373: /// <summary>
1374: ///
1375: /// </summary>
1376: public static bool StaffCanMigratePremisesFromPstnToFiberForNddOnt(Ia.Ngn.Cl.Model.Staff staff, Ia.Ngn.Cl.Model.Business.NetworkDesignDocument.Ont nddOnt)
1377: {
1378: // see related sister function StaffCanMigratePremisesFromPstnToFiber()
1379: bool isAllowed;
1380:
1381: if (staff != null)
1382: {
1383: if (nddOnt != null)
1384: {
1385: var list = Ia.Ngn.Cl.Model.Data.Service.AllowedToBeMigratedOltIdList;
1386:
1387: if (list.Contains(nddOnt.Pon.PonGroup.Olt.Id))
1388: {
1389: if (StaffIsSuperUser(staff)) isAllowed = true;
1390: else if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
1391: else if (staff.Framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isAllowed = true;
1392: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
1393: else if (staff.Framework.ArabicName == "مراقبة خدمات الشبكة") isAllowed = true;
1394: else if (staff.Framework.ArabicName == "مراقبة تشغيل الشبكة") isAllowed = true;
1395: else if (staff.Framework.Ancestors.Any(u => u.ArabicName == "مراقبة تقنية المعلومات")) isAllowed = true;
1396: else if (staff.Framework.ArabicName == "التطبيقات المتكاملة") isAllowed = true;
1397: else
1398: {
1399: if (staff.Framework != null && staff.Framework.Sites.Count > 0)
1400: {
1401: isAllowed = staff.Framework.Sites.Any(u => u.Routers.Any(v => v.Odfs.Any(w => w.Olts.Any(x => nddOnt.Pon.PonGroup.Olt.Id == x.Id))));
1402: }
1403: else isAllowed = false;
1404: }
1405: }
1406: else isAllowed = false;
1407: }
1408: else isAllowed = false;
1409: }
1410: else isAllowed = false;
1411:
1412: return isAllowed;
1413: }
1414:
1415: ////////////////////////////////////////////////////////////////////////////
1416:
1417: /// <summary>
1418: ///
1419: /// </summary>
1420: public static bool StaffCanAccessAdministationFolder(Ia.Ngn.Cl.Model.Staff staff)
1421: {
1422: bool isAllowed;
1423:
1424: /*
1425: * <allow roles="التطبيقات المتكاملة,إدارة شبكة الألياف الضوئية,مراقبة خدمات الشبكة,مراقبة الدعم الفنى للشبكة,مراقبة تقنية المعلومات,مراقبة تشغيل الشبكة,قسم دعم تشغيل الشبكة,إدارة مشاريع الشبكة الهاتفية"/>
1426: * <allow roles="نوكيا,هواوي,وزارة الإتصالات وتكنولوجيا المعلومات" />
1427: * <deny users="*"/>
1428: * <allow users="mohammad"/>
1429: */
1430:
1431: if (staff != null)
1432: {
1433: if (StaffIsSuperUser(staff)) isAllowed = true;
1434: else if (staff.Framework.AncestorsOrSelf.Any(u => u.ArabicName == "وزارة الإتصالات وتكنولوجيا المعلومات")) isAllowed = true;
1435: else if (staff.Framework.AncestorsOrSelf.Any(u => u.ArabicName == "هواوي")) isAllowed = true;
1436: else if (staff.Framework.AncestorsOrSelf.Any(u => u.ArabicName == "نوكيا")) isAllowed = true;
1437: else if (staff.Framework.AncestorsOrSelf.Any(u => u.ArabicName == "التطبيقات المتكاملة")) isAllowed = true;
1438: else isAllowed = false;
1439: }
1440: else isAllowed = false;
1441:
1442: return isAllowed;
1443: }
1444:
1445: ////////////////////////////////////////////////////////////////////////////
1446:
1447: /// <summary>
1448: ///
1449: /// </summary>
1450: public static bool StaffCanExecuteTasks(Ia.Ngn.Cl.Model.Staff staff)
1451: {
1452: return StaffCanExecuteTasks(staff, false);
1453: }
1454:
1455: ////////////////////////////////////////////////////////////////////////////
1456:
1457: /// <summary>
1458: ///
1459: /// </summary>
1460: public static bool StaffCanExecuteTasks(Ia.Ngn.Cl.Model.Staff staff, bool overrideCondition)
1461: {
1462: bool isAllowed;
1463:
1464: if (staff != null)
1465: {
1466: if (StaffIsSuperUser(staff)) isAllowed = true;
1467: else if (staff.Framework.ArabicName == "قسم تقنية المعلومات") isAllowed = true;
1468: else if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
1469: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
1470: else if (staff.Framework.ArabicName == "مراقبة تقنية المعلومات") isAllowed = true;
1471: else if (staff.Framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isAllowed = true;
1472: else if (staff.Framework.ArabicName == "مراقبة تشغيل الشبكة") isAllowed = true;
1473: else if (staff.Framework.ArabicName == "مراقبة خدمات الشبكة") isAllowed = true;
1474: else if (staff.Framework.ArabicName == "التطبيقات المتكاملة") isAllowed = true;
1475: else if (overrideCondition) isAllowed = true;
1476: else isAllowed = false;
1477: }
1478: else isAllowed = false;
1479:
1480: return isAllowed;
1481: }
1482:
1483: ////////////////////////////////////////////////////////////////////////////
1484:
1485: /// <summary>
1486: ///
1487: /// </summary>
1488: public static bool StaffCanExecuteAccessTasks(Ia.Ngn.Cl.Model.Staff staff)
1489: {
1490: bool isAllowed;
1491:
1492: if (staff != null)
1493: {
1494: if (StaffIsSuperUser(staff)) isAllowed = true;
1495: else if (staff.Framework.ArabicName == "قسم تقنية المعلومات") isAllowed = true;
1496: else if (staff.Framework.ArabicName == "قسم الدعم الفني للشبكة") isAllowed = true;
1497: else if (staff.Framework.ArabicName == "قسم تشغيل الخدمات") isAllowed = true;
1498: else if (staff.Framework.ArabicName == "مراقبة تقنية المعلومات") isAllowed = true;
1499: else if (staff.Framework.ArabicName == "مراقبة الدعم الفنى للشبكة") isAllowed = true;
1500: else if (staff.Framework.ArabicName == "مراقبة تشغيل الشبكة") isAllowed = true;
1501: else if (staff.Framework.ArabicName == "مراقبة خدمات الشبكة") isAllowed = true;
1502: else if (staff.Framework.ArabicName == "التطبيقات المتكاملة") isAllowed = true;
1503: else if (Ia.Ngn.Cl.Model.Business.Authority.StaffIsInCustomerServiceSector(staff)) isAllowed = true;
1504: else isAllowed = false;
1505: }
1506: else isAllowed = false;
1507:
1508: return isAllowed;
1509: }
1510:
1511: ////////////////////////////////////////////////////////////////////////////
1512:
1513: /// <summary>
1514: ///
1515: /// </summary>
1516: public static bool StaffIsApplication(Ia.Ngn.Cl.Model.Staff staff)
1517: {
1518: bool isAllowed;
1519:
1520: if (staff != null)
1521: {
1522: if (staff.Framework.ArabicName == "قسم دعم تشغيل الشبكة" && staff.FirstName == "جاسم"
1523: || staff.Framework.ArabicName == "التطبيقات المتكاملة") isAllowed = true;
1524: else isAllowed = false;
1525: }
1526: else isAllowed = false;
1527:
1528: return isAllowed;
1529: }
1530:
1531: ////////////////////////////////////////////////////////////////////////////
1532:
1533: /// <summary>
1534: ///
1535: /// </summary>
1536: public static bool StaffIsInCustomerServiceSector(Ia.Ngn.Cl.Model.Staff staff)
1537: {
1538: bool isAllowed;
1539:
1540: if (staff != null)
1541: {
1542: if (staff.Framework.Ancestors.Any(u => u.ArabicName == "قطاع خدمات المشتركين")) isAllowed = true;
1543: else isAllowed = false;
1544: }
1545: else isAllowed = false;
1546:
1547: return isAllowed;
1548: }
1549:
1550: ////////////////////////////////////////////////////////////////////////////
1551:
1552: /// <summary>
1553: ///
1554: /// </summary>
1555: public static bool StaffIsInOpticalFiberNetworkDepartment(Ia.Ngn.Cl.Model.Staff staff)
1556: {
1557: bool isAllowed;
1558:
1559: if (staff != null)
1560: {
1561: if (staff.Framework.AncestorsOrSelf.Any(u => u.ArabicName == "إدارة شبكة الألياف الضوئية")) isAllowed = true;
1562: //else if (staff.Framework.AncestorsOrSelf.Any(u => u.ArabicName == "إدارة مشاريع الشبكة الهاتفية")) isAllowed = true;
1563: else isAllowed = false;
1564: }
1565: else isAllowed = false;
1566:
1567: return isAllowed;
1568: }
1569:
1570: ////////////////////////////////////////////////////////////////////////////
1571:
1572: /// <summary>
1573: ///
1574: /// </summary>
1575: public static bool StaffIsSupplier(Ia.Ngn.Cl.Model.Staff staff)
1576: {
1577: bool isAllowed;
1578:
1579: if (staff != null)
1580: {
1581: if (staff.Framework.ArabicName == "نوكيا" || staff.Framework.ArabicName == "هواوي") isAllowed = true;
1582: else isAllowed = false;
1583: }
1584: else isAllowed = false;
1585:
1586: return isAllowed;
1587: }
1588:
1589: ////////////////////////////////////////////////////////////////////////////
1590:
1591: /// <summary>
1592: ///
1593: /// </summary>
1594: public static bool StaffIsInRole(Ia.Ngn.Cl.Model.Staff staff, string role)
1595: {
1596: bool isAllowed;
1597:
1598: if (staff != null)
1599: {
1600: if (staff.Framework.Ancestors.Any(u => u.ArabicName == role)) isAllowed = true;
1601: else isAllowed = false;
1602: }
1603: else isAllowed = false;
1604:
1605: return isAllowed;
1606: }
1607:
1608: ////////////////////////////////////////////////////////////////////////////
1609: ////////////////////////////////////////////////////////////////////////////
1610:
1611: /// <summary>
1612: ///
1613: /// </summary>
1614: public static List<Tuple<string, string>> EmailRecipientTupleList(Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction schedularFunction)
1615: {
1616: List<Tuple<string, string>> recipientTupleList;
1617:
1618: recipientTupleList = new List<Tuple<string, string>>();
1619:
1620: switch (schedularFunction)
1621: {
1622: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.ListOfPreviouslyPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport:
1623: {
1624: recipientTupleList.Add(new Tuple<string, string>("E. Shatti", "emad@moc.gov.kw"));
1625: //recipientTupleList.Add(new Tuple<string, string>("M. Qattan", "qattan04@hotmail.com"));
1626: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1627:
1628: break;
1629: }
1630: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.ListOfPreviouslyQrnPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport:
1631: {
1632: recipientTupleList.Add(new Tuple<string, string>("QRN Exchange", "qrnexchange@gmail.com"));
1633: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1634:
1635: break;
1636: }
1637: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.ListOfPreviouslyJblPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport:
1638: {
1639: recipientTupleList.Add(new Tuple<string, string>("JBL Exchange", "jbl.exch@gmail.com"));
1640: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1641:
1642: break;
1643: }
1644: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.ListOfPreviouslySsbPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport:
1645: {
1646: recipientTupleList.Add(new Tuple<string, string>("SSB Exchange", "ssb.exch@gmail.com"));
1647: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1648:
1649: break;
1650: }
1651: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.ListOfPreviouslySlmaPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport:
1652: {
1653: recipientTupleList.Add(new Tuple<string, string>("SLMA Exchange", "slmakw158@gmail.com"));
1654: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1655:
1656: break;
1657: }
1658: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.ListOfPreviouslySlmbPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport:
1659: {
1660: recipientTupleList.Add(new Tuple<string, string>("SLMB Exchange", "msfkw158@gmail.com"));
1661: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1662:
1663: break;
1664: }
1665: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.ListOfPreviouslyMsfPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport:
1666: {
1667: recipientTupleList.Add(new Tuple<string, string>("MSF Exchange", "msfkw158@gmail.com"));
1668: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1669:
1670: break;
1671: }
1672: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.ListOfPreviouslyFhhPstnDomainServicesMigratedOrProvisionedIntoImsFiberOrImsMsanServicesInAllowedToBeMigratedOltsReport:
1673: {
1674: recipientTupleList.Add(new Tuple<string, string>("FHH Exchange", "fahaheel.2021@gmail.com"));
1675: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1676:
1677: break;
1678: }
1679:
1680: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.StatusReport:
1681: {
1682: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1683:
1684: break;
1685: }
1686: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.StatisticsReport:
1687: {
1688: recipientTupleList.Add(new Tuple<string, string>("Traffic", "traffic_section@yahoo.com"));
1689: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1690:
1691: break;
1692: }
1693: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.NokiaReport:
1694: {
1695: recipientTupleList.Add(new Tuple<string, string>("R. Vizcara", "rumello.vizcara@nokia.com"));
1696: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1697:
1698: break;
1699: }
1700: case Ia.Ngn.Cl.Model.Business.Authority.SchedularFunction.HuaweiReport:
1701: {
1702: //recipientTupleList.Add(new Tuple<string, string>("J. Shamlan", "info@ia.com.kw"));
1703:
1704: break;
1705: }
1706: default: break;
1707: }
1708:
1709: return recipientTupleList;
1710: }
1711:
1712: ////////////////////////////////////////////////////////////////////////////
1713: ////////////////////////////////////////////////////////////////////////////
1714:
1715: /// <summary>
1716: ///
1717: /// </summary>
1718: public static bool ServiceRequestIsAllowedProcessing(Ia.Ngn.Cl.Model.ServiceRequest serviceRequest)
1719: {
1720: // below: this skips processing some service requests due to misc problems
1721: bool processingIsAllowed;
1722:
1723: // see ServiceRequestIdIsAllowedForProcessing in service-request.cs
1724:
1725: if (serviceRequest.Id == 1719402 || serviceRequest.Id == 1875029) processingIsAllowed = false;
1726: // 1719402 25232104 1 تم التنفيذ 2014-10-28 11:07 خط هاتف هاتف 17 الادارة العامة للجمارك جهات حكومية
1727: // 1875029 25232104 1 تعذر التنفيذ 2016-02-24 00:00 رفع خط هاتف 17 الادارة العامة للجمارك جهات حكومية
1728: else if (serviceRequest.Id == 1639637) processingIsAllowed = false;
1729: // 1639637 25430454 3 تم التنفيذ 2014-03-05 09:04 خط هاتف هاتف 1619586 بدر ناصر غانم الارملي
1730: // above: wrong service record with serial 3, but later records reduce to 2
1731: else if (serviceRequest.Id == 361494) processingIsAllowed = false;
1732: // 361494 25518807 0 تم التنفيذ 2006-07-26 11:58 إيقاف كاشف هاتف
1733: // above: causes call waiting to stop in the group service
1734: else processingIsAllowed = true;
1735:
1736: return processingIsAllowed;
1737: }
1738:
1739: ////////////////////////////////////////////////////////////////////////////
1740:
1741: /// <summary>
1742: ///
1743: /// </summary>
1744: public static bool ServiceRequestHistoryIsAllowedProcessing(Ia.Ngn.Cl.Model.ServiceRequestHistory serviceRequestHistory)
1745: {
1746: // below: this skips processing some service requests due to misc problems
1747: bool processingIsAllowed;
1748:
1749: if (serviceRequestHistory.Id == "25429778:1:965:0:66:2005-11-27") processingIsAllowed = false;
1750: // prevent the removal of service group
1751: else if (serviceRequestHistory.Id == "23900287:1:965:1:14:2005-07-06" || serviceRequestHistory.Id == "23900287:1:965:1:66:2008-12-25") processingIsAllowed = false;
1752: /*
1753: 23900287 1 يعمل 2005-07-06 2005-07-06 كاشف رقم هاتف 2019-03-29 22:01 2019-03-29 22:01
1754: 23900287 1 يعمل 2005-07-06 2008-12-25 إيقاف كاشف هاتف 2019-03-29 22:01 2019-03-29 22:01
1755: */
1756: else if (serviceRequestHistory.Id == "25518807:1:965:0:66:2002-10-27" || serviceRequestHistory.Id == "25518807:1:965:0:66:2006-07-26") processingIsAllowed = false;
1757: /*
1758: 25518807:1:965:0:66:2002-10-27 25518807 0 7001 1986-05-29 00:00:00.000 1753-01-01 00:00:00.000 2002-10-27 00:00:00.000 66 3 2019-04-10 23:07:01.897 2019-04-10 23:07:01.897 NULL
1759: 25518807:1:965:0:66:2006-07-26 25518807 0 7001 1986-05-29 00:00:00.000 1753-01-01 00:00:00.000 2006-07-26 00:00:00.000 66 3 2019-04-10 23:07:01.897 2019-04-10 23:07:01.897 NULL
1760: */
1761: else if (serviceRequestHistory.Id == "25519290:1:965:1:66:2002-10-28") processingIsAllowed = false;
1762: /*
1763: 25519290 1 يعمل 1998-03-28 2002-10-28 إيقاف كاشف هاتف 2019-04-10 23:48 2019-04-10 23:48
1764: 25519290:1:965:1:66:2002-10-28 25519290 1 7001 1998-03-28 00:00:00.000 1753-01-01 00:00:00.000 2002-10-28 00:00:00.000 66 3 2019-04-10 23:48:15.117 2019-04-10 23:48:15.117 NULL
1765: */
1766: else processingIsAllowed = true;
1767:
1768: return processingIsAllowed;
1769: }
1770:
1771: ////////////////////////////////////////////////////////////////////////////
1772:
1773: /// <summary>
1774: ///
1775: /// </summary>
1776: public static bool ServiceProcessingIsAllowed(string service)
1777: {
1778: // below: this skips processing some services due to misc problems
1779: bool processingIsAllowed;
1780:
1781: if (!string.IsNullOrEmpty(service))
1782: {
1783: if (Ia.Ngn.Cl.Model.Data.ServiceExemption.ServiceList().Contains(service)) processingIsAllowed = false;
1784: else processingIsAllowed = true;
1785: }
1786: else processingIsAllowed = true;
1787:
1788: return processingIsAllowed;
1789: }
1790:
1791: ////////////////////////////////////////////////////////////////////////////
1792: ////////////////////////////////////////////////////////////////////////////
1793:
1794: /// <summary>
1795: ///
1796: /// </summary>
1797: public static bool TelegramUserCanReadFind(string chatId, int userId)
1798: {
1799: bool isAllowed;
1800:
1801: if (userId != 0)
1802: {
1803: isAllowed = true;
1804: }
1805: else isAllowed = false;
1806:
1807: return isAllowed;
1808: }
1809:
1810: ////////////////////////////////////////////////////////////////////////////
1811:
1812: /// <summary>
1813: ///
1814: /// </summary>
1815: public static bool NumberIsWithinFrameworkSiteDomainList(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string service)
1816: {
1817: bool isWithin;
1818:
1819: if (framework != null)
1820: {
1821: if (framework.Sites.Count > 0)
1822: {
1823: if (framework.Sites.Any(w => w.DomainList.Any(u => service.StartsWith(u.ToString())))) isWithin = true;
1824: else isWithin = true; // false; temp
1825: }
1826: else isWithin = true; // will allow number for framework.Site == null
1827: }
1828: else isWithin = true; // will allow for null framework because the function is used from systems that do not utilize ASP.NET membership like telegram and email.
1829:
1830: return isWithin;
1831: }
1832:
1833: ////////////////////////////////////////////////////////////////////////////
1834:
1835: /// <summary>
1836: ///
1837: /// </summary>
1838: public static bool AccessNameIsWithinFrameworkSiteAreaSymbolList(Ia.Ngn.Cl.Model.Business.Administration.Framework framework, string accessName)
1839: {
1840: bool isWithin;
1841:
1842: if (framework != null)
1843: {
1844: if (framework.Sites.Count > 0)
1845: {
1846: if (framework.Sites.Any(u => u.AreaSymbolList.Any(v => accessName.StartsWith(v.ToString())))) isWithin = true;
1847: else isWithin = true; // false; temp
1848: }
1849: else isWithin = true; // will allow number for framework.Site == null
1850: }
1851: else isWithin = true; // I will allow for null framework because the function is used from systems that do not utilize ASP.NET membership like telegram and email.
1852:
1853: return isWithin;
1854: }
1855:
1856: ////////////////////////////////////////////////////////////////////////////
1857:
1858: /// <summary>
1859: ///
1860: /// </summary>
1861: public static void UpdateAdministrativeFrameworkRolesOfStaff(Ia.Ngn.Cl.Model.Staff staff)
1862: {
1863: string userName;
1864: MembershipUser membershipUser;
1865:
1866: membershipUser = Membership.GetUser(staff.UserId);
1867:
1868: if (membershipUser != null)
1869: {
1870: userName = membershipUser.UserName;
1871:
1872: // add user to IsHead role if he is head, and remove him otherwise
1873: if (staff.IsHead)
1874: {
1875: if (!Roles.IsUserInRole(userName, "IsHead")) Roles.AddUserToRole(userName, "IsHead");
1876: }
1877: else
1878: {
1879: if (Roles.IsUserInRole(userName, "IsHead")) Roles.RemoveUserFromRole(userName, "IsHead");
1880: }
1881:
1882: // add user to its direct role
1883: if (!Roles.IsUserInRole(userName, staff.Framework.FullyQualifiedArabicName)) Roles.AddUserToRole(userName, staff.Framework.FullyQualifiedArabicName);
1884:
1885: // add user to its decendants roles
1886: foreach (var framework in staff.Framework.Descendants)
1887: {
1888: if (!Roles.IsUserInRole(userName, framework.FullyQualifiedArabicName)) Roles.AddUserToRole(userName, framework.FullyQualifiedArabicName);
1889: }
1890:
1891: // add user to its ancestors roles
1892: foreach (var framework in staff.Framework.Ancestors)
1893: {
1894: if (!Roles.IsUserInRole(userName, framework.FullyQualifiedArabicName)) Roles.AddUserToRole(userName, framework.FullyQualifiedArabicName);
1895: }
1896:
1897: // loop through all user roles and remove it from roles not in his description
1898: foreach (var framework in Ia.Ngn.Cl.Model.Data.Administration.FrameworkList)
1899: {
1900: if (framework.Id != staff.Framework.Id
1901: && !staff.Framework.Descendants.Any(f => f.Id == framework.Id)
1902: && !staff.Framework.Ancestors.Any(f => f.Id == framework.Id)
1903: && Roles.IsUserInRole(userName, framework.FullyQualifiedArabicName))
1904: Roles.RemoveUserFromRole(userName, framework.FullyQualifiedArabicName);
1905: }
1906: }
1907: }
1908:
1909: ////////////////////////////////////////////////////////////////////////////
1910: ////////////////////////////////////////////////////////////////////////////
1911: }
1912:
1913: ////////////////////////////////////////////////////////////////////////////
1914: ////////////////////////////////////////////////////////////////////////////
1915: }