public void ReadyClicked() { cam = GameObject.Find("Main Camera"); canvasArena = GameObject.Find("Canvas Arena"); cam.transform.position = new Vector3(canvasArena.transform.position.x, canvasArena.transform.position.y, -10); Bf bf = new Bf(); for (int i = 0; i < Formation.SIZE; i++) { if (Formation.occupied[i]) { bf.AddUnit(Formation.units[i], i); } } for (int i = 0; i < Recruit.SIZE; i++) { Recruit.videoPlayer[i].GetComponentInChildren <VideoPlayer>().clip = null; } Enemy enemy = new Enemy(); bf.AddUnit(enemy.Recruit("ccc"), 29); bf.AddUnit(enemy.Recruit("ccc"), 28); bf.AddUnit(enemy.Recruit("ccc"), 27); }
/// <summary> /// Загружает <see cref="CookieStorage"/> из файла. /// </summary> /// <param name="filePath">Путь к файлу с куками</param> /// <returns>Вернет <see cref="CookieStorage"/>, который задается в свойстве <see cref="HttpRequest"/> Cookies.</returns> // ReSharper disable once UnusedMember.Global public static CookieStorage LoadFromFile(string filePath) { if (!File.Exists(filePath)) { throw new FileNotFoundException($"Файл с куками '${filePath}' не найден", nameof(filePath)); } using (var fs = new FileStream(filePath, FileMode.Open)) return((CookieStorage)Bf.Deserialize(fs)); }
/// <summary> /// Сохраняет куки в файл. /// <remarks>Рекомендуется расширение .jar.</remarks> /// </summary> /// <param name="filePath">Пусть для сохранения файла</param> /// <param name="overwrite">Перезаписать файл если он уже существует</param> // ReSharper disable once UnusedMember.Global public void SaveToFile(string filePath, bool overwrite = true) { if (!overwrite && File.Exists(filePath)) { throw new ArgumentException(string.Format(Resources.CookieStorage_SaveToFile_FileAlreadyExists, filePath), nameof(filePath)); } using (var fs = new FileStream(filePath, FileMode.OpenOrCreate)) Bf.Serialize(fs, this); }
private static string Format(Bf b) { string s = "[" + b.GetType().Name + "]"; s += " " + b.a; if (b.b == null) { return(s + " null"); } s += " " + b.b.Count; foreach (var i in b.b) { s += ": " + i; } return(s); }
private async Task <int> ReEncryptBFAndACtivityVariable(string oldKey = null) { ShowStatusMessage("Re-Encrypting Business flow and activity Password variables Values with new Key..."); return(await Task.Run(() => { int varReencryptedCount = 0; List <BusinessFlow> Bfs = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>().ToList(); // For BF and Activity Parallel.ForEach(Bfs, Bf => { try { // Get all variables from BF List <GingerCore.Variables.VariableBase> variables = Bf.GetBFandActivitiesVariabeles(false).Where(f => f is GingerCore.Variables.VariablePasswordString).ToList(); variables.ForEach(v => { try { ((GingerCore.Variables.VariablePasswordString)v).Password = EncryptionHandler.ReEncryptString(((GingerCore.Variables.VariablePasswordString)v).Password, oldKey); varReencryptedCount++; } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, string.Format("ReEncryptVariable- Failed to Re-encrypt password variable of {0} for {1}", Bf.Name, v.Name), ex); } }); if (variables.Any()) { WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(Bf); } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, string.Format("ReEncryptVariable- Failed to Re encrypt password variable of {0}.", Bf.Name), ex); } }); return varReencryptedCount; })); }
void Update() { if (counter > 0) { Vector3 dir = endPoint.transform.position - startPoint.transform.position; float dist = Mathf.Sqrt( Mathf.Pow(endPoint.transform.position.x - startPoint.transform.position.x, 2) + Mathf.Pow(endPoint.transform.position.y - startPoint.transform.position.y, 2)); this.transform.Translate(dir.normalized * dist * Time.deltaTime); } else if (counter <= 0) { Bf bf = new Bf(); bf.AddUnit(unit, _to); Destroy(gameObject); } counter -= Time.deltaTime; }
public void Execute() { //Test Data App app = new App(); Apf apf = new Apf(); Afp afp = new Afp(); Aff aff = new Aff(); Bp bp1 = new Bp() { a = "b1" }; Bp bp2 = new Bp() { a = "b2" }; Bf bf1 = new Bf() { a = "b1" }; Bf bf2 = new Bf() { a = "b2" }; bp1.b = new List <string>(); bp2.b = new List <string>(); bf1.b = new List <string>(); bf2.b = new List <string>(); bp1.b.Add("a"); bp2.b.Add("b"); bf1.b.Add("a"); bf2.b.Add("b"); app.list.Add(bp1); app.list.Add(bp2); apf.list.Add(bf1); apf.list.Add(bf2); afp.list.Add(bp1); afp.list.Add(bp2); aff.list.Add(bf1); aff.list.Add(bf2); using StringWriter before = new StringWriter(); before.WriteLine(Format(app)); before.WriteLine(Format(apf)); before.WriteLine(Format(afp)); before.WriteLine(Format(aff)); //Serialize MemoryStream mspp = new MemoryStream(); MemoryStream mspf = new MemoryStream(); MemoryStream msfp = new MemoryStream(); MemoryStream msff = new MemoryStream(); Serializer.Serialize(mspp, app); Serializer.Serialize(mspf, apf); Serializer.Serialize(msfp, afp); Serializer.Serialize(msff, aff); //Compare binary data byte[] bpp = mspp.ToArray(); byte[] bpf = mspf.ToArray(); byte[] bfp = msfp.ToArray(); byte[] bff = msff.ToArray(); Assert.Equal(18, bpp.Length); if (bpp.Length != bpf.Length) { throw new InvalidDataException("Length does not match"); } if (bpf.Length != bff.Length) { throw new InvalidDataException("Length does not match"); } if (bff.Length != bfp.Length) { throw new InvalidDataException("Length does not match"); } for (int n = 0; n < bpp.Length; n++) { if (bpp[n] != bpf[n] || bpf[n] != bff[n] || bff[n] != bfp[n]) { throw new InvalidDataException("Data does not match"); } } //Deserialize StringWriter after = new StringWriter(); Deserialize(bpp, after); Assert.Equal(before.ToString(), after.ToString()); }
public bool MoveUnit(Unit unit) { int moveTo = unit.tile; if (unit.ally) { for (int i = unit.tile + 3; i <= unit.tile + (unit.speed * 3); i += 3) { if (i > 29) { break; } Tile tile = new Tile(); List <int> tiles = tile.GetInFront(i - 3, unit.ally); for (int j = 0; j < tiles.Count; j++) { if (Bf.occupied[tiles[j]]) { if (!Bf.units[tiles[j]].ally) { goto OutOfLoop; } } } if (!Bf.occupied[i]) { moveTo = i; } } } else { for (int i = unit.tile - 3; i >= unit.tile - (unit.speed * 3); i -= 3) { if (i < 0) { break; } Tile tile = new Tile(); List <int> tiles = tile.GetInFront(i + 3, unit.ally); for (int j = 0; j < tiles.Count; j++) { if (Bf.occupied[tiles[j]]) { if (Bf.units[tiles[j]].ally) { goto OutOfLoop; } } } if (!Bf.occupied[i]) { moveTo = i; } } } OutOfLoop: if (unit.tile != moveTo) { AnimaUnit animaUnit = new AnimaUnit(); animaUnit.MoveUnit(unit.tile, moveTo); Bf bf = new Bf(); bf.Destroy(unit.tile); unit.tile = moveTo; return(true); } return(false); }
private async Task LoadEncryptedParamtersList() { ObservableList <GingerCore.Variables.VariablePasswordString> variables = new ObservableList <GingerCore.Variables.VariablePasswordString>(); await Task.Run(() => { this.ShowLoader(); this.ShowStatusMessage("Searching all password values in the solution..."); try { if (WorkSpace.Instance.SolutionRepository == null) { WorkSpace.Instance.SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository(); WorkSpace.Instance.SolutionRepository.Open(_solution.ContainingFolderFullPath); } // For BF and Activity List <BusinessFlow> Bfs = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>()?.ToList(); Parallel.ForEach(Bfs, Bf => { foreach (GingerCore.Variables.VariablePasswordString item in Bf.GetBFandActivitiesVariabeles(true).Where(f => f is GingerCore.Variables.VariablePasswordString)) { item.Password = ""; variables.Add(item); } }); //for Golbal Variables foreach (GingerCore.Variables.VariablePasswordString v in _solution.Variables.Where(f => f is GingerCore.Variables.VariablePasswordString)) { v.Password = ""; v.ParentType = string.IsNullOrEmpty(v.ParentType) ? "Global Variable" : v.ParentType; variables.Add(v); } //For Project environments List <ProjEnvironment> projEnvironments = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ProjEnvironment>().ToList(); projEnvironments.ForEach(pe => { // GingerCore.Variables.VariablePasswordString vp; foreach (EnvApplication ea in pe.Applications) { foreach (Database db in ea.Dbs) { if (!string.IsNullOrEmpty(db.Pass)) { variables.Add(CreatePasswordVariable(db.Name, "Database Password", pe.Name + "-->" + ea.Name, db.Guid)); } } foreach (GeneralParam gp in ea.GeneralParams.Where(f => f.Encrypt)) { variables.Add(CreatePasswordVariable(gp.Name, "Environment Parameter", pe.Name + "-->" + ea.Name, gp.Guid)); } } }); //For Shared Variales List <GingerCore.Variables.VariableBase> sharedRepoVarsList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <GingerCore.Variables.VariableBase>().Where(f => f is GingerCore.Variables.VariablePasswordString).ToList(); Parallel.ForEach(sharedRepoVarsList, sharedVar => { ((GingerCore.Variables.VariablePasswordString)sharedVar).Password = ""; sharedVar.ParentType = "Shared Variable"; variables.Add((GingerCore.Variables.VariablePasswordString)sharedVar); }); //For Shared Activites List <Activity> sharedActivityList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>().ToList(); Parallel.ForEach(sharedActivityList, sharedAct => { List <GingerCore.Variables.VariableBase> sharedActivityVariables = sharedAct.Variables?.Where(f => f is GingerCore.Variables.VariablePasswordString).ToList(); foreach (GingerCore.Variables.VariablePasswordString v in sharedActivityVariables) { v.Password = ""; v.ParentType = "Shared Activity"; variables.Add(v); } }); //For Email passwords var runSetConfigs = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <RunSetConfig>(); foreach (var rsc in runSetConfigs) { //VariablePasswordString vp; foreach (var ra in rsc.RunSetActions) { try { if (ra is RunSetActionHTMLReportSendEmail) { if (((RunSetActionHTMLReportSendEmail)ra).Email != null && !string.IsNullOrEmpty(((RunSetActionHTMLReportSendEmail)ra).Email.SMTPPass)) { variables.Add(CreatePasswordVariable(ra.ItemName, "Run Set Operation", rsc.Name, ((RunSetActionHTMLReportSendEmail)ra).Email.Guid)); } } else if (ra is RunSetActionSendFreeEmail) { if (((RunSetActionSendFreeEmail)ra).Email != null && !string.IsNullOrEmpty(((RunSetActionSendFreeEmail)ra).Email.SMTPPass)) { variables.Add(CreatePasswordVariable(ra.ItemName, "Run Set Operation", rsc.Name, ((RunSetActionSendFreeEmail)ra).Email.Guid)); } } else if (ra is RunSetActionSendSMS) { if (((RunSetActionSendSMS)ra).SMSEmail != null && !string.IsNullOrEmpty(((RunSetActionSendSMS)ra).SMSEmail.SMTPPass)) { variables.Add(CreatePasswordVariable(ra.ItemName, "Run Set Operation", rsc.Name, ((RunSetActionSendSMS)ra).SMSEmail.Guid)); } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.WARN, "Error while Retrieving encrypted SMTP password for " + rsc.Name, ex); throw; } } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.WARN, "Retrieving encrypted variables for setting new value", ex); } finally { this.HideLoader(); ShowStatusMessage("Please set the new values for password paramters"); } }); if (!variables.Any()) { _pageGenericWin.Close(); } SetGridsView(); xSolutionPasswordsParamtersGrid.DataSourceList = variables; xSolutionPasswordsParamtersGrid.RowChangedEvent += grdGroups_RowChangedEvent; xSolutionPasswordsParamtersGrid.Title = "List of Passwords/Encrypted Values to update new value"; xSolutionPasswordsParamtersGrid.Visibility = Visibility.Visible; }
private async void OkBtn_Click(object sender, RoutedEventArgs e) { await Task.Run(() => { try { this.ShowLoader(); ShowStatusMessage("Saving the new password values for parameters..."); EncryptGridValues(); // For BF and Activity List <BusinessFlow> Bfs = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>().ToList(); Parallel.ForEach(Bfs, Bf => { try { if (Bf.GetBFandActivitiesVariabeles(false).Where(f => f is GingerCore.Variables.VariablePasswordString).Any()) { WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(Bf); } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Replace Key Page: Error while encrypting variable password of " + Bf.Name, ex); } }); // For Global Variables foreach (GingerCore.Variables.VariableBase v in WorkSpace.Instance.Solution.Variables.Where(f => f is GingerCore.Variables.VariablePasswordString)) { try { WorkSpace.Instance.Solution.SolutionOperations.SaveSolution(false); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, string.Format("ReEncryptVariable- Failed to Reencrypt password Global variable {1}", v.Name), ex); } } //For Environment parameters List <ProjEnvironment> projEnvironments = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ProjEnvironment>().ToList(); projEnvironments.ForEach(pe => { try { bool res1 = false; foreach (EnvApplication ea in pe.Applications) { foreach (GeneralParam gp in ea.GeneralParams.Where(f => f.Encrypt)) { gp.Value = ((ObservableList <GingerCore.Variables.VariablePasswordString>)xSolutionPasswordsParamtersGrid.DataSourceList).Where(f => f.Guid.Equals(gp.Guid)).FirstOrDefault().Password; res1 = true; } foreach (Database db in ea.Dbs) { if (!string.IsNullOrEmpty(db.Pass)) { db.Pass = ((ObservableList <GingerCore.Variables.VariablePasswordString>)xSolutionPasswordsParamtersGrid.DataSourceList).Where(f => f.Guid.Equals(db.Guid)).FirstOrDefault().Password; res1 = true; } } } if (res1) { WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(pe); } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Replace Key Page: Error while encrypting Environment parameter password of " + pe.Name, ex); } }); //For shared variables List <GingerCore.Variables.VariableBase> sharedRepoVarsList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <GingerCore.Variables.VariableBase>().Where(f => f is GingerCore.Variables.VariablePasswordString).ToList(); foreach (GingerCore.Variables.VariableBase sharedVar in sharedRepoVarsList) { try { WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(sharedVar); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Replace Key Page: Error while encrypting Shared variable password " + sharedVar.Name, ex); } } //For Shared Activites List <Activity> sharedActivityList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>().ToList(); foreach (Activity sharedAct in sharedActivityList) { try { if (sharedAct.Variables.Where(f => f is GingerCore.Variables.VariablePasswordString).Any()) { WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(sharedAct); } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Replace Key Page: Error while encrypting Shared variable password " + sharedAct.ActivityName, ex); } } //Email Passwords var runSetConfigs = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <RunSetConfig>(); bool res = false; foreach (var rsc in runSetConfigs) { try { res = false; foreach (var ra in rsc.RunSetActions) { if (ra is RunSetActionHTMLReportSendEmail && ((RunSetActionHTMLReportSendEmail)ra).Email != null && !string.IsNullOrEmpty(((RunSetActionHTMLReportSendEmail)ra).Email.SMTPPass)) { ((RunSetActionHTMLReportSendEmail)ra).Email.SMTPPass = ((ObservableList <GingerCore.Variables.VariablePasswordString>)xSolutionPasswordsParamtersGrid.DataSourceList) .Where(f => f.Guid.Equals(((RunSetActionHTMLReportSendEmail)ra).Email.Guid)).FirstOrDefault().Password; res = true; } else if (ra is RunSetActionSendFreeEmail && ((RunSetActionSendFreeEmail)ra).Email != null && !string.IsNullOrEmpty(((RunSetActionSendFreeEmail)ra).Email.SMTPPass)) { ((RunSetActionSendFreeEmail)ra).Email.SMTPPass = ((ObservableList <GingerCore.Variables.VariablePasswordString>)xSolutionPasswordsParamtersGrid.DataSourceList) .Where(f => f.Guid.Equals(((RunSetActionSendFreeEmail)ra).Email.Guid)).FirstOrDefault().Password; res = true; } else if (ra is RunSetActionSendSMS && ((RunSetActionSendSMS)ra).SMSEmail != null && !string.IsNullOrEmpty(((RunSetActionSendSMS)ra).SMSEmail.SMTPPass)) { ((RunSetActionSendSMS)ra).SMSEmail.SMTPPass = ((ObservableList <GingerCore.Variables.VariablePasswordString>)xSolutionPasswordsParamtersGrid.DataSourceList) .Where(f => f.Guid.Equals(((RunSetActionSendSMS)ra).SMSEmail.Guid)).FirstOrDefault().Password; res = true; } } if (res) { WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(rsc); } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Replace Key Page: Error while encrypting Email SMTP password of " + rsc.Name, ex); } } _solution.SolutionOperations.SaveSolution(false); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Error while in Encrypting variables passwords", ex); } finally { this.HideLoader(); HideStatusMessage(); } }); _pageGenericWin.Close(); }
public void Execute() { //Test Data App app = new App(); Apf apf = new Apf(); Afp afp = new Afp(); Aff aff = new Aff(); Bp bp1 = new Bp() { a = "b1" }; Bp bp2 = new Bp() { a = "b2" }; Bf bf1 = new Bf() { a = "b1" }; Bf bf2 = new Bf() { a = "b2" }; bp1.b = new List<string>(); bp2.b = new List<string>(); bf1.b = new List<string>(); bf2.b = new List<string>(); bp1.b.Add("a"); bp2.b.Add("b"); bf1.b.Add("a"); bf2.b.Add("b"); app.list.Add(bp1); app.list.Add(bp2); apf.list.Add(bf1); apf.list.Add(bf2); afp.list.Add(bp1); afp.list.Add(bp2); aff.list.Add(bf1); aff.list.Add(bf2); StringWriter before = new StringWriter(); before.WriteLine(Format(app)); before.WriteLine(Format(apf)); before.WriteLine(Format(afp)); before.WriteLine(Format(aff)); //Serialize MemoryStream mspp = new MemoryStream(); MemoryStream mspf = new MemoryStream(); MemoryStream msfp = new MemoryStream(); MemoryStream msff = new MemoryStream(); Serializer.Serialize(mspp, app); Serializer.Serialize(mspf, apf); Serializer.Serialize(msfp, afp); Serializer.Serialize(msff, aff); //Compare binary data byte[] bpp = mspp.ToArray(); byte[] bpf = mspf.ToArray(); byte[] bfp = msfp.ToArray(); byte[] bff = msff.ToArray(); Assert.AreEqual(18, bpp.Length); if (bpp.Length != bpf.Length) throw new InvalidDataException("Length does not match"); if (bpf.Length != bff.Length) throw new InvalidDataException("Length does not match"); if (bff.Length != bfp.Length) throw new InvalidDataException("Length does not match"); for (int n = 0; n < bpp.Length; n++) { if (bpp[n] != bpf[n] || bpf[n] != bff[n] || bff[n] != bfp[n]) throw new InvalidDataException("Data does not match"); } //Deserialize StringWriter after = new StringWriter(); Deserialize(bpp, after); Assert.AreEqual(before.ToString(), after.ToString()); }
private static string Format(Bf b) { string s = "[" + b.GetType().Name + "]"; s += " " + b.a; if (b.b == null) return s + " null"; s += " " + b.b.Count; foreach (var i in b.b) s += ": " + i; return s; }
/// <summary> /// /// </summary> /// <returns></returns> public Bf BF(Data.IDataSeries input, bool showLabels, int startTime) { if (cacheBF != null) for (int idx = 0; idx < cacheBF.Length; idx++) if (cacheBF[idx].ShowLabels == showLabels && cacheBF[idx].StartTime == startTime && cacheBF[idx].EqualsInput(input)) return cacheBF[idx]; lock (checkBF) { checkBF.ShowLabels = showLabels; showLabels = checkBF.ShowLabels; checkBF.StartTime = startTime; startTime = checkBF.StartTime; if (cacheBF != null) for (int idx = 0; idx < cacheBF.Length; idx++) if (cacheBF[idx].ShowLabels == showLabels && cacheBF[idx].StartTime == startTime && cacheBF[idx].EqualsInput(input)) return cacheBF[idx]; Bf indicator = new Bf(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.ShowLabels = showLabels; indicator.StartTime = startTime; Indicators.Add(indicator); indicator.SetUp(); Bf[] tmp = new Bf[cacheBF == null ? 1 : cacheBF.Length + 1]; if (cacheBF != null) cacheBF.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheBF = tmp; return indicator; } }