mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-30 09:03:20 -05:00
1 line
40 KiB
JavaScript
1 line
40 KiB
JavaScript
|
function AmtStackCreateService(e){var E=new Object;E.wsman=e,E.pfx=["http://intel.com/wbem/wscim/1/amt-schema/1/","http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/","http://intel.com/wbem/wscim/1/ips-schema/1/"],E.PendingEnums=[],E.PendingBatchOperations=0,E.ActiveEnumsCount=0,E.MaxActiveEnumsCount=1,E.onProcessChanged=null;var t=0,n=0;function A(){var e=E.GetPendingActions();t<e&&(t=e),null!=E.onProcessChanged&&n!=e&&(n=e,E.onProcessChanged(e,t)),0==e&&(t=0)}function _(e){if(E.ActiveEnumsCount-=e,!(E.ActiveEnumsCount>=E.MaxActiveEnumsCount||0==E.PendingEnums.length)){var t=E.PendingEnums.shift();E.Enum(t[0],t[1],t[2]),_(0)}}function r(o){o.names.length<=o.current?o.callback(E,o.name,o.responses,200,o.tag):(E.wsman.ExecGet(E.CompleteName(o.names[o.current]),function(e,t,n,i){!function(e,t,n){null==t||200!=n?e.callback(E,e.name,null,n,e.tag):(e.responses[t.Header.Method]=t,r(e))}(o,n,i)},o.pri),o.current++),A()}function i(e,t,n,i,o){200==i&&"0"==n.Body.ReturnValue?E.AMT_MessageLog_GetRecords(n.Body.IterationIdentifier,390,l,o):o[0](E,null,o[2])}function l(e,t,n,i,o){if(200==i&&"0"==n.Body.ReturnValue){var r,c,a,s,u,d=o[2],S=new Date,A=n.Body.RecordArray;for(r in"string"==typeof A&&(n.Body.RecordArray=[n.Body.RecordArray]),A){s=null;try{s=window.atob(A[r])}catch(e){}if(null!=s&&0<(u=ReadIntX(s,0))&&u<4294967295){for(a={DeviceAddress:s.charCodeAt(4),EventSensorType:s.charCodeAt(5),EventType:s.charCodeAt(6),EventOffset:s.charCodeAt(7),EventSourceType:s.charCodeAt(8),EventSeverity:s.charCodeAt(9),SensorNumber:s.charCodeAt(10),Entity:s.charCodeAt(11),EntityInstance:s.charCodeAt(12),EventData:[],Time:new Date(1e3*(u+60*S.getTimezoneOffset()))},c=13;c<21;c++)a.EventData.push(s.charCodeAt(c));a.EntityStr=C[a.Entity],a.Desc=m(a.EventSensorType,a.EventOffset,a.EventData,a.Entity),a.EntityStr||(a.EntityStr="Unknown"),d.push(a)}}1!=n.Body.NoMoreRecords?E.AMT_MessageLog_GetRecords(n.Body.IterationIdentifier,390,l,[o[0],d,o[2]]):o[0](E,d,o[2])}else o[0](E,null,o[2])}E.GetPendingActions=function(){return 2*E.PendingEnums.length+E.ActiveEnumsCount+E.wsman.comm.PendingAjax.length+E.wsman.comm.ActiveAjaxCount+E.PendingBatchOperations},E.Subscribe=function(o,e,t,r,c,n,i,a,s,u){E.wsman.ExecSubscribe(E.CompleteName(o),e,t,function(e,t,n,i){A(),r(E,o,n,i,c)},0,n,i,a,s,u),A()},E.UnSubscribe=function(o,r,c,e,t){E.wsman.ExecUnSubscribe(E.CompleteName(o),function(e,t,n,i){A(),r(E,o,n,i,c)},0,e,t),A()},E.Get=function(o,r,c,e){E.wsman.ExecGet(E.CompleteName(o),function(e,t,n,i){A(),r(E,o,n,i,c)},0,e),A()},E.Put=function(o,e,r,c,t,n){E.wsman.ExecPut(E.CompleteName(o),e,function(e,t,n,i){A(),r(E,o,n,i,c)},0,t,n),A()},E.Create=function(o,e,r,c,t){E.wsman.ExecCreate(E.CompleteName(o),e,function(e,t,n,i){A(),r(E,o,n,i,c)},0,t),A()},E.Delete=function(o,e,r,c,t){E.wsman.ExecDelete(E.CompleteName(o),e,function(e,t,n,i){A(),r(E,o,n,i,c)},0,t),A()},E.Exec=function(o,e,t,r,c,n,i){E.wsman.ExecMethod(E.CompleteName(o),e,t,function(e,t,n,i){A(),r(E,o,E.CompleteExecResponse(n),i,c)},0,n,i),A()},E.ExecWithXml=function(o,e,t,r,c,n,i){E.wsman.ExecMethodXml(E.CompleteName(o),e,execArgumentsToXml(t),function(e,t,n,i){A(),r(E,o,E.CompleteExecResponse(n),i,c)},0,n,i),A()},E.Enum=function(r,c,e,t){E.ActiveEnumsCount<E.MaxActiveEnumsCount?(E.ActiveEnumsCount++,E.wsman.ExecEnum(E.CompleteName(r),function(e,t,n,i,o){A(),function(o,e,r,t,n,c){if(200!=n)return r(E,o,null,n,c),_(1);if(null==e||"EnumerateResponse"!=e.Header.Method||!e.Body.EnumerationContext)return r(E,o,null,603,c),_(1);var i=e.Body.EnumerationContext;E.wsman.ExecPull(t,i,function(e,t,n,i){!function o(r,e,c,t,a,n,s,i){if(200!=n)return c(E,r,null,n,s),void _(1);if(null==e||"PullResponse"!=e.Header.Method)return c(E,r,null,604,s),void _(1);for(var u in e.Body.Items)if(e.Body.Items[u]instanceof Array)for(var d in e.Body.Items[u])a.push(e.Body.Items[u][d]);else a.push(e.Body.Items[u]);if(e.Body.EnumerationContext){var S=e.Body.EnumerationContext;E.wsman.ExecPull(t,S,function(e,t,n,i){o(r,n,c,t,a,i,s,1)})}else _(1),c(E,r,a,n,s),A()}(o,n,r,t,[],i,c)})}(r,n,c,t,i,o)},e,t)):E.PendingEnums.push([r,c,e,t]),A()},E.Batc
|