using KMBIM.Revit.Tools.kr.co.dcs.newlicense; using System; using System.Collections.Generic; using System.Linq; using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; namespace KDCS.Utils { public class CommonFunc { static DCS_License_WebService dcslic = new DCS_License_WebService(); static public bool CallAspx(string lpszParam, ref List rStrArray) { string strEncParam = Crypt.str2hex(lpszParam); string strResult = string.Empty; strResult = CommonFunc.dcslic.RequestBase(strEncParam); if (!string.IsNullOrEmpty(strResult)) { string strDecRes = Crypt.HexString2Ascii(strResult); if (SplitToStrArray(strDecRes, ref rStrArray, "|") > 0) if (StrArrayValue(ref rStrArray, Define.STRING_RESULT_TAG) == "1") return true; } return false; } private static void A_RequestBaseCompleted1(object sender, RequestBaseCompletedEventArgs e) { var a=e.Result.ToString(); } static public int SplitToStrArray(string lpszLine, ref List rArr, string lpszSep) { string[] arr = lpszLine.Split(lpszSep.ToCharArray()[0]); rArr = arr.ToList(); string strSep = lpszSep; string strBuf = lpszLine; strBuf.Trim(); if (strBuf.Length < 1) return 0; int nCur = -1, nNext = -1; int nCount = 0; while (true) { nNext = strBuf.IndexOf(strSep, ++nCur); if (nNext != -1) { string strTmp = Mid(strBuf, nCur, nNext - nCur); strTmp.Trim(); rArr.Add(strTmp); nCur = nNext; } else { if (Right(strBuf, 1) == strSep) rArr.Add(""); else { string strTmp = Mid(strBuf, nCur, strBuf.Length - 1); strTmp.Trim(); rArr.Add(strTmp); } return rArr.Count; } ++nCount; } return rArr.Count(); } static public string StrArrayValue(ref List rArr, string lpszKey) { string strRet = string.Empty; for (int i = 0; i < rArr.Count(); i++) { string strTmp = rArr[i]; string[] strArr = strTmp.Split('='); string strKey = strArr[0]; if (string.Compare(strKey, string.Empty, true) == 0 || string.Compare(strKey, lpszKey, true) != 0) continue; strRet = strArr[strArr.Length - 1]; break; } return strRet; } static public string Mid(string Text, int Startint, int Endint) { Text.Replace("\\0", ""); string convertText; if (Startint < Text.Length || Endint < Text.Length) { convertText = Text.Substring(Startint, Endint); return convertText; } else return Text; } static public string Right(string Text, int TextLength) { string ConvertText; if (Text.Length < TextLength) { TextLength = Text.Length; } ConvertText = Text.Substring(Text.Length - TextLength, TextLength); return ConvertText; } static public string Left(string Text, int TextLength) { string ConvertText; if (Text.Length < TextLength) { TextLength = Text.Length; } ConvertText = Text.Substring(0, TextLength); return ConvertText; } static public string GetMACAddress() { string MacAddress = ""; NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface adapter in adapters) { System.Net.NetworkInformation.PhysicalAddress pa = adapter.GetPhysicalAddress(); if (pa != null && !pa.ToString().Equals("")) { MacAddress = pa.ToString(); break; } } return MacAddress; } } }