public IEnumerator CreateLink(string nodeA_id, string nodeB_id, int nodeA_portNumber, int nodeB_portNumber, int nodeA_adapter, int nodeB_adapter) { var input = new LinkInput(nodeA_id, nodeB_id, nodeA_portNumber, nodeB_portNumber, nodeA_adapter, nodeB_adapter); string postData = JsonUtility.ToJson(input); byte[] bodyRaw = Encoding.UTF8.GetBytes(postData); var request = new UnityWebRequest(url + "/links", "POST"); request.uploadHandler = (UploadHandler) new UploadHandlerRaw(bodyRaw); request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debug.Log(request.downloadHandler.text); yield break; } // TODO instantiate some kind of link object // GameObject switch_ = Instantiate(switchPrefab, transform.position + transform.forward, Quaternion.identity); Link link = Link.CreateFromJSON(request.downloadHandler.text); links.Add(link); Debug.Log("Successfully created link with id " + link.link_id + " connecting nodes " + link.nodes[0].node_id + " and " + link.nodes[1].node_id); }
public UrlJsonResult ShortenLink(string url) { var link = new LinkInput() { LongURL = url, ClientPlatform = ClientPlatform.Webservice, ClientIP = _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString() }; return(_linkService.ShortenLink(link)); }
protected override void beforeEach() { theInput = new LinkInput { BottleFolder = "package", AppFolder = "app", }; appManifest = new LinkManifest(); btlManifest = new LinkManifest(); }
protected override void beforeEach() { theInput = new LinkInput { PackageFolder = "package", AppFolder = "app", }; appManifest = new ApplicationManifest(); pakManifest = new PackageManifest(); Services.PartialMockTheClassUnderTest(); }
public IActionResult ShortenLink(string url) { var link = new LinkInput() { LongURL = url, ClientPlatform = ClientPlatform.Website, ClientIP = _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString() }; var result = _linkService.ShortenLink(link); string baseUrl = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}/r/"; return PartialView("_ShortenLinkResult", baseUrl + result.Url); }
public UrlJsonResult ShortenLink(LinkInput link) { #region validation if (string.IsNullOrEmpty(link.LongURL)) { return(new UrlJsonResult() { Result = false, Message = Resource.Messages.RequiredField, Url = string.Empty }); } #endregion string longUrl = NormalizeUrl(link.LongURL); #region if exists in db var existLink = _links.FirstOrDefault(x => x.LongURL == longUrl && x.Deleted != true); if (existLink != null) { existLink.SubmitCount++; _uow.MarkAsChanged(existLink); _uow.SaveAllChanges(); return(new UrlJsonResult() { Result = true, Message = Resource.Messages.Successful, Url = existLink.ShortURL }); } #endregion #region shorten url var insertedLink = _links.Add(new Link() { FirstClientIP = link.ClientIP, FirstClientPlatform = link.ClientPlatform, LongURL = longUrl, SubmitCount = 1, CreateDate = DateTime.Now, Deleted = false }); _uow.SaveAllChanges(); string shortedUrl = Encode(insertedLink.Entity.Id); insertedLink.Entity.ShortURL = shortedUrl; _uow.MarkAsChanged(insertedLink.Entity); _uow.SaveAllChanges(); return(new UrlJsonResult() { Result = true, Message = Resource.Messages.Successful, Url = shortedUrl }); #endregion }
public RemoteLink AddRemoteLink(LinkInput input) { var link = _remotes.FirstOrDefault(x => x.Folder.EqualsIgnoreCase(input.BottleFolder)); if (link == null) { link = new RemoteLink { Folder = input.RelativePathOfPackage() }; _remotes.Add(link); } link.BootstrapperName = input.BootstrapperFlag; link.ConfigFile = input.ConfigFileFlag; return(link); }
public IActionResult r(string shortUrl) { var link = new LinkInput() { ShortURL = shortUrl, ClientIP = _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(), ClientPlatform = ClientPlatform.Website }; UrlJsonResult resolveResult = _linkService.ResolveLink(link); if (resolveResult.Result) { return Redirect(resolveResult.Url); } else return RedirectToAction("UrlNotFound"); }
public UrlJsonResult ResolveLink(LinkInput link) { var existLink = _links.FirstOrDefault(x => x.ShortURL == link.ShortURL && x.Deleted != true); if (existLink != null) { existLink.RequestCount++; _uow.MarkAsChanged(existLink); _uow.SaveAllChanges(); return(new UrlJsonResult() { Result = true, Message = Messages.Successful, Url = existLink.LongURL }); } else { return(new UrlJsonResult() { Result = false, Message = Messages.NotFound, Url = string.Empty });; } }
void Update() { Gate gate = ClickGate(); if (enable) { if (gate == null) { window.SetActive(false); } else { if (gate != selectedGate) { selectedGate = gate; ClearLinks(); FillLinks(); } DrawLabels(); if (Input.GetAxis("Mouse ScrollWheel") != 0) { ScrollLabels(); } if (Input.GetMouseButtonDown(0)) { if (!connectOutput) { if (inputs.Count > 0) { inp = selectedGate.Inputs[inputs[selectedInput].GetComponent<IOLabel>().GetLabel()]; inp.Disconnect(); connectOutput = true; showInputs = false; currentWire = Instantiate(wireFab) as GameObject; currentWire.transform.position = selectedGate.transform.position; currentWire.transform.parent = selectedGate.transform; ChipWire w = currentWire.GetComponent<ChipWire>(); w.ownerChipGUID = selectedGate.guid; w.AddPoint(lastClickPos); Debug.Log(inputs[selectedInput].GetComponent<IOLabel>().GetLabel()); w.connectedInput = inputs[selectedInput].GetComponent<IOLabel>().GetLabel(); pointNum++; inp.wire = currentWire; } } else { if (outputs.Count > 0) { output = selectedGate.Outputs[outputs[selectedOutput].GetComponent<IOLabel>().GetLabel()]; connectOutput = false; showInputs = true; currentWire.GetComponent<ChipWire>().AddPoint(lastClickPos); LinkInput(); pointNum = 0; } } } if (Input.GetKeyDown("r")) { if (showInputs) { if (inputs.Count > 0) { LinkInput inpt = selectedGate.Inputs[inputs[selectedInput].GetComponent<IOLabel>().GetLabel()]; inpt.Disconnect(); } } else { connectOutput = false; showInputs = true; pointNum = 0; Destroy(currentWire); inp = null; } } if (Input.GetMouseButtonDown(1)) { GameState.Instance.SetCircuitEditSubstate(GameState.CircuitEditSubstate.EditOptions); optsWindow.gameObject.SetActive(true); optsWindow.LoadParameters(gate); } } if (Input.GetMouseButtonDown(0)) { Vector3 pos = ClickPos(); if ((connectOutput) && (pos != Vector3.zero)) { // pos.y += 0.015f; currentWire.GetComponent<ChipWire>().AddPoint(pos); pointNum++; } } if (Input.GetKeyDown("r")) { if (connectOutput) { connectOutput = false; showInputs = true; pointNum = 0; Destroy(currentWire); inp = null; } } } }