private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
CommonMethod.ExecuteFunc(_broker => {
var dt = _broker.ExecuteSQLForDst($@"SELECT deviceid from sm_device where is_deleted=0").Tables[0];
if (dt.Rows.Count == 0)
{
return;
}
else
{
dt = _broker.ExecuteSQLForDst($@"SELECT GROUP_CONCAT(deviceid,'') from sm_device where is_deleted=0").Tables[0];
var Ids = dt.Rows[0][0].ToString();
for (int i = 0; i < intercept(Ids).Count(); i++) {
SearchOprationLog(intercept(Ids)[i]);
}
}
}, ex => {
Console.Write(ex.Message);
});
}
//将以逗号分隔的id字符串按每20个id截取分组存进list中并返回
public List<string> intercept(string a) {
String[] b = a.Split(',');
int splitLength = 20;
int start = 0;
int end = start + splitLength;
List<string> idList = new List<string>();
while (end < b.Length)
{
StringBuilder builder = new StringBuilder();
for (int i = start; i < end; i++)
{
builder.Append(b[i] + ",");
}
String str = builder.ToString();
String c = str.Substring(0, str.LastIndexOf(","));
idList.Add(c);
start = end;
end = end + splitLength;
}
if (start <= b.Length)
{
StringBuilder builder = new StringBuilder();
for (int i = start; i < b.Length; i++)
{
builder.Append(b[i] + ",");
}
String c = builder.ToString().Substring(0, builder.ToString().LastIndexOf(","));
idList.Add(c);
}
return idList;
}
//查询操作记录接口
public void SearchOprationLog(string deviceIds) {
}