Home directory for Malawi's wwwroot
Duncan Ewan
2021-02-19 beae6e0bf7ffeba3d49691a847fab778e5296ce5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<cfcomponent>
  <cffunction access="public" name="getMaxListDate" output="false" returntype="query" hint="Returns the max date from the fm_alm_list table">
    <cfquery name="getMaxListDate" datasource="tnis" password="webuser" username="webuser">
    select to_char(max(event_date),'YYYY-MM-DD HH24:MI:SS') maxdate from acc_alarm_733_list where nwtype = 'WCDMA' 
    </cfquery>
    <cfreturn getMaxListDate>
  </cffunction>
  <cffunction access="public" name="getCritAlarms" output="false" returntype="query" hint="Returns the critical network alarms">
    <cfquery name="getCritAlarms" datasource="tnis" password="webuser" username="webuser">
    select substr(ne,1,350) ne,substr(alarm,1,350) alarm,substr(ref,1,350) ref,substr(arsoutage,1,350) arsoutage,substr(tmosoutage,1,350) tmosoutage,substr(resource_group,1,350) resource_group,replace(replace(ptxt,chr(10),chr(13)),chr(34),' ') ptxt,substr(engineer,1,350) engineer,substr(phone,1,350) phone from v_fma_critical
    </cfquery>
    <cfreturn getCritAlarms>
  </cffunction>
  <cffunction access="public" name="getCellSupervision" output="false" returntype="query" hint="Returns A1 & A2 Cell Supervision Alarms">
    <cfargument name="bsc" type="string" required="no">
    <cfif IsDefined("bsc") and bsc neq "">
      <cfset session.bsc = "#Ucase(bsc)#">
      <cfset bscno = #ListLen(session.bsc)#>
      <cfelse>
      <cfset session.bsc = "">
    </cfif>
    <cfset yourTimeSpan = CreateTimeSpan(0,0,0,30)>
    <cfquery name="getCellSupervision" datasource="TNIS" username="NCC_REPORT" password="NCC_REPORT" cachedwithin="#yourTimeSpan#" >
    SELECT siteid, sitename, bsc, ref, fault_reason, isd_ref, status, outage, last_update, inception_time, severity, update_time_exp, tmn.getpriority_text (tmn.getpriority (siteid)) priority, tmn.getxalarms (siteid) xalarms, remedy.getplanned (siteid) planned, remedy.iscoallink (siteid) coallink, remedy.is_icc (siteid) specialevent, remedy.upd_time_expired (REF) updaterequired FROM tmn.v_fma_cellstatus
    <cfif #session.bsc# neq "" >
      WHERE
    </cfif>
    <cfif #session.bsc# neq "">
      <cfif bscno eq 1>
        bsc LIKE '%#bsc#%'
        <cfelse>
        bsc LIKE '%#ListFirst(session.bsc)#%'
        <cfloop from="2" to="#bscno#" index="Counter">
          or bsc LIKE '%#ListGetAt(session.bsc, Counter)#%'
        </cfloop>
      </cfif>
    </cfif>
    order by last_update,priority desc
    </cfquery>
    <cfreturn getCellSupervision>
  </cffunction>
  <cffunction access="public" name="getCommands" output="false" returntype="query" hint="Returns Commands send to network elements">
    <cfargument name="cmdtext" type="string" required="yes">
    <cfargument name="paratext" type="string" required="yes">
    <cfargument name="date1" type="string" required="yes">
    <cfargument name="date2" type="string" required="yes">
    <cfargument name="ne" type="string" required="no">
    <cfargument name="type" type="string" required="no">
    <cfquery name="getCommands" datasource="tnis" username="webuser" password="webuser">
    SELECT ne, substr(cmd,1,100)||'<br>'||substr(cmd,101,length(cmd)-100) cmd, to_char(datum,'YYYY-MM-DD HH24:MI:SS') datum, username, cmd_type FROM command.v_all_cmd WHERE SUBSTR (cmd, 1, 5) LIKE '#cmdtext#' AND SUBSTR (cmd, 6) LIKE '%#paratext#%' AND datum BETWEEN TO_DATE ('#date1#', 'yyyy-mm-dd HH24:MI:SS') AND TO_DATE ('#date2#', 'yyyy-mm-dd HH24:MI:SS')
    <cfif ne neq "">
      AND ne = '#ne#'
    </cfif>
    <cfif type neq "">
      AND cmd_type = '#type#'
    </cfif>
    ORDER by datum desc
    </cfquery>
    <cfreturn getCommands>
  </cffunction>
    <cffunction access="public" name="getNodeNames" output="false" returntype="query" hint="Returns the node names">
    <cfquery name="getNodeNames" datasource="tnis" password="webuser" username="webuser">
    select nodename from axe_node WHERE type not in ('SDP','BGW') order by nodename
    </cfquery>
    <cfreturn getNodeNames>
  </cffunction>
  <cffunction access="public" name="getARSWorkLog" output="false" returntype="query" hint="Returns ars worklog">
    <cfargument name="ref" type="string" required="yes">
    <cfquery name="getARSWorklog" datasource="tnis">
        select replace(fault_work_log,chr(13),'<br/>') fault_work_log 
        from v_nwm_faultlog_all 
        where ref = '#ref#'
    </cfquery>
    <cfreturn getARSWorklog>
  </cffunction>
  <cffunction access="public" name="getPlannedAnchorLog" output="false" returntype="query" hint="Returns ars planned anchor worklog">
    <cfargument name="siteid" type="string" required="yes">
    <cfquery name="getPlannedAnchorLog" datasource="tnis" username="tmn" password="rainydays">
        SELECT '<a href="worklog.cfm?value='||REF||'&setting=ref">'||REF||'</a><br/>' REF
          FROM mtn_eventlog
         WHERE status = 0
           AND (event LIKE '%PLANNED%' OR event_category LIKE '%PLANNED%')
           AND (t_number = '#siteid#')
    </cfquery>
    <cfreturn getPlannedAnchorLog>
  </cffunction>
  <cffunction access="public" name="getPlannedLogCount" output="false" returntype="query" hint="Returns ars planned worklog count">
    <cfargument name="siteid" type="string" required="yes">
    <cfquery name="getPlannedLogCount" datasource="tnis" username="tmn" password="rainydays">
        SELECT COUNT (*) COUNT
          FROM mtn_eventlog
         WHERE status = 0
           AND (event LIKE '%PLANNED%' OR event_category LIKE '%PLANNED%')
           AND (t_number = '#siteid#')
    </cfquery>
    <cfreturn getPlannedLogCount>
  </cffunction>
  <cffunction access="public" name="getPlannedLog" output="false" returntype="query" hint="Returns ars planned worklog">
    <cfargument name="siteid" type="string" required="yes">
    <cfquery name="getPlannedLog" datasource="tnis" username="tmn" password="rainydays">
        SELECT REF
          FROM mtn_eventlog
         WHERE status = 0
           AND (event LIKE '%PLANNED%' OR event_category LIKE '%PLANNED%')
           AND (t_number = '#siteid#')
    </cfquery>
    <cfreturn getPlannedLog>
  </cffunction>
 
    <cffunction name="getAlarmsBySeverityJSON" access="remote" returntype="struct" output="no" returnformat="json" >
        <!--- <cfset hasAdminRights = ListContainsNoCase(session.userRoles,"ACC_ADMINISTRATOR",",")> --->
        <cfset hasAdminRights = 1>
        <cfset hasRights = hasAdminRights or isAllowedUser or isAllowedAdmin>
 
        <cfif hasRights> <!--- START "hasRights" --->
 
            <cfset var NodeBytesSentStruct = StructNew()/>
            <cfset NodeBytesSentStruct.status = true />
 
            <cftry>
                <cfquery name="getNodeBytesSentQuery" datasource="accdb" result="getDomainCntQueryResult">
                SELECT
                    round(ksink.remedy_pkg.asnumdate(sdate), 0) sdate,
                    severity,
                    COUNT(*) AS events
                FROM
                    (
                        SELECT
                            trunc(event_time, 'HH24')        AS sdate,
                            upper(perceived_severity)     AS severity
                        FROM
                            acc_alarm_733_list
                        WHERE
                            event_time > sysdate - 2
                    ) a
                GROUP BY
                    sdate,
                    severity
                ORDER BY
                    sdate,
                    severity
                </cfquery>
 
                <cfset var NodeBytesSentRecord = arrayNew(1)/>
                <cfset var NodeBytesSentStruct = StructNew()/>
                <cfset NodeBytesSentStruct.status = true />
 
                <cfloop query="getNodeBytesSentQuery" > <!--- START Loop "getNodeBytesSentQuery"--->
                <cfset var NodeBytesSentTmp = arrayNew(1)/>
                    <cfset ArrayAppend(NodeBytesSentRecord, { sdate = getNodeBytesSentQuery.sdate, severity = getNodeBytesSentQuery.severity, events = getNodeBytesSentQuery.events })>
                </cfloop> <!--- END Loop "getNodeBytesSentQuery"--->
                <!--- <cfset DomainCntStruct.data = serializeJSON(NodeBytesSentRecord) /> --->
                <cfset DomainCntStruct.data = NodeBytesSentRecord />
 
                <cfcatch type="any">
                    <cfset DomainCntStruct.status = false />
 
                    <cfif isdefined('cfcatch.sql')>
                        <cflog text="insertConfigItems: #cfcatch.message#; #cfcatch.detail#; #cfcatch.sql#">
                        <cfset DomainCntStruct["SQL"] = cfcatch.sql />
                    <cfelse>
                        <cflog text="insertConfigItems: #cfcatch.message#; #cfcatch.detail#;">
                    </cfif>        
                    <cfset DomainCntStruct["Result"] = "ERROR" />
                    <cfset DomainCntStruct["Message"] = cfcatch.message />
                    <cfset DomainCntStruct["Detail"] = cfcatch.detail />
                </cfcatch>
            </cftry>
        <cfelse> <!--- MIDDLE "hasRights" --->
            <cfset DomainCntStruct.status = false />
            <cfset DomainCntStruct.reason = 'You do not have the required permissions' />
        </cfif> <!--- END "hasRights" --->
 
        <cfreturn DomainCntStruct>
    </cffunction>
</cfcomponent>