1: using System.Collections.Generic;
2: using System.Data;
3: using System.Linq;
4:
5: namespace Ia.Ngn.Cl.Model.Ui
6: {
7: ////////////////////////////////////////////////////////////////////////////
8:
9: /// <summary publish="true">
10: /// Access support class for Optical Fiber Network (OFN) ui model.
11: /// </summary>
12: ///
13: /// <remarks>
14: /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
15: ///
16: /// 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
17: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
18: ///
19: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
20: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21: ///
22: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
23: ///
24: /// Copyright notice: This notice may not be removed or altered from any source distribution.
25: /// </remarks>
26: public class Access
27: {
28: /// <summary/>
29: public string Id { get; set; }
30:
31: /// <summary/>
32: public int AreaId { get; set; }
33: /// <summary/>
34: public string Block { get; set; }
35: /// <summary/>
36: public string Street { get; set; }
37: /// <summary/>
38: public string Boulevard { get; set; }
39: /// <summary/>
40: public string PremisesOld { get; set; }
41: /// <summary/>
42: public string PremisesNew { get; set; }
43: /// <summary/>
44: public string Name { get; set; }
45:
46: /// <summary/>
47: public int NumberOfTrials { get; set; }
48:
49: /// <summary/>
50: public string Note { get; set; }
51:
52: /// <summary/>
53: public Access() { }
54:
55: ////////////////////////////////////////////////////////////////////////////
56:
57: /// <summary>
58: ///
59: /// </summary>
60: public static DataTable ReadListWithOntListProvisionedAndReadyButDoNotExistInCustomerDepartmentDatabaseDataTable()
61: {
62: return ReadListWithOntListProvisionedAndReadyButDoNotExistInCustomerDepartmentDatabaseDataTable(99999);
63: }
64:
65: ////////////////////////////////////////////////////////////////////////////
66:
67: /// <summary>
68: ///
69: /// </summary>
70: public static DataTable ReadListWithOntListProvisionedAndReadyButDoNotExistInCustomerDepartmentDatabaseDataTable(int numberOfFirstRowsToTake)
71: {
72: bool familyExists;
73: int c, possibleNumberOfTd, possibleNumberOfEthernet;
74: string /*accessId, ponNumber, ontNumber,*/ areaSymbol, areaName, accessOntFamilyTypeCapacityString;
75: DataRow dr;
76: DataTable dt;
77: List<Ia.Ngn.Cl.Model.Access> accessList;
78: Ia.Ngn.Cl.Model.Business.Service.KuwaitOfnArea kuwaitOfnArea;
79:
80: c = 0;
81: possibleNumberOfTd = possibleNumberOfEthernet = 0;
82:
83: dt = new DataTable("");
84: dt.Columns.Add("Id");
85: dt.Columns.Add("Pon");
86: dt.Columns.Add("Ont");
87: dt.Columns.Add("Name");
88: dt.Columns.Add("FamilyType");
89: dt.Columns.Add("AreaSymbol");
90: dt.Columns.Add("Area");
91: dt.Columns.Add("Block");
92: dt.Columns.Add("Street");
93: dt.Columns.Add("PremisesOld");
94: dt.Columns.Add("PremisesNew");
95: dt.Columns.Add("Paci");
96: dt.Columns.Add("Note");
97: dt.Columns.Add("PossibleNumberOfTd");
98: dt.Columns.Add("PossibleNumberOfEthernet");
99:
100: accessList = Ia.Ngn.Cl.Model.Data.Access.ListOfAccessesWithProvisionedAndReadyOntsButDoNotExistInCustomerDepartmentDatabase();
101:
102: accessList = accessList.OrderByDescending(a => a.Created).ToList();
103:
104: foreach (Ia.Ngn.Cl.Model.Access access in accessList)
105: {
106: possibleNumberOfTd = possibleNumberOfEthernet = 0;
107:
108: if (access.Onts != null && access.Onts.Count > 0)
109: {
110: accessOntFamilyTypeCapacityString = Ia.Ngn.Cl.Model.Data.Nokia.Ont.FamilyTypeStringFromId(access.Onts.FirstOrDefault().FamilyTypeId);
111:
112: possibleNumberOfTd = Ia.Ngn.Cl.Model.Business.Nokia.Ont.PossibleNumberOfTdForOntFamilyType(access.Onts.FirstOrDefault().FamilyTypeId);
113: possibleNumberOfEthernet = Ia.Ngn.Cl.Model.Business.Nokia.Ont.PossibleNumberOfHsiCardPortServiceConfigurationForOntFamilyType(access.Onts.FirstOrDefault().FamilyTypeId);
114:
115: accessOntFamilyTypeCapacityString += " (" + possibleNumberOfTd + ")";
116:
117: familyExists = true;
118: }
119: else if (access.EmsOnts != null && access.EmsOnts.Count > 0)
120: {
121: accessOntFamilyTypeCapacityString = access.EmsOnts.FirstOrDefault().FamilyType.ToString().ToUpper();
122:
123: var equipmentType = access.EmsOnts.FirstOrDefault().EquipmentType;
124:
125: if (equipmentType != null)
126: {
127: possibleNumberOfTd = equipmentType.TelPorts;
128: possibleNumberOfEthernet = equipmentType.EthernetPorts;
129:
130: accessOntFamilyTypeCapacityString += " (" + possibleNumberOfTd + ")";
131:
132: familyExists = true;
133: }
134: else
135: {
136: accessOntFamilyTypeCapacityString = string.Empty;
137: familyExists = false;
138: }
139: }
140: else
141: {
142: accessOntFamilyTypeCapacityString = string.Empty;
143: familyExists = false;
144: }
145:
146:
147: if (familyExists)
148: {
149: c++;
150:
151: dr = dt.NewRow();
152:
153: dr["Id"] = access.Id;
154: dr["Pon"] = access.Pon;
155: dr["Ont"] = access.Ont;
156: dr["Name"] = access.Name;
157: dr["Paci"] = access.Paci;
158: dr["Note"] = access.Note;
159:
160: dr["FamilyType"] = accessOntFamilyTypeCapacityString;
161:
162: kuwaitOfnArea = Ia.Ngn.Cl.Model.Data.Service.KuwaitOfnAreaById(access.AreaId);
163:
164: areaName = kuwaitOfnArea.Name;
165: areaSymbol = kuwaitOfnArea.Symbol;
166:
167: dr["AreaSymbol"] = areaSymbol;
168: dr["Area"] = areaName;
169:
170: dr["Block"] = access.Block;
171: dr["Street"] = access.Street;
172: dr["PremisesOld"] = access.PremisesOld;
173: dr["PremisesNew"] = access.PremisesNew;
174:
175: dr["PossibleNumberOfTd"] = possibleNumberOfTd;
176: dr["PossibleNumberOfEthernet"] = possibleNumberOfEthernet;
177:
178: dt.Rows.Add(dr);
179:
180: if (c >= numberOfFirstRowsToTake) break;
181: }
182: else
183: {
184:
185: }
186: }
187:
188: return dt;
189: }
190:
191: ////////////////////////////////////////////////////////////////////////////
192: ////////////////////////////////////////////////////////////////////////////
193: }
194:
195: ////////////////////////////////////////////////////////////////////////////
196: ////////////////////////////////////////////////////////////////////////////
197: }