private void CaptureImpl() { if (Leakage != null || Admixture != null || Changes != null) throw new NotSupportedException("Cannot call this method twice."); Admixture = new ParametersValues(); Changes = new ParametersValues(); Leakage = new ParametersValues(); foreach (var key in BaseLine.Keys.Union(NewVersion.Keys)) { if (BaseLine.ContainsKey(key) && NewVersion.ContainsKey(key)) { var bval = BaseLine[key]; var cval = NewVersion[key]; if (!Equals(bval, cval)) { Changes.Add(key, cval); } } else if (BaseLine.ContainsKey(key) && !NewVersion.ContainsKey(key)) { Leakage.Add(key, BaseLine[key]); } else if (!BaseLine.ContainsKey(key) && NewVersion.ContainsKey(key)) { Admixture.Add(key, NewVersion[key]); } } Admixture = new ParametersValues(Admixture.AsReadOnly()); Changes = new ParametersValues(Changes.AsReadOnly()); Leakage = new ParametersValues(Leakage.AsReadOnly()); }
public void AddParameterValuesForQuery(TDSQueriesTree.QueriesRow queryRow, NameValueCollection searchConfiguration) { DataRow[] parameters = ParametersValues.Select("QueryID = " + queryRow.ID); for (int i = parameters.GetLength(0) - 1; i >= 0; i--) { parameters[i].Delete(); } ParametersValues.AcceptChanges(); for (int i = 0; i < searchConfiguration.Count; i++) { //compose QueryString based on the criteria selected in the interface for (int j = 0; j < searchConfiguration.GetValues(i).Length; j++) { ParametersValuesRow qpValue = _instance.ParametersValues.NewParametersValuesRow(); qpValue.QueryID = queryRow.ID; DataRow[] qpRows = _instance.QueryParameters.Select("Name = '" + searchConfiguration.GetKey(i) + "'"); if (qpRows.GetLength(0) == 1) { qpValue.ParameterID = Byte.Parse(qpRows[0][0].ToString()); qpValue.Value = searchConfiguration.GetValues(i)[j]; _instance.ParametersValues.Rows.Add(qpValue); } } } }
static DBHelper() { try { using (var db = new CitiesDB("con1")) { foreach (var dt in db.CitiesData) { var record = new Dictionary <int, string>() { { 1, "" + dt.Nhemisphere }, { 2, "" + dt.Whemisphere }, { 3, dt.Continent }, { 4, dt.PosContWEC }, { 5, dt.PosContSNC }, { 6, dt.Country }, { 7, "" + dt.PosBySea }, { 8, dt.PosCountryWEC }, { 9, dt.PosCountrySNC }, { 10, dt.Population }, { 11, dt.Name } }; ParametersValues.Add(record); } } } catch (Exception e) { } }
public ChangeSet StartRecording() { if (BaseLine != null) throw new NotSupportedException("Cannot call this method twice."); BaseLine = new ParametersValues(Get().AsReadOnly()); return this; }
public ChangeSet Accept() { var updated = new ParametersValues(Get()); Admixture.ForEach(kvp => updated.Add(kvp.Key, kvp.Value)); Changes.ForEach(kvp => updated[kvp.Key] = kvp.Value); Leakage.ForEach(kvp => updated.Remove(kvp.Key)); Set(updated); return this; }
public StructQueryParameters GetExecuteParameter() { return(new StructQueryParameters { ParametersValues = ParametersValues.ToArray(), StartRowIndex = StartRowIndex, MaximumRows = MaximumRows, RefParent = RefParent, }); }
public ChangeSet Capture() { if (Leakage != null || Admixture != null || Changes != null) throw new NotSupportedException("Cannot call this method twice."); NewVersion = new ParametersValues(Get().AsReadOnly()); CaptureImpl(); return this; }
//Обработчик фильтров public void OnFilterChanged() { System.Linq.Expressions.Expression result = null, temp; Delegate lambda = null, lambdaSU = null, lambdaSD = null; foreach (var item in _filters) { if (result == null) { result = item.GetFilter(); } else { temp = item.GetFilter(); if (temp != null) { result = System.Linq.Expressions.Expression.And(result, temp); } } } if (result != null) { lambda = System.Linq.Expressions.Expression.Lambda <Func <ServiceLog, bool> >(result, _parameter).Compile(); } if (_filterSparesUsed.GetFilter() != null) { lambdaSU = System.Linq.Expressions.Expression.Lambda <Func <SpareUsed, bool> >(_filterSparesUsed.GetFilter(), _parameterSU).Compile(); } if (_filterServicesDone.GetFilter() != null) { lambdaSD = System.Linq.Expressions.Expression.Lambda <Func <ServiceDone, bool> >(_filterServicesDone.GetFilter(), _parameterSD).Compile(); } if (_dbContext is SQLiteContext) { SQLiteContext context = _dbContext as SQLiteContext; var tempServiceLogs = context.ServiceLog.Where((Func <ServiceLog, bool>)lambda).ToList().OrderBy(s => s.DateTime).ToList(); if (lambdaSU != null) { tempServiceLogs = tempServiceLogs.Where(s => s.SparesUsed.Where((Func <SpareUsed, bool>)lambdaSU).Count() > 0).ToList(); } if (lambdaSD != null) { tempServiceLogs = tempServiceLogs.Where(s => s.ServicesDone.Where((Func <ServiceDone, bool>)lambdaSD).Count() > 0).ToList(); } ServiceLogsListCreator(tempServiceLogs); } SelectedServiceLog = null; ParametersValues?.Clear(); ServicesDone?.Clear(); SparesUsed?.Clear(); }
public ColaNode(String name, IEnumerable<ColaNode> children) { Id = Guid.NewGuid(); Name = name; ParamValues = new ParametersValues(); Children = new List<ColaNode>(children).AsReadOnly(); var childIndex = 0; foreach (var child in Children) { child.Parent = this; child.ChildIndex = childIndex++; } }
/// <summary> /// Метод выполняет соединения с шиной RFID /// </summary> private async void Connect() { try { var pbCommunication = new PbCommunicationDescription(); var config = new ParametersValues(pbCommunication.GetClientConfiguration()); config.SetValue(ConfigConstants.PARAMETER_HOST, Settings.Default.BusHost); config.SetValue(ConfigConstants.PARAMETER_PORT, Settings.Default.BusPort); _client = new RfidBusClient(pbCommunication, config); if (!_client.Authorize(Settings.Default.BusLogin, Settings.Default.BusPassword)) { throw new BaseException(RfidErrorCode.InvalidLoginAndPassword); } _client.ReceivedEvent += RfidBusReceivedEvent; var result = await _client.SendRequestAsync(new GetLoadedRfidPrinters()); if (result.Status != ResponseStatus.Ok) { throw new BaseException(String.Format("Ошибка авторизации. Код статуса: {0}", result.Status)); } LoadedPrinters.Clear(); if (!result.RfidPrinters.Any()) { return; } foreach (var printer in result.RfidPrinters) { LoadedPrinters.Add(printer); } SelectedPrinter = LoadedPrinters.First(); } catch (Exception ex) { MessageBox.Show(String.Format("Не удалось установить соединение с шиной RFID. {0}", ex.Message)); } }
private void Initialize() { Console.WriteLine("Establishing connection to RFID Bus..."); var protocol = new PbCommunicationDescription(); var config = new ParametersValues(protocol.GetClientConfiguration()); config.SetValue(ConfigConstants.PARAMETER_HOST, "127.0.0.1"); config.SetValue(ConfigConstants.PARAMETER_PORT, 20000); this._client = new RfidBusClient(protocol, config) { AllowReconnect = true, RequestTimeOut = TimeSpan.FromSeconds(30), }; this._client.Connect(); if (!this._client.Authorize("admin", "admin")) throw new Exception("Invalid login-password."); Console.WriteLine("Connection established."); }
private void Initialize() { Console.WriteLine("Establishing connection to RFID Bus..."); var protocol = new PbCommunicationDescription(); var config = new ParametersValues(protocol.GetClientConfiguration()); config.SetValue(ConfigConstants.PARAMETER_HOST, "127.0.0.1"); config.SetValue(ConfigConstants.PARAMETER_PORT, 20000); this._client = new RfidBusClient(protocol, config) { AllowReconnect = true, RequestTimeOut = TimeSpan.FromSeconds(30), }; this._client.Connect(); if (!this._client.Authorize("admin", "admin")) { throw new Exception("Invalid login-password."); } Console.WriteLine("Connection established."); }
/// <summary> /// Метод выполняет соединения с шиной RFID /// </summary> private async void Connect() { try { var pbCommunication = new PbCommunicationDescription(); var config = new ParametersValues(pbCommunication.GetClientConfiguration()); config.SetValue(ConfigConstants.PARAMETER_HOST, Settings.Default.BusHost); config.SetValue(ConfigConstants.PARAMETER_PORT, Settings.Default.BusPort); _client = new RfidBusClient(pbCommunication, config); if (!_client.Authorize(Settings.Default.BusLogin, Settings.Default.BusPassword)) throw new BaseException(RfidErrorCode.InvalidLoginAndPassword); _client.ReceivedEvent += RfidBusReceivedEvent; var result = await _client.SendRequestAsync(new GetLoadedRfidPrinters()); if (result.Status != ResponseStatus.Ok) { throw new BaseException(String.Format("Ошибка авторизации. Код статуса: {0}", result.Status)); } LoadedPrinters.Clear(); if (!result.RfidPrinters.Any()) return; foreach (var printer in result.RfidPrinters) { LoadedPrinters.Add(printer); } SelectedPrinter = LoadedPrinters.First(); } catch (Exception ex) { MessageBox.Show(String.Format("Не удалось установить соединение с шиной RFID. {0}", ex.Message)); } }
private ChangeSet Eval(ColaNode node) { var canonical = node.Script.ToCanonicalCola(); var className = canonical.Substring(0, canonical.NthIndexOf(" ", 2)).Substring(4); // todo. regularly purge no more useful classes VM.Load(canonical); VM.Context["cc_values"] = _tempValues; VM.Context["cc_node"] = node; var changeset = new ChangeSet(() => _tempValues, v => { _tempValues = v; }).StartRecording(); try { VM.CreateEntryPoint(className, "Main").RunTillEnd(); } catch(ErroneousScriptException e) { // todo. a good idea would be to continue evaluation of everything that doesn't depend on this node var findings = InspectCompositionAndParameters(); throw new FatalFindingsException(new Findings( findings.Concat(new ScriptIsErroneousFactum(node, e).AsArray()))); } return changeset.Capture(); }
public ChangeSet Eval() { try { var findings = InspectCompositionAndParameters(); if (findings.AreFatal) { throw new FatalFindingsException(findings); } else { _tempValues = ParamValues; return ExecutionPlan.Aggregate( new ChangeSet(() => ParamValues, v => { ParamValues = v; }).StartRecording().Capture(), (curr, n) => curr.Merge(Eval(n))); } } catch(Exception e) { if (e is CocacolaException) throw; throw new UnexpectedCocacolaException(String.Format( "Unexpected error evaluating complex calculation. Reason: '{0}'.", e.Message), e); } }