private void sendRequest_ActivationButton(object sender, RoutedEventArgs e) { string licenseCode = licenseCode1.Text + "-" + licenseCode2.Text + "-" + licenseCode3.Text + "-" + licenseCode4.Text; if (checkInternetConnection()) { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; // set the cursor to loading spinner LicenseServiceController licenseController = new LicenseServiceController(); int licenseNumber = licenseController.getLincenceRequest(licenseCode); LicenseRequest request = getRequest(licenseCode, cpuId); if (licenseNumber == request.ExcerciseNumber && request.LicenseExistence) { this.Hide(); Properties.Settings.Default.LicenceExists = true; Properties.Settings.Default.Save(); Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;// set the cursor back to arrow this.mainWindow.ConnectBnt.IsEnabled = true; this.mainWindow.OpenFilesBtn.IsEnabled = true; } else { activationButton.IsEnabled = true; messageLabel.Visibility = Visibility.Visible; Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow; // set the cursor back to arrow } } else { Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow; // set the cursor back to arrow messageLabel.Content = "Подключитесь к интернету для проверки ключа"; messageLabel.Visibility = Visibility.Visible; } }
private LicenseRequest getRequest(string licenseCode, string cpu) { try { //Create a request and get Response in a xml WebClient webClient = new WebClient(); webClient.QueryString.Add("licenseNumber", licenseCode); webClient.QueryString.Add("cpuId", cpu); var result = webClient.DownloadString("http://yournewskills.ru/LicenseService.asmx/getLincenseAndCPURequest"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(result); var excerciseNumber = xmlDoc.GetElementsByTagName("ExcerciseNumber")[0].InnerText; var licenseExistence = xmlDoc.GetElementsByTagName("LicenseExistence")[0].InnerText; LicenseRequest licenseRequest = new LicenseRequest(); licenseRequest.LicenseExistence = bool.Parse(licenseExistence); licenseRequest.ExcerciseNumber = int.Parse(excerciseNumber); return(licenseRequest); } catch (WebException e) { string pageContent = new StreamReader(e.Response.GetResponseStream()).ReadToEnd().ToString(); return(new LicenseRequest()); } }
async private void BtnEmailClicked(object sender, EventArgs e) { UpdateUI(true); LicenseService service = new LicenseService(ProgramVars.LicURL); LicenseRequest request = new LicenseRequest() { Method = "Request", ClientID = "", DeviceID = "", languageID = App.appSettings.languageID, ServerID = "", Email = tbEmail.Text }; try { LicenseResult result = await service.ExecuteAsync(request); if (result.statusCode != 0) { throw new Exception(result.status); } tbEmail.Text = ""; UpdateUI(false); licensePanel.IsVisible = true; emailPanel.IsVisible = false; await DisplayAlert(AppResources.Info, AppResources.LicenseRequested, AppResources.OK); } catch (Exception ex) { UpdateUI(false); await DisplayAlert(AppResources.Error, ex.Message, AppResources.OK); } }
public LicenseRequest getLincenseAndCPURequest(string licenseNumber, string cpuId) { LicenseRequest request = new LicenseRequest(); request.ExcerciseNumber = getExcersiceRequest(licenseNumber); request.LicenseExistence = checkLicenseExistenz(licenseNumber, cpuId); return(request); }
public Response <License> Post(LicenseRequest request) { try { License license = LicenseDAL.GetNewLicense(request.User, request.ApplicationID); return(new Response <License>(license)); } catch (Exception ex) { return(new Response <License>(ex.Message)); } }
public LicenseContainer Request(LicenseRequest request) { if (request is LicenseRequestMock) { var req = request as LicenseRequestMock; var lic = new LicenseMock(); lic.SetHarwareId(req.HardwareId); lic.SetProductId(req.ProductId); return(Sign(lic, Const.FULL_KEY)); } throw new NotSupportedException($"License request of type '{request.GetType().Name}' is not supported by this provider"); }
public LicenseContainer Request(LicenseRequest request) { return(LicenseContainer.Sign(new LicenseMock(), Const.FULL_KEY)); //if (request is LicenseMock) //{ // var req = request as LicenseMock; // var lic = new LicenseMock(req.HardwareId, req.ProductId, // req.SaltoEnabled, req.PresenceEnabled, req.VisitsEnabled, req.LogisticEnabled, req.IntrusionEnabled); // //string fullKey, publicKey; // //LicensingManager.GenerateKey(out fullKey, out publicKey); // return LicenseContainer.Sign(lic, FullKey); //} //throw new NotSupportedException($"License request of type '{request.GetType().Name}' is not supported by this provider"); }
public async Task <IActionResult> Post(LicenseRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (HybridSupport.IsElectronActive && !request.LicenseAgreed) { Electron.App.Exit(); } await ApplicationDataHelper.AgreeLicense(GetType().Assembly, "HstWB Imager", request.LicenseAgreed); return(Ok()); }
public async Task <ActionResult <App> > PostApp( [FromBody] LicenseRequest request) { var result = await appsService.CreateApp(request); if (result.Success) { result.Message = ControllerMessages.StatusCode201(result.Message); return(StatusCode((int)HttpStatusCode.Created, result)); } else { result.Message = ControllerMessages.StatusCode404(result.Message); return(NotFound(result)); } }
public LicenseResponse Post([FromBody] LicenseRequest request) { if (request == null) { throw new BadRequestException("Request body could not be deserialized as a license request."); } request.Validate(); _telemetry.TrackEvent("LicenseRequest", new Dictionary <string, string> { { "KeySessionType", request.SessionType } }, new Dictionary <string, double> { { "RequestedKeyCount", request.KeyIdsAsBase64Url.Length } }); // 404 if a key is missing foreach (var requestedKey in request.KeyIds) { if (!KeyDatabase.Current.Keys.ContainsKey(requestedKey)) { throw new HttpResponseException(new HttpResponseMessage { StatusCode = System.Net.HttpStatusCode.NotFound, ReasonPhrase = "Key is not in database: " + requestedKey }); } } return(new LicenseResponse { // Whatever session type was requested shall be in the response. SessionType = request.SessionType, Keys = request.KeyIds.Select(kid => new ContentKey { IdAsBase64Url = ConvertHelpers.ByteArrayToBase64Url(kid.ToBigEndianByteArray()), ValueAsBase64Url = ConvertHelpers.ByteArrayToBase64Url(KeyDatabase.Current.Keys[kid]) }).ToArray() }); }
async private void BtnActivateClicked(object sender, EventArgs e) { UpdateUI(true); LicenseService service = new LicenseService(ProgramVars.LicURL); LicenseRequest request = new LicenseRequest() { Method = "Register", ClientID = tbLicenseKey.Text, DeviceID = App.appSettings.deviceID, languageID = App.appSettings.languageID, ServerID = "", Email = "" }; try { LicenseResult result = await service.ExecuteAsync(request); if (result.statusCode != 0) { throw new Exception(result.status); } App.appSettings.clientID = request.ClientID; App.appSettings.serverID = result.ServerID; App.appSettings.installationID = result.InstallationID; App.appSettings.isDemo = result.IsDemo; App.appSettings.serviceURL = result.URLs[0]; App.appSettings.imageURL = result.URLs[2]; ProgramVars.URL = App.appSettings.serviceURL; ProgramVars.ImageHandlerUrl = App.appSettings.imageURL; UpdateUI(false); await App.SaveAllPropertiesAsync(); await App.Current.MainPage.Navigation.PopAsync(true); } catch (Exception ex) { UpdateUI(false); tbLicenseKey.Text = ""; await DisplayAlert(AppResources.Error, ex.Message, AppResources.OK); } }
public async Task <IActionResult> CreateTodo([FromBody] LicenseRequest newTodo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await using var stream = new FileStream(newTodo.filePath, FileMode.Open, FileAccess.Read); using var reader = new StreamReader(stream); string xmlString = await reader.ReadToEndAsync(); bool isCreated = await _licenseService.CreateLicense(xmlString, newTodo.Name); if (isCreated == false) { return(BadRequest()); } return(Ok()); }
public override LicenseResponse GetLicenses(LicenseRequest objLicenseRequest) { LicensesProcess objLicenseProcess = new LicensesProcess(); return(objLicenseProcess.GetLicenses(objLicenseRequest)); }
async private void BtnLoginClicked(object sender, EventArgs e) { //0. Check if network available // if (Connectivity.NetworkAccess != NetworkAccess.Internet) { await DisplayAlert(AppResources.Warning, AppResources.NoNetwork, AppResources.OK); return; } await SetWaitStatus(true); // 1. Check license // LicenseService service = new LicenseService(ProgramVars.LicURL); LicenseRequest request = new LicenseRequest() { Method = "Validate", ClientID = App.appSettings.clientID, DeviceID = App.appSettings.deviceID, languageID = App.appSettings.languageID, ServerID = App.appSettings.serverID }; try { LicenseResult result = await service.ExecuteAsync(request); if (result.statusCode != 0) { App.appSettings.serverID = result.ServerID; await App.SaveAllPropertiesAsync(); throw new Exception(result.status); } // Check if license is about to expire // int nrDaysValid = result.ExpirationDate.Subtract(DateTime.Now).Days; if (nrDaysValid < 30) { await DisplayAlert(AppResources.Warning, $"License is about to expire in {nrDaysValid} days. Renew license !!!", AppResources.OK); } // App.appSettings.serverID = result.ServerID; App.appSettings.installationID = result.InstallationID; App.appSettings.isDemo = result.IsDemo; App.appSettings.serviceURL = result.URLs[0]; App.appSettings.imageURL = result.URLs[2]; ProgramVars.URL = App.appSettings.serviceURL; ProgramVars.ImageHandlerUrl = App.appSettings.imageURL; //await App.SaveAllPropertiesAsync(); await SetWaitStatus(false); } catch (Exception ex) { await SetWaitStatus(false); await DisplayAlert(AppResources.Error, ex.Message, AppResources.OK); //lbDemo.IsVisible = true; //lbDemo.Text = $"Error:{ex.Message}"; return; } // 2. Goto login page // await App.Current.MainPage.Navigation.PushAsync(new LoginPage(), true); }
public IHttpActionResult PostLicense([FromBody] LicenseRequest request) { logger.Debug("PostLicense(LicenseRequest) entered ..."); try { // Validate Company PIN format, if invalid return an error. if (request.CompanyPIN.Length != 8) { logger.InfoFormat("PIN is incorrect length : {0}, should be 8 characters", request.CompanyPIN.Length); return(Ok(new LicenseResponse() { Error = "PIN must be 8 digits", Result = (int)LicenceResultCode.PinIncorrectLength })); } // Attempt to find Company from the PIN. Company company = db.Companies.FirstOrDefault(c => c.Pin == request.CompanyPIN); // If not found return an error. if (company == null) { logger.InfoFormat("Failed to find Company with PIN : {0}", request.CompanyPIN); return(Ok(new LicenseResponse() { Error = "PIN is invalid", Result = (int)LicenceResultCode.PinNotFound })); } // Check if already listed as a device. MobileDevice device = db.MobileDevices.FirstOrDefault(d => d.SerialNo == request.SerialNo); // If the device exists return error showing already registered if (device != null) { logger.InfoFormat("Device with Serial # : {0} already registered", request.SerialNo); return(Ok(new LicenseResponse() { Error = "Device already registered", Result = (int)LicenceResultCode.DeviceAlreadyRegistered })); } // Create new device. device = new MobileDevice() { Company = company, SerialNo = request.SerialNo, Created = DateTime.Now, CompanyId = company.CompanyId, }; // Add to the collection of Mobile Devices ... device = db.MobileDevices.Add(device); db.SaveChanges(); logger.DebugFormat("New device with Id : {0} created", device.MobileDeviceId); // Send email ... int numberOfDevices = db.MobileDevices.Count(d => d.CompanyId == device.MobileDeviceId); MailUtilities.SendEmail(numberOfDevices, device, "licensed"); // Return configuration. return(Ok(new LicenseResponse() { Result = (int)LicenceResultCode.Success, DeviceNo = device.MobileDeviceId, Url = device.Company.ColossusMobileUrl, ConsignorName = device.Company.ConsignorName, ConsignorAdd1 = device.Company.ConsignorAdd1, ConsignorAdd2 = device.Company.ConsignorAdd2, ConsignorAdd3 = device.Company.ConsignorAdd3, Error = string.Empty })); } catch (Exception ex) { logger.Error("Error licensing device", ex); return(Ok(new LicenseResponse() { Result = (int)LicenceResultCode.Unknown, Error = "Unknown Error", Url = string.Empty })); } finally { logger.Debug("PostLicense(LicenseRequest) exited"); } }
public LicenseRequest GetLicenseRequest(byte[] result) { return(LicenseRequest.ParseFrom(result)); }
/// <summary> /// /// </summary> /// <param name="objLicenseRequest"></param> /// <returns></returns> public LicenseResponse GetLicenses(LicenseRequest objLicenseRequest) { var objLicenseResponse = new LicenseResponse(); //Start GetLicenses; if (objLicenseRequest != null) { #region DUMMY RESPONSE /* * objLicenseResponse.RequestID = objLicenseRequest.RequestID; * objLicenseResponse.ResponseID = objLicenseRequest.RequestID; * objLicenseResponse.ResponseDateTime = DateTime.UtcNow; * objLicenseResponse.ResponseStatus = (int)Constants.ResponseStatus.Success; * objLicenseResponse.ResponseMessage = Constants.ResponseStatus.Success.ToString(); * #region Creating Dummy Response * if (objLicenseRequest.UnitInfo.Length > 0) * { * UnitLicenseInfo[] UnitLicenseInfoList = new UnitLicenseInfo[objLicenseRequest.UnitInfo.Length]; * for (int i = 0; i < UnitLicenseInfoList.Length; i++) * { * UnitLicenseInfoList[i] = new UnitLicenseInfo(); * UnitLicenseInfoList[i].SNum = objLicenseRequest.UnitInfo[i].SNum; * UnitLicenseInfoList[i].LicensableSNum = "AAAA-BBBB-CCCC-DDDD-EEEE" + i.ToString(); * * SKUDetailInfo[] SKUInfoList = new SKUDetailInfo[req.UnitInfo[i].SKU.Length]; * for (int j = 0; j < SKUInfoList.Length; j++) * { * SKUInfoList[j] = new SKUDetailInfo(); * SKUInfoList[j].SKUID = objLicenseRequest.UnitInfo[i].SKU[j].SKUID; * SKUInfoList[j].SKUName = "Memory Card"; * SKUInfoList[j].TAAPartNo = "TAA" + SKUInfoList[j].SKUID; * SKUInfoList[j].TAAPartName = "TAANO" + SKUInfoList[j].SKUID; * SKUInfoList[j].Qty = 1; * SKUInfoList[j].OptionLicenseKey = ""; * SKUInfoList[j].SKUType = "SW"; * * VersionInfoWithLicense[] VersionInfoWithLicenseList = new VersionInfoWithLicense[2]; * for (int k = 0; k < VersionInfoWithLicenseList.Length; k++) * { * * VersionInfoWithLicenseList[k] = new VersionInfoWithLicense(); * VersionInfoWithLicenseList[k].VersionPartName = "sdfasf"; * VersionInfoWithLicenseList[k].VersionPartNo = "123"; * VersionInfoWithLicenseList[k].ImageUrl = "https://cisco.com/downloads"; * VersionInfoWithLicenseList[k].IsShippedVersion = (k == 0) ? true : false; * VersionInfoWithLicenseList[k].LicenseKey = "AAAA-BBBB-CCCC-DDDD-EEEE" + k.ToString(); * VersionInfoWithLicenseList[k].ReleaseDate = DateTime.Now.AddDays(-5).ToUniversalTime(); * VersionInfoWithLicenseList[k].Version = "LatestMajorRelease"; * VersionInfoWithLicenseList[k].VersionSeqNo = k + 1; * VersionInfoWithLicenseList[k].VersionType = "DOT MAJOR"; * * } * SKUInfoList[j].VersionList = VersionInfoWithLicenseList; * * } * UnitLicenseInfoList[i].SKU = SKUInfoList; * } * * * objLicenseResponse.UnitLicenseInfo = UnitLicenseInfoList; * * } * else * { * objLicenseResponse.ResponseStatus = (int)Constants.ResponseStatus.InvalidParameter; * objLicenseResponse.ResponseMessage = Constants.ResponseStatus.InvalidParameter.ToString(); * } #endregion */ #endregion try { //ASSIGNING ID'S objLicenseResponse.RequestID = objLicenseRequest.RequestID; objLicenseResponse.ResponseID = objLicenseRequest.RequestID; //Input Validation GetLicenses if (objLicensesBL.ValidateRequest(objLicenseRequest, objLicenseResponse)) { //PROCESS DATA & RETURN RESPONSE objLicensesBL.ProcessRequest(objLicenseRequest, objLicenseResponse); } } catch (Exception ex) { //SET FAILURE STATUS objLicenseResponse.ResponseStatus = (int)Constants.ResponseStatus.ServiceUnavailable; objLicenseResponse.ResponseMessage = Constants.ResponseMessage[1000].ToString(); //LOG EXCEPTION objEventLogger.WriteLog("GetLicenses:" + ex.Message + Environment.NewLine + ex.StackTrace, objLicenseRequest.RequestingSystem, DateTime.UtcNow, objLicenseRequest.RequestID); } finally { objLicenseResponse.ResponseDateTime = DateTime.UtcNow; //SERIALIZE REQUEST/RESPONSE string request = "GetLicensesRequest"; string response = "GetLicensesResponse"; try { request = Util.SerializeObject(objLicenseRequest); response = Util.SerializeObject(objLicenseResponse); } catch (Exception ex) { objEventLogger.WriteLog("GetLicenses:Request/Response Object Serialization Error: " + ex.Message + Environment.NewLine + ex.StackTrace, objLicenseRequest.RequestingSystem, DateTime.UtcNow, objLicenseRequest.RequestID); } if (!request.IsValidString()) { request = "GetLicensesRequest"; } if (!response.IsValidString()) { response = "GetLicensesResponse"; } //LOG REQUEST/RESPONSE objTransactionLogger.LogTransaction(objLicenseRequest.RequestID, objLicenseRequest.RequestDateTime, objLicenseRequest.RequestingSystem, request, objLicenseResponse.ResponseID, objLicenseResponse.ResponseDateTime, response, objLicenseResponse.ResponseStatus, objLicenseResponse.ResponseMessage, 0); //End Processing GetLicenses } } //GetLicenses ends return(objLicenseResponse); }