// private ListChangedEventArgs resetList = new ListChangedEventArgs(ListChangedType.Reset,-1,-1); // public event EventHandler <ListChangedEventArgs> ListChanged; // public event EventHandler <GroupChangedEventArgs> GroupChanged; #region Constructor protected BaseListStrategy(ReportSettings reportSettings) { if (reportSettings == null) { throw new ArgumentNullException("reportSettings"); } this.reportSettings = reportSettings; this.indexList = new IndexList("IndexList"); }
public TableSchema() { this.DatabaseOwner = string.Empty; this.Name = string.Empty; this.Columns = new ColumnList(); this.Indexes = new IndexList(); this.ForeignKeys = new ForeignKeyList(); }
public TableSchema(string databaseOwner, string schemaName, ColumnList columns) { this.DatabaseOwner = databaseOwner ?? @""; this.Name = schemaName ?? @""; this.Columns = new ColumnList(); if (columns != null) this.Columns.InsertRange(0, columns); this.Indexes = new IndexList(); this.ForeignKeys = new ForeignKeyList(); }
public ChildNavigator(IDataViewStrategy dataStore,IndexList indexList) { if (dataStore == null) { throw new ArgumentNullException("dataStore"); } this.store = dataStore; this.indexList = indexList; genEnumerator = this.indexList.GetEnumerator(); genEnumerator.MoveNext(); }
public TableSchema(string schemaName, ColumnList columns, IndexList indexes, ForeignKeyList foreignKeys) { this.DatabaseOwner = string.Empty; this.Name = schemaName ?? @""; this.Columns = new ColumnList(); if (columns != null) this.Columns.InsertRange(0, columns); this.Indexes = new IndexList(); if (indexes != null) this.Indexes.InsertRange(0, indexes); this.ForeignKeys = new ForeignKeyList(); this.ForeignKeys.InsertRange(0, foreignKeys); }
public CollectionSource(IList list,ReportSettings reportSettings) { if (list.Count > 0) { itemType = list[0].GetType(); this.baseList = new DataCollection <object>(itemType); this.baseList.AddRange(list); } this.reportSettings = reportSettings; this.listProperties = this.baseList.GetItemProperties(null); IndexList = new IndexList(); }
public SubsonicResponse() { Error = new SubsonicError(); NowPlaying = new List<NowPlaying>(); MusicFolders = new List<MusicFolder>(); Indexes = new IndexList(); Directory = new Directory(); SearchResult2 = new SearchResult2(); Playlists = new List<Playlist>(); User = new User(); ChatMessages = new List<ChatMessage>(); AlbumList = new List<Album>(); RandomSongs = new List<Song>(); Shares = new List<Share>(); Podcasts = new List<Channel>(); JukeboxPlaylist = new List<Entry>(); }
protected void BuildGroup (IndexList list) { string compVal = String.Empty; IndexList.Clear(); IndexList childList = null; foreach (BaseComparer element in list) { string groupValue = ExtractValue (element); if (compVal != groupValue) { childList = new IndexList(); GroupComparer gc = CreateGroupHeader(element); gc.IndexList = childList; } CreateGroupedChildren(childList,element); compVal = groupValue; } // ShowIndexList(IndexList); }
private IndexList BuildSortIndex(SortColumnCollection col) { IndexList arrayList = new IndexList(); PropertyDescriptor[] sortProperties = BuildSortProperties (col); for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){ object rowItem = this.baseList[rowIndex]; object[] values = new object[col.Count]; // Hier bereits Wertabruf um dies nicht während des Sortierens tun zu müssen. for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++){ object value = sortProperties[criteriaIndex].GetValue(rowItem); // Hier auf Verträglichkeit testen um Vergleiche bei Sortierung zu vereinfachen. // Muss IComparable und gleicher Typ sein. if (value != null && value != DBNull.Value) { if (!(value is IComparable)){ throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString()); } values[criteriaIndex] = value; } } arrayList.Add(new SortComparer(col, rowIndex, values)); } if (arrayList[0].ObjectArray.GetLength(0) == 1) { List<BaseComparer> lbc = BaseListStrategy.GenericSorter (arrayList); arrayList.Clear(); arrayList.AddRange(lbc); } else { arrayList.Sort(); } return arrayList; }
private IndexList BuildSortIndex(ColumnCollection col) { IndexList arrayList = new IndexList(); for (int rowIndex = 0; rowIndex < this.table.Rows.Count; rowIndex++){ DataRow rowItem = this.table.Rows[rowIndex]; object[] values = new object[col.Count]; for (int criteriaIndex = 0; criteriaIndex < col.Count; criteriaIndex++) { object value = ExtractColumnValue(rowItem,col,criteriaIndex); if (value != null && value != DBNull.Value) { values[criteriaIndex] = value; } else { values[criteriaIndex] = DBNull.Value; } } arrayList.Add(new SortComparer(col, rowIndex, values)); } if (arrayList[0].ObjectArray.GetLength(0) == 1) { List<BaseComparer> lbc = BaseListStrategy.GenericSorter (arrayList); arrayList.Clear(); arrayList.AddRange(lbc); } else { arrayList.Sort(); } return arrayList; }
public virtual void Visit(IndexList indexList) { }
/// <summary> /// Naive bayes values should only be used for ranking against each other /// </summary> public IReadOnlyList <(string Label, float Weight)> Classify(IndexList indexList) { return(_Classify(indexList.Index).OrderByDescending(kv => kv.Item2).Take(1). Select((d, i) => (d.Item1, 1f)).ToList()); }
private void SaveFileByBegainWithBarcode() { m_listBarcodeType = new List <string>(); List <IndexList> listImageIndex = new List <IndexList>(); IndexList listIndex = null; BarcodeReader reader = new BarcodeReader(); bHasBarcodeOnFirstImage = false; reader.LicenseKeys = "91392547848AAF240620ADFEFDB2EDEB"; try { for (int i = 0; i < this.dynamicDotNetTwain1.HowManyImagesInBuffer; i++) { if (null == listIndex) { listIndex = new IndexList(); } switch (cmbBarcodeFormat.SelectedIndex) { case 0: break; case 1: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.OneD; break; case 2: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODE_39; break; case 3: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODE_128; break; case 4: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODE_93; break; case 5: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODABAR; break; case 6: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.ITF; break; case 7: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.EAN_13; break; case 8: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.EAN_8; break; case 9: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.UPC_A; break; case 10: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.UPC_E; break; case 11: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.PDF417; break; case 12: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.QR_CODE; break; case 13: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.DATAMATRIX; break; case 14: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.INDUSTRIAL_25; break; } strBarcodeFormat = reader.ReaderOptions.BarcodeFormats.ToString(); if (cmbBarcodeFormat.SelectedIndex == 0) { strBarcodeFormat = "All"; } BarcodeResult[] aryResult = null; aryResult = reader.DecodeBitmap((Bitmap)dynamicDotNetTwain1.GetImage((short)i)); if (i == 0) { if (aryResult != null) { if (aryResult.Length != 0) { bHasBarcodeOnFirstImage = true; } } } if (null == aryResult || (aryResult != null && aryResult.Length == 0)) { listIndex.Add(i); //If no barcode found on the current image, add it to the image list for saving } else { m_listBarcodeType.Add(aryResult[0].BarcodeText); if (listIndex != null && listIndex.Count > 0) { listImageIndex.Add(listIndex); listIndex = null; } //If a barcode is found, restart the list if (null == listIndex) { listIndex = new IndexList(); } listIndex.Add(i); } } if (listIndex != null) { listImageIndex.Add(listIndex); //save a last set of data listIndex = null; } SaveImages(listImageIndex); } catch (Exception exp) { MessageBox.Show(exp.Message, "Decoding error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected static void CreateGroupedChildren(IndexList list,BaseComparer sc) { list.Add(sc); }
public PartialViewResult FilterRequests(string rDate) { var indexList = new IndexList(); DateTime requestDate; var model = _db.Requests.Where(r => (r.IsDeleted != true || r.IsDeleted == null)); if (User.IsInRole("LAN\\TR_Managers") || AccountManager.IsApprover(User.Identity.Name).Item2 || User.IsInRole("LAN\\TR_Viewers")) { } else { model = model.Where(r => r.UserLogin == User.Identity.Name); } if (DateTime.TryParseExact(rDate, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out requestDate)) { model = model.Where(r => r.RequestDate == requestDate); } var rezult = model.OrderByDescending(r => r.PublishDate) .ToList(); foreach (var r in rezult) { r.DetailsLink = RequestType.GetDetailsLink(r); r.DetailsButton = RequestType.GetDetailsButton(r); r.CopyButton = RequestType.GetCopyButton(r); r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r); } indexList.Requests = rezult; indexList.TotalRows = rezult.Count; indexList.RowPerPage = rezult.Count; return(PartialView("_Table", indexList)); /* * if (DateTime.TryParseExact(rDate, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out requestDate)) * { * if (User.IsInRole("LAN\\TR_Managers") || AccountManager.IsApprover(User.Identity.Name).Item2 || User.IsInRole("LAN\\TR_Viewers")) * { * var model = _db.Requests * .Where(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.RequestDate == requestDate)) * .OrderByDescending(r => r.PublishDate) * .ToList(); * foreach (var r in model) * { * r.DetailsLink = RequestType.GetDetailsLink(r); * r.DetailsButton = RequestType.GetDetailsButton(r); * r.CopyButton = RequestType.GetCopyButton(r); * r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r); * } * indexList.Requests = model; * indexList.TotalRows = model.Count; * indexList.RowPerPage = model.Count; * return PartialView("_Table", indexList); * } * else * { * var model = _db.Requests * .Where(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.UserLogin == User.Identity.Name && r.RequestDate == requestDate)) * .OrderByDescending(r => r.PublishDate) * .ToList(); * foreach (var r in model) * { * r.DetailsLink = RequestType.GetDetailsLink(r); * r.DetailsButton = RequestType.GetDetailsButton(r); * r.CopyButton = RequestType.GetCopyButton(r); * r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r); * } * indexList.Requests = model; * indexList.TotalRows = model.Count; * indexList.RowPerPage = model.Count; * return PartialView("_Table", indexList); * } * } * else * { * if (User.IsInRole("LAN\\TR_Managers") || AccountManager.IsApprover(User.Identity.Name).Item2 || User.IsInRole("LAN\\TR_Viewers")) * { * var model = _db.Requests * .Where(r => (r.IsDeleted != true || r.IsDeleted == null)) * .OrderByDescending(r => r.PublishDate) * .ToList(); * * foreach (var r in model) * { * r.DetailsLink = RequestType.GetDetailsLink(r); * r.DetailsButton = RequestType.GetDetailsButton(r); * r.CopyButton = RequestType.GetCopyButton(r); * r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r); * } * indexList.Requests = model; * indexList.TotalRows = model.Count; * indexList.RowPerPage = model.Count; * return PartialView("_Table", indexList); * } * else * { * var model = _db.Requests * .Where(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.UserLogin == User.Identity.Name)) * .OrderByDescending(r => r.PublishDate) * .ToList(); * * foreach (var r in model) * { * r.DetailsLink = RequestType.GetDetailsLink(r); * r.DetailsButton = RequestType.GetDetailsButton(r); * r.CopyButton = RequestType.GetCopyButton(r); * r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r); * } * indexList.Requests = model; * indexList.TotalRows = model.Count; * indexList.RowPerPage = model.Count; * return PartialView("_Table", indexList); * } * }*/ }
public static void ReadConfigFileForImg() { if (!File.Exists(configFileImg)) { LoadDefault(); return; } try { IndexList indexListId = IndexList.NONE; string line; StreamReader sr = new StreamReader(configFileImg); while ((line = sr.ReadLine()) != null) { if (line.Trim() == "") { continue; } if (line.Contains("clickInterval =")) { string[] tmpArr = Regex.Split(line, "clickInterval ="); clickInterval = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("clickIntervalForRepeat =")) { string[] tmpArr = Regex.Split(line, "clickIntervalForRepeat ="); clickIntervalForRepeat = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("timeoutClickCount =")) { string[] tmpArr = Regex.Split(line, "timeoutClickCount ="); timeoutClickCount = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("timeoutClickCountLong =")) { string[] tmpArr = Regex.Split(line, "timeoutClickCountLong ="); timeoutClickCountLong = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("timeoutDragCount =")) { string[] tmpArr = Regex.Split(line, "timeoutDragCount ="); timeoutDragCount = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("imgSubScreenCount =")) { string[] tmpArr = Regex.Split(line, "imgSubScreenCount ="); imgSubScreenCount = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("startLoopIndex =")) { string[] tmpArr = Regex.Split(line, "startLoopIndex ="); startLoopIndex = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("endLoopIndex =")) { string[] tmpArr = Regex.Split(line, "endLoopIndex ="); endLoopIndex = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("endRoundIndex =")) { string[] tmpArr = Regex.Split(line, "endRoundIndex ="); endRoundIndex = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("loopCount =")) { string[] tmpArr = Regex.Split(line, "loopCount ="); loopCount = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("jumpIndexList =")) { indexListId = IndexList.JUMP_INDEX_LIST; continue; } if (line.Contains("longTimeImgIndexList =")) { indexListId = IndexList.LONG_TIME_IMG_INDEX_LIST; continue; } if (line.Contains("repeatImgIndexList =")) { indexListId = IndexList.REPEAT_IMG_INDEX_LIST; continue; } if (line.Contains("ignoreWhenLoopImgIndexList =")) { indexListId = IndexList.IGNORE_WHEN_LOOP_IMG_INDEX_LIST; continue; } if (line.Contains("textAfterIndexList =")) { indexListId = IndexList.TEXT_AFTER_INDEX_LIST; continue; } if (line.Contains("mouseDownIndexList =")) { indexListId = IndexList.MOUSE_DOWN_INDEX_LIST; continue; } if (line.Contains("mouseWheelDownIndexList =")) { indexListId = IndexList.MOUSE_WHEEL_DOWN_INDEX_LIST; continue; } if (line.Contains("expectedImgListIndex =")) { string[] tmpArr = Regex.Split(line, "expectedImgListIndex ="); expectedImgListIndex = Int32.Parse(tmpArr[1]); continue; } if (line.Contains("expectedImgList =")) { indexListId = IndexList.EXPECTED_IMG_LIST; continue; } switch (indexListId) { case IndexList.JUMP_INDEX_LIST: string[] tmpArr = Regex.Split(line, ","); int jumpFrom = Int32.Parse(tmpArr[0]); int jumpTo = Int32.Parse(tmpArr[1]); int detectCountBeforeJump = Int32.Parse(tmpArr[2]); jumpIndexList.Add(Tuple.Create(jumpFrom, jumpTo, detectCountBeforeJump)); break; case IndexList.LONG_TIME_IMG_INDEX_LIST: longTimeImgIndexList.Add(Int32.Parse(line)); break; case IndexList.REPEAT_IMG_INDEX_LIST: repeatImgIndexList.Add(Int32.Parse(line)); break; case IndexList.IGNORE_WHEN_LOOP_IMG_INDEX_LIST: ignoreWhenLoopImgIndexList.Add(Int32.Parse(line)); break; case IndexList.TEXT_AFTER_INDEX_LIST: string[] tmpArr2 = Regex.Split(line, ","); int afterIndex = Int32.Parse(tmpArr2[0]); string textAfterIndex = tmpArr2[1].Trim(); if (textAfterIndex.Contains("username : "******"password : ")) { passwordDefault = textAfterIndex; } textAfterIndexList.Add(afterIndex, textAfterIndex); break; case IndexList.MOUSE_DOWN_INDEX_LIST: mouseDownIndexList.Add(Int32.Parse(line)); break; case IndexList.MOUSE_WHEEL_DOWN_INDEX_LIST: mouseWheelDownIndexList.Add(Int32.Parse(line)); break; case IndexList.EXPECTED_IMG_LIST: expectedImgList.Add(line.Trim()); break; default: break; } } sr.Close(); for (int i = 0; i < expectedImgList.Count; i++) { checkedExpectedImgList.Add(false); } } catch { LoadDefault(); } }
public void Sort() { if ((this.reportSettings.SortColumnsCollection != null)) { if (this.reportSettings.SortColumnsCollection.Count > 0) { IndexList = this.BuildSortIndex (reportSettings.SortColumnsCollection); } else { IndexList = this.BuildIndexInternal(reportSettings.SortColumnsCollection); } } }
private static void ShowIndexList (IndexList list) { foreach (BaseComparer element in list) { var groupComparer = element as GroupComparer; if (groupComparer == null) continue; if (groupComparer.IndexList.Any()) { var ss = String.Format("{0} with {1} Children",element.ObjectArray[0],groupComparer.IndexList.Count); System.Console.WriteLine(ss); foreach (BaseComparer c in groupComparer.IndexList) { Console.WriteLine("---- {0}",c.ObjectArray[0]); } } } }
void ShowGrouping(ref IndexList idlist) { Console.WriteLine("----ShowGrouping---"); foreach (GroupComparer el in idlist) { Console.WriteLine("{0}", el.ToString()); if (el.IndexList.Any()) { foreach (var element in el.IndexList) { Console.WriteLine("--{0}", element.ToString()); } } } }
IndexList BuildIndexInternal(Collection<AbstractColumn> sortColumnsCollection) { var indexList = new IndexList(); PropertyDescriptor[] sortProperties = BuildSortProperties(sortColumnsCollection); for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++) { var rowItem = this.baseList[rowIndex]; var values = FillComparer(sortProperties, rowItem); indexList.Add(new SortComparer(sortColumnsCollection, rowIndex, values)); } return indexList; }
private IndexList BuildGroup (IndexList source,GroupColumnCollection groups) { string compareValue = String.Empty; var idlist = new IndexList(); PropertyDescriptor[] groupProperties = BuildSortProperties (groups); GroupComparer groupComparer = null; foreach (BaseComparer element in source) { var groupValue = ExtractValue(element,groupProperties); // var query2 = idlist.FirstOrDefault( s => ((GroupComparer)s).ObjectArray[0] == groupValue) as GroupComparer; // if (query2 == null) { // groupComparer = CreateGroupHeader(element); // idlist.Add(groupComparer); // } else { // Console.WriteLine("xx"); // } if (compareValue != groupValue) { groupComparer = CreateGroupHeader(element); idlist.Add(groupComparer); } groupComparer.IndexList.Add(element); compareValue = groupValue; } ShowGrouping(ref idlist); return idlist; }
private Dictionary<string,IndexList> BuildGroup_1 (IndexList list,GroupColumnCollection groups) { var dictionary = new Dictionary<string,IndexList>(); PropertyDescriptor[] groupProperties = BuildSortProperties (groups); foreach (var element in list) { string groupValue = ExtractValue (element,groupProperties); if (!dictionary.ContainsKey(groupValue)) { dictionary[groupValue] = new IndexList(); } dictionary[groupValue].Add(element); } Console.WriteLine("Dictonary "); foreach (var el in dictionary.Values) { Console.WriteLine(el.Count.ToString()); foreach (var element in el) { Console.WriteLine("-- {0}",element.ToString()); } } return dictionary; }
protected static void CreateGroupedChildren(IndexList list, BaseComparer sc) { list.Add(sc); }
public int MaxIndex() => IndexList.GetMaxIndex();
/// <summary> /// Serializes the key list /// </summary> protected override void SerializeIndexes() { var dictionary = IndexList.ToDictionary(item => item.Key, item => Tuple.Create(item.Index.Item1, item.Index.Item2)); Driver.SerializeIndex(typeof(T), Name, dictionary); }
/// <summary> /// Classifies text into either positive or negative sentiment /// The data files can be downloaded from https://archive.ics.uci.edu/ml/datasets/Sentiment+Labelled+Sentences /// </summary> /// <param name="dataFilesPath">Path to extracted data files</param> public static void SentimentClassification(string dataFilesPath) { var files = new[] { "amazon_cells_labelled.txt", "imdb_labelled.txt", "yelp_labelled.txt" }; var LINE_SEPARATOR = "\n".ToCharArray(); var SEPARATOR = "\t".ToCharArray(); var stringTable = new StringTableBuilder(); var sentimentData = files.SelectMany(f => File.ReadAllText(dataFilesPath + f).Split(LINE_SEPARATOR). Where(l => !string.IsNullOrWhiteSpace(l)).Select(l => l.Split(SEPARATOR)). Select(s => Tuple.Create(Tokenise(s[0]), s[1][0] == '1' ? "positive" : "negative")). Where(d => d.Item1.Any())).Shuffle(0).ToList(); var splitSentimentData = sentimentData.Split(); // build training and test classification bag var trainingClassificationBag = BuildIndexedClassifications(splitSentimentData.Training, stringTable); var testClassificationBag = BuildIndexedClassifications(splitSentimentData.Test, stringTable); // train a bernoulli naive bayes classifier var bernoulli = trainingClassificationBag.TrainBernoulliNaiveBayes(); Console.WriteLine("Bernoulli accuracy: {0:P}", testClassificationBag.Classify(bernoulli.CreateClassifier()).Average(r => r.Score)); // train a multinomial naive bayes classifier var multinomial = trainingClassificationBag.TrainMultinomialNaiveBayes(); Console.WriteLine("Multinomial accuracy: {0:P}", testClassificationBag.Classify(multinomial.CreateClassifier()).Average(r => r.Score)); // convert the index lists to vectors and normalise along the way var sentimentDataTable = BuildIndexedClassifications(sentimentData, stringTable). ConvertToTable().Normalise(NormalisationType.Standard); var vectoriser = sentimentDataTable.GetVectoriser(); var sentimentDataSet = sentimentDataTable.Split(0); var dataTableAnalysis = sentimentDataTable.GetAnalysis(); using (var lap = BrightWireProvider.CreateLinearAlgebra()) { var graph = new GraphFactory(lap); var trainingData = graph.CreateDataSource(sentimentDataSet.Training, vectoriser); var testData = graph.CreateDataSource(sentimentDataSet.Test, vectoriser); var indexListEncoder = (IIndexListEncoder)trainingData; // use a one hot encoding error metric, rmsprop gradient descent and xavier weight initialisation var errorMetric = graph.ErrorMetric.OneHotEncoding; var propertySet = graph.CurrentPropertySet.Use(graph.GradientDescent.RmsProp). Use(graph.WeightInitialisation.Xavier); var engine = graph.CreateTrainingEngine(trainingData, 0.3f); engine.LearningContext.ScheduleLearningRate(5, 0.1f); engine.LearningContext.ScheduleLearningRate(11, 1f); engine.LearningContext.ScheduleLearningRate(15, 0.3f); // train a neural network classifier var neuralNetworkWire = graph.Connect(engine).AddFeedForward(512, "layer1") //.AddBatchNormalisation() .Add(graph.ReluActivation()).AddDropOut(0.5f). AddFeedForward(trainingData.OutputSize, "layer2").Add(graph.ReluActivation()). AddBackpropagation(errorMetric, "first-network"); // train the network Console.WriteLine("Training neural network classifier..."); const int TRAINING_ITERATIONS = 10; GraphModel bestNetwork = null; engine.Train(TRAINING_ITERATIONS, testData, errorMetric, network => bestNetwork = network); if (bestNetwork != null) { engine.LoadParametersFrom(bestNetwork.Graph); } var firstClassifier = graph.CreateEngine(engine.Graph); // stop the backpropagation to the first neural network engine.LearningContext.EnableNodeUpdates(neuralNetworkWire.Find("layer1"), false); engine.LearningContext.EnableNodeUpdates(neuralNetworkWire.Find("layer2"), false); // create the bernoulli classifier wire var bernoulliClassifier = bernoulli.CreateClassifier(); var bernoulliWire = graph.Connect(engine).AddClassifier(bernoulliClassifier, sentimentDataSet.Training, dataTableAnalysis); // create the multinomial classifier wire var multinomialClassifier = multinomial.CreateClassifier(); var multinomialWire = graph.Connect(engine).AddClassifier(multinomialClassifier, sentimentDataSet.Training, dataTableAnalysis); // join the bernoulli, multinomial and neural network classification outputs var firstNetwork = neuralNetworkWire.Find("first-network"); var joined = graph.Join(multinomialWire, graph.Join(bernoulliWire, graph.Connect(trainingData.OutputSize, firstNetwork))); // train an additional classifier on the output of the previous three classifiers joined.AddFeedForward(outputSize: 64).Add(graph.ReluActivation()). AddDropOut(dropOutPercentage: 0.5f).AddFeedForward(trainingData.OutputSize). Add(graph.ReluActivation()).AddBackpropagation(errorMetric); // train the network again Console.WriteLine("Training stacked neural network classifier..."); GraphModel bestStackedNetwork = null; engine.Train(10, testData, errorMetric, network => bestStackedNetwork = network); if (bestStackedNetwork != null) { engine.LoadParametersFrom(bestStackedNetwork.Graph); } Console.WriteLine("Enter some text to test the classifiers..."); while (true) { Console.Write(">"); var line = Console.ReadLine(); if (string.IsNullOrWhiteSpace(line)) { break; } var tokens = Tokenise(line); var indexList = new List <uint>(); foreach (var token in tokens) { if (stringTable.TryGetIndex(token, out uint stringIndex)) { indexList.Add(stringIndex); } } if (indexList.Any()) { var queryTokens = indexList.GroupBy(d => d). Select(g => Tuple.Create(g.Key, (float)g.Count())).ToList(); var vector = new float[trainingData.InputSize]; foreach (var token in queryTokens) { vector[token.Item1] = token.Item2; } var indexList2 = IndexList.Create(indexList.ToArray()); var encodedInput = indexListEncoder.Encode(indexList2); Console.WriteLine("Bernoulli classification: " + bernoulliClassifier.Classify(indexList2).First().Label); Console.WriteLine("Multinomial classification: " + multinomialClassifier.Classify(indexList2).First().Label); var result = firstClassifier.Execute(encodedInput); var classification = vectoriser.GetOutputLabel(1, (result.Output[0].Data[0] > result.Output[0].Data[1]) ? 0 : 1); Console.WriteLine("Neural network classification: " + classification); var stackedResult = engine.Execute(encodedInput); var stackedClassification = vectoriser.GetOutputLabel(1, (stackedResult.Output[0].Data[0] > stackedResult.Output[0].Data[1]) ? 0 : 1); Console.WriteLine("Stack classification: " + stackedClassification); } else { Console.WriteLine("Sorry, none of those words have been seen before."); } Console.WriteLine(); } } Console.WriteLine(); }
private IndexList UnsortedIndex(SortColumnCollection col) { IndexList arrayList = new IndexList(); for (int rowIndex = 0; rowIndex < this.table.Rows.Count; rowIndex++){ object[] values = new object[1]; arrayList.Add(new SortComparer(col, rowIndex, values)); } return arrayList; }
private void SetupShotModelData(ShotModelData data) { int[] indices = Array.ConvertAll(data.Indices, i => i + VertexList.Count); IndexList.AddRange(indices); PmxVertexData[] vertices = data.Vertices; foreach (var vertex in vertices) { vertex.VertexId = VertexList.Count; vertex.BoneId = Array.ConvertAll(vertex.BoneId, i => i + BoneList.Count); VertexList.Add(vertex); } PmxMaterialData[] materials = data.Materials; PmxMorphData morph = data.MaterialMorph; morph.MorphName = data.Property.Type.Name[0] + MorphList.Count.ToString(); morph.Type = 4; morph.MorphArray = ArrayUtil.Set(new PmxMorphMaterialData[materials.Length], i => new PmxMorphMaterialData()); for (int i = 0; i < materials.Length; i++) { morph.MorphArray[i].Index = MaterialList.Count + i; morph.MorphId = MorphList.Count + i; } MorphList.Add(morph); string[] textures = data.Textures; foreach (var texture in textures) { if (!TextureList.Contains(texture)) { TextureList.Add(texture); } } foreach (PmxMaterialData material in materials) { material.MaterialName = data.Property.Type.Name[0] + MaterialList.Count.ToString(); if (0 <= material.TextureId && material.TextureId < textures.Length) { material.TextureId = TextureList.IndexOf(textures[material.TextureId]); } else { material.TextureId = -1; } if (0 <= material.SphereId && material.SphereId < textures.Length) { material.SphereId = TextureList.IndexOf(textures[material.SphereId]); } else { material.SphereId = -1; } material.MaterialId = MaterialList.Count; MaterialList.Add(material); } SetupBone(data, data.Bones); ModelDataList.Add(data); }
public override void Group () { base.Group(); // if (ReportSettings.SortColumnsCollection.Count > 0) { // ReportSettings.GroupColumnsCollection.AddRange(ReportSettings.SortColumnsCollection); // } IndexList groupedIndexList = new IndexList("group"); groupedIndexList = this.BuildSortIndex (ReportSettings.GroupColumnsCollection); // ShowIndexList(sortedIndexList); BuildGroup(groupedIndexList); }
private void SaveFileByBarcodeText() { m_listBarcodeType = new List <string>(); List <IndexList> listImageIndex = new List <IndexList>(); IndexList listIndex = new IndexList(); listImageIndex.Add(listIndex); //use to save no barcode files BarcodeReader reader = new BarcodeReader(); reader.LicenseKeys = "91392547848AAF240620ADFEFDB2EDEB"; try { switch (cmbBarcodeFormat.SelectedIndex) { case 0: break; case 1: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.OneD; break; case 2: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODE_39; break; case 3: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODE_128; break; case 4: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODE_93; break; case 5: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODABAR; break; case 6: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.ITF; break; case 7: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.EAN_13; break; case 8: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.EAN_8; break; case 9: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.UPC_A; break; case 10: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.UPC_E; break; case 11: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.PDF417; break; case 12: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.QR_CODE; break; case 13: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.DATAMATRIX; break; case 14: reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.INDUSTRIAL_25; break; } strBarcodeFormat = reader.ReaderOptions.BarcodeFormats.ToString(); if (cmbBarcodeFormat.SelectedIndex == 0) { strBarcodeFormat = "All"; } for (int i = 0; i < this.dynamicDotNetTwain1.HowManyImagesInBuffer; i++) { BarcodeResult[] aryResult = null; aryResult = reader.DecodeBitmap((Bitmap)dynamicDotNetTwain1.GetImage((short)i)); if (null == aryResult || (aryResult != null && aryResult.Length == 0)) { //If no barcode found on the current image, add it to the image list for saving UpdateDateList(0, i, ref listImageIndex); } else //If a barcode is found, restart the list { string strBarcodeText = aryResult[0].BarcodeText; int iPosition = 0; if (IfExistBarcodeText(strBarcodeText, out iPosition)) { UpdateDateList(iPosition, i, ref listImageIndex); } else { m_listBarcodeType.Add(strBarcodeText); AddDateList(i, ref listImageIndex); } } } SaveImages(listImageIndex); } catch (Exception exp) { MessageBox.Show(exp.Message, "Decoding error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public GroupComparer (ColumnCollection owner, int listIndex, object[] values):base(owner,listIndex,values) { IndexList = new IndexList(); }
//MO - Changed : new ctor that accepts the new arguments public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update) { errors = new ErrorResultTO(); ForEachType = forEachType; IIndexIterator localIndexIterator; switch (forEachType) { case enForEachType.InRecordset: var records = compiler.EvalRecordSetIndexes(recordsetName, update); if (!compiler.HasRecordSet(recordsetName)) { errors.AddError("When selecting a recordset only valid recordsets can be used"); break; } localIndexIterator = new IndexListIndexIterator(records); IndexIterator = localIndexIterator; break; case enForEachType.InRange: if (string.IsNullOrWhiteSpace(@from)) { errors.AddError("The from field can not be left empty."); break; } if (string.IsNullOrWhiteSpace(to)) { errors.AddError("The to field can not be left empty."); break; } if (@from.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the From field."); break; } var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@from, update)); int intFrom; if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1) { errors.AddError("From range must be a whole number from 1 onwards."); break; } if (to.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the To field."); break; } var evalledTo = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@to, update)); int intTo; if (!int.TryParse(evalledTo, out intTo) || intTo < 1) { errors.AddError("To range must be a whole number from 1 onwards."); break; } IndexList indexList; if (intFrom > intTo) { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = revIdxItr; } else { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; localIndexIterator = new IndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = localIndexIterator; } break; case enForEachType.InCSV: var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(csvNumbers, update)); ErrorResultTO allErrors; List <int> listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors); if (allErrors.HasErrors()) { errors.MergeErrors(allErrors); break; } ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes); ListOfIndex listOfIndex = new ListOfIndex(listOfIndexes); listLocalIndexIterator.IndexList = listOfIndex; IndexIterator = listLocalIndexIterator; break; default: if (numberOfExecutes != null && numberOfExecutes.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the Numbers field."); break; } int intExNum; var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(numberOfExecutes, update)); if (!int.TryParse(numOfExItr, out intExNum)) { errors.AddError("Number of executes must be a whole number from 1 onwards."); } IndexIterator = new IndexIterator(new HashSet <int>(), intExNum); break; } }
/// <summary> /// Minimums the index. /// </summary> /// <returns></returns> public int MinIndex() { return(IndexList.GetMinIndex()); }
protected static void ShowIndexList (IndexList list) { foreach (BaseComparer element in list) { string s = String.Format("{0} ",element.ObjectArray[0]); GroupComparer gc = element as GroupComparer; if ( gc != null) { s = s + "GroupHeader"; if (gc.IndexList != null) { s = s + String.Format(" <{0}> Childs",gc.IndexList.Count); } System.Console.WriteLine(s); foreach (BaseComparer c in gc.IndexList) { Console.WriteLine("---- {0}",c.ObjectArray[0]); } } } }
private int FindNearIndex(int position) => IndexList.Take(position).Reverse().FirstOrDefault(x => x != null) ?? -1;
//MO - Changed : new ctor that accepts the new arguments public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update) { errors = new ErrorResultTO(); ForEachType = forEachType; IIndexIterator localIndexIterator; switch (forEachType) { case enForEachType.InRecordset: if (string.IsNullOrEmpty(recordsetName)) { errors.AddError(string.Format(ErrorResource.IsRequired, "The Recordset Field")); break; } var records = compiler.EvalRecordSetIndexes(recordsetName, update); if (!compiler.HasRecordSet(recordsetName)) { errors.AddError("When selecting a recordset only valid recordsets can be used"); break; } localIndexIterator = new IndexListIndexIterator(records); IndexIterator = localIndexIterator; break; case enForEachType.InRange: if (string.IsNullOrWhiteSpace(@from)) { errors.AddError(string.Format(ErrorResource.IsRequired, "The FROM field")); break; } if (string.IsNullOrWhiteSpace(to)) { errors.AddError(string.Format(ErrorResource.IsRequired, "The TO field")); break; } if (@from.Contains("(*)")) { errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "From field")); break; } var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@from, update)); int intFrom; if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1) { errors.AddError(string.Format(ErrorResource.RangeFromOne, "FROM range")); break; } if (to.Contains("(*)")) { errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "TO field.")); break; } var evalledTo = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@to, update)); int intTo; if (!int.TryParse(evalledTo, out intTo) || intTo < 1) { errors.AddError(string.Format(ErrorResource.RangeFromOne, "TO range")); break; } IndexList indexList; if (intFrom > intTo) { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; var revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = revIdxItr; } else { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; localIndexIterator = new IndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = localIndexIterator; } break; case enForEachType.InCSV: if (string.IsNullOrEmpty(csvNumbers)) { errors.AddError(string.Format(ErrorResource.IsRequired, "The CSV Field")); break; } var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(csvNumbers, update)); ErrorResultTO allErrors; var listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors); if (allErrors.HasErrors()) { errors.MergeErrors(allErrors); break; } var listLocalIndexIterator = new ListIndexIterator(listOfIndexes); var listOfIndex = new ListOfIndex(listOfIndexes); listLocalIndexIterator.IndexList = listOfIndex; IndexIterator = listLocalIndexIterator; break; default: if (numberOfExecutes != null && numberOfExecutes.Contains("(*)")) { errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "Numbers field.")); break; } int intExNum; var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(numberOfExecutes, update)); if (!int.TryParse(numOfExItr, out intExNum) || intExNum < 1) { errors.AddError(string.Format(ErrorResource.RangeFromOne, "Number of executes")); } IndexIterator = new IndexIterator(new HashSet <int>(), intExNum); break; } }
//MO - Changed : new ctor that accepts the new arguments public ForEachBootstrapTOOld(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, Guid dlID, IDataListCompiler compiler, out ErrorResultTO errors) { errors = new ErrorResultTO(); ForEachType = forEachType; IDev2IteratorCollection colItr = Dev2ValueObjectFactory.CreateIteratorCollection(); IndexIterator localIndexIterator; IndexList indexList; switch (forEachType) { case enForEachType.InRecordset: IBinaryDataListEntry recordset = compiler.Evaluate(dlID, enActionType.User, recordsetName, false, out errors); if (recordset == null || !recordset.IsRecordset) { errors.AddError("When selecting a recordset only valid recordsets can be used"); break; } var isEmpty = recordset.IsEmpty(); if (isEmpty) { indexList = new IndexList(new HashSet <int> { 1 }, 0); localIndexIterator = new IndexIterator(new HashSet <int> { 1 }, 0); } else { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = 1, MaxValue = recordset.FetchLastRecordsetIndex() }; localIndexIterator = new IndexIterator(new HashSet <int>(), 0); } localIndexIterator.IndexList = indexList; IndexIterator = localIndexIterator; break; case enForEachType.InRange: if (string.IsNullOrWhiteSpace(from)) { errors.AddError("The from field can not be left empty."); break; } if (string.IsNullOrWhiteSpace(to)) { errors.AddError("The to field can not be left empty."); break; } if (from.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the From field."); break; } var fromItr = CreateDataListEvaluateIterator(from, dlID, compiler, colItr, errors); colItr.AddIterator(fromItr); int intFrom; if (!int.TryParse(colItr.FetchNextRow(fromItr).TheValue, out intFrom) || intFrom < 1) { errors.AddError("From range must be a whole number from 1 onwards."); break; } if (to.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the To field."); break; } var toItr = CreateDataListEvaluateIterator(to, dlID, compiler, colItr, errors); colItr.AddIterator(toItr); int intTo; if (!int.TryParse(colItr.FetchNextRow(toItr).TheValue, out intTo) || intTo < 1) { errors.AddError("To range must be a whole number from 1 onwards."); break; } if (intFrom > intTo) { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = revIdxItr; } else { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; localIndexIterator = new IndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = localIndexIterator; } break; case enForEachType.InCSV: var csvIndexedsItr = CreateDataListEvaluateIterator(csvNumbers, dlID, compiler, colItr, errors); colItr.AddIterator(csvIndexedsItr); ErrorResultTO allErrors; List <int> listOfIndexes = SplitOutCsvIndexes(colItr.FetchNextRow(csvIndexedsItr).TheValue, out allErrors); if (allErrors.HasErrors()) { errors.MergeErrors(allErrors); break; } ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes); ListOfIndex listOfIndex = new ListOfIndex(listOfIndexes); listLocalIndexIterator.IndexList = listOfIndex; IndexIterator = listLocalIndexIterator; break; default: if (numberOfExecutes != null && numberOfExecutes.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the Numbers field."); break; } int intExNum; var numOfExItr = CreateDataListEvaluateIterator(numberOfExecutes, dlID, compiler, colItr, errors); colItr.AddIterator(numOfExItr); if (!int.TryParse(colItr.FetchNextRow(numOfExItr).TheValue, out intExNum)) { errors.AddError("Number of executes must be a whole number from 1 onwards."); } IndexIterator = new IndexIterator(new HashSet <int>(), intExNum); break; } }
public override void Group () { base.Group(); IndexList groupedIndexList = new IndexList("group"); groupedIndexList = this.BuildSortIndex (ReportSettings.GroupColumnsCollection); // ShowIndexList(sortedIndexList); BuildGroup(groupedIndexList); }
public override void Group () { base.Group(); IndexList gl = new IndexList("group"); gl = this.BuildSortIndex (ReportSettings.GroupColumnsCollection); ShowIndexList(gl); base.BuildGroup(gl); }
public void AddAlias(Guid dlId, string parentColumn, string parentNamespace, string childColumn, out ErrorResultTO errors) { errors = new ErrorResultTO(); // TODO : This needs to change so we can track at all levels what the root alias is ;) IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); Guid masterId = dlId; string masterRs = parentNamespace; string masterCol = parentColumn; Guid searchId = dlId; IBinaryDataListEntry masterEntry = null; int aliasSearchRounds = 0; BinaryDataListAlias binaryDataListAlias = null; while (searchId != Guid.Empty) { ErrorResultTO invokeErrors; var bdl = compiler.FetchBinaryDataList(searchId, out invokeErrors); errors.MergeErrors(invokeErrors); if (bdl != null) { string error; bdl.TryGetEntry(masterRs, out masterEntry, out error); errors.AddError(error); if (masterEntry != null) { var aliases = masterEntry.FetchAlias(); if (aliases.TryGetValue(masterCol, out binaryDataListAlias)) { // we have a hit ;) masterId = binaryDataListAlias.MasterKeyID; searchId = masterId; masterRs = binaryDataListAlias.MasterNamespace; masterCol = binaryDataListAlias.MasterColumn; aliasSearchRounds++; } else { // ensure we copy over the alias entry's keys ;) if (IsEmtpy) { var keyItr = masterEntry.FetchRecordsetIndexes(); _myKeys = new IndexList(keyItr.FetchGaps(), keyItr.MaxIndex(), keyItr.MinIndex()); IsEmtpy = false; } searchId = Guid.Empty; // signal end ;) } } else { if (aliasSearchRounds == 0) { throw new Exception("Missing Entry"); } // we hit the bottom earlier, handle it ;) if (binaryDataListAlias != null) { masterEntry = binaryDataListAlias.MasterEntry; } searchId = Guid.Empty; // signal end ;) } } else { throw new Exception("Missing DataList"); } } // Check MasterKeyID to see if it contains an alias, if so keep bubbling until we at end ;) _keyToAliasMap[childColumn] = new BinaryDataListAlias { MasterKeyID = masterId, ChildKey = GenerateKeyPrefix(Namespace, DataListKey), MasterKey = GenerateKeyPrefix(masterRs, masterId), MasterColumn = masterCol, MasterNamespace = masterRs, MasterEntry = masterEntry }; }
private IndexSetInfo(ObjectName tableName, IEnumerable <IndexInfo> indexes, bool readOnly) { TableName = tableName ?? throw new ArgumentNullException(nameof(tableName)); IsReadOnly = readOnly; Indexes = new IndexList(this, indexes); }
private static IReadOnlyList <(string Classification, IndexList Data)> BuildIndexedClassifications( IReadOnlyList <Tuple <string[], string> > data, StringTableBuilder stringTable) { return(data.Select(d => (d.Item2, IndexList.Create(d.Item1.Select(str => stringTable.GetIndex(str)).ToArray()))).ToList()); }
/// <summary> /// Serializes the key list /// </summary> protected override async Task SerializeIndexesAsync() { var dictionary = IndexList.ToDictionary(item => item.Key, item => Tuple.Create(item.Index.Item1, item.Index.Item2)); await Driver.SerializeIndexAsync(typeof(T), Name, dictionary).ConfigureAwait(false); }
public void RefreshZn() { Fjcclist.Clear(); IndexList.Clear(); for (int i = 0; i < Sbhlist.Length; i++) { FJCClist list = new FJCClist(); MES_PD_SCRW pd_scrw = new MES_PD_SCRW(); pd_scrw.SBBH = Sbhlist[i].SBBH; pd_scrw.GC = getGC("value"); //pd_scrw.GZZXBH = getUserInfo("gzzxvalue"); pd_scrw.ZPRQ = Convert.ToDateTime(ServicModel.PUBLIC_FUNC.GET_TIME(getToken())).AddHours(-4).ToString("yyyy-MM-dd"); SELECT_MES_PD_SCRW Smodel = ServicModel.PD_SCRW.SELECT(pd_scrw, getToken()); if (Smodel.MES_RETURN.TYPE.Equals("S")) { list.RwArr = Smodel; } else { list.RwArr = new SELECT_MES_PD_SCRW(); } list.SbStruct = Sbhlist[i]; Fjcclist.Add(list); } for (int i = 0; i < Fjcclist.Count; i++) { if (Fjcclist[i].RwArr.MES_PD_SCRW_LIST == null) { IndexList.Add(-2); continue; } else { if (Fjcclist[i].RwArr.MES_PD_SCRW_LIST.Length == Fjcclist[i].RwArr.MES_PD_SCRW_LIST.Count(p => p.ISACTION == 2)) { IndexList.Add(-1); continue; } ; int action1Index = Fjcclist[i].RwArr.MES_PD_SCRW_LIST.ToList().FindIndex(p => p.ISACTION == 1); if (action1Index >= 0) { IndexList.Add(action1Index); continue; } int action0Index = Fjcclist[i].RwArr.MES_PD_SCRW_LIST.ToList().FindIndex(p => p.ISACTION == 0); if (action0Index >= 0) { IndexList.Add(action0Index); continue; } } } int panelCount = 0; foreach (Control p1 in totalpanel.Controls) { if (p1 is Panel) { foreach (Control item in p1.Controls) { if (Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST == null) { p1.BackColor = Color.FromArgb(252, 228, 214); if (Convert.ToInt32(item.Tag) == 1 + panelCount * 100) { //item.Visible = false; item.Visible = true; } else if (Convert.ToInt32(item.Tag) == 2 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 3 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 4 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 5 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 6 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 7 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 8 + panelCount * 100) { item.Visible = true; } else if (Convert.ToInt32(item.Tag) == 9 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 10 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 11 + panelCount * 100) { item.Visible = false; } break; } else { if (Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST.Length == Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST.Count(p => p.ISACTION == 2)) { p1.BackColor = Color.FromArgb(252, 228, 214); if (Convert.ToInt32(item.Tag) == 1 + panelCount * 100) { item.Visible = true; } else if (Convert.ToInt32(item.Tag) == 2 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 3 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 4 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 5 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 6 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 7 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 8 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 9 + panelCount * 100) { item.Visible = true; } else if (Convert.ToInt32(item.Tag) == 10 + panelCount * 100) { item.Visible = true; } else if (Convert.ToInt32(item.Tag) == 11 + panelCount * 100) { item.Visible = false; } continue; } ; int action1Index = Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST.ToList().FindIndex(p => p.ISACTION == 1); if (action1Index >= 0) { p1.BackColor = Color.FromArgb(146, 208, 80); MES_PD_SCRW_LIST[] data = Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST; if (Convert.ToInt32(item.Tag) == 1 + panelCount * 100) { item.Visible = true; } else if (Convert.ToInt32(item.Tag) == 2 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titleth) + data[action1Index].TH.ToString();//"桶号:" } else if (Convert.ToInt32(item.Tag) == 3 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlepf) + data[action1Index].PFDH;//"配方:" } else if (Convert.ToInt32(item.Tag) == 4 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlepldh) + data[action1Index].PLDH;//"配料单号:" } else if (Convert.ToInt32(item.Tag) == 5 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlexfcd) + data[action1Index].XFCDNAME;//"锌粉产地:" } else if (Convert.ToInt32(item.Tag) == 6 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlexfcd) + data[action1Index].XFPC;//"锌粉批号:" } else if (Convert.ToInt32(item.Tag) == 7 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlezt) + q(Msg_Type.fieldytl);//"状态:已投料"; lb.ForeColor = Color.Black; } else if (Convert.ToInt32(item.Tag) == 8 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 9 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 10 + panelCount * 100) { Button btn = (Button)item; btn.Enabled = true; btn.Visible = true; } else if (Convert.ToInt32(item.Tag) == 11 + panelCount * 100) { Button btn = (Button)item; btn.Enabled = true; btn.Visible = true; } continue; } int action0Index = Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST.ToList().FindIndex(p => p.ISACTION == 0); if (action0Index >= 0) { p1.BackColor = Color.FromArgb(252, 228, 214); MES_PD_SCRW_LIST[] data = Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST; if (Convert.ToInt32(item.Tag) == 1 + panelCount * 100) { item.Visible = true; } else if (Convert.ToInt32(item.Tag) == 2 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titleth) + data[action0Index].TH.ToString();//"桶号:" } else if (Convert.ToInt32(item.Tag) == 3 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlepf) + data[action0Index].PFDH;//"配方:" } else if (Convert.ToInt32(item.Tag) == 4 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlepldh) + data[action0Index].PLDH;//"配料单号:" } else if (Convert.ToInt32(item.Tag) == 5 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlexfcd) + data[action0Index].XFCDNAME;//"锌粉产地:" } else if (Convert.ToInt32(item.Tag) == 6 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlexfph) + data[action0Index].XFPC;//"锌粉批号:" } else if (Convert.ToInt32(item.Tag) == 7 + panelCount * 100) { Label lb = (Label)item; lb.Visible = true; lb.Text = q(Msg_Type.titlezt) + q(Msg_Type.fieldnotl);//"状态:未投料"; lb.ForeColor = Color.Red; } else if (Convert.ToInt32(item.Tag) == 8 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 9 + panelCount * 100) { item.Visible = false; } else if (Convert.ToInt32(item.Tag) == 10 + panelCount * 100) { item.Visible = true; } else if (Convert.ToInt32(item.Tag) == 11 + panelCount * 100) { Button btn = (Button)item; btn.Visible = true; btn.Enabled = false; } continue; } } } panelCount++; } } }
public void AddIndex(Index index) { if (Indexes == null) Indexes = new IndexList(); if (index.Name == null) { if (index.Mode == IndexMode.PrimaryKey) { index.Name = @"PK_"; } else { index.Name = @"IX_"; } index.Name += Name + @"_"; for (int idx = 0; idx < index.ColumnNames.Length; idx++) { if (idx > 0) index.Name += @"_"; index.Name += index.ColumnNames[idx]; } } Indexes.Add(index); }
/// <summary> /// Initializes a new instance of the <see cref="IndexIterator"/> class. /// </summary> /// <param name="gaps">The gaps.</param> /// <param name="maxValue">The maximum value.</param> /// <param name="minValue">The minimum value.</param> public IndexIterator(HashSet <int> gaps, int maxValue, int minValue = 1) { IndexList = new IndexList(gaps, maxValue, minValue); _curValue = minValue; }
protected void BuildGroup (IndexList list) { string compVal = String.Empty; IndexList.Clear(); IndexList childList = null; foreach (BaseComparer element in list) { string v = element.ObjectArray[0].ToString(); if (compVal != v) { childList = new IndexList(); GroupComparer gc = CreateGroupHeader(element); gc.IndexList = childList; CreateGroupeChildren(childList,element); } else { CreateGroupeChildren(childList,element); } compVal = v; } // ShowIndexList(IndexList); }
/// <summary> /// constructor /// </summary> /// <param name="source">source collection</param> /// <param name="filter">filter function</param> public FilteredReadOnlyObservableCollection(TCollection source, Func <TElement, bool> filter) { Source = source; Filter = filter; Initialize(); { // propertychanged CollectionUtilities.ObserveElementPropertyChanged <TCollection, TElement>(source) .Subscribe(x => { var index = source.IndexOf(x.Sender); var filteredIndex = IndexList[index]; var isTarget = Filter(x.Sender); if (isTarget && filteredIndex == null) { // add AppearNewItem(index); } else if (!isTarget && filteredIndex.HasValue) { // remove DisappearItem(index); IndexList[index] = null; OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, x.Sender, filteredIndex.Value)); } }) .AddTo(Subscription); } { // collection changed(support single changed only) source.CollectionChangedAsObservable() .Subscribe(x => { switch (x.Action) { case NotifyCollectionChangedAction.Add: // appear IndexList.Insert(x.NewStartingIndex, null); if (Filter(x.NewItems.Cast <TElement>().Single())) { AppearNewItem(x.NewStartingIndex); } break; case NotifyCollectionChangedAction.Move: throw new NotSupportedException("Move is not supported"); case NotifyCollectionChangedAction.Remove: var removedIndex = IndexList[x.OldStartingIndex]; if (removedIndex.HasValue) { DisappearItem(x.OldStartingIndex); IndexList.RemoveAt(x.OldStartingIndex); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, x.OldItems.Cast <TElement>().Single(), removedIndex.Value)); } else { IndexList.RemoveAt(x.OldStartingIndex); } break; case NotifyCollectionChangedAction.Replace: var index = IndexList[x.NewStartingIndex]; var isTarget = Filter(x.NewItems.Cast <TElement>().Single()); if (index == null && isTarget) { // add AppearNewItem(x.NewStartingIndex); } else if (index.HasValue && isTarget) { // replace InnerCollection[index.Value] = x.NewItems.Cast <TElement>().Single(); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, x.NewItems.Cast <TElement>().Single(), x.OldItems.Cast <TElement>().Single(), index.Value)); } else if (index.HasValue && !isTarget) { // remove DisappearItem(x.NewStartingIndex); IndexList[x.NewStartingIndex] = null; OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, x.OldItems.Cast <TElement>().Single(), index.Value)); } break; case NotifyCollectionChangedAction.Reset: Initialize(); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); break; default: throw new InvalidOperationException(); } }) .AddTo(Subscription); } }
public Aqua() { Properties = new IndexList(); }
// if we have no sorting, we build the indexlist as well, so we don't need to private IndexList IndexBuilder(SortColumnCollection col) { IndexList arrayList = new IndexList(); for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){ object[] values = new object[1]; arrayList.Add(new SortComparer(col, rowIndex, values)); } return arrayList; }
public void ReadFromFile() { const int Cir = 1; const int Pos = 2; const int xPlace = 3; const int yPlace = 4; const int Angle = 5; const int startLine = 6; try { string path = filePath + AppGen.Inst.OrderParams.CarrierName; if (!System.IO.File.Exists(path)) { System.Windows.Forms.MessageBox.Show("CARRIER File not found"); return; } string[] lines = System.IO.File.ReadAllLines(path); IndexList.Clear(); CarrierIndex carrierIndex; for (int ii = startLine; ii < lines.Length; ii++) { string line = lines[ii]; if (line == "") { break; } //end of carrier string[] parts = line.Split(("").ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) { continue; } carrierIndex = new CarrierIndex(); carrierIndex.Master.X = double.Parse(parts[xPlace]); carrierIndex.Master.Y = double.Parse(parts[yPlace]); carrierIndex.Master.Cir = int.Parse(parts[Cir]); carrierIndex.Master.Pos = int.Parse(parts[Pos]); carrierIndex.Master.Angle = double.Parse(parts[Angle]); IndexList.Add(carrierIndex); if (LastCircleNo < carrierIndex.Master.Cir) { //start Old // CircleRadius[carrierIndex.Master.Cir] = carrierIndex.Master.X; //first index in circle is the radius (x=radius, y=0) //end old //start New CircleRadius[carrierIndex.Master.Cir] = Math.Sqrt(Math.Pow(carrierIndex.Master.X, 2) + Math.Pow(carrierIndex.Master.Y, 2)); //first index in circle is the radius of srqt of Y and Y <<new>> //end New } LastCircleNo = carrierIndex.Master.Cir; NoOfCircles = carrierIndex.Master.Cir; NoOfInsAtCircle[carrierIndex.Master.Cir] += 1; //how many inserts in each cycle //if (ii == startLine) //first index is the radius (x=radius, y=0) //{ // CircleRadius[1] = carrierIndex.Master.X; //} // CircleRadius[1] = Math.Max(1,2); //if (CurrCycle < carrierIndex.Master.Cir) //{ // CircleRadius[CurrCycle] = carrierIndex.Master.X; //} //CurrCycle = carrierIndex.Master.Cir; //NoOfCircles = Math.Max(NoOfCircles, carrierIndex.Master.Cir); ////////////////////////////////// //tbd: read from file!!!: //NoOfInsAtCircle[1] = 15; //how many inserts in first cycle //NoOfInsAtCircle[2] = 8; //how many inserts in second cycle //NoOfCircles = 2; //No of circles //CircleRadius[1] = 86.9; //radius of first cycle //CircleRadius[2] = 50.1; //radius of second cycle ////////////////////////////////// } } catch { } }
protected virtual void Dispose(bool disposing) { if (disposing) { // Free other state (managed objects). if (this.indexList != null) { this.indexList.Clear(); this.indexList = null; } } // Release unmanaged resources. // Set large fields to null. // Call Dispose on your base class. }
public GroupComparer(Collection <AbstractColumn> owner, int listIndex, object[] values) : base(owner, listIndex, values) { IndexList = new IndexList(); }