RyLiveTools/Source/Config/API.cs
如果当时 0ec1400de9 ### 2024-04-12更新
------
####  V1.0.2404.1201
- 新增支持手动运行规则。
- 规则播放时间间隔不再针对全局声效,而只针对当前规则声效。
- 修复规则中播放文件夹可能导致无法执行的BUG。
- 修复规则不勾选礼物和点赞,则无法执行的BUG。
2024-04-13 10:13:30 +08:00

118 lines
4.7 KiB
C#

using CommunityToolkit.Mvvm.Messaging;
using DotNet4.Utilities;
using LiveTools.Data;
using Microsoft.VisualBasic.ApplicationServices;
using ryCommon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
namespace LiveTools
{
public class API
{
/// <summary>
/// 检查登录
/// </summary>
/// <param name="ErrorMsg"></param>
/// <returns></returns>
public static int CheckedLogin(out string ErrorMsg)
{
try
{
ErrorMsg = "";
Config.UserInfo.NickName = "";
Config.UserInfo.isOut = 1;
HttpResult html = Config.ry_api.Post(Config.Api_Url + "user.aspx", "api=login&userid=" + RyWeb.WebDecode.Escape(Config.UserInfo.UserId) +
"&soft_id=" + RyWeb.WebDecode.Escape(Config.SoftId) + "&pwd=" + RyWeb.WebDecode.Escape(Config.UserInfo.Pwd)
+ "&ver=" + RyWeb.WebDecode.Escape(RySoft.VersionStr) + "&hdid=" + RyWeb.WebDecode.Escape(Config.GetMac()) + "&login=1");
string jsonText = GetJson(html.Html);
if (jsonText != "")
{
Json json = new Json(jsonText);
string result = json.GetJsonValue(Data.ConstVar.json_Result);
if (result == Data.ResultVar.json_Success.ToString())
{
Config.UserInfo.NickName = json.GetJsonValue("nickname");
Config.UserInfo.OutDateStr = json.GetJsonValue("out_date");
Config.UserInfo.OutTime = Config.UserInfo.OutDateStr.ToDateTime().ToInt64();
Config.UserInfo.isOut = json.GetJsonValue("isout").ToInt();
Config.UserInfo.PriceAds = json.GetJsonValue("PriceAds", "月卡59元,季卡99元,年卡199元,永久卡299元");
Config.UserInfo.BuyContact = json.GetJsonValue("BuyContact", "邮箱:1017848709@qq.com");
//ClsPram.ZZ_Op = json.GetJsonValue("zz_op").ToInt();
Config.UserInfo.Media_id = json.GetJsonValue("media_id");
Config.UserInfo.Setting = json.GetJsonValue("setting");
Config.UserInfo.Sys_Setting = json.GetJsonValue("sys_setting");
Config.UserInfo.Parent_Setting = json.GetJsonValue("parent_setting");
Config.UserInfo.Ads_id = json.GetJsonValue("ads_id");
return 1;
}
else if (result == Data.ResultVar.json_UserOutDate.ToString())
{
Config.UserInfo.isOut = 1;
ErrorMsg = "当前账号需要续费才能使用,请续费。";
return -1000;//需要续费
}
else
{
ErrorMsg = json.GetJsonValue(ConstVar.json_ResultText);
//HandyControl.Controls.MessageBox.Show(json.GetJsonValue(ConstVar.json_ResultText), "错误代码:" + result);
return -1;
}
}
else
{
ErrorMsg ="服务器异常,请检查网络连接";
return -100;//服务器异常
}
}
catch { ErrorMsg = "检查登录过程中发生错误。"; return -2; }
}
public static bool IsJson(string result)
{
if (result.Length <= 6)
{
return false;
}
else if (result.Substring(0, 1) == "1")
{
return true;
}
else
{ return false; }
}
public static string GetJson(string result)
{
if (IsJson(result))
{
return result.Substring(6);
}
else
{
return "";
}
}
/// <summary>
/// 获取相对路径
/// </summary>
/// <param name="fullPath"></param>
/// <returns></returns>
public static string GetRelativePath(string fullPath)
{
return fullPath.Replace(Config.GetCurrentFolder,"{app}",true, System.Globalization.CultureInfo.CurrentCulture);
}
/// <summary>
/// 获取相对路径
/// </summary>
/// <param name="fullPath"></param>
/// <returns></returns>
public static string GetTruePath(string fullPath)
{
return fullPath.Replace("{app}", Config.GetCurrentFolder);
}
}
}