/// <summary> /// 파일에서 라이센스정보를 읽어, 유효성검사를 한다. /// </summary> private void registerLicenseInfo() { try { LogWrite("라이선스 체크중....."); mLicenseHandler = new LicenseHandler(ConstDef.APP_DATA_CONFIG_DIR); mLicenseHandler.LogWriteHandler += this.OnLogWrite; //파일읽음&라이센스값 decode if (mLicenseHandler.ReadLicense()) { stringDele dele = new stringDele(disposeLicenseResult); Invoke(dele, mLicenseHandler.ResultMessage); } } catch (Exception ex) { LogWrite(ex.ToString()); } }
private void ButtonLicenseFile_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); if (!Directory.Exists(ConstDef.APP_DATA_CONFIG_DIR)) { fileDialog.InitialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); } else { fileDialog.InitialDirectory = ConstDef.APP_DATA_CONFIG_DIR; } fileDialog.DefaultExt = "ini"; fileDialog.RestoreDirectory = true; fileDialog.Filter = "WeDo License 파일|*.ini"; fileDialog.SupportMultiDottedExtensions = true; if (Utils.STAShowDialog(fileDialog) == DialogResult.OK) { Initialize(); LabelLicenseFile.Text = fileDialog.FileName; FileInfo info = new FileInfo(LabelLicenseFile.Text); LicenseHandler handler = new LicenseHandler(info); handler.LogWriteHandler += OnStatusWrite; handler.ReadLicense(); companyCd = handler.CompanyCode; companyName = handler.CompanyName; LabelCompanyCd.Text = string.Format("{0}({1})", companyName, companyCd); if (ctrl.NeedDbReinstall(handler.CompanyCode)) { ButtonDBReinstall.Enabled = true; SetLicenseCheck(false); LabelWarning.Text = string.Format("라이센스파일의 회사코드[{0}]가 기존 회사코드[{1}]와 다릅니다.\n" +" 새로운 회사코드를 쓰려면 DB를 재설치해야 합니다." , handler.CompanyCode, ctrl.CompanyCd); } else { ButtonDBReinstall.Enabled = false; if (handler.ValidLicense()) { SetLicenseCheck(true); LabelWarning.Text = "라이센스파일이 유효합니다."; } else { SetLicenseCheck(false); LabelWarning.Text = "라이센스파일 검증에 실패했습니다. 파일유효성을 확인하세요.\n"; int resultCode = Convert.ToInt16(handler.ResultMessage.Split('&')[0]); if (resultCode == (int)LicenseResult.ERR_EXPIRED) { LabelWarning.Text += "License 만료일자 지남."; } else if (resultCode == (int)LicenseResult.ERR_INVALID_FILE) { LabelWarning.Text += "잘못된 등록일자, 회사코드/명 또는 라이센스키."; } else if (resultCode == (int)LicenseResult.ERR_MAC_ADDR) { LabelWarning.Text += string.Format("License file 잘못된 mac address값.실제 mac address[{0}]", handler.MacAddress); } } } } fileDialog.Dispose(); }