初始化
This commit is contained in:
26
ConsoleApp1/App.config
Normal file
26
ConsoleApp1/App.config
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.7.9.0" newVersion="6.7.9.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.serviceModel>
|
||||
<bindings />
|
||||
<client />
|
||||
</system.serviceModel>
|
||||
</configuration>
|
||||
103
ConsoleApp1/ConsoleApp1.csproj
Normal file
103
ConsoleApp1/ConsoleApp1.csproj
Normal file
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{CEEE2228-3250-4886-AECF-AB66211C41E6}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>ConsoleApp1</RootNamespace>
|
||||
<AssemblyName>ConsoleApp1</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" />
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath>..\RestSharp\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Messaging" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.8.0.4\lib\net462\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BLWWS_BLL\BLWWS_BLL.csproj">
|
||||
<Project>{CF2AB5DE-C3AF-4388-B6C4-EFA14BAF3316}</Project>
|
||||
<Name>BLWWS_BLL</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
441
ConsoleApp1/Program.cs
Normal file
441
ConsoleApp1/Program.cs
Normal file
@@ -0,0 +1,441 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Messaging;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using BLWWS_BLL;
|
||||
using ConsoleApp1;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
|
||||
public class portinfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string LodgerNmae { get; set; }
|
||||
/// <summary>
|
||||
/// 身份证
|
||||
/// </summary>
|
||||
public string IDNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 性别 0女 1男
|
||||
/// </summary>
|
||||
public Nullable<int> Sex { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public Nullable<System.DateTime> CheckInDate { get; set; }
|
||||
/// <summary>
|
||||
/// 消息来源
|
||||
/// </summary>
|
||||
public int Sourcedian { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
public string picture { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片时间
|
||||
/// </summary>
|
||||
public Nullable<System.DateTime> pictureDate { get; set; }
|
||||
/// <summary>
|
||||
/// 酒店code
|
||||
/// </summary>
|
||||
public string HotelCode { get; set; }
|
||||
/// <summary>
|
||||
/// 房间号
|
||||
/// </summary>
|
||||
public string roomid { get; set; }
|
||||
/// <summary>
|
||||
/// 电话号码
|
||||
/// </summary>
|
||||
public string phonenumber { get; set; }
|
||||
/// <summary>
|
||||
/// 开房时间
|
||||
/// </summary>
|
||||
public DateTime CheckTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 退房时间
|
||||
/// </summary>
|
||||
public DateTime checkOutTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 密钥
|
||||
/// </summary>
|
||||
public string key { get; set; }
|
||||
public int pmsinfoid { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class XMSData
|
||||
{
|
||||
public string hotelid { get; set; }
|
||||
/// <summary>
|
||||
/// 订单账号(酒店唯一)
|
||||
/// </summary>
|
||||
public string accnt { get; set; }
|
||||
|
||||
public string groupid { get; set; }
|
||||
public string name { get; set; }
|
||||
public Dictionary<string, string> original { get; set; }
|
||||
public extrasData extras { get; set; }
|
||||
}
|
||||
public class originalData
|
||||
{
|
||||
//public string name { get; set; }
|
||||
//public string mobile { get; set; }
|
||||
//public string roomno { get; set; }
|
||||
//public string type { get; set; }
|
||||
//public string rtc { get; set; }
|
||||
//public string rmnum { get; set; }
|
||||
//public string sta { get; set; }
|
||||
}
|
||||
// "arr":"1750586400000",
|
||||
// "rtc":"CPC",
|
||||
// "sta":"R",
|
||||
// "rmnum":"1",
|
||||
// "roomno":"",
|
||||
// "mobile":"1212345678",
|
||||
// "name":"李二",
|
||||
// "type":"CPC",
|
||||
// "dep":"1750651200000"
|
||||
public class extrasData
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string mobile { get; set; }
|
||||
/// <summary>
|
||||
/// 房间号
|
||||
/// </summary>
|
||||
public string roomno { get; set; }
|
||||
public string type { get; set; }
|
||||
public string rtc { get; set; }
|
||||
public string rmnum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单状态
|
||||
///Q:问询
|
||||
///X:取消预订
|
||||
///N:noshow
|
||||
///R:预订
|
||||
///I:在住
|
||||
///O:本日结账
|
||||
///S:挂账退房
|
||||
///D:昨日结账
|
||||
///H:历史订单
|
||||
/// </summary>
|
||||
public string sta { get; set; }
|
||||
public string arr { get; set; }
|
||||
public string dep { get; set; }
|
||||
}
|
||||
internal class Program
|
||||
{
|
||||
public static long GetCurrentTimeStamp(DateTime dt)
|
||||
{
|
||||
TimeSpan ts = dt - new DateTime(1970, 1, 1, 8, 0, 0, DateTimeKind.Local);
|
||||
long current_timestamp = Convert.ToInt64(ts.TotalSeconds);
|
||||
return current_timestamp;
|
||||
}
|
||||
public class PMSDataBase
|
||||
{
|
||||
public string hotel_code { get; set; } = "";
|
||||
public string time { get; set; } = "";
|
||||
public string sign { get; set; } = "";
|
||||
public string hotel_id { get; set; } = "";
|
||||
public string order_no { get; set; } = "";
|
||||
public string room_no { get; set; } = "";
|
||||
public string check_out_original { get; set; }
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
var DQQQ = File.ReadAllText("1.txt");
|
||||
|
||||
|
||||
|
||||
//<items><item customer="安赞同" idcard="2110**********222X" sex="女" country="0" checkindate="2025-06-19 16:26:14" checkoutdate="2025-06-20 12:00:00"/></items>
|
||||
|
||||
XDocument doc32 = XDocument.Parse(DQQQ);
|
||||
XElement Root1 = doc32.Root;
|
||||
string orderno = Root1.Attribute("orderno")?.Value;
|
||||
string cost = Root1.Attribute("cost")?.Value;
|
||||
|
||||
//是否有早餐
|
||||
string breakfast = Root1.Attribute("breakfast")?.Value;
|
||||
//押金
|
||||
string deposit = Root1.Attribute("deposit")?.Value;
|
||||
|
||||
var LESuuu = Root1.Elements("item");
|
||||
|
||||
|
||||
|
||||
|
||||
var NNNjkl = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, object>>>(DQQQ);
|
||||
PMSDataBase data = new PMSDataBase()
|
||||
{
|
||||
hotel_code = "2079",
|
||||
time = "1751426235",
|
||||
sign = "a68b2596ce7c1ca970e82a00626c16e3",
|
||||
hotel_id = "1101",
|
||||
order_no = "",
|
||||
room_no = "1102",
|
||||
check_out_original = ""
|
||||
};
|
||||
|
||||
string BaseURL = "https://f.blv-oa.com:8099/rcu_pms_api/v1";
|
||||
var client123 = new RestClient(BaseURL);
|
||||
var request123 = new RestRequest("/order/checkOut", Method.POST);
|
||||
request123.AddJsonBody(data);
|
||||
var Response = client123.Execute(request123).Content;
|
||||
string content12345 = Response;
|
||||
|
||||
|
||||
long lllhhh = GetCurrentTimeStamp(DateTime.Now);
|
||||
decimal DDD = Convert.ToDecimal(32432423.34343);
|
||||
decimal lll = DDD / 1024;
|
||||
decimal a = Math.Round(lll, 2);
|
||||
Console.WriteLine("aaaaaaaaaaaa");
|
||||
|
||||
string content = "";
|
||||
|
||||
|
||||
string PPP = File.ReadAllText("3.txt");
|
||||
byte[] photo = Tools.HEXString2ByteArray(PPP);
|
||||
|
||||
//分辨率 判断
|
||||
using (var ms = new MemoryStream(photo))
|
||||
{
|
||||
ms.Write(photo, 0, photo.Length);
|
||||
using (System.Drawing.Image image = System.Drawing.Image.FromStream(ms, false, false)) // 不加载图像数据
|
||||
{
|
||||
bool bf = image.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
Console.WriteLine(image.Height);
|
||||
Console.WriteLine(image.Width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
string sss111 = File.ReadAllText("3.txt");
|
||||
var OOO = JsonConvert.DeserializeObject<XMSData>(sss111);
|
||||
string Url111 = "http://pms.boonlive-rcu.com:8989";
|
||||
var client1 = new RestClient(Url111);
|
||||
//var request1 = new RestRequest("api/XMSOrderPush?xrsecret=Ip202rSR132zJGKH", Method.POST);
|
||||
var request1 = new RestRequest("api/XMSOrderPush", Method.POST);
|
||||
request1.AddQueryParameter("xrsecret", "Ip202rSR132zJGKH");
|
||||
request1.AddJsonBody(OOO);
|
||||
var response = client1.Execute(request1);
|
||||
var content111 = response.Content;
|
||||
|
||||
|
||||
|
||||
////string url = "http://face.blv-oa.com/Interface/checkinInterface?key=abc&data={"LodgerNmae":"王悦","IDNumber":"1133397752487743488","Sex":0,"picture":"http://pms.boonlive-rcu.com:89/pic/1133397752487743488_1384391.jpg","HotelCode":"2079","roomid":"1906","phonenumber":"19847388255","CheckTime":"2025-06-20 11:19:04","pmsinfoid":1905524}";
|
||||
//string url = File.ReadAllText("2.txt");
|
||||
//var NNN1= JsonConvert.DeserializeObject<portinfo>(url);
|
||||
|
||||
//return;
|
||||
//var client1 = new RestClient(url);
|
||||
//var request1 = new RestRequest(Method.POST);
|
||||
//request1.AddJsonBody(null);
|
||||
//var Response = client1.Execute(request1).Content;
|
||||
//content = Response;
|
||||
|
||||
//string result = string.Empty;
|
||||
//HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
||||
//req.ContentType = "application/json";
|
||||
//req.Method = "POST";
|
||||
////req.Timeout = 10000;//设置请求超时时间,单位为毫秒
|
||||
//byte[] data = Encoding.UTF8.GetBytes("");
|
||||
//req.ContentLength = data.Length;
|
||||
//using (Stream reqStream = req.GetRequestStream())
|
||||
//{
|
||||
// reqStream.Write(data, 0, data.Length);
|
||||
//}
|
||||
//HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
||||
//using (Stream stream = resp.GetResponseStream())
|
||||
//{
|
||||
// using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
||||
// {
|
||||
// result = reader.ReadToEnd();//获取响应内容
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
Console.ReadKey();
|
||||
|
||||
|
||||
string xmlString = File.ReadAllText("1.txt");
|
||||
XDocument doc1 = XDocument.Parse(xmlString);
|
||||
XElement Root = doc1.Root;
|
||||
string NNN = Root.Attribute("orderno")?.Value;
|
||||
|
||||
var LES = Root.Elements("item");
|
||||
foreach (var item in LES)
|
||||
{
|
||||
string customer = item.Attribute("customer").Value;
|
||||
string sex = item.Attribute("sex").Value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//ServiceReference1.blwwsSoapClient c = new ServiceReference1.blwwsSoapClient();
|
||||
//c.Test();
|
||||
//string token = GetToken_G();
|
||||
//Console.WriteLine(token);
|
||||
//ConcurrentDictionary<string, string> GlobalData = new ConcurrentDictionary<string, string>();
|
||||
//GlobalData.AddOrUpdate("A", token, (k, v) => { return token; });
|
||||
//GlobalData.AddOrUpdate("A", token, (k, v) => { return token; });
|
||||
//GlobalData.AddOrUpdate("A", token, (k, v) => { return token; });
|
||||
//GlobalData.AddOrUpdate("A", token, (k, v) => { return token; });
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
static public string UserCode = "KKJK";
|
||||
static public string UserKey = "KKJK0428";
|
||||
static public string BaseUrl = "https://armitage-ipms.shijicloud.com";
|
||||
public static string GetToken_G()
|
||||
{
|
||||
Dictionary<string, string> Params = new Dictionary<string, string>();
|
||||
Params.Add("userCode", UserCode);
|
||||
Params.Add("key", UserKey);
|
||||
|
||||
var tokenstr = Send_Http_Request_Params("/iPMSAPI/iPMSApiService/api/applySecurityToken", Params);
|
||||
|
||||
Console.WriteLine(tokenstr);
|
||||
if (!string.IsNullOrEmpty(tokenstr))
|
||||
{
|
||||
var dic = JsonConvert.DeserializeObject<Dictionary<string, string>>(tokenstr);
|
||||
string token = dic["securityToken"];
|
||||
return token;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string Send_Http_Request_Params(string Url, Dictionary<string, string> Params)
|
||||
{
|
||||
var client1 = new RestClient(BaseUrl);
|
||||
var request1 = new RestRequest(Url, Method.POST);
|
||||
|
||||
foreach (KeyValuePair<string, string> item in Params)
|
||||
{
|
||||
request1.AddParameter(item.Key, item.Value);
|
||||
}
|
||||
|
||||
var response = client1.Execute(request1);
|
||||
var content = response.Content;
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
public static string queueName2 = @".\private$\faceServerToWeb";
|
||||
public static MessageQueue mq2 = null;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 从消息队列中读取命令,并执行
|
||||
/// </summary>
|
||||
public static void ReceiveCmdLoop()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
//判断队列是否存在
|
||||
if (MessageQueue.Exists(queueName2))
|
||||
{
|
||||
mq2 = new MessageQueue(queueName2);
|
||||
}
|
||||
else
|
||||
{
|
||||
//创建队列
|
||||
mq2 = MessageQueue.Create(queueName2);
|
||||
}
|
||||
//给管理员队列权力
|
||||
mq2.SetPermissions("Administrator", MessageQueueAccessRights.FullControl);
|
||||
//匿名登录
|
||||
mq2.SetPermissions("ANONYMOUS LOGON", MessageQueueAccessRights.FullControl);
|
||||
mq2.SetPermissions("Everyone", MessageQueueAccessRights.FullControl);
|
||||
|
||||
while (true)
|
||||
{
|
||||
Message msgRx = mq2.Receive();
|
||||
msgRx.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
|
||||
|
||||
string strRx = msgRx.Body.ToString();
|
||||
|
||||
|
||||
Thread.Sleep(1300); //阻塞当前线程1秒,让其他线程运行
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Thread.Sleep(5000); //阻塞当前线程5秒,再重新启动
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向消息队列中发送消息
|
||||
/// </summary>
|
||||
/// <param name="sendMsg">消息</param>
|
||||
/// <returns></returns>
|
||||
public static string QueueSend(string sendMsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (mq2 == null)
|
||||
{
|
||||
if (MessageQueue.Exists(queueName2))
|
||||
{
|
||||
mq2 = new MessageQueue(queueName2);
|
||||
}
|
||||
else
|
||||
{
|
||||
mq2 = MessageQueue.Create(queueName2);
|
||||
}
|
||||
mq2.SetPermissions("Administrator", MessageQueueAccessRights.FullControl);
|
||||
mq2.SetPermissions("ANONYMOUS LOGON", MessageQueueAccessRights.FullControl);
|
||||
mq2.SetPermissions("Everyone", MessageQueueAccessRights.FullControl);
|
||||
}
|
||||
|
||||
Message msgTx = new Message
|
||||
{
|
||||
Body = "",
|
||||
Formatter = new XmlMessageFormatter(new Type[] { typeof(string) })
|
||||
};
|
||||
mq2.Send(msgTx);
|
||||
return "Succeed push msg to MQ !";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mq2 = null;
|
||||
return ex.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
ConsoleApp1/Properties/AssemblyInfo.cs
Normal file
33
ConsoleApp1/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("ConsoleApp1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ConsoleApp1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("ceee2228-3250-4886-aecf-ab66211c41e6")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
12
ConsoleApp1/packages.config
Normal file
12
ConsoleApp1/packages.config
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
|
||||
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net48" />
|
||||
<package id="System.Text.Json" version="8.0.4" targetFramework="net48" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user