You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.2 KiB
74 lines
2.2 KiB
1 month ago
|
using Aliyun.Acs.Sms.Model.V20160927;
|
||
|
using ProtoCSStruct;
|
||
|
using Sog;
|
||
|
|
||
|
namespace Operation
|
||
|
{
|
||
|
public class WebsiteSvc
|
||
|
{
|
||
|
private static long m_lastTickTime;
|
||
|
|
||
|
|
||
|
private static string GetSaveFileName()
|
||
|
{
|
||
|
return "./Operation_Website_" + OperationServerUtils.GetApp().ServerID.ToString() + ".fdb";
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 保存到数据库,存本地文件
|
||
|
/// </summary>
|
||
|
public static void SaveDataToFile()
|
||
|
{
|
||
|
ref var data = ref OperationServerUtils.GetOperationServerData().m_operationWebsite;
|
||
|
string filename = GetSaveFileName();
|
||
|
int iRet = Sog.IO.FileDBSave.SaveToFile(ref data, filename);
|
||
|
if (iRet != 0)
|
||
|
{
|
||
|
TraceLog.Error("WebsiteSvc.SaveDataToFile save file {0} error ,ret {1}", filename, iRet);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
TraceLog.Trace("WebsiteSvc.SaveDataToFile save file {0} success", filename);
|
||
|
}
|
||
|
|
||
|
public static void LoadDataFromFile()
|
||
|
{
|
||
|
string filename = GetSaveFileName();
|
||
|
TraceLog.Trace("WebsiteSvc.LoadDataFromFile load now file {0}", filename);
|
||
|
ref var data = ref OperationServerUtils.GetOperationServerData().m_operationWebsite;
|
||
|
bool success = Sog.IO.FileDBSave.ReadFromFile(ref data, filename);
|
||
|
if (success)
|
||
|
{
|
||
|
TraceLog.Trace("WebsiteSvc.LoadDataFromFile load file {0} success, DailySendTime {1}"
|
||
|
, filename, data.DailySendTime);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
public static void OnTick(long nowMs)
|
||
|
{
|
||
|
//50秒一次
|
||
|
var tail = 5000 * 10;
|
||
|
if (nowMs - m_lastTickTime < tail)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
m_lastTickTime = nowMs;
|
||
|
SaveDataToFile();
|
||
|
}
|
||
|
|
||
|
public static int UpdateNoticeSeq()
|
||
|
{
|
||
|
ref var data = ref OperationServerUtils.GetOperationServerData().m_operationWebsite;
|
||
|
data.NoticeSeq++;
|
||
|
return data.NoticeSeq;
|
||
|
}
|
||
|
|
||
|
public static void Commit()
|
||
|
{
|
||
|
SaveDataToFile();
|
||
|
PlayerPresetOp.UpdateVersion();
|
||
|
}
|
||
|
}
|
||
|
};
|