|
|
|
@ -26,7 +26,6 @@ namespace Txgy.FilesWatcher.model
|
|
|
|
|
public static void UploadRealtimeFileOnce(string path, string eventMessage, int workAreaId, out bool isUpload)
|
|
|
|
|
{
|
|
|
|
|
GetLogger _log = new GetLogger("UploadRealtimeFile");
|
|
|
|
|
_log.Log.Debug("UploadRealtimeFile.UploadRealtimeFileOnce() > enter....");
|
|
|
|
|
_log.Log.DebugFormat("UploadRealtimeFile.UploadRealtimeFileOnce() path:{0},eventMessage:{1},workAreaId:{2}", path, eventMessage, workAreaId);
|
|
|
|
|
isUpload = false;
|
|
|
|
|
try
|
|
|
|
@ -57,20 +56,29 @@ namespace Txgy.FilesWatcher.model
|
|
|
|
|
|
|
|
|
|
string EventTime = index_file_line[0].Substring(0, 23);
|
|
|
|
|
string OriginTime = EventTime;
|
|
|
|
|
|
|
|
|
|
//上传前,检查workAreaId和eventTime
|
|
|
|
|
//.json文件
|
|
|
|
|
string JPath = dFile.FullName.Replace(".mseed", "A.json");
|
|
|
|
|
if(File.Exists(JPath))
|
|
|
|
|
{
|
|
|
|
|
string mes= File.ReadAllText(JPath);
|
|
|
|
|
if (!mes.Contains(EventTime))
|
|
|
|
|
{
|
|
|
|
|
//int workAreaId = 10;
|
|
|
|
|
//string eventTime = "0";
|
|
|
|
|
//if (workAreaId == 0 && eventTime == "0")
|
|
|
|
|
//{ }
|
|
|
|
|
//和json文件的otime 时间需要一致
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//WorkAreaId = 1,更新realtimeeventresult
|
|
|
|
|
// 上传前,检查workAreaId和eventTime
|
|
|
|
|
sqlNumber = $"SELECT COUNT(*) FROM {tbrealtimeresult} WHERE WorkAreaId = '{workAreaId}' && EventTime='{EventTime}'";
|
|
|
|
|
cmd = new MySqlCommand(sqlNumber, conn);
|
|
|
|
|
int b = conn.QueryFirst<int>(sqlNumber);
|
|
|
|
|
if (b == 0)
|
|
|
|
|
{
|
|
|
|
|
sqlNumber = $"INSERT INTO {tbrealtimeresult}(WorkAreaId, EventTime, OriginTime, X, Y, Z, ML, LocSta, MLSta, RMS) VALUES('{workAreaId}', '{EventTime}', '{OriginTime}', '{index_file_line[1]}', '{index_file_line[2]}', '{index_file_line[3]}', '{index_file_line[5]}', '{index_file_line[7]}', '{index_file_line[8]}', '{index_file_line[6]}')";
|
|
|
|
|
var res = conn.Execute(sqlNumber);
|
|
|
|
|
isUpload = true;
|
|
|
|
|
conn.Execute(sqlNumber);
|
|
|
|
|
_log.Log.DebugFormat("UploadRealtimeFileOnce() 上传数据表:{0},eventMessage:{1}", tbrealtimeresult, eventMessage);
|
|
|
|
|
}
|
|
|
|
|
isUpload = true;
|
|
|
|
|
// .mseed文件
|
|
|
|
|
FileStream fs = new FileStream(dFile.FullName, FileMode.Open, FileAccess.Read);
|
|
|
|
|
BinaryReader mbr = new BinaryReader(fs);
|
|
|
|
@ -97,12 +105,11 @@ namespace Txgy.FilesWatcher.model
|
|
|
|
|
{
|
|
|
|
|
sqlNumber = $"INSERT INTO {tbname} (EventTime, WorkAreaID, WaveData, JsonFile) VALUES('{EventTime}', '{workAreaId}', @mDatas, @jDatas);";
|
|
|
|
|
MySqlCommand mycomm = new MySqlCommand(sqlNumber, conn);
|
|
|
|
|
res = conn.Execute(sqlNumber, new { mDatas = mseedDatas, jDatas = jsonDatas });
|
|
|
|
|
conn.Execute(sqlNumber, new { mDatas = mseedDatas, jDatas = jsonDatas });
|
|
|
|
|
_log.Log.DebugFormat("UploadRealtimeFileOnce() 上传数据表:{0}", tbname);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')";
|
|
|
|
|
res = conn.Execute(sqlNumber);
|
|
|
|
|
int res = conn.Execute(sqlNumber);
|
|
|
|
|
_log.Log.DebugFormat("UploadRealtimeFileOnce() 上传数据表:{0},文传:{1}", uploadedtbname, file);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -112,15 +119,12 @@ namespace Txgy.FilesWatcher.model
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_log.Log.ErrorFormat("UploadRealtimeFile.UploadRealtimeFileOnce() error:{0}", ex);
|
|
|
|
|
MessageBox.Show(ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
_log.Log.Debug("UploadRealtimeFile.UploadRealtimeFileOnce() < exit....");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void UploadRealtimeFileMQ(Action<string, string> mqAction, string path, string eventMessage)
|
|
|
|
|
{
|
|
|
|
|
GetLogger _log = new GetLogger("UploadRealtimeFile");
|
|
|
|
|
_log.Log.Debug("UploadRealtimeFile.UploadRealtimeFileMQ() > enter....");
|
|
|
|
|
_log.Log.DebugFormat("UploadRealtimeFile.UploadRealtimeFileMQ() path:{0},eventMessage:{1}", path, eventMessage);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -151,10 +155,8 @@ namespace Txgy.FilesWatcher.model
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//MessageBox.Show(ex.ToString());
|
|
|
|
|
_log.Log.ErrorFormat("UploadRealtimeFile.UploadRealtimeFileMQ() error:{0}", ex);
|
|
|
|
|
}
|
|
|
|
|
_log.Log.Debug("UploadRealtimeFile.UploadRealtimeFileMQ() < exit....");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|