Esempio n. 1
0
        /// <summary>
        /// 从云平台调用指定方法并返回指定类型(T)信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="method"></param>
        /// <param name="mParams"></param>
        /// <returns></returns>
        private static BaseCloudResponse <T> GetCloudResponse <T>(string method, DiscuzCloudMethodParameter mParams)
        {
            string timeStamp = mParams.Find("sTimestamp");

            timeStamp = string.IsNullOrEmpty(timeStamp) ? Utils.ConvertToUnixTimestamp(DateTime.Now).ToString() : timeStamp;

            string postData = string.Format("format={0}&method={1}&sId={2}&sig={3}&ts={4}{5}"
                                            , FORMAT, method, DiscuzCloudConfigs.GetConfig().Cloudsiteid,
                                            GetCloudMethodSignature(method, timeStamp, mParams), timeStamp, mParams.GetPostData());

            string response = Utils.GetHttpWebResponse(CLOUD_URL, postData);

            try
            {
                return(JavaScriptConvert.DeserializeObject <BaseCloudResponse <T> >(response));
            }
            catch
            {
                BaseCloudResponse <string> err    = JavaScriptConvert.DeserializeObject <BaseCloudResponse <string> >(response);
                BaseCloudResponse <T>      errObj = new BaseCloudResponse <T>();
                errObj.ErrCode    = err.ErrCode;
                errObj.ErrMessage = err.ErrMessage;
                return(errObj);
            }
        }
Esempio n. 2
0
        private static BaseCloudResponse <T> GetCloudResponse <T>(string method, DiscuzCloudMethodParameter mParams)
        {
            string text = mParams.Find("sTimestamp");

            text = (string.IsNullOrEmpty(text) ? Utils.ConvertToUnixTimestamp(DateTime.Now).ToString() : text);
            string postData = string.Format("format={0}&method={1}&sId={2}&sig={3}&ts={4}{5}", new object[]
            {
                FORMAT,
                method,
                DiscuzCloudConfigInfo.Current.Cloudsiteid,
                DiscuzCloud.GetCloudMethodSignature(method, text, mParams),
                text,
                mParams.GetPostData()
            });
            string httpWebResponse = Utils.GetHttpWebResponse(CLOUD_URL, postData);
            BaseCloudResponse <T> result;

            try
            {
                result = JavaScriptConvert.DeserializeObject <BaseCloudResponse <T> >(httpWebResponse);
            }
            catch
            {
                BaseCloudResponse <string> baseCloudResponse = JavaScriptConvert.DeserializeObject <BaseCloudResponse <string> >(httpWebResponse);
                result = new BaseCloudResponse <T>
                {
                    ErrCode    = baseCloudResponse.ErrCode,
                    ErrMessage = baseCloudResponse.ErrMessage
                };
            }
            return(result);
        }
Esempio n. 3
0
        public static string RegisterSite()
        {
            DiscuzCloudConfigInfo      config = DiscuzCloudConfigInfo.Current;
            DiscuzCloudMethodParameter discuzCloudMethodParameter = new DiscuzCloudMethodParameter();

            discuzCloudMethodParameter.Add("sName", GeneralConfigInfo.Current.Forumtitle);
            discuzCloudMethodParameter.Add("sSiteKey", config.Sitekey);
            discuzCloudMethodParameter.Add("sCharset", CHARSET);
            discuzCloudMethodParameter.Add("sTimeZone", "8");
            discuzCloudMethodParameter.Add("sLanguage", "zh_CN");
            discuzCloudMethodParameter.Add("sProductType", DiscuzCloud.productType);
            discuzCloudMethodParameter.Add("sProductVersion", DiscuzCloud.productVersion);
            discuzCloudMethodParameter.Add("sTimestamp", Utils.ConvertToUnixTimestamp(DateTime.Now).ToString());
            discuzCloudMethodParameter.Add("sApiVersion", "0.4");
            discuzCloudMethodParameter.Add("sSiteUid", BaseConfigs.GetFounderUid.ToString());
            discuzCloudMethodParameter.Add("sProductRelease", PRODUCT_RELEASE);
            discuzCloudMethodParameter.Add("sUrl", Utils.GetRootUrl(BaseConfigs.GetForumPath));
            discuzCloudMethodParameter.Add("sUCenterUrl", Utils.GetRootUrl(BaseConfigs.GetForumPath));
            BaseCloudResponse <RegisterCloud> cloudResponse = DiscuzCloud.GetCloudResponse <RegisterCloud>("site.register", discuzCloudMethodParameter);

            if (cloudResponse.ErrCode == 0)
            {
                config.Cloudsiteid  = cloudResponse.Result.CloudSiteId;
                config.Cloudsitekey = cloudResponse.Result.CloudSiteKey;

                //DiscuzCloudConfigs.SaveConfig(config);
                //DiscuzCloudConfigs.ResetConfig();
                config.Save();
                DiscuzCloudConfigInfo.Current = null;
            }
            return(cloudResponse.ErrMessage);
        }
Esempio n. 4
0
        //public static string ResumeSite()
        //{
        //    DiscuzCloudMethodParameter mParams = new DiscuzCloudMethodParameter();
        //    mParams.Add("sUrl", Utils.GetRootUrl(BaseConfigs.GetForumPath));
        //    mParams.Add("sCharset", CHARSET);
        //    mParams.Add("sProductType", productType);
        //    mParams.Add("sProductVersion", productVersion);

        //    BaseCloudResponse<RegisterCloud> resumeCloudResult = GetCloudResponse<RegisterCloud>("site.resume", mParams);

        //    if (resumeCloudResult.ErrCode == 0 &&
        //        (resumeCloudResult.Result.CloudSiteId != config.Cloudsiteid || resumeCloudResult.Result.CloudSiteKey != config.Cloudsitekey))
        //    {
        //        config.Cloudsiteid = resumeCloudResult.Result.CloudSiteId;
        //        config.Cloudsitekey = resumeCloudResult.Result.CloudSiteKey;

        //        GeneralConfigs.SaveConfig(config);
        //        GeneralConfigs.ResetConfig();
        //    }

        //    return resumeCloudResult.ErrMessage;
        //}

        /// <summary>
        /// 同步站点信息,包括站点名称和站点地址
        /// </summary>
        /// <returns></returns>
        public static string SyncSite()
        {
            DiscuzCloudConfigInfo      config  = DiscuzCloudConfigs.GetConfig();
            DiscuzCloudMethodParameter mParams = new DiscuzCloudMethodParameter();

            mParams.Add("sId", config.Cloudsiteid);
            mParams.Add("sName", GeneralConfigs.GetConfig().Forumtitle);
            mParams.Add("sSiteKey", config.Sitekey);
            mParams.Add("sCharset", "utf-8");
            mParams.Add("sTimeZone", "8");
            mParams.Add("sLanguage", "zh_CN");
            mParams.Add("sProductType", productType);
            mParams.Add("sProductVersion", productVersion);
            mParams.Add("sApiVersion", "0.4");
            mParams.Add("sSiteUid", BaseConfigs.GetFounderUid > 0 ? BaseConfigs.GetFounderUid.ToString() : "1");
            mParams.Add("sProductRelease", PRODUCT_RELEASE);
            mParams.Add("sTimestamp", Utils.ConvertToUnixTimestamp(DateTime.Now).ToString());

#if DEBUG
            mParams.Add("sUrl", "http://247.mydev.com/~cailong/");
            mParams.Add("sUCenterUrl", "http://247.mydev.com/~cailong/");
#else
            mParams.Add("sUrl", Utils.GetRootUrl(BaseConfigs.GetForumPath));
            mParams.Add("sUCenterUrl", Utils.GetRootUrl(BaseConfigs.GetForumPath));
#endif
            BaseCloudResponse <bool> syncSiteResult = GetCloudResponse <bool>("site.sync", mParams);
            return(syncSiteResult.ErrMessage);
        }
Esempio n. 5
0
        public static string GetCloudBindUrl(int userId)
        {
            DiscuzCloudMethodParameter discuzCloudMethodParameter = new DiscuzCloudMethodParameter(false);

            discuzCloudMethodParameter.Add("s_id", DiscuzCloudConfigInfo.Current.Cloudsiteid);
            discuzCloudMethodParameter.Add("s_site_uid", userId.ToString());
            return(DiscuzCloud.GetCloudCpUrl("bind/index", discuzCloudMethodParameter));
        }
Esempio n. 6
0
        public static string GetCloudAppListIFrame(int userId)
        {
            DiscuzCloudMethodParameter discuzCloudMethodParameter = new DiscuzCloudMethodParameter(false);

            discuzCloudMethodParameter.Add("refer", Utils.GetRootUrl(BaseConfigs.GetForumPath));
            discuzCloudMethodParameter.Add("s_id", DiscuzCloudConfigInfo.Current.Cloudsiteid);
            discuzCloudMethodParameter.Add("s_site_uid", userId.ToString());
            return(DiscuzCloud.GetCloudCpUrl("cloud/appList/", discuzCloudMethodParameter));
        }
Esempio n. 7
0
        /// <summary>
        /// 获取云平台绑定QQ号的页面地址
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static string GetCloudBindUrl(int userId)
        {
            DiscuzCloudMethodParameter mParams = new DiscuzCloudMethodParameter(false);

            mParams.Add("s_id", DiscuzCloudConfigs.GetConfig().Cloudsiteid);
            mParams.Add("s_site_uid", userId.ToString());

            return(GetCloudCpUrl("bind/index", mParams));
        }
Esempio n. 8
0
        /// <summary>
        /// 获取云平台后台服务管理列表Iframe地址
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static string GetCloudAppListIFrame(int userId)
        {
            DiscuzCloudMethodParameter mParams = new DiscuzCloudMethodParameter(false);

            mParams.Add("refer", Utils.GetRootUrl(BaseConfigs.GetForumPath));
            mParams.Add("s_id", DiscuzCloudConfigs.GetConfig().Cloudsiteid);
            mParams.Add("s_site_uid", userId.ToString());
            return(GetCloudCpUrl("cloud/appList/", mParams));
        }
Esempio n. 9
0
        public static string GetCloudUploadLogoIFrame(int userId)
        {
            DiscuzCloudMethodParameter discuzCloudMethodParameter = new DiscuzCloudMethodParameter(false);

            discuzCloudMethodParameter.Add("s_id", DiscuzCloudConfigInfo.Current.Cloudsiteid);
            discuzCloudMethodParameter.Add("s_site_uid", userId.ToString());
            discuzCloudMethodParameter.Add("link_url", "admin/global/global_connectset.aspx");
            discuzCloudMethodParameter.Add("self_url", "admin/global/global_connectset.aspx?upload=1");
            return(DiscuzCloud.GetCloudCpUrl("connect/service", discuzCloudMethodParameter));
        }
Esempio n. 10
0
        public static string GetCloudTestResponse(string method, DiscuzCloudMethodParameter mParams)
        {
            string timeStamp = mParams.Find("sTimestamp");

            timeStamp = string.IsNullOrEmpty(timeStamp) ? Utils.ConvertToUnixTimestamp(DateTime.Now).ToString() : timeStamp;
            string postData = string.Format("format={0}&method={1}&sId={2}&sig={3}&ts={4}{5}"
                                            , FORMAT, method, DiscuzCloudConfigs.GetConfig().Cloudsiteid,
                                            GetCloudMethodSignature(method, timeStamp, mParams), timeStamp, mParams.GetPostData());

            return(Utils.GetHttpWebResponse(CLOUD_URL, postData));
        }
Esempio n. 11
0
        /// <summary>
        /// 获取云平台上传站点logo的页面地址
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static string GetCloudUploadLogoIFrame(int userId)
        {
            DiscuzCloudMethodParameter mParams = new DiscuzCloudMethodParameter(false);

            mParams.Add("s_id", DiscuzCloudConfigs.GetConfig().Cloudsiteid);
            mParams.Add("s_site_uid", userId.ToString());
            mParams.Add("link_url", "admin/global/global_connectset.aspx");
            mParams.Add("self_url", "admin/global/global_connectset.aspx?upload=1");

            return(GetCloudCpUrl("connect/service", mParams));
        }
Esempio n. 12
0
        /// <summary>
        /// 更换站点KEY
        /// </summary>
        /// <returns></returns>
        public static string ResetSiteKey()
        {
            DiscuzCloudConfigInfo      config  = DiscuzCloudConfigs.GetConfig();
            DiscuzCloudMethodParameter mParams = new DiscuzCloudMethodParameter();

            mParams.Add("sId", config.Cloudsiteid);
            BaseCloudResponse <RegisterCloud> resetCloudResult = GetCloudResponse <RegisterCloud>("site.resetKey", mParams);

            if (resetCloudResult.ErrCode == 0)
            {
                config.Cloudsitekey = resetCloudResult.Result.CloudSiteKey;
                DiscuzCloudConfigs.SaveConfig(config);
                DiscuzCloudConfigs.ResetConfig();
            }
            return(resetCloudResult.ErrMessage);
        }
Esempio n. 13
0
        public static string ResetSiteKey()
        {
            DiscuzCloudConfigInfo      config = DiscuzCloudConfigInfo.Current;
            DiscuzCloudMethodParameter discuzCloudMethodParameter = new DiscuzCloudMethodParameter();

            discuzCloudMethodParameter.Add("sId", config.Cloudsiteid);
            BaseCloudResponse <RegisterCloud> cloudResponse = DiscuzCloud.GetCloudResponse <RegisterCloud>("site.resetKey", discuzCloudMethodParameter);

            if (cloudResponse.ErrCode == 0)
            {
                config.Cloudsitekey = cloudResponse.Result.CloudSiteKey;

                //DiscuzCloudConfigs.SaveConfig(config);
                //DiscuzCloudConfigs.ResetConfig();
                config.Save();
                DiscuzCloudConfigInfo.Current = null;
            }
            return(cloudResponse.ErrMessage);
        }
Esempio n. 14
0
        public static string SyncSite()
        {
            DiscuzCloudConfigInfo      config = DiscuzCloudConfigInfo.Current;
            DiscuzCloudMethodParameter discuzCloudMethodParameter = new DiscuzCloudMethodParameter();

            discuzCloudMethodParameter.Add("sId", config.Cloudsiteid);
            discuzCloudMethodParameter.Add("sName", GeneralConfigInfo.Current.Forumtitle);
            discuzCloudMethodParameter.Add("sSiteKey", config.Sitekey);
            discuzCloudMethodParameter.Add("sCharset", CHARSET);
            discuzCloudMethodParameter.Add("sTimeZone", "8");
            discuzCloudMethodParameter.Add("sLanguage", "zh_CN");
            discuzCloudMethodParameter.Add("sProductType", DiscuzCloud.productType);
            discuzCloudMethodParameter.Add("sProductVersion", DiscuzCloud.productVersion);
            discuzCloudMethodParameter.Add("sApiVersion", "0.4");
            discuzCloudMethodParameter.Add("sSiteUid", BaseConfigs.GetFounderUid.ToString());
            discuzCloudMethodParameter.Add("sProductRelease", PRODUCT_RELEASE);
            discuzCloudMethodParameter.Add("sTimestamp", Utils.ConvertToUnixTimestamp(DateTime.Now).ToString());
            discuzCloudMethodParameter.Add("sUrl", Utils.GetRootUrl(BaseConfigs.GetForumPath));
            discuzCloudMethodParameter.Add("sUCenterUrl", Utils.GetRootUrl(BaseConfigs.GetForumPath));
            BaseCloudResponse <bool> cloudResponse = DiscuzCloud.GetCloudResponse <bool>("site.sync", discuzCloudMethodParameter);

            return(cloudResponse.ErrMessage);
        }
Esempio n. 15
0
        /// <summary>
        /// 获取云平台后台调用链接(产品后台iframe链接和跳转链接)
        /// </summary>
        /// <param name="target"></param>
        /// <param name="mParams"></param>
        /// <returns></returns>
        private static string GetCloudCpUrl(string target, DiscuzCloudMethodParameter mParams)
        {
            string timeStamp = Utils.ConvertToUnixTimestamp(DateTime.Now).ToString();

            return(CLOUD_CP_URL + target + "?ts=" + timeStamp + mParams.GetPostData() + "&sig=" + GetCloudIframeSignature(mParams, timeStamp));
        }
Esempio n. 16
0
 /// <summary>
 /// 获取云平台后台调用签名(产品后台iframe链接和跳转链接的附带签名)
 /// </summary>
 /// <param name="mParams"></param>
 /// <param name="timeStamp"></param>
 /// <returns></returns>
 private static string GetCloudIframeSignature(DiscuzCloudMethodParameter mParams, string timeStamp)
 {
     return(Utils.MD5(string.Format("{0}|{1}|{2}", mParams.GetPostData().TrimStart('&'), DiscuzCloudConfigs.GetConfig().Cloudsitekey, timeStamp)));
 }
Esempio n. 17
0
        /// <summary>
        /// 获取云平台方法签名
        /// </summary>
        /// <param name="method"></param>
        /// <param name="timeStamp"></param>
        /// <param name="mParams"></param>
        /// <returns></returns>
        private static string GetCloudMethodSignature(string method, string timeStamp, DiscuzCloudMethodParameter mParams)
        {
            DiscuzCloudConfigInfo config = DiscuzCloudConfigs.GetConfig();

            return(Utils.MD5(string.Format("format={0}&method={1}&sId={2}{3}|{4}|{5}",
                                           FORMAT, method, config.Cloudsiteid, mParams.GetPostData(), config.Cloudsitekey, timeStamp)));
        }