¤NameÀ¤User¤Name¬1nvisibleMan¤Icon¤GuidÙ$f8cd88b1-1b2f-4fa2-8b36-77a9264dca6e¢IdÌ
§ServiceÀ«TimeCreated×ÿJÀg¿ºÃ¢IdÙ$4b7eb4c4-7c03-4aee-9f74-1e5c93b3be46¢IdÙ4Microsoft.VisualStudio.Conversations.Chat.HelpWindow¨Metadata¨IsThreadðConversationMode°ExperimentalChatªResponders¤Name®GitHub Copilot¤Icon¤GuidÙ$4515b9bd-70a1-45fa-9545-d4536417c596¢Id§Service¤NameÙ7Microsoft.VisualStudio.Copilot.CopilotChatAgentProvider§Version£0.3 CorrelationIdÙ$7bb4b94c-1be0-4840-80b8-aad1069c024d©MessageIdÙ$c2544384-1083-497f-a96d-26fb0bfe834b§Context®ValueContainerÙMicrosoft.VisualStudio.Copilot.DocumentContext, Microsoft.VisualStudio.Copilot, Version=17.13.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aÓ Ò
§ContentÚusing HH.WCS.QingXigongchang.api;
|
using HH.WCS.QingXigongchang.core;
|
using HH.WCS.QingXigongchang.device;
|
using HH.WCS.QingXigongchang.process;
|
using HH.WCS.QingXigongchang.util;
|
using HH.WCS.QingXigongchang.wms;
|
using Microsoft.Owin.Hosting;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Diagnostics;
|
using System.IO;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Sockets;
|
using System.Net.WebSockets;
|
using System.Runtime.InteropServices;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using Topshelf;
|
using Monitor = HH.WCS.QingXigongchang.core.Monitor;
|
|
namespace HH.WCS.QingXigongchang
|
{
|
internal class Program
|
{
|
#region å
³éæ§å¶å° å¿«éç¼è¾æ¨¡å¼ãæå
¥æ¨¡å¼
|
const int STD_INPUT_HANDLE = -10;
|
const uint ENABLE_QUICK_EDIT_MODE = 0x0040;
|
const uint ENABLE_INSERT_MODE = 0x0020;
|
[DllImport("kernel32.dll", SetLastError = true)]
|
internal static extern IntPtr GetStdHandle(int hConsoleHandle);
|
[DllImport("kernel32.dll", SetLastError = true)]
|
internal static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint mode);
|
[DllImport("kernel32.dll", SetLastError = true)]
|
internal static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint mode);
|
|
public static void DisbleQuickEditMode()
|
{
|
IntPtr hStdin = GetStdHandle(STD_INPUT_HANDLE);
|
uint mode;
|
GetConsoleMode(hStdin, out mode);
|
mode &= ~ENABLE_QUICK_EDIT_MODE;//ç§»é¤å¿«éç¼è¾æ¨¡å¼
|
mode &= ~ENABLE_INSERT_MODE; //ç§»é¤æå
¥æ¨¡å¼
|
SetConsoleMode(hStdin, mode);
|
}
|
#endregion
|
static void Main(string[] args)
|
{
|
string currentProcessName = Process.GetCurrentProcess().ProcessName;
|
Process[] processes = Process.GetProcessesByName(currentProcessName);
|
if (processes.Length <= 1)
|
{
|
LogHelper.Info(">>>>>>>>>>>>>>>>>>> ç¨åºå¯å¨<<<<<<<<<<<<<<<<<<<<<<<<");
|
}
|
else
|
{
|
Console.WriteLine("ç¨åºå·²ç»å¨è¿è¡ï¼æ æ³å¼å¯æ°çå®ä¾ã");
|
return;
|
}
|
List<int> ints = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
|
foreach (var item in ints.GroupBy(x => (x + 1) / 2))
|
{
|
Console.WriteLine(item.Key + ":::" + JsonConvert.SerializeObject(item.ToList()));
|
}
|
|
string avvv = "";
|
Encoding.UTF8.GetBytes(avvv);
|
|
//List<string> strings = new List<string>() { "", "1", "" };
|
//byte[] a = new byte[] { };
|
//var _b = a.Skip(addr).Take(len).toarray();
|
|
//_b.skip(_b.tolist().FindIndex(x => x > 0));
|
//var a = Settings.GetDeviceInfoList()[2].taskPri;
|
|
//string te = "æå-空æä¸çº¿xiaoban";
|
//var aa=Settings.GetDeviceInfoList();
|
|
// return true;
|
//});
|
var List = new List<Location>();
|
|
List.Add(new Location
|
{
|
S_LOC_CODE = "1-2",
|
N_COL = 2,
|
N_ROW = 1,
|
N_CURRENT_NUM = 2
|
});
|
|
List.Add(new Location
|
{
|
S_LOC_CODE = "1-1",
|
N_COL = 1,
|
N_ROW = 1,
|
N_CURRENT_NUM = 2
|
});
|
|
List.Add(new Location
|
{
|
S_LOC_CODE = "3-1",
|
N_COL = 1,
|
N_ROW = 3,
|
N_CURRENT_NUM = 0
|
});
|
|
List.Add(new Location
|
{
|
S_LOC_CODE = "2-2",
|
N_COL = 2,
|
N_ROW = 2,
|
N_CURRENT_NUM = 1
|
});
|
|
List.Add(new Location
|
{
|
S_LOC_CODE = "2-1",
|
N_COL = 1,
|
N_ROW = 2,
|
N_CURRENT_NUM = 0
|
});
|
|
|
var bbbc = List.OrderBy(x => x.N_COL).ThenBy(x => x.N_ROW).Skip(List.FindLastIndex(x => x.N_ROW == 3));//.Select(x => new { x.N_ROW, x.N_COL });
|
var bbb = List.GroupBy(x => x.N_ROW).OrderBy(x => x.ToList().FindAll(y => y.N_CURRENT_NUM > 0).Count);
|
Dictionary<string, int> map = new Dictionary<string, int>();
|
map.Add("1-2", -3);
|
map.Add("1-3", 3);
|
map.Add("1-4", 0);
|
map.Add("2-3", 2);
|
map.Add("2-4", 1);
|
map.Add("3-4", -2);
|
var _map = map.OrderBy(x => x.Value);
|
var _map2 = map.OrderBy(x => x.Value > 0);
|
var _map3 = map.OrderBy(x => x.Value).ThenBy(n => Math.Abs(n.Value)).ToArray();
|
var _map4 = map.OrderBy(x => Math.Abs(x.Value)).ThenBy(n => n.Value).ToArray();
|
var _map5 = map.OrderBy(x => x.Value >= 0).ThenBy(n => Math.Abs(n.Value)).ToArray();
|
//foreach (var item in map)
|
{
|
//Console.WriteLine(item);
|
}
|
//var v = new string[] { "QX-04_J", "QX-04_D", "QX04_J", "QX4_X", "QX-12_A", "QX-08_X", "QX-08_XC", "QX-08_DC" };
|
//foreach (var item in v)
|
//{
|
// var m = System.Text.RegularExpressions.Regex.Matches(item, @"QX-\d+_[A-Z]+");
|
// if (m.Count > 0)
|
// foreach (Match match in m)
|
// {
|
// Console.WriteLine(match.Value);
|
// }
|
//}
|
Console.WriteLine("");
|
//new WmsController().BindLoc3(new { loc = "PPMKCK=1-2", LineNo = "ç¿»ææº", ItemCode = "550mlæ°´_15å
¥_èå
_6" });
|
//var b = new List<Location>(List);
|
//b.RemoveRange(0, 2);
|
//var b = List.OrderBy(x => x.N_CURRENT_NUM).GroupBy(x => x.N_COL);
|
|
//var a = TaskHelper.GetAgvTask(new WMSTask { S_TASK_NO = "WW0001" });
|
//var æ¯ = Settings.GetDoorOneToMany();
|
|
|
//SuGGAttribute.attributes = new Dictionary<string, string>();
|
#region è·å表é
ç½®
|
int tableCount = 0;
|
LogHelper.Info("å¼å§å 载表é
置信æ¯");
|
try
|
{
|
var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "\\TableSetting.json";
|
if (!File.Exists(jsonFile))
|
{
|
LogHelper.Error("è·åjsonæä»¶å¤±è´¥ï¼åå ï¼è¿ä¸ªjsonæä»¶å°±ä¸åå¨,æä¸ªå±çå¼ï¼\n ä½ å»ççè¿ä¸ªè·¯å¾ææ²¡ææä»¶â:ã" + jsonFile + "ã", new FileLoadException("没æè¡¨é
ç½®æä»¶"));
|
Console.ReadKey();
|
}
|
using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile))
|
{
|
using (JsonTextReader reader = new JsonTextReader(file))
|
{
|
JObject o = (JObject)JToken.ReadFrom(reader);
|
foreach (Newtonsoft.Json.Linq.JProperty keyValue in o.Properties())
|
{
|
string value = keyValue.Value.ToString();
|
if (string.IsNullOrEmpty(value))
|
{
|
LogHelper.Error("ã" + keyValue.Name.Trim() + "ã" + "表é
置表å为空ï¼", new ArgumentException("表å为空"));
|
Console.ReadKey();
|
}
|
SuGGAttribute.attributes.Add(keyValue.Name.Trim(), value);
|
tableCount++;
|
}
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error("å 载表é
ç½®æä»¶å¤±è´¥ï¼" + ex.Message, ex);
|
Console.ReadKey();
|
}
|
if (tableCount == 0)
|
{
|
LogHelper.Error("å è½½å°0个表é
置信æ¯ã", new Exception("å 载表é
ç½®æä»¶å¤±è´¥ï¼"));
|
Console.ReadKey();
|
}
|
#endregion
|
#region æµè¯ä»£ç åºåã
|
|
//LocationHelper.DoAction(db =>
|
//{
|
// var S_CNTRS = "FTP2312050001vTP2312050002";
|
// var fulectlist = LocationHelper.GetFuLeTrayCodeList(f => S_CNTRS.Contains(f.trayCode.Trim()));
|
// LogHelper.Info("Fuæååè´§" + S_CNTRS + "--<>--" + JsonConvert.SerializeObject(fulectlist));
|
// //foreach (var item in fulectlist)
|
// //{
|
// // item.SQL_State = "宿";
|
// // db.Updateable<FuLeTrayCode>(item).UpdateColumns(it => new { it.SQL_State }).ExecuteCommand();
|
// //}
|
// if (fulectlist.Any())
|
// db.Updateable<FuLeTrayCode>(fulectlist).ReSetValue(it => { it.SQL_State = "宿" }).ExecuteCommand();
|
// return true;
|
//});
|
|
//var l = LocationHelper.GetAllLocList().First();
|
//var b = l.S_LOC_CODE;
|
//LocationHelper.lOCReSetValue(x => x.S_LOC_CODE == b, lo =>
|
//{
|
// lo.S_LOCK_STATE = "åºåºé";
|
//});
|
|
//l = LocationHelper.GetAllLocList().First();
|
//b = l.S_LOCK_STATE;
|
//LocationHelper.lOCReSetValue(x => x.S_LOC_CODE.Trim() == l.S_LOC_CODE, y =>
|
//{
|
// y.N_CURRENT_NUM++;
|
//});
|
//var c = LocationHelper.GetAllLocList().First();
|
//var d = c.N_CURRENT_NUM;
|
|
|
//var asasd = Settings.GetInStockCacheList();
|
//var locs = LocationHelper.GetAllLocList();
|
//var b = locs.OrderBy(x => x.N_COL).ThenBy(x => x.N_ROW).GroupBy(x => x.N_COL).ToList();
|
//foreach (var item in b)
|
//{
|
// var _collocs = item.ToList();
|
//}
|
//var l = LocationHelper.GetAllLocList();
|
#endregion
|
|
//å
³é å¿«éç¼è¾ãæå
¥æ¨¡å¼
|
DisbleQuickEditMode();
|
|
#region å³äº§ éå¡ éå³äº§ éå¡
|
//Container c_tie = ContainerHelper.GetContainer(x => x.S_CNTR_CODE == "UsNow2347" && x.S_TYPE == "éç");
|
//if (c_tie == null)
|
//{
|
// LocationHelper.DoAction(db =>
|
// {
|
// var res = db.Insertable<Container>(new Container
|
// {
|
// S_CNTR_CODE = "UsNow2347",
|
// S_TYPE = "éç",
|
// }).ExecuteCommand() > 0;
|
// return res;
|
// });
|
//}
|
//c_tie = ContainerHelper.GetContainer(x => x.S_CNTR_CODE == "UsAfter2347" && x.S_TYPE == "塿ç");
|
//if (c_tie == null)
|
//{
|
// LocationHelper.DoAction(db =>
|
// {
|
// var res = db.Insertable<Container>(new Container
|
// {
|
// S_CNTR_CODE = "UsAfter2347",
|
// S_TYPE = "塿ç",
|
// }).ExecuteCommand() > 0;
|
// return res;
|
// });
|
//}
|
// å³+tmesapn
|
#endregion
|
|
|
{
|
|
|
if (true)
|
{
|
Task task = null;
|
var ips = "";
|
var host = Dns.GetHostEntry(Dns.GetHostName());
|
foreach (var ip in host.AddressList)
|
{
|
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
{
|
Console.WriteLine($"ip= {ip.ToString()}");
|
ips = ip.ToString();
|
break;
|
}
|
}
|
if (false)
|
Task.Run(() =>
|
{
|
// 设置çå¬ç端å£åå°å
|
int port = 8080;
|
string url = $"http://{ips}:" + port + "/";
|
|
// å建ä¸ä¸ªæ°ç HttpListener
|
HttpListener listener = new HttpListener();
|
listener.Prefixes.Add(url);
|
|
// å¼å§çå¬
|
listener.Start();
|
Console.WriteLine("HTTPæå¡å¨å·²å¯å¨ï¼çå¬å°åï¼" + url);
|
|
while (true)
|
{
|
// çå¾
客æ·ç«¯è¿æ¥
|
HttpListenerContext context = listener.GetContext();
|
HttpListenerRequest request = context.Request;
|
HttpListenerResponse response = context.Response;
|
|
// 读å请æ±å
容并è¾åºå°æ§å¶å°
|
Stream body = request.InputStream;
|
StreamReader reader = new StreamReader(body, request.ContentEncoding);
|
string content = reader.ReadToEnd();
|
Console.WriteLine("æ¶å°è¯·æ±ï¼ " + content + ">" + request.Url);
|
// è·å请æ±çæä»¶è·¯å¾
|
string filePath = request.Url.AbsolutePath.Substring(1).ToLower();
|
var file = false;
|
// æ£æ¥è¯·æ±çæä»¶ç±»åå¹¶è¿åç¸åºçéææä»¶
|
if (filePath.EndsWith(".js"))
|
{
|
file = true;
|
filePath = Path.Combine("Static", filePath);
|
//response.ContentType = "text/javascript";
|
}
|
else if (filePath.EndsWith(".css"))
|
{
|
file = true;
|
filePath = Path.Combine("Static", filePath);
|
//response.ContentType = "text/css";
|
}
|
else if (string.IsNullOrEmpty(filePath))
|
{
|
file = true;
|
filePath = Path.Combine("Static", "W.html");
|
response.ContentType = "text/html";
|
|
// 设置ååºå
容åç¶æç
|
//byte[] buffer = File.ReadAllBytes(Path.Combine("Static", "W.html")); ;//
|
//buffer = System.Text.Encoding.UTF8.GetBytes(File.ReadAllText(Path.Combine("Static", "W.html")));
|
|
//response.ContentLength64 = buffer.Length;
|
//response.OutputStream.Write(buffer, 0, buffer.Length);
|
//response.ContentType = "text/html";
|
//response.StatusCode = 200;
|
//response.OutputStream.Close();
|
}
|
else
|
{
|
response.StatusCode = 404;
|
var bt = Encoding.UTF8.GetBytes("å°åæ æï¼");
|
response.OutputStream.Write(bt, 0, bt.Length);
|
response.OutputStream.Close();
|
}
|
//// 读åæä»¶å
容并åéç»å®¢æ·ç«¯
|
if (file)
|
try
|
{
|
//byte[] buffer = File.ReadAllBytes(filePath);
|
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(File.ReadAllText(filePath));
|
response.ContentLength64 = buffer.Length;
|
response.OutputStream.Write(buffer, 0, buffer.Length);
|
response.StatusCode = 200;
|
}
|
catch (FileNotFoundException ex)
|
{
|
response.StatusCode = 404;
|
response.OutputStream.Write(Encoding.UTF8.GetBytes("æä»¶æªæ¾å°"), 0, Encoding.UTF8.GetBytes("æä»¶æªæ¾å°").Length);
|
}
|
catch (Exception ex)
|
{
|
Console.WriteLine(ex.Message);
|
}
|
finally
|
{
|
response.OutputStream.Close();
|
}
|
}
|
});
|
|
//Task.Run(() =>
|
//{
|
var httpListener = new HttpListener();
|
httpListener.Prefixes.Add($"http://{ips}:8181/");
|
httpListener.Start();
|
Console.WriteLine($"Listening on http://{ips}:8181/");
|
|
while (true)
|
{
|
var context = httpListener.GetContext();
|
if (context.Request.IsWebSocketRequest)
|
{
|
ProcessRequest(context);
|
}
|
}
|
//});
|
}
|
// è¦æ§è¡ç C# 代ç å符串
|
// string code = @"
|
// int Add(int a, int b, int c)
|
// {
|
// return a + b + c;
|
// }
|
// Add(a, b, c);
|
//";
|
|
// // å®ä¹åæ°
|
// var gg = new tempClass();
|
// gg.a = 5;
|
// gg.b = 10;
|
// gg.c = 15;
|
|
// try
|
// {
|
// // æ§è¡ä»£ç å¹¶è·åç»æ
|
// var result = CSharpScript.Create<int>(code, ScriptOptions.Default, typeof(tempClass)).RunAsync(gg);
|
// result.Wait();
|
// Console.WriteLine($"Result: {result.Result}");
|
// }
|
// catch (CompilationErrorException e)
|
// {
|
// Console.WriteLine("Compilation Errors:");
|
// foreach (var diagnostic in e.Diagnostics)
|
// {
|
// Console.WriteLine($"{diagnostic.Id}: {diagnostic.GetMessage()}");
|
// }
|
// }
|
// catch (Exception e)
|
// {
|
// Console.WriteLine($"Execution Error: {e.Message}");
|
// }
|
|
////string code1 = @"
|
////public class ScriptedClass
|
////{
|
//// public string HelloWorld { get; set; }
|
//// public ScriptedClass()
|
//// {
|
//// HelloWorld = ""Hello Roslyn!"";
|
//// }
|
|
////}";
|
|
////var script = CSharpScript.RunAsync(code1).Result;
|
|
////var result = script.ContinueWithAsync<string>("new ScriptedClass().HelloWorld").Result;
|
|
////Console.WriteLine(result.ReturnValue);
|
|
//var loc = new Location
|
//{
|
// S_LOC_CODE = "2-1",
|
// N_COL = 1,
|
// N_ROW = 2,
|
// N_CURRENT_NUM = 0
|
//};
|
//string code = @"int result = 1 + 2; Console.WriteLine(result);if (S_LOC_CODE==""2-1"")return true; else return false;";
|
//var options = ScriptOptions.Default.WithImports("System");
|
//var script1 = CSharpScript.Create<bool>(code, options, typeof(Location));
|
//var v = script1.RunAsync(loc);
|
//v.Wait();
|
//Console.WriteLine(v.Result.ReturnValue);
|
//code = @"int result = 1 + 2; return new tempClass().Good(S_LOC_CODE);";
|
//options = ScriptOptions.Default.WithImports("System");
|
//var script2 = CSharpScript.Create(code, options.WithReferences(typeof(tempClass).Assembly), typeof(Location));
|
//var v2 = script2.RunAsync(loc);
|
//v2.Wait();
|
//Console.WriteLine(v.Result.ReturnValue);
|
|
|
|
//Console.SetWindowSize(120, 36);
|
//Console.SetBufferSize(120, 36);
|
//Console.Title = "æ¸
溪 wcsç¨åºæ§å¶æ»å°";
|
//Console.CursorVisible = false;
|
//Console.SetCursorPosition(0, 0);
|
//Console.WriteLine("æ ¹ç®å½" + System.Environment.CurrentDirectory);
|
//Console.WriteLine("ç³»ç»ç®å½" + System.Environment.SystemDirectory);
|
//Console.WriteLine("该è¿ç¨çå½ä»¤è¡" + System.Environment.CommandLine);
|
//Console.WriteLine("è·åæ¤æ¬å°è®¡ç®æºç NetBIOS åç§°ã" + System.Environment.MachineName);
|
//Console.WriteLine("è·åå½åè®¡ç®æºä¸çå¤ç卿°" + System.Environment.ProcessorCount);
|
//Console.WriteLine("ä¸ä¸ªå
å«å¹³å°æ è¯ç¬¦åçæ¬å·ç对象" + System.Environment.OSVersion);
|
//Console.WriteLine("è·å为æ¤ç¯å¢å®ä¹çæ¢è¡å符串ã" + System.Environment.NewLine);
|
//Console.WriteLine("è·åå½åç»å½ç¨æ·" + System.Environment.UserName);
|
//Console.WriteLine("è·åä¸ä¸ªå¼ï¼ç¨ä»¥æç¤ºå½åè¿ç¨æ¯å¦å¨ç¨æ·äº¤äºæ¨¡å¼ä¸è¿è¡" + System.Environment.UserInteractive);
|
//Console.WriteLine("è·åä¸å½åç¨æ·å
³èçç½ç»ååã" + System.Environment.UserDomainName);
|
//Console.WriteLine("è·åç³»ç»å¯å¨åç»è¿çæ¯«ç§æ°" + System.Environment.TickCount);
|
//Console.WriteLine("è·åå½åçå æ è·è¸ªä¿¡æ¯ã" + System.Environment.StackTrace);
|
//Console.WriteLine(" è·åæ å°å°è¿ç¨ä¸ä¸æçç©çå
åéã" + System.Environment.WorkingSet);
|
//Console.WriteLine("ç¨äºæ¾ç¤ºå
Œ
±è¯è¨è¿è¡æ¶çæ¬ç对象" + System.Environment.Version);
|
//Console.WriteLine("ä»å½åè¿ç¨æ£ç´¢ç¯å¢åéçå¼" + System.Environment.GetEnvironmentVariable("Path"));
|
//Console.WriteLine("ä»å½åè¿ç¨æ£ç´¢ç¯å¢åéçå¼" + System.Environment.GetEnvironmentVariables());
|
//Console.WriteLine("ä»å½åè¿ç¨æè
ä»å½åç¨æ·ææ¬å°è®¡ç®æºç Windows æä½ç³»ç»æ³¨å表项æ£ç´¢ææç¯å¢åéååå
¶å¼" + System.Environment.GetEnvironmentVariables());
|
//Console.WriteLine("è¿åæ¡é¢çè·¯å¾" + System.Environment.GetFolderPath(SpecialFolder.Desktop));
|
//Console.SetCursorPosition(0, 0);
|
|
//for (int i = 0; i < 15; i++)
|
//{
|
// Console.WriteLine(i + "···················································");
|
//}
|
|
//for (int i = 0; i < 6; i++)
|
//{
|
// Console.SetCursorPosition(2, i * 2);
|
// Console.WriteLine("vv");
|
// Thread.Sleep(1000);
|
//}
|
|
}
|
;
|
|
|
//LocationHelper.DoAction(db =>
|
//{
|
// //var a = db.Queryable<Location>().Includes(aa => aa.LocCntrRels).Where(x => x.S_LOC_CODE == "PGKQ-03-10").ToList();
|
|
// //var a = db.Queryable
|
//ContainerHelper.GetCntrItemRel
|
|
|
|
|
//1.0 å¼å¯api
|
Startup();
|
//2.0 å¼å¯tcp
|
StartTcp();
|
|
LocationHelper.DoAction(db =>
|
{
|
var c = db.Queryable<CntrItemRel>().Where(a => a.S_CNTR_CODE.Contains("TP" + Settings._TPcc)).OrderByDescending(x => x.T_CREATE).ToList().FirstOrDefault();
|
|
LogHelper.Info("æçåå§å1- " + c?.S_CNTR_CODE);
|
|
if (c != null)
|
{
|
string tp = c.S_CNTR_CODE.Split('v')[0];
|
var t = tp.Split('_')[0];
|
Settings._TPnum = Convert.ToInt32(t.Substring(8));
|
}
|
LogHelper.Info("æçåå§å2- " + Settings._TPnum);
|
return true;
|
});
|
//3.0 å¼å¯çº¿ç¨
|
var rc = HostFactory.Run(x =>
|
{
|
x.Service<WorkThread>(s =>
|
{
|
s.ConstructUsing(name => new WorkThread());
|
s.WhenStarted(tc => tc.Start());
|
s.WhenStopped(tc => tc.Stop());
|
});
|
x.RunAsLocalSystem();
|
|
x.SetDescription("hh");
|
x.SetDisplayName("hh.wms");
|
x.SetServiceName("hh.wms");
|
|
});
|
|
var exitCode = (int)Convert.ChangeType(rc, rc.GetTypeCode());
|
Environment.ExitCode = exitCode;
|
}
|
|
private static async void ProcessRequest(HttpListenerContext context)
|
{
|
var webSocketContext = await context.AcceptWebSocketAsync(null);
|
var webSocket = webSocketContext.WebSocket;
|
|
while (webSocket.State == WebSocketState.Open)
|
{
|
var buffer = new ArraySegment<byte>(new byte[1024]);
|
var received = await webSocket.ReceiveAsync(buffer, CancellationToken.None);
|
|
if (received.MessageType == WebSocketMessageType.Close)
|
{
|
await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None);
|
}
|
else
|
{
|
string read = Encoding.UTF8.GetString(buffer.Array).TrimEnd('\0');
|
if (read != "reLoad")
|
{
|
Console.WriteLine("WebSocket Request Received " + read);
|
await webSocket.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes("Connection opened")), WebSocketMessageType.Text, true, CancellationToken.None);
|
}
|
else
|
{
|
// Echo the message back to the client
|
//await webSocket.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(DeviceProcess.Deviceooo))), WebSocketMessageType.Text, true, CancellationToken.None);
|
if (!DeviceProcess.Deviceooo.Any())
|
{
|
DeviceProcess.Deviceooo.Add("192.168.1.1", new
|
{
|
äº§çº¿å· = "ccc1",
|
å¯åäº§çº¿å· = "plc.FuLeLineNo",
|
设å¤å· = new List<string> { "","66"},
|
设å¤ç±»å = "plc.deviceType",
|
è´§ä½ = new List<string> { "","22233"},
|
任塿é = "plc.taskPri",
|
ä¿¡å· = "3f0010210d0a",
|
});
|
DeviceProcess.Deviceooo.Add("192.168.1.2", new
|
{
|
äº§çº¿å· = "ccc12",
|
å¯åäº§çº¿å· = "plc.FuLeLineNo2",
|
设å¤å· = "plc.deviceNo2",
|
设å¤ç±»å = "plc.deviceTyp2e",
|
è´§ä½ = "plc.location2",
|
任塿é = "plc.taskPri2",
|
ä¿¡å· = "3f0010210d0a",
|
});
|
}
|
await webSocket.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(DeviceProcess.Deviceooo))), WebSocketMessageType.Text, true, CancellationToken.None);
|
}
|
}
|
}
|
}
|
private static void Startup()
|
{
|
Task.Run(() =>
|
{
|
var url = "http://+:8801";//{SettingHelper.port}
|
restart:
|
try
|
{
|
using (WebApp.Start<Startup>(url))
|
{
|
Console.WriteLine("Running on {0}", url);
|
while (true)
|
Thread.Sleep(int.MaxValue);
|
}
|
}
|
catch (Exception ex)
|
{
|
Console.WriteLine(ex);
|
Thread.Sleep(1000);
|
}
|
Console.WriteLine("API - ç»æ¢");
|
goto restart;
|
});
|
//Console.WriteLine("Startup ApiController");
|
//Action action = () =>
|
//{
|
// var url = "http://+:8801";//{SettingHelper.port}
|
// using (WebApp.Start<Startup>(url))
|
// {
|
// Console.WriteLine("Running on {0}", url);
|
// Console.ReadLine();
|
// }
|
// Console.WriteLine("API - ç»æ¢");
|
//};
|
//Task task = Task.Run(action);
|
//Action action1 = () =>
|
//{
|
// while (true)
|
// {
|
// if (task.IsCanceled || task.IsCompleted || task.IsFaulted)
|
// {
|
// Console.WriteLine("API - 线ç¨ä¸æï¼éå¯éå¯ã");
|
// task = Task.Run(action);
|
// }
|
// Thread.Sleep(1000);
|
// }
|
//};
|
//Task.Run(action1);
|
}
|
private static void StartTcp()
|
{
|
var host = Dns.GetHostEntry(Dns.GetHostName());
|
foreach (var ip in host.AddressList)
|
{
|
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
{
|
Console.WriteLine($"ip= {ip.ToString()}");
|
new TcpServer(ip.ToString());
|
}
|
}
|
}
|
|
public class WorkThread
|
{
|
public void Start()
|
{
|
List<Task> tasks = new List<Task>
|
{
|
GetTask(Monitor.A),//计æ°å¨ æ¸
é¤ æ§å¶å°
|
//æ·»å 任塿¨é线ç¨
|
GetTask(TaskCore.Dispatch),
|
|
GetTask(TaskCore.ChargeHostAgv),
|
//æå¨è½¬è¿
|
GetTask(Monitor.BottleCapAuto2),
|
/// èªå¨è½¬è¿
|
GetTask(Monitor.BottleCapAuto3, 1),
|
//åæ£éæ - æ¸
é¤ æç©ºäºæè§£éã
|
GetTask(Monitor.BottleCapAuto4),
|
//èªå¨é¢æ - ä¸è¾é线
|
GetTask(Monitor.BottleCapAuto5),
|
//空æ¡ä¸è½¬ï¼è½¬ææ¡
|
GetTask(Monitor.BottleCapAuto6),
|
//åºåºåæ¹å
|
GetTask(Monitor.BottleCapAuto7),
|
//èªå¨ä¸è½¬
|
GetTask(Monitor.BB7),
|
|
//tasks.Add(GetTask(DeviceProcess.WJGInoutEF));
|
|
/// æ°´çåã å
¥åºäººå·¥è§£ï¼ åºå
¥ä»åºåºä½è½¬ 550 åºå
¥åºã 5L
|
/* - - éåç¶çæµç¨ã ä¸ä½¿ç¨å
¥åºäº
|
//æ°´çä¹å
¥åº
|
GetTask(DeviceProcess.TakeNotUsing2WH),
|
GetTask(DeviceProcess.TakeNotUsing2FDJXB),
|
GetTask(DeviceProcess.TakeEmpty2WH),
|
GetTask(DeviceProcess.TakeNotUsing2PGXB)
|
*/
|
};
|
|
|
|
//tasks.Add(GetTask(DeviceProcess.TakeNotUsing2PGJ));/// æ°´ç空æ¡ï¼ æ èç©ºæ¡ æ¾ TakeNotUsing2FDJXB ä¸èµ·äº
|
|
//ä¸çº¿åº åºåºæ»¡æ¡ç©ºäº åºæ¡ - ä»åºå
è¿æ¾åºã åå å
è¿ååº
|
|
//ç¿»ææº å空 éæ»¡ ï¼å³äº§ åä¸çº¿å³äº§æ»¡åº éå³äº§ ååºåºæ»¡åºï¼
|
|
//ç¿»ææº åæ»¡ ï¼æå ä»å³å¾å·¦å -
|
//tasks.Add(GetTask(Monitor.TipperAuto));
|
//çµæ¢¯
|
//tasks.Add(GetTask(Monitor.ElevatorTask));
|
//çµæ¢¯
|
//tasks.Add(GetTask(Monitor.OutGo));
|
|
Task.WaitAll(tasks.ToArray());
|
}
|
public void Stop() { Console.WriteLine("work stopped"); }
|
private Task GetTask(Action action, int i = 0)
|
{
|
var task = Task.Run(() =>
|
{
|
while (true)
|
{
|
try
|
{
|
action();
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.Message, ex);
|
if (i == 1)
|
Monitor.AutoTurn = 0;
|
}
|
Thread.Sleep(2500);
|
}
|
});
|
return task;
|
}
|
}
|
}
|
|
public class tempClass
|
{
|
public int a;
|
public int b;
|
|
public int c { get; set; }
|
|
public string Good(string a)
|
{
|
if (a == "2-1")
|
return "oooooooooo";
|
return a;
|
}
|
}
|
}
|
¯OriginalContentÀªSelections¨FilePathÙ1E:\!AGIT\WCS\HH.WCS.Mobox\å夫æ¸
溪\Program.cs¨Language¢C#¯CopilotTypeName¯DocumentContext¨TypeName¤Name¯DocumentContext§IsArray¢IdÙ$d3c74391-f447-40ee-944b-2d67b41cf5db¯ProviderMoniker¤NameÙ6Microsoft.VisualStudio.Copilot.DocumentContextProvider§Version£0.3¦SourceÙ6Microsoft.VisualStudio.Copilot.DocumentContextProvider¦Member¤file©CanReduceéRequestIdÙ$7bb4b94c-1be0-4840-80b8-aad1069c024d©ReferenceÀ¦Traits¯ProviderMoniker¤NameÙ9Microsoft.VisualStudio.Copilot.CSharpProjectTraitProvider§Version£0.3£Key¯LanguageVersion¥Value®ValueContainerÙMicrosoft.VisualStudio.Copilot.LanguageVersionTrait, Microsoft.VisualStudio.Copilot, Version=17.13.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aÓ ¨Language¢C#§Version£7.3¯CopilotTypeName¯LanguageVersion¨TypeName¤Name¯LanguageVersion§IsArray¯ProviderMoniker¤NameÙ9Microsoft.VisualStudio.Copilot.CSharpProjectTraitProvider§Version£0.3£Key¶CSharpTargetFrameworks¥Value®ValueContainerÙ£Microsoft.VisualStudio.Copilot.CSharpTargetFrameworkTrait, Microsoft.VisualStudio.Copilot.Core, Version=17.13.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aÓ 6°TargetFrameworks¶'.NET Framework 4.6.1'ªIsDocumentïCopilotTypeName¶CSharpTargetFrameworks¨TypeName¤Name¶CSharpTargetFrameworks§IsArray«IsEphemeral§Content
¢IdÄYX)F@ 3¹§-½ªVisibility«Annotations§ContentÙJè¿ç¨æ¹å¨æ²¡æå®æå
³éæ¡æçæ
åµä¸å
³éäº WebSocket è¿æ¥¨Mentions¨Metadata¦IntentÀ¨GuidanceÀ¥ModelÀ²DirectedResponders©FunctionsCorrelationIdÙ$7bb4b94c-1be0-4840-80b8-aad1069c024d©MessageIdÙ$2d95f5de-302d-4c08-b96a-e7d1d136fd0a§Context§Content¨Metadata©SessionIdÙ$4b7eb4c4-7c03-4aee-9f74-1e5c93b3be46¢IdÙ4Microsoft.VisualStudio.Conversations.Chat.HelpWindow¦Author¤Name®GitHub Copilot¤Icon¤GuidÙ$4515b9bd-70a1-45fa-9545-d4536417c596¢Id§Service¤NameÙ7Microsoft.VisualStudio.Copilot.CopilotChatAgentProvider§Version£0.3¦Status©FollowUps
|