public double[] ExponentialMovingAverage() { int m = DataString.GetLength(1); double[] data = new double[m]; for (int i = 0; i < m; i++) { data[i] = Convert.ToDouble(DataString[1, i]); } double[] ema = new double[m - NDays + 1]; double psum = 0.0; double alpha = 2.0 / NDays; if (m > NDays) { for (int i = 0; i < NDays; i++) { psum += data[i]; } ema[0] = psum / NDays + alpha * (data[NDays - 1] - psum / NDays); for (int i = 1; i <= m - NDays; i++) { ema[i] = ema[i - 1] + alpha * (data[i + NDays - 1] - ema[i - 1]); } } return(ema); }
public double[] SimpleMovingAverage() { int m = DataString.GetLength(1); double[] data = new double[m]; for (int i = 0; i < m; i++) { data[i] = Convert.ToDouble(DataString[1, i]); } double[] sma = new double[m - NDays + 1]; if (m > NDays) { double sum = 0.0; for (int i = 0; i < NDays; i++) { sum += data[i]; } sma[0] = sum / NDays; for (int i = 1; i <= m - NDays; i++) { sma[i] = sma[i - 1] + (data[NDays + i - 1] - data[i - 1]) / NDays; } } return(sma); }
private void Can_Create_Multifield_DE() { //Arrange DataString elementData = new DataString("09114212233"); DataDefinition def = new VariableLengthDataDefinition(DataType.n_numeric, VariableLenthType.LLVAR, 20, new Dictionary <int, DataDefinition>() { { 1, new FixedLengthDataDefinition(DataType.n_numeric, 2) }, { 2, new VariableLengthDataDefinition(DataType.n_numeric, VariableLenthType.LVAR, 4, new Dictionary <int, DataDefinition> { { 1, new FixedLengthDataDefinition(DataType.n_numeric, 2) }, { 2, new FixedLengthDataDefinition(DataType.n_numeric, 2) } } ) }, { 3, new FixedLengthDataDefinition(DataType.n_numeric, 2) } }); //Act DataElement mfDE = new DataElement(999, def, elementData); //Assert Assert.Equal("11", mfDE[1].GetFieldData()); Assert.Equal("2122", mfDE[2].GetFieldData()); Assert.Equal("42122", mfDE[2].ToString()); Assert.Equal("21", mfDE[2][1].GetFieldData()); Assert.Equal("33", mfDE[3].GetFieldData()); }
public CommandResult Criar(CriarRotaCommand command) { try { command.Validate(); if (command.Invalid) { return(CommandResult.Invalid(command.Notifications.ToNotificationsString())); } Rota rota = Rota.Criar( DataString.FromString(command.Nome), DataString.FromNullableString(command.Composicao_Rota), DataString.FromNullableString(command.Observacao), command.Flag_Ativo); dataContext.Add(rota); dataContext.SaveChanges(); return(CommandResult.Valid()); } catch (Exception ex) { return(CommandResult.Invalid(ex.Message)); } }
void Can_Add_Data_Element() { //Arrange DataElementsDefinition dataElementsDefinition = new DataDefinitionDictionary(); DataString elementData = new DataString("09114212233"); DataDefinition def = new VariableLengthDataDefinition(DataType.n_numeric, VariableLenthType.LLVAR, 20, new Dictionary <int, DataDefinition>() { { 1, new FixedLengthDataDefinition(DataType.n_numeric, 2) }, { 2, new VariableLengthDataDefinition(DataType.n_numeric, VariableLenthType.LVAR, 4, new Dictionary <int, DataDefinition> { { 1, new FixedLengthDataDefinition(DataType.n_numeric, 2) }, { 2, new FixedLengthDataDefinition(DataType.n_numeric, 2) } } ) }, { 3, new FixedLengthDataDefinition(DataType.n_numeric, 2) } }); DataElement mfDE74 = new DataElement(74, def, elementData); DataElement mfDE7 = new DataElement(7, def, elementData); Message message = new Message(new MessageTypeIdentifier("0800"), dataElementsDefinition); //Act message.AddOrReplaceDataElement(mfDE74); message.AddOrReplaceDataElement(mfDE7); List <int> des = message.BitMaps.GetPresentDataElements(); string DE74Data = string.Empty; message.TryGetFieldData(out DE74Data, 74, 2, 1); //Assert Assert.Contains(74, des); Assert.Contains(7, des); Assert.Equal("21", DE74Data); }
// GM命令,添加机器人 public void ReqAddBot() { DataString data = new DataString(); data.Param = string.Format("addbot"); Net.Send(MSG.GM_COMMAND, data); }
public CommandResult Atualizar(AtualizarMesReferenciaCommand command) { string entityName = "MesReferencia"; try { command.Validate(); if (command.Invalid) { return(CommandResult.Invalid(command.Notifications.ToNotificationsString())); } MesReferencia mesRef = dataContext.MesReferencia.FirstOrDefault(x => x.Cod_MesReferencia == command.Cod_MesReferencia); if (mesRef is null) { return(CommandResult.Invalid(Logs.EntidadeNaoEncontrada(entityName, command.Cod_MesReferencia))); } mesRef.Atualizar(DataString.FromString(command.MesAno), command.DataInicio, command.DataTermino, command.Ativo); dataContext.SaveChanges(); return(CommandResult.Valid()); } catch (Exception ex) { return(CommandResult.Invalid(ex.Message)); } }
public CommandResult Criar(CriarMaterialCommand command) { try { command.Validate(); if (command.Invalid) { return(CommandResult.Invalid(command.Notifications.ToNotificationsString())); } Material material = Material.Criar(DataString.FromString(command.Descricao), DataString.FromNullableString(command.Volume), DataString.FromNullableString(command.Material_Coletado), DataString.FromNullableString(command.Material_Coletado)); dataContext.Add(material); dataContext.SaveChanges(); return(CommandResult.Valid()); } catch (Exception ex) { return(CommandResult.Invalid(ex.Message)); } }
public CommandResult Criar(CriarMotoristaCommand command) { try { command.Validate(); if (command.Invalid) { return(CommandResult.Invalid(command.Notifications.ToNotificationsString())); } Motorista motorista = Motorista.Criar(DataString.FromString(command.Nome), DataString.FromNullableString(command.Ajudante1), DataString.FromNullableString(command.Ajudante2), DataString.FromString(command.Placa), DataString.FromNullableString(command.Telefone1), DataString.FromNullableString(command.Telefone2)); dataContext.Add(motorista); dataContext.SaveChanges(); return(CommandResult.Valid()); } catch (Exception ex) { return(CommandResult.Invalid(ex.Message)); } }
public void Can_CreateMessage_From_String() { //Arrange DataString dataString = new DataString("0200B2200000001000000000000000800000201" + "234000000010000110722183012345606A5DFGR021ABCDEFGHIJ 1234567890"); DataElementsDefinition dataElementsDefinition = new DataDefinitionDictionary(); //Act Message message = new Message(dataString, dataElementsDefinition); //Assert Assert.Equal("0200", message.MessageTypeIdentifier.ToString()); Assert.Contains(3, message.BitMaps.GetPresentDataElements()); Assert.Contains(4, message.BitMaps.GetPresentDataElements()); Assert.Contains(7, message.BitMaps.GetPresentDataElements()); Assert.Contains(11, message.BitMaps.GetPresentDataElements()); Assert.Contains(44, message.BitMaps.GetPresentDataElements()); Assert.Contains(105, message.BitMaps.GetPresentDataElements()); Assert.Equal("201234", message.DataElements[3].GetFieldData()); Assert.Equal("000000010000", message.DataElements[4].GetFieldData()); Assert.Equal("1107221830", message.DataElements[7].GetFieldData()); Assert.Equal("123456", message.DataElements[11].GetFieldData()); Assert.Equal("A5DFGR", message.DataElements[44].GetFieldData()); Assert.Equal("ABCDEFGHIJ 1234567890", message.DataElements[105].GetFieldData()); Assert.Equal("B2200000001000000000000000800000", message.BitMaps.ToString()); Assert.Equal("0200B2200000001000000000000000800000201" + "234000000010000110722183012345606A5DFGR021ABCDEFGHIJ 1234567890", message.ToString()); }
private string GenerateSequence() { DataString seedContent = string.IsNullOrEmpty(start) ? new DataString(string.Empty) : new DataString(start); DataPhrase seed = new DataPhrase(new[] { seedContent }); //IEnumerable<string> result = model.Walk ( sequenceLength, seed ); IEnumerable <DataPhrase> result = model.Walk(sequenceLength, seed, true); //IEnumerable<string> result = model.WalkRepeat ( sequenceLength, seed ); sequence = ""; string previousLyricIndex = string.Empty; foreach (DataPhrase phrase in result) { sequence += phrase.ToString((token) => { string index; if (token.data.TryGetValue("index", out index)) { bool sameSource = previousLyricIndex == index; string word = string.Format("{0}{1} ", sameSource ? "" : "|", token.ToString()); previousLyricIndex = index; return(word); } return(string.Empty); }) + "\n"; } return(sequence); }
public CommandResult Criar(CriarMesReferenciaCommand command) { try { command.Validate(); if (command.Invalid) { return(CommandResult.Invalid(command.Notifications.ToNotificationsString())); } MesReferencia mesRef = MesReferencia.Criar( DataString.FromString(command.MesAno), command.DataInicio, command.DataTermino, command.Ativo); dataContext.Add(mesRef); dataContext.SaveChanges(); return(CommandResult.Valid()); } catch (Exception ex) { return(CommandResult.Invalid(ex.Message)); } }
private void Can_Get_VariableLength_Subfield_Data() { //Arrange DataString elementData = new DataString("08114212233"); DataDefinition def = new VariableLengthDataDefinition(DataType.n_numeric, VariableLenthType.LLVAR, 20, new Dictionary <int, DataDefinition>() { { 1, new FixedLengthDataDefinition(DataType.n_numeric, 2) }, { 2, new VariableLengthDataDefinition(DataType.n_numeric, VariableLenthType.LVAR, 4, new Dictionary <int, DataDefinition> { { 1, new FixedLengthDataDefinition(DataType.n_numeric, 2) }, { 2, new FixedLengthDataDefinition(DataType.n_numeric, 2) } } ) }, { 3, new FixedLengthDataDefinition(DataType.n_numeric, 2) } }); //Act DataString sf1Data = def.GetSubFieldData(elementData, 1); DataString sf2Data = def.GetSubFieldData(elementData, 2); DataString sf3Data = def.GetSubFieldData(elementData, 3); //Assert Assert.Equal("11", sf1Data.ToString()); Assert.Equal("42122", sf2Data.ToString()); Assert.Equal("33", sf3Data.ToString()); }
private void Validate(VowpalWabbitExampleValidator<DataString> vwSharedValidation, VowpalWabbitExampleValidator<DataStringADF> vwADFValidation, DataString example) { vwSharedValidation.Validate(example.Line, example, SharedLabel.Instance); for (int i = 0; i < example.ActionDependentFeatures.Count; i++) { var adf = example.ActionDependentFeatures[i]; vwADFValidation.Validate(adf.Line, adf, i == example.SelectedActionIndex ? example.Label : null); } }
public void Create_EmptyObjects_ValidString() { var configuration = new KassaConfiguration(); var request = new PaymentRequest(); var result = DataString.Create(configuration, request); Assert.AreEqual("merchantId=|keyVersion=1|amount=0|currencyCode=000|normalReturnUrl=|transactionReference=", result); }
//This is button2 and will parse data that will be shown in textbox2 private void button2_Click(object sender, EventArgs e) { // Read lines from source file string[] arr = File.ReadAllLines(filename); // x = 0 declare and initializes x for the loop set to 0 //for each is a loop that will go over and over int x = 0; foreach (string value in arr) { //Will parse the data read from the file into an array //, \n are delimiters that can split the information //a , or newline will be a chunck of data string[] tempdataholder = arr[x].Split(new Char[] { ',', '\n' }, StringSplitOptions.RemoveEmptyEntries); x++; //This for loop will check the list for the string from tempdataholder (array of strings) //If the string is found it will increase the count for that string //If the string is not found it will add the string to the list as a DataString object and make the count 1 foreach (string tempstring in tempdataholder) { bool found = false; foreach (DataString y in parseddata) { if (tempstring == y.dataname) { found = true; y.datacount += 1; } } if (found == false) { DataString temp1 = new DataString(); temp1.dataname = tempstring; temp1.datacount = 1; parseddata.Add(temp1); } } } //This loop will print each DataString object and its count //is a random variable name to represent the object that will be used to foreach (DataString z in parseddata) { //Show Item: before dataname textBox1.AppendText("Item: "); textBox1.AppendText(z.dataname); //Show | Count: before the datacount textBox1.AppendText(" | Count: "); int num = z.datacount; textBox1.AppendText(num.ToString()); //\r is a carriage return that will move all the way to the left on the next line //\n will tell it to also go to a new line at the next line when printing it textBox1.AppendText("\r\n"); } }
public void Atualizar(DataString descricao, string volume, DataString?observacao, DataString?material_coletado) { Descricao = descricao; Volume = volume; Observacao = observacao; Material_Coletado = material_coletado; Validate(); }
protected void Start() { //csvInput.Test(2, new[] { "songs", "lyrics" }); csvInput.Test(); model = new DataStringMarkov(n); model.EnsureUniqueWalk = true; //string[] lineDelim = new[] { "\r\n", "\r", "\n" }; string[] wordDelim = new[] { " " }; char[] trimChars = new[] { '\r', '\n', ' ', '"', '\'' }; if (csvInput != null) { List <string> lyrics = csvInput.Data["lyrics"]; List <string> songsInfo = csvInput.Data["songs"]; textDisplay.text = ""; int numLyrics = lyrics.Count; Debug.LogFormat("Lyrics #: {0}", numLyrics); for (int iLyric = 0; iLyric < numLyrics; iLyric++) { string info = songsInfo[iLyric]; string[] words = lyrics[iLyric].Trim().Split(wordDelim, System.StringSplitOptions.RemoveEmptyEntries); int numWords = words.Length; DataString[] wordsData = new DataString[numWords]; for (int iWord = 0; iWord < numWords; iWord++) { DataString word = new DataString(words[iWord].Trim(trimChars)); word.data.Add("info", info); word.data.Add("index", iLyric.ToString()); wordsData[iWord] = word; if (iLyric < 10) { textDisplay.text += word.value; } } DataPhrase phrase = new DataPhrase(wordsData); input.Add(phrase); // Train the model model.Learn(phrase); } } if (rand == null) { rand = gameObject.AddComponent <Rand> (); } }
static void Main() { DataString dataStr = new DataString(); // Assigning the dataStr property causes the 'set' accessor to be called. dataStr.Data = "some string"; // Evaluating the Hours property causes the 'get' accessor to be called. System.Console.WriteLine(dataStr.Data); //this will display "some string" }
public void Create_AutomaticResponseUrlIsSet_ValidString() { var configuration = new KassaConfiguration(); var request = new PaymentRequest() { AutomaticResponseUrl = new Uri("https://www.github.com") }; var result = DataString.Create(configuration, request); Assert.AreEqual("merchantId=|keyVersion=1|amount=0|currencyCode=000|normalReturnUrl=|transactionReference=|automaticResponseUrl=https://www.github.com/", result); }
public void Can_Convert_ToString() { //Arramge DataString dataString = new DataString("0800202000000080000000000000000129110001"); DataElementsDefinition dataElementsDefinition = new DataDefinitionDictionary(); //Act Message message = new Message(dataString, dataElementsDefinition); //Assert Assert.Equal("0800202000000080000000000000000129110001", message.ToString()); }
public void Create_LanguageIsSet_ValidString() { var configuration = new KassaConfiguration(); var request = new PaymentRequest() { Language = LanguageCode.CS }; var result = DataString.Create(configuration, request); Assert.AreEqual("merchantId=|keyVersion=1|amount=0|currencyCode=000|normalReturnUrl=|transactionReference=|customerLanguage=CS", result); }
public void Create_CurrencyCodeIsSetToCanadianDollar_ValidString() { var configuration = new KassaConfiguration(); var request = new PaymentRequest() { CurrencyCode = CurrencyCode.CanadianDollar }; var result = DataString.Create(configuration, request); Assert.AreEqual("merchantId=|keyVersion=1|amount=0|currencyCode=124|normalReturnUrl=|transactionReference=", result); }
public void Create_PaymentBrandsIsSetWithMultipleValues_ValidString() { var configuration = new KassaConfiguration(); var request = new PaymentRequest() { PaymentBrands = new PaymentBrand[] { PaymentBrand.IDEAL, PaymentBrand.MASTERCARD, PaymentBrand.VISA } }; var result = DataString.Create(configuration, request); Assert.AreEqual("merchantId=|keyVersion=1|amount=0|currencyCode=000|normalReturnUrl=|transactionReference=|paymentMeanBrandList=IDEAL,MASTERCARD,VISA", result); }
public void Create_ExpirationDateIsSet_ValidString() { var configuration = new KassaConfiguration(); var request = new PaymentRequest() { ExpirationDate = new DateTime(2010, 5, 10, 16, 10, 15) }; var result = DataString.Create(configuration, request); Assert.AreEqual("merchantId=|keyVersion=1|amount=0|currencyCode=000|normalReturnUrl=|transactionReference=|expirationDate=2010-05-10T16:10:15", result); }
public void Create_CaptureModeIsSet_ValidString() { var configuration = new KassaConfiguration(); var request = new PaymentRequest() { CaptureMode = "VALIDATION" }; var result = DataString.Create(configuration, request); Assert.AreEqual("merchantId=|keyVersion=1|amount=0|currencyCode=000|normalReturnUrl=|transactionReference=|captureMode=VALIDATION", result); }
public static BagInstance FromPyTKAdditionalSaveData(Dictionary <string, string> PyTKData) { if (PyTKData != null && PyTKData.TryGetValue(PyTKSaveDataKey, out string DataString)) { if (XMLSerializer.TryDeserializeFromString(DataString.Replace(PyTKEqualsSignEncoding, "="), out BagInstance Data, out Exception Error)) { return(Data); } } return(null); }
public Dictionary <string, string> ToPyTKAdditionalSaveData() { Dictionary <string, string> SaveData = new Dictionary <string, string>(); if (XMLSerializer.TrySerializeToString(this, out string DataString, out Exception Error)) { string CompatibleDataString = DataString.Replace("=", PyTKEqualsSignEncoding); // PyTK Mod doesn't like it when the Value contains '=' characters (the string will be truncated in ISaveElement.rebuild), so replace = with something else SaveData.Add(PyTKSaveDataKey, CompatibleDataString); } return(SaveData); }
void drawListSelector() { GUIStyle areaStyle = new GUIStyle("box"); GUIStyle buttonStyle = new GUIStyle(EditorStyles.toolbarButton); buttonStyle.fixedHeight = 25; buttonStyle.fixedWidth = 25; GUIStyle poputStyle = new GUIStyle(EditorStyles.popup); poputStyle.fixedHeight = 25; GUI.color = Color.gray; GUILayout.BeginArea(new Rect(position.width - 250, 0, 250, 55), areaStyle); GUILayout.BeginHorizontal(); GUI.color = new Color(.8f, .8f, .8f); if (objectsLists != null) { string[] names = new string[datas.Count]; for (int i = 0; i < datas.Count; i++) { names[i] = datas[i].displayName; } selectedData = EditorGUILayout.Popup(lastSelectedData, names, poputStyle); GUILayout.BeginVertical(); if (GUILayout.Button("+", buttonStyle)) { addList = true; newData = new DataString(); } if (datas.Count > 0) { if (GUILayout.Button("C", buttonStyle)) { optionList = true; } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
private DataString[] CreateStringCbAdfData(int numSamples, int randomSeed = 0) { var random = new Random(randomSeed); var sampleData = new DataString[numSamples]; for (int i = 0; i < numSamples; i++) { int numActions = random.Next(2, 5); int[] fIndex = Enumerable.Range(1, numActions).OrderBy(ind => random.Next()).Take(numActions).ToArray(); var features = new string[numActions][]; for (int j = 0; j < numActions; j++) { features[j] = new string[] { "a_" + fIndex[j], "b_" + fIndex[j], "c_" + fIndex[j], "d_" + fIndex[j] }; } var adf = new DataStringADF[numActions]; int labelIndex = random.Next(-1, numActions); for (int j = 0; j < numActions; j++) { adf[j] = new DataStringADF { Features = features[j] }; if (j == labelIndex) { adf[j].Label = new ContextualBanditLabel { Cost = (float)random.NextDouble(), Probability = (float)random.NextDouble() }; } } sampleData[i] = new DataString { ActionDependentFeatures = adf }; } return(sampleData); }
public void Atualizar(DataString nome, DataString?composicao_rota, DataString?observacao, bool?flag_ativo) { { Nome = nome; Composicao_Rota = composicao_rota; Flag_Ativo = flag_ativo; Observacao = observacao; }; //Validate(); }
public static DataString CommonPrefix(this DataString str1, DataString str2) { int len1 = str1.Value.Length; int len2 = str2.Value.Length; int len = Math.Min (len1, len2); int common = 0; while (common < len && str1.Value [common] == str2.Value [common]) common++; if (common == len1) return str1; else if (common == len2) return str2; else if (common == 0) return ""; else return new DataString (str1.Value.Substring (0, common)); }
public void Initialize(GqlQueryState gqlQueryState) { regex = new Regex (regexDefinition, caseInsensitive ? RegexOptions.IgnoreCase : RegexOptions.None); string[] groups = regex.GetGroupNames (); columnNameList = groups.Skip (1).Select (p => new ColumnName (p)).ToArray (); for (int i = 0; i < columnNameList.Length; i++) if (groups [i + 1] == (i + 1).ToString ()) columnNameList [i] = new ColumnName (i); else columnNameList [i] = new ColumnName (groups [i + 1]); provider.Initialize (gqlQueryState); record = new ProviderRecord (this, true); dataStrings = new DataString[columnNameList.Length]; for (int i = 0; i < dataStrings.Length; i++) { dataStrings [i] = new DataString (); record.Columns [i] = dataStrings [i]; } }
private DataString[] CreateStringCbAdfData(int numSamples, int randomSeed = 0) { var random = new Random(randomSeed); var sampleData = new DataString[numSamples]; for (int i = 0; i < numSamples; i++) { int numActions = random.Next(2, 5); int[] fIndex = Enumerable.Range(1, numActions).OrderBy(ind => random.Next()).Take(numActions).ToArray(); var features = new string[numActions][]; for (int j = 0; j < numActions; j++) { features[j] = new string[] { "a_" + fIndex[j], "b_" + fIndex[j], "c_" + fIndex[j], "d_" + fIndex[j] }; } var adf = new DataStringADF[numActions]; for (int j = 0; j < numActions; j++) { adf[j] = new DataStringADF { Features = features[j] }; } sampleData[i] = new DataString { ActionDependentFeatures = adf, SelectedActionIndex = random.Next(-1, numActions), Label = new ContextualBanditLabel { Cost = (float)random.NextDouble(), Probability = (float)random.NextDouble() } }; } return sampleData; }
private DataString[] CreateSampleCbAdfData() { var sampleData = new DataString[3]; //shared | s_1 s_2 //0:1.0:0.5 | a_1 b_1 c_1 //| a_2 b_2 c_2 //| a_3 b_3 c_3 //| b_1 c_1 d_1 //0:0.0:0.5 | b_2 c_2 d_2 //| a_1 b_1 c_1 //| a_3 b_3 c_3 sampleData[0] = new DataString { Shared = new[] { "s_1", "s_2" }, ActionDependentFeatures = new[] { new DataStringADF { Features = new[] { "a_1", "b_1", "c_1" }, }, new DataStringADF { Features = new [] { "a_2","b_2","c_2" } }, new DataStringADF { Features = new [] { "a_3","b_3","c_3" } }, }, SelectedActionIndex = 0, Label = new ContextualBanditLabel { Cost = 1f, Probability = .5f } }; sampleData[1] = new DataString { ActionDependentFeatures = new[] { new DataStringADF { Features = new [] { "b_1","c_1","d_1" } }, new DataStringADF { Features = new [] { "b_2", "c_2", "d_2" } }, }, SelectedActionIndex = 1, Label = new ContextualBanditLabel { Cost = 0f, Probability = .5f } }; sampleData[2] = new DataString { ActionDependentFeatures = new[] { new DataStringADF { Features = new [] { "a_1","b_1","c_1" } }, new DataStringADF { Features = new [] { "a_3","b_3","c_3" } } } }; return sampleData; }
/// <summary> /// Creates a new data string, used as a bridge to the user interface. /// </summary> /// <returns>The newly created data string.</returns> public DataString CreateDataString() { DataString ds = new DataString(this, ""); return ds; }
public DataString CreateDataString(string unitSymbol) { DataString ds = new DataString(this, unitSymbol); return ds; }
public void Initialize(GqlQueryState gqlQueryState) { this.gqlQueryState = gqlQueryState; gqlEngineExecutionState = gqlQueryState.CurrentExecutionState; string fileName; if (this.fileName.StartsWith ("#")) { fileName = Path.Combine (gqlQueryState.TempDirectory, this.fileName); } else { fileName = Path.Combine (gqlQueryState.CurrentDirectory, this.fileName); } streamReader = new StreamReader (new AsyncStreamReader (new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 32 * 1024), 32 * 1024)); record = new ProviderRecord (this, true); record.Source = fileName; dataString = new DataString (); record.Columns [0] = dataString; for (long i = 0; i < skip; i++) { if (streamReader.ReadLine () == null) { streamReader.Close (); streamReader = null; return; } } }
private async void ProcessData(string doc) { try { contentVal = doc.Substring(doc.IndexOf("<H3>On this day...</h3>", System.StringComparison.Ordinal)+24); int contentLength = contentVal.Length; int indexTillRemove = contentVal.IndexOf("<BR><BR> <BR>", System.StringComparison.Ordinal); contentVal = contentVal.Substring(0, indexTillRemove).Replace("<BR>", "@").Replace("<b> ", "").Replace(" </B> ",":"); foreach (string str in contentVal.Split(Convert.ToChar("@"))) { var temp = str.Split(Convert.ToChar(":")); var data = new DataString() {val =temp[1].Replace("\n",""), year =temp[0]}; Data.Add(data); } } catch (Exception) { } }