Datenbank erweitert
This commit is contained in:
@@ -4,7 +4,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CodeMeter;
|
||||
|
||||
|
||||
namespace SanShared
|
||||
{
|
||||
@@ -15,12 +15,12 @@ namespace SanShared
|
||||
uint ProductCode;
|
||||
public string SyncfusionKey = "";
|
||||
|
||||
Api cmApi;
|
||||
CmCredential cmCred;
|
||||
CmAccess2 cmAcc;
|
||||
HCMSysEntry hcmse;
|
||||
CmBoxInfo cmBoxInfo;
|
||||
CmBoxEntry2 BoxContent;
|
||||
//Api cmApi;
|
||||
//CmCredential cmCred;
|
||||
//CmAccess2 cmAcc;
|
||||
//HCMSysEntry hcmse;
|
||||
//CmBoxInfo cmBoxInfo;
|
||||
//CmBoxEntry2 BoxContent;
|
||||
|
||||
public Dongle(uint ProductCode)
|
||||
{
|
||||
@@ -34,66 +34,66 @@ namespace SanShared
|
||||
#endif
|
||||
|
||||
|
||||
cmApi = new Api();
|
||||
cmCred = new CmCredential();
|
||||
cmAcc = new CmAccess2();
|
||||
//cmApi = new Api();
|
||||
//cmCred = new CmCredential();
|
||||
//cmAcc = new CmAccess2();
|
||||
|
||||
cmAcc.Credential = cmCred;
|
||||
//cmAcc.Credential = cmCred;
|
||||
|
||||
cmAcc.Ctrl |= CmAccess.Option.UserLimit;
|
||||
cmAcc.FirmCode = this.FirmCode;
|
||||
cmAcc.ProductCode = this.ProductCode;
|
||||
//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);
|
||||
//hcmse = cmApi.CmAccess2(CmAccessOption.Local, cmAcc);
|
||||
//if (hcmse == null)
|
||||
//{
|
||||
// ErrorCodes2 code = cmApi.CmGetLastErrorCode2();
|
||||
// string output = string.Format("{0}", code);
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
if (!CheckDongleVorhanden())
|
||||
throw new Exception("Dongle not connected");
|
||||
//if (!CheckDongleVorhanden())
|
||||
// throw new Exception("Dongle not connected");
|
||||
|
||||
cmBoxInfo = new CmBoxInfo();
|
||||
//cmBoxInfo = new CmBoxInfo();
|
||||
|
||||
CmGetBoxContentsOption boxOptions = new CmGetBoxContentsOption();
|
||||
boxOptions = CmGetBoxContentsOption.AllEntries;
|
||||
//CmGetBoxContentsOption boxOptions = new CmGetBoxContentsOption();
|
||||
//boxOptions = CmGetBoxContentsOption.AllEntries;
|
||||
|
||||
CmBoxEntry2[] tmpBoxContent;
|
||||
//CmBoxEntry2[] tmpBoxContent;
|
||||
|
||||
tmpBoxContent = cmApi.CmGetBoxContents2(hcmse, boxOptions, this.FirmCode, cmBoxInfo);
|
||||
//tmpBoxContent = cmApi.CmGetBoxContents2(hcmse, boxOptions, this.FirmCode, cmBoxInfo);
|
||||
|
||||
CmEntryData[] pCmBoxEntry = (CmEntryData[])cmApi.CmGetInfo(hcmse, CmGetInfoOption.EntryData);
|
||||
//CmEntryData[] pCmBoxEntry = (CmEntryData[])cmApi.CmGetInfo(hcmse, CmGetInfoOption.EntryData);
|
||||
|
||||
for (int i = 0; i < pCmBoxEntry.Length; i++)
|
||||
{
|
||||
switch (pCmBoxEntry[i].Ctrl & 0x0ffff)
|
||||
{
|
||||
case (uint)CodeMeter.GlobalEntryOption.ProtectedData:
|
||||
// Transfer to transformed byte
|
||||
uint length = pCmBoxEntry[i].DataLen;
|
||||
byte[] datas = new byte[length];
|
||||
for(uint f = 0; f < length; f++)
|
||||
{
|
||||
datas[f] = pCmBoxEntry[i].Data[f];
|
||||
}
|
||||
//for (int i = 0; i < pCmBoxEntry.Length; i++)
|
||||
//{
|
||||
// switch (pCmBoxEntry[i].Ctrl & 0x0ffff)
|
||||
// {
|
||||
// case (uint)CodeMeter.GlobalEntryOption.ProtectedData:
|
||||
// // Transfer to transformed byte
|
||||
// uint length = pCmBoxEntry[i].DataLen;
|
||||
// byte[] datas = new byte[length];
|
||||
// for(uint f = 0; f < length; f++)
|
||||
// {
|
||||
// datas[f] = pCmBoxEntry[i].Data[f];
|
||||
// }
|
||||
|
||||
|
||||
SyncfusionKey = Encoding.ASCII.GetString(datas);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// SyncfusionKey = Encoding.ASCII.GetString(datas);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach (CmBoxEntry2 boxes in tmpBoxContent)
|
||||
{
|
||||
if (boxes.ProductCode == this.ProductCode)
|
||||
{
|
||||
this.BoxContent = boxes;
|
||||
}
|
||||
//foreach (CmBoxEntry2 boxes in tmpBoxContent)
|
||||
//{
|
||||
// if (boxes.ProductCode == this.ProductCode)
|
||||
// {
|
||||
// this.BoxContent = boxes;
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
}
|
||||
~Dongle()
|
||||
{
|
||||
@@ -102,10 +102,8 @@ namespace SanShared
|
||||
|
||||
public void CleanDongle()
|
||||
{
|
||||
#if DEBUG
|
||||
return;
|
||||
#endif
|
||||
cmApi.CmRelease(hcmse);
|
||||
//cmApi.CmRelease(hcmse);
|
||||
}
|
||||
|
||||
public bool CheckDongleVorhanden()
|
||||
@@ -113,30 +111,32 @@ namespace SanShared
|
||||
#if LAPTOP
|
||||
return true;
|
||||
#else
|
||||
if (hcmse == null)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return true;
|
||||
//if (hcmse == null)
|
||||
// return false;
|
||||
//else
|
||||
// return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
return string.Empty;
|
||||
//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;
|
||||
return 255;
|
||||
//return BoxContent.FeatureMap;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
@@ -146,6 +146,7 @@ namespace SanShared
|
||||
|
||||
public bool IsLicensed(byte neededMask)
|
||||
{
|
||||
return true;
|
||||
#if DEBUG
|
||||
return true;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user