コード例 #1
0
ファイル: Project.cs プロジェクト: aamarber/Exceptionless
 public Project() {
     Configuration = new ClientConfiguration();
     NotificationSettings = new Dictionary<string, NotificationSettings>();
     PromotedTabs = new HashSet<string>();
     DeleteBotDataEnabled = true;
     Data = new DataDictionary();
 }
コード例 #2
0
 /// <summary>
 /// Creates a section for all the (implemented) collections of the given namespace
 /// </summary>
 /// <param name="aNameSpace">The namespace</param>
 /// <param name="addDetails">Add details or simply enumerate the collections</param>
 /// <returns></returns>
 public void CreateCollectionsSection(DataDictionary.Types.NameSpace aNameSpace, bool addDetails)
 {
     if (countDisplayedReqRelated(aNameSpace.Collections) > 0)
     {
         AddSubParagraph("Collections");
         foreach (DataDictionary.Types.Collection collection in aNameSpace.Collections)
         {
             if (collection.ImplementationPartiallyCompleted == true)
             {
                 if (addDetails)
                 {
                     AddSubParagraph(collection.Name);
                     AddTable(new string[] { "Collection " + collection.Name }, new int[] { 40, 100 });
                     if (collection.Comment != "")
                     {
                         AddRow(collection.Comment);
                     }
                     AddRow("Type", collection.getTypeName());
                     AddRow("Default value", collection.Default);
                     AddRow("Max size", collection.getMaxSize().ToString());
                     CreateStatusTable(collection);
                     CloseSubParagraph();
                 }
                 else
                 {
                     AddParagraph(collection.Name + " (" + GetRequirementsAsString(collection.Requirements) + ")");
                 }
             }
         }
         CloseSubParagraph();
     }
 }
コード例 #3
0
        /// <summary>
        /// Takes the control state of the provided context and from it produces
        /// a view state model that is used as the basis of the view-step render
        /// pipeline.
        /// </summary>
        /// <remarks>
        /// This is what you'd override if you wanted to govern your own model presented
        /// to your view layer.
        /// </remarks>
        /// <param name="ev">The event that gave rise to this action.</param>
        public override void Action(IEvent ev)
        {
            DataDictionary<IData> model = new DataDictionary<IData> {
                ["messages"] = ev.Context.Messages,
                ["errors"] = ev.Context.Errors,
                ["flags"] = ev.Context.Flags,
                ["timers"] = ev.Context.Timers,
                ["params"] = new DataDictionary<string>(ev.Context.Params.Where(param => !param.Key.StartsWith("_")))
            };

            // copy from the context

            // copy from the control state
            foreach (KeyValuePair<string, object> entry in ev.Context.State) {
                if (!entry.Key.StartsWith("_")) { // exclude "private" items
                    if (entry.Value is IData) {
                        model[entry.Key] = entry.Value as IData;
                    } else {
                        model[entry.Key] = new TextData(entry.Value.ToString());
                    }
                }
            }

            if (ev.Context.HasParams("model-item") && model.ContainsKey(ev.Context.Params["model-item"])) {
                ev.Context.ViewSteps.CreateStep("view-state", model[ev.Context.Params["model-item"]]);
            } else {
                ev.Context.ViewSteps.CreateStep("view-state", model);
            }
        }
コード例 #4
0
ファイル: Organization.cs プロジェクト: Nangal/Exceptionless
 public Organization() {
     Invites = new Collection<Invite>();
     BillingStatus = BillingStatus.Trialing;
     Usage = new Collection<UsageInfo>();
     OverageHours = new Collection<UsageInfo>();
     Data = new DataDictionary();
 }
コード例 #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="efsSystem">The system for which this frame is built</param>
 public TestReport(DataDictionary.EFSSystem efsSystem)
 {
     InitializeComponent();
     reportHandler = new TestsCoverageReportHandler((Dictionary)null);
     TxtB_Path.Text = reportHandler.FileName;
     EFSSystem = efsSystem;
 }
コード例 #6
0
        public void Get_NoItemAdded_ReturnsNull()
        {
            var dd = new DataDictionary ();

            string res = dd.Get ("foobar");
            Assert.IsNull (res);
        }
コード例 #7
0
        /// <summary>
        /// Provides the set of covered requirements by the tests
        /// </summary>
        /// <param name="aDictionary">The model</param>
        /// <returns></returns>
        public static HashSet<DataDictionary.Specification.Paragraph> CoveredRequirements(DataDictionary.Dictionary aDictionary)
        {
            HashSet<DataDictionary.Specification.Paragraph> retVal = new HashSet<DataDictionary.Specification.Paragraph>();
            ICollection<DataDictionary.Specification.Paragraph> applicableParagraphs = aDictionary.Specifications.ApplicableParagraphs;
            Dictionary<DataDictionary.Specification.Paragraph, List<DataDictionary.ReqRef>> paragraphsReqRefDictionary = aDictionary.ParagraphsReqRefs;

            foreach (DataDictionary.Specification.Paragraph paragraph in applicableParagraphs)
            {
                bool implemented = paragraph.getImplementationStatus() == DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented;
                bool tested = false;
                if (implemented)
                {
                    if (paragraphsReqRefDictionary.ContainsKey(paragraph))
                    {
                        List<DataDictionary.ReqRef> implementations = paragraphsReqRefDictionary[paragraph];
                        for (int i = 0; i < implementations.Count; i++)
                        {
                            DataDictionary.ReqRelated reqRelated = implementations[i].Enclosing as DataDictionary.ReqRelated;
                            if (reqRelated is TestCase && reqRelated.ImplementationCompleted == true)
                            {
                                tested = true;
                            }
                        }
                    }
                }

                if (implemented && tested)
                {
                    retVal.Add(paragraph);
                }
            }

            return retVal;
        }
コード例 #8
0
 /// <summary>
 /// Sets the explanation for this explain box
 /// </summary>
 /// <param name="explanation"></param>
 public void setExplanation(DataDictionary.Interpreter.ExplanationPart explanation)
 {
     explainTreeView.Nodes.Clear();
     ExplainTreeNode node = new ExplainTreeNode(explanation);
     innerSetExplanation(explanation, node, 0);
     explainTreeView.Nodes.Add(node);
 }
コード例 #9
0
ファイル: RestDataLayer.cs プロジェクト: iringtools/rest_dl
        public static string ToFilterExpression(this DataFilter dataFilter,DataDictionary dataDictionary, string objectName)
        {
            StringBuilder filterUrl = new StringBuilder();
            DataObject dataObject = null;

            try
            {
                dataObject = dataDictionary.dataObjects.Find(x => x.objectName.ToUpper() == objectName.ToUpper());
                if (dataObject == null)
                {
                    throw new Exception("Data object not found.");
                }

                if (dataFilter != null && dataFilter.Expressions != null && dataFilter.Expressions.Count > 0)
                {
                    foreach (Expression expression in dataFilter.Expressions)
                    {
                        if (filterUrl.Length <= 0) // To avoid adding logical operator at starting.
                        {
                            expression.LogicalOperator = org.iringtools.library.LogicalOperator.None;
                        }

                        string sqlExpression = ResolveFilterExpression(dataObject, expression);
                        filterUrl.Append(sqlExpression);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error generating filter url .", ex);
            }

            return filterUrl.ToString();
        }
コード例 #10
0
        /// <summary>
        /// Configures the filtering dialog
        /// </summary>
        /// <param name="efsSystem"></param>
        /// <param name="filterConfiguration"></param>
        public void Configure(DataDictionary.EFSSystem efsSystem, FilterConfiguration filterConfiguration)
        {
            ruleActivationCheckBox.Checked = filterConfiguration.RuleFired;
            expectationsCheckBox.Checked = filterConfiguration.Expect;
            variableUpdateCheckBox.Checked = filterConfiguration.VariableUpdate;

            List<DataDictionary.Dictionary> dictionaries = new List<DataDictionary.Dictionary>(efsSystem.Dictionaries);
            dictionaries.Sort(compare);
            foreach (DataDictionary.Dictionary dictionary in dictionaries)
            {
                NamableTreeNode dictionaryTreeNode = new NamableTreeNode(dictionary);
                nameSpaceTreeView.Nodes.Add(dictionaryTreeNode);

                List<DataDictionary.Types.NameSpace> nameSpaces = new List<DataDictionary.Types.NameSpace>();
                foreach (DataDictionary.Types.NameSpace nameSpace in dictionary.NameSpaces)
                {
                    nameSpaces.Add(nameSpace);
                }
                nameSpaces.Sort();

                foreach (DataDictionary.Types.NameSpace nameSpace in nameSpaces)
                {
                    GatherNamespaces(dictionaryTreeNode, nameSpace, filterConfiguration);
                }
            }

            regExpTextBox.Text = filterConfiguration.RegExp;
        }
コード例 #11
0
 /// <summary>
 /// Constructor (for function)
 /// </summary>
 /// <param name="item"></param>
 public ParametersTreeNode(DataDictionary.Functions.Function item)
     : base(item, "Parameters", true, false)
 {
     foreach (DataDictionary.Parameter parameter in item.FormalParameters)
     {
         Nodes.Add(new ParameterTreeNode(parameter));
     }
 }
コード例 #12
0
        /// <summary>
        /// Adds a new parameter
        /// </summary>
        /// <param name="function"></param>
        public ParameterTreeNode AddParameter(DataDictionary.Parameter parameter)
        {
            Item.appendParameters(parameter);
            ParameterTreeNode retVal = new ParameterTreeNode(parameter);
            Nodes.Add(retVal);

            return retVal;
        }
コード例 #13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="specification"></param>
 public Window(DataDictionary.Dictionary dictionary)
 {
     InitializeComponent();
     FormClosed += new FormClosedEventHandler(Window_FormClosed);
     Visible = false;
     Dictionary = dictionary;
     Refresh();
 }
コード例 #14
0
        public async Task AddManualStackSignatureData(string dataKey, string dataValue, bool willAddManualStackSignature) {
            var plugin = new ManualStackingPlugin();
            var data = new DataDictionary() { { dataKey, dataValue } };
            var context = new EventContext(new PersistentEvent { Data = data });

            await plugin.EventBatchProcessingAsync(new List<EventContext> { context });
            Assert.Equal(willAddManualStackSignature, context.StackSignatureData.Count > 0);
        }
コード例 #15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item"></param>
 /// <param name="name"></param>
 public CasesTreeNode(DataDictionary.Functions.Function item)
     : base(item, "Cases", true, false)
 {
     foreach (DataDictionary.Functions.Case aCase in item.Cases)
     {
         Nodes.Add(new CaseTreeNode(aCase));
     }
 }
コード例 #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item"></param>
 /// <param name="children"></param>
 public RulePreConditionsTreeNode(DataDictionary.Rules.RuleCondition item)
     : base(item, "Pre conditions", true, false)
 {
     foreach (DataDictionary.Rules.PreCondition preCondition in item.PreConditions)
     {
         Nodes.Add(new PreConditionTreeNode(preCondition));
     }
 }
コード例 #17
0
        /// <summary>
        /// Adds a rule in this set of sub rules
        /// </summary>
        /// <param name="rule"></param>
        public void AddRule(DataDictionary.Rules.Rule rule)
        {
            Item.appendSubRules(rule);
            Nodes.Add(new RuleTreeNode(rule));
            SortSubNodes();

            Item.setVerified(false);
        }
コード例 #18
0
 public void AddValue(DataDictionary.Constants.EnumValue value)
 {
     value.Name = "<EnumValue" + (GetNodeCount(false) + 1) + ">";
     value.setValue("");
     Item.appendValues(value);
     Nodes.Add(new EnumerationValueTreeNode(value));
     SortSubNodes();
 }
コード例 #19
0
        /// <summary>
        /// Adds a new case
        /// </summary>
        /// <param name="function"></param>
        public CaseTreeNode AddCase(DataDictionary.Functions.Case aCase)
        {
            Item.appendCases(aCase);
            CaseTreeNode retVal = new CaseTreeNode(aCase);
            Nodes.Add(retVal);

            return retVal;
        }
コード例 #20
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item"></param>
 /// <param name="children"></param>
 public PreConditionsTreeNode(DataDictionary.Functions.Case item)
     : base(item, "Pre condition", true)
 {
     foreach (DataDictionary.Rules.PreCondition preCondition in item.PreConditions)
     {
         Nodes.Add(new DataDictionaryView.PreConditionTreeNode(preCondition));
     }
 }
コード例 #21
0
ファイル: DataDictionaryTest.cs プロジェクト: vbatz258/manos
        public void Get_DifferentKeyAdded_ReturnsNull()
        {
            var dd = new DataDictionary ();

            dd.Set ("blizbar", "baz");

            string res = dd.Get ("foobar");
            Assert.IsNull (res);
        }
        /// <summary>
        /// Adds a namespace in the corresponding namespace
        /// </summary>
        /// <param name="nameSpace"></param>
        public NameSpaceTreeNode AddSubNameSpace(DataDictionary.Types.NameSpace nameSpace)
        {
            Item.appendNameSpaces(nameSpace);
            NameSpaceTreeNode retVal = new NameSpaceTreeNode(nameSpace);
            Nodes.Add(retVal);
            SortSubNodes();

            return retVal;
        }
コード例 #23
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item"></param>
 public SubRulesTreeNode(DataDictionary.Rules.RuleCondition item)
     : base(item, "Sub rules", true, false)
 {
     foreach (DataDictionary.Rules.Rule rule in item.SubRules)
     {
         Nodes.Add(new RuleTreeNode(rule));
     }
     SortSubNodes();
 }
コード例 #24
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item"></param>
 public EnumerationValuesTreeNode(DataDictionary.Types.Enum item)
     : base(item, "Values", true, false)
 {
     foreach (DataDictionary.Constants.EnumValue value in item.Values)
     {
         Nodes.Add(new EnumerationValueTreeNode(value));
     }
     SortSubNodes();
 }
コード例 #25
0
ファイル: Message.cs プロジェクト: baffled/quickfixn
 public Message(string msgstr, DataDictionary.DataDictionary sessionDataDictionary, DataDictionary.DataDictionary appDD, bool validate)
     : this()
 {
     FromStringHeader(msgstr);
     if(IsAdmin())
         FromString(msgstr, validate, sessionDataDictionary, sessionDataDictionary, null);
     else
         FromString(msgstr, validate, sessionDataDictionary, appDD, null);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item"></param>
 /// <param name="name"></param>
 public NameSpaceSubNameSpacesTreeNode(DataDictionary.Types.NameSpace item)
     : base(item, "Namespaces", true)
 {
     foreach (DataDictionary.Types.NameSpace nameSpace in item.SubNameSpaces)
     {
         Nodes.Add(new NameSpaceTreeNode(nameSpace));
     }
     SortSubNodes();
 }
コード例 #27
0
 /// <summary>
 /// Constructor: creates a report for the selected frame
 /// </summary>
 /// <param name="aFrame"></param>
 public TestReport(DataDictionary.Tests.Frame aFrame)
 {
     InitializeComponent();
     EFSSystem = aFrame.EFSSystem;
     reportHandler = new TestsCoverageReportHandler(aFrame.Dictionary);
     reportHandler.Frame = aFrame;
     InitializeCheckBoxes(1);
     TxtB_Path.Text = reportHandler.FileName;
 }
コード例 #28
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item"></param>
 public StructureElementsTreeNode(DataDictionary.Types.Structure item)
     : base(item, "Sub elements", true, false)
 {
     foreach (DataDictionary.Types.StructureElement structureElement in item.Elements)
     {
         Nodes.Add(new StructureElementTreeNode(structureElement));
     }
     SortSubNodes();
 }
コード例 #29
0
ファイル: DataDictionaryTest.cs プロジェクト: KevinT/manos
        public void Get_NameSetTwice_ReturnsSecondItem()
        {
            var dd = new DataDictionary ();

            dd.Set ("foobar", "blah");
            dd.Set ("foobar", "baz");

            string res = dd.Get ("foobar");
            Assert.AreEqual ("baz", res);
        }
コード例 #30
0
ファイル: DataDictionaryTest.cs プロジェクト: vbatz258/manos
        public void Get_EmptyChildrenAdded_ReturnsNull()
        {
            var dd = new DataDictionary ();

            dd.Children.Add (new DataDictionary ());
            dd.Children.Add (new DataDictionary ());

            string res = dd.Get ("foobar");
            Assert.IsNull (res);
        }
コード例 #31
0
        public void IsEmpty_WhenNotEmpty_IsFalse()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.IsFalse(dict.IsEmpty);
        }
コード例 #32
0
        public void Keys_ContainsAllKeys()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            CollectionAssert.AreEquivalent(InitialKeys, dict.Keys);
        }
コード例 #33
0
        public void TryRemove_OnNonExistingKey_ReturnsFalse()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.IsFalse(dict.TryRemove(InitialNonExistingKey, out _));
        }
コード例 #34
0
        public void Values_ContainsAllValues()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            CollectionAssert.AreEquivalent(InitialValues, dict.Values);
        }
コード例 #35
0
        public void TryAdd_OnExistingKey_ReturnsFalse()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.IsFalse(dict.TryAdd(InitialExistingKey, DifferentValueForInitialExistingKey));
        }
コード例 #36
0
        public void TryGetValue_OnExistingKey_ReturnsTrue()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.IsTrue(dict.TryGetValue(InitialExistingKey, out _));
        }
コード例 #37
0
        public void Count_WhenEmpty_IsZero()
        {
            var dict = new DataDictionary <string, string>();

            Assert.AreEqual(0, dict.Count);
        }
コード例 #38
0
        public void ICollection_IsReadOnly_ReturnsFalse()
        {
            ICollection <KeyValuePair <string, string> > dict = new DataDictionary <string, string>();

            Assert.IsFalse(dict.IsReadOnly);
        }
コード例 #39
0
        public void ConstructorWithCapacityCollectionAndComparer_AppliesComparer()
        {
            var dict = new DataDictionary <string, string>(10, InitialData, StringComparer.InvariantCultureIgnoreCase);

            Assert.IsTrue(dict.TryGetValue(InitialExistingKeyWithDifferentCasing, out _));
        }
コード例 #40
0
        public void GetOrAdd_OnNonExistingKeyAndNullValue_ReturnsNull()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.AreEqual(null, dict.GetOrAdd(InitialNonExistingKey, null));
        }
コード例 #41
0
        public void Remove_OnExistingKey_ReturnsTrue()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.IsTrue(dict.Remove(InitialExistingKey));
        }
コード例 #42
0
 public UserDescription()
 {
     Data = new DataDictionary();
 }
コード例 #43
0
        public void IsEmpty_WhenEmpty_IsTrue()
        {
            var dict = new DataDictionary <string, string>();

            Assert.IsTrue(dict.IsEmpty);
        }
コード例 #44
0
        public void IReadOnlyDictionary_Values_ContainsAllValues()
        {
            IReadOnlyDictionary <string, string> dict = new DataDictionary <string, string>(InitialData);

            CollectionAssert.AreEqual(InitialValues, dict.Values, StringComparer.Ordinal);
        }
コード例 #45
0
        public void Count_AfterAdd_HasCorrectValue()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.AreEqual(InitialCount, dict.Count);
        }
コード例 #46
0
        public void ConstructorWithCollection_CopiesNonNullValues()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.AreEqual(InitialCount, dict.Count);
        }
コード例 #47
0
        public void ConstructorWithCapacityCollectionAndComparer_DoesNotCopyNullValues()
        {
            var dict = new DataDictionary <string, string>(10, InitialData, StringComparer.InvariantCultureIgnoreCase);

            Assert.IsFalse(dict.TryGetValue(InitialKeyWithNullValue, out _));
        }
コード例 #48
0
        public void ConstructorWithCollection_DoesNotCopyNullValues()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.IsFalse(dict.TryGetValue(InitialKeyWithNullValue, out _));
        }
コード例 #49
0
        public void ConstructorWithCapacityCollectionAndComparer_CopiesNonNullValues()
        {
            var dict = new DataDictionary <string, string>(10, InitialData, StringComparer.OrdinalIgnoreCase);

            Assert.AreEqual(InitialCount, dict.Count);
        }
コード例 #50
0
        public void TryAdd_OnNonExistingKeyAndNullValue_ReturnsTrue()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.IsTrue(dict.TryAdd(InitialNonExistingKey, null));
        }
コード例 #51
0
        public void GetOrAdd_OnExistingKey_ReturnsExistingValue()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.AreEqual(InitialExistingValue, dict.GetOrAdd(InitialExistingKey, DifferentValueForInitialExistingKey));
        }
コード例 #52
0
        public void ContainsKey_OnNonExistingKey_ReturnsFalse()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.IsFalse(dict.ContainsKey(InitialNonExistingKey));
        }
コード例 #53
0
 public InnerError()
 {
     Data       = new DataDictionary();
     StackTrace = new StackFrameCollection();
 }
コード例 #54
0
        public void GetItem_OnNonExistingKey_ReturnsNull()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.IsNull(dict[InitialNonExistingKey]);
        }
コード例 #55
0
ファイル: SPPIDDataLayer.cs プロジェクト: iringtools/sp_pid
        private Response Refresh(XDocument configDoc, string tableName)
        {
            Response response = new Response();

            try
            {
                _dataDictionary = new library.DataDictionary();

                XElement   config = configDoc.Element("configuration");
                SQLBuilder sqlBuilder;

                //
                // Parse project assignments
                //
                Dictionary <string, string> projectAssignments    = new Dictionary <string, string>();
                IEnumerable <XElement>      projectAssignmentElts = config.Element("assignments").Elements("assignment");

                if (projectAssignmentElts != null && projectAssignmentElts.Count() > 0)
                {
                    foreach (XElement assignment in projectAssignmentElts)
                    {
                        string name  = assignment.Attribute("name").Value;
                        string value = assignment.Attribute("value").Value;

                        if (name.StartsWith("@") && value.Length > 0)
                        {
                            projectAssignments[name] = value;
                        }
                    }
                }

                //
                // Parse project text replacements
                //
                Dictionary <string, string> projectReplacements    = new Dictionary <string, string>();
                IEnumerable <XElement>      projectReplacementElts = config.Element("replacements").Elements("replacement");

                if (projectReplacementElts != null && projectReplacementElts.Count() > 0)
                {
                    foreach (XElement replacement in projectReplacementElts)
                    {
                        string placeHolder = replacement.Attribute("placeHolder").Value;
                        string name        = replacement.Attribute("name").Value;
                        string value       = replacement.Attribute("value").Value;

                        if (placeHolder == string.Empty || name == string.Empty || value == string.Empty)
                        {
                            continue;
                        }

                        projectReplacements[placeHolder[0] + name + placeHolder[1]] = value;
                    }
                }

                //
                // Get query elements
                //
                IEnumerable <XElement> queryElts = config.Elements("query");

                DBType    siteDbType       = Utility.GetDBType(_siteConnStr);
                DataTable siteSchemaResult = DBManager.Instance.ExecuteQuery(_siteConnStr, Constants.ORACLE_GET_CURRENT_SCHEMA);
                string    siteSchema       = siteSchemaResult.Rows[0][0].ToString();

                //
                // Process !SiteData query
                //
                XElement siteQueryElt = (from query in queryElts
                                         where query.Attribute("name").Value == Constants.SITE_DATA_QUERY
                                         select query).First();

                Dictionary <string, string> siteSchemaMap = new Dictionary <string, string>();
                siteSchemaMap["SITE"] = siteSchema;

                sqlBuilder = new SQLBuilder(siteDbType, siteQueryElt, siteSchemaMap, projectAssignments, projectReplacements);
                string    siteSelectQuery = sqlBuilder.Build(SQLCommand.SELECT);
                DataTable siteInfo        = DBManager.Instance.ExecuteQuery(_siteConnStr, siteSelectQuery);

                //
                // Get actual schemas from !SiteData query
                //
                Dictionary <string, string> schemaMap = new Dictionary <string, string>();

                if (siteInfo != null && siteInfo.Rows.Count > 0)
                {
                    foreach (DataRow row in siteInfo.Rows)
                    {
                        schemaMap[row["SP_SCHEMA_TYPE"].ToString()] = row["USERNAME"].ToString();
                    }
                }

                //
                // Process other queries
                //
                if (string.IsNullOrEmpty(tableName))
                {
                    queryElts = from query in queryElts
                                where query.Attribute("name").Value != Constants.TEMPLATE_QUERY && query.Attribute("name").Value != Constants.SITE_DATA_QUERY
                                select query;
                }
                else
                {
                    queryElts = from query in queryElts
                                where query.Attribute("name").Value != Constants.TEMPLATE_QUERY && query.Attribute("name").Value != Constants.SITE_DATA_QUERY && query.Attribute("destination").Value.ToUpper() == tableName.ToUpper()
                                select query;
                }

                DBType stagingDbType = Utility.GetDBType(_stagingConnStr);

                //   NOTE - although it is possible to make use of an INTO clause to create a selection query that will
                //   also automatically create the destination table, this has limitations, the most serious of which is
                //   it is not safe to assume that the Source DB and Staging DB have the same security requirements. Instead,
                //   we will always assume that security is separate for these two databases and that the connection strings for the
                //   Source and Staging connections provide this information for each individual location. We also cannot assume that
                //   the specified credentials have the power to create a Linked Server connection or that both SQL Server instances
                //   allow ad hoc (OpenDataSource) queries. Instead, the provided credentials are used to copy the data to the
                //   local machine and then bulk copied out to the staging server, bypassing the need for a more sophisticated security
                //   check/edit)

                DBType plantDbType = Utility.GetDBType(_plantSchemaConnStr);

                if (plantDbType == DBType.ORACLE)
                {
                    string plantDictConnStr = _settings[Constants.SPPID_PLANT_DICTIONARY];
                    if (Utility.IsBase64Encoded(plantDictConnStr))
                    {
                        plantDictConnStr = EncryptionUtility.Decrypt(plantDictConnStr);
                    }

                    string pidSchemaConnStr = _settings[Constants.SPPID_PID_SCHEMA];
                    if (Utility.IsBase64Encoded(pidSchemaConnStr))
                    {
                        pidSchemaConnStr = EncryptionUtility.Decrypt(pidSchemaConnStr);
                    }

                    string pidDictConnStr = _settings[Constants.SPPID_PID_DICTIONARY];
                    if (Utility.IsBase64Encoded(pidDictConnStr))
                    {
                        pidDictConnStr = EncryptionUtility.Decrypt(pidDictConnStr);
                    }

                    _workingSet = new WorkingSet(_plantSchemaConnStr, plantDictConnStr, pidSchemaConnStr, pidDictConnStr);
                }
                else if (plantDbType == DBType.SQLServer)
                {
                    _workingSet = new WorkingSet(_plantSchemaConnStr);
                }
                else
                {
                    throw new Exception("SPPID DB type not supported.");
                }

                _workingSet.GrantPrivilege("SELECT");

                foreach (XElement queryElt in queryElts)
                {
                    sqlBuilder = new SQLBuilder(stagingDbType, queryElt, schemaMap, projectAssignments, projectReplacements, true);

                    response.StatusList.Add(new Status()
                    {
                        Messages = new Messages()
                        {
                            "Query [" + queryElt.Attribute("name").Value + "] processed."
                        }
                    });

                    //
                    // Delete existing staging table
                    //
                    string stagingTableName = queryElt.Attribute("destination").Value;
                    string deleteQuery      = string.Format(Constants.SQLSERVER_DELETE_TEMPLATE, stagingTableName);
                    DBManager.Instance.ExecuteNonQuery(_stagingConnStr, deleteQuery);

                    //
                    // Create new staging table
                    //
                    string createQuery = sqlBuilder.Build(SQLCommand.CREATE);
                    DBManager.Instance.ExecuteNonQuery(_stagingConnStr, createQuery);

                    response.StatusList.Add(new Status()
                    {
                        Messages = new Messages()
                        {
                            "Staging table [" + stagingTableName + "] created."
                        }
                    });

                    //
                    // Fetch data
                    //
                    string    selectQuery = sqlBuilder.Build(SQLCommand.SELECT);
                    DataTable result      = DBManager.Instance.ExecuteQuery(_plantSchemaConnStr, selectQuery);

                    response.StatusList.Add(new Status()
                    {
                        Messages = new Messages()
                        {
                            "New data fetched."
                        }
                    });

                    //
                    // Bulk copy data to staging table
                    //
                    SqlBulkCopy bulkCopy = new SqlBulkCopy(_stagingConnStr);
                    bulkCopy.DestinationTableName = stagingTableName;
                    bulkCopy.WriteToServer(result);

                    response.StatusList.Add(new Status()
                    {
                        Messages = new Messages()
                        {
                            "Data copied to staging table."
                        }
                    });

                    //
                    // Add to data dictionary
                    //
                    DataObject objDef = new DataObject()
                    {
                        tableName       = stagingTableName,
                        objectNamespace = "SPPID",
                        objectName      = stagingTableName
                    };

                    foreach (var pair in sqlBuilder.Keys)
                    {
                        objDef.keyProperties.Add(new KeyProperty()
                        {
                            keyPropertyName = pair.Key
                        });
                    }

                    foreach (DBField field in sqlBuilder.Fields)
                    {
                        DataProperty dataProperty = new DataProperty()
                        {
                            propertyName = field.Name,
                            columnName   = field.Name,
                            dataType     = Utility.ResolveDataType(field.DataType),
                            isNullable   = field.Nullable,
                        };

                        if (sqlBuilder.Keys.ContainsKey(field.Name))
                        {
                            dataProperty.keyType = (sqlBuilder.Keys[field.Name] == KeyType.AUTO)
                ? library.KeyType.unassigned : library.KeyType.assigned;
                        }

                        objDef.dataProperties.Add(dataProperty);
                    }

                    _dataDictionary.dataObjects.Add(objDef);
                }

                _workingSet.RevokePrivilege("SELECT");
            }
            catch (Exception ex)
            {
                string error = "Error refreshing [" + tableName + "]: " + ex.Message;

                response.Level    = StatusLevel.Error;
                response.Messages = new Messages()
                {
                    error
                };
                _logger.Error(error);
            }

            return(response);
        }
コード例 #56
0
        public void GetItem_OnExistingKey_ReturnsCorrectValue()
        {
            var dict = new DataDictionary <string, string>(InitialData);

            Assert.AreEqual(InitialExistingValue, dict[InitialExistingKey]);
        }
コード例 #57
0
 protected override void OnEnable()
 {
     base.OnEnable();
     this.Dictionary.ValueChanged += this.OnDictionaryChanged;
     this.DataDictionary           = this.Dictionary.GetValue <DataDictionary>();
 }
コード例 #58
0
        public void DefaultConstructor_CreatesEmptyDictionary()
        {
            var dict = new DataDictionary <string, string>();

            Assert.AreEqual(0, dict.Count);
        }
コード例 #59
0
 public EntityChanged()
 {
     Data = new DataDictionary();
 }
コード例 #60
0
ファイル: ManosBrowser.cs プロジェクト: stangelandcl/manos
 public With(MockHttpRequest request, DataDictionary dict)
 {
     _request = request;
     _dict    = dict;
 }