public string DownloadFile(DataItem dataItem, Resolution resolution, DateTime dateTime, Currency currency) { var url = BuildFileName(dataItem, resolution, dateTime, currency); var file = DownloadFile(url); File.WriteAllBytes(SavePath + url, file); return url; }
public HomePageViewModel() { var worldRepository = new WorldDataRepository(); Data = new ObservableCollection<DataItem>(); ItemsSource = new ObservableCollection<CountryItem>(); worldRepository.GetCountries().ContinueWith(list => { Countries = list.Result; var dataItems = new ObservableCollection<DataItem>(); foreach (var item in Countries) { var countryItem = new CountryItem { Name = item.Name, Change = item.Chg1Y, IsChangePositive = item.IsChangePositive }; double val = 0.0; double.TryParse(item.LifeExpectancy, out val); countryItem.LifeExpectancy = val; ItemsSource.Add(countryItem); } foreach (var region in worldRepository.CountriesByRegion) { var dataItem = new DataItem {Label = region.Key, Level = region.Value.Sum(x => x.Level.ToDouble())}; dataItems.Add(dataItem); } WorldPopulation = dataItems.Sum(l => l.Level * 1000).ToString("#,##0,,,.B", CultureInfo.InvariantCulture); LifeExpectancy = ItemsSource.Average(x => x.LifeExpectancy).ToString("00.00", CultureInfo.InvariantCulture); Data = dataItems; }); }
public void ProcessBytes(byte[] bytes, int byteSize) { Debug.Log("SYNC IN " + dataModel.client.prefab); try { MemoryStream memStream = new MemoryStream(bytes, false); BinaryReader br = new BinaryReader(memStream); Debug.Log ("PLN: 1" ); var item = new DataItem (); item.uid = br.ReadInt32 (); item.position.x = br.ReadSingle(); item.position.y = br.ReadSingle(); item.position.z = br.ReadSingle(); item.velocity.x = br.ReadSingle(); item.velocity.y = br.ReadSingle(); item.velocity.z = br.ReadSingle(); //Debug.Log ("@" + (client== null)); syncLocally(item); }catch (Exception e){ Debug.Log(e); } }
public void GetData(Action<DataItem, Exception> callback) { // Use this to connect to the actual data service var item = new DataItem("Welcome to MVVM Light"); callback(item, null); }
/// <summary> /// Конструктор. /// </summary> /// <param name="aTopicName">Имя топика для OPC-тегов.</param> /// <param name="aOpcConnection">Соединеие с OPC-сервером.</param> public InputAreaData(string aTopicName, OpcConnectionHolder aOpcConnection) { IdCheckOutputItem = new DataItem(aTopicName + ITEMID_INPUTAREA_ID_CHECK_OUT, aOpcConnection); IdNumberOutputItem = new DataItem(aTopicName + ITEMID_INPUTAREA_ID_NUMBER_OUT, aOpcConnection); IdCheckInputItem = new DataItem(aTopicName + ITEMID_INPUTAREA_ID_CHECK_IN, aOpcConnection); IdNumberInputItem = new DataItem(aTopicName + ITEMID_INPUTAREA_ID_NUMBER_IN, aOpcConnection); }
void ProcessInput() { //Debug.Log ("IN"); float dV= 0.25f; DataItem d; if(Input.anyKeyDown){ d = dataModel.GetItem(this); Debug.Log ("PREL-- X:" + d.velocity.x +" Y:"+ d.velocity.y ); if (Input.GetKeyDown (KeyCode.W)){ d.velocity.y += dV; }else if(Input.GetKeyDown (KeyCode.S)){ d.velocity.y += -dV; }else if(Input.GetKeyDown (KeyCode.D)){ d.velocity.x += dV; }else if(Input.GetKeyDown (KeyCode.A)){ d.velocity.x += -dV; } Debug.Log ("POST-- X:" + d.velocity.x +" Y:"+ d.velocity.y ); Debug.Log ("PINTPU"); DataItem di = new DataItem(); di.uid = d.uid; di.position = d.position; di.velocity = d.velocity; dataModel.UpdateItem(di); saveDataToDataModel(); } }
public string DownloadFile(DataItem dataItem, Country country, Resolution resolution, DateTime dateTime) { var url = BuildFileName(dataItem, country, resolution, dateTime); var file = DownloadFile(url); File.WriteAllBytes(SavePath + url, file); return url; }
public void addItem(DataItem di) { Debug.Log ("ADDD " + di.uid + client.prefab); allThings[di.uid] = di; //uidObjectMap[di.uid] = go; newItems.Enqueue(di.uid); }
public Task<DataItem> GetData() { // Use this to create design time data var item = new DataItem("Welcome to MVVM Light [design]"); return Task.FromResult(item); }
public IDataItem createByForm(IConnection aConnection, IWin32Window aOwner) { Connection lConnection = (Connection)aConnection; DataItem lItem = new DataItem(); bool lCreated = false; using (var lSetupForm = new ItemSetupForm(lConnection, lItem)) { do { try { lSetupForm.ShowDialog(aOwner); if (lSetupForm.DialogResult == DialogResult.OK) { lItem = lConnection.addItem(lSetupForm.Topic, lSetupForm.Subscribe, lSetupForm.Publish, ""); lCreated = true; } else { lItem = null; } } catch (Exception lExc) { Log.Error("Error while user was creating new data item for MQQT broker '" + lConnection.mHost + ":" + lConnection.mPort + "'. " + lExc.Message, lExc.ToString()); MessageForm.showMessage(lExc.Message, aOwner); } } while (lSetupForm.DialogResult == DialogResult.OK && lCreated == false); } return lItem; }
public HomePageViewModel() { var worldRepository = new WorldDataRepository(); Data = new ObservableCollection<DataItem>(); ItemsSource = new ObservableCollection<Item>(); worldRepository.GetCountries().ContinueWith((list) => { Countries = list.Result; var data = new ObservableCollection<DataItem>(); foreach (var item in Countries) { ItemsSource.Add(new Item { Name = item.Name, Change = item.Chg1Y, IsChangePositive = item.IsChangePositive}); } foreach (var region in worldRepository.CountriesByRegion) { var dataItem = new DataItem(); dataItem.Label = region.Key; dataItem.Level = region.Value.Sum(x => x.Level.ToDouble()); data.Add(dataItem); } Data = data; }); }
public void CollectionChangedReplaceDataItemsResultInCollectionChangedForAdapter() { //create a list of dataItem containing urls IEventedList<IDataItem> dataItems = new EventedList<IDataItem>(); var oldUrl = new Url(); var newUrl = new Url(); var dataItem = new DataItem(oldUrl); dataItems.Add(dataItem); //adapter for the list var adapter = new DataItemListAdapter<Url>(dataItems); int callCount = 0; adapter.CollectionChanged += (sender, e) => { callCount++; Assert.AreEqual(NotifyCollectionChangedAction.Replace,e.Action); Assert.AreEqual(adapter, sender); Assert.AreEqual(newUrl, e.Item); //discutable but current eventedlist implementation does this Assert.AreEqual(-1, e.OldIndex); Assert.AreEqual(0, e.Index); }; //action! replace one dataitem with another dataItems[0] = new DataItem(newUrl); Assert.AreEqual(1, callCount); }
public void TestSequenceLinkFirstTargetThenSource() { string result = ""; SimplerModel sourceModel = new SimplerModel { Name = "source" }; sourceModel.Executing += (s, e) => result += ((SimplerModel)s).Name; SimplerModel targetModel = new SimplerModel { Name = "target" }; targetModel.Executing += (s, e) => result += ((SimplerModel)s).Name; IDataItem sourceInput = new DataItem { Name = "SI", Value = new object(), Role = DataItemRole.Input }; IDataItem sourceOutput = new DataItem { Name = "SO", Value = new object(), Role = DataItemRole.Output }; IDataItem targetInput = new DataItem { Name = "TI", Value = new object(), Role = DataItemRole.Input }; IDataItem targetOutput = new DataItem { Name = "TO", Value = new object(), Role = DataItemRole.Output }; sourceModel.DataItems.Add(sourceInput); sourceModel.DataItems.Add(sourceOutput); targetModel.DataItems.Add(targetInput); targetModel.DataItems.Add(targetOutput); var compositeModel = new CompositeModel { Name = "composite model", Models = { sourceModel, targetModel } }; sourceInput.LinkTo(targetOutput); compositeModel.Initialize(); compositeModel.Execute(); Assert.AreEqual("targetsource", result); }
public void GetData(Action<DataItem, Exception> callback) { // Use this to create design time data var item = new DataItem("Welcome to MVVM Light [design]"); callback(item, null); }
private void ItemsLoaded() { DataItem root = new DataItem(); root.Text = "Personal Folders"; root.ImageUrl = "../../Images/ContextMenu/Outlook/1PersonalFolders.png"; root.IsExpanded = true; DataItem deletedItems = new DataItem(); root.Items.Add(deletedItems); deletedItems.Text = "Deleted Items(6)"; deletedItems.ImageUrl = "../../Images/ContextMenu/Outlook/2DeletedItems.png"; DataItem inbox = new DataItem(); root.Items.Add(inbox); inbox.Text = "Inbox(14)"; inbox.ImageUrl = "../../Images/ContextMenu/Outlook/4Inbox.png"; DataItem folders = new DataItem(); inbox.Items.Add(folders); folders.Text = "Folders"; folders.ImageUrl = "../../Images/ContextMenu/Outlook/folder.png"; DataItem junkEmails = new DataItem(); root.Items.Add(junkEmails); junkEmails.Text = "Junk E-mails"; junkEmails.ImageUrl = "../../Images/ContextMenu/Outlook/junk.png"; DataItem outbox = new DataItem(); root.Items.Add(outbox); outbox.Text = "Outbox"; outbox.ImageUrl = "../../Images/ContextMenu/Outlook/outbox.png"; DataItem sentItems = new DataItem(); root.Items.Add(sentItems); sentItems.Text = "Sent Items"; sentItems.ImageUrl = "../../Images/ContextMenu/Outlook/sent.png"; DataItem search = new DataItem(); root.Items.Add(search); search.Text = "Search Folder"; search.ImageUrl = "../../Images/ContextMenu/Outlook/searchFolder.png"; DataItem followup = new DataItem(); search.Items.Add(followup); followup.Text = "From Follow up"; followup.ImageUrl = "../../Images/ContextMenu/Outlook/folder.png"; DataItem largeMail = new DataItem(); search.Items.Add(largeMail); largeMail.Text = "Large Mail"; largeMail.ImageUrl = "../../Images/ContextMenu/Outlook/search.png"; DataItem unreadMail = new DataItem(); search.Items.Add(unreadMail); unreadMail.Text = "Unread Mail"; unreadMail.ImageUrl = "../../Images/ContextMenu/Outlook/search.png"; this.Items.Add(root); }
public Task<DataItem> GetData() { // Use this to connect to the actual data service // Simulate by returning a DataItem var item = new DataItem("Welcome to MVVM Light"); return Task.FromResult(item); }
public Stock GetFristCol(string data) { List<Price> prices = new List<Price>(); List<DataItem> items = new List<DataItem>(); string firstCol = string.Empty; List<string> lines = data.Split('\n').ToList<string>(); for (int i = 2; i < lines.Count; i++) { string line = lines[i]; List<string> numStrs = line.Split(' ').ToList<string>(); if (numStrs.Count < 5) continue; DataItem item = new DataItem(); Price price = new Price(); price.content = new string[4]; for (int numI = 0; numI < numStrs.Count; numI++) { if (numI == 0) item.content = numStrs[numI]; if (numI > 0 && numI < 5) { price.content[numI-1] = numStrs[numI]; if (numI == 3) { price.content[numI-1] = numStrs[numI+1]; } if (numI == 4) { price.content[numI - 1] = numStrs[numI-1]; } } // if (numI > 0 && numI < 4) //price.content += ","; } items.Add(item); prices.Add(price); } Stock stock = new Stock(); stock.price = new Price[prices.Count]; for (int itemI = 0; itemI < items.Count; itemI++) { stock.data += items[itemI].content; if (itemI != items.Count - 1) stock.data += ","; } for (int priceI = 0; priceI < prices.Count; priceI++) { stock.price[priceI] = prices[priceI]; // += "[" + prices[priceI].content + "]"; //if (priceI != prices.Count - 2) // stock.price += ";"; } // stock.data = "[" + stock.data + "]"; // stock.price = "[" + stock.price + "]"; return stock; }
/// <summary> /// Конструктор. /// </summary> /// <param name="aTopicName">Имя топика.</param> /// <param name="aOpcConnection">Соединение с OPC-сервером.</param> public OutputAreaData(string aTopicName, OpcConnectionHolder aOpcConnection) { IdCheckOutputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_ID_CHECK_OUT, aOpcConnection); IdNumberOutputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_ID_NUMBER_OUT, aOpcConnection); IdCheckInputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_ID_CHECK_IN, aOpcConnection); IdNumberInputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_ID_NUMBER_IN, aOpcConnection); WeightOutputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_WEIGHT_OUT, aOpcConnection); LengthOutputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_LENGTH_OUT, aOpcConnection); }
void saveDataToDataModel() { DataItem dm = new DataItem(); dm.uid = uid; dm.position = gameObj.transform.position; dm.velocity = velocity; dataModel.UpdateItem(dm); }
private void Append(String name, DataItem dataItem) { Append(FormatHeader(name, dataItem)); if (dataItem.Length > 0) { Stream.Write(dataItem.GetBytes(), 0, dataItem.Length); } AppendNewline(); }
public static List<DataItem> GetList(int pCount) { var aList = new List<DataItem>(pCount); for (int i = 1; i <= pCount; i++) { var aItem = new DataItem(); aItem.Text = string.Format("Text_{0}", i); aItem.Value = string.Format("Value_{0}", i); aList.Add(aItem); } return aList; }
public XmlNode Create() { XmlDocument xmldoc = new XmlDocument(); XmlNode deNode = xmldoc.CreateElement("DataElement"); XmlAttribute attrName = xmldoc.CreateAttribute("Name"); attrName.Value = m_DataElement.Name; XmlAttribute attrType = xmldoc.CreateAttribute("type"); attrType.Value = Utils.DataTypeToString(m_DataElement.Type); deNode.Attributes.Append(attrName); deNode.Attributes.Append(attrType); IEnumerator<KeyValuePair<string, IPolicyLanguageItem>> enumerator = m_DataElement.GetAttributeEnumerator(); while (enumerator.MoveNext()) { KeyValuePair<string, IPolicyLanguageItem> pair = enumerator.Current; XmlAttribute attrib = xmldoc.CreateAttribute(pair.Key); attrib.Value = pair.Value.Value; deNode.Attributes.Append(attrib); } if (m_DataElement.Data is IDataItem) { XmlNode diNode = new DataItem(m_DataElement.Data as IDataItem).Create(); deNode.AppendChild(xmldoc.ImportNode(diNode, true)); } else if (m_DataElement.Data is IPolicyObjectCollection<IDataItem>) { IPolicyObjectCollection<IDataItem> dataitems = m_DataElement.Data as IPolicyObjectCollection<IDataItem>; foreach (IDataItem di in dataitems) { XmlNode diNode = new DataItem(di).Create(); deNode.AppendChild(xmldoc.ImportNode(diNode, true)); } } else if (m_DataElement.Data is IDataSource) { XmlNode dsNode = new DataSource(m_DataElement.Data as IDataSource).Create(); deNode.AppendChild(xmldoc.ImportNode(dsNode, true)); } else if (m_DataElement.Data is IPolicyObjectCollection<IDataSource>) { IPolicyObjectCollection<IDataSource> datasources = m_DataElement.Data as IPolicyObjectCollection<IDataSource>; foreach (IDataSource ds in datasources) { XmlNode dsNode = new DataSource(ds).Create(); deNode.AppendChild(xmldoc.ImportNode(dsNode, true)); } } return deNode; }
public void CreateContainingSimpleValue() { DataItem d1 = new DataItem("item", typeof(int)); int i = 0; d1.Value = i; d1.Name = "i"; d1.Description = "simple integer value"; Assert.AreEqual(d1.Name, "i"); }
public DocumentDlg(string name, string curDoc) { data = new DataItem(curDoc); InitializeComponent(); txtDocumenting.Text = name; txtContent.DataContext = data; Buttons = new Button[] { OkButton, CancelButton }; }
public void UpdateDataItemOwner() { EventedList<IDataItem> dataItems = new EventedList<IDataItem>(); DataItem dataItem = new DataItem(); dataItems.Add(dataItem); Folder folder = new Folder {DataItems = dataItems}; Assert.AreEqual(folder, dataItem.Owner); EventedList<IDataItem> dataItems2 = new EventedList<IDataItem>(); DataItem dataItem2 = new DataItem(); dataItems2.Add(dataItem2); folder.DataItems = dataItems2; }
public String Header(String name, DataItem dataItem) { var builder = new StringBuilder(); builder.AppendFormat("--{0}\r\n", _boundary); var attributes = String.Format("name=\"{0}\"; filename=\"{1}\"", name, dataItem.FileName); builder.AppendFormat("Content-Disposition: form-data; {0}\r\n", attributes); builder.AppendFormat("Content-Type: {0}\r\n", dataItem.ContentType); builder.Append("Content-Transfer-Encoding: binary\r\n"); builder.Append("\r\n"); return builder.ToString(); }
public void GetAllItemsRecursive() { DataItem di = new DataItem(); di.Value = 9; Assert.AreEqual(new object[]{9,di},di.GetAllItemsRecursive().ToArray()); DataItem emptyDi = new DataItem(); Assert.AreEqual(new object[] { emptyDi}, emptyDi.GetAllItemsRecursive().ToArray()); DataItem stringDi = new DataItem(); stringDi.Value = "9"; Assert.AreEqual(new object[] { "9", stringDi }, stringDi.GetAllItemsRecursive().ToArray()); }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { var list = new[] { Kp.BullishHammer, Kp.BearishShootingStar, Kp.BullishHaramiCross, Kp.BearishHarami, Kp.BullishHarami, Kp.BullishDoji }; var nonSignalRow = new DataItem { High = High[0], Low = Low[0], Open = Open[0], Close = Close[0], Volume = Volume[0], DtTm = Time[0], Dt = Time[0].Date, Hr = Time[0].Hour, CandleStick = 0, IsSignal = 0 }; LogTheData(nonSignalRow); foreach (var dood in Enum.GetValues(typeof(Kp)).Cast<Kp>()) { double candleStick = KenCandleStickPattern(dood, 4)[0]; if (candleStick > 99 || candleStick < -99) { var myRow = new DataItem { High = High[0], Low = Low[0], Open = Open[0], Close = Close[0], Volume = Volume[0], DtTm = Time[0], Dt = Time[0].Date, Hr = Time[0].Hour, CandleStick = candleStick, IsSignal = 1 }; LogTheData(myRow); } } }
protected override void LoadData() { List<UserAccessReport> report = UserAccessReport.GetAll(); foreach (UserAccessReport t in report) { DataItem record = new DataItem(); record.Items.Add(t.FirstName + " " + t.LastName); record.Items.Add(t.Email); record.Items.Add(t.Resource); record.Items.Add(t.Date); ReportData.Add(record); } }
public static void PrintItemValue(DataItem item) { if (item.Value != null) { Console.WriteLine("Item Key:" + item.Name + " Item Value:" + item.Value.ToString()); } if (item.HasItems) { foreach (var subItem in item.DataItems) { PrintItemValue(subItem.Value); } } }
/// <summary> /// Sets the data item. /// </summary> public void SetItem(DataItem item) { _data = item; }
/// <summary> /// Proceeds to the next data item. When shuffling, the next item is randomly selected. /// </summary> protected void Next() { m_currentData = m_data.GetNextData(m_param.model_data_param.shuffle); }
/// <summary> /// 加载配置 /// </summary> void LoadAppConfig() { #region 绑定语音类型 List <string> arrVoices = voiceSpeaker.GetVoices(); for (int i = 0; i < arrVoices.Count; i++) { DataItem comboitem = new DataItem(arrVoices[i]); cmbVoiceName.Items.Add(comboitem); } cmbVoiceName.SelectedIndex = 0; #endregion txtAppIdentifier.Text = commonAppConfig.AppIdentifier; txtSelfConnStr.Text = commonAppConfig.SelfConnStr; chbStartup.Checked = (commonDAO.GetAppletConfigString("开机启动") == "1"); //公共配置 chkAutoPrint.Checked = (commonDAO.GetCommonAppletConfigString("自动打印磅单") == "1"); chkITMS.Checked = (commonDAO.GetCommonAppletConfigString("启用智能调运") == "1"); chkPaperWorkPass.Checked = (commonDAO.GetCommonAppletConfigString("启用证件到期") == "1"); dbiSampleWayCount.Value = commonDAO.GetCommonAppletConfigInt32("采样通道车数"); chkSampleWayCount.Checked = (commonDAO.GetCommonAppletConfigString("启用采样通道车数") == "1"); dbiFactoryCount.Value = commonDAO.GetCommonAppletConfigInt32("厂内总车数"); chkFactoryCount.Checked = (commonDAO.GetCommonAppletConfigString("启用厂内总车数") == "1"); txtTicketDiff.Value = commonDAO.GetCommonAppletConfigDouble("净重超差限值"); chkTicketDiff.Checked = (commonDAO.GetCommonAppletConfigString("启用净重超差限值") == "1"); txtTareCoefficient.Value = commonDAO.GetCommonAppletConfigDouble("皮重排查系数"); chkTareCoefficient.Checked = (commonDAO.GetCommonAppletConfigString("启用皮重排查系数") == "1"); // IO控制器 SelectedComboBoxItem(cmbIocerCom, commonDAO.GetAppletConfigInt32("IO控制器_串口").ToString()); SelectedComboBoxItem(cmbIocerBandrate, commonDAO.GetAppletConfigInt32("IO控制器_波特率").ToString()); SelectedComboBoxItem(cmbIocerDataBits, commonDAO.GetAppletConfigInt32("IO控制器_数据位").ToString()); SelectedComboBoxItem(cmbIocerStopBits, commonDAO.GetAppletConfigInt32("IO控制器_停止位").ToString()); SelectedComboBoxItem(cmbIocerParity, commonDAO.GetAppletConfigInt32("IO控制器_校验位").ToString()); SelectedComboBoxItem(cmbInductorCoil1Port, commonDAO.GetAppletConfigInt32("IO控制器_地感1端口").ToString()); SelectedComboBoxItem(cmbInductorCoil2Port, commonDAO.GetAppletConfigInt32("IO控制器_地感2端口").ToString()); SelectedComboBoxItem(cmbInductorCoil3Port, commonDAO.GetAppletConfigInt32("IO控制器_地感3端口").ToString()); SelectedComboBoxItem(cmbInductorCoil4Port, commonDAO.GetAppletConfigInt32("IO控制器_地感4端口").ToString()); SelectedComboBoxItem(cmbGate1UpPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸1升杆端口").ToString()); SelectedComboBoxItem(cmbGate1DownPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸1降杆端口").ToString()); SelectedComboBoxItem(cmbGate2UpPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸2升杆端口").ToString()); SelectedComboBoxItem(cmbGate2DownPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸2降杆端口").ToString()); SelectedComboBoxItem(cmbSignalLight1Port, commonDAO.GetAppletConfigInt32("IO控制器_信号灯1端口").ToString()); SelectedComboBoxItem(cmbSignalLight2Port, commonDAO.GetAppletConfigInt32("IO控制器_信号灯2端口").ToString()); // 入厂读卡器 cmbRwer1Ip.Value = commonDAO.GetAppletConfigString("读卡器1_Ip"); cmbRwer1Port.Value = commonDAO.GetAppletConfigInt32("读卡器1_端口"); // 出厂读卡器 cmbRwer2Ip.Value = commonDAO.GetAppletConfigString("读卡器2_Ip"); cmbRwer2Port.Value = commonDAO.GetAppletConfigInt32("读卡器2_端口"); //室内发卡器 SelectedComboBoxItem(cmbRwer2Com, commonDAO.GetAppletConfigInt32("读卡器2_串口").ToString()); txtRwerTagStartWith.Text = commonDAO.GetAppletConfigString("读卡器_标签过滤"); // LED显示屏 iptxtLED1IP.Value = commonDAO.GetAppletConfigString("LED显示屏1_IP地址"); iptxtLED2IP.Value = commonDAO.GetAppletConfigString("LED显示屏2_IP地址"); // 语音 SelectedComboBoxItem(cmbVoiceName, commonDAO.GetAppletConfigString("语音包").ToString()); sldVoiceRate.Value = commonDAO.GetAppletConfigInt32("语速"); sldVoiceVolume.Value = commonDAO.GetAppletConfigInt32("音量"); lblVoiceRate.Text = sldVoiceRate.Value.ToString(); lblVoiceVolume.Text = sldVoiceVolume.Value.ToString(); }
public bool Remove(string key) { int p = wk.String2Int(key); //检查是否有碰撞 if (dataArr[p].Key == null) //没有对应的数据 { return(false); } else { if (dataArr[p].Key == key) //未碰撞,此时应该更新值 { dataArr[p].Value = default(T); dataArr[p].ReadCount = 0; //ExtNext 不可更新 return(true); } else { //发生碰撞,更新节点指针 ExtNext lock (sync_obj) { int index = dataArr[p].ExtNext; if (index > 0) { List <int> keyIndexList = new List <int>(); int objIndex = 0; while (index > 0) { keyIndexList.Add(index); if (extList[index].Key == key) { objIndex = index; break; } else { index = extList[index].ExtNext; } } if (objIndex > 0) { if (keyIndexList.Count >= 1) { int nextIndex = extList[objIndex].ExtNext; if (nextIndex > 0 || keyIndexList.Count > 1) { if (keyIndexList.Count > 1) { int preIndex = keyIndexList[keyIndexList.Count - 2]; var preData = extList[preIndex]; preData.ExtNext = nextIndex; extList[preIndex] = preData; } else { //修正入口位置 dataArr[p].ExtNext = nextIndex; } } else { //当前节点没有下一个节点,将入口位置置为0 dataArr[p].ExtNext = 0; } //如果没有下一节点,直接将当前节点移除 extList[objIndex] = new DataItem(); freeQueue.Enqueue(objIndex); } return(true); } } } } } return(false); }
public virtual DataCollection Serialize(object obj, ITypeSerializer handler) { if (obj is ProjectFile) { ProjectFile pf = (ProjectFile)obj; DataCollection data = handler.Serialize(obj); //Map the Content build action to the old FileCopy action if CopyToOutputDirectory is set if (pf.BuildAction == BuildAction.Content && pf.CopyToOutputDirectory != FileCopyMode.None) { DataValue value = data ["buildaction"] as DataValue; if (value != null) { data.Remove(value); data.Add(new DataValue("buildaction", "FileCopy")); data.Extract("copyToOutputDirectory"); } } // Don't store the resource id if it matches the default. if (pf.BuildAction == BuildAction.EmbeddedResource && pf.ResourceId != Path.GetFileName(pf.FilePath)) { data.Add(new DataValue("resource_id", pf.ResourceId)); } return(data); } else if (obj is SolutionEntityItem) { DotNetProject project = obj as DotNetProject; if (project != null) { foreach (DotNetProjectConfiguration config in project.Configurations) { config.ExtendedProperties ["Build/target"] = project.CompileTarget.ToString(); } } DataCollection data = handler.Serialize(obj); SolutionEntityItem item = (SolutionEntityItem)obj; if (item.DefaultConfiguration != null) { DataItem confItem = data ["Configurations"] as DataItem; if (confItem != null) { confItem.UniqueNames = true; if (item.ParentSolution != null) { confItem.ItemData.Add(new DataValue("active", item.ParentSolution.DefaultConfigurationId)); } } } if (project != null) { data.Extract("targetFramework"); data.Add(new DataValue("targetFramework", project.TargetFramework.Id.ToLegacyIdString())); } WriteItems(handler, (SolutionEntityItem)obj, data); return(data); } else if (obj is ProjectReference) { ProjectReference pref = (ProjectReference)obj; DataCollection data = handler.Serialize(obj); string refto = pref.Reference; if (pref.ReferenceType == ReferenceType.Assembly) { string basePath = Path.GetDirectoryName(handler.SerializationContext.BaseFile); refto = FileService.AbsoluteToRelativePath(basePath, refto); } else if (pref.ReferenceType == ReferenceType.Package && pref.LoadedReference != null) { refto = pref.LoadedReference; } data.Add(new DataValue("refto", refto)); return(data); } return(handler.Serialize(obj)); }
public static DataItem WithCode(this DataItem dataItem, Guid code) { dataItem.Code = code; return(dataItem); }
public static DataItem WithName(this DataItem dataItem, String name) { dataItem.Name = name; return(dataItem); }
public static DataItem WithDataTable(this DataItem dataItem, DataTable dataTable) { dataItem.DataTable = dataTable; return(dataItem); }
public static DataItem WithReportItems(this DataItem dataItem, ICollection <ReportItem> reportItems) { dataItem.ReportItems = reportItems; return(dataItem); }
public static DataItem WithDataCategory(this DataItem dataItem, DataCategory dataCategory) { dataItem.DataCategory = dataCategory; return(dataItem); }
public static DataItem WithLinkAssociatedField(this DataItem dataItem, String linkAssociatedField) { dataItem.LinkAssociatedField = linkAssociatedField; return(dataItem); }
public static DataItem WithIsCommonTableGrouping(this DataItem dataItem, Boolean isCommonTableGrouping) { dataItem.IsCommonTableGrouping = isCommonTableGrouping; return(dataItem); }
public static DataItem WithDataCategoryCode(this DataItem dataItem, Guid dataCategoryCode) { dataItem.DataCategoryCode = dataCategoryCode; return(dataItem); }
public static DataItem WithDataType(this DataItem dataItem, String dataType) { dataItem.DataType = dataType; return(dataItem); }
private async void FrmPlcTest2_Load(object sender, EventArgs e) { await _plc.OpenAsync(); if (_plc.IsConnected) { var var0 = new DataItem { DB = 1, BitAdr = 0, Count = 1, StartByteAdr = 0, Value = new object(), DataType = DataType.DataBlock, VarType = VarType.Bit, }; #region ReadMultipleVars //var var1 = new DataItem //{ // DB = 1, // BitAdr = 0, // Count = 1, // StartByteAdr = 1, // Value = new object(), // DataType = DataType.DataBlock, // VarType = VarType.Byte, //}; //var var2 = new DataItem //{ // DB = 1, // BitAdr = 0, // Count = 10, // StartByteAdr = 2, // Value = new object(), // DataType = DataType.DataBlock, // VarType = VarType.String, //}; //var dataItemsRead = new List<DataItem> //{ // var0, // var1, // var2 //}; //var readed = await _plc.ReadMultipleVarsAsync(dataItemsRead); //MessageBox.Show(readed[2].Value.ToString()); #endregion var db = new TestDataBlock { Var0 = true, Var1 = 5, Var2 = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, }; await _plc.ReadClassAsync(db, 1); //var str = Encoding.UTF8.GetString(db.Var2, 0, db.Var2.Length); //MessageBox.Show(str); } }
public static DataItem WithCaption(this DataItem dataItem, String caption) { dataItem.Caption = caption; return(dataItem); }
/// <summary> /// 设置指定键的值,如果存在,则替换 /// </summary> /// <param name="key"></param> /// <param name="value"></param> public void Set(string key, T value) { int p = wk.String2Int(key); //检查是否有碰撞 //下面的判断类似于 下面的功能,但是线程安全 //if (dataArr[p].Key == null) //{ // dataArr[p].Key = key; // dataArr[p].Value = value; //} if (Interlocked.CompareExchange(ref dataArr[p].Key, key, null) == null) { dataArr[p].Value = value; Interlocked.Increment(ref _count); } else { if (dataArr[p].Key == key) //未碰撞,此时应该更新值 { dataArr[p].Value = value; } else { #if (LockFree) //发生碰撞,更新节点指针 ExtNext DataItem data = new DataItem(); data.Key = key; data.Value = value; int index = SetDataOnFreeIndex(ref data); if (Interlocked.CompareExchange(ref dataArr[p].ExtNext, index, 0) > 0) { //碰撞的数大于2个 lock (sync_obj) { int extIndex = dataArr[p].ExtNext; while (extList[extIndex].ExtNext > 0) { extIndex = extList[extIndex].ExtNext; } //注意: //List<T> 中的结构体,直接修改或者调用方法,无效,但是数组可以 //所以需要重新整体赋值 DataItem objData = extList[extIndex]; objData.ExtNext = index; extList[extIndex] = objData; } } #else lock (sync_obj) { //发生碰撞,更新节点指针 ExtNext DataItem data = new DataItem(); data.Key = key; data.Value = value; extList.Add(data); int index = extList.Count - 1; if (dataArr[p].ExtNext > 0) { int extIndex = dataArr[p].ExtNext; while (extList[extIndex].ExtNext > 0) { extIndex = extList[extIndex].ExtNext; } DataItem objData = extList[extIndex]; objData.ExtNext = index; extList[extIndex] = objData; } else { dataArr[p].ExtNext = index; } _count++; } #endif } } }
public static DataItem WithDescription(this DataItem dataItem, String description) { dataItem.Description = description; return(dataItem); }
public virtual void Deserialize(object obj, ITypeSerializer handler, DataCollection data) { if (obj is ProjectFile) { ProjectFile pf = (ProjectFile)obj; //Map the old FileCopy action to the Content BuildAction with CopyToOutputDirectory set to "always" //BuildActionDataType handles mapping the BuildAction to "Content" DataValue value = data ["buildaction"] as DataValue; bool isFileCopy = value != null && value.Value == "FileCopy"; DataValue resourceId = data.Extract("resource_id") as DataValue; handler.Deserialize(obj, data); if (isFileCopy) { pf.CopyToOutputDirectory = FileCopyMode.Always; } if (resourceId != null) { pf.ResourceId = resourceId.Value; } } else if (obj is SolutionEntityItem) { DataValue ac = null; DataItem confItem = data ["Configurations"] as DataItem; if (confItem != null) { ac = (DataValue)confItem.ItemData.Extract("active"); } DataItem items = data.Extract("Items") as DataItem; if (items != null) { ReadItems(handler, (SolutionEntityItem)obj, items); } handler.Deserialize(obj, data); if (ac != null) { SolutionEntityItem item = (SolutionEntityItem)obj; item.DefaultConfigurationId = ac.Value; } DotNetProject np = obj as DotNetProject; if (np != null) { // Import the framework version TargetFrameworkMoniker fx = null; DataValue vfx = data["targetFramework"] as DataValue; if (vfx != null) { fx = TargetFrameworkMoniker.Parse(vfx.Value); } else { vfx = data ["clr-version"] as DataValue; if (vfx != null && vfx.Value == "Net_2_0") { fx = TargetFrameworkMoniker.NET_2_0; } else if (vfx != null && vfx.Value == "Net_1_1") { fx = TargetFrameworkMoniker.NET_1_1; } } if (fx != null) { np.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework(fx); } // Get the compile target from one of the configurations if (np.Configurations.Count > 0) { np.CompileTarget = (CompileTarget)Enum.Parse(typeof(CompileTarget), (string)np.Configurations [0].ExtendedProperties ["Build/target"]); } } } else if (obj is ProjectReference) { ProjectReference pref = (ProjectReference)obj; DataValue refto = data.Extract("refto") as DataValue; handler.Deserialize(obj, data); if (refto != null) { pref.Reference = refto.Value; if (pref.ReferenceType == ReferenceType.Assembly) { string basePath = Path.GetDirectoryName(handler.SerializationContext.BaseFile); pref.Reference = FileService.RelativeToAbsolutePath(basePath, pref.Reference); } } } else { handler.Deserialize(obj, data); } }
public static DataItem WithIsGroup(this DataItem dataItem, Boolean isGroup) { dataItem.IsGroup = isGroup; return(dataItem); }
private void OnCreated(DataItem relatedData) { GlobalEvents.OnAddStorageItem.Publish(_item); //GlobalEvents.OnAddStorageItem.Publish(relatedData); Complete(); }
public static DataItem WithLocationOnSystem(this DataItem dataItem, String locationOnSystem) { dataItem.LocationOnSystem = locationOnSystem; return(dataItem); }
public static void GenerateEnum( string directory, string enumName, DataItem[] data, Func <DataItem, string> getEnumElementName, Func <DataItem, int> getEnumElementValue) { string generationFolder = directory; string namespaceName = "Lockstep.Data"; /* * AppDomain currentDomain = AppDomain.CurrentDomain; * // Create a dynamic assembly in the current application domain, * // and allow it to be executed and saved to disk. * AssemblyName aName = new AssemblyName("LockstepGenerated"); * string path = generationFolder; * if (AssetDatabase.IsValidFolder (path) == false) * { * AssetDatabase.CreateFolder("/Assets", "/Lockstep/Database/Generated/Plugins"); * } * AssemblyBuilder ab = currentDomain.DefineDynamicAssembly(aName, AssemblyBuilderAccess.RunAndSave, path); * // Define a dynamic module in "TempAssembly" assembly. For a single- * // module assembly, the module has the same name as the assembly. * ModuleBuilder mb = ab.DefineDynamicModule(aName.Name, aName.Name + ".dll"); * * // Define a public enumeration with the name "Elevation" and an * // underlying type of Integer. * EnumBuilder eb = mb.DefineEnum("Elevation", TypeAttributes.Public, typeof(int)); * * for (int i = 0; i < data.Length; i++) { * TData item = data [i]; * string memberName = getEnumElementName (item); * if (string.IsNullOrEmpty (memberName)) continue; * int memberValue = getEnumElementValue (item); * eb.DefineLiteral(memberName, memberValue); * } * * // Create the type and save the assembly. * Type finished = eb.CreateType(); * * ab.Save(aName.Name + ".dll"); */ CodeCompileUnit codeBase = new CodeCompileUnit(); CodeNamespace enumNamespace = new CodeNamespace(namespaceName); CodeTypeDeclaration newEnum = new CodeTypeDeclaration(enumName) { IsEnum = true }; //Duplicate checker HashSet <int> enumValues = new HashSet <int> (); HashSet <string> enumNames = new HashSet <string> (); //Add default newEnum.Members.Add(new CodeMemberField { Name = "None", InitExpression = new CodePrimitiveExpression(0) }); enumValues.Add(0); enumNames.Add("None"); for (int i = 0; i < data.Length; i++) { DataItem item = data [i]; string memberName = getEnumElementName(item); if (string.IsNullOrEmpty(memberName)) { throw new System.ArgumentException("Member cannot have empty name"); continue; } if (memberName.Contains(" ")) { throw new System.ArgumentException("Member name cannot contain spaces"); } int memberValue = getEnumElementValue(item); if (enumValues.Contains(memberValue) || enumNames.Contains(memberName)) { throw new System.ArgumentException("Duplicate member at index: " + i); continue; } CodeMemberField member = new CodeMemberField { Name = memberName , InitExpression = new CodePrimitiveExpression(memberValue) }; newEnum.Members.Add(member); enumNames.Add(memberName); enumValues.Add(memberValue); } codeBase.ReferencedAssemblies.Add(typeof(string).Assembly.Location); codeBase.Namespaces.Add(enumNamespace); enumNamespace.Imports.Add(new CodeNamespaceImport("System")); enumNamespace.Types.Add(newEnum); CSharpCodeProvider provider = new CSharpCodeProvider(); using (FileStream fs = new FileStream( generationFolder + newEnum.Name + ".cs", FileMode.Create, FileAccess.ReadWrite)) { using (StreamWriter sw = new StreamWriter(fs)) { CodeGeneratorOptions genOptions = new CodeGeneratorOptions(); genOptions.VerbatimOrder = true; provider.GenerateCodeFromCompileUnit(codeBase, sw, genOptions); } } }
public override string WriteToString(DataItem item) { var i = item as NumberItem; return(i.Value.ToString()); }
/// <summary> /// This object builds an SQL query given a set of parameters. /// </summary> /// <param name="fieldList">List of fields used in the query</param> /// <param name="groupList">List of items for the query to group by</param> /// <param name="filterList">List of Filters used in the query</param> /// <param name="parameterList">List of parameters used in the query</param> /// <param name="isParameterQuery">Denotes whether this query is used as a /// dataset query for a ValidValues tag in RDL (i.e. a parameter query) or /// is a query for data selection.</param> /// <param name="joinMethod">Inner or Outer joins for tables</param> public QueryBuilder(List <DataItem> fieldList, List <DataItem> groupList, List <ReportFilterBusinessObject> filterList, List <DataItem> parameterList, bool isParameterQuery, List <ReportDataTableJoin> joinList, DataModel currentDataModel) { CurrentDataModel = currentDataModel; // Temporary list to store DataTables used in query List <DataTable> DataTableList = new List <DataTable>(); _isParameterQuery = isParameterQuery; //_joinMethod=joinMethod; // Check that each of parameters to this constructor are non-null; // Initialise them if not. if (fieldList == null) { fieldList = new List <DataItem>(); } if (groupList == null) { groupList = new List <DataItem>(); } if (filterList == null) { filterList = new List <ReportFilterBusinessObject>(); } if (parameterList == null) { parameterList = new List <DataItem>(); } if (joinList == null) { joinList = new List <ReportDataTableJoin>(); } // This loop adds all required fields to the fieldItem list and // adds all required tables to the dataTable foreach (DataItem Item in fieldList) { // Retrieve DataTable DataTable DataTable = CurrentDataModel.DataTables.Single(x => x.Code == Item.DataTableCode); //DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(Item.DataTableCode); _fieldItemList.Add(new FieldItem(Item.Name, DataTable.Name, Item.Caption)); //If the systems' link field is in the query then add the associated field to the query. if (Item.IsLink) { _fieldItemList.Add(new FieldItem(Item.LinkAssociatedField, DataTable.Name, Item.LinkAssociatedField)); } if (!DataTableList.Contains(DataTable)) { DataTableList.Add(DataTable); } } // If there is more than one table in the DataTableList, we must construct // a set of joins covering all related tables if (DataTableList.Count > 1) { _tableJoinList = ConstructTableJoins(DataTableList, joinList, CurrentDataModel); OrderTableJoins(_tableJoinList); } else { DataTable dt = (DataTable)DataTableList[0]; _tableJoinList.Add(new TableJoin(dt.SchemaName, null, dt.Name, null, null, null, -1, null, false)); } // Populate filterList foreach (ReportFilterBusinessObject CurrentFilter in filterList) { //TODO: Code Review Issue 11/05/05: Do not use 'my' in variable names. //Choose a meaningful name. Pascal casing for variables. // Done 24/05/2005 Guid CodeForRepository = Guid.Parse(CurrentFilter.DataItemCode); DataItem CurrentItem = CurrentDataModel.DataTables.SelectMany(x => x.DataItems).Single(y => y.Code == CodeForRepository); //DataAccessUtilities.RepositoryLocator<IDataItemRepository>().GetByCode(CodeForRepository); DataTable CurrentTable = CurrentDataModel.DataTables.Single(x => x.Code == CurrentItem.DataTableCode); //DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(CurrentItem.DataTableCode); //25/08/05 LL - TIR0289 convert 'Current Month' to appropriate data format if (CurrentFilter.FilterValue == CURRENTMONTH) { CurrentFilter.FilterValue = DateUtility.GetCurrentYearMonth(); } _filterItemList.Add(new FilterItem(CurrentItem.Name, CurrentTable.Name, CurrentFilter.FilterValue, CurrentFilter.Operand, CurrentItem.DataType)); } // Populate parameterList foreach (DataItem Item in parameterList) { DataTable CurrentTable = CurrentDataModel.DataTables.Single(x => x.Code == Item.DataTableCode);//DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(Item.DataTableCode); _reportParameterList.Add(new ParameterItem(Item.Name, CurrentTable.Name, Item.DataType.Contains("char"))); } // Populate groupList foreach (DataItem Item in groupList) { _groupList.Add(Item.Caption); } }
public void FDS() { // Create the Data System OCX FixDataSystem fixDataSystem = new FixDataSystem(); // Get the servers collection DataServers dataServers = fixDataSystem.DataServers; Debug.Print("FixDataSystem.DataServers.Count: {" + dataServers.Count + "}"); // Get the groups collection Groups groups = fixDataSystem.Groups; Debug.Print("FixDataSystem.Groups.Count: {" + groups.Count + "}"); // Get server info foreach (DataServer dataServer in dataServers) { Debug.Print("FixDataSystem.DataServers.DataServer.DefaultServer: {" + dataServer.DefaultServer + "}"); Debug.Print("FixDataSystem.DataServers.DataServer.Name: {" + dataServer.Name + "}"); Debug.Print("FixDataSystem.DataServers.DataServer.OpcAccessPath: {" + dataServer.OpcAccessPath + "}"); Debug.Print("FixDataSystem.DataServers.DataServer.OpcDataSource: {" + dataServer.OpcDataSource + "}"); Debug.Print("FixDataSystem.DataServers.DataServer.OpcProgID: {" + dataServer.OpcProgID + "}"); Debug.Print("FixDataSystem.DataServers.DataServer.OpcServerMachineName: {" + dataServer.OpcServerMachineName + "}"); } // Add a group to the Groups collection Group group = groups.Add("DataGroup1"); Debug.Print("FixDataSystem.Groups.Group.Name: {" + group.Name + "}"); DataItems dataItems = group.DataItems; Debug.Print("FixDataSystem.Groups.Group.DataItems.Count: {" + dataItems.Count + "}"); DataItem dataItem = dataItems.Add("Fix32.SCADA01.SMS_BLOKERINGS_TID.A_DESC"); Debug.Print("Reading from iFix database before (READ)"); ReadDataItem(dataItem); foreach (DataItem dataItem2 in dataItems) { dataItem2.Value = 1; } group.Write(); dataItem.Read(); Debug.Print("Reading from iFix database after (READ)"); ReadDataItem(dataItem); dataItem.Write("Rasmus"); Debug.Print("Reading from iFix database after (WRITE)"); dataItem.Read(); ReadDataItem(dataItem); }
private void RemoveInvalidCustomAttributes() { bool update = false; Database db = this.DatabaseManager.AdomdDatabase; // get the Store dimension Dimension dim = db.Dimensions.FindByName(this.DimensionName); if (dim == null) { throw new Exception("Dimension not found: " + this.DimensionName); } // get existing custom columns DataTable dataColumns = GetCustomDataSourceColumns(); // check and remove for (int i = dim.Attributes.Count - 1; i >= 0; i--) { DimensionAttribute attr = dim.Attributes[i]; // custom attribute consists of 1 column if (attr.KeyColumns.Count != 1) { continue; } // get key column info DataItem di = attr.KeyColumns[0]; string tableId = ((ColumnBinding)di.Source).TableID; string colName = ((ColumnBinding)di.Source).ColumnID; // check if it's not custom if (!colName.StartsWith("GRP@#@")) { continue; } // check if valid if (dataColumns.Rows.Find(colName) != null) { continue; } // remove datasourceview column if (db.DataSourceViews[0].Schema.Tables[tableId].Columns.Contains(colName)) { db.DataSourceViews[0].Schema.Tables[tableId].Columns.Remove(colName); update = true; } // remove hierarchies that contain this attribute for (int j = dim.Hierarchies.Count - 1; j >= 0; j--) { foreach (Level lev in dim.Hierarchies[j].Levels) { if (lev.SourceAttribute == attr) { dim.Hierarchies.RemoveAt(j); update = true; break; // level loop } } } // remove attribute if (dim.Attributes.Contains(attr)) { dim.Attributes.RemoveAt(i); update = true; } } if (update) { // update datasource db.DataSourceViews[0].Update(UpdateOptions.ExpandFull | UpdateOptions.AlterDependents); // update dimension dim.Update(UpdateOptions.ExpandFull | UpdateOptions.AlterDependents); } }
public void SetItem(DataItem data, ShowType type) //设置自己的显示层 { SetItem(Item.CreateEntityByID(data.cif.id, type)); //调用了Item的静态生成实例的方法 }
public static DataItem WithIsLink(this DataItem dataItem, Boolean isLink) { dataItem.IsLink = isLink; return(dataItem); }
public static DataItem WithDataTableCode(this DataItem dataItem, Guid dataTableCode) { dataItem.DataTableCode = dataTableCode; return(dataItem); }