public void upload(Action <UpLoadIntakeLogsResponseData> callBack, Action <ResponseErroInfo> errCallBack)
        {
            GuLog.Info("IntakeLogDataManager upload");
            string currentChildSN = mLocalChildInfoAgent.getChildSN();

            if (currentChildSN == string.Empty)
            {
                errCallBack(ResponseErroInfo.GetErrorInfo(0, "upload resource is empty"));
                return;
            }
            List <LogItem> info = mLocalIntakeLogsData.getAllIntakeLogsInfo(currentChildSN);

            if (info != null && info.Count > 0)
            {
                GuLog.Info("IntakeLogDataManager havedata");
                IntakeLogs mIntakeLogs = new IntakeLogs();
                mIntakeLogs.logs = info;


                mUploadChildIntakeLogsService.uploadIntakeLogs(mIntakeLogs, currentChildSN, (cb) =>
                {
                    mLocalIntakeLogsData.deleteIntakeLogsInfo(currentChildSN);
                    callBack(cb);
                }, (ecb) =>
                {
                    errCallBack(ecb);
                });
            }
            else
            {
                errCallBack(ResponseErroInfo.GetErrorInfo(0, "upload resource is empty"));
            }
        }
예제 #2
0
        public void uploadIntakeLogs(IntakeLogs mIntakeLogs, string current_child_sn, Action <UpLoadIntakeLogsResponseData> callBack, Action <ResponseErroInfo> errCallBack)
        {
            GuLog.Info("UploadChildIntakeLogsService uploadIntakeLogs");
            Dictionary <string, string> head = new Dictionary <string, string>();

            string body = mJsonUtils.Json2String(mIntakeLogs);

            // mGululuNetwork.sendRequest(mUrlProvider.getChildIntakeLogUrl(current_child_sn,CupBuild.getCupSn()), head, body, (result) =>
            // {

            // UpLoadIntakeLogsResponseData info = mJsonUtils.String2Json<UpLoadIntakeLogsResponseData>(result);
            //  mUploadChildIntakeLogsModel.mUpLoadIntakeLogsResponseData = info;
            // callBack(info);

            // }, (ecb) =>
            // {
            //     errCallBack(ecb);
            // }, HTTPMethods.Post);

            mNativeOkHttpMethodWrapper.post(mUrlProvider.getChildIntakeLogUrl(current_child_sn, CupBuild.getCupSn()), "", body, (result) => {
                GuLog.Info("UploadChildIntakeLogsService onresponse");
                UpLoadIntakeLogsResponseData info = mJsonUtils.String2Json <UpLoadIntakeLogsResponseData>(result);
                mUploadChildIntakeLogsModel.mUpLoadIntakeLogsResponseData = info;
                callBack(info);
            }, (errorResult) => {
                GuLog.Info("UploadChildIntakeLogsService faliure");
                errCallBack(errorResult);
            });
        }