Exemple #1
0
        /// <summary>
        /// 取更新信息
        /// </summary>
        /// <returns>更新信息或Null</returns>
        public async static Task <UpdateInfo> GetUpdateInfo()
        {
            string timestamp = FreeYunUtil.ToTimeStamp(DateTime.Now).ToString();

            JObject dic = new JObject();

            dic.Add("version", version);

            dic.Add("macCode", macCode);

            dic.Add("timestamp", timestamp);
            dic.Add("secretKey", secretkey);

            string data = JsonConvert.SerializeObject(dic);

            //var data = "{" + $"'version':'{version}','timestamp':{timestamp},'macCode':'{macCode}','secretKey':'{secretkey}'".Replace("'", "\"") + "}";

            var ret = await Request(15, data);

            if (!FreeYunUtil.IsJson(ret))
            {
                throw new Exception("更新 json 格式 不正确");
            }

            Console.WriteLine(ret);
            JObject json = (JObject)JsonConvert.DeserializeObject(ret);
            var     code = json["code"].ToString();

            if (code != "1033" && code != "1002")
            {
                throw new Exception("取更新信息失败,原因:" + GetMsg(code));
            }
            if (code == "1002")
            {
                return(null);
            }
            var describe = json["describe"].ToString();
            var md5      = json["md5"].ToString();
            var name     = json["name"].ToString();
            var url      = json["url"].ToString();

            var upINfo = new UpdateInfo();

            upINfo.Desc    = describe;
            upINfo.MD5     = md5;
            upINfo.DownUrl = url;
            upINfo.AppName = name;

            return(upINfo);
        }
Exemple #2
0
        /// <summary>
        /// (登录后)心跳[发送频率建议为:10-20分钟一次]
        /// </summary>
        /// <param name="usr">账号</param>
        /// <param name="token">登录返回的TOKEN</param>
        public async static Task <Result_Info> Heartbeat()
        {
            string timestamp = FreeYunUtil.ToTimeStamp(DateTime.Now).ToString();

            var info = new Result_Info();

            var data = "{" + $"'account':'{mUser}','token':'{mToken}','timestamp':{timestamp},'macCode':'{macCode}','secretKey':'{secretkey}'".Replace("'", "\"") + "}";

            try
            {
                var ret = await Request(9, data);

                if (!FreeYunUtil.IsJson(ret))
                {
                    info.Html = "网络错误";
                }

                JObject json = (JObject)JsonConvert.DeserializeObject(ret);
                var     code = json["code"].ToString();

                if (code != "1046")
                {
                    info.Html = GetMsg(code);
                }
                else
                {
                    info.Html    = "ok";
                    info.Is_bool = true;
                }
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                info.Html = ex.Message;
            }

            return(info);
        }
Exemple #3
0
        /// <summary>
        /// 帐号注册_2
        /// </summary>
        /// <param name="usr">账号</param>
        /// <param name="pwd">密码</param>
        /// <param name="qq">QQ选填</param>
        /// <param name="email">邮箱选填</param>
        /// <param name="mobile">手机号码选填</param>
        /// <param name="invitingCode">邀请码选填</param>
        /// <param name="agentCode">代理商代理编号,该参数为代理商列表的代理编号,可空,可内置在软件用于指定不同的代理商注册的用户所有权</param>
        public async static Task <Result_Info> Register(string usr, string pwd,
                                                        string qq = "", string email = "", string mobile = "", string invitingCode = "", string agentCode = "")
        {
            string timestamp = FreeYunUtil.ToTimeStamp(DateTime.Now).ToString();

            Result_Info info = new Result_Info();

            JObject dic = new JObject();

            dic.Add("account", usr);
            dic.Add("password", pwd);
            dic.Add("macCode", macCode);
            dic.Add("timestamp", timestamp);
            dic.Add("secretKey", secretkey);

            if (!FreeYunUtil.IsNull(qq))
            {
                dic.Add("qq", qq);
            }


            if (!FreeYunUtil.IsNull(email))
            {
                dic.Add("email", email);
            }


            if (!FreeYunUtil.IsNull(mobile))
            {
                dic.Add("mobile", mobile);
            }


            if (!FreeYunUtil.IsNull(invitingCode))
            {
                dic.Add("mobile", mobile);
            }


            if (!FreeYunUtil.IsNull(agentCode))
            {
                dic.Add("agentCode", agentCode);
            }

            try
            {
                string data = JsonConvert.SerializeObject(dic);


                var ret = await Request(2, data);

                if (!FreeYunUtil.IsJson(ret))
                {
                    info.Html = ret;
                    return(info);
                }

                JObject json = (JObject)JsonConvert.DeserializeObject(ret);
                var     code = json["code"].ToString();
                if (code != "1006")
                {
                    info.Html = "注册失败,原因:" + GetMsg(code);
                }
                else
                {
                    info.Html    = "注册成功";
                    info.Is_bool = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);

                info.Html = ex.Message;
            }

            return(info);
        }
Exemple #4
0
        /// <summary>
        /// 软件取初始化信息接口_1
        /// </summary>
        /// <param name="_appid">软件id</param>
        /// <param name="_secretkey">软件密钥</param>
        /// <param name="_salt">加密盐</param>
        /// <param name="_desKey">des 密钥</param>
        /// <param name="_mackCode">机器码</param>
        /// <param name="_version">当前版本号</param>
        /// <returns></returns>
        public async static Task <InitInfo> Init(int _appid, string _secretkey, string _salt, string _desKey, string _mackCode, string _version)
        {
            appid     = _appid;
            secretkey = _secretkey;
            salt      = _salt;
            desKey    = _desKey;
            macCode   = _mackCode;
            version   = _version;

            try
            {
                string timestamp = FreeYunUtil.ToTimeStamp(DateTime.Now).ToString();

                JObject dic = new JObject();
                dic.Add("version", version);
                dic.Add("timestamp", timestamp);
                dic.Add("macCode", macCode);
                dic.Add("secretKey", secretkey);

                //string data = "{" + $"'version':'{version}','timestamp':{timestamp},'macCode':'{macCode}','secretKey':'{secretkey}'"Replace("'", "\"") + "}";
                string data = JsonConvert.SerializeObject(dic);


                var ret = await Request(1, data);

                if (string.IsNullOrEmpty(ret))
                {
                    return(null);
                }

                if (!FreeYunUtil.IsJson(ret))
                {
                    LastErr = "服务器返回为空";
                    return(null);
                }

                JObject json = (JObject)JsonConvert.DeserializeObject(ret);

                if (json == null)
                {
                    return(null);
                }

                var code = json["code"].ToString();
                if (code != "1003")
                {
                    LastErr = GetMsg(code);
                    Console.WriteLine("初始化失败,原因:" + GetMsg(code));
                    return(null);
                }


                var nowVersion  = json["nowVersion"].ToString();
                var lastVersion = json["lastVersion"].ToString();
                var needUpdate  = true;
                var md5         = json["md5"].ToString();
                var notic       = json["notic"].ToString();
                var baseData    = json["baseData"].ToString();
                return(new InitInfo(nowVersion, lastVersion, needUpdate, md5, notic, baseData));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(null);
            }
        }