protected override void Check(MainForm form, string ext, RegistryKey rk, DataEntry[] de) { RegistryKey r = null; using (r = Registry.ClassesRoot.OpenSubKey(string.Format(CultureInfo.InvariantCulture, "{0}\\ShellEx\\{1}", ext, ShellExGuid))) { CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de); } if (r == null) { using (r = Registry.ClassesRoot.OpenSubKey(string.Format(CultureInfo.InvariantCulture, "SystemFileAssociations\\{0}\\ShellEx\\{1}", ext, ShellExGuid))) { CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de); } } if (r == null) { string type = CheckStringValue(form, rk, PerceivedType, de); using (r = OpenSubKey(form, Registry.ClassesRoot, string.Format(CultureInfo.InstalledUICulture, "SystemFileAssociations\\{0}\\ShellEx\\{1}", type, ShellExGuid), de)) { CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de); } } }
protected override bool ProcessDecoder(MainForm form, IWICBitmapDecoder decoder, DataEntry[] de, object tag) { IWICBitmapDecoderInfo info = decoder.GetDecoderInfo(); try { Guid clsid; info.GetCLSID(out clsid); if (clsid != Parent.Clsid) { form.Add(this, Resources.IncorrectDecoderPickedUp, de, new DataEntry(Resources.Expected, Parent.Clsid), new DataEntry(Resources.Actual, clsid)); } else { Tag t = (Tag)tag; if (!t.SupportsMultiframe && decoder.GetFrameCount() > 1) { form.Add(this, Resources.DecoderDoesNotMultiframe, de, new DataEntry(Resources.FrameCount, decoder.GetFrameCount())); } } } finally { info.ReleaseComObject(); } return true; }
static void ReadResourceDataEntry(BinaryStreamReader reader, DataEntry dataEntry) { dataEntry.DataRVA = reader.ReadUInt32(); dataEntry.Size = reader.ReadUInt32(); dataEntry.Codepage = reader.ReadUInt32(); dataEntry.Reserved = reader.ReadUInt32(); }
public static DataEntry Decode(IByteReader stream) { DataEntry decodedDataEntry = new DataEntry(); decodedDataEntry.AccountID = AccountID.Decode(stream); decodedDataEntry.DataName = String64.Decode(stream); decodedDataEntry.DataValue = DataValue.Decode(stream); decodedDataEntry.Ext = DataEntryExt.Decode(stream); return decodedDataEntry; }
protected override void Check(MainForm form, string ext, RegistryKey rk, DataEntry[] de) { using (RegistryKey r = OpenSubKey(form, Registry.LocalMachine, PropertyHandler, de)) { string value = CheckStringValue(form, r, null, de); if (value != null) { if (value == PhotoMetadataHandler) { using (RegistryKey r2 = OpenSubKey(form, Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\PhotoPropertyHandler\ContainerAssociations", de)) { foreach (Guid g in Parent.ContainerFormats) { if (0 <= Array.FindIndex(r2.GetValueNames(), delegate(string obj) { return string.Compare(obj, g.ToString("B"), CultureInfo.InvariantCulture, CompareOptions.IgnoreCase) == 0; })) { CheckValue(form, r2, g.ToString("B"), PhotoMetadataHandlerContainerFormats, de); } } } } else { Guid? clsid = null; try { clsid = new Guid(value); } catch (ArgumentException) { form.Add(this, Resources.InvalidGUIDRegistryValue, new DataEntry(Resources.Key, r.ToString()), new DataEntry(Resources.Value, Resources.RegistryValue_default)); } if (clsid.HasValue) { Type t = Type.GetTypeFromCLSID(clsid.Value, false); if (t == null) { object ps = null; try { ps = Activator.CreateInstance(t); } catch (Exception e) { form.Add(this, string.Format(CultureInfo.CurrentUICulture, Resources._0_Failed, "CoCreateInstance(...)"), new DataEntry(e), new DataEntry(Resources.CLSID, clsid)); } finally { ps.ReleaseComObject(); } } } } } } }
protected override void Check(ListView.ListViewItemCollection collection, string ext, RegistryKey rk, IWICBitmapDecoderInfo info) { DataEntry[] de = new DataEntry[] { new DataEntry("File Extension", ext)}; using (RegistryKey r = OpenSubKey(collection, Registry.ClassesRoot, string.Format(CultureInfo.InvariantCulture, "{0}\\ShellEx\\{1}", ext, ShellExGuid), de)) { CheckValue(collection, r, null, new string[] { ThumnailCacheGuid }, de); } using (RegistryKey r = OpenSubKey(collection, Registry.ClassesRoot, string.Format(CultureInfo.InvariantCulture, "SystemFileAssociations\\{0}\\ShellEx\\{1}", ext, ShellExGuid), de)) { CheckValue(collection, r, null, new string[] { ThumnailCacheGuid }, de); } }
protected override bool ProcessFrameDecode(MainForm form, IWICBitmapFrameDecode frame, DataEntry[] de, object tag) { Guid pixelFormat; frame.GetPixelFormat(out pixelFormat); Tag t = (Tag)tag; if (Array.IndexOf(t.PixelFormats, pixelFormat) < 0) { form.Add(this, Resources.DecoderUnsuportedPixelFormat, de, new DataEntry(Resources.PixelFormat, pixelFormat), new DataEntry(Resources.SupportedPixelFormats, t.PixelFormats)); } return true; }
protected override bool ProcessDecoder(MainForm form, IWICBitmapDecoder decoder, DataEntry[] de, object tag) { CheckCopyPalette(form, de, decoder.CopyPalette); CheckGetColorContexts(form, de, decoder.GetColorContexts); if (decoder.GetFrameCount() == 0) { form.Add(this, Resources.FileNoFrames, de); } CheckGetBitmapSource(form, de, decoder.GetPreview, WinCodecError.WINCODEC_ERR_UNSUPPORTEDOPERATION); CheckGetBitmapSource(form, de, decoder.GetThumbnail, WinCodecError.WINCODEC_ERR_CODECNOTHUMBNAIL); return true; }
protected override void Add(DataEntry entry) { double price = entry.Items[0].Price; if (this.bar == null) { this.CreateNewBar(BarType.Range, entry.DateTime, entry.DateTime, price); } else { this.AddItemsToBar(entry.Items); this.bar.bar.EndTime = entry.DateTime; bool flag = false; while (!flag) { if (10000.0 * (this.bar.High - this.bar.Low) >= (double)this.newBarSize) { Bar bar = new Bar(new FreeQuant.Data.Bar(FreeQuant.Data.BarType.Range, this.newBarSize, entry.DateTime, entry.DateTime, price, price, price, price, 0, 0)); if (this.bar.High == price) { this.bar.bar.High = this.bar.Low + (double)this.newBarSize / 10000.0; this.bar.bar.Close = this.bar.High; bar.bar.Low = this.bar.High; } if (this.bar.Low == price) { this.bar.bar.Low = this.bar.High - (double)this.newBarSize / 10000.0; this.bar.bar.Close = this.bar.Low; bar.bar.High = this.bar.Low; } this.EmitNewCompressedBar(); this.bar = bar; flag = 10000.0 * (this.bar.High - this.bar.Low) < (double)this.newBarSize; } else flag = true; } } }
protected override bool ProcessFrameDecode(MainForm form, IWICBitmapFrameDecode frame, DataEntry[] de, object tag) { CheckGetColorContexts(form, de, frame.GetColorContexts); CheckGetBitmapSource(form, de, frame.GetThumbnail, WinCodecError.WINCODEC_ERR_CODECNOTHUMBNAIL); uint width; uint height; frame.GetSize(out width, out height); Guid pixelFormat; frame.GetPixelFormat(out pixelFormat); uint stride = (PixelFormatInfoRule.GetBitPerPixel(pixelFormat) * width + 7) / 8; byte[] buffer = new byte[stride * height]; WICRect rect = new WICRect(); rect.Height = (int)Math.Min(height, int.MaxValue); rect.Width = (int)Math.Min(width, int.MaxValue); try { frame.CopyPixels(rect, stride, stride * height, buffer); try { frame.CopyPixels(null, stride, stride * height, buffer); } catch (Exception e) { form.Add(this, e.TargetSite.ToString(Resources._0_Failed, "NULL"), de, new DataEntry(e)); } } catch { } return true; }
public void ChangeEntryData(DataEntry dataEntry) { }
public string GetFileExtension(DataEntry dataEntry) { return(""); }
private EditorDataEntry GetData(DataEntry entry) { return(EditorData.Instance.GetData(Shape, "ShapeVisualCreateTool_" + entry.ToString())); }
public void populateSearch(string result) { PurgeCells(); printHeader(); TSection.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); Dictionary <string, List <string> > dictionary = FormatFunctions.createValuePairs(FormatFunctions.SplitToPairs(result)); if (dictionary.Count > 0) { EditDict = new Dictionary <int, List <UIElement> >(); for (int i = 0; i < dictionary["IDKey"].Count; i++) { if (!(bool)EditMode.IsChecked) { string[] s = new string[] { dictionary["Desc1"][i], dictionary["Desc2"][i], "$" + dictionary["Price"][i], "$" + dictionary["PriceSale"][i] }; int count = 4; if (BrandPicker.SelectedIndex == -1 || !BrandPicker.SelectedItem.Equals("Additives")) { count++; s = new string[] { dictionary["Brand"][i], s[0], s[1], s[2], s[3] }; } if (TypePicker.SelectedIndex == -1) { count++; if (count == 6) { s = new string[] { dictionary["ItemType"][i], s[0], s[1], s[2], s[3], s[4] }; } else { s = new string[] { dictionary["ItemType"][i], s[0], s[1], s[2], s[3] }; } } int[] Spacing = new int[] { 1, 1, 1, 1, 1, 1 }; if (s.Length == 5) { Spacing = new int[] { 1, 2, 1, 1, 1 }; } else if (s.Length == 4) { Spacing = new int[] { 2, 2, 1, 1 }; } GridFiller.rapidFillSpaced(s, TSection, Spacing); } else { int[] Spacing = new int[] { 1, 1, 1, 1, 1, 1 }; DataEntry Desc1 = new DataEntry(int.Parse(dictionary["IDKey"][i]), dictionary["Desc1"][i]) { Text = dictionary["Desc1"][i] }; DataEntry Desc2 = new DataEntry(int.Parse(dictionary["IDKey"][i]), dictionary["Desc2"][i]) { Text = dictionary["Desc2"][i] }; DataEntry Price = new DataEntry(int.Parse(dictionary["IDKey"][i]), dictionary["Price"][i]) { Text = dictionary["Price"][i] }; DataEntry PriceSale = new DataEntry(int.Parse(dictionary["IDKey"][i]), dictionary["PriceSale"][i]) { Text = dictionary["PriceSale"][i] }; DataEntry Brand = new DataEntry(int.Parse(dictionary["IDKey"][i]), dictionary["Brand"][i]) { Text = dictionary["Brand"][i] }; DataEntry ItemType = new DataEntry(int.Parse(dictionary["IDKey"][i]), dictionary["ItemType"][i]) { Text = dictionary["ItemType"][i] }; List <UIElement> list = new List <UIElement>() { Desc1, Desc2, Price, PriceSale, Brand, ItemType }; EditDict.Add(int.Parse(dictionary["IDKey"][i]), list); GridFiller.rapidFillSpacedPremadeObjects(list, TSection, Spacing, new bool[] { false, false, false, false, false, false }); } } } }
private void AddEntry(DataEntry entry) { _entries.Insert(0, entry); _entries.RemoveAt(_entries.Count - 1); }
//dataUpdater is the update for the list of all group (no subgroup data) //returns an updater that includes subgroup data for group that were open before that are still present after the update protected Updater UpdateDataBegin(IUpdater dataUpdater) { if (dataUpdater == null && m_Data.m_ExpandedGroup.Count == 0) { //no change in data return(null); } Updater u = new Updater(); u.m_DataUpdater = dataUpdater; long newGroupCount = 0; if (dataUpdater != null) { newGroupCount = dataUpdater.GetRowCount(); //convert open groups' row foreach (var e in m_Data.m_ExpandedGroup) { var newRow = dataUpdater.OldToNewRow(e.Key); if (newRow >= 0) { u.m_NewData.m_ExpandedGroup[newRow] = e.Value; } } } else { newGroupCount = m_Data.m_GroupRowDataRange.LongLength; u.m_NewData.m_ExpandedGroup = m_Data.m_ExpandedGroup; } //update all expanded groups' table u.m_NewData.m_GroupRowDataRange = new Range[newGroupCount]; long newCurrentRow = 0; long newCurrentGroup = 0; var newExpandedGroupEnum = u.m_NewData.m_ExpandedGroup.GetEnumerator(); bool hasExpandedGroup = newExpandedGroupEnum.MoveNext(); List <DataEntry> newRowDataList = new List <DataEntry>(); while (newCurrentGroup < newGroupCount) { //add group to row data var deGroupHead = new DataEntry(); deGroupHead.groupIndex = newCurrentGroup; deGroupHead.subGroupIndex = -1; // < 0 meaning the group head row newRowDataList.Add(deGroupHead); //check if this group is expanded if (hasExpandedGroup && newCurrentGroup == newExpandedGroupEnum.Current.Key) { //update its sub table var subGroupUpdater = newExpandedGroupEnum.Current.Value.table.BeginUpdate(); u.m_NewExpandedGroupUpdater[newCurrentGroup] = subGroupUpdater; long subRowCount; if (subGroupUpdater != null) { subRowCount = subGroupUpdater.GetRowCount(); } else { subRowCount = newExpandedGroupEnum.Current.Value.table.GetRowCount(); } //add subgroup rows into the row data for (int i = 0; i != subRowCount; ++i) { var deSubRow = new DataEntry(); deSubRow.groupIndex = newCurrentGroup; deSubRow.subGroupIndex = i; newRowDataList.Add(deSubRow); } //set group data range to include head + sub rows u.m_NewData.m_GroupRowDataRange[newCurrentGroup] = Range.FirstPlusLength(newCurrentRow, 1 + subRowCount); newCurrentRow += subRowCount + 1; hasExpandedGroup = newExpandedGroupEnum.MoveNext(); } else { //group use only a single row u.m_NewData.m_GroupRowDataRange[newCurrentGroup] = Range.FirstPlusLength(newCurrentRow, 1); ++newCurrentRow; } ++newCurrentGroup; } u.m_NewData.m_RowData = newRowDataList.ToArray(); //compute old to new row conversion table var oldExpandedGroupEnum = m_Data.m_ExpandedGroup.GetEnumerator(); hasExpandedGroup = oldExpandedGroupEnum.MoveNext(); u.m_OldToNewRow = new long[m_Data.m_RowData.Length]; newCurrentRow = 0; long oldCurrentRow = 0; //for (long i = 0; i < u.m_OldToNewRow.Length; ++i) while (oldCurrentRow < u.m_OldToNewRow.Length) { var oldRowGroup = m_Data.m_RowData[oldCurrentRow].groupIndex; long newRowGroup = -1; if (dataUpdater != null) { newRowGroup = dataUpdater.OldToNewRow(oldRowGroup); } else { newRowGroup = oldRowGroup; } if (newRowGroup >= 0) { var newGroupHeadRow = u.m_NewData.m_GroupRowDataRange[newRowGroup].First; u.m_OldToNewRow[oldCurrentRow] = newGroupHeadRow; //check if this group was expanded if (hasExpandedGroup && oldRowGroup == oldExpandedGroupEnum.Current.Key) { IUpdater subUpdater; if (u.m_NewExpandedGroupUpdater.TryGetValue(newRowGroup, out subUpdater)) { //fix all sub rows if (subUpdater != null) { //sub table is dirty, update each sub row with the group's updater for (int j = 0; j < m_Data.m_GroupRowDataRange[oldRowGroup].Length - 1; ++j) { var subRowTopRow = oldCurrentRow + j + 1;//sub row index in the m_RowData array long newSubRow = subUpdater.OldToNewRow(j); if (newSubRow >= 0) { //set to new head row + new sub row u.m_OldToNewRow[subRowTopRow] = newGroupHeadRow + 1 + newSubRow; } else { //row no longer exist in sub table u.m_OldToNewRow[subRowTopRow] = -1; } } } else { //sub table didn't change for (int j = 0; j != m_Data.m_GroupRowDataRange[oldCurrentRow].Length - 1; ++j) { var subRowTopRow = oldCurrentRow + 1 + j;//sub row index in the m_RowData array //set to new head row + new sub row u.m_OldToNewRow[subRowTopRow] = newGroupHeadRow + 1 + j; } } } hasExpandedGroup = oldExpandedGroupEnum.MoveNext(); //offset oldCurrentRow by the sub row we just fixed oldCurrentRow += m_Data.m_GroupRowDataRange[oldCurrentRow].Length - 1;//-1 to exclude the group head } } else { //the group no longer exist u.m_OldToNewRow[oldCurrentRow] = -1; } ++oldCurrentRow; } return(u); }
public ActionResult Create([Bind(Include = "Type,MachineNumber,CurrentReading,CashRecieved")] DataEntry dataEntry) { if (ModelState.IsValid) { //Adding value to balance sheet var e = db.DataEntries.Where(x => x.MachineNumber == dataEntry.MachineNumber).OrderByDescending(x => x.CreatedOn).FirstOrDefault(); var sheet = new BalanceSheet(); sheet.Cash = dataEntry.CashRecieved; sheet.CreatedOn = DateTime.Now; if (e == null) { sheet.FuelAmount = dataEntry.CurrentReading; } else { sheet.FuelAmount = dataEntry.CurrentReading - e.CurrentReading; } sheet.FuelType = dataEntry.Type; sheet.Type = "Sale"; db.BalanceSheets.Add(sheet); db.SaveChanges(); //Updating the stock tracker var a = sheet.FuelAmount; while (a != 0) { var s = db.StockTrackers.Where(x => x.FuelType == dataEntry.Type && x.RemainingFuelAmount > 0).OrderBy(x => x.CreatedOn).FirstOrDefault(); s.UpdatedOn = DateTime.Now; if (a < s.RemainingFuelAmount) { s.RemainingFuelAmount -= a; a = 0; } else { a -= s.RemainingFuelAmount; s.RemainingFuelAmount = 0; } db.Entry(s).State = EntityState.Modified; db.SaveChanges(); } //Creating dataentry dataEntry.CreatedBy = Session["LoggedIn"].ToString(); dataEntry.CreatedOn = DateTime.Now; db.DataEntries.Add(dataEntry); db.SaveChanges(); return(RedirectToAction("Index")); } List <SelectListItem> typeList = new List <SelectListItem>(); var mt = db.MachineTypes.Distinct().ToList(); foreach (var m in mt) { typeList.Add(new SelectListItem() { Text = m.MType, Value = m.MType }); } if (mt.Count > 0) { ViewBag.TypeList = new SelectList(typeList, "Value", "Text", typeList[0]); } else { ViewBag.TypeList = new SelectList(typeList, "Value", "Text"); } var machines = new List <Machine>(); if (mt.Count > 0) { machines = db.Machines.Where(x => x.Type == mt[0].MType).ToList(); } else { machines = db.Machines.Distinct().ToList(); } List <SelectListItem> mac = new List <SelectListItem>(); foreach (var machine in machines) { mac.Add(new SelectListItem { Text = machine.MachineNumber, Value = machine.MachineNumber }); } if (machines.Count > 0) { ViewBag.MachineList = new SelectList(mac, "Value", "Text", machines[0]); } else { ViewBag.MachineList = new SelectList(mac, "Value", "Text"); } return(View(dataEntry)); }
public DataEnum(string id, DataEntry owner, string value, int index) : base(id, owner, value) { EnumIndex = index; }
protected DataCell(string id, DataEntry owner) { ID = id; FullID = string.Format("{0}.{1}", owner.ID, id); }
public void DataParseTest() { string xml = "<?xml version='1.0' encoding='UTF-8'?>" + "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:dxp='http://schemas.google.com/analytics/2009' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"A05PSHcycSp9ImA2WxJSGYQ."'>" + "<id>http://www.google.com/analytics/feeds/data?ids=ga:123456&dimensions=ga:browser&metrics=ga:pageviews&start-date=2009-04-28&end-date=2009-05-10</id>" + "<updated>2009-05-10T01:01:01.999-07:00</updated><title>Google Analytics Data for Profile 123456</title>" + "<link rel='self' type='application/atom+xml' href='http://www.google.com/analytics/feeds/data?max-results=200&sort=ga%3Abrowser%2Cga%3Apageviews&end-date=2009-05-10&start-date=2009-04-28&metrics=ga%3Apageviews&ids=ga%3A123456&dimensions=ga%3Abrowser'/>" + "<author><name>Google Analytics</name></author>" + "<generator version='1.0'>Google Analytics</generator>" + "<openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>200</openSearch:itemsPerPage>" + "<dxp:startDate>2009-04-28</dxp:startDate>" + "<dxp:endDate>2009-05-10</dxp:endDate>" + "<dxp:aggregates>" + "<dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='50599'/>" + "</dxp:aggregates>" + "<dxp:dataSource>" + "<dxp:tableId>ga:123456</dxp:tableId>" + "<dxp:tableName>www.test.com</dxp:tableName>" + "<dxp:property name='ga:profileId' value='123456'/>" + "<dxp:property name='ga:webPropertyId' value='UA-111111-1'/>" + "<dxp:property name='ga:accountName' value='Test Account'/>" + "</dxp:dataSource>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Camino&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Camino</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Camino'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='8'/></entry>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Chrome&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Chrome</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Chrome'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='894'/></entry>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Firefox&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Firefox</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Firefox'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='9969'/></entry>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Internet%20Explorer&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Internet Explorer</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Internet Explorer'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='36261'/></entry>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Konqueror&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Konqueror</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Konqueror'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='1'/></entry>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Mozilla&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Mozilla</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Mozilla'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='21'/></entry>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Mozilla%20Compatible%20Agent&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Mozilla Compatible Agent</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Mozilla Compatible Agent'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='11'/></entry>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Netscape&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Netscape</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Netscape'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='4'/></entry>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Opera&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Opera</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Opera'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='84'/></entry>" + "<entry gd:etag='W/"CQFFQX53eSp7ImA8WxPSGUw."'><id>http://www.google.com/analytics/feeds/data?ids=ga:123456&ga:browser=Safari&start-date=2009-04-28&end-date=2009-05-10</id><updated>2009-05-09T17:00:00.001-07:00</updated><title>ga:browser=Safari</title><link rel='alternate' type='text/html' href='http://www.google.com/analytics'/><dxp:dimension name='ga:browser' value='Safari'/><dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='3346'/></entry>" + "</feed>"; Google.GData.Analytics.DataFeed feed = Parse(xml); Dataset f = new Dataset(feed); f.AutoPaging = false; Assert.IsNotNull(f.Aggregates); Assert.IsNotNull(f.DataSource); Assert.IsNotNull(f.Entries); Assert.AreEqual(50599, f.Aggregates.Metrics[0].IntegerValue); Assert.AreEqual("0.0", f.Aggregates.Metrics[0].ConfidenceInterval); Assert.AreEqual("ga:pageviews", f.Aggregates.Metrics[0].Name); Assert.AreEqual("integer", f.Aggregates.Metrics[0].Type); Assert.AreEqual("ga:123456", f.DataSource.TableId); Assert.AreEqual("www.test.com", f.DataSource.TableName); Assert.AreEqual("123456", f.DataSource.ProfileId); Assert.AreEqual("UA-111111-1", f.DataSource.WebPropertyId); Assert.AreEqual("Test Account", f.DataSource.AccountName); Assert.AreEqual(50599, Int32.Parse(feed.Aggregates.Metrics[0].Value)); DataEntry camino = feed.Entries[0] as DataEntry; Assert.IsNotNull(camino, "entry"); Assert.IsNotNull(camino.Dimensions); Assert.IsNotNull(camino.Metrics); Assert.AreEqual("ga:browser", camino.Dimensions[0].Name); Assert.AreEqual("Camino", camino.Dimensions[0].Value); Assert.AreEqual("ga:pageviews", camino.Metrics[0].Name); Assert.AreEqual(8, int.Parse(camino.Metrics[0].Value)); DataEntry chrome = feed.Entries[1] as DataEntry; Assert.IsNotNull(chrome, "entry"); Assert.IsNotNull(chrome.Dimensions); Assert.IsNotNull(chrome.Metrics); Assert.AreEqual("ga:browser", chrome.Dimensions[0].Name); Assert.AreEqual("Chrome", chrome.Dimensions[0].Value); Assert.AreEqual("ga:pageviews", chrome.Metrics[0].Name); Assert.AreEqual(894, int.Parse(chrome.Metrics[0].Value)); DataEntry fireFox = feed.Entries[2] as DataEntry; Assert.IsNotNull(fireFox, "entry"); Assert.IsNotNull(fireFox.Dimensions); Assert.IsNotNull(fireFox.Metrics); Assert.AreEqual("ga:browser", fireFox.Dimensions[0].Name); Assert.AreEqual("Firefox", fireFox.Dimensions[0].Value); Assert.AreEqual("ga:pageviews", fireFox.Metrics[0].Name); Assert.AreEqual(9969, int.Parse(fireFox.Metrics[0].Value)); DataEntry ie = feed.Entries[3] as DataEntry; Assert.IsNotNull(ie, "entry"); Assert.IsNotNull(ie.Dimensions); Assert.IsNotNull(ie.Metrics); Assert.AreEqual("ga:browser", ie.Dimensions[0].Name); Assert.AreEqual("Internet Explorer", ie.Dimensions[0].Value); Assert.AreEqual("ga:pageviews", ie.Metrics[0].Name); Assert.AreEqual(36261, int.Parse(ie.Metrics[0].Value)); foreach (DataEntry entry in feed.Entries) { Assert.IsNotNull(entry, "entry"); Assert.IsNotNull(entry.Dimensions); Assert.IsNotNull(entry.Metrics); Assert.AreEqual("ga:browser", entry.Dimensions[0].Name); Assert.IsNotEmpty(entry.Dimensions[0].Value); Assert.AreEqual("ga:pageviews", entry.Metrics[0].Name); Assert.Greater(int.Parse(entry.Metrics[0].Value), 0); } foreach (Data d in f.Entries) { Assert.IsNotNull(d, "entry"); Assert.IsNotNull(d.Dimensions); Assert.IsNotNull(d.Metrics); Assert.AreEqual("ga:browser", d.Dimensions[0].Name); Assert.IsNotEmpty(d.Dimensions[0].Value); Assert.AreEqual("ga:pageviews", d.Metrics[0].Name); Assert.Greater(int.Parse(d.Metrics[0].Value), 0); } }
void Read(BinaryStreamReader reader, long baseOffset) { this.Characteristics = reader.ReadUInt32(); uint timestampNum = reader.ReadUInt32(); this.Timestamp = PEFile.TimestampEpochUTC.AddSeconds(timestampNum); this.MajorVersion = reader.ReadUInt16(); this.MinorVersion = reader.ReadUInt16(); ushort nameEntryCount = reader.ReadUInt16(); ushort idEntryCount = reader.ReadUInt16(); List <DirectoryEntry> subdirectories = null; List <DataEntry> dataEntries = null; for (int i = 0; i < nameEntryCount + idEntryCount; i++) { uint idOrNameRva = reader.ReadUInt32(); uint contentRva = reader.ReadUInt32(); string name; uint id; const uint HighBit = 1U << 31; if ((idOrNameRva & HighBit) == 0) { id = idOrNameRva; name = null; } else { id = 0; long savePosition = reader.Position; uint namePositon = idOrNameRva & ~HighBit; reader.Position = baseOffset + namePositon; name = ReadName(reader); reader.Position = savePosition; } if ((contentRva & HighBit) == 0) // high bit is set { var dataEntry = new DataEntry { Name = name, IntegerID = id }; long savePosition = reader.Position; reader.Position = baseOffset + contentRva; ReadResourceDataEntry(reader, dataEntry); if (dataEntries == null) { dataEntries = new List <DataEntry>(); } dataEntries.Add(dataEntry); reader.Position = savePosition; } else { contentRva = contentRva & ~HighBit; // clear hight bit long savePosition = reader.Position; reader.Position = baseOffset + contentRva; var directoryEntry = new DirectoryEntry { Name = name, IntegerID = id }; directoryEntry.Directory = new ResourceDirectory(); directoryEntry.Directory.Read(reader, baseOffset); if (subdirectories == null) { subdirectories = new List <DirectoryEntry>(); } subdirectories.Add(directoryEntry); reader.Position = savePosition; } } this.Subdirectories = subdirectories == null ? EmptyDirectoryEntries : subdirectories.ToArray(); this.DataEntries = dataEntries == null ? EmptyDataEntries : dataEntries.ToArray(); }
public void Read(FileReader reader) { var headers = new List <string>(); uint numEntries = reader.ReadUInt32(); uint entrySize = reader.ReadUInt32(); ushort numFields = reader.ReadUInt16(); byte flag1 = reader.ReadByte(); byte flag2 = reader.ReadByte(); if (flag1 == 1) { uint magic = reader.ReadUInt32(); uint unk = reader.ReadUInt32(); //Always 100000 reader.ReadUInt32(); //0 reader.ReadUInt32(); //0 } Field[] fields = new Field[numFields]; for (int i = 0; i < numFields; i++) { fields[i] = new Field() { Hash = reader.ReadUInt32(), Offset = reader.ReadUInt32(), }; } for (int i = 0; i < numEntries; i++) { DataEntry entry = new DataEntry(); Entries.Add(entry); entry.Fields = new Dictionary <string, object>(); long pos = reader.Position; for (int f = 0; f < fields.Length; f++) { DataType type = DataType.String; uint size = entrySize - fields[f].Offset; if (f < fields.Length - 1) { size = fields[f + 1].Offset - fields[f].Offset; } if (size == 1) { type = DataType.Byte; } if (size == 2) { type = DataType.Int16; } if (size == 4) { type = DataType.Int32; } reader.SeekBegin(pos + fields[f].Offset); object value = 0; string name = fields[f].Hash.ToString("x"); var hashtype = ""; if (Hashes.ContainsKey(fields[f].Hash)) { name = Hashes[fields[f].Hash].Split(' ')[0]; hashtype = Hashes[fields[f].Hash]; } else if (overridehashes.ContainsKey(fields[f].Hash)) { headers.Add(fields[f].Hash.ToString("x")); name = overridehashes[fields[f].Hash]; } else { headers.Add(fields[f].Hash.ToString("x")); } switch (type) { case DataType.Byte: value = reader.ReadByte(); break; case DataType.Float: value = reader.ReadSingle(); break; case DataType.Int16: value = reader.ReadInt16(); break; case DataType.Int32: value = reader.ReadInt32(); var checkVal = BitConverter.ToUInt32(BitConverter.GetBytes((int)value), 0); if (Hashes.ContainsKey(checkVal) && checkVal > 0) { value = Hashes[checkVal]; type = DataType.String; break; } if (mmhashes.ContainsKey(checkVal) && checkVal > 0) { value = mmhashes[checkVal]; type = DataType.String; break; } if ((name.Contains(".hshCstringRef") || name.Contains(".HashRef") || hashtype.Contains("string")) && checkVal != 0 || name.Contains(".HashRef")) { value = checkVal.ToString("X"); type = DataType.String; break; } if (IsFloatValue((int)value)) { reader.Seek(-4); value = reader.ReadSingle(); type = DataType.Float; } if (value.ToString().Contains("E+") || value.ToString().Contains("E-")) { value = checkVal.ToString("X"); type = DataType.String; } break; case DataType.String: value = reader.ReadZeroTerminatedString(Encoding.UTF8); if (!OnlyHexInString(value.ToString()) && !value.ToString().Contains("|")) { break; } var result = ""; var spl = value.ToString().Split('|'); foreach (var s in spl) { if (!OnlyHexInString(s)) { result += s + "|"; continue; } var sHash = Convert.ToUInt32(s.ToString(), 16); if (Hashes.ContainsKey(sHash) && sHash > 0) { result += Hashes[sHash] + "|"; continue; } if (mmhashes.ContainsKey(sHash) && sHash > 0) { result += mmhashes[sHash] + "|"; continue; } } value = result.TrimEnd('|'); break; } if (Hashes.ContainsKey(fields[f].Hash)) { name = Hashes[fields[f].Hash].Split(' ')[0]; } else if (overridehashes.ContainsKey(fields[f].Hash)) { name = overridehashes[fields[f].Hash]; } else { if (type == DataType.String) { if (size > 4) { name += " string" + size; } else { name += " string"; } } else { switch (type) { case DataType.Byte: name += " u8"; break; case DataType.Int16: name += " u16"; break; case DataType.Int32: name += " u32"; break; case DataType.Float: name += " f32"; break; } } } entry.Fields.Add(name.Replace(".hshCstringRef", ""), value); } reader.SeekBegin(pos + entrySize); } // File.AppendAllLines(@"s:\Bcsvheaderunknown.txt", headers); }
public byte[] DownloadEntry(DataEntry dataEntry) { return(DataTransferProtocolFactory.ExecuteFunction <byte[]>("DownloadData", dataEntry.Id)); }
private void Check(MainForm form, IWICPixelFormatInfo info, object tag) { uint bpp = info.GetBitsPerPixel(); if (bpp == 0) { form.Add(this, Resources.ZeroBPP); } uint count = info.GetChannelCount(); if (count == 0) { form.Add(this, Resources.ZeroChannelCount); } byte[][] channelMasks = new byte[count][]; var dups = new Dictionary <int, List <uint> >(); byte[] fullMask = new byte[(bpp + 7) / 8]; for (uint i = 0; i < count; i++) { DataEntry[] de = new DataEntry[] { new DataEntry(Resources.Channel, i) }; byte[] mask = new byte[info.GetChannelMask(i, 0, null)]; if (mask.Length > 0) { info.GetChannelMask(i, (uint)mask.Length, mask); } if (mask.Length != (bpp + 7) / 8) { form.Add(this, Resources.IncorrectMaskLegth, de, new DataEntry(Resources.Expected, (bpp + 7) / 8), new DataEntry(Resources.Actual, mask.Length)); } byte[] fullMaskSaved = fullMask.Clone() as byte[]; for (int k = 0; k < fullMask.Length && k < mask.Length; k++) { fullMask[k] |= mask[k]; } if (fullMaskSaved.ItemsEqual(fullMask)) { form.Add(this, Resources.IncorrectChannelMask, de, new DataEntry(Resources.Mask, mask)); } int idx = Array.FindIndex(channelMasks, mask.ItemsEqual); if (idx >= 0) { List <uint> r; if (!dups.TryGetValue(idx, out r)) { r = new List <uint>(); dups[idx] = r; r.Add((uint)idx); } r.Add(i); } channelMasks[(int)i] = mask; } foreach (List <uint> l in dups.Values) { form.Add(this, Resources.DuplicatedChannelMask, new DataEntry(Resources.Channel, l.ToArray())); } }
void CheckCopyPalette(MainForm form, DataEntry[] de, Action<IWICPalette> method) { IWICImagingFactory factory = (IWICImagingFactory)new WICImagingFactory(); IWICPalette palette = factory.CreatePalette(); try { method(palette); try { if (palette.GetColorCount() == 0) { form.Add(this, method.ToString(Resources._0_ZeroColorPalette), de); } } catch (Exception e) { form.Add(this, method.ToString(Resources._0_IncorrectStatePalette), de, new DataEntry(e)); } } catch (Exception e) { form.CheckHRESULT(this, WinCodecError.WINCODEC_ERR_PALETTEUNAVAILABLE, e, de); } finally { palette.ReleaseComObject(); factory.ReleaseComObject(); } }
void CheckGetColorContexts(MainForm form, DataEntry[] de, Func<uint, IWICColorContext[], uint> method) { IWICColorContext[] contexts = null; IWICImagingFactory factory = new WICImagingFactory() as IWICImagingFactory; try { try { contexts = new IWICColorContext[method(0, null)]; } catch (Exception e) { form.CheckHRESULT(this, WinCodecError.WINCODEC_ERR_UNSUPPORTEDOPERATION, e, "0, NULL", de); return; } if (contexts.Length > 0) { for (int i = 0; i < contexts.Length; i++) { contexts[i] = factory.CreateColorContext(); } try { method((uint)contexts.Length, contexts); int index = 0; foreach (IWICColorContext c in contexts) { if (c == null) { form.Add(this, method.ToString(Resources._0_NULLItem), de, new DataEntry(Resources.Index, index)); } index++; } } catch (Exception e) { form.Add(this, method.ToString(Resources._0_Failed), de, new DataEntry(e)); } } } finally { contexts.ReleaseComObject(); factory.ReleaseComObject(); } }
public DataReference(string id, DataEntry owner, string targetSheet, string targetId, JsonDB db) : base(id, owner) { TargetSheet = targetSheet; TargetID = targetId; _db = db; }
public static DataEntry ParseDataEntry(string dataEntryString, TextReader reader = null) { var newEntry = new DataEntry(); var type = dataEntryString.Trim(); string[] splitString; var isUdt = false; int length; if (type.ToUpper().Replace(" ", string.Empty).Contains("ARRAY[")) { splitString = type.Split(new string[] { "[", "..", "]" }, StringSplitOptions.RemoveEmptyEntries); if (splitString.Length >= 4) { if (int.TryParse(splitString[2], out length)) // See if the array end index is an integer { newEntry.ArrayEndIndex = length; } else // If not, the array index is a constant defined elsewhere { newEntry.ArrayEndIndex = new Constant <int>(splitString[2].Trim('\"')); } if (int.TryParse(splitString[1], out var arrayStart)) // Do the same as above for the start index { newEntry.ArrayStartIndex = arrayStart; } else { newEntry.ArrayStartIndex = new Constant <int>(splitString[1].Trim('\"')); } } splitString = type.Replace(" of ", " OF ").Split(new string[] { " OF " }, StringSplitOptions.RemoveEmptyEntries); var arrayType = string.Empty; if (splitString.Length > 1) { arrayType = splitString[1].Trim().Trim('"'); } else if (splitString.Length == 1 && reader != null) // Search the next line for the array type if it hasn't already been defined { string line; line = reader.ReadLine(); arrayType = line.Trim().Trim(';').Trim('\"'); } var parsedType = TagHelper.ParseDataType(arrayType); if (parsedType == DataType.UNKNOWN) { newEntry.ArrayDataEntry = new DataEntry(dataType: DataType.UDT, dataTypeName: arrayType); } else if (parsedType == DataType.STRING) { newEntry.ArrayDataEntry = new DataEntry(dataType: DataType.STRING, stringLength: ParseStringLength(arrayType)); } else if (parsedType == DataType.STRUCT) { newEntry.ArrayDataEntry = TagHelper.ParseDataEntry("STRUCT", reader); } else { newEntry.ArrayDataEntry = new DataEntry(dataType: parsedType); } type = "ARRAY"; } else if (type.Contains('"')) { var startUdt = type.IndexOf('"'); var endUdt = type.LastIndexOf('"'); if (startUdt >= 0 && endUdt >= 0) { newEntry.DataTypeName = type.Substring(startUdt + 1, endUdt - startUdt - 1); isUdt = true; } } else if (type.ToUpper().Contains("STRING")) { newEntry.StringLength = ParseStringLength(type); type = "STRING"; } else if (type.ToUpper().Contains("STRUCT") && reader != null) { newEntry.Children = new LinkedList <DataEntry>(); string line; while ((line = reader.ReadLine()) != null && !line.Contains("END_STRUCT")) { newEntry.Children.AddLast(DataEntry.FromString(line, reader)); } } DataType t; if (isUdt && type != "ARRAY") { t = DataType.UDT; } else { if (!Enum.TryParse <DataType>(type, true, out t)) { throw new SiemensException("Invalid type detected: " + type); } } newEntry.DataType = t; return(newEntry); Constant <int> ParseStringLength(string typeString) { splitString = typeString.Split(new string[] { "[", "]" }, StringSplitOptions.RemoveEmptyEntries); if (splitString.Length > 1) { if (int.TryParse(splitString[1], out length)) // Check to make sure the string length is an integer { return(length); } else // If not, it's a constant referenced elsewhere { return(new Constant <int>(splitString[1].Trim('\"'))); } } else { return(254); } } }
public void ReadData(string path, int rowNumber) { String[] row; int count4 = 0; int count2 = 0; // var rows = File.ReadLines(path, System.Text.Encoding.Default); List <string> rows = new List <string>(); using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default)) { string line; while (((line = sr.ReadLine()) != null) && rowNumber > 0) { rows.Add(line); rowNumber--; } if (rowNumber > 0) { MessageBox.Show("Количество строк, указанное вами больше, чем размер файла. Считан весь файл", "Предупреждение", MessageBoxButtons.OK); } } TrainingData = new DataEntry[rows.Count() / 2]; TestData = new List <DataEntry>(); for (int i = 0; i < rows.Count() / 2; i++) { row = rows.ElementAt(i).Split(','); TrainingData[i] = new DataEntry(row); if (TrainingData[i].EntryClass == 2) { count2++; } if (TrainingData[i].EntryClass == 4) { count4++; } } datainfo = datainfo + "Training: 2-" + count2 + ";4-" + count4 + Environment.NewLine; count2 = 0; count4 = 0; for (int i = rows.Count() / 2; i < rows.Count(); i++) { row = rows.ElementAt(i).Split(','); TestData.Add(new DataEntry(row)); if (TestData.Last().EntryClass == 2) { count2++; } if (TestData.Last().EntryClass == 4) { count4++; } } datainfo = datainfo + "Test: 2-" + count2 + ";4-" + count4; count2 = 0; count4 = 0; }
public override DataLoadResult Load() { if (!Check()) { return(DataLoadResult.NothingLoaded); } try { spae = new Buffer(path); } catch { return(DataLoadResult.NothingLoaded); } // Check that data file is decompressed try { UnpackerTPWM unpacker = new UnpackerTPWM(spae); spae = unpacker.Convert(); Log.Verbose.Write(ErrorSystemType.Data, "Data file is compressed"); } catch { Log.Verbose.Write(ErrorSystemType.Data, "Data file is not compressed"); } // Read the number of entries in the index table. // Some entries are undefined (size and offset are zero). uint entryCount = spae.Pop <uint>(); entries.Add(new DataEntry() { Offset = 0, Size = 0 }); // first entry is whole file itself, drop it for (uint i = 0; i < entryCount; ++i) { DataEntry entry = new DataEntry(); entry.Size = spae.Pop <uint>(); entry.Offset = spae.Pop <uint>(); entries.Add(entry); } FixUp(); // The first uint32 is the byte length of the rest // of the table in big endian order. Buffer anim = GetObject(DATA_SERF_ANIMATION_TABLE); anim.SetEndianess(Endian.Endianess.Big); uint size = anim.Size; if (size != anim.Pop <uint>()) { Log.Error.Write(ErrorSystemType.Data, "Could not extract animation table."); return(DataLoadResult.NothingLoaded); } anim = anim.PopTail(); loaded = LoadAnimationTable(anim); return(loaded ? DataLoadResult.AllLoaded : DataLoadResult.NothingLoaded); }
public double GetConsistency(DataEntry entry) { return((entry.targetsRelation + 1) / 2); }
private float GetHeight(DataEntry entry, DataHeader header) { return(GetHeight(Mathf.InverseLerp(header.Min, header.Max, header.GetValue(entry)))); }
void ParseDataEntry() { try { DataEntry ent = new DataEntry(); ent.Key = reader["Key2"]; ent.Type = reader["Type"]; ent.IsDeleted = reader["IsDeleted"] == "Y"; ent.TimeCreated = Convert.ToInt64(reader["TimeCreated"]); ent.TimeUpdated = Convert.ToInt64(reader["TimeUpdated"]); ent.SortKey = reader["SortKey"]; //ent.Xml = reader.ReadOuterXml(); if (ent.Type == "GV_OpenChannel") { reader.ReadStartElement(); Debug.Assert(reader.Name == "OpenChannel"); // here to read <OpenChannel> data.... ent.ChannelName = reader["Name"]; //addEventDisplay("DataEntry", "Type: " + ent.Type + ", inner: " + reader.Name + ", Key: " + ent.Key); //Trace.WriteLine(ent.Type + ", xml: " + reader.Name + ", outer: " + ent.Xml); if (reader.ReadToDescendant("CameraConfig")) { ent.Driver = reader["Driver"]; ent.Description = reader["Description"]; ent.DomainName = reader["DomainName"]; ent.IPAddress = reader["IPAddress"]; ent.IPPort = reader["IPPort"]; if (ent.IPPort == null) { ent.IPPort = "80"; } ent.Channel = reader["Channel"]; ent.UncondRec = reader["UncondRec"] == "Y"; ent.Disabled = reader["Disabled"] == "Y"; ent.Options = reader["Options"]; ent.AudioInput = reader["AudioInput"]; ent.VideoInput = reader["VideoInput"]; if (reader.ReadToDescendant("HttpAuthorization")) { ent.UserName = reader["UserName"]; ent.Password = reader["Password"]; } } } else if (ent.Type == "GV_Userlog") { reader.ReadToDescendant("Userlog"); ent.UserlogTime = Convert.ToInt64(reader["Time"]); ent.UserlogType = reader["Type"]; bool exitLoop = false; while(!exitLoop && reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "Com_EventDescription") { ent.UserlogMessageRid = reader["MessageRid"]; } else if (reader.Name == "Com_ReplaceStr") { ent.AddUserLogSymbol(reader["Name"], reader["Value"]); } break; case XmlNodeType.EndElement: if (reader.Name == "Userlog") { exitLoop = true; } break; } } } updateEntry(ent); } catch (NullReferenceException err) { Trace.WriteLine(err.ToString()); } }
protected override void Check(ListView.ListViewItemCollection collection, string ext, RegistryKey rk, IWICBitmapDecoderInfo info) { DataEntry[] de = new DataEntry[] { new DataEntry("File Extension", ext) }; string progid = CheckStringValue(collection, rk, null, de); if (!string.IsNullOrEmpty(progid)) { using (RegistryKey r = OpenSubKey(collection, rk, "OpenWithProgids", de)) { if (r != null) { if (Array.IndexOf(r.GetValueNames(), progid) < 0) { collection.Add(this, "Registry value is missing.", de, new DataEntry("Expected Values", progid), new DataEntry("Key", rk.ToString())); } } } using (RegistryKey r = OpenSubKey(collection, rk, string.Format(CultureInfo.InvariantCulture, "OpenWithList\\{0}", PhotoViewerDll), de)) { } using (RegistryKey r = OpenSubKey(collection, rk, "ShelExt\\ContextMenuHandlers\\ShellImagePreview", de)) { CheckValue(collection, r, null, new string[] { PhotoGalleryGuid }, de); } using (RegistryKey r = OpenSubKey(collection, Registry.ClassesRoot, progid, new DataEntry[0])) { CheckStringValue(collection, r, null, de); using (RegistryKey r1 = OpenSubKey(collection, r, "DefaultIcon", new DataEntry[0])) { CheckStringValue(collection, r1, null, de); // TODO get and check icon } using (RegistryKey r1 = OpenSubKey(collection, r, "shell\\open\\command", new DataEntry[0])) { CheckValue(collection, r1, null, new string [] { "%SystemRoot%\\System32\\rundll32.exe \"%ProgramFiles%\\Windows Photo Gallery\\PhotoViewer.dll\", ImageView_Fullscreen %1" }, de); } using (RegistryKey r1 = OpenSubKey(collection, r, "shell\\open", new DataEntry[0])) { CheckValue(collection, r1, "MuiVerb", new string[] { "@%ProgramFiles%\\Windows Photo Gallery\\PhotoViewer.dll,-3043" }, de); } using (RegistryKey r1 = OpenSubKey(collection, r, "shell\\open\\DropTarget", new DataEntry[0])) { CheckValue(collection, r1, "Clsid", new string[] { PhotoGalleryGuid }, de); } using (RegistryKey r1 = OpenSubKey(collection, r, "shell\\printto\\command", new DataEntry[0])) { CheckValue(collection, r1, null, new string[] { "%SystemRoot%\\System32\\rundll32.exe \"%ProgramFiles%\\Windows Photo Gallery\\PhotoViewer.dll\", ImageView_PrintTo /pt \"%1\" \"%2\" \"%3\" \"%4\"" }, de); } } } using (RegistryKey r = OpenSubKey(collection, Registry.ClassesRoot, string.Format(CultureInfo.InvariantCulture, "SystemFileAssociations\\{0}", ext), new DataEntry[0])) { using (RegistryKey r2 = OpenSubKey(collection, r, "ShellEx\\ContextMenuHandlers\\ShellImagePreview", de)) { CheckValue(collection, r2, null, new string[] { PhotoGalleryGuid }, de); } } }
void ReceiveThread() { try { Trace.WriteLine("ReceiveThread..."); addEventDisplay("Connection", "Connecting to remote host: " + edRemoteHost.Text + ":" + edPort.Text); client = new TcpClient(edRemoteHost.Text, Convert.ToInt32(edPort.Text)); addEventDisplay("Connection", "Connected to remote host: " + edRemoteHost.Text + ":" + edPort.Text); XmlWriterSettings xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = true; xws.Encoding = new UTF8Encoding(false); xws.ConformanceLevel = ConformanceLevel.Fragment; writer = XmlWriter.Create(client.GetStream(), xws); writer.WriteStartElement("Login"); writer.WriteAttributeString("UserName", "Handshake"); writer.WriteAttributeString("Password", "7157d7fa-5f8b-44eb-946c-e05940fa3b0e"); writer.WriteAttributeString("Pin", "CxClient"); writer.WriteEndElement(); writer.Flush(); XmlReaderSettings xrs = new XmlReaderSettings(); xrs.ConformanceLevel = ConformanceLevel.Fragment; reader = XmlReader.Create(client.GetStream(), xrs); reader.Read(); Debug.Assert(reader.Name == "LoginResult" && reader["Status"] == "200" && reader["Message"] == "OK"); writer.WriteStartElement("InitControlConnection"); writer.WriteAttributeString("Cookie", Convert.ToString(DateTime.Now.ToFileTime())); writer.WriteStartElement("Com_LoginRequest"); writer.WriteAttributeString("UserName", edUserName.Text); writer.WriteAttributeString("Password", GetSHA1(edPassword.Text)); writer.WriteAttributeString("ClientVersion", "1"); writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); reader.Read(); if (reader.Name == "UserAccess") { if (reader["AccessDenied"] != "Y") { DataEntry s = new DataEntry(); s.Key = "Ch:/Sys"; s.Type = "SysChannel"; // special object updateEntry(s); addEventDisplay("Connection", "Connected and authorized"); } mAuthKey = reader["AuthorizeKey"]; Trace.WriteLine("MQConn.1"); mqclient = new TcpClient(edRemoteHost.Text, Convert.ToInt32(edPort.Text)); addEventDisplay("MQConnection", "Connected to remote host: " + edRemoteHost.Text + ":" + edPort.Text); mqwriter = XmlWriter.Create(mqclient.GetStream(), xws); mqwriter.WriteStartElement("Login"); mqwriter.WriteAttributeString("UserName", "TestUser"); mqwriter.WriteAttributeString("Password", mAuthKey); mqwriter.WriteAttributeString("Pin", "CxClient"); mqwriter.WriteEndElement(); mqwriter.Flush(); Trace.WriteLine("MQConn.2"); mqreader = XmlReader.Create(mqclient.GetStream(), xrs); Trace.WriteLine("MQConn.3"); mqreader.Read(); Trace.WriteLine("MQConn.4: " + mqreader["Status"]); if (mqreader["Status"] == "200") // success { mqthread = new Thread(new ThreadStart(MQReadThread)); mqthread.Start(); } this.Invoke(new EnableQueryButton(EnableQButton), new object[1] { true }); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Depth == 0) { this.Invoke((MyDelegate)ParseTopLevelXml); } break; } } } else { addEventDisplay("Connection", "Access denied!"); } Trace.WriteLine("ReceiveThread().2"); } catch(Exception err) { Trace.WriteLine("ReceiveThread() aborted: " + err); } }
public void DataParseTest() { string xml = @"<?xml version='1.0' encoding='UTF-8'?> <feed xmlns='http://www.w3.org/2005/Atom' xmlns:dxp='http://schemas.google.com/analytics/2009' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"DUINSHcycSp7I2A9WxRWFEQ."' gd:kind='analytics#data'> <id>http://www.google.com/analytics/feeds/data?ids=ga:1174&dimensions=ga:medium,ga:source&metrics=ga:bounces,ga:visits&filters=ga:medium%3D%3Dreferral&start-date=2008-10-01&end-date=2008-10-31</id> <updated>2008-10-31T16:59:59.999-07:00</updated> <title>Google Analytics Data for Profile 1174</title> <link rel='self' type='application/atom+xml' href='http://www.google.com/analytics/feeds/data?max-results=5&sort=-ga%3Avisits&end-date=2008-10-31&start-date=2008-10-01&metrics=ga%3Avisits%2Cga%3Abounces&ids=ga%3A1174&dimensions=ga%3Asource%2Cga%3Amedium&filters=ga%3Amedium%3D%3Dreferral'/> <link rel='next' type='application/atom+xml' href='http://www.google.com/analytics/feeds/data?start-index=6&max-results=5&sort=-ga%3Avisits&end-date=2008-10-31&start-date=2008-10-01&metrics=ga%3Avisits%2Cga%3Abounces&ids=ga%3A1174&dimensions=ga%3Asource%2Cga%3Amedium&filters=ga%3Amedium%3D%3Dreferral'/> <author> <name>Google Analytics</name> </author> <generator version='1.0'>Google Analytics</generator> <openSearch:totalResults>6451</openSearch:totalResults> <openSearch:startIndex>1</openSearch:startIndex> <openSearch:itemsPerPage>5</openSearch:itemsPerPage> <dxp:aggregates> <dxp:metric confidenceInterval='0.0' name='ga:visits' type='integer' value='136540'/> <dxp:metric confidenceInterval='0.0' name='ga:bounces' type='integer' value='101535'/> </dxp:aggregates> <dxp:dataSource> <dxp:property name='ga:profileId' value='1174'/> <dxp:property name='ga:webPropertyId' value='UA-30481-1'/> <dxp:property name='ga:accountName' value='Google Store'/> <dxp:tableId>ga:1174</dxp:tableId> <dxp:tableName>www.googlestore.com</dxp:tableName> </dxp:dataSource> <dxp:endDate>2008-10-31</dxp:endDate> <dxp:startDate>2008-10-01</dxp:startDate> <dxp:segment id='gaid::-11' name='Mobile Traffic'> <dxp:definition>ga:operatingSystem==iPhone</dxp:definition> </dxp:segment> <entry gd:etag='W/"C0UEQX47eSp7I2A9WxRWFEw."' gd:kind='analytics#datarow'> <id>http://www.google.com/analytics/feeds/data?ids=ga:1174&ga:medium=referral&ga:source=blogger.com&filters=ga:medium%3D%3Dreferral&start-date=2008-10-01&end-date=2008-10-31</id> <updated>2008-10-30T17:00:00.001-07:00</updated> <title>ga:source=blogger.com | ga:medium=referral</title> <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/> <dxp:dimension name='ga:source' value='blogger.com'/> <dxp:dimension name='ga:medium' value='referral'/> <dxp:metric confidenceInterval='0.0' name='ga:visits' type='integer' value='68140'/> <dxp:metric confidenceInterval='0.0' name='ga:bounces' type='integer' value='61095'/> </entry> <entry gd:etag='W/"C0UEQX47eSp7I2A9WxRWFEw."' gd:kind='analytics#datarow'> <id>http://www.google.com/analytics/feeds/data?ids=ga:1174&ga:medium=referral&ga:source=google.com&filters=ga:medium%3D%3Dreferral&start-date=2008-10-01&end-date=2008-10-31</id> <updated>2008-10-30T17:00:00.001-07:00</updated> <title>ga:source=google.com | ga:medium=referral</title> <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/> <dxp:dimension name='ga:source' value='google.com'/> <dxp:dimension name='ga:medium' value='referral'/> <dxp:metric confidenceInterval='0.0' name='ga:visits' type='integer' value='29666'/> <dxp:metric confidenceInterval='0.0' name='ga:bounces' type='integer' value='14979'/> </entry> </feed> "; Google.GData.Analytics.DataFeed feed = Parse(xml); Dataset f = new Dataset(feed); f.AutoPaging = false; Assert.IsNotNull(f.Aggregates); Assert.IsNotNull(f.DataSource); Assert.IsNotNull(f.Entries); Assert.AreEqual(136540, f.Aggregates.Metrics[0].IntegerValue); Assert.AreEqual("0.0", f.Aggregates.Metrics[0].ConfidenceInterval); Assert.AreEqual("ga:visits", f.Aggregates.Metrics[0].Name); Assert.AreEqual("integer", f.Aggregates.Metrics[0].Type); Assert.AreEqual("ga:1174", f.DataSource.TableId); Assert.AreEqual("www.googlestore.com", f.DataSource.TableName); Assert.AreEqual("1174", f.DataSource.ProfileId); Assert.AreEqual("UA-30481-1", f.DataSource.WebPropertyId); Assert.AreEqual("Google Store", f.DataSource.AccountName); Assert.AreEqual(136540, Int32.Parse(feed.Aggregates.Metrics[0].Value)); DataEntry blogger = feed.Entries[0] as DataEntry; Assert.IsNotNull(blogger, "entry"); Assert.IsNotNull(blogger.Dimensions); Assert.IsNotNull(blogger.Metrics); Assert.AreEqual("ga:source", blogger.Dimensions[0].Name); Assert.AreEqual("blogger.com", blogger.Dimensions[0].Value); Assert.AreEqual("ga:visits", blogger.Metrics[0].Name); Assert.AreEqual(68140, int.Parse(blogger.Metrics[0].Value)); DataEntry google = feed.Entries[1] as DataEntry; Assert.IsNotNull(google, "entry"); Assert.IsNotNull(google.Dimensions); Assert.IsNotNull(google.Metrics); Assert.AreEqual("ga:source", google.Dimensions[0].Name); Assert.AreEqual("google.com", google.Dimensions[0].Value); Assert.AreEqual("ga:visits", google.Metrics[0].Name); Assert.AreEqual(29666, int.Parse(google.Metrics[0].Value)); foreach (DataEntry entry in feed.Entries) { Assert.IsNotNull(entry, "entry"); Assert.IsNotNull(entry.Dimensions); Assert.IsNotNull(entry.Metrics); Assert.AreEqual("ga:source", entry.Dimensions[0].Name); Assert.IsNotEmpty(entry.Dimensions[0].Value); Assert.AreEqual("ga:visits", entry.Metrics[0].Name); Assert.Greater(int.Parse(entry.Metrics[0].Value), 0); } foreach (Data d in f.Entries) { Assert.IsNotNull(d, "entry"); Assert.IsNotNull(d.Dimensions); Assert.IsNotNull(d.Metrics); Assert.AreEqual("ga:source", d.Dimensions[0].Name); Assert.IsNotEmpty(d.Dimensions[0].Value); Assert.AreEqual("ga:visits", d.Metrics[0].Name); Assert.Greater(int.Parse(d.Metrics[0].Value), 0); } Assert.IsNotEmpty(feed.Segments); Segment s = feed.Segments[0]; Assert.IsNotNull(s.Name); Assert.AreEqual(s.Id, "gaid::-11"); Assert.IsNotNull(s.Id); Assert.AreEqual(s.Name, "Mobile Traffic"); Assert.IsNotNull(s.Definition); Assert.IsNotEmpty(s.Definition.Value); Assert.AreEqual(s.Definition.Value, "ga:operatingSystem==iPhone"); }
void updateEntry(DataEntry ent) { if (InvokeRequired) { Invoke((UpdateEntryDelegate)updateEntry, ent); return; } DataEntry old; if (EntryMap.ContainsKey(ent.Key)) { old = EntryMap[ent.Key]; if (old.lvi != null) { old.lvi.Remove(); old.lvi = null; } if (ent.IsDeleted) { EntryMap.Remove(ent.Key); return; } } if (ent.IsDeleted) return; if (ent.Type == "GV_OpenChannel") { ent.lvi = lvChannels.Items.Add(ent.ChannelName); ent.lvi.SubItems.Add(""); ent.lvi.SubItems.Add(ent.Driver); ent.lvi.Tag = ent; } else if (ent.Type == "SysChannel") { ent.lvi = lvChannels.Items.Add("(System)"); ent.lvi.Tag = ent; } else if (ent.Type == "GV_Userlog") { ent.lvi = lvUserlog.Items.Add(humanTime(ent.UserlogTime)); ent.lvi.SubItems.Add(ent.UserlogType); ent.lvi.SubItems.Add(ent.UserlogMessageRid); String str = ""; if (ent.UserlogSymbols != null) { foreach (String s in ent.UserlogSymbols.Keys) { if (str.Length > 0) { str += ", "; } String value = ent.UserlogSymbols[s]; str += s + "=>" + value; } } ent.lvi.SubItems.Add(str); } EntryMap[ent.Key] = ent; }
public ImageSource GetIconForEntry(DataEntry dataEntry) { return(new BitmapImage(new Uri("/Resources/Images/Folder.png", UriKind.Relative))); }
protected override void Check(ListView.ListViewItemCollection collection, string ext, RegistryKey rk, IWICBitmapDecoderInfo info) { DataEntry[] de = new DataEntry[] { new DataEntry("File Extension", ext)}; string progid = CheckStringValue(collection, rk, null, de); if (!string.IsNullOrEmpty(progid)) { using (RegistryKey r = OpenSubKey(collection, rk, "OpenWithProgids", de)) { if (r != null) { if (Array.IndexOf(r.GetValueNames(), progid) < 0) { collection.Add(this, "Registry value is missing.", de, new DataEntry("Expected Values", progid), new DataEntry("Key", rk.ToString())); } } } using (RegistryKey r = OpenSubKey(collection, rk, string.Format(CultureInfo.InvariantCulture, "OpenWithList\\{0}", PhotoViewerDll), de)) { } using (RegistryKey r = OpenSubKey(collection, rk, "ShelExt\\ContextMenuHandlers\\ShellImagePreview", de)) { CheckValue(collection, r, null, new string[] { PhotoGalleryGuid }, de); } using (RegistryKey r = OpenSubKey(collection, Registry.ClassesRoot, progid, new DataEntry[0])) { CheckStringValue(collection, r, null, de); using (RegistryKey r1 = OpenSubKey(collection, r, "DefaultIcon", new DataEntry[0])) { CheckStringValue(collection, r1, null, de); // TODO get and check icon } using (RegistryKey r1 = OpenSubKey(collection, r, "shell\\open\\command", new DataEntry[0])) { CheckValue(collection, r1, null, new string []{"%SystemRoot%\\System32\\rundll32.exe \"%ProgramFiles%\\Windows Photo Gallery\\PhotoViewer.dll\", ImageView_Fullscreen %1"}, de); } using (RegistryKey r1 = OpenSubKey(collection, r, "shell\\open", new DataEntry[0])) { CheckValue(collection, r1, "MuiVerb", new string[] { "@%ProgramFiles%\\Windows Photo Gallery\\PhotoViewer.dll,-3043" }, de); } using (RegistryKey r1 = OpenSubKey(collection, r, "shell\\open\\DropTarget", new DataEntry[0])) { CheckValue(collection, r1, "Clsid", new string[] { PhotoGalleryGuid }, de); } using (RegistryKey r1 = OpenSubKey(collection, r, "shell\\printto\\command", new DataEntry[0])) { CheckValue(collection, r1, null, new string[] { "%SystemRoot%\\System32\\rundll32.exe \"%ProgramFiles%\\Windows Photo Gallery\\PhotoViewer.dll\", ImageView_PrintTo /pt \"%1\" \"%2\" \"%3\" \"%4\"" }, de); } } } using (RegistryKey r = OpenSubKey(collection, Registry.ClassesRoot, string.Format(CultureInfo.InvariantCulture, "SystemFileAssociations\\{0}", ext), new DataEntry[0])) { using (RegistryKey r2 = OpenSubKey(collection, r, "ShellEx\\ContextMenuHandlers\\ShellImagePreview", de)) { CheckValue(collection, r2, null, new string[] { PhotoGalleryGuid }, de); } } }
public Task <DataViewer> GetDataViewer(DataEntry dataEntry, IDataConnection dataConnection) { throw new NotImplementedException(); }
int AddInternal(int jobId, object data, string dataType, DataEntryType entryType) { if (data == null) throw new ArgumentNullException("data"); if (dataType == null) throw new ArgumentNullException("dataType"); lock (_jsonStore) { var maxId = _jsonStore.Keys.Any() ? _jsonStore.Keys.Max() : 0; var id = maxId + 1; _jsonStore[id] = new DataEntry { JobId = jobId, Data = JsonConvert.SerializeObject(data), DataType = dataType, Type = entryType }; return id; } }
void CheckGetBitmapSource(MainForm form, DataEntry[] de, Func<IWICBitmapSource> method, WinCodecError error) { IWICBitmapSource bs = null; try { bs = method(); } catch (Exception e) { form.CheckHRESULT(this, error, e, de); } finally { bs.ReleaseComObject(); } }
public static DataAddRequestBuilder Add(DataEntry dataEntry) { return(new DataAddRequestBuilder(dataEntry)); }
private static IDiagnoseOutputEntry ParseDataEntryToDiagnoseOutputEntry(DataEntry dataEntry) { DateTime dateTimeParseBuffer; var type = dataEntry.State != null ? dataEntry.State.Trim() : string.Empty; return new DiagnoseOutputEntry( DateTime.TryParse(dataEntry.Timestamp.Replace(',', ':'), out dateTimeParseBuffer) ? dateTimeParseBuffer : DateTime.MinValue, Convert.ToInt64(dataEntry.Gap), Convert.ToInt64(dataEntry.Duration), Convert.ToInt32(dataEntry.ProcessId), Convert.ToInt32(dataEntry.Thread), type.Length > 0 ? TypeCharToTypeEnumLookUp[type.Last()] : DiagnoseType.SingleOutput, dataEntry.Domain, dataEntry.Application, dataEntry.Component, dataEntry.Module, dataEntry.Code, dataEntry.Text, dataEntry.Parent); }
public static DataUpdateRequestBuilder Update(string entryId, DataEntry documentEntry) { return(new DataUpdateRequestBuilder(entryId, documentEntry)); }
/// <summary> /// Loads all shaders from the cache. /// </summary> /// <param name="context">GPU context</param> /// <param name="loader">Parallel disk cache loader</param> public void LoadShaders(GpuContext context, ParallelDiskCacheLoader loader) { if (!CacheExists()) { return; } Stream hostTocFileStream = null; Stream hostDataFileStream = null; try { using var tocFileStream = DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: false); using var dataFileStream = DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: false); using var guestTocFileStream = _guestStorage.OpenTocFileStream(); using var guestDataFileStream = _guestStorage.OpenDataFileStream(); BinarySerializer tocReader = new BinarySerializer(tocFileStream); BinarySerializer dataReader = new BinarySerializer(dataFileStream); TocHeader header = new TocHeader(); if (!tocReader.TryRead(ref header) || header.Magic != TocsMagic) { throw new DiskCacheLoadException(DiskCacheLoadResult.FileCorruptedGeneric); } if (header.FormatVersion != FileFormatVersionPacked) { throw new DiskCacheLoadException(DiskCacheLoadResult.IncompatibleVersion); } bool loadHostCache = header.CodeGenVersion == CodeGenVersion; int programIndex = 0; DataEntry entry = new DataEntry(); while (tocFileStream.Position < tocFileStream.Length && loader.Active) { ulong dataOffset = 0; tocReader.Read(ref dataOffset); if ((ulong)dataOffset >= (ulong)dataFileStream.Length) { throw new DiskCacheLoadException(DiskCacheLoadResult.FileCorruptedGeneric); } dataFileStream.Seek((long)dataOffset, SeekOrigin.Begin); dataReader.BeginCompression(); dataReader.Read(ref entry); uint stagesBitMask = entry.StagesBitMask; if ((stagesBitMask & ~0x3fu) != 0) { throw new DiskCacheLoadException(DiskCacheLoadResult.FileCorruptedGeneric); } bool isCompute = stagesBitMask == 0; if (isCompute) { stagesBitMask = 1; } GuestCodeAndCbData?[] guestShaders = new GuestCodeAndCbData?[isCompute ? 1: Constants.ShaderStages + 1]; DataEntryPerStage stageEntry = new DataEntryPerStage(); while (stagesBitMask != 0) { int stageIndex = BitOperations.TrailingZeroCount(stagesBitMask); dataReader.Read(ref stageEntry); guestShaders[stageIndex] = _guestStorage.LoadShader( guestTocFileStream, guestDataFileStream, stageEntry.GuestCodeIndex); stagesBitMask &= ~(1u << stageIndex); } ShaderSpecializationState specState = ShaderSpecializationState.Read(ref dataReader); dataReader.EndCompression(); if (loadHostCache) { (byte[] hostCode, CachedShaderStage[] shaders) = ReadHostCode( context, ref hostTocFileStream, ref hostDataFileStream, guestShaders, programIndex, header.Timestamp); if (hostCode != null) { bool hasFragmentShader = shaders.Length > 5 && shaders[5] != null; int fragmentOutputMap = hasFragmentShader ? shaders[5].Info.FragmentOutputMap : -1; ShaderInfo shaderInfo = specState.PipelineState.HasValue ? new ShaderInfo(fragmentOutputMap, specState.PipelineState.Value, fromCache: true) : new ShaderInfo(fragmentOutputMap, fromCache: true); IProgram hostProgram; if (context.Capabilities.Api == TargetApi.Vulkan) { ShaderSource[] shaderSources = ShaderBinarySerializer.Unpack(shaders, hostCode, isCompute); hostProgram = context.Renderer.CreateProgram(shaderSources, shaderInfo); } else { hostProgram = context.Renderer.LoadProgramBinary(hostCode, hasFragmentShader, shaderInfo); } CachedShaderProgram program = new CachedShaderProgram(hostProgram, specState, shaders); loader.QueueHostProgram(program, hostCode, programIndex, isCompute); } else { loadHostCache = false; } } if (!loadHostCache) { loader.QueueGuestProgram(guestShaders, specState, programIndex, isCompute); } loader.CheckCompilation(); programIndex++; } } finally { _guestStorage.ClearMemoryCache(); hostTocFileStream?.Dispose(); hostDataFileStream?.Dispose(); } }
protected override void Check(MainForm form, string ext, RegistryKey rk, DataEntry[] de) { bool openWith = false; bool imagePreview = false; string progid = CheckStringValue(form, rk, null, de); if (!string.IsNullOrEmpty(progid)) { using (RegistryKey r = OpenSubKey(form, rk, "OpenWithProgids", de)) { if (r != null) { if (Array.IndexOf(r.GetValueNames(), progid) < 0) { form.Add(this, Resources.MissingRegistryValue, de, new DataEntry(Resources.Value, progid), new DataEntry(Resources.Key, rk.ToString())); } } } using (RegistryKey r = OpenSubKey(form, rk, string.Format(CultureInfo.InvariantCulture, "OpenWithList\\{0}", PhotoViewerDll), de, ref openWith)) { } using (RegistryKey r = OpenSubKey(form, rk, "ShellExt\\ContextMenuHandlers\\ShellImagePreview", de, ref imagePreview)) { CheckValue(form, r, null, new string[] { PhotoGalleryGuid }, de); } using (RegistryKey r = OpenSubKey(form, Registry.ClassesRoot, progid, new DataEntry[0])) { CheckStringValue(form, r, null, de); using (RegistryKey r1 = OpenSubKey(form, r, "DefaultIcon", new DataEntry[0])) { string iconPath = CheckStringValue(form, r1, null, de); if (!string.IsNullOrEmpty(iconPath)) { using (TempFileCollection t = new TempFileCollection()) { string file = t.AddExtension(ext); File.WriteAllBytes(file, new byte[0]); try { Icon.ExtractAssociatedIcon(file).Dispose(); } catch (Exception e) { form.Add(this, Resources.CannotExtractIcon, de, new DataEntry(Resources.Key, r1.ToString()), new DataEntry(Resources.Value, Resources.RegistryValue_default), new DataEntry(Resources.Actual, iconPath), new DataEntry(e)); } } } } using (RegistryKey r1 = OpenSubKey(form, r, "shell\\open\\command", new DataEntry[0])) { CheckValue(form, r1, null, new string[] { string.Format(CultureInfo.InvariantCulture, "%SystemRoot%\\System32\\rundll32.exe \"{0}\", ImageView_Fullscreen %1", PhotoGalleryPath) }, de); } using (RegistryKey r1 = OpenSubKey(form, r, "shell\\open", new DataEntry[0])) { CheckValue(form, r1, "MuiVerb", new string[] { string.Format(CultureInfo.InvariantCulture, "@{0},-3043", PhotoGalleryPath) }, de); } using (RegistryKey r1 = OpenSubKey(form, r, "shell\\open\\DropTarget", new DataEntry[0])) { CheckValue(form, r1, "Clsid", new string[] { PhotoGalleryGuid }, de); } using (RegistryKey r1 = OpenSubKey(form, r, "shell\\printto\\command", new DataEntry[0])) { CheckValue(form, r1, null, new string[] { "%SystemRoot%\\System32\\rundll32.exe \"%SystemRoot%\\System32\\shimgvw.dll\", ImageView_PrintTo /pt \"%1\" \"%2\" \"%3\" \"%4\"" }, de); } } } using (RegistryKey r = OpenSubKey(form, Registry.ClassesRoot, string.Format(CultureInfo.InvariantCulture, "SystemFileAssociations\\{0}", ext), new DataEntry[0])) { using (RegistryKey r1 = OpenSubKey(form, r, string.Format(CultureInfo.InvariantCulture, "OpenWithList\\{0}", PhotoViewerDll), de, ref openWith)) { } using (RegistryKey r2 = OpenSubKey(form, r, "ShellEx\\ContextMenuHandlers\\ShellImagePreview", de, ref imagePreview)) { CheckValue(form, r2, null, new string[] { PhotoGalleryGuid }, de); } } if (!openWith) { form.Add(this, Resources.MissingRegistryKey, de, new DataEntry(Resources.Key, new string[] { string.Format(CultureInfo.InvariantCulture, "{2}\\{0}\\OpenWithList\\{1}", ext, PhotoViewerDll, Registry.ClassesRoot), string.Format(CultureInfo.InvariantCulture, "{2}\\SystemFileAssociations\\{0}\\OpenWithList\\{1}", ext, PhotoViewerDll, Registry.ClassesRoot) })); } if (!imagePreview) { form.Add(this, Resources.MissingRegistryKey, de, new DataEntry(Resources.Key, new string[] { string.Format(CultureInfo.InvariantCulture, "{2}\\{0}\\ShellEx\\ContextMenuHandlers\\ShellImagePreview", ext, PhotoViewerDll, Registry.ClassesRoot), string.Format(CultureInfo.InvariantCulture, "{2}\\SystemFileAssociations\\{0}\\ShellEx\\ContextMenuHandlers\\ShellImagePreview", ext, PhotoViewerDll, Registry.ClassesRoot) })); } }
public static void Encode(IByteWriter stream, DataEntry encodedDataEntry) { AccountID.Encode(stream, encodedDataEntry.AccountID); String64.Encode(stream, encodedDataEntry.DataName); DataValue.Encode(stream, encodedDataEntry.DataValue); DataEntryExt.Encode(stream, encodedDataEntry.Ext); }
public void readData(string[] data) { DataEntry dataEntry; string parseType = ""; for (int i = 0; i < data.Length; i++) { if (data[i] == DataHeadings.hrData) { parseType = DataHeadings.hrData; i++; } if (data[i] == DataHeadings.docInfo) { parseType = DataHeadings.docInfo; i++; } if (data[i] == DataHeadings.intTimes) { parseType = DataHeadings.intTimes; i++; } if (parseType == DataHeadings.docInfo) { string[] columns = data[i].Split('='); if (columns[0] == Params.version) { session.setVersion(columns[1]); } if (columns[0] == Params.date) { session.setDate(columns[1]); } if (columns[0] == Params.length) { session.setLenth(columns[1]); } if (columns[0] == Params.sMode) { session.setSMode(columns[1]); } if (columns[0] == Params.startTime) { session.setStartTime(columns[1]); } if (columns[0] == Params.interval) { session.setInterval(columns[1]); } } if (parseType == DataHeadings.hrData) { string[] columns = data[i].Split(null); dataEntry = new DataEntry(); dataEntry.setEntry(int.Parse(columns[0]), int.Parse(columns[1]), int.Parse(columns[2]), int.Parse(columns[3]), int.Parse(columns[4]), int.Parse(columns[5])); sessionData.Add(dataEntry); } } }
/// <summary> /// Adds a shader to the cache. /// </summary> /// <param name="context">GPU context</param> /// <param name="program">Cached program</param> /// <param name="hostCode">Optional host binary code</param> /// <param name="streams">Output streams to use</param> public void AddShader(GpuContext context, CachedShaderProgram program, ReadOnlySpan <byte> hostCode, DiskCacheOutputStreams streams = null) { uint stagesBitMask = 0; for (int index = 0; index < program.Shaders.Length; index++) { var shader = program.Shaders[index]; if (shader == null || (shader.Info != null && shader.Info.Stage == ShaderStage.Compute)) { continue; } stagesBitMask |= 1u << index; } var tocFileStream = streams != null ? streams.TocFileStream : DiskCacheCommon.OpenFile(_basePath, SharedTocFileName, writable: true); var dataFileStream = streams != null ? streams.DataFileStream : DiskCacheCommon.OpenFile(_basePath, SharedDataFileName, writable: true); ulong timestamp = (ulong)DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds; if (tocFileStream.Length == 0) { TocHeader header = new TocHeader(); CreateToc(tocFileStream, ref header, TocsMagic, CodeGenVersion, timestamp); } tocFileStream.Seek(0, SeekOrigin.End); dataFileStream.Seek(0, SeekOrigin.End); BinarySerializer tocWriter = new BinarySerializer(tocFileStream); BinarySerializer dataWriter = new BinarySerializer(dataFileStream); ulong dataOffset = (ulong)dataFileStream.Position; tocWriter.Write(ref dataOffset); DataEntry entry = new DataEntry(); entry.StagesBitMask = stagesBitMask; dataWriter.BeginCompression(DiskCacheCommon.GetCompressionAlgorithm()); dataWriter.Write(ref entry); DataEntryPerStage stageEntry = new DataEntryPerStage(); for (int index = 0; index < program.Shaders.Length; index++) { var shader = program.Shaders[index]; if (shader == null) { continue; } stageEntry.GuestCodeIndex = _guestStorage.AddShader(shader.Code, shader.Cb1Data); dataWriter.Write(ref stageEntry); } program.SpecializationState.Write(ref dataWriter); dataWriter.EndCompression(); if (streams == null) { tocFileStream.Dispose(); dataFileStream.Dispose(); } if (hostCode.IsEmpty) { return; } WriteHostCode(context, hostCode, program.Shaders, streams, timestamp); }
public static IAdaptableControl DefaultFactoryCreate(FactoryInvocationArgs aArgs) { IAdaptableControl wdg; if (aArgs.State == PropertyDefinition.ReadOnly) wdg = new DataLabel(); else wdg = new DataEntry(); wdg.Mappings = aArgs.PropertyName; return (wdg); }
private void Button_Click_1(object sender, RoutedEventArgs e) { char delimeter = '_'; string[] tempString; DataEntry tempDataEntry = new DataEntry(); Excel.Workbook TemplateWB; Excel.Worksheet TemplateWS; Excel.Range destrng; foreach (string filename in listBox.Items) { TemplateWB = mainApp.Workbooks.Open(@"C:\Users\Bryan\Desktop\Dell Testing\CDA_Tool_Dell 0820 (2).xlsx"); TemplateWS = TemplateWB.Sheets[2]; Excel.Worksheet calculatorWS = TemplateWB.Sheets["Calculator"]; destrng = TemplateWS.get_Range("A1:F80"); tempDataEntry.gamma = "2.2"; string destPath = @"C:\Users\Bryan\Desktop\Dell Testing\temp\update\"; string destPathAndFile = string.Concat(destPath, (string.Concat(System.IO.Path.GetFileNameWithoutExtension(filename), ".xlsx"))); tempString = System.IO.Path.GetFileNameWithoutExtension(filename).Split(delimeter); tempDataEntry.fileName = filename; tempDataEntry.colorSpace = tempString[2]; tempDataEntry.whitePoint = tempString[3]; if (tempDataEntry.colorSpace.Equals("DCIP3")) { tempDataEntry.gamma = "2.6"; } else if (tempDataEntry.colorSpace.Equals("REC709")) { tempDataEntry.gamma = "2.4"; } Excel.Workbook srcWB = mainApp.Workbooks.Open(filename); Excel.Worksheet srcWS = srcWB.Sheets[1]; Excel.Range srcrng = srcWS.get_Range("A1:F80"); srcrng.Copy(destrng); TemplateWS = TemplateWB.Sheets[3]; destrng = TemplateWS.get_Range("Q7"); destrng.Value2 = tempDataEntry.gamma; destrng = TemplateWS.get_Range("Q9"); if (tempDataEntry.colorSpace.Equals("AdRGB")) destrng.Value2 = "Adobe RGB"; else if (tempDataEntry.colorSpace.Equals("DCIP3")) destrng.Value2 = "DCI-P3"; else if (tempDataEntry.colorSpace.Equals("REC709")) destrng.Value2 = "Rec. 709/HDTV"; else if (tempDataEntry.colorSpace.Equals("REC601")) destrng.Value2 = "Rec. 601/SMPTE-C"; else if (tempDataEntry.colorSpace.Equals("FULL")) destrng.Value2 = "xNative"; else if (tempDataEntry.colorSpace.Equals("SRGB")) destrng.Value2 = "sRGB"; destrng = TemplateWS.get_Range("Q10"); if (tempDataEntry.whitePoint.Equals("5000")) destrng.Value2 = "D50 "; else if (tempDataEntry.whitePoint.Equals("6500")) destrng.Value2 = "D65 "; else if (tempDataEntry.whitePoint.Equals("8200")) destrng.Value2 = "8200K"; else if (tempDataEntry.whitePoint.Equals("9300")) destrng.Value2 = "9300K"; else if (tempDataEntry.whitePoint.Equals("10000")) destrng.Value2 = "10000K"; srcWB.Close(false); TemplateWB.SaveAs(destPathAndFile); TemplateWB.Close(false); } }
/// <summary> /// Gets a certain number of data points starting at a call number /// </summary> /// <param name="results">where to append data points to</param> /// <param name="startCallNum">starting call number</param> /// <param name="count">how many data points to load</param> /// <param name="forward">if true then loading is in increasing call num direction</param> public void QueryCount(ref List <DataEntry> results, string startCallNum, int count, bool forward) { if (!Connected) { return; } // construct query string op, order; if (forward) { op = ">"; order = "ASC"; } else { op = "<"; order = "DESC"; } var query = string.Format( "SELECT * FROM {0} " + "WHERE call {1} '{2}' " + "ORDER BY call {3} " + "LIMIT {4}", tableName, op, startCallNum, order, count); // execute query var command = connection.CreateCommand(); command.CommandText = query; IDataReader reader; try { reader = command.ExecuteReader(CommandBehavior.SingleResult); } catch (Exception e) { Debug.LogError("Database excpetion: " + e.ToString()); return; } var table = new DataTable(); table.Load(reader); var id = table.Columns["id"]; var call = table.Columns["call"]; var title = table.Columns["title"]; var author = table.Columns["author"]; var width = table.Columns["width"]; var genre = table.Columns["genre"]; var subject = table.Columns["subject"]; var summary = table.Columns["summary"]; foreach (DataRow row in table.Rows) { var entry = new DataEntry { Id = row[id] as string, Call = row[call] as string, Title = row[title] as string, Author = row[author] as string, Width = Convert.ToDouble(row[width]), Genre = row[genre] as string, Subject = row[subject] as string, Summary = row[summary] as string }; results.Add(entry); } reader.Close(); command.Dispose(); }
void Read(BinaryStreamReader reader, long baseOffset) { this.Characteristics = reader.ReadUInt32(); uint timestampNum = reader.ReadUInt32(); this.Timestamp = PEFile.TimestampEpochUTC.AddSeconds(timestampNum); this.MajorVersion = reader.ReadUInt16(); this.MinorVersion = reader.ReadUInt16(); ushort nameEntryCount = reader.ReadUInt16(); ushort idEntryCount = reader.ReadUInt16(); List<DirectoryEntry> subdirectories = null; List<DataEntry> dataEntries = null; for (int i = 0; i < nameEntryCount + idEntryCount; i++) { uint idOrNameRva = reader.ReadUInt32(); uint contentRva = reader.ReadUInt32(); string name; uint id; const uint HighBit = 1U << 31; if ((idOrNameRva & HighBit)==0) { id = idOrNameRva; name = null; } else { id = 0; long savePosition = reader.Position; uint namePositon = idOrNameRva & ~HighBit; reader.Position = baseOffset + namePositon; name = ReadName(reader); reader.Position = savePosition; } if ((contentRva & HighBit) == 0) // high bit is set { var dataEntry = new DataEntry { Name = name, IntegerID = id }; long savePosition = reader.Position; reader.Position = baseOffset + contentRva; ReadResourceDataEntry(reader, dataEntry); if (dataEntries == null) dataEntries = new List<DataEntry>(); dataEntries.Add(dataEntry); reader.Position = savePosition; } else { contentRva = contentRva & ~HighBit; // clear hight bit long savePosition = reader.Position; reader.Position = baseOffset + contentRva; var directoryEntry = new DirectoryEntry { Name = name, IntegerID = id }; directoryEntry.Directory = new ResourceDirectory(); directoryEntry.Directory.Read(reader, baseOffset); if (subdirectories == null) subdirectories = new List<DirectoryEntry>(); subdirectories.Add(directoryEntry); reader.Position = savePosition; } } this.Subdirectories = subdirectories == null ? EmptyDirectoryEntries : subdirectories.ToArray(); this.DataEntries = dataEntries == null ? EmptyDataEntries : dataEntries.ToArray(); }
private DyanmicDataEntryImpl(DataEntry outer) { _outer = outer; }