|
@@ -1,5 +1,6 @@
|
|
|
using LabelManager2;
|
|
|
using Microsoft.Win32;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
using Seagull.BarTender.Print;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
@@ -51,37 +52,58 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
public static string DToAny(double DB, int Type)
|
|
|
{
|
|
|
string H = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
+ string H1 = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|
|
long D;
|
|
|
double B;
|
|
|
string tempD = "", tempB = "";
|
|
|
- D = (long)DB;
|
|
|
- B = DB - D;
|
|
|
- if (D == 0)
|
|
|
+ if (Type == 32)
|
|
|
{
|
|
|
- tempD = "0";
|
|
|
+ return GetRandomChar(H1);
|
|
|
}
|
|
|
- while (D != 0)
|
|
|
- {
|
|
|
- tempD = H[(((int)D % Type))] + tempD;
|
|
|
- D = D / Type;
|
|
|
- }
|
|
|
- for (int i = 0; i < 7; i++)
|
|
|
- {
|
|
|
- if (B == 0)
|
|
|
+ else {
|
|
|
+ D = (long)DB;
|
|
|
+ B = DB - D;
|
|
|
+ if (D == 0)
|
|
|
{
|
|
|
- break;
|
|
|
+ tempD = "0";
|
|
|
+ }
|
|
|
+ while (D != 0)
|
|
|
+ {
|
|
|
+ tempD = H[(((int)D % Type))] + tempD;
|
|
|
+ D = D / Type;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < 7; i++)
|
|
|
+ {
|
|
|
+ if (B == 0)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ tempB += H[((int)(B * Type))];
|
|
|
+ B = B * Type - (int)(B * Type);
|
|
|
+ }
|
|
|
+ if (tempB == "")
|
|
|
+ {
|
|
|
+ return tempD;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return tempD + "." + tempB;
|
|
|
}
|
|
|
- tempB += H[((int)(B * Type))];
|
|
|
- B = B * Type - (int)(B * Type);
|
|
|
- }
|
|
|
- if (tempB == "")
|
|
|
- {
|
|
|
- return tempD;
|
|
|
}
|
|
|
- else
|
|
|
+ }
|
|
|
+
|
|
|
+ public static string GetRandomChar(string str)
|
|
|
+ {
|
|
|
+ byte[] buffer = Guid.NewGuid().ToByteArray();
|
|
|
+ int iSeed = BitConverter.ToInt32(buffer, 0);
|
|
|
+ Random random = new Random(iSeed);
|
|
|
+ string data = "";
|
|
|
+ for (int i = 0; i < 5; i++)
|
|
|
{
|
|
|
- return tempD + "." + tempB;
|
|
|
+ int index = random.Next(0, 31);
|
|
|
+ data += str[index];
|
|
|
}
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1508,7 +1530,7 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
{
|
|
|
p.StandardInput.Close();
|
|
|
string IMEI = p.StandardOutput.ReadToEnd();
|
|
|
- foreach (Match item in Regex.Matches(IMEI, "'\\S+"))
|
|
|
+ foreach (System.Text.RegularExpressions.Match item in Regex.Matches(IMEI, "'\\S+"))
|
|
|
{
|
|
|
value += item.Value.Replace(".", "").Replace("'", "").Replace(")", "");
|
|
|
}
|