Example #1
0
        /// <summary>
        /// 文件上传----老师PPT做题或抢答
        /// </summary>
        /// <param name="filename"></param>
        public static void uploadPicture(string path)
        {
            //if (true)
            //    return;
            FileInfo fileInfo = new FileInfo(path);
            long     filesize = fileInfo.Length;

            if (filesize > 1024 * 1024 * 5)
            {
                Log.Error("file too big. " + path);
                return;
            }

            int    pos      = path.LastIndexOf("\\");
            string fileName = path.Substring(pos + 1);
            string md5      = Util.GetFileMD5(path);

            //异步同步到云服务
            string url_param = "action=fileupload";

            url_param += "&schoolid=" + schoolid;
            url_param += "&classid=" + Global.getClassID();
            url_param += "&courseid=" + Global.getCourseID();
            url_param += "&lessonid=" + Global.getLessonID();
            url_param += "&teacherid=" + Global.getTeacherID();
            url_param += "&filesize=" + filesize;
            url_param += "&md5=" + md5;
            url_param += "&filename=" + fileName;

            Thread thread = new Thread(delegate()
            {
                string url = "http://" + Global.HOST + "/upload.do" + "?" + url_param;
                string ret = HTTPReq.UploadFile(url, path);
                Log.Info(url + "," + path);
            });

            thread.Start();
            return;
        }
Example #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);
        }