public BIOSTable( BaseTable bt ) { if( bt.TableType != 0 ) //throw new ArgumentException( "Wrong TableType" ); return; HardwareType = bt.TableType; Handle = bt.Handle; if( bt.SMBIOSMinorVersion >= 0 ) { Vendor = bt.GetString( bt.Data.Read8Unchecked( 0x04 ) ); BIOSVersion = bt.GetString( bt.Data.Read8Unchecked( 0x05 ) ); BIOSStartingAddressSegment = bt.Data.Read16Unchecked( 0x08 ); BIOSReleaseDate = bt.GetString( bt.Data.Read8Unchecked( 0x08 ) ); BIOSROMSize = bt.Data.Read8Unchecked( 0x09 ); BIOSCharacteristics = bt.Data.Read64Unchecked( 0x0A ); BIOSCharacteristicsExtensionByteCount = (int)bt.TableLength - 0x13; BIOSCharacteristicsExtensionBytes = new byte[ BIOSCharacteristicsExtensionByteCount ]; for( uint i = 0; i < BIOSCharacteristicsExtensionByteCount; i++ ) bt.Data.Read8Unchecked( 0x12 + i ); SystemBIOSMajorRelease = bt.Data.Read8Unchecked( 0x14 ); SystemBIOSMinorRelease = bt.Data.Read8Unchecked( 0x15 ); EmbeddedControllerFirmwareMajorRelease = bt.Data.Read8Unchecked( 0x16 ); EmbeddedControllerFirmwareMinorRelease = bt.Data.Read8Unchecked( 0x17 ); } }
public ProcessorInformation( BaseTable bt ) { if( bt.TableType != (int) TableTypes.ProcessorInformation ) return; if( bt.SMBIOSMinorVersion >= 0 ) { Handle = bt.Handle; HardwareType = bt.TableType; SocketDesignation = bt.GetString( bt.Data.Read8Unchecked( 0x04 ) ); ProcessorType = bt.Data.Read8Unchecked( 0x05 ); ProcessorFamily = bt.Data.Read8Unchecked( 0x06 ); ProcessorManufacturer = bt.GetString( bt.Data.Read8Unchecked( 0x07 ) ); ProcessorID = bt.Data.Read64Unchecked( 0x08 ); ProcessorVersion = bt.GetString( bt.Data.Read8Unchecked( 0x10 ) ); Voltage = bt.Data.Read8Unchecked( 0x11 ); ExternalClock = bt.Data.Read16Unchecked( 0x12 ); MaxSpeed = bt.Data.Read16Unchecked( 0x14 ); CurrentSpeed = bt.Data.Read16Unchecked( 0x16 ); Status = bt.Data.Read8Unchecked( 0x18 ); ProcessorUpgrade = bt.Data.Read8Unchecked( 0x19 ); } else return; if( bt.SMBIOSMinorVersion >= 1 ) { L1CacheHandle = bt.Data.Read16Unchecked( 0x1A ); L2CacheHandle = bt.Data.Read16Unchecked( 0x1C ); L3CacheHandle = bt.Data.Read16Unchecked( 0x1E ); } else return; if( bt.SMBIOSMinorVersion >= 3 ) { SerialNumber = bt.GetString( bt.Data.Read8Unchecked( 0x20 ) ); AssetTag = bt.GetString( bt.Data.Read8Unchecked( 0x21 ) ); PartNumber = bt.GetString( bt.Data.Read8Unchecked( 0x22 ) ); } else return; if( bt.SMBIOSMinorVersion >= 5 ) { CoreCount = bt.Data.Read8Unchecked( 0x23 ); CoreEnabled = bt.Data.Read8Unchecked( 0x24 ); ThreadCount = bt.Data.Read8Unchecked( 0x25 ); ProcessorCharacteristics = bt.Data.Read16Unchecked( 0x26 ); } else return; if( bt.SMBIOSMinorVersion >= 6 ) { ProcessorFamily2 = bt.Data.Read16Unchecked( 0x28 ); } else return; }
public ImportDataItems(string path, Parser.FileTypes type, BaseTable bTable, ArrayList ddListSelected, ArrayList chkBoxList) { // // Add constructor logic here // this.DBTable = bTable; this.ColumnNameList = ddListSelected; this.ImportList = chkBoxList; this.FilePath = path; this.FileType = type; }
/// <inheritdoc /> public void Replace(Row row) => BaseTable.Replace(row);
/// <summary> /// Sets a database record values with values retrieved from data file. /// </summary> /// <param name="rowValues"></param> /// <param name="record"></param> private bool UpdateColumnValuesInRecord(string[] rowValues, IRecord record, bool isResolvedForeignKeysChecked) { int j = 0; bool isRecordUpdated = false; ColumnCount = 1; foreach (string data in rowValues) { ColumnCount++; if (j > this.ImportList.Count - 1) { return(isRecordUpdated); } try { if (this.ColumnNameList[j].ToString() != "" && ((CheckBox)this.ImportList[j]).Checked) { ForeignKey fkColumn = null; BaseColumn currentColumn = this.DBTable.TableDefinition.ColumnList.GetByAnyName((string)this.ColumnNameList[j]); if (isResolvedForeignKeysChecked) { fkColumn = this.DBTable.TableDefinition.GetForeignKeyByColumnName(currentColumn.InternalName); } String colValue = ""; // Check if the foreign key has DFKA. If so, then check the calue from csv file agains the DFKA column in the parent/foreign key table. // If a match is found retrieve its ID and set that as value to be insterted in the current table where you are adding records. if (fkColumn != null) { TableDefinition originalTableDef = fkColumn.PrimaryKeyTableDefinition; BaseTable originalBaseTable = originalTableDef.CreateBaseTable(); WhereClause wc = null; ArrayList records = new ArrayList(); BaseColumn pkColumn = (BaseColumn)originalTableDef.PrimaryKey.Columns[0];//Index is zero because we handle only those tables which has single PK column not composite keys. if (fkColumn.PrimaryKeyDisplayColumns != null && fkColumn.PrimaryKeyDisplayColumns != "" && (!fkColumn.PrimaryKeyDisplayColumns.Trim().StartsWith("="))) { wc = new WhereClause(originalTableDef.ColumnList.GetByAnyName(fkColumn.PrimaryKeyDisplayColumns), BaseFilter.ComparisonOperator.EqualsTo, data); } else if (fkColumn.PrimaryKeyDisplayColumns != null && fkColumn.PrimaryKeyDisplayColumns != "" && (fkColumn.PrimaryKeyDisplayColumns.Trim().StartsWith("="))) { string primaryKeyDisplay = GetDFKA(fkColumn); if (primaryKeyDisplay != null) { wc = new WhereClause(originalTableDef.ColumnList.GetByAnyName(primaryKeyDisplay), BaseFilter.ComparisonOperator.EqualsTo, data); } else { wc = new WhereClause(pkColumn, BaseFilter.ComparisonOperator.EqualsTo, data); } } else { // if the foreign key does not have DFKA then just check in the foreign key table if the id exists. If not create a record with the specified ID // before adding to current table wc = new WhereClause(pkColumn, BaseFilter.ComparisonOperator.EqualsTo, data); } BaseClasses.Data.BaseFilter join = null; records = originalBaseTable.GetRecordList(join, wc.GetFilter(), null, null, 0, 100); if (records.Count > 0) { // take the first record and retrieve its ID. BaseRecord rec = (BaseRecord)records[0]; colValue = (rec.GetValue(pkColumn)).ToString(); } else { // IF there is not match found then you have to create a record in the foreign key table with DFKA value and then retreive its ID if (data != null & data != "") { IRecord tempRec; if (fkColumn.PrimaryKeyDisplayColumns != null && fkColumn.PrimaryKeyDisplayColumns != "" && (!fkColumn.PrimaryKeyDisplayColumns.Trim().StartsWith("="))) { tempRec = originalBaseTable.CreateRecord(); TableDefinition tableDef = originalBaseTable.TableDefinition; foreach (BaseColumn newCol in tableDef.Columns) { if (fkColumn.PrimaryKeyDisplayColumns == newCol.InternalName) { tempRec.SetValue(data, newCol.UniqueName); } } } else { tempRec = originalBaseTable.CreateRecord(data); } tempRec.Save(); colValue = (tempRec.GetValue(pkColumn)).ToString(); } // colValue = data; } } else { colValue = data; } // set the table row's column for value record.SetValue(colValue, currentColumn.UniqueName); isRecordUpdated = true; } j++; } catch (Exception ex) { throw new Exception(ex.InnerException.Message); } } return(isRecordUpdated); }
/// <summary> /// Clones output channels. /// </summary> private bool CloneCtrlCnls(int srcStartNum, int srcEndNum, int destStartNum, int replaceObjNum, int replaceKpNum, bool updateFormulas) { try { BaseTable <CtrlCnl> ctrlCnlTable = configBase.CtrlCnlTable; int affectedRows = 0; if (srcStartNum <= srcEndNum) { // create new channels int shiftNum = destStartNum - srcStartNum; List <CtrlCnl> cnlsToAdd = new List <CtrlCnl>(srcEndNum - srcStartNum + 1); foreach (CtrlCnl ctrlCnl in ctrlCnlTable.Items.Values) { int ctrlCnlNum = ctrlCnl.CtrlCnlNum; if (srcStartNum <= ctrlCnlNum && ctrlCnlNum <= srcEndNum) { int newCnlNum = ctrlCnlNum + shiftNum; if (newCnlNum <= AdminUtils.MaxCnlNum && !ctrlCnlTable.PkExists(newCnlNum)) { CtrlCnl newCtrlCnl = ScadaUtils.DeepClone(ctrlCnl); newCtrlCnl.CtrlCnlNum = newCnlNum; if (replaceObjNum >= 0) { newCtrlCnl.ObjNum = replaceObjNum > 0 ? replaceObjNum : (int?)null; } if (replaceKpNum >= 0) { newCtrlCnl.KPNum = replaceKpNum > 0 ? replaceKpNum : (int?)null; } if (updateFormulas) { newCtrlCnl.Formula = UpdateFormula(newCtrlCnl.Formula, shiftNum); } cnlsToAdd.Add(newCtrlCnl); } } else if (ctrlCnlNum > srcEndNum) { break; } } // add the created channels foreach (CtrlCnl ctrlCnl in cnlsToAdd) { ctrlCnlTable.AddItem(ctrlCnl); } affectedRows = cnlsToAdd.Count; } if (affectedRows > 0) { ctrlCnlTable.Modified = true; } ScadaUiUtils.ShowInfo(string.Format(AppPhrases.CloneCnlsComplete, affectedRows)); return(true); } catch (Exception ex) { appData.ProcError(ex, AppPhrases.CloneCtrlCnlsError); return(false); } }
public string Execute(GDbTab core, string code) { MemoryStream stream = new MemoryStream(); string output = ""; _core = core; Script script = new Script(); try { TableHelper.EnableTupleTrace = true; if (_core == null) { throw new Exception("No database tab selected."); } _selected = new ObservableList <Tuple>(); foreach (var tuple in _core._listView.SelectedItems.OfType <Tuple>().OrderBy(p => p)) { _selected.Add(tuple); } _selectionChanged = false; _selected.CollectionChanged += delegate { _selectionChanged = true; }; _mEngine.Runtime.IO.SetOutput(stream, EncodingService.DisplayEncoding); _mEngine.Runtime.IO.SetErrorOutput(stream, EncodingService.DisplayEncoding); _mScope = _mEngine.CreateScope(); List <object> dbs = new List <object>(); foreach (var serverDb in ServerDbs.ListDbs) { var db = _core.DbComponent.TryGetDb(serverDb); if (db != null) { if (db.AttributeList.PrimaryAttribute.DataType == typeof(int)) { var adb = (AbstractDb <int>)db; dbs.Add(adb); TableHelper.Tables.Add(adb.Table); _mScope.SetVariable(serverDb.Filename.ToLower().Replace(" ", "_"), adb.Table); } else if (db.AttributeList.PrimaryAttribute.DataType == typeof(string)) { var adb = (AbstractDb <string>)db; dbs.Add(adb); TableHelper.Tables.Add(adb.Table); _mScope.SetVariable(serverDb.Filename.ToLower().Replace(" ", "_"), adb.Table); } } } _mScope.SetVariable("item_db_m", _core.DbComponent.GetMeta <int>(ServerDbs.Items)); _mScope.SetVariable("mob_db_m", _core.DbComponent.GetMeta <int>(ServerDbs.Mobs)); _mScope.SetVariable("mob_skill_db_m", _core.DbComponent.GetMeta <string>(ServerDbs.MobSkills)); _mScope.SetVariable("selection", _selected); _mScope.SetVariable("database", _core.ProjectDatabase); _mScope.SetVariable("script", script); //_mScope.SetVariable("ServerDbs", DynamicHelpers.GetPythonTypeFromType(typeof(ServerDbs))); _selectedDb = null; _to <int>(_core.DbComponent, p => { _selectedDb = p.Table; _mScope.SetVariable("selected_db", p.Table); }); _to <string>(_core.DbComponent, p => { _selectedDb = p.Table; _mScope.SetVariable("selected_db", p.Table); }); string temp = TemporaryFilesManager.GetTemporaryFilePath("python_script_{0:0000}.py"); byte[] file = File.ReadAllBytes(code); Encoding encoding = EncodingService.DetectEncoding(file); using (StreamWriter writer = new StreamWriter(File.Create(temp), encoding)) using (StreamReader reader = new StreamReader(code)) { writer.WriteLine("#!/usr/bin/env python"); writer.WriteLine("# -*- coding: {0} -*- ", encoding.CodePage); while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line == null) { continue; } writer.WriteLine(EncodingService.FromAnyTo(line, encoding)); } } ScriptSource source = _mEngine.CreateScriptSourceFromFile(temp); foreach (var db in dbs) { _to <int>(db, _onBegin); _to <string>(db, _onBegin); } try { try { source.Execute(_mScope); } catch (OperationCanceledException) { } if (stream.Position > 0) { stream.Seek(0, SeekOrigin.Begin); byte[] data = new byte[stream.Length]; stream.Read(data, 0, data.Length); output = EncodingService.DisplayEncoding.GetString(data); Clipboard.SetDataObject(EncodingService.DisplayEncoding.GetString(data)); } } catch { foreach (var db in dbs) { _to <int>(db, p => p.Table.Commands.CancelEdit()); _to <string>(db, p => p.Table.Commands.CancelEdit()); } throw; } finally { foreach (var db in dbs) { _to <int>(db, _onEnd); _to <string>(db, _onEnd); } stream.Close(); _core.Filter(); _core.Update(); } } catch (Exception err) { ErrorHandler.HandleException(err); } finally { TableHelper.EnableTupleTrace = false; TableHelper.Tables.Clear(); } return(output); }
/// <summary> /// Generates the source code to compile. /// </summary> private string GenerateSourceCode(BaseTable <Cnl> cnlTable, BaseTable <Script> scriptTable, HashSet <int> enableFormulasObjNums, out Dictionary <int, string> cnlClassNames) { cnlClassNames = new Dictionary <int, string>(); StringBuilder sourceCode = new StringBuilder(); sourceCode.AppendLine("using Scada.Data.Const;"); sourceCode.AppendLine("using Scada.Data.Models;"); sourceCode.AppendLine("using System;"); sourceCode.AppendLine("using System.Collections.Generic;"); sourceCode.AppendLine("using System.IO;"); sourceCode.AppendLine("using System.Linq;"); sourceCode.AppendLine("using System.Text;"); sourceCode.AppendLine("using static System.Math;"); sourceCode.AppendLine(); sourceCode.AppendLine("namespace Scada.Server.Engine {"); // add scripts sourceCode.AppendLine("public class Scripts : CalcEngine {"); foreach (Script script in scriptTable.EnumerateItems()) { sourceCode .Append("/********** ").Append(script.Name).AppendLine(" **********/") .AppendLine(script.Source); } sourceCode.AppendLine("}").AppendLine(); // definitions for creating classes that implement formulas int cnlCnt = 0; int classCnt = 0; string className = ""; void AddNewClass() { if (classCnt == 0 || cnlCnt == MaxCnlCntInClass) { if (classCnt > 0) { sourceCode.AppendLine("}"); } classCnt++; cnlCnt = 0; className = "Formulas" + classCnt; sourceCode.Append("public class ").Append(className).AppendLine(" : Scripts {"); } } // add formulas foreach (Cnl cnl in cnlTable.EnumerateItems()) { if (cnl.Active && cnl.FormulaEnabled && (enableFormulasObjNums == null || cnl.ObjNum.HasValue && enableFormulasObjNums.Contains(cnl.ObjNum.Value))) { bool inFormulaExists = !string.IsNullOrEmpty(cnl.InFormula); bool outFormulaExists = !string.IsNullOrEmpty(cnl.OutFormula); if (inFormulaExists || outFormulaExists) { AddNewClass(); cnlClassNames[cnl.CnlNum] = className; cnlCnt++; if (inFormulaExists) { AddInFormulaMethod(sourceCode, cnl.CnlNum, cnl.InFormula); } if (outFormulaExists) { AddOutFormulaMethod(sourceCode, cnl.CnlNum, cnl.OutFormula); } } } } // close the last class if (classCnt > 0) { sourceCode.AppendLine("}"); } // close namespace sourceCode.AppendLine("}"); return(sourceCode.ToString()); }
public ExportDataToCSV(BaseTable tbl, WhereClause wc, OrderBy orderBy, BaseColumn[] columns, String header) : base(header) { data = new DataForExport(tbl, wc, orderBy, columns); }
/// <summary> /// Generates the source code to compile. /// </summary> private string GenerateSourceCode( BaseTable <InCnl> inCnlTable, BaseTable <OutCnl> outCnlTable, BaseTable <Script> scriptTable, out Dictionary <int, string> inCnlClassNames, out Dictionary <int, string> outCnlClassNames) { inCnlClassNames = new Dictionary <int, string>(); outCnlClassNames = new Dictionary <int, string>(); StringBuilder sourceCode = new StringBuilder(); sourceCode.AppendLine("using Scada.Data.Const;"); sourceCode.AppendLine("using Scada.Data.Models;"); sourceCode.AppendLine("using System;"); sourceCode.AppendLine("using System.Collections.Generic;"); sourceCode.AppendLine("using System.IO;"); sourceCode.AppendLine("using System.Linq;"); sourceCode.AppendLine("using System.Text;"); sourceCode.AppendLine("using static System.Math;"); sourceCode.AppendLine(); sourceCode.AppendLine("namespace Scada.Server.Engine {"); // add scripts sourceCode.AppendLine("public class Scripts : CalcEngine {"); foreach (Script script in scriptTable.EnumerateItems()) { sourceCode .Append("/********** ").Append(script.Name).AppendLine(" **********/") .AppendLine(script.Source); } sourceCode.AppendLine("}").AppendLine(); // definitions for creating classes that implement formulas int cnlCnt = 0; int classCnt = 0; string className = ""; void AddNewClass() { if (classCnt == 0 || cnlCnt == MaxCnlCntInClass) { if (classCnt > 0) { sourceCode.AppendLine("}"); } classCnt++; cnlCnt = 0; className = "Formulas" + classCnt; sourceCode.Append("public class ").Append(className).AppendLine(" : Scripts {"); } } // add formulas of input channels foreach (InCnl inCnl in inCnlTable.EnumerateItems()) { if (inCnl.FormulaEnabled && !string.IsNullOrEmpty(inCnl.Formula)) { AddNewClass(); inCnlClassNames[inCnl.CnlNum] = className; AddInCnlMethod(sourceCode, inCnl.CnlNum, inCnl.Formula); cnlCnt++; } } // add formulas of output channels foreach (OutCnl outCnl in outCnlTable.EnumerateItems()) { if (outCnl.FormulaEnabled && !string.IsNullOrEmpty(outCnl.Formula)) { AddNewClass(); outCnlClassNames[outCnl.OutCnlNum] = className; AddOutCnlMethod(sourceCode, outCnl.OutCnlNum, outCnl.Formula); cnlCnt++; } } // close the last class if (classCnt > 0) { sourceCode.AppendLine("}"); } // close namespace sourceCode.AppendLine("}"); return(sourceCode.ToString()); }
public static void Write(Stream stream, List <Entry> entries) => BaseTable <Entry> .Write(stream, 1, entries);
public static List <Btlv> Read(Stream stream) => BaseTable <Btlv> .Read(stream);
public void HasRightEntryCount() => Common.FileOpenRead("kh2/res/00objentry.bin", stream => { var table = BaseTable <Objentry> .Read(stream); Assert.Equal(0x076C, table.Count); });
public static List <Cmd> Read(Stream stream) => BaseTable <Cmd> .Read(stream);
/// <summary> /// Clones channels with the specified parameters. /// </summary> private bool CloneChannels(int srcStartNum, int srcEndNum, int destStartNum, int replaceObjNum, int replaceDeviceNum, bool updateFormulas) { try { BaseTable <Cnl> cnlTable = configDatabase.CnlTable; int affectedRows = 0; if (srcStartNum <= srcEndNum) { // create new channels ExtensionUtils.NormalizeIdRange(ConfigDatabase.MinID, ConfigDatabase.MaxID, ref srcStartNum, ref srcEndNum, destStartNum, out int numOffset); List <Cnl> cnlsToAdd = new(srcEndNum - srcStartNum + 1); foreach (Cnl cnl in cnlTable.EnumerateItems()) { if (cnl.CnlNum < srcStartNum) { continue; } else if (cnl.CnlNum > srcEndNum) { break; } else if (!cnlTable.PkExists(cnl.CnlNum + numOffset)) { Cnl newCnl = ScadaUtils.DeepClone(cnl); newCnl.CnlNum = cnl.CnlNum + numOffset; if (replaceObjNum >= 0) { newCnl.ObjNum = replaceObjNum > 0 ? replaceObjNum : null; } if (replaceDeviceNum >= 0) { newCnl.DeviceNum = replaceDeviceNum > 0 ? replaceDeviceNum : null; } if (updateFormulas) { newCnl.InFormula = UpdateFormula(newCnl.InFormula, numOffset); newCnl.OutFormula = UpdateFormula(newCnl.OutFormula, numOffset); } cnlsToAdd.Add(newCnl); } } // add created channels cnlsToAdd.ForEach(cnl => cnlTable.AddItem(cnl)); affectedRows = cnlsToAdd.Count; } if (affectedRows > 0) { cnlTable.Modified = true; } ScadaUiUtils.ShowInfo(string.Format(ExtensionPhrases.CloneChannelsCompleted, affectedRows)); return(true); } catch (Exception ex) { adminContext.ErrLog.HandleError(ex, ExtensionPhrases.CloneChannelsError); return(false); } }
} //don't use this one! public ExportDataToExcel(BaseTable tbl, WhereClause wc, OrderBy orderBy) : base() { data = new DataForExport(tbl, wc, orderBy, null); }
public ExportDataToCSV(BaseTable tbl, WhereClause wc, OrderBy orderBy, String header) : base(header) { data = new DataForExport(tbl, wc, orderBy, null); }
/// <inheritdoc /> public Row GetRow(Search search = null, ResultOption resultOption = null) => BaseTable.GetRow(search, resultOption);
public static void Write(Stream stream, IEnumerable <Plrp> items) => BaseTable <Plrp> .Write(stream, 1, items);
public static void Write(Stream stream, IEnumerable <Cmd> entries) => BaseTable <Cmd> .Write(stream, 2, entries);
void OnActiveElementChanged(object sender, BaseTable.ChangedEventsArgs e) { Control c = (Control)e._new; // Для робберного бриджа: if (this.isRobber) { // Определить № роббера: int robNo = -1; if (HeadlinesScores_Controls.Contains(c)) { robNo = HeadlinesScores_Controls.IndexOf(c); } else { for (int i = 0; i < CONTROLS.Count; i++) { if (CONTROLS[i].Contains(c)) { robNo = ROBBERS.GetRobberNo(i); break; } } } // Показать роббер: if (robNo == -1) CONTROL_ROBBER.DetachData(); else CONTROL_ROBBER.AttachData(ROBBERS[robNo]); } }
public static void Write(Stream stream, IEnumerable <Atkp> items) => BaseTable <Atkp> .Write(stream, 6, items);
public static List <Lvpm> Read(Stream stream) => BaseTable <Lvpm> .Read(stream);
public ActionResult CodesTable(int countryId, string R = "0") { List <BaseTable> UIcodesTable = new List <BaseTable>(); BaseTable table = null; // init table with default values for (int i = 0; i < 100; ++i) { table = new BaseTable { R = R, AB = i < 10 ? $"0{i}" : $"{i}" }; for (int j = 0; j < 10; ++j) { table.codes[j] = new CodeDt() { code = $"{table.AB}{j}" }; } UIcodesTable.Add(table); } Country country = db.Countries.Find(countryId); ICollection <Code> countryCodes = country.Codes; // paint cells with roots colors if (R.Length > 1) { foreach (var ABrow in UIcodesTable) { IEnumerable <Code> rootCodes = null; string RAB; for (int i = 1; i < R.Length; i++) { RAB = R + ABrow.AB; if (i > 1) { RAB = RAB.Remove(RAB.Length - i + 1); } RAB = RAB.Substring(RAB.Length - 3); rootCodes = countryCodes.Where(code => code.R == R.Remove(R.Length - i) && code.Value.Equals(RAB)); if (rootCodes.Count() > 0) { break; } } if (rootCodes.Count() > 0) { foreach (var rootCode in rootCodes) { char lastDigit = rootCode.Value[rootCode.Value.Length - 1] == ' ' ? rootCode.Value[rootCode.Value.Length - 2] : rootCode.Value[rootCode.Value.Length - 1]; for (int i = 0; i < 10; ++i) { if (lastDigit == i.ToString()[0]) { for (int k = 0; k < 10; k++) { ABrow.codes[k].colorHEX = rootCode.Network.Color.Hex; ABrow.codes[k].id = -rootCode.Id; } } continue; } } } } } // fill table with codes IEnumerable <Code> codesOfR = countryCodes.Where(code => code.R == R); if (codesOfR.Count() > 0) { foreach (var ABrow in UIcodesTable) { foreach (var cell in ABrow.codes) { Code code = codesOfR.FirstOrDefault(_code => _code.Value == cell.code); if (code != null) { cell.colorHEX = code.Network.Color.Hex; cell.id = code.Id; } } } } // paint cells with inherited codes colors IEnumerable <Code> inheritedCodes = null; foreach (var ABrow in UIcodesTable) { foreach (var cell in ABrow.codes) { inheritedCodes = countryCodes.Where(code => $"{code.R}{code.Value}".StartsWith(R + cell.code)); if (inheritedCodes.Count() == 0) { continue; } string colorHEX = null; foreach (var code in inheritedCodes) { if (cell.colorHEX == "#FFFFFF") { colorHEX = greyColorHEX; break; } if (colorHEX == null) { colorHEX = code.Network.Color.Hex; } else if (colorHEX != code.Network.Color.Hex) { colorHEX = greyColorHEX; break; } } cell.colorHEX = colorHEX; } } return(PartialView(UIcodesTable)); }
public static void Write(Stream stream, IEnumerable <Lvpm> items) => BaseTable <Lvpm> .Write(stream, 2, items);
public HttpResponseMessage PostTable([FromBody] BaseTable table) { var user = db.Users.Single(u => u.UserName == User.Identity.Name); return(PostTable(table, user)); }
public static List <Vtbl> Read(Stream stream) => BaseTable <Vtbl> .Read(stream);
public JsonResult Save(BaseTable model, FormCollection form) { try { if (model.id != 0) { BoolString validation = model.BeforeEdit(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } db.Entry(model).State = System.Data.Entity.EntityState.Modified; validation = model.BeforeSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } validation = model.BeforeEdit(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } db.SaveChanges(); validation = model.AfterSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } validation = model.AfterEdit(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } } else { BoolString validation = model.BeforeSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } validation = model.BeforeCreate(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } db.BaseTables.Add(model); db.SaveChanges(); validation = model.AfterSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } validation = model.AfterCreate(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } } return(Json(new { id = model.id, MessageSucess = "That Table saved successfully." })); } catch (Exception ex) { return(Json(new { Message = Helper.ModeralException(ex).Replace("@table", "Table") })); } }
public ExportData(BaseTable tbl, WhereClause wc, OrderBy orderBy) { _exportDataToCSV = new ExportDataToCSV(tbl, wc, orderBy); _exportDataToExcel = new ExportDataToExcel(tbl, wc, orderBy); }
public static List <Atkp> Read(Stream stream) => BaseTable <Atkp> .Read(stream);
public DataForExport(BaseTable tbl, WhereClause wc, OrderBy orderBy, BaseColumn[] columns, BaseFilter join) { this.DBTable = tbl; this.SelectWhereClause = wc; this.SelectOrderBy = orderBy; this.SelectJoin = join; if (columns != null) ColumnList.AddRange(columns); }
internal void Update(BaseTable entry) { sqlConnection.Update(entry); }
public ExportDataToCSV(BaseTable tbl, WhereClause wc, OrderBy orderBy, BaseColumn[] columns, String header) : base(header) { data = new DataForExport(tbl, wc, orderBy, columns); }
/// <summary> /// Creates channels based on the prototypes. /// </summary> private bool CreateChannels() { try { List <KPView.InCnlPrototype> inCnlPrototypes = ctrlCnlCreate1.CnlPrototypes.InCnls; List <KPView.CtrlCnlPrototype> ctrlCnlPrototypes = ctrlCnlCreate1.CnlPrototypes.CtrlCnls; int? objNum = ctrlCnlCreate2.ObjNum; int kpNum = ctrlCnlCreate1.SelectedDevice.KPNum; string cnlPrefix = ctrlCnlCreate1.SelectedDevice.Name + " - "; int inCnlNum = ctrlCnlCreate3.StartInCnl; int ctrlCnlNum = ctrlCnlCreate3.StartOutCnl; int inCnlsAdded = 0; int ctrlCnlsAdded = 0; BaseTable <InCnl> inCnlTable = project.ConfigBase.InCnlTable; BaseTable <CtrlCnl> ctrlCnlTable = project.ConfigBase.CtrlCnlTable; BaseTable <Format> formatTable = project.ConfigBase.FormatTable; DictIndexes dictIndexes = new DictIndexes(project.ConfigBase); // create output channels foreach (KPView.CtrlCnlPrototype ctrlCnlPrototype in ctrlCnlPrototypes) { ctrlCnlPrototype.CtrlCnlNum = ctrlCnlNum; CtrlCnl ctrlCnl = new CtrlCnl { CtrlCnlNum = ctrlCnlNum++, Active = ctrlCnlPrototype.Active, Name = cnlPrefix + ctrlCnlPrototype.CtrlCnlName, CmdTypeID = ctrlCnlPrototype.CmdTypeID, ObjNum = objNum, KPNum = kpNum, CmdNum = ctrlCnlPrototype.CmdNum > 0 ? (int?)ctrlCnlPrototype.CmdNum : null, CmdValID = dictIndexes.GetID(dictIndexes.CmdValByName, ctrlCnlPrototype.CmdVal), FormulaUsed = ctrlCnlPrototype.FormulaUsed, Formula = ctrlCnlPrototype.Formula, EvEnabled = ctrlCnlPrototype.EvEnabled }; if (ctrlCnl.Name.Length > ColumnLength.Name) { ctrlCnl.Name = ctrlCnl.Name.Substring(0, ColumnLength.Name); } ctrlCnlTable.AddItem(ctrlCnl); ctrlCnlsAdded++; if (ctrlCnlNum > ushort.MaxValue) { break; } } if (ctrlCnlsAdded > 0) { ctrlCnlTable.Modified = true; } // create input channels foreach (KPView.InCnlPrototype inCnlPrototype in inCnlPrototypes) { int formatID = inCnlPrototype.ShowNumber ? Math.Min(inCnlPrototype.DecDigits, BaseValues.Formats.MaxFixedID) : BaseValues.Formats.EnumText; InCnl inCnl = new InCnl { CnlNum = inCnlNum++, Active = inCnlPrototype.Active, Name = cnlPrefix + inCnlPrototype.CnlName, CnlTypeID = inCnlPrototype.CnlTypeID, ObjNum = objNum, KPNum = kpNum, Signal = inCnlPrototype.Signal > 0 ? (int?)inCnlPrototype.Signal : null, FormulaUsed = inCnlPrototype.FormulaUsed, Formula = inCnlPrototype.Formula, Averaging = inCnlPrototype.Averaging, ParamID = dictIndexes.GetID(dictIndexes.ParamByName, inCnlPrototype.ParamName), FormatID = formatTable.PkExists(formatID) ? (int?)formatID : null, UnitID = dictIndexes.GetID(dictIndexes.UnitByName, inCnlPrototype.UnitName), CtrlCnlNum = inCnlPrototype.CtrlCnlProps?.CtrlCnlNum, EvEnabled = inCnlPrototype.EvEnabled, EvSound = inCnlPrototype.EvSound, EvOnChange = inCnlPrototype.EvOnChange, EvOnUndef = inCnlPrototype.EvOnUndef, LimLowCrash = double.IsNaN(inCnlPrototype.LimLowCrash) ? null : (double?)inCnlPrototype.LimLowCrash, LimLow = double.IsNaN(inCnlPrototype.LimLow) ? null : (double?)inCnlPrototype.LimLow, LimHigh = double.IsNaN(inCnlPrototype.LimHigh) ? null : (double?)inCnlPrototype.LimHigh, LimHighCrash = double.IsNaN(inCnlPrototype.LimHighCrash) ? null : (double?)inCnlPrototype.LimHighCrash }; if (inCnl.Name.Length > ColumnLength.Name) { inCnl.Name = inCnl.Name.Substring(0, ColumnLength.Name); } inCnlTable.AddItem(inCnl); inCnlsAdded++; if (inCnlNum > ushort.MaxValue) { break; } } if (inCnlsAdded > 0) { inCnlTable.Modified = true; } ScadaUiUtils.ShowInfo(string.Format(AppPhrases.CreateCnlsComplete, inCnlsAdded, ctrlCnlsAdded)); return(true); } catch (Exception ex) { appData.ProcError(ex, AppPhrases.CreateCnlsError); return(false); } }
public ExportDataToCSV(BaseTable tbl, WhereClause wc, OrderBy orderBy, String header) : base(header) { data = new DataForExport(tbl, wc, orderBy, null); }
/// <inheritdoc /> public int TryDelete(Search search) => BaseTable.TryDelete(search);
public ExportDataToExcel(BaseTable tbl, WhereClause wc, OrderBy orderBy) : base() { data = new DataForExport(tbl, wc, orderBy, null); }
/// <inheritdoc /> public void Replace(IEnumerable <Row> rows) => BaseTable.Replace(rows);
public ExportData(BaseTable tbl, WhereClause wc, OrderBy orderBy, BaseColumn[] columns) { _exportDataToCSV = new ExportDataToCSV(tbl, wc, orderBy, columns); }
/// <inheritdoc /> public IList <Row> GetRows() => BaseTable.GetRows();
public static List <Entry> Read(Stream stream) => BaseTable <Entry> .Read(stream);