Example #1
0
        private void addRow(Preprocesser p, bool needfire = true)
        {
            p.StatuChange += new EventHandler(p_StatuChange);


            var row = new MyDataRow()
            {
                Preocesser = p
            };

            row.CreateCells(this.gridMethodLst, row.Preocesser.Filter.Name, row.Preocesser.Filter.ArgusToString(), row.Preocesser.Statu.GetDescription());
            row.Cells[1].ToolTipText = "点击可重新设置参数";
            //row.Cells[1].
            this.gridMethodLst.Rows.Add(row);
            if (!p.Filter.EditEnable)
            {
                row.DefaultCellStyle.BackColor = Color.FromArgb(250, 250, 250);
            }
            if (needfire)
            {
                this.fireProcessorChanged();
            }
        }
Example #2
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            // Object Container: Use objectContainer.Get<T>() to retrieve objects from the scope
            var objectContainer = context.GetFromContext <IObjectContainer>(TextApplicationScope.ParentContainerPropertyTag);

            // Inputs
            string inputText = objectContainer.Get <string>();

            // Inputs
            var  begWordsCol        = BegWords.Get(context);
            var  endWordsCol        = EndWords.Get(context);
            var  regexParameterText = RegexParameter.Get(context);
            bool displayLog         = DisplayLog;
            bool displayRegex       = DisplatyRegex;

            //Convert Collection to Array
            string[] begWords = Utils.ConvertCollectionToArray(begWordsCol);

            string[] endWords = null;
            if (endWordsCol != null)
            {
                endWords = Utils.ConvertCollectionToArray(endWordsCol);
            }

            //Output Data Row
            bool bUpdateDataRow  = BUpdateDataRow;
            var  myDataRow       = MyDataRow.Get(context);
            var  myDataRowColumn = MyDataRowColumn.Get(context);
            var  myIndex         = MyIndex.Get(context);

            string OutputString = null;

            ///////////////////////////
            // Add execution logic HERE
            string[] OutputResults = CallExtractions.CallExtractTextBetweenTwoAnchorWords(inputText, begWords, endWords, regexParameterText, displayLog, displayRegex);


ExitLoop:

            #region Update Data Row (optional)
            //Check if functionality is Activated
            if (bUpdateDataRow == true)
            {
                //Check it there is an item to the Output Variable
                if (OutputResults.Length > 0)
                {
                    if (myIndex == -1)
                    {
                        //Upper Bound
                        OutputString = OutputResults[OutputResults.Length - 1];
                    }
                    else
                    {
                        OutputString = OutputResults[myIndex];
                    }

                    //Update Data Row
                    Utils.CallUpdateDataRow2(myDataRow, myDataRowColumn, OutputString);
                }
            }
            #endregion

            ///////////////////////////
            // Outputs
            return((ctx) =>
            {
                Results.Set(ctx, OutputResults);
            });
        }
Example #3
0
 public MyDataRowChangeEvent(MyDataRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
Example #4
0
        /// <summary>
        /// Data Retrieval Indicator
        /// </summary>
        /// <param name="e"></param>
        private void dataContextSource_RetrieveCustomXmlDataCompletedEvent(Common.RetrieveCustomXmlDataCompleteEventArgs e)
        {
            ObservableCollection <MyDataRow> _data         = new ObservableCollection <MyDataRow>();
            Dictionary <string, string>      columnMapping = new Dictionary <string, string>();
            Dictionary <string, string>      columnMappingForAggregates = new Dictionary <string, string>();

            this.dgCustomSecurity.ItemsSource = null;
            this.dgCustomSecurity.Columns.Clear();

            // grab the xml into a XDocument
            XDocument xmlDoc = XDocument.Parse(e.XmlInfo);

            // find the columns
            List <String> columnNames = xmlDoc.Descendants("column")
                                        .Where(a => a.Attribute("isaggregate").Value == "false")
                                        .Attributes("name")
                                        .Select(a => a.Value)
                                        .ToList();

            foreach (string colName in columnNames)
            {
                string displayName = xmlDoc.Descendants("column")
                                     .Attributes("displayname")
                                     .Where(a => a.PreviousAttribute.Value == colName)
                                     .FirstOrDefault().Value;


                var subheaderrows = xmlDoc.Descendants("subcolumns");
                if (subheaderrows != null)
                {
                    foreach (var row in subheaderrows)
                    {
                        string subcoldisplayname = row.Descendants("subcolumn").Where(a => a.Attribute("name").Value == colName).FirstOrDefault().Value;
                        displayName = displayName + "\n" + subcoldisplayname;
                    }
                }

                columnMapping.Add(colName, displayName);
            }



            foreach (KeyValuePair <string, string> kvp in columnMapping)
            {
                GridViewDataColumn column = new GridViewDataColumn();
                column.Header            = kvp.Value;
                column.UniqueName        = kvp.Key;
                column.DataMemberBinding = new System.Windows.Data.Binding(kvp.Key);
                column.IsFilterable      = true;
                column.IsGroupable       = true;
                column.HeaderCellStyle   = this.Resources["GridViewHeaderCellStyle"] as Style;
                column.CellStyle         = this.Resources["GridViewCellStyle"] as Style;
                //column.Width = new GridViewLength(1, GridViewLengthUnitType.Auto);
                this.dgCustomSecurity.Columns.Add(column);
            }

            List <String> columnNamesWithAggregation = xmlDoc.Descendants("column")
                                                       .Where(a => a.Attribute("isaggregate").Value == "true")
                                                       .Attributes("name")
                                                       .Select(a => a.Value)
                                                       .ToList();

            foreach (string colName in columnNamesWithAggregation)
            {
                string displayName = xmlDoc.Descendants("column")
                                     .Attributes("displayname")
                                     .Where(a => a.PreviousAttribute.Value == colName)
                                     .FirstOrDefault().Value;
                var subheaderrows = xmlDoc.Descendants("subcolumns");
                if (subheaderrows != null)
                {
                    foreach (var row in subheaderrows)
                    {
                        string subcoldisplayname = row.Descendants("subcolumn").Where(a => a.Attribute("name").Value == colName).FirstOrDefault().Value;
                        displayName = displayName + "\n" + subcoldisplayname;
                    }
                }
                columnMappingForAggregates.Add(colName, displayName);
            }

            foreach (KeyValuePair <string, string> kvp in columnMappingForAggregates)
            {
                GridViewDataColumn column = new GridViewDataColumn();
                column.Header            = kvp.Value;
                column.UniqueName        = kvp.Key;
                column.DataMemberBinding = new System.Windows.Data.Binding(kvp.Key);
                column.IsFilterable      = true;
                column.IsGroupable       = true;
                column.TextAlignment     = TextAlignment.Right;
                column.HeaderCellStyle   = this.Resources["GridViewHeaderCellStyle"] as Style;
                column.CellStyle         = this.Resources["GridViewCellStyle"] as Style;
                //column.Width = new GridViewLength(1, GridViewLengthUnitType.Auto);
                column.AggregateFunctions.Add(new HarmonicMeanCalculation {
                    SourceField = kvp.Key
                });
                this.dgCustomSecurity.Columns.Add(column);
            }

            this.dgCustomSecurity.ShowColumnFooters = true;

            foreach (KeyValuePair <string, string> kvp in columnMappingForAggregates)
            {
                columnMapping.Add(kvp.Key, kvp.Value);
            }

            // add the rows
            var rows = xmlDoc.Descendants("row");

            foreach (var row in rows)
            {
                MyDataRow rowData = new MyDataRow();

                foreach (KeyValuePair <string, string> kvp in columnMapping)
                {
                    var cells = row.Descendants("Element").Where(a => a.Attribute("name").Value == kvp.Key).ToList();
                    foreach (var cell in cells)
                    {
                        try
                        {
                            if (cell.Value.Length != 0)
                            {
                                rowData[kvp.Key] = Decimal.Parse(cell.Value.Replace("%", ""));
                            }
                        }
                        catch
                        {
                            rowData[kvp.Key] = cell.Value;
                        }
                    }
                }
                _data.Add(rowData);
            }

            this.dgCustomSecurity.ItemsSource = _data;
            //this.radDataPager.Source = _data;
            this.dgCustomSecurity.IsFilteringAllowed = true;
            this.dgCustomSecurity.GroupRowStyle      = this.Resources["GridViewGroupRowStyle"] as Style;
            this.dgCustomSecurity.ShowGroupFooters   = true;
            this.dgCustomSecurity.HeaderRowStyle     = this.Resources["CustomScreenGridViewHeaderRowStyle"] as Style;
            this.dgCustomSecurity.Columns["Market Capitalization"].IsVisible = false;
            this.DataContextViewModelCustomScreeningTool.IsBusyIndicatorBusy = false;
            this.DataContextViewModelCustomScreeningTool.FlagBusyIndicator   = 1;
        }