2021-05-27 15:58:23 +05:00
|
|
|
|
using System;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NLog.Config;
|
|
|
|
|
using NLog.Targets;
|
|
|
|
|
using DataClient;
|
2021-05-28 20:51:55 +05:00
|
|
|
|
using System.Net.Sockets;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2021-06-03 16:43:40 +05:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-05-27 15:58:23 +05:00
|
|
|
|
|
|
|
|
|
namespace Test2
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
2021-06-04 16:57:32 +05:00
|
|
|
|
static bool cycle = true;
|
2021-05-27 15:58:23 +05:00
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
LogConf();
|
2021-06-04 16:57:32 +05:00
|
|
|
|
var t = new Task(() => T1());
|
|
|
|
|
t.Start();
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
cycle = false;
|
|
|
|
|
//Console.WriteLine("Hello World!");
|
2021-05-27 15:58:23 +05:00
|
|
|
|
}
|
|
|
|
|
static void LogConf()
|
|
|
|
|
{
|
|
|
|
|
var conf = new LoggingConfiguration();
|
|
|
|
|
var logcon = new ColoredConsoleTarget()
|
|
|
|
|
{
|
|
|
|
|
Name = "logcon",
|
|
|
|
|
Layout = @"${time}|${level:uppercase=true}|${logger}|${message}${when:when=length('${exception}')>0:Inner=|}${exception:format=ToString,StackTrace}"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
conf.AddRule(LogLevel.Trace, LogLevel.Fatal, logcon);
|
|
|
|
|
LogManager.Configuration = conf;
|
|
|
|
|
}
|
2021-05-28 20:51:55 +05:00
|
|
|
|
|
|
|
|
|
static void testSocket()
|
|
|
|
|
{
|
|
|
|
|
Socket s = null;
|
|
|
|
|
IPEndPoint ipe = new IPEndPoint(IPAddress.Parse("10.10.45.152"), 1070);
|
|
|
|
|
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
|
|
|
var code = "slit history";
|
|
|
|
|
var send = new List<byte>();
|
|
|
|
|
for (var i = 0; i < 4; i++)
|
|
|
|
|
send.Add(0xff);
|
|
|
|
|
send.AddRange(BitConverter.GetBytes((uint)code.Length));
|
|
|
|
|
send.AddRange(Encoding.ASCII.GetBytes(code));
|
|
|
|
|
send.Add(0x00);
|
|
|
|
|
|
|
|
|
|
s.Connect(ipe);
|
|
|
|
|
s.Send(send.ToArray());
|
|
|
|
|
|
2021-06-03 16:43:40 +05:00
|
|
|
|
}
|
2021-05-28 20:51:55 +05:00
|
|
|
|
|
2021-06-03 16:43:40 +05:00
|
|
|
|
static void T1()
|
2021-06-04 16:57:32 +05:00
|
|
|
|
{
|
|
|
|
|
var t = new NETClient("10.10.45.151", 1070);
|
|
|
|
|
while (cycle)
|
|
|
|
|
{
|
|
|
|
|
var arr = t.Full_Server_Time();
|
|
|
|
|
Console.WriteLine(arr.ToString("yyyy.MM.dd HH.mm.ss"));
|
|
|
|
|
Task.Delay(1000).Wait();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void OLD4()
|
|
|
|
|
{
|
|
|
|
|
var t = new NETClient("10.10.45.151", 1070);
|
|
|
|
|
var task1 = new Task(() => t.Full_Download(new DateTime(2021, 06, 04), 33, 1));
|
|
|
|
|
var task2 = new Task(() => t.Full_Download(new DateTime(2021, 06, 04), 34, 1));
|
|
|
|
|
task1.Start();
|
|
|
|
|
task1.GetAwaiter().GetResult();
|
|
|
|
|
task2.Start();
|
|
|
|
|
task2.GetAwaiter().GetResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void OLD1()
|
2021-06-03 16:43:40 +05:00
|
|
|
|
{
|
|
|
|
|
var t = new NETClient("10.10.45.151", 1070);
|
|
|
|
|
var task = new Task<byte[]>(() => t.Full_Download_NH(new DateTime(2021, 06, 02), 12, 1));
|
|
|
|
|
task.Start();
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Status: " + (Math.Round(t.Status * 10000) / 100).ToString() + "%");
|
|
|
|
|
Task.Delay(1000).Wait();
|
|
|
|
|
} while (task.Status == TaskStatus.Running);
|
|
|
|
|
var res = (task.IsCompletedSuccessfully) ?
|
|
|
|
|
task.GetAwaiter().GetResult() :
|
|
|
|
|
Array.Empty<byte>();
|
|
|
|
|
using (var file = new FileStream(Directory.GetCurrentDirectory() + "/test1.txt", FileMode.Create, FileAccess.Write))
|
|
|
|
|
{
|
|
|
|
|
file.Write(res, 0, res.Length);
|
|
|
|
|
}
|
2021-05-28 20:51:55 +05:00
|
|
|
|
}
|
2021-06-04 16:57:32 +05:00
|
|
|
|
static void OLD2()
|
2021-06-03 16:43:40 +05:00
|
|
|
|
{
|
|
|
|
|
string[] tes = {
|
|
|
|
|
"version",
|
|
|
|
|
"file list",
|
|
|
|
|
"download",
|
|
|
|
|
"pasp browse",
|
|
|
|
|
"pasp download",
|
|
|
|
|
"pasp find",
|
|
|
|
|
"prog list",
|
|
|
|
|
"prog download",
|
|
|
|
|
"server time",
|
|
|
|
|
"download usov",
|
|
|
|
|
"slit history",
|
|
|
|
|
"keep alive",
|
|
|
|
|
"vdp cycle",
|
|
|
|
|
"vdp active",
|
|
|
|
|
"vdp last cycle",
|
|
|
|
|
"rmt watchdog",
|
|
|
|
|
"set rmt watchdog",
|
|
|
|
|
"print job",
|
|
|
|
|
"pasp find2",
|
|
|
|
|
"pasp browse2",
|
|
|
|
|
"arch history",
|
|
|
|
|
"download nh",
|
|
|
|
|
"download usov nhv",
|
|
|
|
|
"dir browse",
|
|
|
|
|
"vdp sim med",
|
|
|
|
|
"vdp flags",
|
|
|
|
|
"user flags",
|
|
|
|
|
"user motd",
|
|
|
|
|
"user mail",
|
|
|
|
|
"download tvso",
|
|
|
|
|
"pasp download tvso",
|
|
|
|
|
"pasp find tvso",
|
|
|
|
|
"pasp browse tvsov",
|
|
|
|
|
"korpus cycle",
|
|
|
|
|
"korpus last cycle",
|
|
|
|
|
"download fdan",
|
|
|
|
|
"client version",
|
|
|
|
|
"measure id",
|
|
|
|
|
"read vdp config",
|
|
|
|
|
"write vdp config",
|
|
|
|
|
"read tvso config",
|
|
|
|
|
"delete vdp config",
|
|
|
|
|
"get plav personal",
|
|
|
|
|
"get server info",
|
|
|
|
|
"ctrl split",
|
|
|
|
|
"ctrl set time",
|
|
|
|
|
"ctrl end tc",
|
|
|
|
|
"ctrl remove",
|
|
|
|
|
"ctrl spool",
|
|
|
|
|
"save pasport",
|
|
|
|
|
"save pasport 90",
|
|
|
|
|
"find time bugs",
|
|
|
|
|
"update pasport",
|
|
|
|
|
"get pasp by id",
|
|
|
|
|
"cp com find pasp by temp",
|
|
|
|
|
"get splav list",
|
|
|
|
|
"get field val list",
|
|
|
|
|
"get plav list form",
|
|
|
|
|
"get pasp by priv",
|
|
|
|
|
"print job 2",
|
|
|
|
|
"get pasp by name",
|
|
|
|
|
"get pasp by id 90",
|
|
|
|
|
"find pasp by temp 90",
|
|
|
|
|
"get pasp by priv 90",
|
|
|
|
|
"get pasp by name 90",
|
|
|
|
|
"get plav list form 90",
|
|
|
|
|
"ctrl split db",
|
|
|
|
|
"ctrl set time db",
|
|
|
|
|
"ctrl remove db",
|
|
|
|
|
"update stat",
|
|
|
|
|
"get cur params arr",
|
|
|
|
|
"get cur params",
|
|
|
|
|
"get cur params arr 5",
|
|
|
|
|
"get cur params 5",
|
|
|
|
|
"fix db cycle",
|
|
|
|
|
"by name",
|
|
|
|
|
"test"
|
|
|
|
|
};
|
|
|
|
|
var t = new NETClient("10.10.45.151", 1070);
|
|
|
|
|
using (var file = new StreamWriter(Directory.GetCurrentDirectory() + "/test_by_name.txt"))
|
|
|
|
|
{
|
|
|
|
|
for (var i = 0; i < tes.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var res = t.Full_By_Name(tes[i]);
|
|
|
|
|
if (res != null)
|
|
|
|
|
foreach (var b in res)
|
|
|
|
|
file.Write("0x" + b.ToString("X2") + " ");
|
|
|
|
|
file.Write("- ");
|
|
|
|
|
if (res != null)
|
|
|
|
|
file.Write(BitConverter.ToUInt32(res).ToString("D4") + " - ");
|
|
|
|
|
file.WriteLine(tes[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-04 16:57:32 +05:00
|
|
|
|
static void OLD3()
|
|
|
|
|
{
|
|
|
|
|
var rnd = new Random();
|
|
|
|
|
var t = new NETClient("10.10.45.151", 1070);
|
|
|
|
|
string[] a = null;
|
|
|
|
|
int c = 0;
|
|
|
|
|
for (var i = 0; i < 8; i++)
|
|
|
|
|
{
|
|
|
|
|
if (a == null || a.Length == 0)
|
|
|
|
|
a = t.Full_Dir_Browse();
|
|
|
|
|
else
|
|
|
|
|
a = t.Full_Dir_Browse(a[c]);
|
|
|
|
|
Console.WriteLine((i + 1).ToString() + " test:");
|
|
|
|
|
if (a != null)
|
|
|
|
|
foreach (var e in a) Console.WriteLine(e);
|
|
|
|
|
else
|
|
|
|
|
Console.WriteLine("NULL");
|
|
|
|
|
c = (a == null) ? 0 : rnd.Next(0, a.Length);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-03 16:43:40 +05:00
|
|
|
|
|
2021-05-27 15:58:23 +05:00
|
|
|
|
}
|
|
|
|
|
}
|