1: using System.Collections.Generic;
2: using System.Configuration;
3: using System.Linq;
4:
5: namespace Ia.Ngn.Cl.Model.Business.Huawei
6: {
7: ////////////////////////////////////////////////////////////////////////////
8:
9: /// <summary publish="true">
10: /// Optical Fiber Network's Operations Support System Management Intranet (OFN OSS) support class for Huawei's Optical Fiber Network (OFN) business model
11: /// </summary>
12: ///
13: /// <value>
14: /// <appSettings>
15: /// <add key="imsHuaweiServerHost" value="https://*" />
16: /// <add key="imsHuaweiServerPort" value="*" />
17: /// <add key="imsHuaweiServerServiceUrl" value="*" />
18: /// <add key="imsHuaweiServerUser" value="*" />
19: /// <add key="imsHuaweiServerUserPassword" value="*" />
20: /// </appSettings>
21: /// </value>
22: ///
23: /// <remarks>
24: /// Copyright © 2014-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
25: ///
26: /// 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
27: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
28: ///
29: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
30: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
31: ///
32: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
33: ///
34: /// Copyright notice: This notice may not be removed or altered from any source distribution.
35: /// </remarks>
36: public class Ims
37: {
38: //private static int serviceRequestServiceServiceOfUnmatchedServicesListIndex;
39: private const string sipSubscriberRegistrationPassword = "admin"; // as per Huawei spec
40:
41: private static List<int> allPossibleServiceWithinHuaweiSwitchList = new List<int>();
42:
43: /// <summary/>
44: public static string BaseAddress { get { return ConfigurationManager.AppSettings["imsHuaweiServerHost"].ToString() + ":" + ConfigurationManager.AppSettings["imsHuaweiServerPort"].ToString(); } }
45:
46: /// <summary/>
47: public static string ServiceUrl { get { return ConfigurationManager.AppSettings["imsHuaweiServerServiceUrl"].ToString(); } }
48:
49: /// <summary/>
50: public static string UserName { get { return ConfigurationManager.AppSettings["imsHuaweiServerUser"].ToString(); } }
51:
52: /// <summary/>
53: public static string Password { get { return ConfigurationManager.AppSettings["imsHuaweiServerUserPassword"].ToString(); } }
54:
55: /// <summary/>
56: public class ImsBasicService
57: {
58: public string MgcIp;
59: public string MgcSecondaryIp;
60: public string MgcSubnetMask;
61: public int Service;
62: public string Fsdb;
63: public string PrimarySwitch;
64: }
65:
66: /// <summary/>
67: public static ImsBasicService[] ImsBasicServiceList =
68: {
69: new ImsBasicService { MgcIp="10.10.9.10", MgcSecondaryIp="10.10.13.10", MgcSubnetMask="255.255.248.0", Service=0, Fsdb=string.Empty, PrimarySwitch=string.Empty },
70: new ImsBasicService { MgcIp="10.10.13.10", MgcSecondaryIp="10.10.9.10", MgcSubnetMask="255.255.248.0", Service=0, Fsdb=string.Empty, PrimarySwitch=string.Empty },
71: new ImsBasicService { MgcIp="10.10.9.253", MgcSecondaryIp="10.10.13.253", MgcSubnetMask="255.255.248.0", Service=0, Fsdb=string.Empty, PrimarySwitch=string.Empty },
72: new ImsBasicService { MgcIp="10.10.9.254", MgcSecondaryIp="10.10.13.254", MgcSubnetMask="255.255.248.0", Service=0, Fsdb=string.Empty, PrimarySwitch=string.Empty },
73: new ImsBasicService { MgcIp="10.133.0.1", MgcSecondaryIp="10.133.13.1", MgcSubnetMask="255.255.248.0", Service=0, Fsdb=string.Empty, PrimarySwitch=string.Empty },
74: new ImsBasicService { MgcIp="10.16.5.142", MgcSecondaryIp="10.16.0.142", MgcSubnetMask="255.255.248.0", Service=0, Fsdb=string.Empty, PrimarySwitch=string.Empty },
75: };
76:
77: /// <summary/>
78: public static string SipSubscriberRegistrationPassword { get { return sipSubscriberRegistrationPassword; } }
79:
80: ////////////////////////////////////////////////////////////////////////////
81:
82: /// <summary>
83: ///
84: /// </summary>
85: public Ims()
86: {
87: }
88:
89: ////////////////////////////////////////////////////////////////////////////
90:
91: /// <summary>
92: /// Return the IMS basic service for given MGC IP
93: /// </summary>
94: public static ImsBasicService ImsBasicServiceItem(string mgcIp)
95: {
96: ImsBasicService imsBasicService;
97:
98: imsBasicService = (from ibs in ImsBasicServiceList where ibs.MgcIp == mgcIp select ibs).Single();
99:
100: return imsBasicService;
101: }
102:
103: ////////////////////////////////////////////////////////////////////////////
104:
105: /// <summary>
106: ///
107: /// </summary>
108: public static string ServiceToReadServiceData(ref int referenceIndex, out int itemIndex, out int listCount)
109: {
110: if (allPossibleServiceWithinHuaweiSwitchList.JustStartedOrRolledOver())
111: {
112: allPossibleServiceWithinHuaweiSwitchList = Ia.Ngn.Cl.Model.Data.Service.AllPossibleServiceNumberListWithinHuaweiSwitch;
113: }
114:
115: var service = allPossibleServiceWithinHuaweiSwitchList.Next(ref referenceIndex, out itemIndex, out listCount);
116:
117: return service.ToString();
118: }
119:
120: ////////////////////////////////////////////////////////////////////////////
121:
122: /// <summary>
123: ///
124: /// </summary>
125: public static void ReadSbrForService(Ia.Ngn.Cl.Model.Client.Huawei.Ims client, string service, out string result)
126: {
127: ReadUpdateSbrAndServiceForService(client, service, null, out result);
128: }
129:
130: ////////////////////////////////////////////////////////////////////////////
131:
132: /// <summary>
133: ///
134: /// </summary>
135: public static void ReadUpdateSbrAndServiceForService(Ia.Ngn.Cl.Model.Client.Huawei.Ims client, string service, string accessId, out string result)
136: {
137: bool sbrUpdated, owSbrUpdated, serviceSbrUpdated, serviceOwSbrUpdated;
138: string impuSipDomain;
139: Ia.Ngn.Cl.Model.Huawei.Owsbr owsbr;
140: Ia.Ngn.Cl.Model.Huawei.HuSbr sbr;
141:
142: result = "service: " + service + " ";
143:
144: sbr = client.LstSbr(service, out Client.Huawei.Ims.ResultCode lstSbrResultCode);
145:
146: if (lstSbrResultCode == Ia.Ngn.Cl.Model.Client.Huawei.Ims.ResultCode.OperationSucceeded
147: || lstSbrResultCode == Ia.Ngn.Cl.Model.Client.Huawei.Ims.ResultCode.TheSubscriberIsNotDefinedInTheHssOrAtsOrServiceDataIsNotConfiguredForTheSubscriber
148: || lstSbrResultCode == Ia.Ngn.Cl.Model.Client.Huawei.Ims.ResultCode.NoServiceData)
149: {
150: impuSipDomain = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.ImpuSipDomain(service);
151:
152: sbrUpdated = Ia.Ngn.Cl.Model.Data.Huawei.Ims.UpdateSbr(impuSipDomain, sbr, lstSbrResultCode);
153:
154: serviceSbrUpdated = Ia.Ngn.Cl.Model.Data.Huawei.Ims.UpdateServiceForSbr(impuSipDomain, accessId);
155:
156: owsbr = client.LstOwSbr(service, out Client.Huawei.Ims.ResultCode lstOwSbrResultCode);
157:
158: if (lstOwSbrResultCode == Ia.Ngn.Cl.Model.Client.Huawei.Ims.ResultCode.OperationSucceeded
159: || lstOwSbrResultCode == Ia.Ngn.Cl.Model.Client.Huawei.Ims.ResultCode.TheSubscriberIsNotDefinedInTheHssOrAtsOrServiceDataIsNotConfiguredForTheSubscriber
160: || lstOwSbrResultCode == Ia.Ngn.Cl.Model.Client.Huawei.Ims.ResultCode.NoServiceData)
161: {
162: owSbrUpdated = Ia.Ngn.Cl.Model.Data.Huawei.Ims.UpdateOwsbr(impuSipDomain, owsbr, lstSbrResultCode);
163: serviceOwSbrUpdated = Ia.Ngn.Cl.Model.Data.Huawei.Ims.UpdateServiceServiceSuspensionForOwsbr(impuSipDomain, out Ia.Cl.Model.Result result2);
164:
165: result += "sbr: " + lstSbrResultCode.ToString() + ", owsbr: " + lstOwSbrResultCode.ToString();
166: }
167: else
168: {
169: result += " error: owsbr: " + lstOwSbrResultCode.ToString();
170: }
171: }
172: else
173: {
174: result += " error: sbr: " + lstSbrResultCode.ToString();
175: }
176: }
177:
178: ////////////////////////////////////////////////////////////////////////////
179: ////////////////////////////////////////////////////////////////////////////
180: }
181:
182: ////////////////////////////////////////////////////////////////////////////
183: ////////////////////////////////////////////////////////////////////////////
184: }