예제 #1
0
 /// <summary>
 /// 회사코드가 변경된 경우는 db재설치를 한경우
 /// 신규이거나 변경사항 없으면 패스
 /// 등록한 라이센스파일을 C:\eclues\AppData\config로 복사. 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonNext_Click(object sender, EventArgs e)
 {
     ctrl.KeepPrevConfig = CkBoxKeepConfig.Checked;
     if (ctrl.CompanyCd != "" && !ctrl.CompanyCd.Equals(companyCd))
     {
         if (MessageBox.Show(string.Format("이전에 사용하던 회사코드({0})와 다른 회사코드({1})가 적용되었습니다. "
                                         + "\n회사코드를 변경하시겠습니까?"
                                          , ctrl.CompanyCd
                                          , companyCd)
                             , "회사코드 변경"
                             , MessageBoxButtons.OKCancel) == DialogResult.Cancel)
         {
             DialogResult = DialogResult.None;
             ButtonLicenseFile.Focus();
             return;
         }
     }
     ctrl.CompanyCd = companyCd;
     ctrl.CompanyName = companyName;
     ctrl.MsgrPort = Convert.ToInt16(TextBoxMsgrPort.Text);
     ctrl.CrmPort = Convert.ToInt16(TextBoxCrmPort.Text);
     FileInfo info = new FileInfo(LabelLicenseFile.Text);
     LicenseHandler handler = new LicenseHandler(info);
     handler.BackupLicenseFile(ConstDef.APP_DATA_CONFIG_DIR);
     
 }
예제 #2
0
        /// <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());
            }
        }
예제 #3
0
        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();
        }