Example #1
0
        public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <LicenseCodes.LicenseCodesClient> mockGrpcClient = new moq::Mock <LicenseCodes.LicenseCodesClient>(moq::MockBehavior.Strict);
            GetLicenseCodeRequest request = new GetLicenseCodeRequest
            {
                LicenseCode = "license_code196a50c0",
                Project     = "projectaa6ff846",
            };
            LicenseCode expectedResponse = new LicenseCode
            {
                Id                = "id74b70bb8",
                Kind              = "kindf7aa39d9",
                Name              = "name1c9368b0",
                Transferable      = false,
                CreationTimestamp = "creation_timestamp235e59a1",
                LicenseAlias      =
                {
                    new LicenseCodeLicenseAlias(),
                },
                State       = LicenseCode.Types.State.UndefinedState,
                Description = "description2cf9da67",
                SelfLink    = "self_link7e87f12d",
            };

            mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <LicenseCode>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            LicenseCodesClient client = new LicenseCodesClientImpl(mockGrpcClient.Object, null);
            LicenseCode        responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            LicenseCode responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
        public void Get()
        {
            moq::Mock <LicenseCodes.LicenseCodesClient> mockGrpcClient = new moq::Mock <LicenseCodes.LicenseCodesClient>(moq::MockBehavior.Strict);
            GetLicenseCodeRequest request = new GetLicenseCodeRequest
            {
                LicenseCode = "license_code196a50c0",
                Project     = "projectaa6ff846",
            };
            LicenseCode expectedResponse = new LicenseCode
            {
                Id                = "id74b70bb8",
                Kind              = "kindf7aa39d9",
                Name              = "name1c9368b0",
                Transferable      = false,
                CreationTimestamp = "creation_timestamp235e59a1",
                LicenseAlias      =
                {
                    new LicenseCodeLicenseAlias(),
                },
                State       = LicenseCode.Types.State.UndefinedState,
                Description = "description2cf9da67",
                SelfLink    = "self_link7e87f12d",
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            LicenseCodesClient client   = new LicenseCodesClientImpl(mockGrpcClient.Object, null);
            LicenseCode        response = client.Get(request.Project, request.LicenseCode);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #3
0
        /// <summary>
        /// Register Button Click
        /// </summary>
        protected void RegisterBtn_Click(object sender, DirectEventArgs e)
        {
            try {
                MachineCode.Clear();
                UserLimitLbl.Text = String.Empty;
                ExpiredLbl.Text   = String.Empty;
                RemarkLbl.Text    = String.Empty;
                LicenseCode.Clear();
                var sp = new BUser().GetSysParams(20000001);
                if (sp != null && sp.Count > 0)
                {
                    var mcode = sp[0].ParaDisplay;
                    var lcode = sp[0].Note;
                    if (!String.IsNullOrEmpty(mcode))
                    {
                        MachineCode.Text = mcode;
                        if (Regex.IsMatch(mcode, @"^[a-fA-F0-9]{32}$"))
                        {
                            if (!String.IsNullOrEmpty(lcode))
                            {
                                var dl = WebUtility.GetDecryptLicense(lcode, mcode);
                                if (dl != null)
                                {
                                    UserLimitLbl.Text = String.Format("最多允许{0}个用户同时在线", dl.MaxUsers);
                                    ExpiredLbl.Text   = new DateTime(dl.Expiration) == new DateTime(2099, 12, 31) ? "永不过期" : WebUtility.GetDateString(new DateTime(dl.Expiration));
                                    RemarkLbl.Text    = new DateTime(dl.Expiration) >= DateTime.Today ? String.Format("产品已注册给: {0} - {1}", dl.Name, dl.Company) : "产品注册已过期";
                                }
                                else
                                {
                                    RemarkLbl.Text = "注册码无效";
                                }
                            }
                            else
                            {
                                RemarkLbl.Text = "产品未注册";
                            }
                        }
                        else
                        {
                            RemarkLbl.Text = "机器标识码格式错误";
                        }
                    }
                    else
                    {
                        RemarkLbl.Text = "未获得机器标识码";
                    }
                }
                else
                {
                    RemarkLbl.Text = "未获得注册信息";
                }

                RegisterFormPanel.ClearInvalid();
                RegisterWnd.Show();
            } catch (Exception err) {
                WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name);
                WebUtility.ShowMessage(EnmErrType.Error, err.Message);
            }
        }
Example #4
0
 /// <summary>Snippet for Get</summary>
 public void Get()
 {
     // Snippet: Get(string, string, CallSettings)
     // Create client
     LicenseCodesClient licenseCodesClient = LicenseCodesClient.Create();
     // Initialize request argument(s)
     string project     = "";
     string licenseCode = "";
     // Make the request
     LicenseCode response = licenseCodesClient.Get(project, licenseCode);
     // End snippet
 }
Example #5
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetAsync()
        {
            // Snippet: GetAsync(string, string, CallSettings)
            // Additional: GetAsync(string, string, CancellationToken)
            // Create client
            LicenseCodesClient licenseCodesClient = await LicenseCodesClient.CreateAsync();

            // Initialize request argument(s)
            string project     = "";
            string licenseCode = "";
            // Make the request
            LicenseCode response = await licenseCodesClient.GetAsync(project, licenseCode);

            // End snippet
        }
Example #6
0
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetLicenseCodeRequest, CallSettings)
     // Create client
     LicenseCodesClient licenseCodesClient = LicenseCodesClient.Create();
     // Initialize request argument(s)
     GetLicenseCodeRequest request = new GetLicenseCodeRequest
     {
         LicenseCode = "",
         Project     = "",
     };
     // Make the request
     LicenseCode response = licenseCodesClient.Get(request);
     // End snippet
 }
Example #7
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetLicenseCodeRequest, CallSettings)
            // Additional: GetAsync(GetLicenseCodeRequest, CancellationToken)
            // Create client
            LicenseCodesClient licenseCodesClient = await LicenseCodesClient.CreateAsync();

            // Initialize request argument(s)
            GetLicenseCodeRequest request = new GetLicenseCodeRequest
            {
                LicenseCode = "",
                Project     = "",
            };
            // Make the request
            LicenseCode response = await licenseCodesClient.GetAsync(request);

            // End snippet
        }
Example #8
0
 private void tmrSplash_Tick(object sender, EventArgs e)
 {
     TimerCount         = TimerCount + 10;
     pbLoadingBar.Value = TimerCount;
     if (TimerCount == 100)
     {
         pbLoadingBar.Value = 100;
         frmLogin Login = new frmLogin();
         Login.isDatabaseConnection = isDatabaseConnected;
         tmrSplash.Enabled          = false;
         Login.Show();
         this.Hide();
     }
     else if (TimerCount == 10)
     {
         lblMessage.Text = "Checking Ini File";
         if (!File.Exists(IniPath))
         {
             lblMessage.Text   = "Ini File is Missing";
             tmrSplash.Enabled = false;
             MessageBox.Show("Setting File was not found. Please ask your administrator\n" + IniPath, "Error: Please check your Ini First", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     else if (TimerCount == 20)
     {
         lblMessage.Text = "Reading Settings File";
         ReadSettings();
     }
     else if (TimerCount == 40)
     {
         lblMessage.Text = "Checking License";
         Process proc        = new Process();
         string  LicenseCode = proc.ReadMyINI("LicenseCode", "Systems");
         if (string.IsNullOrEmpty(LicenseCode))
         {
             lblMessage.Text   = "License Code is Invalid";
             tmrSplash.Enabled = false;
             MessageBox.Show("License Code was not found. Please ask your administrator\n" + IniPath, "Error: Please check your Ini First", MessageBoxButtons.OK, MessageBoxIcon.Error);
             LicenseCode lc = new LicenseCode();
             lc.licenseCode = licenseCode;
             lc.ShowDialog();
             if (lc.licensePassed)
             {
                 tmrSplash.Enabled = true;
             }
             else
             {
                 Application.Exit();
             }
         }
         else
         {
             tmrSplash.Enabled = false;
             clsLicensing.License lic = new clsLicensing.License();
             string   ErrMsg          = string.Empty;
             DateTime dtEndLicense    = DateTime.Now;
             string   MachineCode     = string.Empty;
             if (!lic.checklicense(LicenseCode, ref ErrMsg, true, ref dtEndLicense, ref MachineCode))
             {
                 MessageBox.Show("Error: " + ErrMsg, "Please ask your administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 Application.Exit();
             }
             else
             {
                 if (DateTime.Now.Subtract(dtEndLicense).Days <= 30)
                 {
                     int Lapse_day = dtEndLicense.Subtract(DateTime.Now).Days;
                     ErrMsg = "You still have " + Lapse_day + " day(s) to use the software and your copy is nearly to expire. Please renew it before time lapse.";
                     MessageBox.Show("Warning: " + ErrMsg, ". Please check your administrator on this matter", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 if (!proc.SaveMyIni("LicenseCode", "Systems", licenseCode))
                 {
                     MessageBox.Show("Error: Cannot save your license.", "Please check your administrator on this matter", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     Application.Exit();
                 }
                 tmrSplash.Enabled = true;
                 lblMessage.Text   = "License Valid";
             }
         }
     }
     else if (TimerCount == 60)
     {
         lblMessage.Text = "Checking Database Connection";
         BusinessLogic.Process proc = new BusinessLogic.Process();
         string ErrMsg           = string.Empty;
         string ConnectionString = proc.GetConnectionStringIni();
         proc.CheckMyConnection(ConnectionString, ref ErrMsg);
         if (!string.IsNullOrEmpty(ErrMsg))
         {
             lblMessage.Text = ErrMsg;
         }
         else
         {
             lblMessage.Text     = "Connected to Database : Sucess";
             isDatabaseConnected = true;
         }
     }
     else if (TimerCount == 70)
     {
         lblMessage.Text = "Preparing Resources";
     }
     else if (TimerCount == 85)
     {
         lblMessage.Text = "Initializing...s";
     }
     else if (TimerCount == 90)
     {
         lblMessage.Text = "Program Starts...";
     }
 }
 private void RequestLicense_Shown(object sender, EventArgs e)
 {
     LicenseCode.Focus();
 }