add about form

This commit is contained in:
Zhuangkh 2022-04-06 20:51:44 +08:00
parent 26dd451123
commit 9b2b336ce2
9 changed files with 1443 additions and 37 deletions

View File

@ -7,29 +7,14 @@ using System.Windows;
namespace TestDemo1
{
[Checker("AOP TestDemo")]
[Transaction(TransactionMode.Manual)]
public class TestCommand : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var a = new A();
a.B();
MessageBox.Show("Executed");
return Result.Succeeded;
}
}
}
namespace Autodesk.Revit.UI
{
[Checker("uBIM ReCAD")]
public class A
{
public void B()
{
MessageBox.Show("121");
}
}
}

View File

@ -3,14 +3,23 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<UserSecretsId>e809dde1-3dc4-4ca0-bcb9-65c8473f590e</UserSecretsId>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants)TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>$(DefineConstants)TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RevitSDK2019" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\uBIM.Checker.AOP\uBIM.Checker.AOP.csproj" />
<PackageReference Include="uBIM.Checker.AOP.Source" Version="0.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

138
src/uBIM.Checker.AOP/AboutForm.Designer.cs generated Normal file
View File

@ -0,0 +1,138 @@
using System;
using System.Windows.Forms;
namespace uBIM.Checker.AOP
{
partial class AboutForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.linkLabel_Version = new System.Windows.Forms.LinkLabel();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.label_Info = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// linkLabel_Version
//
this.linkLabel_Version.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.linkLabel_Version.Location = new System.Drawing.Point(106, 54);
this.linkLabel_Version.Name = "linkLabel_Version";
this.linkLabel_Version.Size = new System.Drawing.Size(123, 25);
this.linkLabel_Version.TabIndex = 0;
this.linkLabel_Version.TabStop = true;
this.linkLabel_Version.Text = "版本20xx";
this.linkLabel_Version.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.toolTip1.SetToolTip(this.linkLabel_Version, "点击检查版本更新");
this.linkLabel_Version.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel_Version_LinkClicked);
//
// label_Info
//
this.label_Info.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label_Info.AutoSize = true;
this.label_Info.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label_Info.Location = new System.Drawing.Point(9, 101);
this.label_Info.Name = "label_Info";
this.label_Info.Size = new System.Drawing.Size(152, 51);
this.label_Info.TabIndex = 2;
this.label_Info.Text = "内部版本1.0.0.0\r\n广州优比建筑咨询有限公司\r\nhttp://www.u-bim.com";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(103, 21);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(149, 28);
this.label2.TabIndex = 3;
this.label2.Text = "uBIM ReCAD";
//
// pictureBox1
//
//this.pictureBox1.Image = global::uBIM.ReCAD.App.Properties.Resources.uBIM;
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(77, 77);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 4;
this.pictureBox1.TabStop = false;
this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
//
// AboutForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(494, 161);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label_Info);
this.Controls.Add(this.linkLabel_Version);
this.linkLabel_ActivateState = new System.Windows.Forms.LinkLabel();
//
// linkLabel_ActivateState
//
this.linkLabel_ActivateState.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.linkLabel_ActivateState.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.linkLabel_ActivateState.Location = new System.Drawing.Point(332, 117);
this.linkLabel_ActivateState.Name = "linkLabel_ActivateState";
this.linkLabel_ActivateState.Size = new System.Drawing.Size(150, 35);
this.linkLabel_ActivateState.TabIndex = 1;
this.linkLabel_ActivateState.TabStop = true;
this.linkLabel_ActivateState.Text = "未激活";
this.linkLabel_ActivateState.TextAlign = System.Drawing.ContentAlignment.BottomRight;
this.linkLabel_ActivateState.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel_ActivateState_LinkClicked);
this.Controls.Add(this.linkLabel_ActivateState);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AboutForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "uBIM ReCAD - 关于";
this.Load += new System.EventHandler(this.HelpForm_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.LinkLabel linkLabel_ActivateState;
private System.Windows.Forms.LinkLabel linkLabel_Version;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.Label label_Info;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.PictureBox pictureBox1;
}
}

View File

@ -0,0 +1,146 @@
using System;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
namespace uBIM.Checker.AOP
{
internal partial class AboutForm : Form
{
private const string key_a = "<RSAKeyValue><Modulus>oNr4T8oRvbqOtswFcRI0jlhy15IUJ6Mi8bHWAyW/bVxPxj3Lga2ZhYgwqA01fLcNfO9tPq63Vfxksbw4p7V5+GzAsYhS1Hs6QGzilKiZB2jjjKSctWTZZCfcURVGsQLcKDz1JlMbT8/M8mNbgIzKI6UiXtxBiWFf8POLoOk5z1s=</Modulus><Exponent>AQAB</Exponent><P>2F+DlaY2KPUUoMwgyauR92ZnGEdrCL1+9YtEQLiQ5f/EkkosVy3rdCF+39b6uP5puzqvb7QftuWL0aTLBcEnoQ==</P><Q>vlCMj5gv+fDAOdOsz1Ma8JRe2R8TcSN22vx63tvrA5gvxgfFPzume/WJRADNtCzfklkGrOXmit80vfgxN0Glew==</Q><DP>w8+keFCj4OryURaKcZeoEDmHAQzYy18aP0JacSvWTZ7qmO0xNXAkDcOmWxHlcnci3kKcs71RmiYgI4g8BygnIQ==</DP><DQ>Doi+Q1UfDNp7A6+LugWhwA/EspYx+Oj5cb3ocE6hQxQDSf9b6/lVPJBC3GOnUgQ/SsDrxpaEJcToFT34HD0yMw==</DQ><InverseQ>MlY+l+X4Nu++oHi/UeSuNVKB3uKTCG3q2rq/fJa5HpOmrwrAblOT50HWb/4DOzp4t/2vKuq92yf4iLokVWMt0A==</InverseQ><D>ZMpwN0bNsQ25qQ7UBhK7PcpsQ2l0GZYeKkYdbKF1fmgOUJCd+Oa3QLWij1qffkMRP4yi7lj55fYdfkULVwLepm1hxE5aGf5c/36JO0QqmrUVppPaz7SR8EnmYwMKJD1tv/puzXfDA8+upFYiCfg+SF/+svxMUVw3mK21dhe27EE=</D></RSAKeyValue>";
private const string key_b = "<RSAKeyValue><Modulus>wK0zy1DkjYBpu9rzXzP9ScqWfxfAv5mOUtbf1Hom4BJREYBoXuRh3kqu8HQuT9nO2/o8nDi52vAJKHVZPZKrKNifYLOAHj4gWIO8qYrWrR9wAYTvhM/cLxXrs3/C3sflCny4A0QPnbkzpDJo/lGaybUpEDG2SNMBYVRO/TVQ5N0=</Modulus><Exponent>AQAB</Exponent><P>6RP6kmHLZARPM1r2VTnDb6z4AoWgqzrgMs5fVzYcqjo/50mXYgjgegf7EvhehCbOUTQwjB/EvS/s3xzgBCpE0w==</P><Q>06ARVWAid/k61Q7C7dBOW7Dz0SXXdql+OuxcwnVOo0lg1+R+m1zWTYDPB4DUqCr9foNHbMz095/zufWnAY3hjw==</Q><DP>o5l7ax4rtmNz+Dcj6sRl0tBVMOf809O6pM7Iix2XV0EVs9Gq6YwTjHRnnnQpW5clgEgiv2hZHvYxzJWnBCVrMw==</DP><DQ>WB89WInRkJfNsc6VySWGm5PR03OohxcJI0wtTCRA/KmflAbn2ZYM/vT2QK+a3fQY3seXxGyMTVjjyrnKM1F7bQ==</DQ><InverseQ>yqPGPSBXIG8FF3m0Rk4doXNcE1ljUeKSZCOo0iblfH4DYrBOIKg9+YQn9F5mA045IFZxMyXoSGZw0BLSEfA/pQ==</InverseQ><D>ruAE9HHVHsEANmpBHZV4PHNNKMkMPlpGnNU9jgHYKuM1BSeAky/BzBoIsWEhb4QGhg2W2Ut7FEVsanYnqwTlprdmXi4VzqAjazjvS/o+sHQbfejIFKIJHC6rUsAsZLkclPZcqyjJqDyLjyrOj5ilqRuIgFp6RhVnZKmL9NC6V5k=</D></RSAKeyValue>";
private string _title;
public AboutForm(string title)
{
InitializeComponent();
_title = title;
string[] temp = Common.AssemblyFileVersion().Split('.');
linkLabel_Version.Text = $"版本20{temp[1]}";
this.Text = $"{_title} - 关于";
this.label2.Text = $"{_title}";
}
private void HelpForm_Load(object sender, EventArgs e)
{
this.label_Info.Text = string.Format("内部版本:{0}\r\n广州优比建筑咨询有限公司\r\nhttp://www.u-bim.com", Common.AssemblyFileVersion());
RefreshActivateState();
}
private void linkLabel_ActivateState_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
LicenseChecker.Instance.Checker.Activate($"{_title}"
, Common.GetDeviceCode()
, string.Format("={0}=", Common.GetMd5Hash("|><=><|"))
, key_a
, key_b);
RefreshActivateState();
Task.Run(() =>
{
Task.Delay(5000).Wait();
//激活成功
if (!LicenseChecker.Instance.Checker.OutLimit && LicenseChecker.Instance.Checker.LimitDate != DateTime.MinValue)
{
DateTime nowTime = uBIM.Utils.General.GetNetTime();
if (nowTime == DateTime.MinValue)
{
nowTime = DateTime.Now;
}
string strEncrypt;
//根据有效期天数是否是试用激活
if (LicenseChecker.Instance.Checker.LimitDate <= nowTime.Date.AddDays(5))
{
//试用
strEncrypt = uBIM.Utils.DESHelper.EncryptDES($"{_title}*{Common.GetDeviceCode()}*0");
}
else
{
//非试用
strEncrypt = uBIM.Utils.DESHelper.EncryptDES($"{_title}*{Common.GetDeviceCode()}*1");
}
//往磁盘写入是否试用标识信息
Common.WirteStringData(strEncrypt, Common.TRY_INFO_FILE_PATH);
}
if (!IsClosed())
{
this.BeginInvoke((Action)RefreshActivateState);
}
});
}
private bool IsClosed()
{
bool result = true;
foreach (Form form in Application.OpenForms)
{
if (form.Name == this.Name)
{
result = false;
break;
}
}
return result;
}
private void RefreshActivateState()
{
if (LicenseChecker.Instance.Checker.OutLimit || LicenseChecker.Instance.Checker.LimitDate == DateTime.MinValue)
{
this.linkLabel_ActivateState.Enabled = true;
if (LicenseChecker.Instance.Checker.LimitDate == DateTime.MinValue)
{
this.linkLabel_ActivateState.Text = "未激活";
}
else
{
if (LicenseChecker.Instance.Checker.OutLimit || DateTime.Now.Date > LicenseChecker.Instance.Checker.LimitDate)
{
this.linkLabel_ActivateState.Text = string.Format("{0}\r\n有效期至{1}", "已过期", LicenseChecker.Instance.Checker.LimitDate.ToString("yyyy-MM-dd"));
}
}
}
else
{
this.linkLabel_ActivateState.Text = string.Format("{0}\r\n有效期至{1}", "已激活", LicenseChecker.Instance.Checker.LimitDate.ToString("yyyy-MM-dd"));
this.linkLabel_ActivateState.Enabled = false;
}
}
private void linkLabel_Version_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
}
private int sumMouseDown;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if ((ModifierKeys & Keys.Control) == Keys.Control)
{
if (!LicenseChecker.Instance.CheckLicenseState(_title, false))
{
return;
}
sumMouseDown++;
if (sumMouseDown == 3)
{
if (DialogResult.Yes == MessageBox.Show("确定需要注销激活吗?", $"{_title} - 注销", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
if (LicenseChecker.Instance.Checker.UnActivate($"{_title}"))
{
this.Close();
}
}
sumMouseDown = 0;
}
}
else
{
sumMouseDown = 0;
}
}
}
}

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="PRIVATE_KEY_A" xml:space="preserve">
<value>&lt;RSAKeyValue&gt;&lt;Modulus&gt;oNr4T8oRvbqOtswFcRI0jlhy15IUJ6Mi8bHWAyW/bVxPxj3Lga2ZhYgwqA01fLcNfO9tPq63Vfxksbw4p7V5+GzAsYhS1Hs6QGzilKiZB2jjjKSctWTZZCfcURVGsQLcKDz1JlMbT8/M8mNbgIzKI6UiXtxBiWFf8POLoOk5z1s=&lt;/Modulus&gt;&lt;Exponent&gt;AQAB&lt;/Exponent&gt;&lt;P&gt;2F+DlaY2KPUUoMwgyauR92ZnGEdrCL1+9YtEQLiQ5f/EkkosVy3rdCF+39b6uP5puzqvb7QftuWL0aTLBcEnoQ==&lt;/P&gt;&lt;Q&gt;vlCMj5gv+fDAOdOsz1Ma8JRe2R8TcSN22vx63tvrA5gvxgfFPzume/WJRADNtCzfklkGrOXmit80vfgxN0Glew==&lt;/Q&gt;&lt;DP&gt;w8+keFCj4OryURaKcZeoEDmHAQzYy18aP0JacSvWTZ7qmO0xNXAkDcOmWxHlcnci3kKcs71RmiYgI4g8BygnIQ==&lt;/DP&gt;&lt;DQ&gt;Doi+Q1UfDNp7A6+LugWhwA/EspYx+Oj5cb3ocE6hQxQDSf9b6/lVPJBC3GOnUgQ/SsDrxpaEJcToFT34HD0yMw==&lt;/DQ&gt;&lt;InverseQ&gt;MlY+l+X4Nu++oHi/UeSuNVKB3uKTCG3q2rq/fJa5HpOmrwrAblOT50HWb/4DOzp4t/2vKuq92yf4iLokVWMt0A==&lt;/InverseQ&gt;&lt;D&gt;ZMpwN0bNsQ25qQ7UBhK7PcpsQ2l0GZYeKkYdbKF1fmgOUJCd+Oa3QLWij1qffkMRP4yi7lj55fYdfkULVwLepm1hxE5aGf5c/36JO0QqmrUVppPaz7SR8EnmYwMKJD1tv/puzXfDA8+upFYiCfg+SF/+svxMUVw3mK21dhe27EE=&lt;/D&gt;&lt;/RSAKeyValue&gt;</value>
</data>
<data name="PRIVATE_KEY_B" xml:space="preserve">
<value>&lt;RSAKeyValue&gt;&lt;Modulus&gt;wK0zy1DkjYBpu9rzXzP9ScqWfxfAv5mOUtbf1Hom4BJREYBoXuRh3kqu8HQuT9nO2/o8nDi52vAJKHVZPZKrKNifYLOAHj4gWIO8qYrWrR9wAYTvhM/cLxXrs3/C3sflCny4A0QPnbkzpDJo/lGaybUpEDG2SNMBYVRO/TVQ5N0=&lt;/Modulus&gt;&lt;Exponent&gt;AQAB&lt;/Exponent&gt;&lt;P&gt;6RP6kmHLZARPM1r2VTnDb6z4AoWgqzrgMs5fVzYcqjo/50mXYgjgegf7EvhehCbOUTQwjB/EvS/s3xzgBCpE0w==&lt;/P&gt;&lt;Q&gt;06ARVWAid/k61Q7C7dBOW7Dz0SXXdql+OuxcwnVOo0lg1+R+m1zWTYDPB4DUqCr9foNHbMz095/zufWnAY3hjw==&lt;/Q&gt;&lt;DP&gt;o5l7ax4rtmNz+Dcj6sRl0tBVMOf809O6pM7Iix2XV0EVs9Gq6YwTjHRnnnQpW5clgEgiv2hZHvYxzJWnBCVrMw==&lt;/DP&gt;&lt;DQ&gt;WB89WInRkJfNsc6VySWGm5PR03OohxcJI0wtTCRA/KmflAbn2ZYM/vT2QK+a3fQY3seXxGyMTVjjyrnKM1F7bQ==&lt;/DQ&gt;&lt;InverseQ&gt;yqPGPSBXIG8FF3m0Rk4doXNcE1ljUeKSZCOo0iblfH4DYrBOIKg9+YQn9F5mA045IFZxMyXoSGZw0BLSEfA/pQ==&lt;/InverseQ&gt;&lt;D&gt;ruAE9HHVHsEANmpBHZV4PHNNKMkMPlpGnNU9jgHYKuM1BSeAky/BzBoIsWEhb4QGhg2W2Ut7FEVsanYnqwTlprdmXi4VzqAjazjvS/o+sHQbfejIFKIJHC6rUsAsZLkclPZcqyjJqDyLjyrOj5ilqRuIgFp6RhVnZKmL9NC6V5k=&lt;/D&gt;&lt;/RSAKeyValue&gt;</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>17, 17</value>
</data>
</root>

View File

@ -5,7 +5,9 @@ using System.Linq;
namespace uBIM.Checker.AOP
{
[Injection(typeof(CkeckerAspect))]
#if !DEBUG
[Injection(typeof(CheckerAspect))]
#endif
public class CheckerAttribute : Attribute
{
public string Title { get; }
@ -17,7 +19,7 @@ namespace uBIM.Checker.AOP
}
[Aspect(Scope.PerInstance)]
public class CkeckerAspect
public class CheckerAspect
{
[Advice(Kind.Around, Targets = Target.Method)]
public object DoCheck([Argument(Source.Instance)] object obj, [Argument(Source.Triggers)] Attribute[] triggers, [Argument(Source.Target)] Func<object[], object> target, [Argument(Source.Arguments)] object[] args)
@ -30,10 +32,18 @@ namespace uBIM.Checker.AOP
{
return target(args);
}
AboutForm aboutForm = new AboutForm(checker.Title);
aboutForm.ShowDialog();
return Result.Cancelled;
}
else
{
if (LicenseChecker.Instance.CheckLicenseState(checker.Title, false))
{
return target(args);
}
AboutForm aboutForm = new AboutForm(checker.Title);
aboutForm.ShowDialog();
if (LicenseChecker.Instance.CheckLicenseState(checker.Title, false))
{
return target(args);

View File

@ -0,0 +1,978 @@
using Microsoft.Win32;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Management;
using System.Net;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security;
using System.Security.AccessControl;
using System.Security.Cryptography;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Xml;
using MessageBox = System.Windows.MessageBox;
namespace uBIM.Checker.AOP
{
public class Common
{
/// <summary>
/// 强制窗口在前
/// </summary>
/// <param name="hWnd"></param>
/// <returns></returns>
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
/// <summary>
/// 激活窗口
/// </summary>
/// <param name="hWnd"></param>
/// <returns></returns>
[DllImport("user32.dll")]
public static extern bool SetActiveWindow(IntPtr hWnd);
#region
public static readonly string TRY_INFO_FILE_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + AssemblyFileProductName() + "\\try_info.dat";
#endregion
#region
/// <summary>
/// 有效期的文件路径
/// </summary>
public static readonly string LIMIT_DATE_FILE_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + AssemblyFileProductName() + "\\aga_limit.dat";
#endregion
#region
/// <summary>
/// 记录日期的文件路径
/// </summary>
public static readonly string RECORD_DATE_FILE_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + AssemblyFileProductName() + "\\aga_record.dat";
#endregion
#region
/// <summary>
/// 获取当前程序版本号
/// </summary>
/// <returns>版本号</returns>
public static string AssemblyFileVersion()
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
if (attributes.Length == 0)
{
return string.Empty;
}
else
{
return ((AssemblyFileVersionAttribute)attributes[0]).Version;
}
}
#endregion
#region
/// <summary>
/// 获取程序集产品名称
/// </summary>
/// <returns>产品名称</returns>
public static string AssemblyFileProductName()
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
if (attributes.Length == 0)
{
return string.Empty;
}
else
{
return ((AssemblyProductAttribute)attributes[0]).Product;
}
}
#endregion
#region
/// <summary>
/// 获取设备识别码
/// </summary>
/// <returns></returns>
public static string GetDeviceCode(bool includeAssemblyFileProductName = true)
{
string cpuId = GetCPUID();
string diskId = GetHardDiskID();
if (includeAssemblyFileProductName)
{
return GetMd5Hash(AssemblyFileProductName() + string.Format("[{0}{1}{0}]", cpuId, diskId)).ToUpper();
}
else
{
return GetMd5Hash(string.Format("[{0}{1}{0}]", cpuId, diskId)).ToUpper();
}
}
#endregion
#region CPU ID
/// <summary>
/// 获取CPU ID
/// </summary>
/// <returns></returns>
public static string GetCPUID()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT ProcessorId FROM Win32_Processor WHERE (ProcessorId IS NOT NULL)"); //SELECT * FROM Win32_Processor
string strCPUID = string.Empty;
ManagementObjectCollection managementObjectCollection = searcher.Get();
foreach (ManagementObject mo in managementObjectCollection)
{
strCPUID = (string)mo["ProcessorId"];
break;
}
return strCPUID;
}
#endregion
#region
/// <summary>
/// 获取第一块磁盘编号
/// </summary>
/// <returns></returns>
public static string GetHardDiskID()
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
string strHardDiskID = null;
foreach (ManagementObject mo in searcher.Get())
{
strHardDiskID = mo["SerialNumber"].ToString().Trim();
break;
}
return strHardDiskID;
}
catch
{
return string.Empty;
}
}
#endregion
#region MD5
/// <summary>
/// 取得输入字符串的MD5哈希值
/// </summary>
/// <param name="argInput">输入字符串</param>
/// <returns>MD5哈希值</returns>
public static string GetMd5Hash(string argInput)
{
// Create a new instance of the MD5CryptoServiceProvider object.
MD5 md5Hasher = MD5.Create();
// Convert the input string to a byte array and compute the hash.
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(argInput));
// Create a new Stringbuilder to collect the bytes
// and create a string.
StringBuilder sBuilder = new StringBuilder();
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
// Return the hexadecimal string.
return sBuilder.ToString();
}
/// <summary>
/// 验证MD5哈希值
/// </summary>
/// <param name="argInput">输入字符串</param>
/// <param name="argHash">哈希值</param>
/// <returns>相同返回TRUE,不同返回FALSE</returns>
public static bool VerifyMd5Hash(string argInput, string argHash)
{
// Hash the input.
string hashOfInput = GetMd5Hash(argInput);
// Create a StringComparer an comare the hashes.
StringComparer comparer = StringComparer.OrdinalIgnoreCase;
if (0 == comparer.Compare(hashOfInput, argHash))
{
return true;
}
else
{
return false;
}
}
#endregion
#region
/// <summary>
/// 写入字符串数据到文件
/// </summary>
/// <param name="strData">字符串</param>
/// <param name="strPath">文件</param>
public static bool WirteStringData(string strData, string strPath)
{
bool result = false;
try
{
string strLog = string.Empty;
string saveFolder = Path.GetDirectoryName(strPath);
if (!Directory.Exists(saveFolder))
{
Directory.CreateDirectory(saveFolder);
}
//DirectorySecurity secu = new DirectorySecurity(Path.GetDirectoryName(strPath), AccessControlSections.Access);
//FileSystemAccessRule fsar = new FileSystemAccessRule(Environment.UserName, FileSystemRights.FullControl, AccessControlType.Allow);
//secu.SetAccessRule(fsar);
//Directory.SetAccessControl(saveFolder, secu);
using (StreamWriter sw = new StreamWriter(strPath, false))
{
sw.WriteLine(strData);
}
result = true;
}
catch (Exception ex)
{
throw ex;
}
return result;
}
/// <summary>
/// 写入字符串数据到文件
/// </summary>
/// <param name="strData">字符串</param>
/// <param name="strPath">文件</param>
/// <param name="msg">异常消息</param>
/// <returns></returns>
public static bool WirteStringData(string strData, string strPath, ref string msg)
{
bool result = false;
try
{
WirteStringData(strData, strPath);
result = true;
}
catch (Exception ex)
{
msg = string.Format("{0}\r\n\r\n{1}", ex.uBIMMessage(), ex.uBIMMessage());
}
return result;
}
#endregion
#region
/// <summary>
/// 从文件读取字符串
/// </summary>
/// <param name="strPath">文件路径</param>
/// <returns></returns>
public static string ReadStringData(string strPath)
{
string result = string.Empty;
try
{
using (StreamReader sr = new StreamReader(strPath))
{
result = sr.ReadToEnd();
}
}
catch
{
throw;
}
return result;
}
#endregion
#region JSON
/// <summary>
/// 对象转JSON
/// </summary>
/// <typeparam name="T">类型约束</typeparam>
/// <param name="t">类型</param>
/// <returns>返回JSON字符串</returns>
public static string EntityToJsonString<T>(T t)
{
return JsonConvert.SerializeObject(t);
}
/// <summary>
/// 对象转JSON
/// </summary>
/// <typeparam name="T">类型约束</typeparam>
/// <param name="t">类型</param>
/// <param name="settings">JsonSerializerSettings</param>
/// <returns>返回JSON字符串</returns>
public static string EntityToJsonString<T>(T t, JsonSerializerSettings settings)
{
return JsonConvert.SerializeObject(t, settings);
}
#endregion
#region JSON转对象
/// <summary>
/// JSON转对象
/// </summary>
/// <typeparam name="T">类型约束</typeparam>
/// <param name="strJson">JSON字符串</param>
/// <param name="t">类型</param>
/// <returns>返回指定类型</returns>
public static T JsonStringToEntity<T>(string strJson)// where T : class
{
try
{
return JsonConvert.DeserializeObject<T>(strJson);
}
catch
{
throw;
}
}
/// <summary>
/// JSON转对象
/// </summary>
/// <typeparam name="T">类型约束</typeparam>
/// <param name="strJson">JSON字符串</param>
/// <param name="t">类型</param>
/// <param name="settings">JsonSerializerSettings</param>
/// <returns>返回指定类型</returns>
public static T JsonStringToEntity<T>(string strJson, JsonSerializerSettings settings)
{
try
{
return JsonConvert.DeserializeObject<T>(strJson, settings);
}
catch
{
throw;
}
}
public static dynamic JsonStringToEntity<T>(string strJson, ExpandoObjectConverter expConverter)
{
try
{
return JsonConvert.DeserializeObject<T>(strJson, expConverter);
}
catch
{
throw;
}
}
#endregion
#region
/// <summary>
/// 将对象序列化
/// </summary>
/// <param name="FilePath">文件(支持绝大多数数据类型)</param>
/// <param name="obj">要序列化的对象(如哈希表,数组等等)</param>
public static bool FileSerialize(string FilePath, object obj, ref string message)
{
bool result = false;
FileStream fs = null;
try
{
string saveFolder = Path.GetDirectoryName(FilePath);
if (!Directory.Exists(saveFolder))
{
Directory.CreateDirectory(saveFolder);
}
//DirectorySecurity secu = new DirectorySecurity(saveFolder, AccessControlSections.Access);
//FileSystemAccessRule fsar = new FileSystemAccessRule(Environment.UserName, FileSystemRights.FullControl, AccessControlType.Allow);
//secu.SetAccessRule(fsar);
//System.IO.Directory.SetAccessControl(saveFolder, secu);
fs = new FileStream(FilePath, FileMode.Create);
BinaryFormatter sl = new BinaryFormatter();
//sl.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
sl.Binder = new Binder();
sl.Serialize(fs, obj);
result = true;
}
catch (Exception ex)
{
message = string.Format("{0}\r\n\r\n{1}", ex.uBIMMessage(), ex.uBIMMessage());
}
finally
{
if (fs != null)
{
fs.Close();
fs.Dispose();
}
}
return result;
}
#endregion
#region
/// <summary>
/// 将文件反序列化
/// </summary>
/// <param name="FilePath">文件路径(必须是经过当前序列化后的文件)</param>
/// <returns>返回 null 表示序列反解失败或者目标文件不存在</returns>
public static object FileDeSerialize(string FilePath, ref string message)
{
object result = null;
if (File.Exists(FilePath))
{
FileStream fs = null;
try
{
string saveFolder = Path.GetDirectoryName(FilePath);
if (!Directory.Exists(saveFolder))
{
Directory.CreateDirectory(saveFolder);
}
//DirectorySecurity secu = new DirectorySecurity(saveFolder, AccessControlSections.Access);
//FileSystemAccessRule fsar = new FileSystemAccessRule(Environment.UserName, FileSystemRights.FullControl, AccessControlType.Allow);
//secu.SetAccessRule(fsar);
//System.IO.Directory.SetAccessControl(saveFolder, secu);
fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
BinaryFormatter sl = new BinaryFormatter();
//sl.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
sl.Binder = new Binder();
result = sl.Deserialize(fs);
}
catch (Exception ex)
{
result = null;
message = string.Format("{0}\r\n\r\n{1}", ex.uBIMMessage(), ex.uBIMMessage());
}
finally
{
if (fs != null)
{
fs.Close();
}
}
}
return result;
}
#endregion
#region Byte数组
/// <summary>
/// 反序列化Byte数组
/// </summary>
/// <param name="resource"></param>
/// <returns></returns>
public static object DeSerializeByByteArray(byte[] resource)
{
try
{
using (MemoryStream sm = new MemoryStream(resource))
{
BinaryFormatter sl = new BinaryFormatter();
object obg = sl.Deserialize(sm);
sm.Close();
return obg;
}
}
catch
{
return null;
}
}
#endregion
public class Binder : SerializationBinder
{
public override Type BindToType(string assemblyName, string typeName)
{
Assembly ass = Assembly.GetExecutingAssembly();
return ass.GetType(typeName);
}
}
#region CAD颜色集合
/// <summary>
/// CAD颜色集合
/// </summary>
public static Color[] CadColors =
{
Color.FromRgb(255,0,0),
Color.FromRgb(255,255,0),
Color.FromRgb(0,255,0),
Color.FromRgb(0,255,255),
Color.FromRgb(0,0,255),
Color.FromRgb(255,0,255),
Color.FromRgb(255,255,255),
Color.FromRgb(128,128,128),
Color.FromRgb(192,192,192),
Color.FromRgb(255,0,0),
Color.FromRgb(255,127,127),
Color.FromRgb(204,0,0),
Color.FromRgb(204,102,102),
Color.FromRgb(153,0,0),
Color.FromRgb(153,76,76),
Color.FromRgb(127,0,0),
Color.FromRgb(127,63,63),
Color.FromRgb(76,0,0),
Color.FromRgb(76,38,38),
Color.FromRgb(255,63,0),
Color.FromRgb(255,159,127),
Color.FromRgb(204,51,0),
Color.FromRgb(204,127,102),
Color.FromRgb(153,38,0),
Color.FromRgb(153,95,76),
Color.FromRgb(127,31,0),
Color.FromRgb(127,79,63),
Color.FromRgb(76,19,0),
Color.FromRgb(76,47,38),
Color.FromRgb(255,127,0),
Color.FromRgb(255,191,127),
Color.FromRgb(204,102,0),
Color.FromRgb(204,153,102),
Color.FromRgb(153,76,0),
Color.FromRgb(153,114,76),
Color.FromRgb(127,63,0),
Color.FromRgb(127,95,63),
Color.FromRgb(76,38,0),
Color.FromRgb(76,57,38),
Color.FromRgb(255,191,0),
Color.FromRgb(255,223,127),
Color.FromRgb(204,153,0),
Color.FromRgb(204,178,102),
Color.FromRgb(153,114,0),
Color.FromRgb(153,133,76),
Color.FromRgb(127,95,0),
Color.FromRgb(127,111,63),
Color.FromRgb(76,57,0),
Color.FromRgb(76,66,38),
Color.FromRgb(255,255,0),
Color.FromRgb(255,255,127),
Color.FromRgb(204,204,0),
Color.FromRgb(204,204,102),
Color.FromRgb(153,153,0),
Color.FromRgb(153,153,76),
Color.FromRgb(127,127,0),
Color.FromRgb(127,127,63),
Color.FromRgb(76,76,0),
Color.FromRgb(76,76,38),
Color.FromRgb(191,255,0),
Color.FromRgb(223,255,127),
Color.FromRgb(153,204,0),
Color.FromRgb(178,204,102),
Color.FromRgb(114,153,0),
Color.FromRgb(133,153,76),
Color.FromRgb(95,127,0),
Color.FromRgb(111,127,63),
Color.FromRgb(57,76,0),
Color.FromRgb(66,76,38),
Color.FromRgb(127,255,0),
Color.FromRgb(191,255,127),
Color.FromRgb(102,204,0),
Color.FromRgb(153,204,102),
Color.FromRgb(76,153,0),
Color.FromRgb(114,153,76),
Color.FromRgb(63,127,0),
Color.FromRgb(95,127,63),
Color.FromRgb(38,76,0),
Color.FromRgb(57,76,38),
Color.FromRgb(63,255,0),
Color.FromRgb(159,255,127),
Color.FromRgb(51,204,0),
Color.FromRgb(127,204,102),
Color.FromRgb(38,153,0),
Color.FromRgb(95,153,76),
Color.FromRgb(31,127,0),
Color.FromRgb(79,127,63),
Color.FromRgb(19,76,0),
Color.FromRgb(47,76,38),
Color.FromRgb(0,255,0),
Color.FromRgb(127,255,127),
Color.FromRgb(0,204,0),
Color.FromRgb(102,204,102),
Color.FromRgb(0,153,0),
Color.FromRgb(76,153,76),
Color.FromRgb(0,127,0),
Color.FromRgb(63,127,63),
Color.FromRgb(0,76,0),
Color.FromRgb(38,76,38),
Color.FromRgb(0,255,63),
Color.FromRgb(127,255,159),
Color.FromRgb(0,204,51),
Color.FromRgb(102,204,127),
Color.FromRgb(0,153,38),
Color.FromRgb(76,153,95),
Color.FromRgb(0,127,31),
Color.FromRgb(63,127,79),
Color.FromRgb(0,76,19),
Color.FromRgb(38,76,47),
Color.FromRgb(0,255,127),
Color.FromRgb(127,255,191),
Color.FromRgb(0,204,102),
Color.FromRgb(102,204,153),
Color.FromRgb(0,153,76),
Color.FromRgb(76,153,114),
Color.FromRgb(0,127,63),
Color.FromRgb(63,127,95),
Color.FromRgb(0,76,38),
Color.FromRgb(38,76,57),
Color.FromRgb(0,255,191),
Color.FromRgb(127,255,223),
Color.FromRgb(0,204,153),
Color.FromRgb(102,204,178),
Color.FromRgb(0,153,114),
Color.FromRgb(76,153,133),
Color.FromRgb(0,127,95),
Color.FromRgb(63,127,111),
Color.FromRgb(0,76,57),
Color.FromRgb(38,76,66),
Color.FromRgb(0,255,255),
Color.FromRgb(127,255,255),
Color.FromRgb(0,204,204),
Color.FromRgb(102,204,204),
Color.FromRgb(0,153,153),
Color.FromRgb(76,153,153),
Color.FromRgb(0,127,127),
Color.FromRgb(63,127,127),
Color.FromRgb(0,76,76),
Color.FromRgb(38,76,76),
Color.FromRgb(0,191,255),
Color.FromRgb(127,223,255),
Color.FromRgb(0,153,204),
Color.FromRgb(102,178,204),
Color.FromRgb(0,114,153),
Color.FromRgb(76,133,153),
Color.FromRgb(0,95,127),
Color.FromRgb(63,111,127),
Color.FromRgb(0,57,76),
Color.FromRgb(38,66,76),
Color.FromRgb(0,127,255),
Color.FromRgb(127,191,255),
Color.FromRgb(0,102,204),
Color.FromRgb(102,153,204),
Color.FromRgb(0,76,153),
Color.FromRgb(76,114,153),
Color.FromRgb(0,63,127),
Color.FromRgb(63,95,127),
Color.FromRgb(0,38,76),
Color.FromRgb(38,57,76),
Color.FromRgb(0,63,255),
Color.FromRgb(127,159,255),
Color.FromRgb(0,51,204),
Color.FromRgb(102,127,204),
Color.FromRgb(0,38,153),
Color.FromRgb(76,95,153),
Color.FromRgb(0,31,127),
Color.FromRgb(63,79,127),
Color.FromRgb(0,19,76),
Color.FromRgb(38,47,76),
Color.FromRgb(0,0,255),
Color.FromRgb(127,127,255),
Color.FromRgb(0,0,204),
Color.FromRgb(102,102,204),
Color.FromRgb(0,0,153),
Color.FromRgb(76,76,153),
Color.FromRgb(0,0,127),
Color.FromRgb(63,63,127),
Color.FromRgb(0,0,76),
Color.FromRgb(38,38,76),
Color.FromRgb(63,0,255),
Color.FromRgb(159,127,255),
Color.FromRgb(51,0,204),
Color.FromRgb(127,102,204),
Color.FromRgb(38,0,153),
Color.FromRgb(95,76,153),
Color.FromRgb(31,0,127),
Color.FromRgb(79,63,127),
Color.FromRgb(19,0,76),
Color.FromRgb(47,38,76),
Color.FromRgb(127,0,255),
Color.FromRgb(191,127,255),
Color.FromRgb(102,0,204),
Color.FromRgb(153,102,204),
Color.FromRgb(76,0,153),
Color.FromRgb(114,76,153),
Color.FromRgb(63,0,127),
Color.FromRgb(95,63,127),
Color.FromRgb(38,0,76),
Color.FromRgb(57,38,76),
Color.FromRgb(191,0,255),
Color.FromRgb(223,127,255),
Color.FromRgb(153,0,204),
Color.FromRgb(178,102,204),
Color.FromRgb(114,0,153),
Color.FromRgb(133,76,153),
Color.FromRgb(95,0,127),
Color.FromRgb(111,63,127),
Color.FromRgb(57,0,76),
Color.FromRgb(66,38,76),
Color.FromRgb(255,0,255),
Color.FromRgb(255,127,255),
Color.FromRgb(204,0,204),
Color.FromRgb(204,102,204),
Color.FromRgb(153,0,153),
Color.FromRgb(153,76,153),
Color.FromRgb(127,0,127),
Color.FromRgb(127,63,127),
Color.FromRgb(76,0,76),
Color.FromRgb(76,38,76),
Color.FromRgb(255,0,191),
Color.FromRgb(255,127,223),
Color.FromRgb(204,0,153),
Color.FromRgb(204,102,178),
Color.FromRgb(153,0,114),
Color.FromRgb(153,76,133),
Color.FromRgb(127,0,95),
Color.FromRgb(127,63,111),
Color.FromRgb(76,0,57),
Color.FromRgb(76,38,66),
Color.FromRgb(255,0,127),
Color.FromRgb(255,127,191),
Color.FromRgb(204,0,102),
Color.FromRgb(204,102,153),
Color.FromRgb(153,0,76),
Color.FromRgb(153,76,114),
Color.FromRgb(127,0,63),
Color.FromRgb(127,63,95),
Color.FromRgb(76,0,38),
Color.FromRgb(76,38,57),
Color.FromRgb(255,0,63),
Color.FromRgb(255,127,159),
Color.FromRgb(204,0,51),
Color.FromRgb(204,102,127),
Color.FromRgb(153,0,38),
Color.FromRgb(153,76,95),
Color.FromRgb(127,0,31),
Color.FromRgb(127,63,79),
Color.FromRgb(76,0,19),
Color.FromRgb(76,38,47),
Color.FromRgb(51,51,51),
Color.FromRgb(91,91,91),
Color.FromRgb(132,132,132),
Color.FromRgb(173,173,173),
Color.FromRgb(214,214,214),
Color.FromRgb(255,255,255)
};
#endregion
#region
/// <summary>
/// 获取更新路径
/// </summary>
/// <param name="settingsPath"></param>
/// <returns></returns>
public static string GetUpdatePath(string settingsPath)
{
string strUpdatePath = string.Empty;
try
{
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(File.ReadAllText(settingsPath));
strUpdatePath = xdoc.DocumentElement["Url"].InnerText;
}
catch (Exception ex)
{
strUpdatePath = ex.uBIMMessage();
}
return strUpdatePath;
}
#endregion
#region
/// <summary>
/// 获取网络时间
/// </summary>
/// <returns></returns>
public static DateTime? GetNetTime()
{
DateTime? dateTime = null;
try
{
Dictionary<string, string> HeaderList = GetHTTPResponseHeaders("http://www.baidu.com/"); //http://www.ntsc.ac.cn/
dateTime = DateTime.Parse(HeaderList["Date"]);
}
catch
{
//忽略
}
return dateTime;
}
public static Dictionary<string, string> GetHTTPResponseHeaders(string Url)
{
Dictionary<string, string> HeaderList = new Dictionary<string, string>();
WebRequest WebRequestObject = WebRequest.Create(Url);
//5秒超时
WebRequestObject.Timeout = 5000;
WebResponse ResponseObject = WebRequestObject.GetResponse();
foreach (string HeaderKey in ResponseObject.Headers)
{
HeaderList.Add(HeaderKey, ResponseObject.Headers[HeaderKey]);
}
ResponseObject.Close();
return HeaderList;
}
public static bool GMTStrParse(string gmtStr, out DateTime gmtTime)
{
CultureInfo enUS = new CultureInfo("en-US");
bool s = DateTime.TryParseExact(gmtStr, "r", enUS, DateTimeStyles.None, out gmtTime);
return s;
}
#endregion
#region exe
[DllImport("shell32.dll")]
public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);
/// <summary>
/// 运行exe
/// </summary>
/// <param name="exePath">exe路径</param>
public static void RunExe(string exePath)
{
string exeFileName = Path.GetFileName(exePath);
string dirPath = Directory.GetParent(exePath).FullName;
ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder(exeFileName), new StringBuilder(""), new StringBuilder(dirPath), 1);
}
#endregion
#region AutoCad
/// <summary>
/// 安装字体到AutoCad
/// </summary>
public static void InstallFonts()
{
try
{
//字体文件路径
string strInstallPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Autodesk\ApplicationPlugins\uBIM_ReCAD.bundle\Contents\Libs";
//获取SHX文件路径
List<string> lstFontFilePath = GetSHXFiles(strInstallPath);
#region CAD版本对应R版本参数
Dictionary<string, string> dicCadVersion = new Dictionary<string, string>
{
{ "AutoCAD 2002", "R15.0" },
{ "AutoCAD 2004", "R16.0" },
{ "AutoCAD 2005", "R16.1" },
{ "AutoCAD 2006", "R16.2" },
{ "AutoCAD 2007", "R17.0" },
{ "AutoCAD 2008", "R17.1" },
{ "AutoCAD 2009", "R17.2" },
{ "AutoCAD 2010", "R18.0" },
{ "AutoCAD 2011", "R18.1" },
{ "AutoCAD 2012", "R18.2" },
{ "AutoCAD 2013", "R19.0" },
{ "AutoCAD 2014", "R19.1" },
{ "AutoCAD 2015", "R20.0" },
{ "AutoCAD 2016", "R20.1" },
{ "AutoCAD 2017", "R21.0" },
{ "AutoCAD 2018", "R22.0" },
{ "AutoCAD 2019", "R23.0" },
{ "AutoCAD 2020", "R24.0" },
{ "AutoCAD 2021", "R25.0" },
{ "AutoCAD 2022", "R26.0" },
{ "AutoCAD 2023", "R27.0" },
{ "AutoCAD 2024", "R28.0" },
{ "AutoCAD 2025", "R29.0" },
};
#endregion
foreach (var key in dicCadVersion.Keys)
{
//中文版本
string chsFontFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), string.Format(@"Autodesk\{0}\{1}\chs\Support", key, dicCadVersion[key]));
if (Directory.Exists(chsFontFolder))
{
foreach (var fontFilePath in lstFontFilePath)
{
string strFontName = Path.GetFileName(fontFilePath);
string targetFontPath = Path.Combine(chsFontFolder, strFontName);
if (!File.Exists(targetFontPath))
{
File.Copy(fontFilePath, targetFontPath, true);
}
}
}
//英文版本
string enFontFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), string.Format(@"Autodesk\{0}\{1}\en\Support", key, dicCadVersion[key]));
if (Directory.Exists(enFontFolder))
{
foreach (var fontFilePath in lstFontFilePath)
{
string strFontName = Path.GetFileName(fontFilePath);
string targetFontPath = Path.Combine(enFontFolder, strFontName);
if (!File.Exists(targetFontPath))
{
File.Copy(fontFilePath, targetFontPath, true);
}
}
}
}
}
catch
{
throw;
}
}
#endregion
#region SHX字体文件路径
/// <summary>
/// 获取文件夹下所有的SHX字体文件路径
/// </summary>
/// <param name="targetDir">目标文件夹</param>
/// <returns></returns>
private static List<string> GetSHXFiles(string targetDir)
{
List<string> result = new List<string>();
string[] filePaths = Directory.GetFiles(targetDir);
foreach (var file in filePaths)
{
if (file.ToLower().EndsWith(".shx"))
{
result.Add(file);
}
}
return result;
}
#endregion
}
public static class ExceptionEx
{
/// <summary>
/// 异常信息处理
/// </summary>
/// <param name="exception">异常</param>
/// <returns></returns>
public static string uBIMMessage(this Exception exception)
{
return exception.Message.Replace("WW.CAD", "uBIM.CAD");
}
/// <summary>
/// 异常信息处理
/// </summary>
/// <param name="exception">异常</param>
/// <returns></returns>
public static string uBIMStackTrace(this Exception exception)
{
return exception.uBIMStackTrace().Replace("WW.CAD", "uBIM.CAD");
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Reflection;
using System.Windows;
namespace uBIM.Checker.AOP
@ -25,6 +26,8 @@ namespace uBIM.Checker.AOP
{
RunChecker();
}
/// <summary>
/// 启动检查器
/// </summary>
@ -32,6 +35,7 @@ namespace uBIM.Checker.AOP
{
Checker = new uBIM.PersonLicense.Checker(Assembly.GetExecutingAssembly());
Checker.Run();
CheckLicenseState("", false);
}
/// <summary>
/// 检查许可状态(是否有效)
@ -41,6 +45,7 @@ namespace uBIM.Checker.AOP
public bool CheckLicenseState(string title = "uBIM", bool showMsg = true)
{
bool result = !Checker.OutLimit;
Trace.TraceInformation(result.ToString());
if (showMsg)
{
string msg;

View File

@ -1,19 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<VersionPrefix>0.0.5</VersionPrefix>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<VersionPrefix>0.0.11</VersionPrefix>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspectInjector" Version="2.7.2" />
<PackageReference Include="dotnetCampus.SourceYard" Version="0.1.19392">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="RevitSDK2017" Version="1.0.0" />
<PackageReference Include="uBIM.Checker.Person" Version="1.0.13" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AspectInjector" Version="2.7.2" />
<PackageReference Include="dotnetCampus.SourceYard" Version="0.1.19392">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="RevitSDK2017" Version="1.0.0" />
<PackageReference Include="uBIM.Checker.Person" Version="1.0.13" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Management" />
</ItemGroup>
</Project>