/** * 保存本地事件 * * @param event 事件 * @param cid 日历ID * @param calendarAccount 日历帐号 * @return * @throws Exception */ public FDEvent saveGo2Events(FDEvent event, FDCalendar cal) throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put("method", "add"); params.put("title", event.getTitle()); params.put("description", event.getNote()); params.put("start", FDTimeFormatUtil.sdfAllDate.format(event.getFromDateByTimeZone())); params.put("timezone", event.getTimezone()); params.put("end", FDTimeFormatUtil.sdfAllDate.format(event.getToDateByTimeZone())); params.put("isAllDay", event.isAllDay() ? "1" : "0"); params.put("location", event.getLocation()); params.put("cid", event.getCalendarId()); params.put("recurrence", event.getRecurrence()); params.put("recurringEventId", event.getRecurringEventId()); params.put("status", event.getStatus() + ""); params.put("originalStartTime", event.getOriginalStartTime()); FDEvent receiveEvent = null; FDJson json = sendPOSTRequestByJson("user/privateEvent", params); if (json != null) { if (json.getStatusCode() != 1) { return null; } receiveEvent = new FDEvent(json.getData(), cal, FDCalendarAccount.TYPE_GO2); } return receiveEvent; }
/** * 保存google事件 * * @param event * @param cid * @throws Exception */ public FDEvent saveGoogleEvent(FDEvent event, FDCalendar cal) throws Exception { Map<String, String> params = new HashMap<String, String>(); // params.put("cid", cal.getId()); // params.put("cid", event.getCalendarId()); // params.put("type", "1" ); // FDPrintln.print("save google event :"+event); // JSONObject obj =event.toJsonObjByGoogle(); // params.put("text", obj.toString() ); params.put("method", "addEvent"); params.put("accountId", cal.getGoogleAccountId()); params.put("calendarId", event.getCalendarId()); FDPrintln.print("save google event :" + event); JSONObject obj = event.toJsonObjByGoogle(); params.put("params", obj.toString()); FDPrintln.print("saveGoogleEvent params " + obj.toString()); FDEvent receiveEvent = null; FDJson json = sendPOSTRequestByJson("user/Google", params); if (json != null) { if (json.getStatusCode() != 1) return null; receiveEvent = new FDEvent(json.getData(), cal, FDCalendarAccount.TYPE_GOOGLE); receiveEvent.setBackground(cal.getBackgroundColor()); receiveEvent.setAccount(cal.getId()); } return receiveEvent; }
/** * 删除IF 本地事件 * * @param id * @return */ public int deleteGo2Event(String id) { int result = FDConstant.REQUEST_RESULT_FAILER; try { Map<String, String> params = new HashMap<String, String>(); params.put("method", "delete"); params.put("peid", id); FDJson json = sendPOSTRequestByJson("user/privateEvent", params); result = json.getStatusCode(); } catch (Exception e) { e.printStackTrace(); } return result; }
public List<FDEvent> getGo2Events(FDCalendar cal) throws Exception { List<FDEvent> events = new ArrayList<FDEvent>(); Map<String, String> params = new HashMap<String, String>(); params.put("cid", cal.getId()); params.put("method", "query"); FDJson json = sendGETRequestByJson("user/privateEvent", params); if (json != null && json.getStatusCode() == 1) { JSONArray items = new JSONArray(json.getData()); for (int i = 0; items != null && i < items.length(); i++) { JSONObject item = items.getJSONObject(i); FDEvent event = new FDEvent(item.toString(), cal, FDCalendarAccount.TYPE_GO2); events.add(event); } } return events; }
/** * 删除google日历 * * @param eid * @param cid */ public int deleteGoogleEvent(String eid, FDCalendar cal) { int result = 0; Map<String, String> params = new HashMap<String, String>(); // params.put("cid", cid); // params.put("eid", eid); params.put("method", "deleteEvent"); params.put("accountId", cal.getGoogleAccountId()); params.put("calendarId", cal.getId()); params.put("eventId", eid); try { FDJson json = sendPOSTRequestByJson("user/Google", params); if (json != null) result = json.getStatusCode(); } catch (Exception e) { e.printStackTrace(); } return result; }