Umgeschrieben auf Dongle System
This commit is contained in:
BIN
3rdPackage/WibuCmNET.dll
Normal file
BIN
3rdPackage/WibuCmNET.dll
Normal file
Binary file not shown.
133
SanSystem/Dongle.cs
Normal file
133
SanSystem/Dongle.cs
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
using CodeMeter;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SanSystem
|
||||||
|
{
|
||||||
|
class Dongle
|
||||||
|
{
|
||||||
|
uint FirmCode;
|
||||||
|
uint ProductCode;
|
||||||
|
|
||||||
|
Api cmApi;
|
||||||
|
CmCredential cmCred;
|
||||||
|
CmAccess2 cmAcc;
|
||||||
|
HCMSysEntry hcmse;
|
||||||
|
CmBoxInfo cmBoxInfo;
|
||||||
|
CmBoxEntry2 BoxContent;
|
||||||
|
|
||||||
|
public Dongle(uint FirmCode, uint ProductCode)
|
||||||
|
{
|
||||||
|
#if !DEBUG
|
||||||
|
if (FirmCode == 103086)
|
||||||
|
this.FirmCode = FirmCode;
|
||||||
|
else
|
||||||
|
this.FirmCode = 103086;
|
||||||
|
#else
|
||||||
|
this.FirmCode = 10;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
this.ProductCode = ProductCode;
|
||||||
|
cmApi = new Api();
|
||||||
|
cmCred = new CmCredential();
|
||||||
|
cmAcc = new CmAccess2();
|
||||||
|
|
||||||
|
cmAcc.Credential = cmCred;
|
||||||
|
|
||||||
|
cmAcc.Ctrl |= CmAccess.Option.UserLimit;
|
||||||
|
cmAcc.FirmCode = this.FirmCode;
|
||||||
|
cmAcc.ProductCode = this.ProductCode;
|
||||||
|
|
||||||
|
|
||||||
|
hcmse = cmApi.CmAccess2(CmAccessOption.Local, cmAcc);
|
||||||
|
if(hcmse == null)
|
||||||
|
{
|
||||||
|
ErrorCodes2 code = cmApi.CmGetLastErrorCode2();
|
||||||
|
string output = string.Format("{0}", code);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CheckDongleVorhanden())
|
||||||
|
Trace.WriteLine("Dongle nicht vorhanden");
|
||||||
|
|
||||||
|
cmBoxInfo = new CmBoxInfo();
|
||||||
|
|
||||||
|
CmGetBoxContentsOption boxOptions = new CmGetBoxContentsOption();
|
||||||
|
boxOptions = CmGetBoxContentsOption.FirmItem;
|
||||||
|
|
||||||
|
CmBoxEntry2[] tmpBoxContent;
|
||||||
|
|
||||||
|
tmpBoxContent = cmApi.CmGetBoxContents2(hcmse, boxOptions, this.FirmCode, cmBoxInfo);
|
||||||
|
|
||||||
|
foreach (CmBoxEntry2 boxes in tmpBoxContent)
|
||||||
|
{
|
||||||
|
if (boxes.ProductCode == this.ProductCode)
|
||||||
|
{
|
||||||
|
this.BoxContent = boxes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~Dongle()
|
||||||
|
{
|
||||||
|
CleanDongle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CleanDongle()
|
||||||
|
{
|
||||||
|
cmApi.CmRelease(hcmse);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckDongleVorhanden()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (hcmse == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetDongleSerial()
|
||||||
|
{
|
||||||
|
|
||||||
|
CmBoxInfo res = (CmBoxInfo)cmApi.CmGetInfo(hcmse, CmGetInfoOption.BoxInfo);
|
||||||
|
if (null != res)
|
||||||
|
{
|
||||||
|
return res.SerialNumber.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Fehler beim aufrufen der Seriennummer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint GetFeatureMap()
|
||||||
|
{
|
||||||
|
return BoxContent.FeatureMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsLicensed(byte neededMask)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint DongleFeature = GetFeatureMap();
|
||||||
|
|
||||||
|
Trace.WriteLine("DongleFeature: " + DongleFeature);
|
||||||
|
|
||||||
|
byte DongleFeatureB = (byte)DongleFeature;
|
||||||
|
|
||||||
|
if ((DongleFeatureB & neededMask) == neededMask)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -40,7 +40,7 @@ namespace SanSystem
|
|||||||
private void btn_add_san_Click(object sender, EventArgs e)
|
private void btn_add_san_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
int mod = (int)Sanierungsarten.KURZLINER ^ (int)Sanierungsarten.QUICKLOCK ^ (int)Sanierungsarten.HUTPROFIL;
|
int mod = (int)Sanierungsarten.KURZLINER ^ (int)Sanierungsarten.QUICKLOCK ^ (int)Sanierungsarten.HUTPROFIL;
|
||||||
FrmSelectNewSan frmSelectNewSan = new FrmSelectNewSan(mod);
|
FrmSelectNewSan frmSelectNewSan = new FrmSelectNewSan();
|
||||||
|
|
||||||
frmSelectNewSan.AddKurzlinerClicked += FrmSelectNewSan_AddKurzlinerClicked;
|
frmSelectNewSan.AddKurzlinerClicked += FrmSelectNewSan_AddKurzlinerClicked;
|
||||||
frmSelectNewSan.AddHutprofilClicked += FrmSelectNewSan_AddHutprofilClicked;
|
frmSelectNewSan.AddHutprofilClicked += FrmSelectNewSan_AddHutprofilClicked;
|
||||||
|
|||||||
@@ -85,23 +85,26 @@ namespace SanSystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mod"></param>
|
public FrmSelectNewSan()
|
||||||
public FrmSelectNewSan(int mod)
|
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
SanArt sanArt = new SanArt(mod);
|
//SanArt sanArt = new SanArt(mod);
|
||||||
|
Dongle dongle = new Dongle(10, 60);
|
||||||
|
|
||||||
btn_inliner.Text = Global.Instance.language.Labels["inliner"];
|
btn_inliner.Text = Global.Instance.language.Labels["inliner"];
|
||||||
btn_hut.Text = Global.Instance.language.Labels["hut"];
|
btn_hut.Text = Global.Instance.language.Labels["hut"];
|
||||||
btn_kurzliner.Text = Global.Instance.language.Labels["kurzliner"];
|
btn_kurzliner.Text = Global.Instance.language.Labels["kurzliner"];
|
||||||
btn_schacht_anb.Text = Global.Instance.language.Labels["schacht_an"];
|
btn_schacht_anb.Text = Global.Instance.language.Labels["schacht_an"];
|
||||||
|
|
||||||
btn_inliner.Enabled = sanArt.SanierungActivated(Sanierungsarten.INLINER);
|
|
||||||
btn_kurzliner.Enabled = sanArt.SanierungActivated(Sanierungsarten.KURZLINER);
|
btn_inliner.Enabled = dongle.IsLicensed((byte)Sanierungsarten.INLINER) ? true : false;// sanArt.SanierungActivated(Sanierungsarten.INLINER);
|
||||||
btn_hut.Enabled = sanArt.SanierungActivated(Sanierungsarten.HUTPROFIL);
|
btn_kurzliner.Enabled = dongle.IsLicensed((byte)Sanierungsarten.KURZLINER) ? true : false; //sanArt.SanierungActivated(Sanierungsarten.KURZLINER);
|
||||||
btn_schacht_anb.Enabled = sanArt.SanierungActivated(Sanierungsarten.SCHACHTANBINDUNG);
|
btn_hut.Enabled = dongle.IsLicensed((byte)Sanierungsarten.HUTPROFIL) ? true : false;// sanArt.SanierungActivated(Sanierungsarten.HUTPROFIL);
|
||||||
//btn_hut.Enabled = btn_kurzliner.Enabled = false;
|
btn_schacht_anb.Enabled = dongle.IsLicensed((byte)Sanierungsarten.SCHACHTANBINDUNG) ? true : false; // sanArt.SanierungActivated(Sanierungsarten.SCHACHTANBINDUNG);
|
||||||
|
btn_hut.Enabled = btn_kurzliner.Enabled = false;
|
||||||
|
|
||||||
|
dongle.CleanDongle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btn_inliner_Click(object sender, EventArgs e)
|
private void btn_inliner_Click(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -14,10 +14,20 @@ namespace SanSystem
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
Global.Instance.LoadLanguage();
|
Dongle dongle = new Dongle(10, 60);
|
||||||
Application.EnableVisualStyles();
|
if (dongle.CheckDongleVorhanden())
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
{
|
||||||
Application.Run(new frmMain());
|
dongle.CleanDongle();
|
||||||
|
Global.Instance.LoadLanguage();
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new frmMain());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Sorry es wurde kein Dongle gefunden!");
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,8 +78,13 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="WibuCmNET, Version=6.80.274.500, Culture=neutral, PublicKeyToken=01d86e1eb0c69c23, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\3rdPackage\WibuCmNET.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Dongle.cs" />
|
||||||
<Compile Include="Einstellungen\ObjecteListSetting.cs" />
|
<Compile Include="Einstellungen\ObjecteListSetting.cs" />
|
||||||
<Compile Include="Einstellungen\Settings.cs" />
|
<Compile Include="Einstellungen\Settings.cs" />
|
||||||
<Compile Include="FrmAuftraggeberEdit.cs">
|
<Compile Include="FrmAuftraggeberEdit.cs">
|
||||||
|
|||||||
@@ -116,8 +116,11 @@ namespace SanSystem
|
|||||||
|
|
||||||
private void btn_add_san_Click(object sender, EventArgs e)
|
private void btn_add_san_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
int mod = (int)Sanierungsarten.INLINER ^ (int)Sanierungsarten.SCHACHTANBINDUNG;
|
//Dongle dongle = new Dongle(103086, 60);
|
||||||
FrmSelectNewSan frmSelectNewSan = new FrmSelectNewSan(mod);
|
|
||||||
|
//int mod = dongle.IsLicensed((byte)Sanierungsarten.INLINER) ? (int)Sanierungsarten.INLINER : 0; // (int)Sanierungsarten.INLINER ^ (int)Sanierungsarten.SCHACHTANBINDUNG; // Auslagern zur Dongle
|
||||||
|
|
||||||
|
FrmSelectNewSan frmSelectNewSan = new FrmSelectNewSan();
|
||||||
|
|
||||||
frmSelectNewSan.AddInlinerClicked += FrmSelectNewSan_AddInlinerClicked;
|
frmSelectNewSan.AddInlinerClicked += FrmSelectNewSan_AddInlinerClicked;
|
||||||
frmSelectNewSan.AddSchachtAnbindungClicked += FrmSelectNewSan_AddSchachtAnbindungClicked;
|
frmSelectNewSan.AddSchachtAnbindungClicked += FrmSelectNewSan_AddSchachtAnbindungClicked;
|
||||||
|
|||||||
Reference in New Issue
Block a user