public JsonResult GetTechniqueData(DataSource source = DataSource.Old) { var attempts = AttemptRepository.GetAttempts(source); var count = AttemptRepository.GetTestCount(source); var info = new TechniqueInformationViewModel(attempts, count); return Json(info, JsonRequestBehavior.AllowGet); }
public static TestDataViewModel GetTest(string id, DataSource source) { if(id == "average") { return GetTest(source); } if (TestViewModels.ContainsKey(id)) { return TestViewModels[id]; } TestViewModels.Add(id, new TestDataViewModel(id)); TestViewModels[id].GestureInformation = new Dictionary<string, GestureInfo>(); if (!Tests.ContainsKey(id)) { Tests[id] = AttemptRepository.GetTest(id, source); } foreach (var gesture in AllGestures) { GestureInfo info = new GestureInfo(); var hitsPerTry = MathHelper.GetHitsPerTry(Tests[id].Attempts[gesture]); info.HitData = GetJSPercentageArray(hitsPerTry, gesture); info.TimeData = GetJSTimeArray(MathHelper.GetTimePerTarget(Tests[id].Attempts[gesture]), gesture); info.HitPercentage = hitsPerTry.Last() * 100f; TestViewModels[id].GestureInformation[GetGestureTypeString(gesture)] = info; } return TestViewModels[id]; }
public void Parse(string path) { _workingSource = new DataSource(FileMap.FromFile(path)); short tag = *(short*)_workingSource.Address; if (tag != 0x666f) return; _version = *(short*)(_workingSource.Address + 0x02); _entryCount = *(int*)(_workingSource.Address + 0x04); Entries = new SortedList<uint, LSEntryObject>(_entryCount); for (int i = 0; i < _entryCount; i++) { LSEntryObject lsobj = new LSEntryObject(); if (Version == 1) { LSEntry_v1 entry = *(LSEntry_v1*)(_workingSource.Address + 0x08 + (i * 0x0C)); lsobj.FileNameCRC = entry._crc; lsobj.DTOffset = entry._start; lsobj.Size = entry._size; } else if (Version == 2) { LSEntry_v2 entry = *(LSEntry_v2*)(_workingSource.Address + 0x08 + (i * 0x10)); lsobj.FileNameCRC = entry._crc; lsobj.DTOffset = entry._start; lsobj.Size = entry._size; lsobj.DTIndex = entry._dtIndex; lsobj.PaddingLength = entry._padlen; } Entries.Add(lsobj.FileNameCRC, lsobj); } }
public XCdwConnection(DataSource ds) : base(ds) { SaveToFile = false; MockXmlSource xml = new MockXmlSource(ds.SiteId.Id); }
public static void FixExtensionsInvalidity(DataSource source) { string[] files = Directory.GetFiles(DataGenerator.TestFileDirectory(source) + "/invalidity", "*txt"); foreach (var file in files) { string n = DataGenerator.TestFileDirectory(source) + "/invalidity/" + file.Split('\\').Last().Split('.')[0] + ".invalidity"; File.Move(file, n); } }
public void TestFixtureSetup() { _src = new DataSource() { ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mhv.va.gov)(PORT=1))(CONNECT_DATA=(SERVICE_NAME=sid)));User ID=user;Password=password;" }; _cxn = new MdoOracleConnection(_src); }
public MySQLJDBCIDMigrator(DataSource dataSource, String mappingTable, String longIDColumn, String stringIDColumn) { super(dataSource, "SELECT " + stringIDColumn + " FROM " + mappingTable + " WHERE " + longIDColumn + "=?", "INSERT IGNORE INTO " + mappingTable + " (" + longIDColumn + ',' + stringIDColumn + ") VALUES (?,?)"); }
public ContentResult GetAttemptData(DataSource source) { var tests = AttemptRepository.GetTests(source); var attemptInfos = new List<AttemptInfo>(); attemptInfos.Add(new AttemptInfo(tests, GestureDirection.Pull)); attemptInfos.Add(new AttemptInfo(tests, GestureDirection.Push)); var json = $"{{\"Pull\": {JsonConvert.SerializeObject(attemptInfos[0])}, \"Push\": {JsonConvert.SerializeObject(attemptInfos[1])}}}"; return Content(json, "application/json"); }
public XSqliteConnection(DataSource src) : base(src) { if (src == null || String.IsNullOrEmpty(src.ConnectionString)) { throw new ArgumentNullException("Must supply a connection string"); } _src = src; _cxn = new SQLiteConnection(src.ConnectionString); }
public RFFile(string filename) { DataSource cmpSource = new DataSource(FileMap.FromFile(filename)); byte[] header = cmpSource.Slice(0, 0x80); byte[] filedata = Util.DeCompress(cmpSource.Slice(0x80, cmpSource.Length - 0x80)); File.WriteAllBytes($"{filename}.dec", header.Concat(filedata).ToArray()); cmpSource.Close(); Parse($"{filename}.dec"); }
public ACMDFile(DataSource source, Endianness endian) { WorkingSource = source; Endian = endian; _actionCount = Util.GetWordUnsafe(source.Address + 0x08, endian); _commandCount = Util.GetWordUnsafe(source.Address + 0x0C, endian); Initialize(); }
public void Login(KZApplication.OnEventHandler onAuthFinish) { #if __ANDROID__ this.kidozenApplication.Authenticate (App.AndroidContext, onAuthFinish); #else this.kidozenApplication.Authenticate (onAuthFinish); #endif database = kidozenApplication.Storage["todo"]; queryDataSource = kidozenApplication.DataSource["QueryTodo"]; saveDataSource = kidozenApplication.DataSource["AddTodo"]; }
public PACKManager(string path) { _source = new DataSource(FileMap.FromFile(path)); string magic = new String((sbyte*)_source.Address); if (magic == "PACK") _endian = Endianness.little; else if (magic == "KCAP") _endian = Endianness.big; else Console.WriteLine("Not a valid PACK file"); }
/// <summary> /// Applies changes. /// </summary> public void Rebuild() { FileMap temp = FileMap.FromTempFile(Size); // Write changes to the new filemap. OnRebuild(temp.Address, temp.Length); // Close backing source. _replSource.Close(); // set backing source to new source from temp map. _replSource = new DataSource(temp.Address, temp.Length) { Map = temp }; // Set backing source's map to the temp map. }
public ACMDFile(DataSource source, Endianness endian) { _eventLists = new SortedList<uint, CommandList>(); _hashPairs = new Dictionary<uint, string>(); Type = ACMDType.NONE; _workingSource = source; Endian = endian; _actionCount = Util.GetWordUnsafe(source.Address + 0x08, endian); _commandCount = Util.GetWordUnsafe(source.Address + 0x0C, endian); Initialize(); }
public ActionResult Index(DataSource? source) { if (source == null) { var cookie = Request.Cookies["source"]; if (IsValidCookie(cookie)) { ViewBag.Source = cookie.Value; } else { ViewBag.Source = "Old"; } } else ViewBag.Source = source; return View(); }
public VistaConnection(DataSource dataSource) : base(dataSource) { Account = new VistaAccount(this); if (ConnectTimeout == 0) { ConnectTimeout = CONNECTION_TIMEOUT; } if (ReadTimeout == 0) { ReadTimeout = READ_TIMEOUT; } port = (dataSource.Port == 0) ? DEFAULT_PORT : dataSource.Port; sysFileHandler = new VistaSystemFileHandler(this); }
public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. NavigationItem.LeftBarButtonItem = EditButtonItem; var addButton = new UIBarButtonItem (UIBarButtonSystemItem.Refresh, RefreshData); addButton.AccessibilityLabel = "Refresh"; NavigationItem.RightBarButtonItem = addButton; DetailViewController = (DetailViewController)((UINavigationController)SplitViewController.ViewControllers [1]).TopViewController; TableView.Source = dataSource = new DataSource (this); }
public ActionResult GetImage(string testId, GestureType type, DataSource source = DataSource.Old) { List<Attempt> attempts = new List<Attempt>(); if(testId != "average") { attempts = AttemptRepository.GetTest(testId, source).Attempts[type]; } else { var tests = AttemptRepository.GetTests(source); foreach(var test in tests) { attempts.AddRange(test.Attempts[type]); } } MemoryStream ms; DataVisualizer.DrawHitBox(attempts, out ms); return File(ms, "image/png"); }
public static void Intialize(int sHeight, int sWidth, int lHeight, int lWidth, double cnvasHeight, double cnvasWidth, DataSource source) { directory = DataGenerator.TestFileDirectory(source); if (CurrentLogger == null) { CurrentLogger = new Logger(); CurrentLogger.DebugMode = false; } if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } sgHeight = sHeight; sgWidth = sWidth; lgHeight = lHeight; lgWidth = lWidth; canvasHeight = cnvasHeight; canvasWidth = cnvasWidth; }
public bool CreateReport(string name, byte[] definition, string path = null) { string batchId = null; client.CreateBatch(out batchId); Warning[] warnings = null; var result = client.CreateReport( new BatchHeader() { BatchID = batchId }, name, path ?? "/", true, definition, new Property[0], out warnings); string reportPath = string.Format("/{0}/{1}", path.Trim('/'), name); DataSourceReference reference = new DataSourceReference(); reference.Reference = "/libservices/DS"; DataSource[] dataSources = new DataSource[1]; DataSource ds = new DataSource(); ds.Item = (DataSourceDefinitionOrReference)reference; ds.Name = "DS"; dataSources[0] = ds; client.SetItemDataSources(new BatchHeader() { BatchID = batchId }, reportPath, dataSources); client.ExecuteBatch(new BatchHeader() { BatchID = batchId }); if (warnings != null && warnings.Length > 0) { StringBuilder sb = new StringBuilder(); foreach (var w in warnings) { sb.AppendLine(w.Severity); sb.AppendLine("---"); sb.AppendLine(w.ObjectName); sb.AppendLine(w.ObjectType); sb.AppendLine(w.Message); sb.AppendLine(); } throw new Exception(sb.ToString()); } return true; }
public async override void ViewDidLoad () { base.ViewDidLoad (); var query = ParseObject.GetQuery("Item") .WhereNotEqualTo("Description", ""); IEnumerable<ParseObject> results = await query.FindAsync(); if (results.Count() == 0) { Items initItem = new Items { Description = "Dummy Item", Value= "0.00", Available = true, PurchaserName = "N/A" }; AddItems (initItem); } else { ParseObj = results.ToList (); foreach (ParseObject po in ParseObj) { string Desc = po.Get<string> ("Description"); string Value = po.Get<string> ("Value"); bool Available = po.Get<Boolean> ("Available"); GuiItems.Add (new Items { Description = Desc, Value = Value, Available = Available }); } } TableView.Source = dataSource = new DataSource (this, GuiItems); UIBarButtonItem[] barButtonItems = new UIBarButtonItem[2]; barButtonItems [0] = new UIBarButtonItem (UIBarButtonSystemItem.Add, (sender, args) => { var newItemVC = this.Storyboard.InstantiateViewController ("AddNewItemViewController") as AddNewItemViewController; newItemVC.SetBuyItemsVC = this; NavigationController.PushViewController (newItemVC, true); }); barButtonItems [1] = new UIBarButtonItem (UIBarButtonSystemItem.Trash, (sender, args) => { // DBConn.DeleteAll<Items> (); }); this.NavigationItem.SetRightBarButtonItems (barButtonItems, true); TableView.ReloadData (); }
public ActionResult GetData(string data ="", DataSource source= DataSource.Old) { string fileName = $"{source}data", filePath = ""; switch (data) { //case "csv": fileName = DataGenerator.GenerateCSVDocument(source, Path.GetTempPath()); fileName += ".csv"; break; } byte[] filedata = System.IO.File.ReadAllBytes(filePath); string contentType = MimeMapping.GetMimeMapping(filePath); var cd = new System.Net.Mime.ContentDisposition { FileName = fileName, Inline = true, }; Response.AppendHeader("Content-Disposition", cd.ToString()); return File(filedata, contentType); }
public StockProcessingAgent(string _inputFile, string _storageConnectionString, DataSource _dataSource) { storageConnectionString = _storageConnectionString; if (!string.IsNullOrEmpty(_inputFile)) { switch (_dataSource) { case DataSource.Yahoo: dataSourceClient = new YahooDataSourceClient(_inputFile, _storageConnectionString); break; case DataSource.Tecent: dataSourceClient = new TecentDataSourceClient(_inputFile, _storageConnectionString); break; case DataSource.Intelligent: default: dataSourceClient = new IntelligentDataSourceClient(_inputFile, _storageConnectionString); break; } } }
public static void CreateHitboxes(DataSource source) { var tests = DataGenerator.GetTests(source); if (tests.Count == 0) return; Dictionary<GestureType, List<Attempt>> techAttempts = new Dictionary<GestureType, List<Attempt>>(); Dictionary<GridSize, List<Attempt>> sizeAttempts = new Dictionary<GridSize, List<Attempt>>(); sizeAttempts.Add(GridSize.Large, new List<Attempt>()); sizeAttempts.Add(GridSize.Small, new List<Attempt>()); foreach (var test in tests) { foreach (var gesture in DataGenerator.AllTechniques) { if (!techAttempts.ContainsKey(gesture)) { techAttempts.Add(gesture, new List<Attempt>()); } techAttempts[gesture].AddRange(test.Attempts[gesture]); sizeAttempts[GridSize.Small].AddRange(from attempt in test.Attempts[gesture] where attempt.Size == GridSize.Small select attempt); sizeAttempts[GridSize.Large].AddRange(from attempt in test.Attempts[gesture] where attempt.Size == GridSize.Large select attempt); } } foreach(var t in DataGenerator.AllTechniques) { DrawHitBox(techAttempts[t], t.ToString() + ".png"); } foreach (var s in DataGenerator.AllSizes) { DrawHitBox(sizeAttempts[s], s.ToString() + ".png"); } foreach(var s in DataGenerator.AllSizes) { foreach(var t in DataGenerator.AllTechniques) { var attempts = from attempt in techAttempts[t] where attempt.Size == s select attempt; DrawHitBox(attempts.ToList(), t.ToString() + s.ToString() + ".png"); } } }
public override void ViewDidLoad() { base.ViewDidLoad (); //Show an edit button NavigationItem.LeftBarButtonItem = EditButtonItem; Selector insertObject = new Selector("InsertNewObject"); UIBarButtonItem AddButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, this, insertObject ); NavigationItem.RightBarButtonItem = AddButton; this.Title = "Blood Pressure"; this.db = new SQLiteConnection(Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "bloodPressure.db")); this.db.CreateTable<BloodPressure>(); DataSource dataSource = new DataSource(this); dataSource.RowSelectedEvent += HandleDataSourceRowSelectedHandler; this.TableView.Source = dataSource; }
public override void ViewWillAppear (bool animated) { Console.Out.WriteLine ("view will appear entered."); TableView.Source = dataSource = new DataSource (this, bookList, _pathToDatabase); // attempt to hide Cover Downloading pop-up. try { BTProgressHUD.Dismiss (); } catch(Exception ex) { Console.Out.WriteLine ("Error hiding BTProgressHUD \n" + ex.ToString ()); } // begin creating and loading the database attempt var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal); _pathToDatabase = Path.Combine(documents, _databaseName); createDatabase (); var db = new SQLite.SQLiteConnection (_pathToDatabase); QueryValuations (db); bookList = BookList (db); // Perform any additional setup after loading the view, typically from a nib. //NavigationItem.LeftBarButtonItem = EditButtonItem; // experiment with f**k the edit button item. going for sorting here var sortButton = new UIBarButtonItem (UIBarButtonSystemItem.Bookmarks, sortDataBase); var addButton = new UIBarButtonItem (UIBarButtonSystemItem.Add, AddNewItem); addButton.AccessibilityLabel = "addButton"; NavigationItem.RightBarButtonItems = new UIBarButtonItem[]{addButton, sortButton}; TableView.Source = dataSource = new DataSource (this, bookList, _pathToDatabase); }
static unsafe void Main(string[] args) { if (args.Length > 0) { List<string> strings = new List<string>(); List<int> stringOffsets = new List<int>(); List<int> dataOffsets = new List<int>(); List<int> sizes = new List<int>(); DataSource source = new DataSource(FileMap.FromFile(args[0])); string magic = new String((sbyte*)source.Address); Endianness endian = Endianness.little; if (magic == "PACK") endian = Endianness.little; else if (magic == "KCAP") endian = Endianness.big; else Console.WriteLine("Not a valid PACK file"); try { if (args.Length == 2) new Unpacker(source).Unpack(endian,args[1]); else { new Unpacker(source).Unpack(endian); } Console.WriteLine("Files successfully unpacked."); } catch (Exception x) { Console.WriteLine(x.Message); } source.Close(); } else { Console.WriteLine("\n \n Usage: 'unpacker.exe <File Path> <Output Path>' \n If no output path"+ " is specified, files will be extracted to 'Output'."); } }
public XSqliteConnection(DataSource src) : base(src) { if (src == null || String.IsNullOrEmpty(src.ConnectionString)) { DataSource newSrc = new DataSource() { ConnectionString = new sqlite.SqliteDao().getResourcesPath() }; if (src != null) { newSrc.IsTestSource = src.IsTestSource; newSrc.Modality = src.Modality; newSrc.Password = src.Password; newSrc.Port = src.Port; newSrc.Protocol = src.Protocol; newSrc.SiteId = src.SiteId; } src = newSrc; } if (String.IsNullOrEmpty(_sqliteDbPath)) { _sqliteDbPath = src.ConnectionString; } _src = src; _cxn = new SQLiteConnection(src.ConnectionString); }
public void Parse(string fileDecomp) { _workingSource = new DataSource(FileMap.FromFile(fileDecomp)); RFHeader rfheader = *(RFHeader*)_workingSource.Address; Header = new RfHeaderObject { Tag = rfheader._rf, HeaderLen1 = rfheader._headerLen1, Pad = rfheader._pad0, EntriesChunkOffset = rfheader._headerLen2, EntriesChunkLen = rfheader._0x18EntriesLen, UnixTimestamp = rfheader._unixTimestamp, CompressedLen = rfheader._compressedLen, DecompressedLen = rfheader._decompressedLen, StrsChunkOffset = rfheader._strsPlus, StrsChunkLen = rfheader._strsLen, EntryCount = rfheader._resourceEntries }; VoidPtr addr = _workingSource.Address + Header.StrsChunkOffset; strChunks = new byte[*(uint*)addr][]; addr += 4; for (int i = 0; i < strChunks.Length; i++) strChunks[i] = _workingSource.Slice((int)(Header.StrsChunkOffset + 4) + i * 0x2000, 0x2000); addr += strChunks.Length * 0x2000; ExtensionOffsets = new uint[*(uint*)addr]; Extensions = new string[ExtensionOffsets.Length]; addr += 4; for (int i = 0; i < ExtensionOffsets.Length; i++) { ExtensionOffsets[i] = *(uint*)(addr + i * 4); var ext = Encoding.ASCII.GetString(str_from_offset((int)ExtensionOffsets[i], 64)); Extensions[i] = ext.Remove(ext.IndexOf('\0')); } addr = _workingSource.Address + Header.EntriesChunkOffset; uint size1 = *(uint*)addr * 8 + 4; addr += size1; uint size2 = *(uint*)addr + 4; addr += size2; ResourceEntries = new ResourceEntryObject[Header.EntryCount]; for (int i = 0; i < Header.EntryCount; i++, addr += 0x18) { ResourceEntry entry = *(ResourceEntry*)addr; ResourceEntryObject rsobj = new ResourceEntryObject() { OffInPack = entry.offInPack, NameOffsetEtc = entry.nameOffsetEtc, CmpSize = entry.cmpSize, DecSize = entry.decSize, Timestamp = entry.timestamp, Flags = entry.flags, }; if (rsobj.OffInPack == 0xBBBBBBBB) { ResourceEntries[i] = null; continue; } var strbytes = str_from_offset((int)rsobj.NameOffset, 128); var name = Encoding.ASCII.GetString(str_from_offset((int)rsobj.NameOffset, 128)); if ((entry.nameOffsetEtc & 0x00800000) > 0) { var reference = BitConverter.ToUInt16(strbytes, 0); var referenceLen = (reference & 0x1f) + 4; var refReloff = (reference & 0xe0) >> 6 << 8 | (reference >> 8); name = Encoding.ASCII.GetString(str_from_offset((int)rsobj.NameOffset - refReloff, referenceLen)) + name.Substring(2); } if (name.Contains('\0')) name = name.Substring(0, name.IndexOf('\0')); rsobj.EntryString = name + Extensions[rsobj.extIndex]; ResourceEntries[i] = rsobj; } //_workingSource.Close(); }