2dd958d071d7b01621dfc102374061cca938b13a.svn-base 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /// <reference path="../js/jquery-1.11.1.min.js" />
  2. /// <reference path="../js/knockout-3.1.0.js" />
  3. /// <reference path="../js/dx.all.js" />
  4. (function() {
  5. var endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints);
  6. var serviceConfig = $.extend(true, {}, BemsWebApplication.config.services, {
  7. db: {
  8. url: endpointSelector.urlFor("db"),
  9. // To enable JSONP support, uncomment the following line
  10. //jsonp: !window.WinJS,
  11. // To allow cookies and HTTP authentication with CORS, uncomment the following line
  12. // withCredentials: true,
  13. errorHandler: handleServiceError
  14. }
  15. });
  16. function handleServiceError(error) {
  17. var message = '알 수 없는 오류';
  18. if (window.WinJS) {
  19. try {
  20. message = error.message;
  21. } catch (e) {
  22. message = e.message;
  23. }
  24. }
  25. else {
  26. if (_.isUndefined(error.message)) {
  27. if (error.responseJSON) {
  28. if (error.responseJSON.ExceptionType === "System.Data.Entity.Infrastructure.DbUpdateException") {
  29. message = "이미 다른 화면에서 사용중이므로 삭제할 수 없습니다";
  30. }
  31. else {
  32. message = error.responseJSON.ExceptionMessage || error.responseJSON.Message;
  33. }
  34. }
  35. }
  36. else {
  37. //message = "데이터베이스 작업중 오류가 발생하였습니다. 입력 혹은 삭제하려는 값을 확인하시기 바랍니다."
  38. message = error.message;
  39. //if (error.message === "이 요청을 처리하는 동안 오류가 발생했습니다.") {
  40. // if (!_.isUndefined(error.httpStatus)) {
  41. // if (error.httpStatus == 500) {
  42. // message = "필수입력 정보가 입력되지 않았습니다.";
  43. // } else if (error.httpStatus == 400) {
  44. // message = "필수입력 정보가 입력되지 않았습니다.";
  45. // } else {
  46. // message = error.message;
  47. // }
  48. // }
  49. //}
  50. //else {
  51. //message = error.message;
  52. //}
  53. }
  54. utils.toast.show('오류: ' + message, 'error');
  55. }
  56. }
  57. // Enable partial CORS support for IE < 10
  58. $.support.cors = true;
  59. BemsWebApplication.db = new DevExpress.data.ODataContext(serviceConfig.db);
  60. }());