示例#1
0
 protected virtual AzurePipelinesJob GetJob(
     ExecutableTarget executableTarget,
     LookupTable <ExecutableTarget, AzurePipelinesJob> jobs)
 {
     var(partitionName, totalPartitions) = ArtifactExtensions.Partitions.GetValueOrDefault(executableTarget.Definition);
示例#2
0
 /// <summary>
 /// Stores the given lookup table in the current cache under the table's type.
 /// The lookup table and its type should not be <c>null</c>.
 /// </summary>
 /// <param name="table">A lookup table to store.</param>
 public virtual void CacheLookupTable(LookupTable table)
 {
     if (table == null || table.Type == null) return;
     #if SILVERLIGHT
     cache[table.Type] = table;
     #else
     rwLock.EnterWriteLock();
     try
     {
         cache[table.Type] = table;
     }
     finally
     {
         rwLock.ExitWriteLock();
     }
     #endif
     LookupTableReady notify;
     if (notifyQueues.TryGetValue(table.Type, out notify) && notify != null) notify(table.Type);
     notifyQueues.Remove(table.Type);
 }
示例#3
0
 public LookupTable Put(LookupTable request)
 {
     return(Patch(request));
 }
示例#4
0
 public frmTableViewer2(LookupTable l)
 {
     InitializeComponent();
     lut = l;
 }
示例#5
0
        public static void Compute(LinearDecomposition decomposition)
        {
            Graph graph = decomposition.Graph;
            List<int> sequence = decomposition.Sequence;
            int n = graph.Size;

            BitSet right = graph.Vertices;
            BitSet left = new BitSet(0, n);

            LookupTable table = new LookupTable(n);

            LinearRepresentativeTable cuts = new LinearRepresentativeTable(graph, sequence);

            int l = sequence[0];
            BitSet leaf = new BitSet(0, n) { l };
            BitSet nleaf = new BitSet(0, n) { graph.OpenNeighborhood(l).First() };

            table[leaf, new BitSet(0, n), 1] = 1;
            table[leaf, nleaf, 1] = 1;
            table[new BitSet(0, n), nleaf, 0] = 1;

            left.Add(l);
            right.Remove(l);

            for (int i = 1; i < sequence.Count; i++)
            {
                int v = sequence[i];

                left.Add(v);
                right.Remove(v);

                LinearRepresentativeList LRw = cuts[left];
                LinearRepresentativeList LRw_ = cuts[right];

                LinearRepresentativeList LRa = cuts[left - v];
                LinearRepresentativeList LRa_ = cuts[right + v];

                LookupTable newTable = new LookupTable(n);

                foreach (BitSet outside in LRw_)
                {
                    foreach (BitSet inside in LRa)
                    {
                        BitSet nrw_ = graph.Neighborhood(outside) * (left - v);
                        BitSet ra_ = LRa_.GetRepresentative(nrw_);

                        BitSet nra = graph.Neighborhood(inside) * right;
                        BitSet rw = LRw.GetRepresentative(nra);

                        BitSet ra = inside;
                        BitSet rw_ = outside;

                        BitSet raw_ = inside + outside;
                        BitSet nraw_ = graph.Neighborhood(raw_);
                        if (nraw_.Contains(v))  // this means rb_ exists ==> multiplier is equal to 1
                        {
                            for (int ka = 0; ka < n; ka++)
                            {
                                newTable[rw, rw_, ka] = newTable[rw, rw_, ka] + table[ra, ra_, ka];
                            }
                        }

                        //--------

                        nrw_ = graph.Neighborhood(outside + v) * (left - v);
                        ra_ = LRa_.GetRepresentative(nrw_);

                        nra = graph.Neighborhood(inside + v) * right;
                        rw = LRw.GetRepresentative(nra);

                        for (int ka = 0; ka < n; ka++)
                        {
                            newTable[rw, rw_, ka + 1] = newTable[rw, rw_, ka + 1] + table[ra, ra_, ka];
                        }
                    }
                }

                table = newTable;
            }

            return;
        }
示例#6
0
 public object Get(LookupTable request) => GetEntityWithCache <LookupTable>(DocConstantModelName.LOOKUPTABLE, request, GetLookupTable);
示例#7
0
 public HighlightRuleSet()
 {
     this.keyWords    = new LookupTable(false);
     this.prevMarkers = new LookupTable(false);
     this.nextMarkers = new LookupTable(false);
 }
        public HighlightRuleSet(XmlElement el)
        {
            XmlNodeList nodes;

            if (el.Attributes["name"] != null)
            {
                Name = el.Attributes["name"].InnerText;
            }

            if (el.HasAttribute("escapecharacter"))
            {
                escapeCharacter = el.GetAttribute("escapecharacter")[0];
            }

            if (el.Attributes["reference"] != null)
            {
                reference = el.Attributes["reference"].InnerText;
            }

            if (el.Attributes["ignorecase"] != null)
            {
                ignoreCase = Boolean.Parse(el.Attributes["ignorecase"].InnerText);
            }

            for (int i = 0; i < Delimiters.Length; ++i)
            {
                delimiters[i] = false;
            }

            if (el["Delimiters"] != null)
            {
                string delimiterString = el["Delimiters"].InnerText;
                foreach (char ch in delimiterString)
                {
                    delimiters[(int)ch] = true;
                }
            }

//			Spans       = new LookupTable(!IgnoreCase);

            keyWords    = new LookupTable(!IgnoreCase);
            prevMarkers = new LookupTable(!IgnoreCase);
            nextMarkers = new LookupTable(!IgnoreCase);

            nodes = el.GetElementsByTagName("KeyWords");
            foreach (XmlElement el2 in nodes)
            {
                HighlightColor color = new HighlightColor(el2);

                XmlNodeList keys = el2.GetElementsByTagName("Key");
                foreach (XmlElement node in keys)
                {
                    keyWords[node.Attributes["word"].InnerText] = color;
                }
            }

            nodes = el.GetElementsByTagName("Span");
            foreach (XmlElement el2 in nodes)
            {
                Spans.Add(new Span(el2));

                /*
                 * Span span = new Span(el2);
                 * Spans[span.Begin] = span;*/
            }

            nodes = el.GetElementsByTagName("MarkPrevious");
            foreach (XmlElement el2 in nodes)
            {
                PrevMarker prev = new PrevMarker(el2);
                prevMarkers[prev.What] = prev;
            }

            nodes = el.GetElementsByTagName("MarkFollowing");
            foreach (XmlElement el2 in nodes)
            {
                NextMarker next = new NextMarker(el2);
                nextMarkers[next.What] = next;
            }
        }
示例#9
0
 private static List <Declaration> BuildDeclarations()
 {
     return(new List <Declaration>(83)
     {
         Aggregate.GetDeclaration(),
         AggregateRow.GetDeclaration(),
         Avg.GetDeclaration(),
         BTree.GetDeclaration(),
         BTreeNode.GetDeclaration(),
         BTreeNodeTuple.GetDeclaration(),
         BTreeNodeTupleList.GetDeclaration(),
         BTreeNodeHierarchyObj.GetDeclaration(),
         CalculatedFieldWrapperImpl.GetDeclaration(),
         ChildLeafInfo.GetDeclaration(),
         Count.GetDeclaration(),
         CountDistinct.GetDeclaration(),
         CountRows.GetDeclaration(),
         DataAggregateObj.GetDeclaration(),
         DataAggregateObjResult.GetDeclaration(),
         DataRegionMemberInstance.GetDeclaration(),
         DataFieldRow.GetDeclaration(),
         FieldImpl.GetDeclaration(),
         First.GetDeclaration(),
         Last.GetDeclaration(),
         Max.GetDeclaration(),
         Min.GetDeclaration(),
         Previous.GetDeclaration(),
         RuntimeCell.GetDeclaration(),
         RuntimeCells.GetDeclaration(),
         RuntimeCellWithContents.GetDeclaration(),
         RuntimeChartCriCell.GetDeclaration(),
         RuntimeChartCriGroupLeafObj.GetDeclaration(),
         RuntimeChartCriObj.GetDeclaration(),
         RuntimeChartObj.GetDeclaration(),
         RuntimeCriObj.GetDeclaration(),
         RuntimeDataRegionObj.GetDeclaration(),
         RuntimeDataTablixObj.GetDeclaration(),
         RuntimeDataTablixGroupLeafObj.GetDeclaration(),
         RuntimeDataTablixGroupRootObj.GetDeclaration(),
         RuntimeDataTablixMemberObj.GetDeclaration(),
         RuntimeDataTablixWithScopedItemsObj.GetDeclaration(),
         RuntimeDataTablixWithScopedItemsGroupLeafObj.GetDeclaration(),
         RuntimeDetailObj.GetDeclaration(),
         RuntimeExpressionInfo.GetDeclaration(),
         RuntimeGroupLeafObj.GetDeclaration(),
         RuntimeGroupObj.GetDeclaration(),
         RuntimeGroupRootObj.GetDeclaration(),
         RuntimeGroupingObj.GetDeclaration(),
         RuntimeHierarchyObj.GetDeclaration(),
         RuntimeMemberObj.GetDeclaration(),
         RuntimeRDLDataRegionObj.GetDeclaration(),
         RuntimeRICollection.GetDeclaration(),
         RuntimeSortDataHolder.GetDeclaration(),
         RuntimeSortFilterEventInfo.GetDeclaration(),
         RuntimeSortFilterEventInfo.SortExpressionScopeInstanceHolder.GetDeclaration(),
         RuntimeSortFilterEventInfo.SortFilterExpressionScopeObj.GetDeclaration(),
         RuntimeSortFilterEventInfo.SortScopeValuesHolder.GetDeclaration(),
         RuntimeSortHierarchyObj.GetDeclaration(),
         RuntimeSortHierarchyObj.SortHierarchyStructure.GetDeclaration(),
         RuntimeDataRowSortHierarchyObj.GetDeclaration(),
         RuntimeTablixCell.GetDeclaration(),
         RuntimeTablixGroupLeafObj.GetDeclaration(),
         RuntimeTablixObj.GetDeclaration(),
         RuntimeUserSortTargetInfo.GetDeclaration(),
         ScopeInstance.GetDeclaration(),
         ScopeLookupTable.GetDeclaration(),
         StDev.GetDeclaration(),
         StDevP.GetDeclaration(),
         Sum.GetDeclaration(),
         Var.GetDeclaration(),
         VarBase.GetDeclaration(),
         VarP.GetDeclaration(),
         Filters.FilterKey.GetDeclaration(),
         RuntimeGaugePanelObj.GetDeclaration(),
         LookupMatches.GetDeclaration(),
         LookupMatchesWithRows.GetDeclaration(),
         LookupTable.GetDeclaration(),
         RuntimeMapDataRegionObj.GetDeclaration(),
         DataScopeInfo.GetDeclaration(),
         BucketedDataAggregateObjs.GetDeclaration(),
         DataAggregateObjBucket.GetDeclaration(),
         RuntimeGroupingObjHash.GetDeclaration(),
         RuntimeGroupingObjTree.GetDeclaration(),
         RuntimeGroupingObjDetail.GetDeclaration(),
         RuntimeGroupingObjDetailUserSort.GetDeclaration(),
         RuntimeGroupingObjLinkedList.GetDeclaration(),
         RuntimeGroupingObjNaturalGroup.GetDeclaration()
     });
 }
示例#10
0
        public HighlightRuleSet(XmlElement el)
        {
            XmlNodeList elementsByTagName = el.GetElementsByTagName("KeyWords");

            if (el.Attributes["name"] != null)
            {
                this.Name = el.Attributes["name"].InnerText;
            }
            if (el.Attributes["noescapesequences"] != null)
            {
                this.noEscapeSequences = bool.Parse(el.Attributes["noescapesequences"].InnerText);
            }
            if (el.Attributes["reference"] != null)
            {
                this.reference = el.Attributes["reference"].InnerText;
            }
            if (el.Attributes["ignorecase"] != null)
            {
                this.ignoreCase = bool.Parse(el.Attributes["ignorecase"].InnerText);
            }
            for (int i = 0; i < this.Delimiters.Length; i++)
            {
                this.Delimiters[i] = false;
            }
            if (el["Delimiters"] != null)
            {
                string innerText = el["Delimiters"].InnerText;
                string text      = innerText;
                for (int j = 0; j < text.Length; j++)
                {
                    char c = text[j];
                    this.Delimiters[(int)c] = true;
                }
            }
            this.keyWords    = new LookupTable(!this.IgnoreCase);
            this.prevMarkers = new LookupTable(!this.IgnoreCase);
            this.nextMarkers = new LookupTable(!this.IgnoreCase);
            foreach (XmlElement xmlElement in elementsByTagName)
            {
                HighlightColor value = new HighlightColor(xmlElement);
                XmlNodeList    elementsByTagName2 = xmlElement.GetElementsByTagName("Key");
                foreach (XmlElement xmlElement2 in elementsByTagName2)
                {
                    this.keyWords[xmlElement2.Attributes["word"].InnerText] = value;
                }
            }
            elementsByTagName = el.GetElementsByTagName("Span");
            foreach (XmlElement span in elementsByTagName)
            {
                this.Spans.Add(new Span(span));
            }
            elementsByTagName = el.GetElementsByTagName("MarkPrevious");
            foreach (XmlElement mark in elementsByTagName)
            {
                PrevMarker prevMarker = new PrevMarker(mark);
                this.prevMarkers[prevMarker.What] = prevMarker;
            }
            elementsByTagName = el.GetElementsByTagName("MarkFollowing");
            foreach (XmlElement mark2 in elementsByTagName)
            {
                NextMarker nextMarker = new NextMarker(mark2);
                this.nextMarkers[nextMarker.What] = nextMarker;
            }
        }
示例#11
0
        public bool TryCreateObject(ObjectType objectType, out IPersistable persistObj)
        {
            switch (objectType)
            {
            case ObjectType.Aggregate:
                persistObj = new Aggregate();
                break;

            case ObjectType.AggregateRow:
                persistObj = new AggregateRow();
                break;

            case ObjectType.Avg:
                persistObj = new Avg();
                break;

            case ObjectType.BTree:
                persistObj = new BTree();
                break;

            case ObjectType.BTreeNode:
                persistObj = new BTreeNode();
                break;

            case ObjectType.BTreeNodeTupleList:
                persistObj = new BTreeNodeTupleList();
                break;

            case ObjectType.BTreeNodeTuple:
                persistObj = new BTreeNodeTuple();
                break;

            case ObjectType.BTreeNodeHierarchyObj:
                persistObj = new BTreeNodeHierarchyObj();
                break;

            case ObjectType.CalculatedFieldWrapperImpl:
                persistObj = new CalculatedFieldWrapperImpl();
                break;

            case ObjectType.ChildLeafInfo:
                persistObj = new ChildLeafInfo();
                break;

            case ObjectType.Count:
                persistObj = new Count();
                break;

            case ObjectType.CountDistinct:
                persistObj = new CountDistinct();
                break;

            case ObjectType.CountRows:
                persistObj = new CountRows();
                break;

            case ObjectType.DataAggregateObj:
                persistObj = new DataAggregateObj();
                break;

            case ObjectType.DataAggregateObjResult:
                persistObj = new DataAggregateObjResult();
                break;

            case ObjectType.DataFieldRow:
                persistObj = new DataFieldRow();
                break;

            case ObjectType.DataRegionMemberInstance:
                persistObj = new DataRegionMemberInstance();
                break;

            case ObjectType.FieldImpl:
                persistObj = new FieldImpl();
                break;

            case ObjectType.First:
                persistObj = new First();
                break;

            case ObjectType.Last:
                persistObj = new Last();
                break;

            case ObjectType.Max:
                persistObj = new Max();
                break;

            case ObjectType.Min:
                persistObj = new Min();
                break;

            case ObjectType.Previous:
                persistObj = new Previous();
                break;

            case ObjectType.RuntimeCells:
                persistObj = new RuntimeCells();
                break;

            case ObjectType.RuntimeChartCriCell:
                persistObj = new RuntimeChartCriCell();
                break;

            case ObjectType.RuntimeChartCriGroupLeafObj:
                persistObj = new RuntimeChartCriGroupLeafObj();
                break;

            case ObjectType.RuntimeChartObj:
                persistObj = new RuntimeChartObj();
                break;

            case ObjectType.RuntimeGaugePanelObj:
                persistObj = new RuntimeGaugePanelObj();
                break;

            case ObjectType.RuntimeCriObj:
                persistObj = new RuntimeCriObj();
                break;

            case ObjectType.RuntimeDataTablixGroupRootObj:
                persistObj = new RuntimeDataTablixGroupRootObj();
                break;

            case ObjectType.RuntimeDataTablixMemberObj:
                persistObj = new RuntimeDataTablixMemberObj();
                break;

            case ObjectType.RuntimeExpressionInfo:
                persistObj = new RuntimeExpressionInfo();
                break;

            case ObjectType.RuntimeHierarchyObj:
                persistObj = new RuntimeHierarchyObj();
                break;

            case ObjectType.RuntimeRICollection:
                persistObj = new RuntimeRICollection();
                break;

            case ObjectType.RuntimeSortDataHolder:
                persistObj = new RuntimeSortDataHolder();
                break;

            case ObjectType.RuntimeSortFilterEventInfo:
                persistObj = new RuntimeSortFilterEventInfo();
                break;

            case ObjectType.RuntimeSortHierarchyObj:
                persistObj = new RuntimeSortHierarchyObj();
                break;

            case ObjectType.RuntimeDataRowSortHierarchyObj:
                persistObj = new RuntimeDataRowSortHierarchyObj();
                break;

            case ObjectType.RuntimeTablixCell:
                persistObj = new RuntimeTablixCell();
                break;

            case ObjectType.RuntimeTablixGroupLeafObj:
                persistObj = new RuntimeTablixGroupLeafObj();
                break;

            case ObjectType.RuntimeTablixObj:
                persistObj = new RuntimeTablixObj();
                break;

            case ObjectType.RuntimeUserSortTargetInfo:
                persistObj = new RuntimeUserSortTargetInfo();
                break;

            case ObjectType.ScopeLookupTable:
                persistObj = new ScopeLookupTable();
                break;

            case ObjectType.SortExpressionScopeInstanceHolder:
                persistObj = new RuntimeSortFilterEventInfo.SortExpressionScopeInstanceHolder();
                break;

            case ObjectType.SortFilterExpressionScopeObj:
                persistObj = new RuntimeSortFilterEventInfo.SortFilterExpressionScopeObj();
                break;

            case ObjectType.SortHierarchyStruct:
                persistObj = new RuntimeSortHierarchyObj.SortHierarchyStructure();
                break;

            case ObjectType.SortScopeValuesHolder:
                persistObj = new RuntimeSortFilterEventInfo.SortScopeValuesHolder();
                break;

            case ObjectType.StDev:
                persistObj = new StDev();
                break;

            case ObjectType.StDevP:
                persistObj = new StDevP();
                break;

            case ObjectType.StorageItem:
                persistObj = new StorageItem();
                break;

            case ObjectType.Sum:
                persistObj = new Sum();
                break;

            case ObjectType.Var:
                persistObj = new Var();
                break;

            case ObjectType.VarP:
                persistObj = new VarP();
                break;

            case ObjectType.FilterKey:
                persistObj = new Filters.FilterKey();
                break;

            case ObjectType.LookupMatches:
                persistObj = new LookupMatches();
                break;

            case ObjectType.LookupMatchesWithRows:
                persistObj = new LookupMatchesWithRows();
                break;

            case ObjectType.LookupTable:
                persistObj = new LookupTable();
                break;

            case ObjectType.Union:
                persistObj = new Union();
                break;

            case ObjectType.RuntimeMapDataRegionObj:
                persistObj = new RuntimeMapDataRegionObj();
                break;

            case ObjectType.DataScopeInfo:
                persistObj = new DataScopeInfo();
                break;

            case ObjectType.BucketedDataAggregateObjs:
                persistObj = new BucketedDataAggregateObjs();
                break;

            case ObjectType.DataAggregateObjBucket:
                persistObj = new DataAggregateObjBucket();
                break;

            case ObjectType.RuntimeGroupingObjHash:
                persistObj = new RuntimeGroupingObjHash();
                break;

            case ObjectType.RuntimeGroupingObjTree:
                persistObj = new RuntimeGroupingObjTree();
                break;

            case ObjectType.RuntimeGroupingObjDetail:
                persistObj = new RuntimeGroupingObjDetail();
                break;

            case ObjectType.RuntimeGroupingObjDetailUserSort:
                persistObj = new RuntimeGroupingObjDetailUserSort();
                break;

            case ObjectType.RuntimeGroupingObjLinkedList:
                persistObj = new RuntimeGroupingObjLinkedList();
                break;

            case ObjectType.RuntimeGroupingObjNaturalGroup:
                persistObj = new RuntimeGroupingObjNaturalGroup();
                break;

            default:
                persistObj = null;
                return(false);
            }
            return(true);
        }
示例#12
0
        public static SocketOutboundAdapterConfig BuildSampleConfig()
        {
            SocketOutboundAdapterConfig Config = new SocketOutboundAdapterConfig();

            #region General Params
            //Config.OutGeneralParams.LogLevel = LogType.Debug;
            Config.OutGeneralParams.TimerEnable   = true;
            Config.OutGeneralParams.TimerInterval = 1000 * 30;
            #endregion


            #region Client Socket Params
            Config.ClientSocketParams.ServerIP   = "127.0.0.1";
            Config.ClientSocketParams.ServerPort = 6000;
            #endregion

            #region Look up Table
            LookupTable lt = new LookupTable();
            lt.DisplayName = "CommandType to EventType";
            lt.Table.Add(new LookupItem("0", Convert.ToInt32(CommandBase.CommandTypeEnum.PATIENT_ADD).ToString()));
            lt.Table.Add(new LookupItem("1", Convert.ToInt32(CommandBase.CommandTypeEnum.PATIENT_UPDATE).ToString()));
            lt.Table.Add(new LookupItem("3", Convert.ToInt32(CommandBase.CommandTypeEnum.PATIENT_DEL).ToString()));
            lt.Table.Add(new LookupItem("10", Convert.ToInt32(CommandBase.CommandTypeEnum.ORDER_ADD).ToString()));
            lt.Table.Add(new LookupItem("11", Convert.ToInt32(CommandBase.CommandTypeEnum.ORDER_UPDATE).ToString()));
            lt.Table.Add(new LookupItem("13", Convert.ToInt32(CommandBase.CommandTypeEnum.ORDER_DEL).ToString()));

            //IMAGE_ARRIVAL Need not to map

            Config.LookupTables.Add(lt);

            #endregion


            #region Channel List
            SocketOutChannel ch;

            #region Channel for ImageArrival

            ch                            = new SocketOutChannel();
            ch.ChannelName                = "Out_ImageArrival";
            ch.Enable                     = true;
            ch.OperationName              = "Out_ImageArrival";
            ch.Rule.CheckProcessFlag      = true;
            ch.Rule.AutoUpdateProcessFlag = true;

            #region Query CriterialItems for channel ImageArrival
            ch.Rule.QueryCriteria.Type = QueryCriteriaRuleType.DataSet;

            // ImageArrival
            SocketOutQueryCriterialItem ciImageArrival = new SocketOutQueryCriterialItem();
            ciImageArrival.Type                    = QueryCriteriaType.And;
            ciImageArrival.SourceField             = "Event_Type";
            ciImageArrival.GWDataDBField.FieldName = "Event_Type";
            ciImageArrival.GWDataDBField.Table     = GWDataDBTable.Index;
            ciImageArrival.Translating.Type        = TranslatingType.FixValue;
            ciImageArrival.Translating.ConstValue  = "13"; // del order
            ciImageArrival.Operator                = QueryCriteriaOperator.EqualSmallerThan;
            ch.Rule.QueryCriteria.MappingList.Add(ciImageArrival);

            ciImageArrival                         = new SocketOutQueryCriterialItem();
            ciImageArrival.Type                    = QueryCriteriaType.And;
            ciImageArrival.SourceField             = "Event_Type";
            ciImageArrival.GWDataDBField.FieldName = "Event_Type";
            ciImageArrival.GWDataDBField.Table     = GWDataDBTable.Index;
            ciImageArrival.Translating.Type        = TranslatingType.FixValue;
            ciImageArrival.Translating.ConstValue  = "10"; // add order
            ciImageArrival.Operator                = QueryCriteriaOperator.EqualLargerThan;
            ch.Rule.QueryCriteria.MappingList.Add(ciImageArrival);

            ciImageArrival                         = new SocketOutQueryCriterialItem();
            ciImageArrival.Type                    = QueryCriteriaType.And;
            ciImageArrival.SourceField             = "Exam_status";
            ciImageArrival.GWDataDBField.FieldName = "Exam_status";
            ciImageArrival.GWDataDBField.Table     = GWDataDBTable.Order;
            ciImageArrival.Translating.Type        = TranslatingType.FixValue;
            ciImageArrival.Translating.ConstValue  = "18"; // ImageArrival
            ciImageArrival.Operator                = QueryCriteriaOperator.Equal;
            ch.Rule.QueryCriteria.MappingList.Add(ciImageArrival);

            #endregion

            #region Query Result for channel ImageArrival

            // Set Commantype = Convert.ToInt32(CommandBase.CommandTypeEnum.IMAGE_ARRIVAL).ToString();
            SocketOutQueryResultItem ri = new SocketOutQueryResultItem();

            // Get Data_ID ,but not send to third database
            ri.SourceField                    = "Data_ID";
            ri.TargetField                    = "Data_ID";
            ri.GWDataDBField.FieldName        = "Data_ID";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Data_DT";
            ri.TargetField                    = "Data_DT";
            ri.GWDataDBField.FieldName        = "Data_DT";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri             = new SocketOutQueryResultItem();
            ri.SourceField = "";
            ri.TargetField = "Commandtype";
            ri.ThirdPartyDBPatamter.FieldName = "Commandtype";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ri.Translating.Type       = TranslatingType.FixValue;
            ri.Translating.ConstValue = Convert.ToInt32(CommandBase.CommandTypeEnum.IMAGE_ARRIVAL).ToString();
            ch.Rule.QueryResult.MappingList.Add(ri);


            // CommandGUID -> DataIndex.Record_Index_1
            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Record_Index_1";
            ri.TargetField                    = "CommandGUID";
            ri.GWDataDBField.FieldName        = "Record_Index_1";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = "CommandGUID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ch.Rule.QueryResult.MappingList.Add(ri);

            // PatientID -> Patient.PatientID
            ri             = new SocketOutQueryResultItem();
            ri.SourceField = "PatientID";
            ri.TargetField = "PatientID";

            ri.GWDataDBField.FieldName = "PatientID";
            ri.GWDataDBField.Table     = GWDataDBTable.Patient;

            ri.ThirdPartyDBPatamter.FieldName = "PatientID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // AccessionNumber -> Order.Order_No
            ri             = new SocketOutQueryResultItem();
            ri.SourceField = "Order_No";
            ri.TargetField = "AccessionNumber";

            ri.GWDataDBField.FieldName = "Order_No";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "AccessionNumber";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // ModalityName -> Order.Modality


            // OperatorName -> Order.???

            //TODO: Identity OperatorName

            // Performed_enddt ->

            //TODO: Identity Performed_enddt

            // Performed_startdt -> Order.Exam_DT
            ri             = new SocketOutQueryResultItem();
            ri.SourceField = "Exam_DT";
            ri.TargetField = "Performed_startdt";

            ri.GWDataDBField.FieldName = "Exam_DT";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "Performed_startdt";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            #endregion

            Config.OutboundChanels.Add(ch);

            #endregion//Channel for ImageArrival



            #region Channel for Order

            ch                            = new SocketOutChannel();
            ch.ChannelName                = "crud_Order";
            ch.Enable                     = true;
            ch.OperationName              = "crud_Order";
            ch.Rule.CheckProcessFlag      = true;
            ch.Rule.AutoUpdateProcessFlag = true;

            #region Query CriterialItems for channel Order
            ch.Rule.QueryCriteria.Type = QueryCriteriaRuleType.DataSet;

            // Order
            SocketOutQueryCriterialItem ciOrder = new SocketOutQueryCriterialItem();
            ciOrder.Type                    = QueryCriteriaType.And;
            ciOrder.SourceField             = "Event_Type";
            ciOrder.GWDataDBField.FieldName = "Event_Type";
            ciOrder.GWDataDBField.Table     = GWDataDBTable.Index;
            ciOrder.Translating.Type        = TranslatingType.FixValue;
            ciOrder.Translating.ConstValue  = "13"; // del order
            ciOrder.Operator                = QueryCriteriaOperator.EqualSmallerThan;
            ch.Rule.QueryCriteria.MappingList.Add(ciOrder);

            ciOrder                         = new SocketOutQueryCriterialItem();
            ciOrder.Type                    = QueryCriteriaType.And;
            ciOrder.SourceField             = "Event_Type";
            ciOrder.GWDataDBField.FieldName = "Event_Type";
            ciOrder.GWDataDBField.Table     = GWDataDBTable.Index;
            ciOrder.Translating.Type        = TranslatingType.FixValue;
            ciOrder.Translating.ConstValue  = "10"; // add order
            ciOrder.Operator                = QueryCriteriaOperator.EqualLargerThan;
            ch.Rule.QueryCriteria.MappingList.Add(ciOrder);

            ciOrder                         = new SocketOutQueryCriterialItem();
            ciOrder.Type                    = QueryCriteriaType.And;
            ciOrder.SourceField             = "Exam_status";
            ciOrder.GWDataDBField.FieldName = "Exam_status";
            ciOrder.GWDataDBField.Table     = GWDataDBTable.Order;
            ciOrder.Translating.Type        = TranslatingType.FixValue;
            ciOrder.Translating.ConstValue  = "18"; // not imagearrval
            ciOrder.Operator                = QueryCriteriaOperator.NotEqual;
            ch.Rule.QueryCriteria.MappingList.Add(ciOrder);

            #endregion

            #region Query Result for channel Order


            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Data_ID";
            ri.TargetField                    = "Data_ID";
            ri.GWDataDBField.FieldName        = "Data_ID";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Data_DT";
            ri.TargetField                    = "Data_DT";
            ri.GWDataDBField.FieldName        = "Data_DT";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Event_Type";
            ri.TargetField                    = "Commandtype";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.GWDataDBField.FieldName        = "Event_Type";
            ri.ThirdPartyDBPatamter.FieldName = "Commandtype";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ri.Translating.Type               = TranslatingType.LookUpTable;
            ri.Translating.LutName            = lt.TableName;
            ch.Rule.QueryResult.MappingList.Add(ri);


            // CommandGUID -> DataIndex.Record_Index_1
            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Record_Index_1";
            ri.TargetField                    = "CommandGUID";
            ri.GWDataDBField.FieldName        = "Record_Index_1";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = "CommandGUID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ch.Rule.QueryResult.MappingList.Add(ri);

            // PatientID -> Patient.PatientID
            ri             = new SocketOutQueryResultItem();
            ri.SourceField = "PatientID";
            ri.TargetField = "PatientID";

            ri.GWDataDBField.FieldName = "PatientID";
            ri.GWDataDBField.Table     = GWDataDBTable.Patient;

            ri.ThirdPartyDBPatamter.FieldName = "PatientID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Order.Order_No -> AccessionNumber
            ri             = new SocketOutQueryResultItem();
            ri.SourceField = "Order_No";
            ri.TargetField = "AccessionNumber";

            ri.GWDataDBField.FieldName = "Order_No";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "AccessionNumber";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // ModalityName -> Order.Modality


            // OperatorName -> Order.???

            //TODO: Identity OperatorName

            // Performed_enddt ->

            //TODO: Identity Performed_enddt

            // Performed_startdt -> Order.Exam_DT
            //ri = new SocketOutQueryResultItem();
            //ri.SourceField = "Performed_startdt";
            //ri.TargetField = "Exam_DT";

            //ri.GWDataDBField.FieldName = "Exam_DT";
            //ri.GWDataDBField.Table = GWDataDBTable.Order;

            //ri.ThirdPartyDBPatamter.FieldName = "Performed_startdt";
            //ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            #endregion

            Config.OutboundChanels.Add(ch);

            #endregion//Channel for Order


            #region Channel For Add,Edit,Delete Patient
            ch                            = new SocketOutChannel();
            ch.ChannelName                = "Out_CRUDPatient";
            ch.Enable                     = true;
            ch.OperationName              = "Out_CRUDPatient";
            ch.Rule.CheckProcessFlag      = true;
            ch.Rule.AutoUpdateProcessFlag = true;

            #region CriterialItems
            ch.Rule.QueryCriteria.Type = QueryCriteriaRuleType.DataSet;

            // Patient Add
            SocketOutQueryCriterialItem ciPatientAdd = new SocketOutQueryCriterialItem();
            ciPatientAdd.Type                    = QueryCriteriaType.And;
            ciPatientAdd.SourceField             = "Event_Type";
            ciPatientAdd.GWDataDBField.FieldName = "Event_Type";
            ciPatientAdd.GWDataDBField.Table     = GWDataDBTable.Index;
            ciPatientAdd.Translating.Type        = TranslatingType.FixValue;
            ciPatientAdd.Translating.ConstValue  = "03";
            ciPatientAdd.Operator                = QueryCriteriaOperator.EqualSmallerThan;
            ch.Rule.QueryCriteria.MappingList.Add(ciPatientAdd);

            ciPatientAdd                         = new SocketOutQueryCriterialItem();
            ciPatientAdd.Type                    = QueryCriteriaType.And;
            ciPatientAdd.SourceField             = "Event_Type";
            ciPatientAdd.GWDataDBField.FieldName = "Event_Type";
            ciPatientAdd.GWDataDBField.Table     = GWDataDBTable.Index;
            ciPatientAdd.Translating.Type        = TranslatingType.FixValue;
            ciPatientAdd.Translating.ConstValue  = "00";
            ciPatientAdd.Operator                = QueryCriteriaOperator.EqualLargerThan;
            ch.Rule.QueryCriteria.MappingList.Add(ciPatientAdd);

            #endregion

            #region Query Result

            // Commantype -> DataIndex.Event_Type
            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Data_ID";
            ri.TargetField                    = "Data_ID";
            ri.GWDataDBField.FieldName        = "Data_ID";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Data_DT";
            ri.TargetField                    = "Data_DT";
            ri.GWDataDBField.FieldName        = "Data_DT";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Event_Type";
            ri.TargetField                    = "Commandtype";
            ri.GWDataDBField.FieldName        = "Event_Type";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = "Commandtype";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ri.Translating.Type               = TranslatingType.LookUpTable;
            ri.Translating.LutName            = lt.TableName;
            ch.Rule.QueryResult.MappingList.Add(ri);



            // CommandGUID -> DataIndex.Record_Index_1
            ri                                = new SocketOutQueryResultItem();
            ri.SourceField                    = "Record_Index_1";
            ri.TargetField                    = "CommandGUID";
            ri.GWDataDBField.FieldName        = "Record_Index_1";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = "CommandGUID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ch.Rule.QueryResult.MappingList.Add(ri);

            // PatientID -> Patient.PatientID
            ri             = new SocketOutQueryResultItem();
            ri.SourceField = "PatientID";
            ri.TargetField = "PatientID";

            ri.GWDataDBField.FieldName = "PatientID";
            ri.GWDataDBField.Table     = GWDataDBTable.Patient;

            ri.ThirdPartyDBPatamter.FieldName = "PatientID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // PatientName -> Patient_Name
            ri             = new SocketOutQueryResultItem();
            ri.SourceField = "Patient_Name";
            ri.TargetField = "PatientName";

            ri.GWDataDBField.FieldName = "Patient_Name";
            ri.GWDataDBField.Table     = GWDataDBTable.Patient;

            ri.ThirdPartyDBPatamter.FieldName = "PatientName";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);
            #endregion

            Config.OutboundChanels.Add(ch);
            #endregion



            #endregion


            #region ThrPartDBParameters

            #endregion

            return(Config);
        }
示例#13
0
        void ReadLookupListTable(BinaryReader reader, long lookupListHeadPos)
        {
            reader.BaseStream.Seek(lookupListHeadPos, SeekOrigin.Begin);
            //
            //------
            //https://www.microsoft.com/typography/otspec/chapter2.htm
            //LookupList table
            //Type 	Name 	Description
            //USHORT 	LookupCount 	Number of lookups in this table
            //Offset 	Lookup[LookupCount] 	Array of offsets to Lookup tables-from beginning of LookupList -zero based (first lookup is Lookup index = 0)
            //Lookup Table

            //A Lookup table (Lookup) defines the specific conditions, type, and results of a substitution or positioning action that is used to implement a feature. For example, a substitution operation requires a list of target glyph indices to be replaced, a list of replacement glyph indices, and a description of the type of substitution action.

            //Each Lookup table may contain only one type of information (LookupType), determined by whether the lookup is part of a GSUB or GPOS table. GSUB supports eight LookupTypes, and GPOS supports nine LookupTypes (for details about LookupTypes, see the GSUB and GPOS chapters of the document).

            //Each LookupType is defined with one or more subtables, and each subtable definition provides a different representation format. The format is determined by the content of the information required for an operation and by required storage efficiency. When glyph information is best presented in more than one format, a single lookup may contain more than one subtable, as long as all the subtables are the same LookupType. For example, within a given lookup, a glyph index array format may best represent one set of target glyphs, whereas a glyph index range format may be better for another set of target glyphs.

            //During text processing, a client applies a lookup to each glyph in the string before moving to the next lookup. A lookup is finished for a glyph after the client makes the substitution/positioning operation. To move to the “next” glyph, the client will typically skip all the glyphs that participated in the lookup operation: glyphs that were substituted/positioned as well as any other glyphs that formed a context for the operation. However, in the case of pair positioning operations (i.e., kerning), the “next” glyph in a sequence may be the second glyph of the positioned pair (see pair positioning lookup for details).

            //A Lookup table contains a LookupType, specified as an integer, that defines the type of information stored in the lookup. The LookupFlag specifies lookup qualifiers that assist a text-processing client in substituting or positioning glyphs. The SubTableCount specifies the total number of SubTables. The SubTable array specifies offsets, measured from the beginning of the Lookup table, to each SubTable enumerated in the SubTable array.
            //Lookup table
            //Type 	Name 	Description
            //USHORT 	LookupType 	Different enumerations for GSUB and GPOS
            //USHORT 	LookupFlag 	Lookup qualifiers
            //USHORT 	SubTableCount 	Number of SubTables for this lookup
            //Offset 	SubTable
            //[SubTableCount] 	Array of offsets to SubTables-from beginning of Lookup table
            //unit16 	MarkFilteringSet

            ushort lookupCount = reader.ReadUInt16();
            lookupTables = new LookupTable[lookupCount];
            int[] subTableOffset = new int[lookupCount];
            for (int i = 0; i < lookupCount; ++i)
            {
                subTableOffset[i] = reader.ReadUInt16();
            }
            //----------------------------------------------
            //load each sub table
            //https://www.microsoft.com/typography/otspec/chapter2.htm
            for (int i = 0; i < lookupCount; ++i)
            {
                long lookupTablePos = lookupListHeadPos + subTableOffset[i];
                reader.BaseStream.Seek(lookupTablePos, SeekOrigin.Begin);

                ushort lookupType = reader.ReadUInt16();//Each Lookup table may contain only one type of information (LookupType)
                ushort lookupFlags = reader.ReadUInt16();
                ushort subTableCount = reader.ReadUInt16();
                //Each LookupType is defined with one or more subtables, and each subtable definition provides a different representation format
                //
                ushort[] subTableOffsets = new ushort[subTableCount];
                for (int m = 0; m < subTableCount; ++m)
                {
                    subTableOffsets[m] = reader.ReadUInt16();
                }

                ushort markFilteringSet =
                    ((lookupFlags & 0x0010) == 0x0010) ? reader.ReadUInt16() : (ushort)0;

                lookupTables[i] =
                    new LookupTable(
                        lookupTablePos,
                        lookupType,
                        lookupFlags,
                        subTableCount,
                        subTableOffsets,//Array of offsets to SubTables-from beginning of Lookup table
                        markFilteringSet);
            }
            //----------------------------------------------
            //read each lookup record content ...
            for (int i = 0; i < lookupCount; ++i)
            {
                LookupTable lookupRecord = lookupTables[i];
                //set origin
                reader.BaseStream.Seek(lookupListHeadPos + subTableOffset[i], SeekOrigin.Begin);
                lookupRecord.ReadRecordContent(reader);
            }

        }
示例#14
0
        private static void ComputeTableCache(
            IOpenTypeFont font,
            OpenTypeTags tableTag,
            int maxCacheSize,
            ref int cacheSize,
            ref GlyphLookupRecord[] records,
            ref int recordCount,
            ref int glyphCount,
            ref int lastLookupAdded
            )
        {
            FontTable table = font.GetFontTable(tableTag);

            if (!table.IsPresent)
            {
                return;
            }

            FeatureList featureList;
            LookupList  lookupList;

            Debug.Assert(tableTag == OpenTypeTags.GSUB || tableTag == OpenTypeTags.GPOS);

            switch (tableTag)
            {
            case OpenTypeTags.GSUB:
            {
                GSUBHeader header = new GSUBHeader();
                featureList = header.GetFeatureList(table);
                lookupList  = header.GetLookupList(table);
                break;
            }

            case OpenTypeTags.GPOS:
            {
                GPOSHeader header = new GPOSHeader();
                featureList = header.GetFeatureList(table);
                lookupList  = header.GetLookupList(table);
                break;
            }

            default:
            {
                Debug.Assert(false);
                featureList = new FeatureList(0);
                lookupList  = new LookupList(0);
                break;
            }
            }

            // Estimate number of records that can fit into cache using ratio of approximately
            // 4 bytes of cache per actual record. Most of fonts will fit into this value, except
            // some tiny caches and big EA font that can have ratio of around 5 (theoretical maximum is 8).
            //
            // If actual ratio for particluar font will be larger than 4, we will remove records
            // from the end to fit into cache.
            //
            // If ratio is less than 4 we actually can fit more lookups, but for the speed and because most fonts
            // will fit into cache completely anyway we do not do anything about this here.
            int maxRecordCount = maxCacheSize / 4;

            // For now, we will just allocate array of maximum size.
            // Given heuristics above, it wont be greater than max cache size.
            //
            records = new GlyphLookupRecord[maxRecordCount];

            //
            // Now iterate through lookups and subtables, filling in lookup-glyph pairs list
            //
            int lookupCount = lookupList.LookupCount(table);
            int recordCountAfterLastLookup = 0;

            //
            // Not all lookups can be invoked from feature directly,
            // they are actions from contextual lookups.
            // We are not interested in those, because they will
            // never work from high level, so do not bother adding them to the cache.
            //
            // Filling array of lookup usage bits, to skip those not mapped to any lookup
            //
            BitArray lookupUsage = new BitArray(lookupCount);

            for (ushort feature = 0; feature < featureList.FeatureCount(table); feature++)
            {
                FeatureTable featureTable = featureList.FeatureTable(table, feature);

                for (ushort lookup = 0; lookup < featureTable.LookupCount(table); lookup++)
                {
                    ushort lookupIndex = featureTable.LookupIndex(table, lookup);

                    if (lookupIndex >= lookupCount)
                    {
                        // This must be an invalid font. Just igonoring this lookup here.
                        continue;
                    }

                    lookupUsage[lookupIndex] = true;
                }
            }
            // Done with lookup usage bits

            for (ushort lookupIndex = 0; lookupIndex < lookupCount; lookupIndex++)
            {
                if (!lookupUsage[lookupIndex])
                {
                    continue;
                }

                int  firstLookupRecord = recordCount;
                int  maxLookupGlyph    = -1;
                bool cacheIsFull       = false;

                LookupTable lookup        = lookupList.Lookup(table, lookupIndex);
                ushort      lookupType    = lookup.LookupType();
                ushort      subtableCount = lookup.SubTableCount();

                for (ushort subtableIndex = 0; subtableIndex < subtableCount; subtableIndex++)
                {
                    int subtableOffset = lookup.SubtableOffset(table, subtableIndex);

                    CoverageTable coverage = GetSubtablePrincipalCoverage(table, tableTag, lookupType, subtableOffset);

                    if (coverage.IsInvalid)
                    {
                        continue;
                    }

                    cacheIsFull = !AppendCoverageGlyphRecords(table, lookupIndex, coverage, records, ref recordCount, ref maxLookupGlyph);

                    if (cacheIsFull)
                    {
                        break;
                    }
                }

                if (cacheIsFull)
                {
                    break;
                }

                lastLookupAdded            = lookupIndex;
                recordCountAfterLastLookup = recordCount;
            }

            // We may hit storage overflow in the middle of lookup. Throw this partial lookup away
            recordCount = recordCountAfterLastLookup;

            if (lastLookupAdded == -1)
            {
                // We did not succeed adding even single lookup.
                return;
            }

            // We now have glyph records for (may be not all) lookups in the table.
            // Cache structures should be sorted by glyph, then by lookup index.
            Array.Sort(records, 0, recordCount);

            cacheSize  = -1;
            glyphCount = -1;

            // It may happen, that records do not fit into cache, even using our heuristics.
            // We will remove lookups one by one from the end until it fits.
            while (recordCount > 0)
            {
                CalculateCacheSize(records, recordCount, out cacheSize, out glyphCount);

                if (cacheSize <= maxCacheSize)
                {
                    // Fine, we now fit into max cache size
                    break;
                }
                else
                {
                    // Find last lookup index
                    int lastLookup = -1;
                    for (int i = 0; i < recordCount; i++)
                    {
                        int lookup = records[i].Lookup;

                        if (lastLookup < lookup)
                        {
                            lastLookup = lookup;
                        }
                    }

                    Debug.Assert(lastLookup >= 0); // There are lookups, so there was an index

                    // Remove it
                    int currentRecord = 0;
                    for (int i = 0; i < recordCount; i++)
                    {
                        if (records[i].Lookup == lastLookup)
                        {
                            continue;
                        }

                        if (currentRecord == i)
                        {
                            continue;
                        }

                        records[currentRecord] = records[i];
                        currentRecord++;
                    }

                    recordCount = currentRecord;

                    // Do not forget update lastLookupAdded variable
                    lastLookupAdded = lastLookup - 1;
                }
            }

            if (recordCount == 0)
            {
                // We can't fit even single lookup into the cache
                return;
            }

            Debug.Assert(cacheSize > 0);  // We've calcucalted them at least ones, and
            Debug.Assert(glyphCount > 0); // if there is no records, we already should've exited
        }
示例#15
0
 private void Box_ValueChanged(object sender, EventArgs e)
 {
     Delg.SetMaximum(Trades, LookupTable.GetRemainingSpaces((int)Box.Value, (int)Slot.Value));
 }
示例#16
0
 private void Box_ValueChanged(object sender, EventArgs e)
 {
     Delg.SetMaximum(Eggs, LookupTable.getMaxSpace((int)Box.Value, (int)Slot.Value));
 }
示例#17
0
        protected virtual IEnumerable <TeamCityBuildType> GetBuildTypes(
            NukeBuild build,
            ExecutableTarget executableTarget,
            TeamCityVcsRoot vcsRoot,
            LookupTable <ExecutableTarget, TeamCityBuildType> buildTypes)
        {
            var isPartitioned        = ArtifactExtensions.Partitions.ContainsKey(executableTarget.Definition);
            var artifactRules        = ArtifactExtensions.ArtifactProducts[executableTarget.Definition].Select(GetArtifactRule).ToArray();
            var artifactDependencies = (
                from artifactDependency in ArtifactExtensions.ArtifactDependencies[executableTarget.Definition]
                let dependency = executableTarget.ExecutionDependencies.Single(x => x.Factory == artifactDependency.Item1)
                                 let rules = (artifactDependency.Item2.Any()
                        ? artifactDependency.Item2
                        : ArtifactExtensions.ArtifactProducts[dependency.Definition])
                                             .Select(GetArtifactRule).ToArray()
                                             select new TeamCityArtifactDependency
            {
                BuildType = buildTypes[dependency].Single(x => x.Partition == null),
                ArtifactRules = rules
            }).ToArray <TeamCityDependency>();

            var invokedTargets = executableTarget
                                 .DescendantsAndSelf(x => x.ExecutionDependencies, x => NonEntryTargets.Contains(x.Name))
                                 .Where(x => x == executableTarget || NonEntryTargets.Contains(x.Name))
                                 .Reverse()
                                 .Select(x => x.Name).ToArray();
            var snapshotDependencies = executableTarget.ExecutionDependencies
                                       .Where(x => !ExcludedTargets.Contains(x.Name) && !NonEntryTargets.Contains(x.Name))
                                       .SelectMany(x => buildTypes[x])
                                       .Where(x => x.Partition == null)
                                       .Select(x => new TeamCitySnapshotDependency
            {
                BuildType     = x,
                FailureAction = TeamCityDependencyFailureAction.FailToStart,
                CancelAction  = TeamCityDependencyFailureAction.Cancel
            }).ToArray <TeamCityDependency>();

            if (isPartitioned)
            {
                var partitions = ArtifactExtensions.Partitions[executableTarget.Definition];
                for (var i = 0; i < partitions; i++)
                {
                    var partition = new Partition {
                        Part = i + 1, Total = partitions
                    };
                    yield return(new TeamCityBuildType
                    {
                        Id = $"{executableTarget.Name}_P{partition.Part}T{partition.Total}",
                        Name = $"{executableTarget.Name} {partition}",
                        Description = executableTarget.Description,
                        Platform = Platform,
                        ArtifactRules = artifactRules,
                        Partition = partition,
                        PartitionTarget = executableTarget.Name,
                        InvokedTargets = invokedTargets,
                        VcsRoot = new TeamCityBuildTypeVcsRoot {
                            Root = vcsRoot
                        },
                        Dependencies = snapshotDependencies.Concat(artifactDependencies).ToArray()
                    });
                }

                snapshotDependencies = buildTypes[executableTarget]
                                       .Select(x => new TeamCitySnapshotDependency
                {
                    BuildType     = x,
                    FailureAction = TeamCityDependencyFailureAction.FailToStart,
                    CancelAction  = TeamCityDependencyFailureAction.Cancel
                }).ToArray <TeamCityDependency>();
                artifactDependencies = new TeamCityDependency[0];
            }

            var parameters = executableTarget.Requirements
                             .Where(x => !(x is Expression <Func <bool> >))
                             .Select(x => GetParameter(x.GetMemberInfo(), build, required: true)).ToArray();
            var triggers = GetTriggers(executableTarget, buildTypes).ToArray();

            yield return(new TeamCityBuildType
            {
                Id = executableTarget.Name,
                Name = executableTarget.Name,
                Description = executableTarget.Description,
                Platform = Platform,
                VcsRoot = new TeamCityBuildTypeVcsRoot
                {
                    Root = vcsRoot,
                    ShowDependenciesChanges = isPartitioned
                },
                IsComposite = isPartitioned,
                InvokedTargets = invokedTargets,
                ArtifactRules = artifactRules,
                Dependencies = snapshotDependencies.Concat(artifactDependencies).ToArray(),
                Parameters = parameters,
                Triggers = triggers
            });
        }
        public override ConfigurationEntity GetConfiguration(
            NukeBuild build,
            IReadOnlyCollection <ExecutableTarget> relevantTargets
            )
        {
            var steps = new List <GitHubActionsStep> {
                new CheckoutStep("Checkout"),
                // new SetupDotNetStep("Install .NET Core Sdk"),
            };


            var globalToolStep = new RunStep("Install Nuke Global Tool")
            {
                Run = "dotnet tool install -g Nuke.GlobalTool"
            };
            var dotnetTools = Path.Combine(NukeBuild.RootDirectory, ".config/dotnet-tools.json");
            var localTool   = false;

            if (File.Exists(dotnetTools))
            {
                steps.Add(new RunStep("dotnet tool restore")
                {
                    Run = "dotnet tool restore"
                });
                if (!File.ReadAllText(dotnetTools).Contains("\"nuke.globaltool\": {"))
                {
                    steps.Add(globalToolStep);
                }
                else
                {
                    localTool = true;
                }
            }
            else
            {
                steps.Add(globalToolStep);
            }

            var stepParameters = GetParameters(build).Select(z => $"--{z.Name.ToLowerInvariant()} '${{{{ env.{z.Name.ToUpperInvariant()} }}}}'")
                                 .ToArray()
                                 .JoinSpace();

            var lookupTable = new LookupTable <ExecutableTarget, ExecutableTarget[]>();

            foreach (var(execute, targets) in relevantTargets
                     .Select(x => (ExecutableTarget: x, Targets: GetInvokedTargets(x, relevantTargets).ToArray()))
                     .ForEachLazy(x => lookupTable.Add(x.ExecutableTarget, x.Targets.ToArray()))
                     )
            {
                steps.Add(new RunStep(execute.Name.Humanize(LetterCasing.Title))
                {
                    Run = $"{( localTool ? "dotnet nuke" : "nuke" )} {targets.Select(z => z.Name).JoinSpace()} --skip {stepParameters}".TrimEnd()
                });
            }

            var config = new RocketSurgeonGitHubActionsConfiguration()
            {
                Name             = _name,
                DetailedTriggers = GetTriggers().ToList(),
                Jobs             = new List <RocketSurgeonsGithubActionsJob> {
                    new RocketSurgeonsGithubActionsJob("Build")
                    {
                        Steps  = steps,
                        Images = _images,
                    }
                }
            };

            if (Enhancements?.Any() == true)
            {
                foreach (var method in Enhancements.Join(build.GetType().GetMethods(), z => z, z => z.Name, (_, e) => e))
                {
                    config = method.IsStatic
                        ? method.Invoke(null, new object[] { config }) as RocketSurgeonGitHubActionsConfiguration ?? config
                        : method.Invoke(build, new object[] { config }) as RocketSurgeonGitHubActionsConfiguration ?? config;
                }
            }

            return(config);
        }
示例#19
0
        private static LookupTable LoadMAVTable(string TableName)
        {
            var lookupTable = new LookupTable();

            string sql = "select Wt, MAV from " + TableName + " order by Wt";

            DbDataReader dr = WWD.GetSysReader(sql);

            while (dr.Read())
            {
                lookupTable.Add(dr.GetFloat(0), dr.GetFloat(1));
            }

            dr.Close();

            return lookupTable;
        }
示例#20
0
        // updating
        private void updatePermissions(int pid)
        {
            string principal = String.Empty, grant = String.Empty, deny = String.Empty, revoke = String.Empty, grantwgrant = String.Empty;
            LookupTable permissionLT;

            if (String.IsNullOrEmpty(db)) {
                principal = dbl.getPrincipalName(pid);
                permissionLT = new LookupTable(LookupTables.serverPermissionType);
            } else {
                principal = dbl.getPrincipalName(db, pid);
                permissionLT = new LookupTable(LookupTables.databasePermissionType);
            }

            for (int i = 0; i < post.Count; i++) {
                if (String.Compare(post[i], submitValue) == 0) continue;

                switch(post[i]) {
                    case "G":
                        grant += ((grant.Length > 0) ? ", " : "") + permissionLT(post.GetKey(i));
                        break;
                    case "D":
                        deny += ((deny.Length > 0) ? ", " : "") + permissionLT(post.GetKey(i));
                        break;
                    case "R":
                        revoke += ((revoke.Length > 0) ? ", " : "") + permissionLT(post.GetKey(i));
                        break;
                    case "W":
                        grantwgrant += ((grantwgrant.Length > 0) ? ", " : "") + permissionLT(post.GetKey(i));
                        break;
                }
            }

            if (grant.Length > 0) dbl.executeQuery(db, "GRANT " + grant + " TO " + principal);
            if (deny.Length > 0) dbl.executeQuery(db, "DENY " + deny + " TO " + principal); // there is no way this will work
            if (revoke.Length > 0) dbl.executeQuery(db, "REVOKE " + revoke + " FROM " + principal);
            if (grantwgrant.Length > 0) dbl.executeQuery(db, "GRANT " + grantwgrant + " TO " + principal + " WITH GRANT OPTION");

            principal_edit(pid);
        }
示例#21
0
        public static RdetOutboundAdapterConfig BuildSampleConfig()
        {
            RdetOutboundAdapterConfig Config = new RdetOutboundAdapterConfig();

            #region General Params
            Config.OutGeneralParams.TimerEnable   = true;
            Config.OutGeneralParams.TimerInterval = 1000 * 30;
            #endregion


            #region Client Rdet Params
            Config.ClientRdetParams.ServerIP   = "127.0.0.1";
            Config.ClientRdetParams.ServerPort = 58431;
            #endregion

            #region Look up Table
            LookupTable ltEventType = new LookupTable();
            ltEventType.DisplayName = "EventType To Command ";
            //ltEventType.Table.Add(new LookupItem("00", "NewPatient"));
            //ltEventType.Table.Add(new LookupItem("01", "UpdatePatient"));
            ltEventType.Table.Add(new LookupItem("10", "NewPatient"));
            ltEventType.Table.Add(new LookupItem("11", "UpdatePatient"));
            ltEventType.Table.Add(new LookupItem("99", "NewImage"));
            Config.LookupTables.Add(ltEventType);



            LookupTable ltSex = new LookupTable();
            ltSex.DisplayName = "Sex To Gender ";
            ltSex.Table.Add(new LookupItem("M", "1"));
            ltSex.Table.Add(new LookupItem("F", "2"));
            ltSex.Table.Add(new LookupItem("O", "3"));
            ltSex.Table.Add(new LookupItem("U", "3"));
            Config.LookupTables.Add(ltSex);

            #endregion


            #region Channel List
            RdetOutChannel         ch;
            RdetOutQueryResultItem ri;

            #region Channel for NewPatient,UpdatePatient <- NewOrder and updateorder
            // Actuall New Order -> New patient and Update Order -> Update Patient

            ch                            = new RdetOutChannel();
            ch.ChannelName                = "NewPatient/UpdatePatient";
            ch.Enable                     = true;
            ch.OperationName              = "NewPatient/UpdatePatient";
            ch.Rule.CheckProcessFlag      = true;
            ch.Rule.AutoUpdateProcessFlag = true;

            #region Query CriterialItems for channel Order
            ch.Rule.QueryCriteria.Type = QueryCriteriaRuleType.DataSet;

            // Order
            RdetOutQueryCriterialItem ciOrder = new RdetOutQueryCriterialItem();
            ciOrder.Type                    = QueryCriteriaType.Or;
            ciOrder.SourceField             = "Event_Type";
            ciOrder.GWDataDBField.FieldName = "Event_Type";
            ciOrder.GWDataDBField.Table     = GWDataDBTable.Index;
            ciOrder.Translating.Type        = TranslatingType.FixValue;
            ciOrder.Translating.ConstValue  = "10"; // new order
            ciOrder.Operator                = QueryCriteriaOperator.Equal;
            ch.Rule.QueryCriteria.MappingList.Add(ciOrder);

            ciOrder                         = new RdetOutQueryCriterialItem();
            ciOrder.Type                    = QueryCriteriaType.Or;
            ciOrder.SourceField             = "Event_Type";
            ciOrder.GWDataDBField.FieldName = "Event_Type";
            ciOrder.GWDataDBField.Table     = GWDataDBTable.Index;
            ciOrder.Translating.Type        = TranslatingType.FixValue;
            ciOrder.Translating.ConstValue  = "11"; // update order
            ciOrder.Operator                = QueryCriteriaOperator.Equal;
            ch.Rule.QueryCriteria.MappingList.Add(ciOrder);

            ciOrder                         = new RdetOutQueryCriterialItem();
            ciOrder.Type                    = QueryCriteriaType.Or;
            ciOrder.SourceField             = "Event_Type";
            ciOrder.GWDataDBField.FieldName = "Event_Type";
            ciOrder.GWDataDBField.Table     = GWDataDBTable.Index;
            ciOrder.Translating.Type        = TranslatingType.FixValue;
            ciOrder.Translating.ConstValue  = "01"; // update patient
            ciOrder.Operator                = QueryCriteriaOperator.Equal;
            ch.Rule.QueryCriteria.MappingList.Add(ciOrder);

            ciOrder                         = new RdetOutQueryCriterialItem();
            ciOrder.Type                    = QueryCriteriaType.Or;
            ciOrder.SourceField             = "Event_Type";
            ciOrder.GWDataDBField.FieldName = "Event_Type";
            ciOrder.GWDataDBField.Table     = GWDataDBTable.Index;
            ciOrder.Translating.Type        = TranslatingType.FixValue;
            ciOrder.Translating.ConstValue  = "00"; // add patient
            ciOrder.Operator                = QueryCriteriaOperator.Equal;
            ch.Rule.QueryCriteria.MappingList.Add(ciOrder);

            #endregion

            #region Query Result for channel Order -> New/Update patient

            ri                                = new RdetOutQueryResultItem();
            ri.SourceField                    = "Data_ID";
            ri.TargetField                    = "Data_ID";
            ri.GWDataDBField.FieldName        = "Data_ID";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri                                = new RdetOutQueryResultItem();
            ri.SourceField                    = "Data_DT";
            ri.TargetField                    = "Data_DT";
            ri.GWDataDBField.FieldName        = "Data_DT";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri                                = new RdetOutQueryResultItem();
            ri.SourceField                    = "Event_Type";
            ri.TargetField                    = "Command";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.GWDataDBField.FieldName        = "Event_Type";
            ri.ThirdPartyDBPatamter.FieldName = "Command";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ri.Translating.Type               = TranslatingType.LookUpTable;
            ri.Translating.LutName            = ltEventType.TableName;
            ch.Rule.QueryResult.MappingList.Add(ri);


            // Order.Study_Instance_UID -> StudyInstanceUID
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Study_Instance_UID";
            ri.TargetField = "StudyInstanceUID";

            ri.GWDataDBField.FieldName = "Study_Instance_UID";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "StudyInstanceUID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);


            // Patient.PatientID  -> PatientID
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "PatientID";
            ri.TargetField = "PatientID";

            ri.GWDataDBField.FieldName = "PatientID";
            ri.GWDataDBField.Table     = GWDataDBTable.Patient;

            ri.ThirdPartyDBPatamter.FieldName = "PatientID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Patient.PatientName -> PatientName
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Patient_Name";
            ri.TargetField = "PatientName";

            ri.GWDataDBField.FieldName = "Patient_Name";
            ri.GWDataDBField.Table     = GWDataDBTable.Patient;

            ri.ThirdPartyDBPatamter.FieldName = "PatientName";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Patient.BirthDate -> BirthDate
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "BirthDate";
            ri.TargetField = "BirthDate";

            ri.GWDataDBField.FieldName = "BirthDate";
            ri.GWDataDBField.Table     = GWDataDBTable.Patient;

            ri.ThirdPartyDBPatamter.FieldName = "BirthDate";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            //sex -> gender
            ri                                = new RdetOutQueryResultItem();
            ri.SourceField                    = "sex";
            ri.TargetField                    = "Gender";
            ri.GWDataDBField.Table            = GWDataDBTable.Patient;
            ri.GWDataDBField.FieldName        = "sex";
            ri.ThirdPartyDBPatamter.FieldName = "Gender";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ri.Translating.Type               = TranslatingType.LookUpTable;
            ri.Translating.LutName            = ltSex.TableName;
            ch.Rule.QueryResult.MappingList.Add(ri);


            // Order.Order_No -> AccessionNumber
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Order_No";
            ri.TargetField = "AccessionNumber";

            ri.GWDataDBField.FieldName = "Order_No";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "AccessionNumber";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);


            // Order.Scheduled_DT -> StudyDate
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Scheduled_DT";
            ri.TargetField = "StudyDate";

            ri.GWDataDBField.FieldName = "Scheduled_DT";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "StudyDate";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);


            // Order.Scheduled_DT -> StudyTime
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Scheduled_DT";
            ri.TargetField = "StudyTime";

            ri.GWDataDBField.FieldName = "Scheduled_DT";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "StudyTime";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);


            // Order.Scheduled_DT -> StudyTime
            //ri = new RdetOutQueryResultItem();
            //ri.SourceField = "Scheduled_DT";
            //ri.TargetField = "StudyTime";

            //ri.GWDataDBField.FieldName = "Scheduled_DT";
            //ri.GWDataDBField.Table = GWDataDBTable.Order;

            //ri.ThirdPartyDBPatamter.FieldName = "StudyTime";
            //ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            //ch.Rule.QueryResult.MappingList.Add(ri);


            // Order.Customer_1 -> Priority
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Customer_1";
            ri.TargetField = "Priority";

            ri.GWDataDBField.FieldName = "Customer_1";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "Priority";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ri.Translating.Type       = TranslatingType.DefaultValue;
            ri.Translating.ConstValue = "1";  //3=STAT,2=Urgent,1=Routine
            ch.Rule.QueryResult.MappingList.Add(ri);

            // Patient.Procedure_Name -> ProcedureName
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Procedure_Name";
            ri.TargetField = "ProcedureName";

            ri.GWDataDBField.FieldName = "Procedure_Name";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "ProcedureName";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Patient.Procedure_Code -> ProcedureCode
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Procedure_Code";
            ri.TargetField = "ProcedureCode";

            ri.GWDataDBField.FieldName = "Procedure_Code";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "ProcedureCode";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Patient.Customer_1 -> PatientComments
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Customer_1";
            ri.TargetField = "PatientComments";

            ri.GWDataDBField.FieldName = "Customer_1";
            ri.GWDataDBField.Table     = GWDataDBTable.Patient;

            ri.ThirdPartyDBPatamter.FieldName = "PatientComments";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Order.REF_Physician -> ReferringPhysician
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "REF_Physician";
            ri.TargetField = "ReferringPhysician";

            ri.GWDataDBField.FieldName = "REF_Physician";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "ReferringPhysician";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Order.Placer_Department -> Department
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Placer_Department";
            ri.TargetField = "Department";

            ri.GWDataDBField.FieldName = "Placer_Department";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "Department";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Patient.Patient_Location -> PatientLocation
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Patient_Location";
            ri.TargetField = "PatientLocation";

            ri.GWDataDBField.FieldName = "Patient_Location";
            ri.GWDataDBField.Table     = GWDataDBTable.Patient;

            ri.ThirdPartyDBPatamter.FieldName = "PatientLocation";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);


            // Order.CNT_Agent -> ContrastAgent
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "CNT_Agent";
            ri.TargetField = "ContrastAgent";

            ri.GWDataDBField.FieldName = "CNT_Agent";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "ContrastAgent";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Order.Customer_2 -> TechID
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Customer_2";
            ri.TargetField = "TechID";

            ri.GWDataDBField.FieldName = "Customer_2";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "TechID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Order.Study_ID -> StudyID
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Study_ID";
            ri.TargetField = "StudyID";

            ri.GWDataDBField.FieldName = "Study_ID";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "StudyID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Order.Station_Name -> StationName
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Station_Name";
            ri.TargetField = "StationName";

            ri.GWDataDBField.FieldName = "Station_Name";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "StationName";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            // Order.Station_AETitle -> AETitle
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Station_AETitle";
            ri.TargetField = "AETitle";

            ri.GWDataDBField.FieldName = "Station_AETitle";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "AETitle";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);


            #endregion

            Config.OutboundChanels.Add(ch);

            #endregion//Channel for Order


            #region Channel For UpdatePatient
            //ch = new RdetOutChannel();
            //ch.ChannelName = "Out_CRUDPatient";
            //ch.Enable = true;
            //ch.OperationName = "Out_CRUDPatient";
            //ch.Rule.CheckProcessFlag = true;
            //ch.Rule.AutoUpdateProcessFlag = true;

            //#region CriterialItems
            //ch.Rule.QueryCriteria.Type = QueryCriteriaRuleType.DataSet;

            //// Patient Add
            //RdetOutQueryCriterialItem ciPatientAdd = new RdetOutQueryCriterialItem();
            //ciPatientAdd.Type = QueryCriteriaType.And;
            //ciPatientAdd.SourceField = "Event_Type";
            //ciPatientAdd.GWDataDBField.FieldName = "Event_Type";
            //ciPatientAdd.GWDataDBField.Table = GWDataDBTable.Index;
            //ciPatientAdd.Translating.Type = TranslatingType.FixValue;
            //ciPatientAdd.Translating.ConstValue = "03";
            //ciPatientAdd.Operator = QueryCriteriaOperator.EqualSmallerThan;
            //ch.Rule.QueryCriteria.MappingList.Add(ciPatientAdd);

            //ciPatientAdd = new RdetOutQueryCriterialItem();
            //ciPatientAdd.Type = QueryCriteriaType.And;
            //ciPatientAdd.SourceField = "Event_Type";
            //ciPatientAdd.GWDataDBField.FieldName = "Event_Type";
            //ciPatientAdd.GWDataDBField.Table = GWDataDBTable.Index;
            //ciPatientAdd.Translating.Type = TranslatingType.FixValue;
            //ciPatientAdd.Translating.ConstValue = "00";
            //ciPatientAdd.Operator = QueryCriteriaOperator.EqualLargerThan;
            //ch.Rule.QueryCriteria.MappingList.Add(ciPatientAdd);

            //#endregion

            //#region Query Result

            //// Commantype -> DataIndex.Event_Type
            //ri = new RdetOutQueryResultItem();
            //ri.SourceField = "Data_ID";
            //ri.TargetField = "Data_ID";
            //ri.GWDataDBField.FieldName = "Data_ID";
            //ri.GWDataDBField.Table = GWDataDBTable.Index;
            //ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            //ch.Rule.QueryResult.MappingList.Add(ri);

            //ri = new RdetOutQueryResultItem();
            //ri.SourceField = "Data_DT";
            //ri.TargetField = "Data_DT";
            //ri.GWDataDBField.FieldName = "Data_DT";
            //ri.GWDataDBField.Table = GWDataDBTable.Index;
            //ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            //ch.Rule.QueryResult.MappingList.Add(ri);

            //ri = new RdetOutQueryResultItem();
            //ri.SourceField = "Event_Type";
            //ri.TargetField = "Commandtype";
            //ri.GWDataDBField.FieldName = "Event_Type";
            //ri.GWDataDBField.Table = GWDataDBTable.Index;
            //ri.ThirdPartyDBPatamter.FieldName = "Commandtype";
            //ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            //ri.Translating.Type = TranslatingType.LookUpTable;
            //ri.Translating.LutName = lt.TableName;
            //ch.Rule.QueryResult.MappingList.Add(ri);



            //// CommandGUID -> DataIndex.Record_Index_1
            //ri = new RdetOutQueryResultItem();
            //ri.SourceField = "Record_Index_1";
            //ri.TargetField = "CommandGUID";
            //ri.GWDataDBField.FieldName = "Record_Index_1";
            //ri.GWDataDBField.Table = GWDataDBTable.Index;
            //ri.ThirdPartyDBPatamter.FieldName = "CommandGUID";
            //ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            //ch.Rule.QueryResult.MappingList.Add(ri);

            //// PatientID -> Patient.PatientID
            //ri = new RdetOutQueryResultItem();
            //ri.SourceField = "PatientID";
            //ri.TargetField = "PatientID";

            //ri.GWDataDBField.FieldName = "PatientID";
            //ri.GWDataDBField.Table = GWDataDBTable.Patient;

            //ri.ThirdPartyDBPatamter.FieldName = "PatientID";
            //ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            //ch.Rule.QueryResult.MappingList.Add(ri);

            //// PatientName -> Patient_Name
            //ri = new RdetOutQueryResultItem();
            //ri.SourceField = "PatientName";
            //ri.TargetField = "Patient_Name";

            //ri.GWDataDBField.FieldName = "Patient_Name";
            //ri.GWDataDBField.Table = GWDataDBTable.Patient;

            //ri.ThirdPartyDBPatamter.FieldName = "PatientName";
            //ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            //ch.Rule.QueryResult.MappingList.Add(ri);
            //#endregion

            //Config.OutboundChanels.Add(ch);
            #endregion

            #region Channel for NewImage

            ch                            = new RdetOutChannel();
            ch.ChannelName                = "NewImage";
            ch.Enable                     = false;
            ch.OperationName              = "NewImage";
            ch.Rule.CheckProcessFlag      = true;
            ch.Rule.AutoUpdateProcessFlag = true;

            #region Query CriterialItems for channel NewImage
            ch.Rule.QueryCriteria.Type = QueryCriteriaRuleType.DataSet;

            // ImageArrival
            RdetOutQueryCriterialItem ciImageArrival = new RdetOutQueryCriterialItem();
            ciImageArrival.Type                    = QueryCriteriaType.And;
            ciImageArrival.SourceField             = "Event_Type";
            ciImageArrival.GWDataDBField.FieldName = "Event_Type";
            ciImageArrival.GWDataDBField.Table     = GWDataDBTable.Index;
            ciImageArrival.Translating.Type        = TranslatingType.FixValue;
            ciImageArrival.Translating.ConstValue  = "100"; // New Image
            ciImageArrival.Operator                = QueryCriteriaOperator.EqualSmallerThan;
            ch.Rule.QueryCriteria.MappingList.Add(ciImageArrival);

            #endregion

            #region Query Result for channel NewImage

            // Set Commantype = Convert.ToInt32(CommandBase.CommandTypeEnum.IMAGE_ARRIVAL).ToString();

            // Get Data_ID ,but not send to third database
            ri.SourceField                    = "Data_ID";
            ri.TargetField                    = "Data_ID";
            ri.GWDataDBField.FieldName        = "Data_ID";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri                                = new RdetOutQueryResultItem();
            ri.SourceField                    = "Data_DT";
            ri.TargetField                    = "Data_DT";
            ri.GWDataDBField.FieldName        = "Data_DT";
            ri.GWDataDBField.Table            = GWDataDBTable.Index;
            ri.ThirdPartyDBPatamter.FieldName = ""; //flag not send to third database
            ch.Rule.QueryResult.MappingList.Add(ri);

            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "";
            ri.TargetField = "Command";
            ri.ThirdPartyDBPatamter.FieldName = "Command";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;
            ri.Translating.Type       = TranslatingType.FixValue;
            ri.Translating.ConstValue = "NewImage";
            ch.Rule.QueryResult.MappingList.Add(ri);


            // Order.Study_Instance_UID -> StudyInstanceUID
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Study_Instance_UID";
            ri.TargetField = "StudyInstanceUID";

            ri.GWDataDBField.FieldName = "Study_Instance_UID";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "StudyInstanceUID";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            //// AccessionNumber -> Order.Order_No
            //ri = new RdetOutQueryResultItem();
            //ri.SourceField = "Order_No";
            //ri.TargetField = "AccessionNumber";

            //ri.GWDataDBField.FieldName = "Order_No";
            //ri.GWDataDBField.Table = GWDataDBTable.Order;

            //ri.ThirdPartyDBPatamter.FieldName = "AccessionNumber";
            //ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            //ch.Rule.QueryResult.MappingList.Add(ri);

            // ModalityName -> Order.Modality


            // OperatorName -> Order.???

            //TODO: Identity OperatorName

            // Performed_enddt ->

            //TODO: Identity Performed_enddt

            // Performed_startdt -> Order.Exam_DT
            ri             = new RdetOutQueryResultItem();
            ri.SourceField = "Exam_DT";
            ri.TargetField = "Performed_startdt";

            ri.GWDataDBField.FieldName = "Exam_DT";
            ri.GWDataDBField.Table     = GWDataDBTable.Order;

            ri.ThirdPartyDBPatamter.FieldName = "Performed_startdt";
            ri.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar;

            ch.Rule.QueryResult.MappingList.Add(ri);

            #endregion

            Config.OutboundChanels.Add(ch);

            #endregion//Channel for ImageArrival


            #endregion


            #region ThrPartDBParameters

            #endregion

            return(Config);
        }
示例#22
0
        private LookupTable _AssignValues(LookupTable request, DocConstantPermission permission, Session session)
        {
            if (permission != DocConstantPermission.ADD && (request == null || request.Id <= 0))
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No record");
            }

            if (permission == DocConstantPermission.ADD && !DocPermissionFactory.HasPermissionTryAdd(currentUser, "LookupTable"))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
            }

            request.Select = request.Select ?? new List <string>();

            LookupTable ret = null;

            request = _InitAssignValues <LookupTable>(request, permission, session);
            //In case init assign handles create for us, return it
            if (permission == DocConstantPermission.ADD && request.Id > 0)
            {
                return(request);
            }

            var cacheKey = GetApiCacheKey <LookupTable>(DocConstantModelName.LOOKUPTABLE, nameof(LookupTable), request);

            //First, assign all the variables, do database lookups and conversions
            var pBindings   = GetVariable <Reference>(request, nameof(request.Bindings), request.Bindings?.ToList(), request.BindingsIds?.ToList());
            var pCategories = GetVariable <Reference>(request, nameof(request.Categories), request.Categories?.ToList(), request.CategoriesIds?.ToList());
            var pDocuments  = GetVariable <Reference>(request, nameof(request.Documents), request.Documents?.ToList(), request.DocumentsIds?.ToList());
            var pEnum       = DocEntityLookupTableEnum.Get(request.Enum);
            var pName       = request.Name;
            var pArchived   = true == request.Archived;
            var pLocked     = request.Locked;

            var entity = InitEntity <DocEntityLookupTable, LookupTable>(request, permission, session);

            if (AllowPatchValue <LookupTable, bool>(request, DocConstantModelName.LOOKUPTABLE, pArchived, permission, nameof(request.Archived), pArchived != entity.Archived))
            {
                entity.Archived = pArchived;
            }
            if (AllowPatchValue <LookupTable, DocEntityLookupTableEnum>(request, DocConstantModelName.LOOKUPTABLE, pEnum, permission, nameof(request.Enum), pEnum != entity.Enum))
            {
                entity.Enum = pEnum;
            }
            if (AllowPatchValue <LookupTable, string>(request, DocConstantModelName.LOOKUPTABLE, pName, permission, nameof(request.Name), pName != entity.Name))
            {
                entity.Name = pName;
            }
            if (request.Locked && AllowPatchValue <LookupTable, bool>(request, DocConstantModelName.LOOKUPTABLE, pArchived, permission, nameof(request.Locked), pLocked != entity.Locked))
            {
                entity.Archived = pArchived;
            }
            entity.SaveChanges(permission);

            var idsToInvalidate = new List <int>();

            idsToInvalidate.AddRange(PatchCollection <LookupTable, DocEntityLookupTable, Reference, DocEntityLookupTableBinding>(request, entity, pBindings, permission, nameof(request.Bindings)));
            idsToInvalidate.AddRange(PatchCollection <LookupTable, DocEntityLookupTable, Reference, DocEntityLookupCategory>(request, entity, pCategories, permission, nameof(request.Categories)));
            idsToInvalidate.AddRange(PatchCollection <LookupTable, DocEntityLookupTable, Reference, DocEntityDocument>(request, entity, pDocuments, permission, nameof(request.Documents)));
            if (idsToInvalidate.Any())
            {
                idsToInvalidate.Add(entity.Id);
                DocCacheClient.RemoveByEntityIds(idsToInvalidate);
                DocCacheClient.RemoveSearch(DocConstantModelName.LOOKUPTABLE);
            }

            entity.SaveChanges(permission);
            DocPermissionFactory.SetSelect <LookupTable>(currentUser, nameof(LookupTable), request.Select);
            ret = entity.ToDto();

            var cacheExpires = DocResources.Metadata.GetCacheExpiration(DocConstantModelName.LOOKUPTABLE);

            DocCacheClient.Set(key: cacheKey, value: ret, entityId: request.Id, entityType: DocConstantModelName.LOOKUPTABLE, cacheExpires);

            return(ret);
        }
示例#23
0
        public static void Main(string[] args)
        {
            Config      config  = new Config();
            LookupTable lt      = new LookupTable(config.MAX_TOKENS); // Class to store Tokens and Symbols
            string      Command = "";

            try
            {
                //this is the command string which chooses which operation the interpreter will do
                Command = args[0].Trim(new Char[] { '[', ',', '\'', ']' });
            }
            catch (Exception)
            {
                new ErrorReply("Controller error", "No arguements given", Command).PrintToConsole();
                return;
            }

            //This sets it down the newton raphson root root.
            if (Command == "rootofpoly")
            {
                //This deserializes the list of doubles used for the method
                dynamic text = JsonConvert.DeserializeObject(args[1]);

                //These are preset from the config file and are used for the f# functions
                double error = config.ErrorMargin;
                double seed  = config.Seed;

                //This loops over each double and adds it to a list
                //which is then converted to a f# list
                var inputs = new List <double>();
                foreach (string s in text)
                {
                    inputs.Add(Double.Parse(s));
                }
                var fs_list = ListModule.OfSeq(inputs);

                double result = NewtonRoot.CNewton(fs_list, seed, error);

                //This calls and replys back the result from the f# method
                new PositiveReply(null, null, result).PrintToConsole();

                return;
            }
            //this fork just parses the expression/statement
            else if (Command == "parse")
            {
                //deserializes the list of expressions/statements
                dynamic text = JsonConvert.DeserializeObject(args[1]);

                //inits a reply
                Reply reply = null;

                //This loops over every expression/statement
                foreach (string s in text)
                {
                    //This sets the reply from the parse function
                    reply = Parse(ref lt, s, true, ("", 0));

                    //If an error has occured te interpreter returns it before parsing all loops
                    if (reply is ErrorReply)
                    {
                        Console.WriteLine(JsonConvert.SerializeObject(reply));
                        return;
                    }
                }

                //if no error has occured it returns the reply of the last statement/error

                new PositiveReply(lt.operations, lt.variables, 0).PrintToConsole();

                return;
            }
            //This fork both parses and executes the list of expressions/statements
            else if (Command == "expression")
            {
                dynamic text = JsonConvert.DeserializeObject(args[1]);

                double final_result = 0.0;

                foreach (string s in text)
                {
                    Reply reply = Parse(ref lt, s, false, ("", 0));

                    //if an error is found at any point it returns early with an error
                    if (reply is ErrorReply)
                    {
                        Console.WriteLine(JsonConvert.SerializeObject(reply));
                        return;
                    }
                    //if not it runs the executor
                    else
                    {
                        //Init the executor and get the result of parsed tokens
                        //then resets the symbol table for the next expression/statement
                        double   result = 0.0;
                        Executor exe    = new Executor(ref lt, false);

                        try
                        {
                            result = exe.ShuntYard();
                        }
                        catch (Exception e)
                        {
                            new ErrorReply("Executor error", e.Message, s).PrintToConsole();
                            return;
                        }

                        lt.InitSymbols();
                        lt.operations = exe.operations;

                        //This is used for output
                        final_result = result;
                    }
                }
                //This sets the abst for output and then sends the reply
                //LT.pt.SetAST();
                new PositiveReply(lt.operations, lt.variables, final_result).PrintToConsole();
                return;
            }
            else if (Command == "cal")
            {
                dynamic input      = JsonConvert.DeserializeObject(args[1]);
                string  var        = "";
                double  from       = 0.0;
                double  to         = 0.0;
                double  step       = 0.0;
                string  expression = "";

                int i = 0;

                foreach (string obj in input)
                {
                    if (i == 0)
                    {
                        var = obj;
                    }
                    if (i == 1)
                    {
                        from = Double.Parse(obj);
                    }
                    if (i == 2)
                    {
                        to = Double.Parse(obj);
                    }
                    if (i == 3)
                    {
                        step = Double.Parse(obj);
                    }
                    if (i == 4)
                    {
                        expression = obj;
                    }
                    i++;
                }


                Dictionary <double, double> points = new Dictionary <double, double>();

                while (from <= to)
                {
                    Reply reply = Parse(ref lt, expression, false, (var, from));

                    //if an error is found at any point it returns early with an error
                    if (reply is ErrorReply)
                    {
                        Console.WriteLine(JsonConvert.SerializeObject(reply));
                        return;
                    }
                    //if not it runs the executor
                    else
                    {
                        //Init the executor and get the result of parsed tokens
                        //then resets the symbol table for the next expression/statement
                        Executor exe = new Executor(ref lt, false);

                        try
                        {
                            points.Add(from, exe.ShuntYard());
                        }
                        catch (Exception e)
                        {
                            new ErrorReply("Executor error", e.Message, expression).PrintToConsole();
                            return;
                        }

                        //This is used for output
                        lt.InitSymbols();
                    }
                    from += step;
                }
                //This sets the abst for output and then sends the reply
                //LT.pt.SetAST();
                new PositiveReply(lt.operations, lt.variables, points.Count, points).PrintToConsole();
                return;
            }
            else if (Command == "env")
            {
                Executor exe = new Executor(ref lt, false);

                while (true)
                {
                    Console.WriteLine("------------");

                    Dictionary <string, object> vars = new Dictionary <string, object>();

                    string input        = Console.ReadLine();
                    double final_result = 0.0;

                    if (input == "EXIT")
                    {
                        return;
                    }

                    Reply reply = Parse(ref lt, input, false, ("", 0));

                    foreach (KeyValuePair <string, object> pair in vars)
                    {
                        lt.variables.Add(pair.Key, pair.Value);
                    }

                    //if an error is found at any point it returns early with an error
                    if (reply is ErrorReply)
                    {
                        Console.WriteLine(JsonConvert.SerializeObject(reply));
                    }
                    //if not it runs the executor
                    else
                    {
                        //Init the executor and get the result of parsed tokens
                        //then resets the symbol table for the next expression/statement
                        double result = 0.0;

                        try
                        {
                            result = exe.ShuntYard();
                            //This is used for output
                            final_result = result;
                            new PositiveReply(exe.operations, lt.variables, final_result).PrintToConsole();
                        }
                        catch (Exception e)
                        {
                            new ErrorReply("Executor error", e.Message, input).PrintToConsole();
                        }
                    }
                    exe.operations.Clear();
                    lt.InitSymbols();
                }
            }
            //if the command variable is not recognised it will throw this error
            else
            {
                new ErrorReply("Interpreter error", "Unknown command", Command).PrintToConsole();
            }
        }
示例#24
0
        public static void Compute(LinearDecomposition decomposition)
        {
            Graph graph = decomposition.Graph;
            List<int> sequence = decomposition.Sequence;
            int n = graph.Size;

            BitSet right = graph.Vertices;
            BitSet left = new BitSet(0, n);

            LookupTable table = new LookupTable(n);
            LinearRepresentativeTable cuts = new LinearRepresentativeTable(graph, sequence);

            table[new BitSet(0, n), 0] = 1;
            table[new BitSet(0, n), 1] = 0;

            for (int i = 0; i < sequence.Count; i++)
            {
                int v = sequence[i];

                left.Add(v);
                right.Remove(v);

                LinearRepresentativeList LRw = cuts[left];

                LinearRepresentativeList LRa = cuts[left - v];

                LookupTable newTable = new LookupTable(n);

                foreach (BitSet ra in LRa)
                {
                    BitSet nra = graph.Neighborhood(ra) * right;
                    BitSet rw = LRw.GetRepresentative(nra);

                    int maxValue = int.MinValue;
                    int limit = (left - v).Count;
                    for (int k = 0; k <= limit; k++)
                        if (table[ra, k] > 0)
                            maxValue = Math.Max(maxValue, k);

                    for (int j = 0; j <= maxValue; j++)
                    {
                        newTable[rw, j] = newTable[rw, j] + table[ra, j];
                    }

                    //------------

                    // ra + {v} is not a valid independent set
                    if (LRa.GetNeighborhood(ra).Contains(v))
                        continue;

                    //------------

                    // add {v} to the independent set
                    BitSet nrav = graph.Neighborhood(ra + v) * right;
                    BitSet rwv = LRw.GetRepresentative(nrav);

                    for (int j = 0; j <= maxValue; j++)
                    {
                        newTable[rwv, j + 1] = newTable[rwv, j + 1] + table[ra, j];
                    }
                }

                table = newTable;
            }

            return;
        }
示例#25
0
 /// <summary>
 /// This function is the parser but modular so both forks can use it
 /// </summary>
 /// <param name="lt"> ref LookupTable</param>
 /// <param name="s"> string s</param>
 /// <param name="isFromParseFunc"> bool for checking which function the call came from</param>
 /// <returns></returns>
 public static Reply Parse(ref LookupTable lt, string s, bool isFromParseFunc, (string, double) var)
示例#26
0
        protected override AzurePipelinesJob GetJob(ExecutableTarget executableTarget, LookupTable <ExecutableTarget, AzurePipelinesJob> jobs)
        {
            var job = base.GetJob(executableTarget, jobs);

            var dictionary = new Dictionary <string, string>
            {
                { nameof(Compile), "⚙️" },
                { nameof(Test), "🚦" },
                { nameof(Pack), "📦" },
                { nameof(Coverage), "📊" },
                { nameof(Publish), "🚚" },
                { nameof(Announce), "🗣" }
            };
            var symbol = dictionary.GetValueOrDefault(job.Name).NotNull("symbol != null");

            job.DisplayName = job.PartitionName == null
                ? $"{symbol} {job.DisplayName}"
                : $"{symbol} {job.DisplayName} 🧩";
            return(job);
        }
示例#27
0
        /// <summary>
        /// Creates a worksheet in the given XLWorkbook containing the list of changes made
        /// during randomization.
        /// </summary>
        public static void CreateSpoilerLog(XLWorkbook workbook)
        {
            if (LookupTable.Count == 0)
            {
                return;
            }
            var ws = workbook.Worksheets.Add("Module");

            int i = 1;

            ws.Cell(i, 1).Value           = "Seed";
            ws.Cell(i, 1).Style.Font.Bold = true;
            ws.Cell(i, 2).Value           = Properties.Settings.Default.Seed;
            i++;

            Version version = typeof(StartForm).Assembly.GetName().Version;

            ws.Cell(i, 1).Value                      = "Version";
            ws.Cell(i, 1).Style.Font.Bold            = true;
            ws.Cell(i, 2).Value                      = $"v{version.Major}.{version.Minor}.{version.Build}";
            ws.Cell(i, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
            i += 2;     // Skip a row.

            // Module Randomization Settings
            ws.Cell(i, 1).Value = "Module Extra";
            ws.Cell(i, 2).Value = "Is Enabled";
            ws.Cell(i, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
            ws.Cell(i, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
            ws.Cell(i, 1).Style.Font.Bold           = true;
            ws.Cell(i, 2).Style.Font.Bold           = true;
            i++;

            string presetName;
            bool   isCustomPreset = false;

            if (Properties.Settings.Default.LastPresetComboIndex >= 0)
            {
                presetName = Globals.OMIT_PRESETS.Keys.ToList()[Properties.Settings.Default.LastPresetComboIndex];
            }
            else
            {
                presetName     = "Custom";
                isCustomPreset = true;
            }

            var settings = new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("Delete Milestone Save Data", (!Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.NoSaveDelete)).ToString()),
                new Tuple <string, string>("Include Minigames in Save", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.SaveMiniGames).ToString()),
                new Tuple <string, string>("Include All Modules in Save", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.SaveAllModules).ToString()),
                new Tuple <string, string>("", ""),  // Skip a row.
                new Tuple <string, string>("Add Spice Lab Load Zone", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.VulkarSpiceLZ).ToString()),
                new Tuple <string, string>("Fix Dream Sequence", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.FixDream).ToString()),
                new Tuple <string, string>("Fix Mind Prison", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.FixMindPrison).ToString()),
                new Tuple <string, string>("Fix Module Coordinates", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.FixCoordinates).ToString()),
                new Tuple <string, string>("Unlock DAN Ruins Door", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.UnlockDanRuins).ToString()),
                new Tuple <string, string>("Unlock EBO Galaxy Map", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.UnlockGalaxyMap).ToString()),
                new Tuple <string, string>("Unlock LEV Elevators", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.UnlockLevElev).ToString()),
                new Tuple <string, string>("Unlock MAN Door to Sub", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.UnlockManSub).ToString()),
                new Tuple <string, string>("Unlock STA Door to Bastila", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.UnlockStaBastila).ToString()),
                new Tuple <string, string>("Unlock UNK Summit Exit", Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.UnlockUnkSummit).ToString()),
                new Tuple <string, string>("", ""),  // Skip a row.
                new Tuple <string, string>("Shuffle Preset", presetName),
                new Tuple <string, string>("", ""),  // Skip a row.
                new Tuple <string, string>("Use Rando Exclusion Rules", Properties.Settings.Default.UseRandoRules.ToString()),
                new Tuple <string, string>("Verify Reachability", Properties.Settings.Default.VerifyReachability.ToString()),
                new Tuple <string, string>("Goal Is Malak", Properties.Settings.Default.GoalIsMalak.ToString()),
                new Tuple <string, string>("Goal Is Star Maps", Properties.Settings.Default.GoalIsStarMaps.ToString()),
                new Tuple <string, string>("Goal Is Pazaak", Properties.Settings.Default.GoalIsPazaak.ToString()),
                new Tuple <string, string>("Allow Glitch Clipping", Properties.Settings.Default.AllowGlitchClip.ToString()),
                new Tuple <string, string>("Allow Glitch DLZ", Properties.Settings.Default.AllowGlitchDlz.ToString()),
                new Tuple <string, string>("Allow Glitch FLU", Properties.Settings.Default.AllowGlitchFlu.ToString()),
                new Tuple <string, string>("Allow Glitch GPW", Properties.Settings.Default.AllowGlitchGpw.ToString()),
                new Tuple <string, string>("Ignore Single-Use Edges", Properties.Settings.Default.IgnoreOnceEdges.ToString()),
                new Tuple <string, string>("", ""),  // Skip a row.
            };

            foreach (var setting in settings)
            {
                ws.Cell(i, 1).Value             = setting.Item1;
                ws.Cell(i, 2).Value             = setting.Item2;
                ws.Cell(i, 1).Style.Font.Italic = true;
                i++;
            }

            // Custom Omitted Modules
            var omittedModules = Globals.BoundModules.Where(x => x.Omitted);

            if (isCustomPreset)
            {
                int iMax = i;
                i = 3;  // Restart at the top of the settings list.

                ws.Cell(i, 4).Value           = "Omitted Modules";
                ws.Cell(i, 4).Style.Font.Bold = true;
                ws.Range(i, 4, i, 5).Merge().Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                i++;

                ws.Cell(i, 4).Value = "Warp Code";
                ws.Cell(i, 5).Value = "Common Name";
                ws.Cell(i, 4).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
                ws.Cell(i, 5).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
                ws.Cell(i, 4).Style.Font.Italic         = true;
                ws.Cell(i, 5).Style.Font.Italic         = true;
                i++;

                foreach (var mod in omittedModules)
                {
                    ws.Cell(i, 4).Value = mod.Code;
                    ws.Cell(i, 5).Value = mod.Common;
                    i++;
                }

                // Handle variable length omitted modules list.
                if (iMax > i)
                {
                    i = iMax;           // Return to bottom of settings list.
                }
                else
                {
                    i++;       // Skip a row.
                }
            }

            // Module Shuffle
            ws.Cell(i, 1).Value           = "Module Shuffle";
            ws.Cell(i, 1).Style.Font.Bold = true;
            ws.Range(i, 1, i, 5).Merge().Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            i++;

            ws.Cell(i, 1).Value = "Has Changed";
            ws.Cell(i, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            ws.Cell(i, 1).Style.Font.Bold            = true;
            ws.Range(i, 1, i + 1, 1).Merge().Style.Border.BottomBorder = XLBorderStyleValues.Thin;
            ws.Cell(i, 2).Value = "New Destination";
            ws.Cell(i, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            ws.Cell(i, 2).Style.Font.Bold            = true;
            ws.Cell(i, 2).Style.Border.LeftBorder    = XLBorderStyleValues.Thin;
            ws.Range(i, 2, i, 3).Merge();
            ws.Cell(i, 4).Value = "Old Destination";
            ws.Cell(i, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            ws.Cell(i, 4).Style.Font.Bold            = true;
            ws.Cell(i, 4).Style.Border.LeftBorder    = XLBorderStyleValues.Thin;
            ws.Range(i, 4, i, 5).Merge();
            i++;

            ws.Cell(i, 2).Value = "Default Code";
            ws.Cell(i, 3).Value = "Default Name";
            ws.Cell(i, 4).Value = "Shuffled Code";
            ws.Cell(i, 5).Value = "Shuffled Name";
            ws.Cell(i, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            ws.Cell(i, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            ws.Cell(i, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            ws.Cell(i, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            ws.Cell(i, 2).Style.Border.BottomBorder  = XLBorderStyleValues.Thin;
            ws.Cell(i, 2).Style.Border.LeftBorder    = XLBorderStyleValues.Thin;
            ws.Cell(i, 3).Style.Border.BottomBorder  = XLBorderStyleValues.Thin;
            ws.Cell(i, 4).Style.Border.BottomBorder  = XLBorderStyleValues.Thin;
            ws.Cell(i, 4).Style.Border.LeftBorder    = XLBorderStyleValues.Thin;
            ws.Cell(i, 5).Style.Border.BottomBorder  = XLBorderStyleValues.Thin;
            ws.Cell(i, 2).Style.Font.Bold            = true;
            ws.Cell(i, 3).Style.Font.Bold            = true;
            ws.Cell(i, 4).Style.Font.Bold            = true;
            ws.Cell(i, 5).Style.Font.Bold            = true;
            i++;

            var sortedLookup = LookupTable.OrderBy(kvp => kvp.Key);

            foreach (var kvp in sortedLookup)
            {
                var defaultName    = Digraph.Modules.FirstOrDefault(m => m.WarpCode == kvp.Key)?.CommonName;
                var randomizedName = Digraph.Modules.FirstOrDefault(m => m.WarpCode == kvp.Value)?.CommonName;
                var omitted        = omittedModules.Any(x => x.Code == kvp.Key); // Was the module omitted from the shuffle?
                var changed        = kvp.Key != kvp.Value;                       // Has the shuffle changed this module?

                ws.Cell(i, 1).Value = omitted ? "OMITTED" : changed.ToString();
                ws.Cell(i, 2).Value = kvp.Key;
                ws.Cell(i, 2).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
                ws.Cell(i, 3).Value = defaultName;
                ws.Cell(i, 4).Value = kvp.Value;
                ws.Cell(i, 4).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
                ws.Cell(i, 5).Value = randomizedName;

                if (omitted)
                {
                    // Center "OMITTED" text.
                    ws.Cell(i, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                }
                else
                {
                    // Set color of "Has Changed" column. Booleans are automatically centered.
                    if (changed)
                    {
                        ws.Cell(i, 1).Style.Font.FontColor = XLColor.Green;
                    }
                    else
                    {
                        ws.Cell(i, 1).Style.Font.FontColor = XLColor.Red;
                    }
                }
                i++;
            }

            // Resize Columns
            ws.Column(1).AdjustToContents();
            ws.Column(2).AdjustToContents();
            ws.Column(3).AdjustToContents();
            ws.Column(4).AdjustToContents();
            ws.Column(5).AdjustToContents();
        }
示例#28
0
 public LUTWrapper(LookupTable lut)
 {
     this.DisplayName = lut.DisplayName;
     this.TableName   = lut.TableName;
 }
示例#29
0
        /// <summary>
        /// Populates and shuffles the the modules flagged to be randomized. Returns true if override files should be added.
        /// </summary>
        /// <param name="paths">KPaths object for this game.</param>
        public static void Module_rando(KPaths paths)
        {
            // Reset digraph reachability settings.
            Digraph.ResetSettings();
            LookupTable.Clear();

            // Split the Bound modules into their respective lists.
            bool reachable  = false;
            int  iterations = 0;

            // Only shuffle if there is more than 1 module in the shuffle.
            if (Globals.BoundModules.Count(x => !x.Omitted) > 1)
            {
                if (Properties.Settings.Default.UseRandoRules ||
                    Properties.Settings.Default.VerifyReachability)
                {
                    System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                    sw.Start();

                    while (!reachable && iterations < MAX_ITERATIONS)
                    {
                        iterations++;

                        Console.WriteLine($"Iteration {iterations}:");

                        CreateLookupTableShuffle();

                        Digraph.SetRandomizationLookup(LookupTable);

                        if (Properties.Settings.Default.UseRandoRules)
                        {
                            // Skip to the next iteration if the rules are violated.
                            if (AreRulesViolated())
                            {
                                continue;
                            }
                        }

                        if (Properties.Settings.Default.VerifyReachability)
                        {
                            Digraph.CheckReachability();
                            reachable = Digraph.IsGoalReachable();
                        }
                        else
                        {
                            reachable = true;
                        }
                    }

                    if (Properties.Settings.Default.VerifyReachability)
                    {
                        if (reachable)
                        {
                            var message = $"Reachable solution found after {iterations} shuffles. Time elapsed: {sw.Elapsed}";
                            Console.WriteLine(message);
                        }
                        else
                        {
                            // Throw an exception if not reachable.
                            var message = $"No reachable solution found over {iterations} shuffles. Time elapsed: {sw.Elapsed}";
                            Console.WriteLine(message);
                            throw new TimeoutException(message);
                        }
                    }

                    //digraph.WriteReachableToConsole();
                    Console.WriteLine();
                }
                else
                {
                    CreateLookupTableShuffle();
                }
            }
            else
            {
                CreateLookupTableNoShuffle();
            }

            WriteFilesToModulesDirectory(paths);

            // Write additional override files (and unlock galaxy map).
            WriteOverrideFiles(paths);

            // Fix warp coordinates.
            if (Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.FixCoordinates))
            {
                FixWarpCoordinates(paths);
            }

            // Fixed Rakata riddle Man in Mind Prison.
            if (Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.FixMindPrison))
            {
                FixMindPrison(paths);
            }

            // Unlock locked doors or elevators.
            UnlockDoors(paths);

            // Vulkar Spice Lab Transition
            if (Properties.Settings.Default.ModuleExtrasValue.HasFlag(ModuleExtras.VulkarSpiceLZ))
            {
                var vulk_files = paths.FilesInModules.Where(fi => fi.Name.Contains(LookupTable[AREA_TAR_VULK_BASE]));
                foreach (FileInfo fi in vulk_files)
                {
                    // Skip any files that end in "s.rim".
                    if (fi.Name[fi.Name.Length - 5] == 's')
                    {
                        continue;
                    }

                    RIM r_vul = new RIM(fi.FullName);
                    r_vul.File_Table.FirstOrDefault(x => x.Label == LABEL_TAR_VULK_GIT && x.TypeID == (int)ResourceType.GIT).File_Data = Properties.Resources.m10aa;

                    r_vul.WriteToFile(fi.FullName);
                }
            }
        }
示例#30
0
        public static int Compute(LinearDecomposition decomposition)
        {
            Graph graph = decomposition.Graph;
            int n = graph.Size;
            List<int> sequence = decomposition.Sequence;
            BitSet left = new BitSet(0, graph.Size);
            BitSet right = graph.Vertices;
            BitSet VG = graph.Vertices;

            LinearRepresentativeTable cuts = new LinearRepresentativeTable(graph, sequence);
            LookupTable table = new LookupTable();

            // first initialize the very first leaf node
            int l = sequence[0];
            left.Add(l);
            right.Remove(l);

            // Base cases
            BitSet leaf = new BitSet(0, n) { l };
            BitSet nleaf = new BitSet(0, n) { graph.OpenNeighborhood(l).First() };

            table[new BitSet(0, n), new BitSet(0, n)] = int.MaxValue;
            table[leaf, new BitSet(0, n)] = 1;
            table[leaf, nleaf] = 1;
            table[new BitSet(0, n), nleaf] = 0;

            for (int i = 1; i < sequence.Count; i++)
            {
                int v = sequence[i];

                left.Add(v);
                right.Remove(v);

                LinearRepresentativeList LRw = cuts[left];
                LinearRepresentativeList LRw_ = cuts[right];

                LinearRepresentativeList LRa = cuts[left - v];
                LinearRepresentativeList LRa_ = cuts[right + v];

                LookupTable newTable = new LookupTable();

                foreach (BitSet outside in LRw_)
                {
                    foreach (BitSet inside in LRa)
                    {
                        BitSet nrw_ = graph.Neighborhood(outside) * (left - v);
                        BitSet ra_ = LRa_.GetRepresentative(nrw_);

                        BitSet nra = graph.Neighborhood(inside) * right;
                        BitSet rw = LRw.GetRepresentative(nra);

                        int savedValue = newTable[rw, outside];
                        int newValue = table[inside, ra_];

                        BitSet raw_ = inside + outside;
                        BitSet nraw_ = graph.Neighborhood(raw_);
                        if (!nraw_.Contains(v))
                            newValue = int.MaxValue;

                        int min = Math.Min(savedValue, newValue);
                        newTable[rw, outside] = min;

                        //--------

                        nrw_ = graph.Neighborhood(outside + v) * (left - v);
                        ra_ = LRa_.GetRepresentative(nrw_);

                        nra = graph.Neighborhood(inside + v) * right;
                        rw = LRw.GetRepresentative(nra);

                        savedValue = newTable[rw, outside];
                        newValue = table[inside, ra_];
                        newValue = newValue == int.MaxValue ? newValue : newValue + 1;
                        min = Math.Min(savedValue, newValue);
                        newTable[rw,  outside] = min;
                    }
                }

                table = newTable;
            }

            return table[new BitSet(0, graph.Size), new BitSet(0, graph.Size)];
        }
示例#31
0
        public void ExposeTable(string name, LookupTable lut)
        {
            TableMetaData baseTable = GetBaseTable(name);

            if (baseTable != null)
            {
                TableMetaData childTable = baseTable.CreateChild(lut, this);
                //TODO: HANDLE STATIC AXES!!
                if (lut.dataAddress < 0x400000)
                {
                    //TODO: HANDLE UPDATES TO EXISTING TABLES!!??
                    if (ExposedRomTables.ContainsKey(childTable.name))
                    {
                        ExposedRomTables.Remove(childTable.name);
                    }
                    ExposedRomTables.Add(childTable.name, childTable);
                }
                else
                {
                    if (ExposedRamTables.ContainsKey(childTable.name))
                    {
                        ExposedRamTables.Remove(childTable.name);
                    }
                    ExposedRamTables.Add(childTable.name, childTable);
                }
            }

            //if (bt == null) return;
            //bt.SetAttributeValue("address", lut.dataAddress.ToString("X"));//(System.Int32.Parse(temptable.Value.Attribute("offset").Value.ToString(), System.Globalization.NumberStyles.AllowHexSpecifier) + offset).ToString("X"));
            //IEnumerable<XAttribute> tempattr = bt.Attributes();
            //List<String> remattr = new List<String>();
            //foreach (XAttribute attr in tempattr)
            //{
            //    if (attr.Name != "address" && attr.Name != "name")
            //    {
            //        remattr.Add(attr.Name.ToString());
            //    }
            //}
            //foreach (String rem in remattr)
            //{
            //    bt.Attribute(rem).Remove();
            //}

            //List<String> eleremlist = new List<String>();

            //foreach (XElement ele in bt.Elements())
            //{
            //    IEnumerable<XAttribute> childtempattr = ele.Attributes();
            //    List<String> childremattr = new List<String>();

            //    if (ele.Name.ToString() != "table")
            //    {
            //        eleremlist.Add(ele.Name.ToString());
            //        continue;
            //    }
            //    if (ele.Attribute("type").Value.ContainsCI("static"))
            //    {
            //        eleremlist.Add(ele.Name.ToString());
            //    }
            //    else if (ele.Attribute("type").Value.ContainsCI("x axis"))
            //    {
            //        ele.Attribute("name").Value = "X";
            //    }
            //    else if (ele.Attribute("type").Value.ContainsCI("y axis"))
            //    {
            //        ele.Attribute("name").Value = "Y";
            //    }
            //    foreach (XAttribute attr in childtempattr)
            //    {
            //        if (attr.Name != "address" && attr.Name != "name")
            //        {
            //            childremattr.Add(attr.Name.ToString());
            //        }
            //    }
            //    foreach (String rem in childremattr)
            //    {
            //        ele.Attribute(rem).Remove();
            //    }
            //}
            //foreach (String rem in eleremlist)
            //{
            //    bt.Element(rem).Remove();
            //}
        }
示例#32
0
        protected virtual IEnumerable <TeamCityBuildType> GetBuildTypes(
            NukeBuild build,
            ExecutableTarget executableTarget,
            TeamCityVcsRoot vcsRoot,
            LookupTable <ExecutableTarget, TeamCityBuildType> buildTypes,
            IReadOnlyCollection <ExecutableTarget> relevantTargets)
        {
            var chainLinkTargets = GetInvokedTargets(executableTarget, relevantTargets).ToArray();
            var isPartitioned    = ArtifactExtensions.Partitions.ContainsKey(executableTarget.Definition);

            var artifactRules = chainLinkTargets.SelectMany(x =>
                                                            ArtifactExtensions.ArtifactProducts[x.Definition].Select(GetArtifactRule)).ToArray();
            var artifactDependencies = chainLinkTargets.SelectMany(x =>
                                                                   from artifactDependency in ArtifactExtensions.ArtifactDependencies[x.Definition]
                                                                   let dependency                         = relevantTargets.Single(y => y.Factory == artifactDependency.Item1)
                                                                                                let rules = (artifactDependency.Item2.Any()
                        ? artifactDependency.Item2
                        : ArtifactExtensions.ArtifactProducts[dependency.Definition])
                                                                                                            .Select(GetArtifactRule).ToArray()
                                                                                                            select new TeamCityArtifactDependency
            {
                BuildType     = buildTypes[dependency].Single(y => y.Partition == null),
                ArtifactRules = rules
            }).ToArray <TeamCityDependency>();

            var snapshotDependencies = GetTargetDependencies(executableTarget)
                                       .SelectMany(x => buildTypes[x])
                                       .Where(x => x.Partition == null)
                                       .Select(x => new TeamCitySnapshotDependency
            {
                BuildType     = x,
                FailureAction = TeamCityDependencyFailureAction.FailToStart,
                CancelAction  = TeamCityDependencyFailureAction.Cancel
            }).ToArray <TeamCityDependency>();

            if (isPartitioned)
            {
                var(partitionName, totalPartitions) = ArtifactExtensions.Partitions[executableTarget.Definition];
                for (var i = 0; i < totalPartitions; i++)
                {
                    var partition = new Partition {
                        Part = i + 1, Total = totalPartitions
                    };
                    yield return(new TeamCityBuildType
                    {
                        Id = $"{executableTarget.Name}_P{partition.Part}T{partition.Total}",
                        Name = $"{executableTarget.Name} {partition}",
                        Description = executableTarget.Description,
                        BuildCmdPath = BuildCmdPath,
                        ArtifactRules = artifactRules,
                        Partition = partition,
                        PartitionName = partitionName,
                        InvokedTargets = chainLinkTargets.Select(x => x.Name).ToArray(),
                        VcsRoot = new TeamCityBuildTypeVcsRoot {
                            Root = vcsRoot, CleanCheckoutDirectory = CleanCheckoutDirectory
                        },
                        Dependencies = snapshotDependencies.Concat(artifactDependencies).ToArray()
                    });
                }

                artifactRules        = new[] { "**/*" };
                snapshotDependencies = buildTypes[executableTarget]
                                       .Select(x => new TeamCitySnapshotDependency
                {
                    BuildType     = x,
                    FailureAction = TeamCityDependencyFailureAction.AddProblem,
                    CancelAction  = TeamCityDependencyFailureAction.Cancel
                }).ToArray <TeamCityDependency>();
                artifactDependencies = buildTypes[executableTarget]
                                       .Select(x => new TeamCityArtifactDependency
                {
                    BuildType     = x,
                    ArtifactRules = new[] { "**/*" }
                }).ToArray <TeamCityDependency>();
            }

            var parameters = executableTarget.Requirements
                             .Where(x => !(x is Expression <Func <bool> >))
                             .Select(x => GetParameter(x.GetMemberInfo(), build, required: true))
                             .Concat(new TeamCityKeyValueParameter(
                                         "teamcity.ui.runButton.caption",
                                         executableTarget.Name.SplitCamelHumpsWithSeparator(" ", Constants.KnownWords))).ToArray();
            var triggers = GetTriggers(executableTarget, buildTypes).ToArray();

            yield return(new TeamCityBuildType
            {
                Id = executableTarget.Name,
                Name = executableTarget.Name,
                Description = executableTarget.Description,
                BuildCmdPath = BuildCmdPath,
                VcsRoot = new TeamCityBuildTypeVcsRoot
                {
                    Root = vcsRoot,
                    ShowDependenciesChanges = isPartitioned,
                    CleanCheckoutDirectory = CleanCheckoutDirectory
                },
                IsComposite = isPartitioned,
                IsDeployment = ManuallyTriggeredTargets.Contains(executableTarget.Name),
                InvokedTargets = chainLinkTargets.Select(x => x.Name).ToArray(),
                ArtifactRules = artifactRules,
                Dependencies = snapshotDependencies.Concat(artifactDependencies).ToArray(),
                Parameters = parameters,
                Triggers = triggers
            });
        }
示例#33
0
        internal object[] EvaluateLookup()
        {
            bool flag = m_lookupInfo.ReturnFirstMatchOnly();
            OnDemandProcessingContext odpContext = m_reportRuntime.ReportObjectModel.OdpContext;

            Microsoft.ReportingServices.ReportIntermediateFormat.DataSet dataSet = odpContext.ReportDefinition.MappingDataSetIndexToDataSet[m_lookupInfo.DataSetIndexInCollection];
            DataSetInstance dataSetInstance = odpContext.GetDataSetInstance(dataSet);

            if (dataSetInstance == null)
            {
                throw new ReportProcessingException_InvalidOperationException();
            }
            if (dataSetInstance.NoRows)
            {
                return(EmptyResult);
            }
            if (dataSetInstance.LookupResults == null || dataSetInstance.LookupResults[m_lookupInfo.DestinationIndexInCollection] == null)
            {
                if (!odpContext.CalculateLookup(m_lookupInfo))
                {
                    return(EmptyResult);
                }
                Global.Tracer.Assert(dataSetInstance.LookupResults != null, "Lookup not initialized correctly by tablix processing");
            }
            LookupObjResult lookupObjResult = dataSetInstance.LookupResults[m_lookupInfo.DestinationIndexInCollection];

            if (lookupObjResult.ErrorOccured)
            {
                IErrorContext reportRuntime = m_reportRuntime;
                if (lookupObjResult.DataFieldStatus == DataFieldStatus.None && lookupObjResult.ErrorCode != 0)
                {
                    reportRuntime.Register(lookupObjResult.ErrorCode, lookupObjResult.ErrorSeverity, lookupObjResult.ErrorMessageArgs);
                }
                else if (lookupObjResult.DataFieldStatus == DataFieldStatus.UnSupportedDataType)
                {
                    reportRuntime.Register(ProcessingErrorCode.rsLookupOfInvalidExpressionDataType, Severity.Warning, lookupObjResult.ErrorMessageArgs);
                }
                throw new ReportProcessingException_InvalidOperationException();
            }
            Microsoft.ReportingServices.RdlExpressions.VariantResult result = m_lookupInfo.EvaluateSourceExpr(m_reportRuntime);
            CheckExprResultError(result);
            bool           flag2                         = lookupObjResult.HasBeenTransferred || odpContext.CurrentDataSetIndex != dataSet.IndexInCollection;
            List <object>  list                          = null;
            CompareInfo    compareInfo                   = null;
            CompareOptions clrCompareOptions             = CompareOptions.None;
            bool           nullsAsBlanks                 = false;
            bool           useOrdinalStringKeyGeneration = false;

            try
            {
                if (flag2)
                {
                    compareInfo                   = odpContext.CompareInfo;
                    clrCompareOptions             = odpContext.ClrCompareOptions;
                    nullsAsBlanks                 = odpContext.NullsAsBlanks;
                    useOrdinalStringKeyGeneration = odpContext.UseOrdinalStringKeyGeneration;
                    dataSetInstance.SetupCollationSettings(odpContext);
                }
                LookupTable lookupTable = lookupObjResult.GetLookupTable(odpContext);
                Global.Tracer.Assert(lookupTable != null, "LookupTable must not be null");
                ObjectModelImpl reportObjectModel = odpContext.ReportObjectModel;
                Microsoft.ReportingServices.ReportIntermediateFormat.Persistence.ChunkManager.DataChunkReader dataChunkReader = null;
                if (flag2)
                {
                    dataChunkReader = odpContext.GetDataChunkReader(dataSet.IndexInCollection);
                }
                using (reportObjectModel.SetupNewFieldsWithBackup(dataSet, dataSetInstance, dataChunkReader))
                {
                    object[] array = result.Value as object[];
                    if (array == null)
                    {
                        array = new object[1]
                        {
                            result.Value
                        };
                    }
                    else
                    {
                        list = new List <object>(array.Length);
                    }
                    object[] array2 = array;
                    foreach (object key in array2)
                    {
                        if (lookupTable.TryGetValue(key, out LookupMatches matches))
                        {
                            int num = flag ? 1 : matches.MatchCount;
                            if (list == null)
                            {
                                list = new List <object>(num);
                            }
                            for (int j = 0; j < num; j++)
                            {
                                matches.SetupRow(j, odpContext);
                                Microsoft.ReportingServices.RdlExpressions.VariantResult result2 = m_lookupInfo.EvaluateResultExpr(m_reportRuntime);
                                CheckExprResultError(result2);
                                list.Add(result2.Value);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (compareInfo != null)
                {
                    odpContext.SetComparisonInformation(compareInfo, clrCompareOptions, nullsAsBlanks, useOrdinalStringKeyGeneration);
                }
            }
            object[] result3 = EmptyResult;
            if (list != null)
            {
                result3 = list.ToArray();
            }
            return(result3);
        }
 public HighlightRuleSet()
 {
     keyWords    = new LookupTable(false);
     prevMarkers = new LookupTable(false);
     nextMarkers = new LookupTable(false);
 }
            public override bool TryUpdatePosition(
                FontMetrics fontMetrics,
                GPosTable table,
                GlyphPositioningCollection collection,
                Tag feature,
                ushort index,
                int count)
            {
                // Implements Chained Contexts Substitution for Format 2:
                // https://docs.microsoft.com/en-us/typography/opentype/spec/gsub#62-chained-contexts-substitution-format-2-class-based-glyph-contexts
                ushort glyphId = collection[index][0];

                if (glyphId == 0)
                {
                    return(false);
                }

                // Search for the current glyph in the Coverage table.
                int offset = this.coverageTable.CoverageIndexOf(glyphId);

                if (offset <= -1)
                {
                    return(false);
                }

                // Search in the class definition table to find the class value assigned to the currently glyph.
                int classId = this.inputClassDefinitionTable.ClassIndexOf(glyphId);

                ChainedClassSequenceRuleTable[]? rules = classId >= 0 && classId < this.sequenceRuleSetTables.Length ? this.sequenceRuleSetTables[classId].SubRules : null;
                if (rules is null)
                {
                    return(false);
                }

                // Apply ruleset for the given glyph class id.
                SkippingGlyphIterator iterator = new(fontMetrics, collection, index, this.LookupFlags);

                for (int lookupIndex = 0; lookupIndex < rules.Length; lookupIndex++)
                {
                    ChainedClassSequenceRuleTable rule = rules[lookupIndex];
                    if (!AdvancedTypographicUtils.ApplyChainedClassSequenceRule(iterator, rule, this.inputClassDefinitionTable, this.backtrackClassDefinitionTable, this.lookaheadClassDefinitionTable))
                    {
                        continue;
                    }

                    // It's a match. Perform position update and return true if anything changed.
                    bool hasChanged = false;
                    for (int j = 0; j < rule.SequenceLookupRecords.Length; j++)
                    {
                        SequenceLookupRecord sequenceLookupRecord = rule.SequenceLookupRecords[j];
                        LookupTable          lookup = table.LookupList.LookupTables[sequenceLookupRecord.LookupListIndex];
                        ushort sequenceIndex        = sequenceLookupRecord.SequenceIndex;
                        if (lookup.TryUpdatePosition(fontMetrics, table, collection, feature, (ushort)(index + sequenceIndex), 1))
                        {
                            hasChanged = true;
                        }
                    }

                    return(hasChanged);
                }

                return(false);
            }
示例#36
0
 public static KnownCharacteristic Lookup(Guid id)
 {
     return(LookupTable.ContainsKey(id) ? LookupTable[id] : new KnownCharacteristic("Unknown characteristic", Guid.Empty));
 }
            public override bool TryUpdatePosition(
                FontMetrics fontMetrics,
                GPosTable table,
                GlyphPositioningCollection collection,
                Tag feature,
                ushort index,
                int count)
            {
                // Implements Chained Contexts Substitution, Format 1:
                // https://docs.microsoft.com/en-us/typography/opentype/spec/gsub#61-chained-contexts-substitution-format-1-simple-glyph-contexts
                ushort glyphId = collection[index][0];

                if (glyphId == 0)
                {
                    return(false);
                }

                // Search for the current glyph in the Coverage table.
                int offset = this.coverageTable.CoverageIndexOf(glyphId);

                if (offset <= -1)
                {
                    return(false);
                }

                if (this.seqRuleSetTables is null || this.seqRuleSetTables.Length is 0)
                {
                    return(false);
                }

                ChainedSequenceRuleSetTable seqRuleSet = this.seqRuleSetTables[offset];

                if (seqRuleSet is null)
                {
                    return(false);
                }

                // Apply ruleset for the given glyph id.
                ChainedSequenceRuleTable[] rules    = seqRuleSet.SequenceRuleTables;
                SkippingGlyphIterator      iterator = new(fontMetrics, collection, index, this.LookupFlags);

                for (int lookupIndex = 0; lookupIndex < rules.Length; lookupIndex++)
                {
                    ChainedSequenceRuleTable rule = rules[lookupIndex];
                    if (!AdvancedTypographicUtils.ApplyChainedSequenceRule(iterator, rule))
                    {
                        continue;
                    }

                    bool hasChanged = false;
                    for (int j = 0; j < rule.SequenceLookupRecords.Length; j++)
                    {
                        SequenceLookupRecord sequenceLookupRecord = rule.SequenceLookupRecords[j];
                        LookupTable          lookup = table.LookupList.LookupTables[sequenceLookupRecord.LookupListIndex];
                        ushort sequenceIndex        = sequenceLookupRecord.SequenceIndex;
                        if (lookup.TryUpdatePosition(fontMetrics, table, collection, feature, (ushort)(index + sequenceIndex), 1))
                        {
                            hasChanged = true;
                        }
                    }

                    return(hasChanged);
                }

                return(false);
            }
示例#38
0
        public static int Compute(LinearDecomposition decomposition)
        {
            Graph graph = decomposition.Graph;
            List<int> sequence = decomposition.Sequence;

            // Left is the set of vertices that have been processed so far.
            BitSet left = new BitSet(0, graph.Size);

            // Right is the set of vertices that we have yet to process, initially set to all vertices in the graph.
            BitSet right = graph.Vertices;

            // The leftneighborset contains ISN elements, that save the size of each independent set in Left, and the corresponding neighborhood in Right that belongs to this IS.
            LookupTable table = new LookupTable();

            // Insert the initial neighborhood and IS of size 0 and an empty neighborhood.
            table.Update(new Isn(new BitSet(0, graph.Size), 0));

            // maxIS saves the largest independent set that we have encountered so far.
            int maxIs = 0;

            // Loop over all vertices in the sequence; we have to process all of them.
            for (int i = 0; i < sequence.Count; i++)
            {
                // Take the next vertex in the sequence.
                int v = sequence[i];

                //Save all updated element in a new neighborset, so that we do not disturb any looping over elements.
                LookupTable newTable = new LookupTable();

                foreach (Isn iset in table)
                {
                    // If a neighborhood Right contains the currently selected element, then we have to remove it from the neighborhood.
                    // The corresponding IS in Left is still valid, but it simply belongs to a smaller neighborhood in Right (hence the removal of v).
                    if (iset.Elements.Contains(v))
                    {
                        iset.Elements -= v;
                        newTable.Update(iset);
                    }
                    // If the neighborhood does not contain v, then there are two cases that have to be handled.
                    else
                    {
                        // Case a: If v is not an element of the largest IS, then the previous IS is still valid.
                        // We have no risk of v being contained in the neighborhood of Right, because if that would be the case we would not be in the else-part of the if-statement.
                        // Thus, we simply add an unmodified copy of j to the new list of neighborhoodsets.
                        newTable.Update(iset);

                        // Case b: If v is an element of the largest IS, then we should include a new entry for this newly created IS.
                        // The size of this IS will increase by one (adding v will cause this).
                        // The neighborhood of this IS is the old neighborhood, plus any vertices in Right that are in the neighborhood of v. Vertex v causes the addition of these vertices.
                        // The largest saved IS might change because of this addition of a new erlement.
                        Isn newIset = new Isn(iset.Elements, iset.Size);
                        newIset.Size++;
                        newIset.Elements = newIset.Elements + (graph.OpenNeighborhood(v) * right);
                        maxIs = Math.Max(maxIs, newIset.Size);
                        newTable.Update(newIset);
                    }
                }

                // Safely update all sets that we are working with
                left += v;
                right -= v;
                table = newTable;

            }
            // The largest IS that we have encountered is the one we will return
            return maxIs;
        }
 private void UpdateProperty(LookupTable tbl, EnumProperty ep)
 {
     ep.SetValue(null);
     ep.LocalLookupTable = tbl;
     ep.FirePropertyChange(new PropertyChangeEventArgs(PropertyChange.Items, null, null));
 }