示例#1
0
        public static string doPost(string action, string data)
        {
            string data0 = "action=" + action + "&classid=" + Global.getClassID() + "&courseid=" + Global.getCourseID() + "&teacherid=" + Global.getTeacherID();

            if (data.IndexOf("lesson.get") < 0)
            {
                data0 += "&lessonid=" + Global.getLessonID();
            }
            if (data.IndexOf("schoolid=") < 0)
            {
                data0 += "&schoolid=" + Global.getSchoolID();
            }
            data = data0 + "&" + data;

            string tm          = DateTime.Now.ToString("yyyyMMddHHmmss");
            string src         = tm + "_" + Global.getSchoolID() + "_" + Global.getClassID() + "_" + KEY;
            string sign        = GetMD5(src);
            string url         = Global.url_assistant + "s=" + Global.getSchoolID() + "&r=0&classid=" + Global.getClassID() + "&t=" + tm + "&c=" + sign;
            string ret         = "";
            string keyTemp     = sign.Substring(4, 16);
            string dataEncrypt = AesEncrypt(data, keyTemp);//跟java的substring不一样

            string retCrypt = HTTPReq.HttpPost(url, dataEncrypt);

            ret = AesDecrypt(retCrypt, keyTemp);
            if (ret.Length == 0)
            {
                OfflineProcessor.AddEvent(action, url, data, tm);
            }
            Log.Info("doPost: data=" + data);
            Log.Debug("ret=" + ret);

            if (data.IndexOf("lesson.get") > 0)
            {
                handleGetLessonResponse(ret);
            }
            else if (data.IndexOf("handon") > 0 && Global.getLessonID() == 0)
            {
                handleGetLessonResponse(ret);
            }

            if (ret == null)
            {
                ret = "";
            }
            return(ret);
        }
示例#2
0
        public static int uploadOfflineData(LessonEvents le)
        {
            string _lessonid  = "0";
            int    _classid   = le.classid;
            int    _courseid  = le.courseid;
            int    _teacherid = le.teacherid;

            int nRet = 0;

            foreach (LessonEvent ev in le.eventlist)
            {
                string tm  = ev.tm;
                string url = ev.request;
                if (tm == null)
                {
                    tm = url.Substring(url.IndexOf("&t=") + 3, 14);
                }
                string data = ev.filepath + "&offline=1";

                string src     = tm + "_" + Global.getSchoolID() + "_" + _classid + "_" + KEY;
                string sign    = GetMD5(src);
                string keyTemp = sign.Substring(4, 16);
                if (_lessonid != "0")
                {
                    data = data.Replace("lessonid=0", "lessonid=" + _lessonid);
                }

                if (_lessonid == "0" && ev.type != LessonEventType.ClassOn)
                {
                    continue;
                }

                if (ev.type == LessonEventType.UploadFile && _lessonid != "0")
                {
                    string ret = HTTPReq.UploadFile(url, ev.filepath);
                }
                else
                {
                    string dataEncrypt = AesEncrypt(data, keyTemp);//跟java的substring不一样
                    Log.Info("OfflineUpload. url=" + url + ", " + data);
                    string retCrypt = HTTPReq.HttpPost(url, dataEncrypt);
                    string ret      = AesDecrypt(retCrypt, keyTemp);
                    if (ev.type == LessonEventType.ClassOn && ret.Length > 0)
                    {
                        JObject jo = (JObject)JsonConvert.DeserializeObject(ret);
                        _lessonid = jo["data"]["lessonid"].ToString();
                        string _index      = jo["data"]["index"].ToString();
                        string _coursename = jo["data"]["coursename"].ToString();
                        nRet++;
                    }
                    else
                    {
                        if (ret.Length > 0)
                        {
                            nRet++;
                        }

                        if (ev.type == LessonEventType.ClassOff)
                        {
                        }
                        else
                        {
                        }
                    }
                }
            }
            return(nRet);
        }