public void GetStuck(GameObject tongue) { m_collider.enabled = false; m_rigidbody.useGravity = false; m_tongue = tongue; m_state = BugState.Stuck; }
private Bug MoveBug(int id, BugState bugState) { var bug = _bugsRepository.GetBugById(id); bug.State = bugState; _hub.Clients.All.moved(bug); return bug; }
public static BugState[] GetExept(BugState state) { List <BugState> l = GetStates.ToList(); l.Remove(state); return(l.ToArray()); }
/// <summary> /// Renders a bug. /// </summary> /// <param name="state"><see cref="BugState"/> for additional information</param> /// <param name="pickray">current PickRay</param> /// <param name="selected">true, if bug is selected</param> /// <returns>distance from viewer to item, if <see cref="Pickray"/> hits</returns> public float RenderBug(BugState state, Pickray pickray, bool selected) { Matrix matrix = Matrix.Identity; matrix.RotateY((float)(state.Direction * Math.PI) / 180); matrix.M41 = (state.PositionX) - playgroundWidth; matrix.M43 = (-state.PositionY) + playgroundHeight; renderDevice.Material = (selected ? selectionMaterial : bugMaterial); renderDevice.Transform.World = matrix; bugMesh.DrawSubset(0); // Check for pickray-collision matrix.Invert(); pickray.Origin.TransformCoordinate(matrix); pickray.Direction.TransformNormal(matrix); if (collisionBox.Intersect(pickray.Origin, pickray.Direction)) { return (Vector3.Subtract ( pickray.Origin, new Vector3((state.PositionX) - playgroundWidth, 0, (-state.PositionY) + playgroundHeight)). Length()); } return(0.0f); }
void Land() { currentState = BugState.Landed; timeToWait = Random.Range(3f, 20f); transform.position = targetLand.position; transform.localRotation = targetLand.localRotation; transform.parent = targetLand; }
public float DrawBug(BugState state, Pickray pickray, bool selected) { Matrix matrix = Matrix.CreateRotationY((float)(state.Direction * Math.PI) / 180); matrix.M41 = (state.PositionX) - playgroundWidth; matrix.M43 = (-state.PositionY) + playgroundHeight; foreach (var mesh in bug.Meshes) { foreach (BasicEffect eff in mesh.Effects) { eff.World = matrix; eff.View = camera.ViewMatrix; eff.Projection = camera.ProjectionMatrix; if (mesh.Name == "Sphere02" || mesh.Name == "Sphere03") { eff.LightingEnabled = false; // change the bugs eye color depending on its vitality eff.EmissiveColor = Vector3.Lerp(new Vector3(1, 0, 0), new Vector3(0f, 0.6f, 1f), state.Vitality / 1000f); } else if (mesh.Name == "Sphere01") { eff.LightingEnabled = true; eff.DiffuseColor = new Vector3(0.1f, 0.1f, 0.1f); eff.EmissiveColor = new Vector3(0f, 0f, 0f); eff.PreferPerPixelLighting = true; eff.DirectionalLight0.Enabled = true; eff.DirectionalLight0.Direction = LIGHT_0_DIRECTION; eff.DirectionalLight0.DiffuseColor = new Vector3(1, 1, 1); eff.DirectionalLight0.SpecularColor = new Vector3(0.6f, 1f, 1f);//new Vector3(0.7f, 0.3f, 0f);// eff.DirectionalLight1.Enabled = false; eff.DirectionalLight2.Enabled = false; } else { eff.LightingEnabled = false; } } mesh.Draw(); } BoundingSphere sphere = getBoundingSphere(bug, matrix); float?distance = sphere.Intersects(new Ray(pickray.Origin, pickray.Direction)); if (distance != null) { return(distance.Value); } return(0.0f); }
public IEnumerator Idle() { anim.SetBool("isIdle", true); anim.SetBool("isWander", false); state = BugState.Idle; yield return(new WaitForSeconds(3f)); StartCoroutine(Wander()); }
public void Drop() { m_collider.enabled = true; m_rigidbody.useGravity = true; m_tongue = null; m_state = BugState.Idle; m_timeInState = 0; Launch(); }
/// <summary> /// Erzeugt ein BugState-Objekt mit dem aktuellen Daten der Wanzen. /// </summary> /// <returns></returns> internal BugState ErzeugeInfo() { BugState info = new BugState((ushort)id); info.PositionX = (ushort)(CoordinateBase.X / SimulationEnvironment.PLAYGROUND_UNIT); info.PositionY = (ushort)(CoordinateBase.Y / SimulationEnvironment.PLAYGROUND_UNIT); info.Direction = (ushort)CoordinateBase.Richtung; info.Vitality = (ushort)AktuelleEnergieBase; return(info); }
// Use this for initialization void Start() { animator = GetComponentInChildren <Animator>(); m_collider = GetComponent <Collider> (); m_rigidbody = GetComponent <Rigidbody> (); m_state = BugState.Idle; m_timeInState = 0; StartBug(); }
public IEnumerator Wander() { anim.SetBool("isIdle", false); anim.SetBool("isWander", true); state = BugState.Wander; wanderTarget = (Vector2)transform.position + Random.insideUnitCircle * wanderRange; yield return(new WaitForSeconds(2f)); StartCoroutine(Idle()); }
public void ThenTheAndReturnedShouldBeAsExpected(string exp_lat, string exp_lng) { var root = JsonConvert.DeserializeObject <GoogleAPI.RootObject>(response); var location = root.results[0].geometry.location; var latitude = location.lat; var longitude = location.lng; string featureName = FeatureContext.Current.FeatureInfo.Title; string scenarioname = ScenarioContext.Current.ScenarioInfo.Title; bugsummary = "Google api test does not give correct result"; string featureFilePath = featurePath.GetFeatureFileAPIPath(featureName); timestamp = GetTimestamp(DateTime.Now); List <string> Text = File.ReadAllLines(featureFilePath).ToList(); int index = Text.FindIndex(x => x.Contains(scenarioname)); index = index - 1; string latestexecuttext = ""; try { Console.WriteLine("inside try"); Assert.AreEqual(location.lat.ToString(), exp_lat); Assert.AreEqual(location.lng.ToString(), exp_lng); latestexecuttext = "#Last Execution Passed on: " + timestamp; } catch (Exception ex) { bugcreateflag = true; latestexecuttext = "#Last Execution Failed on: " + timestamp; exceptiontext = ex.ToString(); throw ex; } finally { if (bugcreateflag) { bugstate.nobugcreated = false; bugstate.bugcreateflag = true; bugstate = bug.create(bugsummary, exceptiontext, bugstate); key.getJiraTicketId(featureFilePath, bugsummary, scenarioname, bugstate); } else { Console.WriteLine("Bug Closed and Test case passed Upali"); bugstate = bugstatus.check(featureFilePath, bugsummary, scenarioname, bugstate); } comment.addComment(bugsummary, latestexecuttext); ts.update(featureFilePath, bugsummary, scenarioname, latestexecuttext, bugcreateflag, bugstate); } }
protected EyeInfo NextTarget(BugState state, float seightDistance) { switch (state) { case BugState.Normal: return(LookFor(GeneratorController.NormalLayerMask, seightDistance)); case BugState.Horny: return(LookFor(GeneratorController.HornyLayerMask, seightDistance)); } return(new EyeInfo()); }
/// <summary> /// Erzeugt eine BugInfoBox-Instanz. /// </summary> /// <param name="bugState">Die Wanze.</param> public BugInfoBox(BugState bugState) { // Setze Größe und Randabstand. Width = 150; Height = 63; Margin = new Padding(0); // Erzeuge die Hintergrund-Grafik und hole ihre Zeichenfläche. bitmap = new Bitmap(Width, Height); graphics = Graphics.FromImage(bitmap); bug = bugState; name = string.Format(Resource.BugName, NameHelper.GetMaleName(bugState.Id)); }
public void RegisterState(BugToken token, BugState[] fromStates, BugState toState, Action @event) { mTokenValidation.Add(token, fromStates); mTokenActions.Add(token, delegate { if (mTokenValidation[mCurrentToken].Contains(CurrentState)) { CurrentState = toState; @event?.Invoke(); } else { throw new Exception(String.Format("Invalid Change from {0} to {1} with {2}", CurrentState, toState, token)); } }); }
void GetNewFlightPath() { int rand = Random.Range(0, 10); if (rand < 3) { currentState = BugState.Landing; targetLand = BugFlightManager.Instance.GetLandSpot(); return; } else { targetFlightSpot = flightCenter.position + Random.insideUnitSphere * .2f; } transform.parent = null; }
void Update() { Vector3 dir; switch (currentState) { case BugState.Landed: timeToWait -= Time.deltaTime; if (timeToWait < 0) { currentState = BugState.Flying; GetNewFlightPath(); } break; case BugState.Flying: dir = targetFlightSpot - transform.position; if (dir.magnitude < .01) { GetNewFlightPath(); } else { transform.position += dir.normalized * Time.deltaTime * .025f + Random.insideUnitSphere * .0005f; transform.LookAt(dir); } break; case BugState.Landing: if (targetLand == null) { GetNewFlightPath(); return; } dir = targetLand.position - transform.position; if (dir.magnitude < .01) { Land(); } else { transform.position += dir.normalized * Time.deltaTime * .025f + Random.insideUnitSphere * .0005f; transform.LookAt(dir); } break; } }
private void DoIdle() { float v = Random.value; // done idle if (m_timeInState > 1.0f && v < .05f) { m_timeInState = 0; m_state = BugState.Moving; animator.SetFloat("Speed", 1.0f); // get new dest Vector3 destOffset = new Vector3(Random.Range(-1.0f, 1.0f), 0, Random.Range(-1.0f, 1.0f)); destOffset.Normalize(); destOffset *= moveDist + Random.Range(-.5f, .5f) * moveDist; m_destination = transform.position + destOffset; } }
public IEnumerator Run(Vector2 runFromPoint) { StopAllCoroutines(); anim.SetBool("isRun", true); state = BugState.Run; Vector2 runVector = runFromPoint - (Vector2)transform.position; runVector = runVector * -1f; rigid.AddForce(runVector.normalized * runForce, ForceMode2D.Impulse); Debug.DrawRay(transform.position, runVector); // should be inverse of vector to player. yield return(new WaitForSeconds(4f)); StartCoroutine(Wander()); }
private void DoMove() { Vector3 d = m_destination - transform.position; d.y = 0; float s = moveSpeed * Time.deltaTime; //reached destination if (d.magnitude < s * 1.05f) { m_timeInState = 0; animator.SetFloat("Speed", 0); m_state = BugState.Idle; return; } d.Normalize(); transform.position += d * s; transform.rotation = Quaternion.LookRotation(d); }
public BugState check(string featurpath, string bugsummary, string scenarioName, BugState bg) { string state = ""; string issuetype = ""; string closedtktID = null; string closedtktkey = null; bg.bugclosed = false; bg.bugexists = false; bg.bugopen = false; bool closedflag = false; List <string> Text = null; string keyToInsert = ""; string trimmedText = ""; string timestamp; timestamp = DateTime.Now.ToString("dd-MM-yyyy, HH:mm"); HttpClient client2 = new HttpClient(); string issueurl = ("https://spiderlogic.jira.com/rest/api/2/search?jql=project=SFLOW&fields=issues&fields=summary&fields=description&fields=status&fields=project&fields=issuetype"); var credentials = Encoding.ASCII.GetBytes("[email protected]:spiderqa"); client2.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials)); Uri uri = new Uri(issueurl.ToString()); string ApiResponse = client2.GetStringAsync(uri).Result; var root = JsonConvert.DeserializeObject <RootObject>(ApiResponse); var Sumry = root.issues.Count; //Checking if the Bug already exists by iterating though the issue list in jira var issues = root.issues; Console.WriteLine("bg.closed: " + bg.closedflag); Console.WriteLine("closedflag : " + closedflag); Console.WriteLine("bg.open : " + bg.bugopen); foreach (var issue in issues) { var fields = issue.fields; var summary = (fields.summary).ToString(); state = (fields.status.name).ToString(); issuetype = (fields.issuetype.name).ToString(); if ((issuetype == "Bug") && summary.Equals(bugsummary) && (state == "Open")) { //control may never come to this block if (bg.bugclosed) { Console.WriteLine("Bazooka : In BugStatus BUG CLOSED AND REOPENED"); bg.openedafterclosedflag = true; bg.reopentktkey = issue.key; bg.openedafterclosedflag = true; continue; } else { Console.WriteLine("In BugStatus : Bug exists"); bg.bugexists = true; bg.newopentktkey = issue.key; Console.WriteLine("Ticket Key: " + issue.key); bg.bugopen = true; } } else if ((issuetype == "Bug") && summary.Equals(bugsummary) && (state == "Closed")) { Console.WriteLine("In BugStatus: Bug exists bug closed "); Console.WriteLine("In Bug Status:This is the most important step "); closedflag = true; bg.closedflag = true; bg.bugexists = false; closedtktID = issue.id; closedtktkey = issue.key; bg.closedtkyKey = issue.key; bg.bugclosed = true; bg.nobugcreated = true; bg.bugclosedcount = bg.bugclosedcount + 1; bg.buglist.Add(closedtktkey); } } Console.WriteLine("closedflag: " + closedflag); Console.WriteLine("bg.closedflag: " + bg.closedflag); Console.WriteLine("closedtktkey: " + closedtktkey); Console.WriteLine("bg.bugopen: " + bg.bugopen); Console.WriteLine("bg.newopentktkey: " + bg.newopentktkey); //Get the creation/closed date of the bug FetchBugCreationResolutionDate bc = new FetchBugCreationResolutionDate(); //Writing into the Feature file if (bg.openedafterclosedflag) { Console.WriteLine("Bazooka : In BugStatus if openedafterclosed writing intofeature"); bg = bc.fetchBugCreatedClosedDate(bg); Text = File.ReadAllLines(featurpath).ToList(); keyToInsert = "#" + bg.reopentktkey + " Opened on: " + bg.bugcreationdate; trimmedText = keyToInsert.Remove(10); Console.WriteLine("trimmedText: " + trimmedText); if (Text.Contains(keyToInsert)) { Console.WriteLine("Key already exists"); } else { Console.WriteLine("Key does not exist and will write into the feature file"); int length = scenarioName.Length; int index = Text.FindIndex(x => x.Contains(scenarioName)); index = index + 1; string a = Text[index]; Console.WriteLine("a contains: " + a); Console.WriteLine("trimmedtext contains: " + trimmedText); Console.WriteLine("index +1: " + index); Text.RemoveAt(index); Text.Insert(index, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } if (bg.bugopen) { Console.WriteLine("Bazooka : In BugStatus if bug already exists writing intofeature"); Text = File.ReadAllLines(featurpath).ToList(); bg = bc.fetchBugCreatedClosedDate(bg); keyToInsert = "#" + bg.newopentktkey + " Opened on: " + bg.bugcreationdate; Console.WriteLine("Text: " + Text); Console.WriteLine("keyToInsert: " + keyToInsert); trimmedText = keyToInsert.Remove(7); Console.WriteLine("trimmedText: " + trimmedText); if (Text.Contains(keyToInsert)) { Console.WriteLine("Key already exists"); } else { int length = scenarioName.Length; int index = Text.FindIndex(x => x.Contains(scenarioName)); index = index + 1; string a = Text[index]; if (a.Contains(trimmedText)) { Text.Remove(a); Text.Insert(index, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } else { Text.Insert(index, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } } if (closedflag) { Console.WriteLine("In Bugstatus: if closedflag writing intofeature"); Console.WriteLine("Upali bugclosed: " + bg.bugclosedcount); string newclosedkey = bg.buglist[bg.bugclosedcount - 1]; bg.closedtkyKey = newclosedkey; Console.WriteLine("bg.closedtkyKey" + bg.closedtkyKey); Text = File.ReadAllLines(featurpath).ToList(); bg = bc.fetchBugCreatedClosedDate(bg); keyToInsert = "#" + newclosedkey + " Closed on: " + bg.bugcloseddate; Console.WriteLine(" keyToInsert" + keyToInsert); trimmedText = keyToInsert.Remove(7); int length = scenarioName.Length; int index = Text.FindIndex(x => x.Contains(scenarioName)); int newindex = index + 1; string a = Text[newindex]; Console.WriteLine("a contains: " + a); Console.WriteLine("trimmedText contains: " + trimmedText); Console.WriteLine("bg.nobugcreated" + bg.nobugcreated); if (a.Contains(trimmedText)) { if (bg.bugclosedcount == 0) { Console.WriteLine("Do Nothing"); } else if ((bg.bugclosedcount >= 1)) { if (bg.nobugcreated) { if (a.Contains("Opened")) { Console.WriteLine("Inside Opened"); if (a.Contains(bg.newopentktkey)) { Console.WriteLine("inside a contains bg.newopenkey"); int closeindex = newindex + 1; Console.WriteLine("newindex: " + newindex); Console.WriteLine("closeindex: " + closeindex); // Text.RemoveAt(closeindex); Text.Insert(closeindex, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } else { Console.WriteLine("Inside nobugcreated and if a contains Opened, else newopentktkey"); // when there are only closed keys 2nd may string updatedclosedkey = bg.buglist[0]; bg.closedtkyKey = updatedclosedkey; bg = bc.fetchBugCreatedClosedDate(bg); keyToInsert = "#" + updatedclosedkey + " Closed on: " + bg.bugcloseddate; Console.WriteLine("Key to insert: " + keyToInsert); // Text.Remove(a); Text.RemoveAt(newindex); Text.Insert(newindex, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } else { Console.WriteLine("Inside nobugcreated and else a contains Opened"); // when there are only closed keys 2nd may string updatedclosedkey = bg.buglist[0]; bg.closedtkyKey = updatedclosedkey; bg = bc.fetchBugCreatedClosedDate(bg); keyToInsert = "#" + updatedclosedkey + " Closed on: " + bg.bugcloseddate; Console.WriteLine("Key to insert: " + keyToInsert); // Text.Remove(a); Text.RemoveAt(newindex); Text.Insert(newindex, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } else { Console.WriteLine("old closed bug :" + bg.buglist[1]); Console.WriteLine("inside if a.contains(trimmedtext) and if bugcount > 1"); Text.Insert(index, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } else { Console.WriteLine("inside else bugcount >1"); if (a.Contains(bg.buglist[0])) { Console.WriteLine("in if a.contains closed bug"); Text.Remove(a); Text.Insert(index, keyToInsert); } else { Console.WriteLine("in else a.contains closed bug"); Text.Insert(index, keyToInsert); } System.IO.File.WriteAllLines(featurpath, Text); } } else { Console.WriteLine("inside else a.contains(trimmedtext)"); Console.WriteLine("index : " + index); Console.WriteLine("newindex : " + newindex); Text.Insert(newindex, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } return(bg); }
/// <summary> /// Set Bug as dead and stops all movements. /// </summary> public void KillBug() { if (IsDead) { return; } m_Rigidbody.velocity = Vector3.zero; m_State = BugState.Dead; IsDead = true; AudioSource audioSource = gameObject.GetComponent<AudioSource>(); audioSource.Play(); GetComponent<Animator>().SetBool("IsDead",true); }
void OnCollisionExit(Collision coll) { if (coll.gameObject.layer == m_EnvironmentLayer) { m_State = BugState.MidAir; } if (coll.gameObject.layer == m_FoodLayer) { if (m_Behaviour == BugBehaviour.Gathering) { m_Behaviour = BugBehaviour.Searching; } } }
void OnCollisionEnter(Collision coll) { if (coll.gameObject.layer == m_EnvironmentLayer) { m_State = BugState.OnGround; } if (coll.gameObject.layer == m_FoodLayer) { Food food = coll.gameObject.GetComponent<Food>(); if (food.HP > 0) { food.Eat(FoodHPPerByte.value); DropPheromone(Pheromone.PheromoneType.Food, coll.gameObject.transform.position); } } }
void Start() { currentState = BugState.Landed; timeToWait = 3f; }
public BugState fetchBugCreatedClosedDate(BugState bg) { string tkyKey = null; //Get the created and closed datetime of the issue using jira changelog api if (bg.openedafterclosedflag) { tkyKey = bg.reopentktkey; Console.WriteLine("rasika reopen:" + tkyKey); HttpClient client3 = new HttpClient(); string issueurl_datetime = ("https://spiderlogic.jira.com/rest/api/2/issue/" + tkyKey + "?expand=changelog"); var credentials1 = Encoding.ASCII.GetBytes("[email protected]:spiderqa"); client3.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials1)); Uri uri_datetime = new Uri(issueurl_datetime.ToString()); string ApiResponse_datetime = client3.GetStringAsync(uri_datetime).Result; var root_changelog = JsonConvert.DeserializeObject <RootObject2>(ApiResponse_datetime); var issueCreatedtimestamp = root_changelog.fields2.created; bg.bugcreationdate = issueCreatedtimestamp; } if (bg.bugopen) { { tkyKey = bg.newopentktkey; Console.WriteLine("rasika new open:" + tkyKey); HttpClient client3 = new HttpClient(); string issueurl_datetime = ("https://spiderlogic.jira.com/rest/api/2/issue/" + tkyKey + "?expand=changelog"); var credentials1 = Encoding.ASCII.GetBytes("[email protected]:spiderqa"); client3.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials1)); Uri uri_datetime = new Uri(issueurl_datetime.ToString()); string ApiResponse_datetime = client3.GetStringAsync(uri_datetime).Result; var root_changelog = JsonConvert.DeserializeObject <RootObject2>(ApiResponse_datetime); var issueCreatedtimestamp = root_changelog.fields2.created; bg.bugcreationdate = issueCreatedtimestamp; } } if (bg.closedflag) { tkyKey = bg.closedtkyKey; Console.WriteLine("rasika fetchBugCreatedClosedDate closed:" + tkyKey); HttpClient client3 = new HttpClient(); string issueurl_datetime = ("https://spiderlogic.jira.com/rest/api/2/issue/" + tkyKey + "?expand=changelog"); var credentials1 = Encoding.ASCII.GetBytes("[email protected]:spiderqa"); client3.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials1)); Uri uri_datetime = new Uri(issueurl_datetime.ToString()); string ApiResponse_datetime = client3.GetStringAsync(uri_datetime).Result; var root_changelog = JsonConvert.DeserializeObject <RootObject2>(ApiResponse_datetime); var issueClosedtimestamp = root_changelog.fields2.resolutiondate; bg.bugcloseddate = issueClosedtimestamp; } else { tkyKey = bg.newopentktkey; Console.WriteLine("rasika new open:" + tkyKey); HttpClient client3 = new HttpClient(); string issueurl_datetime = ("https://spiderlogic.jira.com/rest/api/2/issue/" + tkyKey + "?expand=changelog"); var credentials1 = Encoding.ASCII.GetBytes("[email protected]:spiderqa"); client3.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials1)); Uri uri_datetime = new Uri(issueurl_datetime.ToString()); string ApiResponse_datetime = client3.GetStringAsync(uri_datetime).Result; var root_changelog = JsonConvert.DeserializeObject <RootObject2>(ApiResponse_datetime); var issueCreatedtimestamp = root_changelog.fields2.created; bg.bugcreationdate = issueCreatedtimestamp; } return(bg); }
public void update(string featurpath, string bugSummary, string scenarioName, string lastex, bool bugcreateflag, BugState bg) { List <string> Text = File.ReadAllLines(featurpath).ToList(); Console.WriteLine("Now Begins JIRA TIME STAMP"); int length = scenarioName.Length; int index = Text.FindIndex(x => x.Contains(scenarioName)); Console.WriteLine("firstindex: " + index); index = index + 2; Console.WriteLine("index + 2: " + index); Console.WriteLine("Then Text at index + 2 :" + Text[index]); string a = Text[index]; Console.WriteLine("a: " + a + " index: " + index); if (a.Contains("#SFLOW")) { Console.WriteLine("now inside #SFLOW :" + index); Console.WriteLine("bugclosed :" + bg.bugclosed); Console.WriteLine("bugexists :" + bg.bugexists); Console.WriteLine("bugopen :" + bg.bugopen); Console.WriteLine("nobugcreated :" + bg.nobugcreated); Console.WriteLine("reopentktkey :" + bg.reopentktkey); Console.WriteLine("newopentktkey :" + bg.newopentktkey); Console.WriteLine("openedafterclosedflag :" + bg.openedafterclosedflag); Console.WriteLine("bugclosedcount :" + bg.bugclosedcount); int newindex = index + 1; Console.WriteLine("new index: " + newindex); string b = Text[newindex]; Console.WriteLine("b contains: " + b); if (bg.bugclosedcount > 1) { if (bg.nobugcreated) { Console.WriteLine("Inside no bug is created"); Console.WriteLine("JIra timestamp, under if sflow, if bugcount > 1, if nobugcreated"); //april 27 int indexofscenarioname = index - 2; //open and closed tickets are there and the test case passes/fails if ((bg.bugexists) || (bg.openedafterclosedflag || bg.bugopen)) { int passfailindex = indexofscenarioname + 1 + bg.bugclosedcount + 1; Console.WriteLine("indexofscenarioname :" + indexofscenarioname); Console.WriteLine("bugcount :" + bg.bugclosedcount); Console.WriteLine("passfailindex :" + passfailindex); Console.WriteLine("Text at passfailindex : " + Text[passfailindex]); Console.WriteLine("Text at: " + newindex + "is" + b); Text.RemoveAt(passfailindex); Text.Insert((passfailindex), lastex); } //only closed tickets are there and the test case passes/fails else { int passfailindex = indexofscenarioname + 0 + bg.bugclosedcount + 1; Console.WriteLine("indexofscenarioname :" + indexofscenarioname); Console.WriteLine("bugcount :" + bg.bugclosedcount); Console.WriteLine("passfailindex :" + passfailindex); Console.WriteLine("Text at passfailindex : " + Text[passfailindex]); Console.WriteLine("Text at: " + newindex + "is" + b); Text.RemoveAt(passfailindex); Text.Insert((passfailindex), lastex); } } else { Console.WriteLine("old closed bug :" + bg.buglist[1]); if (b.Contains(bg.reopentktkey)) { Console.WriteLine("newindex +1 : " + (newindex + 1)); Console.WriteLine("lastex : " + lastex); Console.WriteLine("JIra timestamp, under if sflow, if bugcount >1, if b.contains reopenkey"); Text.Insert((newindex + 1), lastex); } else { Console.WriteLine("Inside ELSE no bug is created"); int indexofscenarioname = index - 2; int passfailindex = indexofscenarioname + 1 + bg.bugclosedcount + 1; Console.WriteLine("indexofscenarioname :" + indexofscenarioname); Console.WriteLine("bugcount :" + bg.bugclosedcount); Console.WriteLine("passfailindex :" + passfailindex); Console.WriteLine("Text at passfailindex : " + Text[passfailindex]); Console.WriteLine("Text at: " + newindex + "is" + b); Text.RemoveAt(passfailindex); Text.Insert((passfailindex), lastex); } } } else { if (b.Contains("Given")) { Console.WriteLine("JIra timestamp, under if sflow, else bugcount > 1 and b contains Closed"); Console.WriteLine("Text at: " + newindex + "is" + b); //may 11 // Text.RemoveAt(newindex); Text.Insert((newindex), lastex); } else { Console.WriteLine("JIra timestamp, under if sflow, else bugcount > 1"); Console.WriteLine("Text at: " + newindex + "is" + b); Text.RemoveAt(newindex); Text.Insert((newindex), lastex); } } } else if (a.Contains("Given")) { int newindex = index - 1; string b = Text[newindex]; Console.WriteLine("b contains: " + b); if (b.Contains("Passed")) { Text.RemoveAt(newindex); Text.Insert(newindex, lastex); } else { Console.WriteLine("bugcreateflag :" + bugcreateflag); Console.WriteLine("now inside given :" + index); Text.Insert(index, lastex); } } else if (a.Contains("When")) { Console.WriteLine("now inside else if:" + index); Text.Insert((index - 1), lastex); } else { Console.WriteLine("now inside else:" + index); Text.RemoveAt(index); Text.Insert(index, lastex); } System.IO.File.WriteAllLines(featurpath, Text); }
public static void Assign(BugState state, IStateMachine<BugState> stateMachine, dynamic args) { args.StatefulObject.AssigneeEmail = args.AssigneeEmail; }
public static void Resolve(BugState state, IStateMachine<BugState> stateMachine, dynamic args) { args.StatefulObject.AssigneeEmail = String.Empty; }
public static void Close(BugState state, IStateMachine<BugState> stateMachine, dynamic args) { args.StatefulObject.ClosedByName = args.ClosedByName; }
public static void Assign(BugState state, IStateMachine <BugState> stateMachine, dynamic args) { args.StatefulObject.AssigneeEmail = args.AssigneeEmail; }
public static void Close(BugState state, IStateMachine <BugState> stateMachine, dynamic args) { args.StatefulObject.ClosedByName = args.ClosedByName; }
public static void Resolve(BugState state, IStateMachine <BugState> stateMachine, dynamic args) { args.StatefulObject.AssigneeEmail = String.Empty; }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); GraphicsDevice.DepthStencilState = DepthStencilState.Default; SimulationState state = CurrentState; if (state == null) { return; } DrawSky(); effect.CurrentTechnique.Passes[0].Apply(); effect.Projection = camera.ProjectionMatrix; effect.View = camera.ViewMatrix; DrawPlayground(); Selection selectedItem = new Selection(); Pickray pickray = camera.Pickray; Point mousePosition = camera.MousePosition; // Selektionsinfos zurücksetzen selectedItem.SelectionType = SelectionType.Nothing; selectedItem.Item = null; float distanceToSelectedItem = VIEWRANGE_MAX * VIEWRANGE_MAX; // Draw Bugs float distance; foreach (var bug in state.BugStates) { if ((distance = DrawBug(bug, pickray, false)) > 0) { if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = bug; selectedItem.SelectionType = SelectionType.Bug; } } } // Draw Sugar foreach (var sugar in state.SugarStates) { if ((distance = DrawSugar(sugar, pickray, false)) > 0) { if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = sugar; selectedItem.SelectionType = SelectionType.Sugar; } } } // Draw Fruit foreach (var fruit in state.FruitStates) { if ((distance = DrawFruit(fruit, pickray, false)) > 0) { if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = fruit; selectedItem.SelectionType = SelectionType.Fruit; } } } // Draw Colony Base foreach (var colony in state.ColonyStates) { // Draw AntHills foreach (var anthill in colony.AnthillStates) { if ((distance = DrawAnthill(colony.Id, anthill, pickray, false)) > 0) { if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = anthill; selectedItem.SelectionType = SelectionType.Anthill; selectedItem.AdditionalInfo = CurrentState.ColonyStates[anthill.ColonyId - 1].ColonyName; } } } // Draw Ants foreach (var ant in colony.AntStates) { // Debug Messages aktualisieren if (!string.IsNullOrEmpty(ant.DebugMessage)) { DebugMessage msg; if (debugMessages.ContainsKey(ant.Id)) { msg = debugMessages[ant.Id]; } else { msg = new DebugMessage(); debugMessages.Add(ant.Id, msg); } msg.CreateRound = state.CurrentRound; msg.Message = ant.DebugMessage; } // Draw if ((distance = DrawAnt(colony.Id, ant, pickray, false)) > 0) { if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = ant; selectedItem.SelectionType = SelectionType.Ant; selectedItem.AdditionalInfo = CurrentState.ColonyStates[ant.ColonyId - 1].ColonyName; } } } // Remove old Messages foreach (var key in debugMessages.Keys.ToArray()) { DebugMessage msg = debugMessages[key]; if (state.CurrentRound - msg.CreateRound > DebugMessage.ROUNDS_TO_LIFE) { debugMessages.Remove(key); } } } // Draw Marker foreach (var colony in state.ColonyStates) { foreach (var marker in colony.MarkerStates) { DrawMarker(colony.Id, marker); } } // render all sprites in one SpriteBatch.Begin()-End() cycle to save performance spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied); // Draw debug ant-thoughts if (showDebugInfo) { foreach (var colony in CurrentState.ColonyStates) { foreach (var ant in colony.AntStates) { // Draw actual debug text if (debugMessages.ContainsKey(ant.Id)) { DebugMessage msg = debugMessages[ant.Id]; Vector3 pos = new Vector3(ant.PositionX - playgroundWidth, 4, -ant.PositionY + playgroundHeight); Vector2 screenPos = debugRenderer.WorldToScreen(pos, new Vector2(0, -20)); Color boxCol = new Color(0.5f * playerColors[ant.ColonyId - 1]); boxCol.A = 128; DrawTextBox(msg.Message, screenPos, boxCol, Color.White); } } } } // Draw Infobox DrawInfobox(state); // Draw Info-Tag at selected item if (selectedItem.SelectionType != SelectionType.Nothing) { string line1; string line2; switch (selectedItem.SelectionType) { case SelectionType.Ant: AntState ameise = (AntState)selectedItem.Item; string antName = NameHelper.GetFemaleName(ameise.Id); line1 = string.Format(Strings.HovertextAntLine1, antName, selectedItem.AdditionalInfo); line2 = string.Format(Strings.HovertextAntLine2, ameise.Vitality); break; case SelectionType.Anthill: line1 = Strings.HovertextAnthillLine1; line2 = string.Format(Strings.HovertextAnthillLine2, selectedItem.AdditionalInfo); break; case SelectionType.Bug: BugState bugState = (BugState)selectedItem.Item; string bugName = NameHelper.GetMaleName(bugState.Id); line1 = string.Format(Strings.HovertextBugLine1, bugName); line2 = string.Format(Strings.HovertextBugLine2, bugState.Vitality); break; case SelectionType.Fruit: FruitState fruitState = (FruitState)selectedItem.Item; line1 = Strings.HovertextFruitLine1; line2 = string.Format(Strings.HovertextFruitLine2, fruitState.Amount); break; case SelectionType.Sugar: SugarState sugar = (SugarState)selectedItem.Item; line1 = Strings.HovertextSugarLine1; line2 = string.Format(Strings.HovertextSugarLine2, sugar.Amount); break; default: line1 = String.Empty; line2 = String.Empty; break; } // Text an Mausposition ausgeben if (line1 != String.Empty || line2 != String.Empty) { DrawInfoTag(mousePosition, line1, line2); } } spriteBatch.End(); base.Draw(gameTime); }
public void getJiraTicketId(string featurpath, string bugSummary, string scenarioName, BugState bg) { Console.WriteLine("Bazooka : Entered JIRA TICKET ID"); timestamp = DateTime.Now.ToString("dd-MM-yyyy, HH:mm"); HttpClient client1 = new HttpClient(); string Apiurl = ("https://spiderlogic.jira.com/rest/api/2/search?jql=project=SFLOW&fields=issuetype&fields=summary&fields=description&fields=status"); var credentials = Encoding.ASCII.GetBytes("[email protected]:spiderqa"); client1.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials)); Uri uri = new Uri(Apiurl.ToString()); string ApiResponse = client1.GetStringAsync(uri).Result; var root = JsonConvert.DeserializeObject <RootObject>(ApiResponse); var issues = root.issues; foreach (var item in issues) { summary = (item.fields.summary).ToString(); if (item.fields.issuetype.name == "Bug") { if (item.fields.summary == bugSummary & item.fields.status.name == "Closed") { Console.WriteLine("This is the most important step : In Jiraticket Closed"); closedflag = true; closedtktID = item.id; closedtktkey = item.key; bg.closedtkyKey = item.key; bg.closedflag = true; break; } else if (item.fields.summary == bugSummary & item.fields.status.name == "Open") { if (bg.bugclosed) { Console.WriteLine("Bazooka : In Jiraticket BUG CLOSED AND REOPENED"); opentktID = item.id; opentktkey = item.key; openedafterclosedflag = true; bg.reopentktkey = item.key; bg.openedafterclosedflag = true; continue; } else { Console.WriteLine("Bazooka : In Jiraticket DIRECTLY into OPen"); tktID = item.id; tktkey = item.key; bg.newopentktkey = item.key; break; } } } else { continue; } } //if closed ticket workflow when a new bug ticket is created if (closedflag && (bg.nobugcreated == false)) { Console.WriteLine("Bazooka : In Jiraticket if closedflag"); Console.WriteLine("check the nobugcreated flag: " + bg.nobugcreated); foreach (var item in issues) { if (item.fields.issuetype.name == "Bug") { if (item.fields.summary == bugSummary & item.fields.status.name == "Open") { Console.WriteLine("Bazooka : In Jiraticket if closedflag and now in open"); opentktID = item.id; opentktkey = item.key; openedafterclosedflag = true; break; } } else { continue; } } } //Get the creation/closed date of the bug FetchBugCreationResolutionDate bc = new FetchBugCreationResolutionDate(); //Writing into the Feature file if (openedafterclosedflag) { Console.WriteLine("Bazooka : In Jiraticket if openedafterclosed writing intofeature"); bg = bc.fetchBugCreatedClosedDate(bg); Text = File.ReadAllLines(featurpath).ToList(); keyToInsert = "#" + opentktkey + " Opened on: " + bg.bugcreationdate; Console.WriteLine("Text: " + Text); Console.WriteLine("keyToInsert: " + keyToInsert); bg.reopentktkey = opentktkey; trimmedText = keyToInsert.Remove(10); Console.WriteLine("trimmedText: " + trimmedText); if (Text.Contains(keyToInsert)) { Console.WriteLine("Key already exists"); } else { Console.WriteLine("Key does not exist and will write into the feature file"); int length = scenarioName.Length; int index = Text.FindIndex(x => x.Contains(scenarioName)); index = index + 1; string a = Text[index]; Console.WriteLine("a contains: " + a); Console.WriteLine("trimmedtext contains: " + trimmedText); Console.WriteLine("index +1: " + index); Text.RemoveAt(index); Text.Insert(index, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } if (closedflag) { Console.WriteLine("Bazooka : In Jiraticket if closedflag writing intofeature"); Console.WriteLine("Upali ClosedKey: " + closedtktkey); bg = bc.fetchBugCreatedClosedDate(bg); Text = File.ReadAllLines(featurpath).ToList(); keyToInsert = "#" + closedtktkey + " Closed on: " + bg.bugcloseddate; trimmedText = keyToInsert.Remove(7); int length = scenarioName.Length; int index = Text.FindIndex(x => x.Contains(scenarioName)); Console.WriteLine("Index: " + index); index = index + 2; string a = Text[index]; Console.WriteLine("Index +2: " + index); Console.WriteLine("In JIRA KEY TICKET, under closed Flag: a contains" + a); Console.WriteLine("In JIRA KEY TICKET, under closed Flag: Trimmed Text contains :" + trimmedText); if (a.Contains(trimmedText)) { if (bg.bugclosedcount == 0) { Console.WriteLine("Do Nothing"); } //april 26 test else if (bg.bugclosedcount >= 1) { if (bg.nobugcreated) { Console.WriteLine("Inside nobugcreated"); int newindex = index - 1; string b = Text[newindex]; if (b.Contains("Opened")) { Console.WriteLine("Inside nobugcreated and if b contains Opened"); Console.WriteLine("Key to insert: " + keyToInsert); Text.Remove(b); Text.Insert(newindex, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } else { Console.WriteLine("old closed bug :" + bg.buglist[bg.bugclosedcount - 1]); Console.WriteLine("inside if a.contains(trimmedtext) and if bugcount > 1"); string closedbug = Text[index]; if (closedbug.Contains(closedtktkey)) { Console.WriteLine("Do nothing"); } else { Text.Insert(index, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } } else { Console.WriteLine("inside else bugcount >1"); if (a.Contains(bg.buglist[0])) { Console.WriteLine("in if a.contains closed bug"); Text.Remove(a); Text.Insert(index, keyToInsert); } else { Console.WriteLine("in else a.contains closed bug"); Text.Insert(index, keyToInsert); } System.IO.File.WriteAllLines(featurpath, Text); } } else { Console.WriteLine("inside else a.contains(trimmedtext)"); Text.Insert(index, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } else if (bg.nobugcreated) { Console.WriteLine("When the test case passes and no bug is created,Do Nothing"); } else { Console.WriteLine("Bazooka : In Jiraticket if opened new writing intofeature"); Text = File.ReadAllLines(featurpath).ToList(); bg = bc.fetchBugCreatedClosedDate(bg); keyToInsert = "#" + tktkey + " Opened on: " + bg.bugcreationdate; Console.WriteLine("Text: " + Text); Console.WriteLine("keyToInsert: " + keyToInsert); trimmedText = keyToInsert.Remove(7); Console.WriteLine("trimmedText: " + trimmedText); if (Text.Contains(keyToInsert)) { Console.WriteLine("Key already exists"); } else { int length = scenarioName.Length; int index = Text.FindIndex(x => x.Contains(scenarioName)); index = index + 1; string a = Text[index]; if (a.Contains(trimmedText)) { Text.Remove(a); Text.Insert(index, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } else { Text.Insert(index, keyToInsert); System.IO.File.WriteAllLines(featurpath, Text); } } } }
private void render(object sender, PaintEventArgs e) { if (Visible && renderDevice != null) { if (watch.ElapsedMilliseconds > 40) { watch.Reset(); watch.Start(); Selection selectedItem = new Selection(); // Selektionsinfos zurücksetzen selectedItem.SelectionType = SelectionType.Nothing; selectedItem.Item = null; float distanceToSelectedItem = VIEWRANGE_MAX * VIEWRANGE_MAX; renderDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.FromArgb(51, 153, 255), 1.0f, 0); renderDevice.BeginScene(); //// Falls schon ein Zustand da ist kann gezeichnet werden if (simulationState != null) { SimulationState currentState = simulationState; // Update Camera camera.Update(currentState.PlaygroundWidth, currentState.PlaygroundHeight); renderDevice.Transform.View = camera.ViewMatrix; Pickray pickray = camera.Pickray; Point mousePosition = camera.MousePosition; // render Playerground modelManager.SetPlaygroundSize(currentState.PlaygroundWidth, currentState.PlaygroundHeight); modelManager.RenderPlayground(); // render these preaty little, blue items... float distance; for (int i = 0; i < currentState.BugStates.Count; i++) { if ((distance = modelManager.RenderBug(currentState.BugStates[i], pickray, false)) > 0) { // select, if pickray collides with item if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = currentState.BugStates[i]; selectedItem.SelectionType = SelectionType.Bug; } } } // Render sugar for (int i = 0; i < currentState.SugarStates.Count; i++) { if ((distance = modelManager.RenderSugar(currentState.SugarStates[i], pickray, false)) > 0) { // select, if pickray collides with item if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = currentState.SugarStates[i]; selectedItem.SelectionType = SelectionType.Sugar; } } } // Render Fruit for (int i = 0; i < currentState.FruitStates.Count; i++) { if ((distance = modelManager.RenderFruit(currentState.FruitStates[i], pickray, false)) > 0) { // select, if pickray collides with item if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = currentState.FruitStates[i]; selectedItem.SelectionType = SelectionType.Fruit; } } } // Colony-specific stuff int count = 0; for (int teamIndex = 0; teamIndex < currentState.TeamStates.Count; teamIndex++) { for (int colonyIndex = 0; colonyIndex < currentState.TeamStates[teamIndex].ColonyStates.Count; colonyIndex++) { ColonyState colony = currentState.TeamStates[teamIndex].ColonyStates[colonyIndex]; // Ensure available materials for that colony modelManager.PrepareColony(count); // Render Anthills for (int anthillIndex = 0; anthillIndex < colony.AnthillStates.Count; anthillIndex++) { if ( (distance = modelManager.RenderAnthill( count, colony.AnthillStates[anthillIndex], pickray, false)) > 0) // select, if pickray collides with item { if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = colony.AnthillStates[anthillIndex]; selectedItem.SelectionType = SelectionType.Anthill; selectedItem.AdditionalInfo = colony.ColonyName; } } } // Render Ants for (int antIndex = 0; antIndex < colony.AntStates.Count; antIndex++) { if ( (distance = modelManager.RenderAnt( count, colony.AntStates[antIndex], pickray, false)) > 0) { // select, if pickray collides with item if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = colony.AntStates[antIndex]; selectedItem.SelectionType = SelectionType.Ant; selectedItem.AdditionalInfo = colony.ColonyName; } } } count++; } } // Render Marker // This must happen at the end, cause of alpha-tranperency count = 0; for (int teamIndex = 0; teamIndex < currentState.TeamStates.Count; teamIndex++) { TeamState team = currentState.TeamStates[teamIndex]; for (int colonyIndex = 0; colonyIndex < team.ColonyStates.Count; colonyIndex++) { ColonyState colony = team.ColonyStates[colonyIndex]; for (int markerIndex = 0; markerIndex < colony.MarkerStates.Count; markerIndex++) { MarkerState marker = colony.MarkerStates[markerIndex]; modelManager.RenderMarker(count, marker); } count++; } } // Render Statistics in the upper left corner modelManager.RenderInfobox(currentState); // Render Info-Tag at selected item if (selectedItem.SelectionType != SelectionType.Nothing) { string line1; string line2; switch (selectedItem.SelectionType) { case SelectionType.Ant: AntState ameise = (AntState)selectedItem.Item; string name; if (!antNames.ContainsKey(ameise.Id)) { name = names[random.Next(names.Length)]; antNames.Add(ameise.Id, name); } else { name = antNames[ameise.Id]; } line1 = string.Format(Resource.HovertextAntLine1, name, selectedItem.AdditionalInfo); line2 = string.Format(Resource.HovertextAntLine2, ameise.Vitality); break; case SelectionType.Anthill: line1 = Resource.HovertextAnthillLine1; line2 = string.Format(Resource.HovertextAnthillLine2, selectedItem.AdditionalInfo); break; case SelectionType.Bug: BugState bugState = (BugState)selectedItem.Item; line1 = Resource.HovertextBugLine1; line2 = string.Format(Resource.HovertextBugLine2, bugState.Vitality); break; case SelectionType.Fruit: FruitState fruitState = (FruitState)selectedItem.Item; line1 = Resource.HovertextFruitLine1; line2 = string.Format(Resource.HovertextFruitLine2, fruitState.Amount); break; case SelectionType.Sugar: SugarState sugar = (SugarState)selectedItem.Item; line1 = Resource.HovertextSugarLine1; line2 = string.Format(Resource.HovertextSugarLine2, sugar.Amount); break; default: line1 = String.Empty; line2 = String.Empty; break; } // Text an Mausposition ausgeben if (line1 != String.Empty || line2 != String.Empty) { modelManager.RenderInfoTag(mousePosition, line1, line2); } } } renderDevice.EndScene(); renderDevice.Present(); } Application.DoEvents(); Invalidate(); } }
public BugState create(string bugsummary, string errordetails, BugState bg) { string tktID = null; string tkyKey = null; string state = ""; string issuetype = ""; string closedtktID = null; string closedtkyKey = null; bg.bugclosed = false; bg.bugexists = false; bg.bugopen = false; //Checking whether the Bug already exists, if true, do not create a new ticket HttpClient client2 = new HttpClient(); string issueurl = ("https://spiderlogic.jira.com/rest/api/2/search?jql=project=SFLOW&fields=issues&fields=summary&fields=description&fields=status&fields=project&fields=issuetype"); var credentials = Encoding.ASCII.GetBytes("[email protected]:spiderqa"); client2.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials)); Uri uri = new Uri(issueurl.ToString()); string ApiResponse = client2.GetStringAsync(uri).Result; var root = JsonConvert.DeserializeObject <RootObject>(ApiResponse); var Sumry = root.issues.Count; //Checking if the user story already exists by iterating though the issue list in jira var issues = root.issues; Debug.WriteLine("Upali Debug: "); foreach (var issue in issues) { var fields = issue.fields; var summary = (fields.summary).ToString(); state = (fields.status.name).ToString(); issuetype = (fields.issuetype.name).ToString(); if ((issuetype == "Bug") & summary.Equals(bugsummary)) { if (state == "Open") { // the control may not go to if block ever if (bg.bugclosed) { Console.WriteLine("In BugCreate: Bug OPened after closed "); bg.bugexists = true; Console.WriteLine("Ticket Key: " + issue.key); } else { Console.WriteLine("In BugCreate : Bug exists"); bg.bugexists = true; tktID = issue.id; tkyKey = issue.key; Console.WriteLine("Ticket Key: " + issue.key); bg.bugopen = true; } } else if (state == "Closed") { if (bg.bugopen) { Console.WriteLine("In BugCreate: Bug closed and ALSO REOPENED"); bg.bugexists = true; bg.bugclosed = true; bg.bugclosedcount = bg.bugclosedcount + 1; bg.buglist.Add(closedtkyKey); } else { Console.WriteLine("In BugCreate: Bug exists bug closed "); bg.bugexists = false; closedtktID = issue.id; closedtkyKey = issue.key; bg.bugclosed = true; bg.closedtkyKey = issue.key; bg.bugclosedcount = bg.bugclosedcount + 1; bg.buglist.Add(closedtkyKey); } } } } //If the Bug not exist, create a new user story by using the POST method in JIRA via API if (bg.bugexists == false) { //The fields required to create a new JIRA ticket var data = new CreateIssue(); data.fields.project.key = "SFLOW"; data.fields.summary = bugsummary; data.fields.description = errordetails; data.fields.issuetype.name = "Bug"; string postUrl = "https://spiderlogic.jira.com/rest/api/latest/"; System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); client.BaseAddress = new System.Uri(postUrl); byte[] cred = UTF8Encoding.UTF8.GetBytes("[email protected]:spiderqa"); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred)); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); System.Net.Http.Formatting.MediaTypeFormatter jsonFormatter = new System.Net.Http.Formatting.JsonMediaTypeFormatter(); System.Net.Http.HttpContent content = new System.Net.Http.ObjectContent <CreateIssue>(data, jsonFormatter); System.Net.Http.HttpResponseMessage response = client.PostAsync("issue", content).Result; if (response.IsSuccessStatusCode) { string result = response.Content.ReadAsStringAsync().Result; Console.Write(result); } else { Console.Write(response.StatusCode.ToString()); Console.ReadLine(); } } return(bg); }