60d1dbd42ecb1187c5821c18c630cd95c6ab8c59.svn-base 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. $(function () {
  2. 'use strict';
  3. // 디버깅 모드 설정(자동로그인 관련)
  4. //var debug = true;
  5. var debug = false;
  6. var eq = BWA.DataUtil.constructEqualFilter;
  7. // 로그인 후 이동하게될 화면 설정
  8. //var viewAfterLogin = 'ExecutionSchedule';
  9. var siteid = ko.observable(''),
  10. id = ko.observable(''),
  11. password = ko.observable(''),
  12. checkSaveId = ko.observable(false),
  13. disabledLoginButton = ko.observable(false),
  14. disabledIdTextBox = ko.observable(false),
  15. disabledPasswordTextBox = ko.observable(false),
  16. disabledCheckSaveId = ko.observable(false);
  17. var menuDataSource = BWA.db.createDataSource('CmMenu');
  18. var overlayOptions = {
  19. width: '100%',
  20. height: '100%',
  21. visible: ko.observable(false),
  22. animation: null,
  23. shading: true,
  24. showingAction: function () {
  25. BWA.UserPanel.hide();
  26. },
  27. shownAction: function () {
  28. if (BemsWebApplication.config.siteenable) {
  29. $('#imageId').attr('src', '/Images/Login/intro_login_box_2.png');
  30. document.getElementById("userId").className = "login_id_area_content2";
  31. document.getElementById("userPassword").className = "login_pw_area_content2";
  32. }
  33. else {
  34. $('#imageId').attr('src', '/Images/Login/intro_login_box.png');
  35. document.getElementById("userId").className = "login_id_area_content";
  36. document.getElementById("userPassword").className = "login_pw_area_content";
  37. }
  38. },
  39. contentReadyAction: function (e) {
  40. BWA.LoginOverlay.handleCheckSaveId();
  41. }
  42. };
  43. function handleLoginFail(error) {
  44. utils.toast.show('로그인에 실패하였습니다.', 'error');
  45. }
  46. function updateMenuHide(vid) {
  47. _.each($SideMenu.sideMenuSet, function (items, id) {
  48. (function MenuHide(array, id, exelement) {
  49. _.each(array, function (element) {
  50. if (element.viewId == (typeof (vid) == "object" ? vid.MenuId() : vid)) {
  51. element.show(false);
  52. if (exelement != null) {
  53. if (exelement.subMenus != null) {
  54. var cnt = 0;
  55. for (var i = 0; i < exelement.subMenus.length; i++) {
  56. if (exelement.subMenus[i].show() == false) {
  57. cnt++;
  58. if (exelement.subMenus.length == cnt) {
  59. exelement.show(false);
  60. }
  61. }
  62. }
  63. }
  64. }
  65. return;
  66. }
  67. if (element.subMenus) {
  68. return MenuHide(element.subMenus, (typeof (vid) == "object" ? vid.MenuId() : vid), element);
  69. }
  70. });
  71. })(items, id);
  72. })
  73. }
  74. //2018 02 19 hcLee
  75. function initMenu() {
  76. _.each($SideMenu.sideMenuSet, function (items, id) {
  77. (function MenuShow(array, id) {
  78. _.each(array, function (element) {
  79. element.show(true);
  80. if (element.subMenus) {
  81. return MenuShow(element.subMenus, id);
  82. }
  83. });
  84. })(items, id);
  85. })
  86. }
  87. function handleAfterTryLogin() {
  88. disabledLoginButton(false);
  89. disabledIdTextBox(false);
  90. disabledPasswordTextBox(false);
  91. disabledCheckSaveId(false);
  92. BWA.LoadIndicator.promiseAlways();
  93. }
  94. BWA.LoginOverlay = {
  95. handleCheckSaveId: function () {
  96. $('.intro_login_container').parent().parent().css('z-index', 3000);
  97. //checkSaveId(false);
  98. checkSaveId($.cookie('checkSaveId') == "true" ? true : false);
  99. if (checkSaveId()) {
  100. var cookieId = $.cookie('id');
  101. id(cookieId);
  102. var cookiesiteId = $.cookie('siteid');
  103. siteid(cookiesiteId);
  104. }
  105. else {
  106. var cookieId = "";
  107. id(cookieId);
  108. siteid(cookieId);
  109. }
  110. if (debug) {
  111. id('admin');
  112. password('kanu123');
  113. //id('lee');
  114. //password('lee');
  115. }
  116. },
  117. overlayOptions: overlayOptions,
  118. getsiteIdTextBoxOptions: function () {
  119. if (BemsWebApplication.config.siteenable) {
  120. return {
  121. value: siteid,
  122. disabled: disabledIdTextBox,
  123. visible: true,
  124. placeholder: ' siteID', //placeholder: $G('id'),
  125. };
  126. }
  127. else {
  128. return {
  129. value: siteid,
  130. disabled: disabledIdTextBox,
  131. visible: false,
  132. placeholder: ' siteID', //placeholder: $G('id'),
  133. };
  134. }
  135. },
  136. getIdTextBoxOptions: function () {
  137. return {
  138. value: id,
  139. disabled: disabledIdTextBox,
  140. // cyim 2016.02.17 : 로그인화면 작업
  141. placeholder: ' username', //placeholder: $G('id'),
  142. // hcLee 2016 01 25 크롬은 문제없으나 IE 8,9,10에서는 동작안하는 버그 떄문에 직접코드 체크로 변경함
  143. /*enterKeyAction: function (e) {
  144. BWA.LoginOverlay.handleLoginButton();*/
  145. onKeyPress: function (e) {
  146. if (e.jQueryEvent.charCode == 13)
  147. BWA.LoginOverlay.handleLoginButton();
  148. }
  149. };
  150. },
  151. getPasswordTextBoxOptions: function () {
  152. return {
  153. value: password,
  154. disabled: disabledPasswordTextBox,
  155. mode: 'password',
  156. // cyim 2016.02.17 : 로그인화면 작업
  157. placeholder: ' password',//placeholder: $G('password'),
  158. // hcLee 2016 01 25 크롬은 문제없으나 IE 8,9,10에서는 동작안하는 버그 떄문에 직접코드 체크로 변경함
  159. /*enterKeyAction: function (e) {
  160. BWA.LoginOverlay.handleLoginButton();*/
  161. onKeyPress: function (e) {
  162. //if (e.jQueryEvent.char == '\n') { onKeyDown or onKeyUp의 경우는 이렇게
  163. if (e.jQueryEvent.charCode == 13) {
  164. $('#loginbtn').focus();
  165. BWA.LoginOverlay.handleLoginButton();
  166. //$('#userPassword').focus();
  167. }
  168. }
  169. };
  170. },
  171. getCheckBoxOptions: function () {
  172. return {
  173. value: checkSaveId,
  174. disabled: disabledCheckSaveId
  175. };
  176. },
  177. getButtonOptions: function () {
  178. return {
  179. // cyim 2016.02.17 : 로그인화면 작업 (이미지로 대체함)
  180. //icon: 'key',
  181. //text: $G('login'),
  182. disabled: disabledLoginButton,
  183. clickAction: BWA.LoginOverlay.handleLoginButton
  184. };
  185. },
  186. GetClientIP: function () {
  187. //return "127.0.0.1";
  188. /* node js
  189. require('dns').lookup(require('os').hostname(), function (err, add, fam) {
  190. //console.log('addr: ' + add);
  191. alert(add);
  192. })*/
  193. //alert(ko.observable(data.IpAddress));
  194. //return "127.0.0.1";
  195. var dfd = $.Deferred();
  196. var urlHeader = BemsWebApplication.config.endpoints.api[BemsWebApplication.config.mode];
  197. /*$.get("http://ipinfo.io", function(response) {
  198. //console.log(response.city, response.region, response.country);
  199. return dfd.resolve(true, response.ip);
  200. }, "jsonp");*/
  201. $.get(urlHeader + "/ClientAccess/ClientIpAddress", function (response) {
  202. if (response.ip === '::1') {
  203. response.ip = '127.0.0.1';
  204. }
  205. //console.log(response.city, response.region, response.country);
  206. return dfd.resolve(true, response.ip);
  207. });
  208. return dfd.promise();
  209. /*
  210. $.when($.get("http://ipinfo.io", function (response){return response.ip;
  211. }, "jsonp"))
  212. .done(function (ip) {
  213. return ip;
  214. });*/
  215. /*
  216. var xmlhttp;
  217. if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
  218. else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  219. xmlhttp.open("GET", "http://api.hostip.info/get_html.php", false);
  220. xmlhttp.send();
  221. var hostipInfo = xmlhttp.responseText.split("n");
  222. //for (var i=0; hostipInfo.length >= i; i++) {
  223. var ipAddress = hostipInfo[hostipInfo.length - 1].split(": ");
  224. //if ( ipAddress[0] == "IP" ) return ipAddress[1];
  225. var IP = ipAddress[1].split('\n');
  226. return IP[0]; */
  227. },
  228. handleLogoutButton: function () {
  229. // 로그아웃 히스토리 기록
  230. var loginHistoryModel = new BemsWebApplication.CmUserLoginHistoryViewModel();
  231. loginHistoryModel.SiteId = BWA.UserInfo.SiteId;
  232. loginHistoryModel.UserId = BWA.UserInfo.UserId;
  233. loginHistoryModel.Type('Log-Off');
  234. loginHistoryModel.TraceTime(new Date());
  235. //hcLee 2015 11 13
  236. //loginHistoryModel.IpAddress(BWA.LoginOverlay.GetClientIP());
  237. $.when(BWA.LoginOverlay.GetClientIP()).done(function (result, ip) {
  238. loginHistoryModel.IpAddress(ip);
  239. BWA.db.CmUserLoginHistory.insert(loginHistoryModel.toJS());
  240. BWA.UserInfo.logout();
  241. if (!checkSaveId()) //2018 03 31 hcLee
  242. {
  243. $.removeCookie('id');
  244. $.removeCookie('siteId');
  245. }
  246. $.removeCookie('password');
  247. $.removeCookie('fromCenter')
  248. clearInterval(BemsWebApplication.app.timer); // hcLee 2015 08 07
  249. //2015 10 28 hcLee 초기화 문제 해결
  250. //alert(Request.UserHostAddress);
  251. //alert(BWA.LoginOverlay.GetClientIP());
  252. //2018 03 31 hcLee
  253. location.reload();
  254. //window.
  255. //location.
  256. /*
  257. BWA.app.navigate('Login');
  258. BWA.LoginOverlay.handleCheckSaveId();*/
  259. });
  260. },
  261. handleLoginButton: function () {
  262. var siteId;
  263. if (BemsWebApplication.config.siteenable) {
  264. siteId = parseInt(siteid());
  265. }
  266. else {
  267. siteId = BemsWebApplication.config.siteId;
  268. }
  269. if (BWA.config["center-mode"]) {
  270. if ($.cookie('fromCenter')) {
  271. var userId = $.cookie('id');
  272. var userPassword = $.cookie('password');
  273. siteId = $.cookie('siteId') * 1;
  274. if (userId) id(userId);
  275. if (userPassword) password(userPassword);
  276. if (siteId) siteid(siteId);
  277. }
  278. }
  279. BWA.UserInfo.IsLogin(false);
  280. //alert(password());
  281. if (BemsWebApplication.config.siteenable) {
  282. if (_.isEmpty(siteid())) {
  283. utils.toast.show('사이트 아이디를 입력하여 주십시오.', 'error');
  284. $('#siteId').focus();
  285. return;
  286. }
  287. }
  288. if (_.isEmpty(id())) {
  289. utils.toast.show('아이디를 입력하여 주십시오.', 'error');
  290. $('#userId').focus();
  291. return;
  292. }
  293. if (_.isEmpty(password())) {
  294. utils.toast.show('비밀번호를 입력하여 주십시오.', 'error');
  295. $('#userPassword').focus();
  296. return;
  297. }
  298. $.cookie('checkSaveId', checkSaveId());
  299. if (checkSaveId()) {
  300. $.cookie('id', id());
  301. $.cookie('siteid', siteid());
  302. }
  303. disabledLoginButton(true);
  304. disabledIdTextBox(true);
  305. disabledPasswordTextBox(true);
  306. disabledCheckSaveId(true);
  307. var userDataSource = BWA.DataUtil.createDataSource({
  308. dataSourceOptions: {
  309. select: [
  310. 'SiteId', 'UserId', 'CompanyId', 'DepartmentId', 'PositionId', 'Name', 'Email', 'UserGroupId', 'BusinessFieldId', 'EmploymentStatus',
  311. 'CmCompany/Name', 'CmDepartment/Name', 'CmPosition/Name', 'CmBusinessField/Name', 'CmUserGroup/Name'
  312. ],
  313. expand: ['CmCompany', 'CmDepartment', 'CmPosition', 'CmBusinessField', 'CmUserGroup'],
  314. extendOptions: {
  315. alterNames: {
  316. 'CmCompany/Name': 'CompanyName',
  317. 'CmDepartment/Name': 'DepartmentName',
  318. 'CmPosition/Name': 'PositionName',
  319. 'CmBusinessField/Name': 'BusinessFieldName',
  320. 'CmUserGroup/Name': 'UserGroupName',
  321. }
  322. }
  323. }
  324. }, 'CmUser');
  325. var userGroupPermissionDataSource = BWA.db.createDataSource('CmUserGroupPermission');
  326. // hcLee 2018 02 23
  327. var chartInfoDataSource = BWA.db.createDataSource('BemsChartInfo');
  328. var eq = BWA.DataUtil.constructEqualFilter;
  329. var and = BWA.DataUtil.andFilter;
  330. if (BemsWebApplication.config.siteenable) {
  331. userDataSource.filter([
  332. eq('SiteId', siteId), // hcLee 2016 06 09 수정
  333. 'and',
  334. eq('UserId', id()),
  335. 'and',
  336. eq('Passwd', password()),
  337. ]);
  338. }
  339. else {
  340. userDataSource.filter([
  341. [eq('SiteId', BemsWebApplication.config.siteId), 'or', eq('SiteId', 0)], // hcLee 2016 06 09 수정
  342. 'and',
  343. eq('UserId', id()),
  344. 'and',
  345. eq('Passwd', password()),
  346. ]);
  347. }
  348. BWA.LoadIndicator.show();
  349. userDataSource.load().done(function (user) {
  350. if (_.isEmpty(user)) {
  351. utils.toast.show('로그인에 실패하였습니다. 아이디 혹은 비밀번호가 다릅니다.', 'error');
  352. password("");
  353. return;
  354. }
  355. user = user[0];
  356. if (user.EmploymentStatus() == 2 || user.EmploymentStatus() == 3) {
  357. utils.toast.show('휴직/퇴사 사용자는 시스템에 로그인 할 수 없습니다.', 'error');
  358. return;
  359. }
  360. userGroupPermissionDataSource.filter([
  361. eq('SiteId', user.SiteId()),
  362. and,
  363. eq('UserGroupId', user.UserGroupId()),
  364. ]);
  365. // hcLee 2018 02 23
  366. chartInfoDataSource.filter([eq('SiteId', user.SiteId()), and, eq('UseChart', true)]);
  367. $.when(userGroupPermissionDataSource.load(), chartInfoDataSource.load()
  368. ).done(function (dbMenuPermissions, chartInfos) {
  369. //userGroupPermissionDataSource.load().done(function (dbMenuPermissions) {
  370. BWA.DataUtil.copyViewModel(user, BWA.UserInfo);
  371. BWA.UserInfo.chartInfo(chartInfos[0]);
  372. BWA.UserInfo.MenuPermissions(_.map(dbMenuPermissions[0], function (x) {
  373. return {
  374. MenuId: x.MenuId(),
  375. MenuPermission: x.MenuPermission()
  376. };
  377. }));
  378. // hcLee 2016 06 09
  379. if (BWA.UserInfo.SiteId() == 0) {
  380. BWA.UserInfo.IsCenter(true);
  381. //BWA.UserInfo.SiteId(1);
  382. }
  383. var CmSite = BemsWebApplication.db.createDataSource('CmSite');
  384. CmSite.filter([
  385. ['SiteId', '=', BWA.UserInfo.SiteId()]
  386. ]);
  387. CmSite.load().done(function (result) {
  388. var dataArray = [];
  389. _.each(result, function (x) {
  390. dataArray.push({
  391. SiteName: x.Name()
  392. });
  393. BWA.Desktop.SiteName = dataArray[0].SiteName;
  394. $('#site-name').html(dataArray[0].SiteName);
  395. $('#version-name').html(BemsWebApplication.config.Version);
  396. });
  397. });
  398. overlayOptions.visible(false);
  399. utils.toast.show('로그인에 성공하였습니다.');
  400. id("");
  401. password("");
  402. BWA.Code.PurchaseProgress.load();
  403. BWA.UserInfo.IsLogin(true);
  404. // 로그인 히스토리 기록
  405. var loginHistoryModel = new BemsWebApplication.CmUserLoginHistoryViewModel();
  406. loginHistoryModel.SiteId = BWA.UserInfo.SiteId;
  407. loginHistoryModel.UserId = BWA.UserInfo.UserId;
  408. loginHistoryModel.Type('Log-On');
  409. loginHistoryModel.TraceTime(new Date());
  410. //2015 11 13 hcLee
  411. //loginHistoryModel.IpAddress(BWA.LoginOverlay.GetClientIP());
  412. $.when(BWA.LoginOverlay.GetClientIP()).done(function (result, ip) {
  413. loginHistoryModel.IpAddress(ip);
  414. BWA.db.CmUserLoginHistory.insert(loginHistoryModel.toJS());
  415. var siteDataSource = BemsWebApplication.db.createDataSource('CmSite', true);
  416. var eq = BWA.DataUtil.constructEqualFilter;
  417. siteDataSource.filter([
  418. eq('SiteId', BWA.UserInfo.SiteId()),
  419. ]);
  420. var bAutoControl;
  421. siteDataSource.load().done(function (site) {
  422. //if (_.isEmpty(site) || site[0].IsControlSchedule() == false) {
  423. if (_.isEmpty(site)) return;
  424. bAutoControl = site[0].IsControlSchedule();
  425. // hcLee 공조기 제어 팝업
  426. //BWA.ControlPanel.show();
  427. BemsWebApplication.app.timer = setInterval(function () {
  428. var now = new Date();
  429. //if (bAutoControl == false && now.getHours () == site[0].ScheduleCheckHour() && (now.getMinutes() == 0) && (now.getSeconds() == 0)) {
  430. // 2016 06 21 두소장과 협의, 플래그가 true면 수동 제어 팝업, 스케줄 자동제어는 플래그 상관없이 동작 안하도록 막음
  431. if (bAutoControl == true && now.getHours() == site[0].ScheduleCheckHour() && (now.getMinutes() == 0) && (now.getSeconds() == 0)) {
  432. BWA.ControlPanel.show();
  433. }
  434. /* 제어팝업 데모 때문에 막음 2015 12 09
  435. if (bAutoControl == true && (now.getMinutes() == site[0].ScheduleCheckHour()) && BWA.UserInfo.IsScheduleUser() && (now.getSeconds() == 0)) {
  436. BWA.ControlPanel.show();
  437. }*/
  438. }, 1000);
  439. });
  440. initMenu(); //2018 02 19 hcLee
  441. //$SideMenu.sideMenuSet = [];
  442. /*
  443. if ($SideMenu.sideMenuSet.navConfiguration != undefined)
  444. delete $SideMenu.sideMenuSet.navConfiguration;*/
  445. //BWA.SetMenunavConfiguration();
  446. //BWA.SetMenunavMaterial();
  447. //$SideMenu.showSideMenuIfWill();
  448. // 2018 01 19 hcLee, admin이 아니면 메뉴설정은 안보인다.
  449. //if (BWA.UserInfo.UserId() != "admin")
  450. // 20190828 admin 계정을 제외한 사용자 정보 확인 페이지 차단
  451. if (BWA.UserInfo.UserId() == "admin")
  452. menuDataSource.filter([
  453. eq('SiteId', BWA.UserInfo.SiteId()),
  454. and,
  455. eq('Used', false)
  456. ]);
  457. else {
  458. menuDataSource.filter([
  459. eq('SiteId', BWA.UserInfo.SiteId()),
  460. and,
  461. [eq('Used', false), 'or', eq('MenuId', 'UserCheck')]
  462. ]);
  463. }
  464. menuDataSource.load().done(function (hideMenus) {
  465. $.each(hideMenus, function (i, item) {
  466. updateMenuHide(item);
  467. });
  468. if (BWA.UserInfo.UserId() != "admin") updateMenuHide('SetMenu');
  469. if (BWA.UserInfo.UserId() != "admin") updateMenuHide('SetChart');
  470. if (BWA.config['BemsFmsMode'] != 0) {
  471. if ($("#mode_button").dxButton("instance") != null) {
  472. $("#mode_button").dxButton("instance").option("visible", false);
  473. }
  474. } else {
  475. if ($("#mode_button").dxButton("instance") != null) {
  476. $("#mode_button").dxButton("instance").option("visible", true);
  477. }
  478. }
  479. if (BWA.config['BemsFmsMode'] == 2) {
  480. BWA.BemsFmsMode.setBemsMode(false);
  481. BWA.app.navigate('FacilityTaskReport');
  482. } else {
  483. BWA.BemsFmsMode.setBemsMode('bems');
  484. BWA.app.navigate('MainDashboard');
  485. }
  486. });
  487. });
  488. // 알람 정보를 출력하자
  489. if (BemsWebApplication.config.control) {
  490. AlarmLog();
  491. SetAlarmInfo();
  492. }
  493. }).fail(handleLoginFail).always(handleAfterTryLogin);
  494. }).fail(handleLoginFail).always(handleAfterTryLogin);
  495. },
  496. isVisible: function () {
  497. return overlayOptions.visible();
  498. },
  499. show: function () {
  500. overlayOptions.visible(true);
  501. }
  502. };
  503. // 알람 로그
  504. var alarm_image = false;
  505. // 알람 정보를 출력하자
  506. function SetAlarmInfo() {
  507. // 1초에 한번 TICK
  508. var alarm_timer = setInterval(function () {
  509. var now = new Date();
  510. var minute = now.getMinutes();
  511. var second = now.getSeconds();
  512. if (((minute == 1) || (minute == 16) || (minute == 31) || (minute == 46)) && (second == 10)) {
  513. // 팝업이 열려 있으면 닫았다가 다시 열자
  514. $("#PopupAlarm").dxPopup('instance').option('visible', false);
  515. // 알람 로그
  516. AlarmLog();
  517. }
  518. // 알람이 존재한다
  519. if (BWA.AlarmInfo.Alarm_Image_Change() == true) {
  520. if (alarm_image == false) {
  521. $("#alarm_button").dxButton("instance").option("type", "danger");
  522. alarm_image = true;
  523. }
  524. else {
  525. $("#alarm_button").dxButton("instance").option("type", "normal");
  526. alarm_image = false;
  527. }
  528. }
  529. else // 알람이 없다(알람 해제 실행시)
  530. {
  531. if ($("#alarm_button").dxButton("instance") != null) {
  532. $("#alarm_button").dxButton("instance").option("type", "normal");
  533. }
  534. alarm_image = false;
  535. }
  536. }, 1000);
  537. }
  538. function AlarmLog() {
  539. var BemsAlarmLogDataSource = BemsWebApplication.DataUtil.createDataSource({
  540. dataSourceOptions: {
  541. select: [
  542. 'CreatedDateTime', 'BemsAlarmSetting/FacilityName', 'BemsAlarmSetting/PointName', 'CurrentValue', 'BemsAlarmSetting/UpperLimit', 'BemsAlarmSetting/LowerLimit', 'SMSResult', 'EmailResult',
  543. 'SiteId', 'FacilityTypeId', 'FacilityCode', 'PropertyId', 'FormulaId'
  544. ],
  545. expand: ['BemsAlarmSetting'],
  546. extendOptions: {
  547. forceOriginalField: true,
  548. alterNames: {
  549. 'BemsAlarmSetting/FacilityName': 'FacilityName',
  550. 'BemsAlarmSetting/PointName': 'PointName',
  551. 'BemsAlarmSetting/UpperLimit': 'UpperLimit',
  552. 'BemsAlarmSetting/LowerLimit': 'LowerLimit'
  553. }
  554. },
  555. filter: [
  556. ['SiteId', '=', BWA.UserInfo.SiteId()],
  557. 'and',
  558. ['Conform', '=', false]
  559. ]
  560. }
  561. }, 'BemsAlarmLog');
  562. BemsAlarmLogDataSource.load().done(function (result) {
  563. if (result.length > 0) BWA.AlarmInfo.Alarm_Image_Change = true;
  564. else BWA.AlarmInfo.Alarm_Image_Change = false;
  565. var DataArrayInfo = [];
  566. _.each(result, function (x) {
  567. var temp = '';
  568. if (x.FormulaId() != 0) {
  569. temp = '성능분석';
  570. }
  571. else {
  572. if (x.FacilityTypeId() == 99) {
  573. temp = '가상시설';
  574. }
  575. else {
  576. temp = '일반시설';
  577. }
  578. }
  579. DataArrayInfo.push({
  580. CreatedDateTime: x.CreatedDateTime,
  581. Type: temp,
  582. FacilityName: x.FacilityName,
  583. PropertyName: x.PointName,
  584. CurrentValue: x.CurrentValue,
  585. UpperLimit: x.UpperLimit,
  586. LowerLimit: x.LowerLimit,
  587. SMSResult: x.SMSResult,
  588. EmailResult: x.EmailResult,
  589. Check: "확인",
  590. SiteId: x.SiteId,
  591. FacilityTypeId: x.FacilityTypeId,
  592. FacilityCode: x.FacilityCode,
  593. PropertyId: x.PropertyId,
  594. FormulaId: x.FormulaId
  595. });
  596. });
  597. //$("#gridContainer").dxDataGrid("instance").option("dataSource", DataArrayInfo);
  598. if (result.length > 0) // 알람 정보가 있을때만 팝업 출력
  599. {
  600. $("#PopupAlarm").dxPopup('instance').option('visible', true);
  601. }
  602. })
  603. }
  604. });