IT-KIMI_SHI\SINOIT.KIMI
2018-06-04 b12dfac6e495d6cf38df6b7e5222191f59762900
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
package frame.file;
 
import frame.data.Entity;
import frame.expression.VariantContext;
import frame.file.IFileContext;
import frame.file.IFileload;
import frame.file.UploadResult;
import frame.persist.NamedSQL;
import frame.persist.SQLRunner;
import frame.util.Util;
 
public class IOHandler implements IFileload{
      private String id;
      private String fileIoCode;
      private String itemId;
      private String sqlName;
      private int no;
      private String eventCode;
      private String resultCode;
 
      public IOHandler() {
 
      }
      
    @Override
    public void initLoad(Entity entity) {
          id = entity.getString("id");
          fileIoCode = entity.getString("fileiocode");
          itemId = entity.getString("itemid");
          sqlName = entity.getString("sqlname");
          sqlName = entity.getString("sqlname");
          eventCode = entity.getString("eventcode");
          resultCode = entity.getString("resultcode");
          String noString = entity.getString("no");
          
          if (Util.isEmptyStr(noString)) {
            no = Integer.parseInt(noString);
          }
          
          if (eventCode != null) {
              eventCode = eventCode.toLowerCase();
          }
 
          if (resultCode != null) {
              resultCode = resultCode.toLowerCase();
          }
      }
 
      public void exec(UploadResult result, IFileContext context) throws Exception {
          NamedSQL namedSql = NamedSQL.getInstance(sqlName);
          result.setWorkingSQL(namedSql);
 
          context.setParametersTo(namedSql);
 
          if ("errorcount".equalsIgnoreCase(resultCode)) {
              int cnt = SQLRunner.execSQL(namedSql.getSQLString());
 
              if (cnt > 0) {
                  result.fail("error_InvalidData", "存在不合法数据(" + cnt + ")", cnt);
              }
          }
          else if ("successcount".equalsIgnoreCase(resultCode)) {
              int cnt = SQLRunner.execSQL(namedSql.getSQLString());
              result.setSuccessCount(cnt);
          }
          else {
              SQLRunner.execSQL(namedSql.getSQLString());
          }
      }
 
    
    public boolean equalEvent(String code) {
        if (Util.isEmptyStr(code)) {
              return false;
          }
          
        return eventCode.equalsIgnoreCase(code);
    }
 
    public String getId() {
        return id;
      }
 
      public String getFileIoCode() {
          return fileIoCode;
      }
 
      public String getItemId() {
          return itemId;
      }
 
      public String getSqlName() {
          return sqlName;
      }
 
      public int getNo() {
          return no;
      }
 
      public String getEventCode() {
          return eventCode;
      }
 
      public String getResultCode() {
          return resultCode;
      }
 
    
 
  }