123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396 |
- package kr.co.icontrols.wallpadconfig.imap;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.List;
- import android.content.Context;
- import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
- import com.artncore.WallPadDataMgr.WallpadStatusData;
- import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
- import com.artncore.wallpadimap.RetProci;
- import com.artncore.wallpadimap.WallPadiMAPClient;
- public class iMAPSetAccessKey extends WallPadiMAPClient{
- String myIP="NONE";
- String myDong="NONE";
- String myHo="NONE";
- Context ctx;
- RetProci Proc;
- String XMLHeader;
- WallpadStatusData DBMGR;
- String ServerIP = "10.0.1.10";
- int SvrPort = 10000;
-
-
- int mKey_Type;
- ID id = new ID();
- public static final class ID
- {
-
- public final static int SAVE = 1;
- public final static int DELETE = 2;
- public final static int RENEW = 3;
-
- public final static int HKEY = 1;
- public final static int DKEY = 2;
- public final static int MKEY = 3;
- }
- public iMAPSetAccessKey(Context ctx)
- {
- DBMGR = new WallpadStatusData(ctx);
- AddressSet addc = DBMGR.getAddressMGR();
- DBMGR.closeDB();
-
- myIP = addc.IPAddress;
- myDong = addc.Dong;
- myHo = addc.Ho;
-
- XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
- "<imap ver = \"1.0\" address = \""+myIP+"\" sender = \""+myDong+"동 "+myHo+"호"+"\">\r\n" ;
- setContext(ctx);
- this.ctx = ctx;
- }
- private String SetXMLInfo(int actionType, int keyType)
- {
- String retXML = null;
- String sActionType = "renew";
- String sKeyType = "hkey";
- if(actionType == ID.SAVE)
- {
- sActionType = "save";
- }
- else if (actionType == ID.DELETE)
- {
- sActionType = "delete";
- }
- else if (actionType == ID.RENEW)
- {
- sActionType = "renew";
- }
- if(keyType == ID.HKEY)
- {
- sKeyType = "hkey";
- }
- else if (keyType == ID.DKEY)
- {
- sKeyType = "dkey";
- }
- else if (keyType == ID.MKEY)
- {
- sKeyType = "mkey";
- }
- mKey_Type = keyType;
- retXML = XMLHeader +
- " <service type=\"request\" name=\"set_accesskey_info\">\r\n"+
- " <action>\""+sActionType+"\"</action>\r\n" +
- " <key_type>\""+sKeyType+"\"</key_type>\r\n";
- return retXML;
- }
- @SuppressWarnings("unused")
- private String SetXML_KeyInfo(List<SmartKeyDataClass> getList)
- {
- String retXML = null;
- SimpleDateFormat CurYearFormat = new SimpleDateFormat("yyyy");
- SimpleDateFormat CurMonthFormat = new SimpleDateFormat("MM");
- SimpleDateFormat CurDayFormat = new SimpleDateFormat("dd");
- SimpleDateFormat CurHourFormat = new SimpleDateFormat("HH");
- SimpleDateFormat CurMinuteFormat = new SimpleDateFormat("mm");
- int ListSize = getList.size();
- if(mKey_Type == ID.HKEY)
- {
- retXML = " <hkey_info dong=\""+myDong+"\" ho=\""+myHo+"\" count=\""+ListSize+"\" />";
- }
- else if (mKey_Type == ID.DKEY)
- {
- retXML = " <dkey_info dong=\""+myDong+"\" count=\""+ListSize+"\" />";
- }
- else if (mKey_Type == ID.MKEY)
- {
- retXML = " <mkey_info count=\""+ListSize+"\" />";
- }
- retXML += "\r\n";
- if(ListSize > 0)
- {
- for(int i = 0; i<ListSize; i++)
- {
- Date tempDate = new Date(getList.get(i).RegDateCal.getTimeInMillis());
- String strYear = CurYearFormat.format(tempDate);
- String strMonth = CurMonthFormat.format(tempDate);
- String strDay = CurDayFormat.format(tempDate);
- String strHour = CurHourFormat.format(tempDate);
- String strMinute = CurHourFormat.format(tempDate);
- String temp_Issued_data = strYear+"."+strMonth+"."+strDay+"."+strHour+"."+strMinute;
- retXML += " <key_info index=\""+getList.get(i).id+"\" "
- + "sn=\""+getList.get(i).SerialNumber+"\" "
- + "uid=\""+getList.get(i).Uid+"\" "
- + "key_num=\""+getList.get(i).id+"\" "
- + "issue_cnt=\""+1+"\" "
- + "issued_date=\""+temp_Issued_data+"\" "
- + "message=\""+"null"+"\" "
- + "/>\r\n";
- }
- }
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
-
- public void SetAdminPC_IPcfg(String IPa, int port)
- {
- ServerIP = IPa;
- SvrPort = port;
- }
- public void SetRetCtr(RetProci retProci)
- {
- Proc = retProci;
- }
- protected void ProcComplite()
- {
- if(Proc != null)
- {
- SetItem("service");
- String result = GetAttributeVal(0, "result");
- if (result!=null)
- {
- if (result.equalsIgnoreCase("ok"))
- {
- String name = GetAttributeVal(0, "name");
- String type = GetAttributeVal(0, "type");
- if((name!=null && name.equalsIgnoreCase("set_accesskey_info")) &&
- (type!=null && type.equalsIgnoreCase("reply")))
- {
- Proc.ProcSuccess();
- }
- else
- {
- Proc.ProcError();
- }
- }
- else if (result.equalsIgnoreCase("fail"))
- {
- Proc.ProcError();
- }
- else
- {
- Proc.ProcError();
- }
- }
- else
- {
- Proc.ProcError();
- }
- }
- }
- protected void ProcError()
- {
- Proc.ProcError();
- }
-
- public boolean DoWork(int actionType, int keyType, List<SmartKeyDataClass> getList)
- {
- SetServerIPConfig(ServerIP, SvrPort);
- String SendMessage = null;
- if(actionType <= 0)
- {
- return false;
- }
- if(keyType <= 0)
- {
- return false;
- }
- if(getList == null)
- {
- return false;
- }
- SendMessage = SetXMLInfo(actionType, keyType);
- SendMessage += SetXML_KeyInfo(getList);
- SendXMLDoc(SendMessage, true);
- return true;
- }
- }
|