This commit is contained in:
PastSaid
2024-03-04 16:50:20 +08:00
parent f3eae0a034
commit 5e2781182d
133 changed files with 20406 additions and 501 deletions

View File

@@ -1,4 +1,6 @@
using ExtensionMethods;
using Kingdee.BOS;
using Kingdee.BOS.Core.Report;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using SAL_OUTSTOCK.Utils;
@@ -9,6 +11,12 @@ using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using K3CExttensionMethods;
using System.Linq.Expressions;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Util;
using Newtonsoft.Json.Linq;
using HandleUtils;
namespace UnitTestProject1
{
@@ -19,7 +27,7 @@ namespace UnitTestProject1
{
public TestEntity(int _id, string _name)
{
id = _id;
id = _id;
name = _name;
}
public int id;
@@ -29,29 +37,43 @@ namespace UnitTestProject1
[TestMethod]
public void TestMethod2()
{
var list = new List<TestEntity>();
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(1,"ttetett"));
list.Add(new TestEntity(2,"ttetett"));
list.Add(new TestEntity(2,"ttetett"));
list.Add(new TestEntity(2,"ttetett"));
list.Add(new TestEntity(2,"ttetett"));
list.Add(new TestEntity(2,"ttetett"));
list.Add(new TestEntity(2,"ttetett"));
list.Add(new TestEntity(2,"ttetett"));
var ttt = list.GroupBy(x => x.id);
var json = "{\"a\":\"0\"}";
var jToken = JsonConvert.DeserializeObject<JToken>(json);
var count = ttt.Count();
var a = jToken["a"].ToString();
string formattedValue2 = $"CD{DateTime.Now.ToString("yyMMddHHmmss")}";
int i = 0;
string itemNo = $"CD{DateTime.Now:yyMMddHHmmss}" + i++.ToString("D2");
string yearAbbreviation = DateTime.Now.Year.ToString().Substring(2, 2); // 获取年份的缩写比如2023年的缩写为23
string formattedValue = $"CD{yearAbbreviation}{DateTime.Now.ToString("MMddHHmmss")}";
//var list = new List<TestEntity>();
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(1, "ttetett"));
//list.Add(new TestEntity(2, "ttetett"));
//list.Add(new TestEntity(2, "ttetett"));
//list.Add(new TestEntity(2, "ttetett"));
//list.Add(new TestEntity(2, "ttetett"));
//list.Add(new TestEntity(2, "ttetett"));
//list.Add(new TestEntity(2, "ttetett"));
//list.Add(new TestEntity(2, "ttetett"));
//var ttt = list.GroupBy(x => x.id);
//var count = ttt.Count();
var tt = " ";
var b = formattedValue2.Equals(formattedValue);
//var i = tt.ToDecimal();
return;
}
@@ -184,6 +206,112 @@ namespace UnitTestProject1
}
return sign.ToString();
}
[TestMethod]
public void TestMethod3()
{
ReportHeader header = new ReportHeader();
var _colIndex = 0;
var h1 = header.AddChild("PRODUCTTYPE", new LocaleValue("生产类型"), _colIndex++);
// Add the following directive to the file:
// using System.Linq.Expressions;
// Creating a parameter for the expression tree.
ParameterExpression param = Expression.Parameter(typeof(int));
// Creating an expression for the method call and specifying its parameter.
MethodCallExpression methodCall = Expression.Call(
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(int) }),
param
);
// The following statement first creates an expression tree,
// then compiles it, and then runs it.
Expression.Lambda<Action<int>>(
methodCall,
new ParameterExpression[] { param }
).Compile()(10);
// This code example produces the following output:
//
// 10
//创建表达式参数(指定参数或变量的类型)
var param2 = Expression.Parameter(typeof(ListHeader));
//构建表达式体(类型包含指定的属性)
var body = Expression.Property(param2, "Mergeable = true");
//根据参数和表达式体构造一个Lambda表达式
var fieldExp = Expression.Lambda<Action<ListHeader>>(Expression.Convert(body, typeof(object)), param2);
h1.SetHeader(fieldExp.Compile());
return;
}
private void TTTT()
{
var list = new List<DecimalControlField>
{
new DecimalControlField("FUnitNeedQty", "LOWEST6"),
new DecimalControlField("FQTY", "LOWEST6"),
new DecimalControlField("FUnitNeedQty", "LOWEST6"),
new DecimalControlField("FBASEQTY", "LOWEST6"),
new DecimalControlField("FNEEDQTY", "LOWEST6"),
new DecimalControlField("FBASEWIPQTY", "LOWEST6"),
new DecimalControlField("FBASELACKQTY", "LOWEST6"),
new DecimalControlField("FBASEONORDERQTY", "LOWEST6"),
new DecimalControlField("FPICKEDQTY", "LOWEST6"),
new DecimalControlField("FNOPICKEDQTY", "LOWEST6"),
new DecimalControlField("FSTDQTY", "LOWEST6"),
new DecimalControlField("FMUSTQTY", "LOWEST6"),
new DecimalControlField("FLossQty", "LOWEST6"),
new DecimalControlField("FSCRAPQTY", "LOWEST6"),
new DecimalControlField("FREPICKEDQTY", "LOWEST6"),
};
}
[TestMethod]
public void TestMeThod4()
{
var appId = "271430_Rf9BQYjJ2NgUWV8JWZxLz+8t2rWa0KOK";
var dbId = "654e408a013340";
var userName = "demo";
var secret = "0ef6a61fa3d349029f8a433609bf824c";
var timeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
var signedData = SHA1Util.GetSignature(new string[] { dbId, userName, appId, secret, timeStamp });
var json2 = @"{""dbid"":""654e408a013340"",""username"":""demo"",""appid"":""271430_Rf9BQYjJ2NgUWV8JWZxLz+8t2rWa0KOK"",""signeddata"":""{0}"",""timestamp"":""1709285538"",""lcid"":""2052"",""origintype"":""SimPas"",""entryrole"":"""",""formid"":"""",""formtype"":"""",""pkid"":"""",""otherargs"":""|{'permitcount':'0'}"",""openmode"":null,""loginthen"":""""}";
var json = $@"{{""dbid"":""{dbId}"",""username"":""{userName}"",""appid"":""{appId}"",""signeddata"":""{signedData}"",""timestamp"":""{timeStamp}"",""lcid"":""2052"",""origintype"":""SimPas"",""entryrole"": """",""formid"":""PUR_PurchaseOrder"",""formtype"":"""",""pkid"":""100001"",""otherargs"":""|{{'permitcount':'0'}}"",""openmode"":null,""loginthen"":""""}}";
var jToken = JsonConvert.DeserializeObject<JToken>(json);
//json = string.Format(json2, signedData);
var base64Str = Base64Helper.Base64Encode(json);
var url = "http://localhost/K3Cloud/html5/index.aspx?ud=";
url = url + base64Str;
return;
}
//public string GetSignature(string[] arr)
//{
// //1. 将数组进行排序
// //2. 将数组拼接成一个字符串进行sha1加密
// arr = arr.OrderBy(z => z).ToArray();
// var arrString = string.Join("", arr);
// var sha1 = SHA1.Create();
// var sha1Arr = sha1.ComputeHash(Encoding.UTF8.GetBytes(arrString));
// StringBuilder enText = new StringBuilder();
// foreach (var b in sha1Arr)
// {
// enText.AppendFormat("{0:x2}", b);
// }
// return enText.ToString();
//}
}

View File

@@ -39,6 +39,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kingdee.BOS">
<HintPath>..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.BOS.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.Core">
<HintPath>..\..\..\..\..\Program Files (x86)\Kingdee\K3Cloud\WebSite\bin\Kingdee.BOS.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
@@ -69,6 +75,14 @@
<Project>{50532462-8f7f-455c-b4b3-732ed764e2fa}</Project>
<Name>ExtensionMethods</Name>
</ProjectReference>
<ProjectReference Include="..\HandleUtils\HandleUtils.csproj">
<Project>{A386E924-0477-49BF-A3DD-82390EDF75C7}</Project>
<Name>HandleUtils</Name>
</ProjectReference>
<ProjectReference Include="..\K3CExttensionMethods\K3CExttensionMethods.csproj">
<Project>{825dd90b-2a8d-4884-9940-6da56ef6623f}</Project>
<Name>K3CExttensionMethods</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />