public void Equals_should_return_false_if_value_is_no_identical_on_instance_being_compared_against()
        {
            var instance =
                new MetadataItem("Foo", new object());

            var results =
                instance.Equals(new MetadataItem("Foo", string.Empty));

            results.ShouldBeFalse();
        }
Beispiel #2
0
 private static void AddChildren(MetadataItem model, PageViewModel result)
 {
     if (model.Items != null && model.Items.Count > 0)
     {
         foreach (var item in model.Items)
         {
             result.Items.Add(ItemViewModel.FromModel(item));
             AddChildren(item, result);
         }
     }
 }
        public void AddMetadata_should_add_metadata_to_convention()
        {
            this.conventionBuilder
                .AddMetadata("Foo", "Bar");

            var convention =
                this.conventionBuilder.GetBuiltInstance();

            var expectedMetadata =
                new MetadataItem("Foo", "Bar");

            convention.Metadata.First().Equals(expectedMetadata).ShouldBeTrue();
        }
        public void AddMetadata_should_set_metadata_on_convention_from_anonymous_type()
        {
            this.conventionBuilder
                .AddMetadata(new {Foo = "Bar"});

            var convention =
                this.conventionBuilder.GetBuiltInstance();

            var expectedMetadata =
                new MetadataItem("Foo", "Bar");

            convention.Metadata.First().Equals(expectedMetadata).ShouldBeTrue();
        }
Beispiel #5
0
        private static ParseResult TryExportYamlMetadataFile(MetadataItem doc, string folder, UriKind uriKind, out string filePath)
        {
            filePath = Path.Combine(folder, doc.Name).FormatPath(uriKind, folder);

            try
            {
                using (StreamWriter writer = new StreamWriter(filePath))
                {
                    YamlUtility.Serialize(writer, doc);
                    return(new ParseResult(ResultLevel.Success, "Successfully generated metadata {0} for {1}", filePath, doc.Name));
                }
            }
            catch (Exception e)
            {
                return(new ParseResult(ResultLevel.Error, e.Message));
            }
        }
Beispiel #6
0
        private MetadataItem createMetadataItem()
        {
            MetadataItem meta = new MetadataItem();

            meta.Benutzer        = _benutzer;
            meta.Bezeichnung     = _bezeichnung;
            meta.Erfassungsdatum = _erfassungsdatum;
            meta.Extension       = _extension;
            meta.Filename        = _filename;
            meta.OriginalPath    = _filePath;
            meta.SelectedTypItem = _selectedTypItem;
            meta.ValutaDatum     = _valutaDatum;
            var temp = _valutaDatum.GetValueOrDefault();

            meta.ValutaYear = temp.Year.ToString();
            return(meta);
        }
Beispiel #7
0
        /// <summary>
        /// Syncs the collections on a bound PSCloudJobSchedule with its wrapped OM object
        /// </summary>
        internal static void BoundJobScheduleSyncCollections(PSCloudJobSchedule jobSchedule)
        {
            if (jobSchedule != null)
            {
                jobSchedule.omObject.Metadata = CreateSyncedList(jobSchedule.Metadata,
                                                                 (m) =>
                {
                    MetadataItem metadata = new MetadataItem(m.Name, m.Value);
                    return(metadata);
                });

                if (jobSchedule.JobSpecification != null)
                {
                    JobSpecificationSyncCollections(jobSchedule.JobSpecification);
                }
            }
        }
        public void CloudJobSchedule_WhenReturnedFromServer_HasExpectedBoundProperties()
        {
            const string jobScheduleId = "id-123";
            const string displayName   = "DisplayNameFoo";
            MetadataItem metadataItem  = new MetadataItem("foo", "bar");

            using BatchClient client = ClientUnitTestCommon.CreateDummyClient();
            DateTime creationTime = DateTime.Now;

            var cloudJobSchedule = new Models.CloudJobSchedule
            {
                Id          = jobScheduleId,
                DisplayName = displayName,
                Metadata    = new[]
                {
                    new Models.MetadataItem {
                        Name = metadataItem.Name, Value = metadataItem.Value
                    }
                },
                CreationTime     = creationTime,
                JobSpecification = new Models.JobSpecification
                {
                    OnAllTasksComplete = Models.OnAllTasksComplete.TerminateJob,
                    OnTaskFailure      = Models.OnTaskFailure.PerformExitOptionsJobAction
                }
            };

            CloudJobSchedule boundJobSchedule = client.JobScheduleOperations.GetJobSchedule(
                jobScheduleId,
                additionalBehaviors: InterceptorFactory.CreateGetJobScheduleRequestInterceptor(cloudJobSchedule));

            Assert.Equal(jobScheduleId, boundJobSchedule.Id); // reading is allowed from a jobSchedule that is returned from the server.
            Assert.Equal(creationTime, boundJobSchedule.CreationTime);
            Assert.Equal(displayName, boundJobSchedule.DisplayName);
            Assert.Equal(OnAllTasksComplete.TerminateJob, boundJobSchedule.JobSpecification.OnAllTasksComplete);
            Assert.Equal(OnTaskFailure.PerformExitOptionsJobAction, boundJobSchedule.JobSpecification.OnTaskFailure);

            Assert.Throws <InvalidOperationException>(() => boundJobSchedule.DisplayName = "cannot-change-display-name");
            Assert.Throws <InvalidOperationException>(() => boundJobSchedule.Id          = "cannot-change-id");

            boundJobSchedule.JobSpecification.OnAllTasksComplete = OnAllTasksComplete.TerminateJob;
            boundJobSchedule.JobSpecification.OnTaskFailure      = OnTaskFailure.NoAction;

            Assert.Equal(OnAllTasksComplete.TerminateJob, boundJobSchedule.JobSpecification.OnAllTasksComplete);
            Assert.Equal(OnTaskFailure.NoAction, boundJobSchedule.JobSpecification.OnTaskFailure);
        }
        public void CloudJobSchedule_WhenSendingToTheServer_HasExpectedUnboundProperties()
        {
            const string jobScheduleId = "id-123";
            const string displayName   = "DisplayNameFoo";
            MetadataItem metadataItem  = new MetadataItem("foo", "bar");

            using BatchClient client = ClientUnitTestCommon.CreateDummyClient();
            CloudJobSchedule jobSchedule = client.JobScheduleOperations.CreateJobSchedule();

            jobSchedule.Id          = jobScheduleId;
            jobSchedule.DisplayName = displayName;
            jobSchedule.Metadata    = new List <MetadataItem> {
                metadataItem
            };
            jobSchedule.JobSpecification = new JobSpecification
            {
                OnAllTasksComplete = OnAllTasksComplete.TerminateJob,
                OnTaskFailure      = OnTaskFailure.PerformExitOptionsJobAction
            };

            Assert.Equal(jobSchedule.Id, jobScheduleId); // can set an unbound object
            Assert.Equal(jobSchedule.Metadata.First().Name, metadataItem.Name);
            Assert.Equal(jobSchedule.Metadata.First().Value, metadataItem.Value);
            Assert.Equal(OnAllTasksComplete.TerminateJob, jobSchedule.JobSpecification.OnAllTasksComplete);
            Assert.Equal(OnTaskFailure.PerformExitOptionsJobAction, jobSchedule.JobSpecification.OnTaskFailure);

            jobSchedule.Commit(additionalBehaviors: InterceptorFactory.CreateAddJobScheduleRequestInterceptor());

            // writing isn't allowed for a jobSchedule that is in an read only state.
            Assert.Throws <InvalidOperationException>(() => jobSchedule.Id          = "cannot-change-id");
            Assert.Throws <InvalidOperationException>(() => jobSchedule.DisplayName = "cannot-change-display-name");

            //Can still read though
            Assert.Equal(jobScheduleId, jobSchedule.Id);
            Assert.Equal(displayName, jobSchedule.DisplayName);

            jobSchedule.Refresh(additionalBehaviors:
                                InterceptorFactory.CreateGetJobScheduleRequestInterceptor(
                                    new Models.CloudJobSchedule()
            {
                JobSpecification = new Models.JobSpecification()
            }));

            jobSchedule.JobSpecification.OnAllTasksComplete = OnAllTasksComplete.NoAction;
            jobSchedule.JobSpecification.OnTaskFailure      = OnTaskFailure.NoAction;
        }
Beispiel #10
0
        protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
        {
            MetadataItem annotation = (MetadataItem)item;

            bool isValueJson = true;

            try
            {
                JObject.Parse(annotation.Value);
            }
            catch (JsonReaderException)
            {
                isValueJson = false;
            }

            return(isValueJson ? this.Popup : this.Basic);
        }
Beispiel #11
0
        public async Task <IEnumerable <MetadataItem> > RetreiveMetadata(string addToQueueMessage)
        {
            var result = await _metadataProviderFactory.GetProvider().GetMetadata();

            var metadataItems = new List <MetadataItem>();

            foreach (var comicItem in result)
            {
                var item = new MetadataItem()
                {
                    emailTo = addToQueueMessage, comicItem = comicItem
                };
                metadataItems.Add(item);
            }

            return(metadataItems);
        }
Beispiel #12
0
        public void MetadataItemConstructor_SetsPropertiesCorrectly()
        {
            // Act
            var metadataItem = new MetadataItem(id: 1,
                                                movieId: 2,
                                                title: "Test",
                                                language: "AnotherTest",
                                                duration: TimeSpan.Parse("10:10:10"),
                                                releaseYear: 2019);

            // Assert
            Assert.AreEqual(metadataItem.Id, 1);
            Assert.AreEqual(metadataItem.MovieId, 2);
            Assert.AreEqual(metadataItem.Title, "Test");
            Assert.AreEqual(metadataItem.Duration, TimeSpan.Parse("10:10:10"));
            Assert.AreEqual(metadataItem.ReleaseYear, 2019);
        }
Beispiel #13
0
 public bool SaveXml(string destPath, string guid, IGetFileName getName, IMessage mb, ISerializer ser)
 {
     if (!IsFileSelected())
     {
         mb.ShowMessage("Keine Datei ausgewählt!");
         return(false);
     }
     if (AreRequiredFieldsValid())
     {
         var newItem  = new MetadataItem(guid, Bezeichnung, (DateTime)ValutaDatum, SelectedTypItem, Stichwoerter, Erfassungsdatum, Benutzer);
         var fileName = getName.GetMetadataName(destPath, guid);
         ser.SerializeFile(newItem, fileName);
         return(true);
     }
     mb.ShowMessage("Es müssen alle Pflichtfelder ausgefüllt werden!");
     return(false);
 }
Beispiel #14
0
        } // createQueryBuilder(...)

        //
        internal void buildBindingList(bool loadDefaultDatabaseOnly, bool loadSystemObjects, bool withFields)
        {
            this._colQnBindingList = new BindingList <ColumnQN>();
            using (SQLContext sqlContext = new SQLContext())
            {
                sqlContext.Assign(this._qb.SQLContext);
                sqlContext.MetadataContainer.LoadingOptions.LoadDefaultDatabaseOnly = loadDefaultDatabaseOnly;
                sqlContext.MetadataContainer.LoadingOptions.LoadSystemObjects       = loadSystemObjects;

                using (MetadataList xList = new MetadataList(sqlContext.MetadataContainer))
                {
                    xList.Load(MetadataType.Server, false);
                    foreach (MetadataItem srv in xList)
                    {
                    }
                    xList.Load(MetadataType.Database, false);
                    foreach (MetadataItem db in xList)
                    {
                        using (MetadataList schemasList = new MetadataList(db))
                        {
                            schemasList.Load(MetadataType.Schema, false);
                            foreach (MetadataItem sch in schemasList)
                            {
                                using (MetadataList tablesList = new MetadataList(sch))
                                {
                                    tablesList.Load(MetadataType.Table, false);
                                    foreach (MetadataItem tbl in tablesList)
                                    {
                                        using (MetadataList columnsList = new MetadataList(tbl))
                                        {
                                            columnsList.Load(MetadataType.Field, false);

                                            foreach (MetadataItem col in columnsList)
                                            {
                                                MetadataItem mdi = col;
                                                this.TreatField(mdi);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } // buildBindingList(...)
Beispiel #15
0
        /// <summary>
        /// Syncs the collections on a bound PSCloudJob with its wrapped OM object
        /// </summary>
        internal static void BoundJobSyncCollections(PSCloudJob job)
        {
            if (job != null)
            {
                job.omObject.Metadata = CreateSyncedList(job.Metadata,
                                                         (m) =>
                {
                    MetadataItem metadata = new MetadataItem(m.Name, m.Value);
                    return(metadata);
                });

                if (job.PoolInformation != null)
                {
                    PoolInformationSyncCollections(job.PoolInformation);
                }
            }
        }
        public void CreateXml_IsFileCreated_FileExists()
        {
            // arrange
            var exportService = new ExportService();
            var TestItem      = new MetadataItem(Guid.Parse("3fc6a223-369b-4efd-a0c4-f563ee6d67f8"), "Username",
                                                 "Dokumenten Bezeichnung", DateTime.Parse("01.01.2020 19:00:00"), "Verträge", "Notiz",
                                                 DateTime.Parse("30.06.2020 00:00:00"), "document.docx");

            // act
            var result      = exportService.CreateXml(TestItem);
            var IsFileExist =
                File.Exists(
                    "C:\\Temp\\UnitTestingOfPhilipp\\Repository\\2020\\3fc6a223-369b-4efd-a0c4-f563ee6d67f8_Metadata.xml");

            // assert
            Assert.That(IsFileExist, Is.EqualTo(true));
        }
        public void Pool_WhenReturnedFromServer_HasExpectedUnboundProperties()
        {
            const string cloudPoolId          = "id-123";
            const string osFamily             = "2";
            const string virtualMachineSize   = "4";
            const string cloudPoolDisplayName = "pool-display-name-test";
            MetadataItem metadataItem         = new MetadataItem("foo", "bar");

            BatchSharedKeyCredentials credentials = ClientUnitTestCommon.CreateDummySharedKeyCredential();

            using (BatchClient client = BatchClient.Open(credentials))
            {
                CloudPool cloudPool = client.PoolOperations.CreatePool(cloudPoolId, virtualMachineSize, new CloudServiceConfiguration(osFamily));
                cloudPool.DisplayName = cloudPoolDisplayName;
                cloudPool.Metadata    = new List <MetadataItem> {
                    metadataItem
                };

                Assert.Equal(cloudPoolId, cloudPool.Id); // can set an unbound object
                Assert.Equal(cloudPool.Metadata.First().Name, metadataItem.Name);
                Assert.Equal(cloudPool.Metadata.First().Value, metadataItem.Value);

                cloudPool.Commit(additionalBehaviors: InterceptorFactory.CreateAddPoolRequestInterceptor());

                // writing isn't allowed for a cloudPool that is in an readonly state.
                Assert.Throws <InvalidOperationException>(() => cloudPool.AutoScaleFormula          = "Foo");
                Assert.Throws <InvalidOperationException>(() => cloudPool.DisplayName               = "Foo");
                Assert.Throws <InvalidOperationException>(() => cloudPool.CloudServiceConfiguration = null);
                Assert.Throws <InvalidOperationException>(() => cloudPool.ResizeTimeout             = TimeSpan.FromSeconds(10));
                Assert.Throws <InvalidOperationException>(() => cloudPool.Metadata                    = null);
                Assert.Throws <InvalidOperationException>(() => cloudPool.TargetDedicated             = 5);
                Assert.Throws <InvalidOperationException>(() => cloudPool.VirtualMachineConfiguration = null);
                Assert.Throws <InvalidOperationException>(() => cloudPool.VirtualMachineSize          = "small");

                //read is allowed though
                Assert.Null(cloudPool.AutoScaleFormula);
                Assert.Equal(cloudPoolDisplayName, cloudPool.DisplayName);
                Assert.NotNull(cloudPool.CloudServiceConfiguration);
                Assert.Null(cloudPool.ResizeTimeout);
                Assert.Equal(1, cloudPool.Metadata.Count);
                Assert.Null(cloudPool.TargetDedicated);
                Assert.Null(cloudPool.VirtualMachineConfiguration);
                Assert.Equal(virtualMachineSize, cloudPool.VirtualMachineSize);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Creates a new WorkItem
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the WorkItem</param>
        public void CreateWorkItem(NewWorkItemParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            if (string.IsNullOrWhiteSpace(parameters.WorkItemName))
            {
                throw new ArgumentNullException("WorkItemName");
            }

            using (IWorkItemManager wiManager = parameters.Context.BatchOMClient.OpenWorkItemManager())
            {
                ICloudWorkItem workItem = wiManager.CreateWorkItem(parameters.WorkItemName);

                if (parameters.Schedule != null)
                {
                    workItem.Schedule = parameters.Schedule.omObject;
                }

                if (parameters.JobSpecification != null)
                {
                    Utils.Utils.JobSpecificationSyncCollections(parameters.JobSpecification);
                    workItem.JobSpecification = parameters.JobSpecification.omObject;
                }

                if (parameters.JobExecutionEnvironment != null)
                {
                    Utils.Utils.JobExecutionEnvironmentSyncCollections(parameters.JobExecutionEnvironment);
                    workItem.JobExecutionEnvironment = parameters.JobExecutionEnvironment.omObject;
                }

                if (parameters.Metadata != null)
                {
                    workItem.Metadata = new List <IMetadataItem>();
                    foreach (DictionaryEntry d in parameters.Metadata)
                    {
                        MetadataItem metadata = new MetadataItem(d.Key.ToString(), d.Value.ToString());
                        workItem.Metadata.Add(metadata);
                    }
                }
                WriteVerbose(string.Format(Resources.NBWI_CreatingWorkItem, parameters.WorkItemName));
                workItem.Commit(parameters.AdditionalBehaviors);
            }
        }
        public void MetadataItem_FilePath_GetSetTestingText()
        {
            // Arrange
            var metadataItem = new MetadataItem(_testDateTime, TestType)
            {
                FilePath = TestFilePath
            };

            // Act
            var filePath   = metadataItem.FilePath;
            var valutaDate = metadataItem.ValueDate;
            var type       = metadataItem.Type;

            // Assert
            Assert.That(filePath, Is.EqualTo(TestFilePath));
            Assert.That(valutaDate, Is.EqualTo(_testDateTime));
            Assert.That(type, Is.EqualTo(TestType));
        }
Beispiel #20
0
        protected void rptrPlatforms_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                MetadataItem platform = (MetadataItem)e.Item.DataItem;

                Literal litPlatform = e.FindControlAs <Literal>("litPlatform");

                if (e.Item.ItemIndex == 0)
                {
                    litPlatform.Text = platform.ContentTitle.Raw;
                }
                else
                {
                    litPlatform.Text = ", " + platform.ContentTitle.Raw;
                }
            }
        }
        public void MetadateItem_Erfassungsdatum_GetTestDateTime()
        {
            // Arrange
            var metadataItem = new MetadataItem(_testDateTime, TestType)
            {
                DateOfCreation = _testDateTime
            };

            // Act
            var creationDate = metadataItem.DateOfCreation;
            var type         = metadataItem.Type;
            var valutaDate   = metadataItem.ValueDate;

            // Assert
            Assert.That(creationDate, Is.EqualTo(_testDateTime));
            Assert.That(valutaDate, Is.EqualTo(_testDateTime));
            Assert.That(type, Is.EqualTo(TestType));
        }
        public void MetadataItem_SetIsRemoveFileEnabled_GetTrue()
        {
            // Arrange
            var metadataItem = new MetadataItem(_testDateTime, TestType)
            {
                IsRemoveFileEnabled = true
            };

            // Act
            var isRemoveEnabled = metadataItem.IsRemoveFileEnabled;
            var valutaDate      = metadataItem.ValueDate;
            var type            = metadataItem.Type;

            // Assert
            Assert.That(isRemoveEnabled, Is.True);
            Assert.That(valutaDate, Is.EqualTo(_testDateTime));
            Assert.That(type, Is.EqualTo(TestType));
        }
        public void MetadataItem_Bezeichnung_GetSetTestingText()
        {
            // Arrange
            var metadataItem = new MetadataItem(_testDateTime, TestType)
            {
                Description = TestDescription
            };

            // Act
            var name       = metadataItem.Description;
            var valutaDate = metadataItem.ValueDate;
            var type       = metadataItem.Type;

            // Assert
            Assert.That(name, Is.EqualTo(TestDescription));
            Assert.That(valutaDate, Is.EqualTo(_testDateTime));
            Assert.That(type, Is.EqualTo(TestType));
        }
        public void MetadataItem_Benutzer_GetSetTestingText()
        {
            // Arrange
            var metadataItem = new MetadataItem(_testDateTime, TestType)
            {
                UserName = TestUserName
            };

            // Act
            var username   = metadataItem.UserName;
            var valutaDate = metadataItem.ValueDate;
            var type       = metadataItem.Type;

            // Arrange
            Assert.That(username, Is.EqualTo(TestUserName));
            Assert.That(valutaDate, Is.EqualTo(_testDateTime));
            Assert.That(type, Is.EqualTo(TestType));
        }
        public void XmlService_Deserialize_MetadataItem()
        {
            // Arrange
            var          xmlService  = new XmlService();
            var          fs          = File.Create("text.txt");
            const string expectedXml = "<?xml version=\"1.0\" encoding=\"utf-16\"?><MetadataItem xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Stichwoerter /><Erfassungsdatum>0001-01-01T00:00:00</Erfassungsdatum><IsRemoveFileEnabled>false</IsRemoveFileEnabled><Type>Test</Type><ValutaDatum>0001-01-01T00:00:00</ValutaDatum></MetadataItem>";

            fs.Close();
            File.WriteAllText(fs.Name, expectedXml);

            // Act
            var deserializedObject = xmlService.DeseralizeMetadataItem(fs.Name);
            var expectedResult     = new MetadataItem(DateTime.MinValue, "Test");

            // Assert
            Assert.That(deserializedObject.ValutaDatum, Is.EqualTo(expectedResult.ValutaDatum));
            Assert.That(deserializedObject.Type, Is.EqualTo(expectedResult.Type));
        }
Beispiel #26
0
 public static PageViewModel FromModel(MetadataItem model)
 {
     if (model == null)
     {
         return null;
     }
     var result = new PageViewModel();
     result.Items.Add(ItemViewModel.FromModel(model));
     if (model.Type.AllowMultipleItems())
     {
         AddChildren(model, result);
     }
     foreach (var item in model.References)
     {
         result.References.Add(ReferenceViewModel.FromModel(item));
     }
     return result;
 }
        public void Save_CheckIfMetadataItemValid_RetrunFalse()
        {
            // arrange
            var dataBaseHandlerStub = A.Fake <IDataBaseHandler>();
            var metaDataControl     = new MetaDataControl();
            var metadataItem        = new MetadataItem(true);

            metadataItem.Bezeichung   = "";
            metadataItem.ValutaDatum  = DateTime.Now;
            metadataItem.DokumentTyp  = "Beleg";
            metadataItem.Stichwoerter = "Test01";
            bool result;

            // act
            result = metaDataControl.Save(metadataItem, "target", "guid", dataBaseHandlerStub);
            // assert
            Assert.That(result, Is.False);
        }
        public void MetadataItem_Bezeichnung_GetSetTestingText()
        {
            // Arrange
            var metadataItem = new MetadataItem(TESTING_TEXT, _testDateTime)
            {
                Bezeichnung = TESTING_TEXT
            };

            // Act
            var name       = metadataItem.Bezeichnung;
            var valutaDate = metadataItem.ValutaDatum;
            var keyword    = metadataItem.Stichwoerter;

            // Assert
            Assert.That(name, Is.EqualTo(TESTING_TEXT));
            Assert.That(valutaDate, Is.EqualTo(_testDateTime));
            Assert.That(keyword, Is.EqualTo(null));
        }
Beispiel #29
0
        public MetadataServiceTest()
        {
            _metadataMock = new MetadataItem()
            {
                FileEnding   = ".test",
                CreationTime = DateTime.Now,
                FileName     = "test",
                Keywords     = "test",
                Typ          = "test",
                Username     = "******",
                Valuta       = DateTime.Now
            };

            _appSettings = new AppSettings()
            {
                RepositoryPath = @"C:\temp"
            };
        }
Beispiel #30
0
        protected void rptSkillsChecklist_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                MetadataItem issue = e.Item.DataItem as MetadataItem;

                if (issue != null)
                {
                    Literal            litSkill   = e.FindControlAs <Literal>("litSkill");
                    HtmlInputCheckBox  inputSkill = e.FindControlAs <HtmlInputCheckBox>("inputSkill");
                    HtmlGenericControl issueLabel = e.FindControlAs <HtmlGenericControl>("issueLabel");

                    inputSkill.Attributes.Add("data-id", issue.ID.ToString());
                    litSkill.Text = issue.ContentTitle;
                    issueLabel.Attributes.Add("for", inputSkill.ID);
                }
            }
        }
Beispiel #31
0
        public void TestCollectionToThreadSafeCollectionNullItem()
        {
            IEnumerable <Protocol.Models.MetadataItem> collection = new List <Protocol.Models.MetadataItem>()
            {
                null
            };

            IEnumerable <MetadataItem> result = UtilitiesInternal.CollectionToThreadSafeCollectionIModifiable(
                collection,
                objectCreationFunc: o => new MetadataItem(o));

            Assert.NotNull(result);
            Assert.Equal(1, result.Count());

            MetadataItem protoItem = result.First();

            Assert.Null(protoItem);
        }
Beispiel #32
0
        void DBView_ItemDoubleClick(object sender, MetadataStructureItem clickedItem)
        {
            if (clickedItem.MetadataItem == null)
            {
                return;
            }

            // Adding a table to the currently active query.
            if ((MetadataType.Objects & clickedItem.MetadataItem.Type) == 0 &&
                (MetadataType.ObjectMetadata & clickedItem.MetadataItem.Type) == 0)
            {
                return;
            }
            if (ActiveMdiChild == null)
            {
                ChildForm childWindow = CreateChildForm();
                if (childWindow == null)
                {
                    return;
                }
                childWindow.Show();
                childWindow.Activate();
            }
            ChildForm window = (ChildForm)ActiveMdiChild;

            if (window == null)
            {
                return;
            }
            MetadataItem metadataItem = clickedItem.MetadataItem;

            if (metadataItem == null)
            {
                return;
            }
            if ((metadataItem.Type & MetadataType.Objects) <= 0 && metadataItem.Type != MetadataType.Field)
            {
                return;
            }
            using (var qualifiedName = metadataItem.GetSQLQualifiedName(null, true))
            {
                window.QueryView.AddObjectToActiveUnionSubQuery(qualifiedName.GetSQL());
            }
        }
        public void TestSpeichern()
        {
            var docDetailViewModel = new DocumentDetailViewModel("simon", null);
            var m = new MetadataItem();

            m.Stichwoerter                     = "asdasd";
            m.ValutaDatum                      = new DateTime(2020, 12, 12);
            m.Typ                              = "Verträge";
            docDetailViewModel.M               = m;
            docDetailViewModel.Bezeichnung     = "Simon";
            docDetailViewModel.ValutaDatum     = new DateTime(2020, 12, 12);
            docDetailViewModel.SelectedTypItem = "Verträge";
            docDetailViewModel.Stichwoerter    = "asdasdasd";
            docDetailViewModel.Erfassungsdatum = new DateTime(2020, 12, 12);
            docDetailViewModel.Benutzer        = "Simon";
            docDetailViewModel.FilePath        = "C:\\Users\\Simon Scherer\\Desktop\\testSave.pdf";
            docDetailViewModel.Speichern();
            Assert.That(docDetailViewModel.M.Bezeichnung, Is.EqualTo("Simon"));
        }
        public override void LoadForeignKeys(MetadataList foreignKeys, MetadataLoadingOptions loadingOptions)
        {
            if (!Connected)
            {
                Connect();
            }

            // load FKs
            try
            {
                MetadataItem obj      = foreignKeys.Parent.Object;
                MetadataItem database = obj.Database;

                string[] restrictions = new string[2];
                restrictions[0] = database != null ? database.Name : string.Empty;
                restrictions[1] = obj.Name;

                DataTable schemaTable = _connection.GetSchema("Foreign Key Columns", restrictions);

                MetadataForeignKeysFetcherFromDatatable mrf = new MetadataForeignKeysFetcherFromDatatable(foreignKeys, loadingOptions);

                if (foreignKeys.SQLContext.SyntaxProvider.IsSupportSchemas())
                {
                    mrf.PkSchemaFieldName = "TABLE_SCHEMA";
                }
                else
                {
                    mrf.PkDatabaseFieldName = "TABLE_SCHEMA";
                }

                mrf.PkNameFieldName  = "TABLE_NAME";
                mrf.PkFieldName      = "COLUMN_NAME";
                mrf.FkFieldName      = "REFERENCED_COLUMN_NAME";
                mrf.OrdinalFieldName = "ORDINAL_POSITION";
                mrf.Datatable        = schemaTable;

                mrf.LoadMetadata();
            }
            catch (Exception exception)
            {
                throw new QueryBuilderException(exception.Message, exception);
            }
        }
Beispiel #35
0
        public void XmlSer_testSerialize_Returnfalse()
        {
            //arrange
            const string guid       = "eb31d4ff-be0b-4366-9838-994ed803dd69";
            const string title      = "TestBezeichnung";
            DateTime     valutaDate = new DateTime(2010, 09, 10);
            const string type       = "Quittungen";
            const string notes      = "TestStichwort";
            DateTime     entryDate  = new DateTime(2020, 09, 10);
            const string username   = "******";
            MetadataItem testItem   = new MetadataItem(guid, title, valutaDate, type, notes, entryDate, username);
            XmlSer       ser        = new XmlSer();

            //act
            bool result = ser.SerializeFile(testItem, "Testordner");

            //assert
            Assert.That(result, Is.False);
        }
Beispiel #36
0
 public static TocItemViewModel FromModel(MetadataItem item)
 {
     var result = new TocItemViewModel
     {
         Uid = item.Name,
         Name = item.DisplayNames.GetLanguageProperty(SyntaxLanguage.Default),
         Href = item.Href,
     };
     var nameForCSharp = item.DisplayNames.GetLanguageProperty(SyntaxLanguage.CSharp);
     if (nameForCSharp != result.Name)
     {
         result.NameForCSharp = nameForCSharp;
     }
     var nameForVB = item.DisplayNames.GetLanguageProperty(SyntaxLanguage.VB);
     if (nameForVB != result.Name)
     {
         result.NameForVB = nameForVB;
     }
     if (item.Items != null)
     {
         result.Items = TocViewModel.FromModel(item);
     }
     return result;
 }
 private MetadataItem(MetadataItem metadataItem)
 {
     Key = metadataItem.Key;
     Value = metadataItem.Value;
 }
Beispiel #38
0
        public static ItemViewModel FromModel(MetadataItem model)
        {
            if (model == null)
            {
                return null;
            }
            var result = new ItemViewModel
            {
                Uid = model.Name,
                Parent = model.Parent?.Name,
                Children = model.Items?.Select(x => x.Name).OrderBy(s => s).ToList(),
                Href = model.Href,
                Type = model.Type,
                Source = model.Source,
                Documentation = model.Documentation,
                AssemblyNameList = model.AssemblyNameList,
                NamespaceName = model.NamespaceName,
                Summary = model.Summary,
                Remarks = model.Remarks,
                Examples = model.Examples,
                Syntax = SyntaxDetailViewModel.FromModel(model.Syntax),
                Overridden = model.Overridden,
                Exceptions = model.Exceptions,
                Sees = model.Sees,
                SeeAlsos = model.SeeAlsos,
                Inheritance = model.Inheritance,
                Implements = model.Implements,
                InheritedMembers = model.InheritedMembers,
            };

            result.Id = model.Name.Substring((model.Parent?.Name?.Length ?? -1) + 1);

            result.Name = model.DisplayNames.GetLanguageProperty(SyntaxLanguage.Default);
            var nameForCSharp = model.DisplayNames.GetLanguageProperty(SyntaxLanguage.CSharp);
            if (result.Name != nameForCSharp)
            {
                result.NameForCSharp = nameForCSharp;
            }
            var nameForVB = model.DisplayNames.GetLanguageProperty(SyntaxLanguage.VB);
            if (result.Name != nameForVB)
            {
                result.NameForVB = nameForVB;
            }

            result.FullName = model.DisplayQualifiedNames.GetLanguageProperty(SyntaxLanguage.Default);
            var fullnameForCSharp = model.DisplayQualifiedNames.GetLanguageProperty(SyntaxLanguage.CSharp);
            if (result.FullName != fullnameForCSharp)
            {
                result.FullNameForCSharp = fullnameForCSharp;
            }
            var fullnameForVB = model.DisplayQualifiedNames.GetLanguageProperty(SyntaxLanguage.VB);
            if (result.FullName != fullnameForVB)
            {
                result.FullNameForVB = fullnameForVB;
            }

            return result;
        }
        public void AddMetadata_should_set_metadata_on_convention_when_called_with_a_function()
        {
            this.conventionBuilder
                .AddMetadata(() => new[] {new KeyValuePair<string, object>("Foo", "Bar")});

            var convention =
                this.conventionBuilder.GetBuiltInstance();

            var expectedMetadata =
                new MetadataItem("Foo", "Bar");

            convention.Metadata.First().Equals(expectedMetadata).ShouldBeTrue();
        }
        private void btnNext_Click(object s, System.EventArgs e)
        {
            if (String.IsNullOrEmpty(txtName.Text) && workitem == null)
            {
                // don't check TVM Size because it has a default
                MessageBox.Show("Pool name cannot be empty");
                return;
            }

            try
            {                

                if (pool != null)
                {
                    pool = new Pool(txtName.Text, "small" /*temporary*/);
                }
                else if (workitem != null)
                {
                    workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool = new PoolUserSpec();
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(string.Format(
                    "{0} Caught\nName is a required field. Please enter a valid name", ex));
            }

            try
            {
                if (Time.CanParse(dataTableResize))
                {
                    TimeSpan span = Time.ParseTimeSpan(dataTableResize);

                    if (workitem != null)
                    {
                        workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool.
                            ResizeTimeout = span;
                    }
                    else if (pool != null)
                    {
                        pool.ResizeTimeout = span;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}", ex));
            }

            try
            {
                string size = (rbtnXLarge.IsChecked == true) ? "extralarge" :
                        (rbtnLarge.IsChecked == true) ? "large" : "small";

                if (workitem != null)
                {
                    workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool.TVMSize = size;
                }
                else if (pool != null)
                {
                    pool.TVMSize = size;
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(string.Format(
                    "{0} Caught\nA TVM size is required", ex));
            }

            try
            {
                if (rbtnAuto.IsChecked == true)
                {
                    if (workitem != null)
                    {
                        workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool.EnableAutoScale = true;
                        workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool.AutoScaleFormula = txtAutoScale.Text;
                    }
                    else if (pool != null)
                    {
                        pool.EnableAutoScale = true;
                        pool.AutoScaleFormula = txtAutoScale.Text;
                    }
                }
                else if (rbtnTD.IsChecked == true)
                {
                    if (workitem != null)
                    {
                        workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool.EnableAutoScale = false;
                        workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool.TargetDedicated = int.Parse(txtTD.Text);
                    }
                    else if (pool != null)
                    {
                        pool.EnableAutoScale = false;
                        pool.TargetDedicated = int.Parse(txtTD.Text);
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show("Something is wrong with the Autoscale/TD buttons");
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(string.Format(
                    "{0} Caught\nThis is not a proper Autoscale/TD argument.", ex));
            }

            try
            {
                if (workitem != null)
                {
                    workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool.Communication = (rbtnComT.IsChecked == true) ? true :
                        (rbtnComF.IsChecked == true) ? false : false;
                }
                else if (pool != null)
                {
                    pool.Communication = (rbtnComT.IsChecked == true) ? true :
                        (rbtnComF.IsChecked == true) ? false : false;
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(string.Format(
                    "{0} Caught\nThis is not a proper Communication argument.", ex));
            }

            try
            {
                if (workitem != null)
                {
                    workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool.StorageAccountAffinity = txtSAA.Text;
                }
                else if (pool != null)
                {
                    pool.StorageAccountAffinity = txtSAA.Text;
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(string.Format(
                    "{0} Caught\nThis is not a proper Storage Account Affinity", ex));
            }

            try
            {
                List<MetadataItem> metadata = new List<MetadataItem>();
                foreach (DataRowView row in dataView)
                {
                    string key = row.Row.ItemArray[0].ToString();
                    string value = row.Row.ItemArray[1].ToString();
                    if (!String.IsNullOrEmpty(key) &&
                        !String.IsNullOrEmpty(value))
                    {
                        MetadataItem item = new MetadataItem();
                        item.Name = key;
                        item.Value = value;
                        metadata.Add(item);
                    }
                }
                if (metadata.Count > 0)
                {
                    if (workitem != null)
                    {
                        workitem.JobExecutionEnvironment.AutoPoolSpecification.Pool.Metadata = metadata.ToArray();
                    }
                    else if (pool != null)
                    {
                        pool.Metadata = metadata.ToArray();
                    }                    
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Pool Metadata:\n{0}", ex));
            }

            try
            {
                if (pool != null && chkStartTask.IsChecked == true)
                {
                    CreatePoolP2 p2 = new CreatePoolP2(this.Sender, pool);
                    NavigationService.Navigate(p2);
                }
                else if (pool != null && chkStartTask.IsChecked == false)
                {
                    (Sender as BatchTreeViewItem).AddPool(pool, pool.Name);
                    (this.Parent as NavigationWindow).Close();
                }
                else if (workitem != null && chkStartTask.IsChecked == true)
                {
                    CreatePoolP2 p7 = new CreatePoolP2(this.Sender, workitem);
                    NavigationService.Navigate(p7);
                }
                else if (workitem != null && chkStartTask.IsChecked == false)
                {
                    (Sender as BatchTreeViewItem).AddWorkItem(workitem);
                    (this.Parent as NavigationWindow).Close();
                }
                else
                {
                    MessageBox.Show("Improper pool/workitem argument passed into CreatePoolP1");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Utils.ExtractExceptionMessage(ex));
            }
        }
Beispiel #41
0
 private void setStuff(ref MetadataItem item, PropertyItem propItem, string tag, string caption)
 {
   try
   {
     item.Caption = caption;
     item.Hex = tag;
     string proptext = propItem.Id.ToString("x");
     if (proptext == tag)
     {
       System.Text.ASCIIEncoding Value = new System.Text.ASCIIEncoding();
       item.DisplayValue = Value.GetString(propItem.Value);
     }
   }
   catch (Exception)
   { }
 }
        /// <summary>
        /// Creates a new workitem
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the workitem</param>
        public void CreateWorkItem(NewWorkItemParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            using (IWorkItemManager wiManager = parameters.Context.BatchOMClient.OpenWorkItemManager())
            {
                ICloudWorkItem workItem = wiManager.CreateWorkItem(parameters.WorkItemName);

                if (parameters.Schedule != null)
                {
                    workItem.Schedule = parameters.Schedule.omObject;
                }

                if (parameters.JobSpecification != null)
                {
                    Utils.Utils.JobSpecificationSyncCollections(parameters.JobSpecification);
                    workItem.JobSpecification = parameters.JobSpecification.omObject;
                }

                if (parameters.JobExecutionEnvironment != null)
                {
                    Utils.Utils.JobExecutionEnvironmentSyncCollections(parameters.JobExecutionEnvironment);
                    workItem.JobExecutionEnvironment = parameters.JobExecutionEnvironment.omObject;
                }

                if (parameters.Metadata != null)
                {
                    workItem.Metadata = new List<IMetadataItem>();
                    foreach (DictionaryEntry d in parameters.Metadata)
                    {
                        MetadataItem metadata = new MetadataItem(d.Key.ToString(), d.Value.ToString());
                        workItem.Metadata.Add(metadata);
                    }
                }
                WriteVerbose(string.Format(Resources.NBWI_CreatingWorkItem, parameters.WorkItemName));
                workItem.Commit(parameters.AdditionalBehaviors);
            }
        }
 internal abstract void Evaluate(EdmModelValidationContext context, MetadataItem item);
        /// <summary>
        /// Creates a new job schedule.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the job schedule.</param>
        public void CreateJobSchedule(NewJobScheduleParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            JobScheduleOperations jobScheduleOperations = parameters.Context.BatchOMClient.JobScheduleOperations;
            CloudJobSchedule jobSchedule = jobScheduleOperations.CreateJobSchedule();

            jobSchedule.Id = parameters.JobScheduleId;
            jobSchedule.DisplayName = parameters.DisplayName;

            if (parameters.Schedule != null)
            {
                jobSchedule.Schedule = parameters.Schedule.omObject;
            }

            if (parameters.JobSpecification != null)
            {
                Utils.Utils.JobSpecificationSyncCollections(parameters.JobSpecification);
                jobSchedule.JobSpecification = parameters.JobSpecification.omObject;
            }

            if (parameters.Metadata != null)
            {
                jobSchedule.Metadata = new List<MetadataItem>();
                foreach (DictionaryEntry d in parameters.Metadata)
                {
                    MetadataItem metadata = new MetadataItem(d.Key.ToString(), d.Value.ToString());
                    jobSchedule.Metadata.Add(metadata);
                }
            }
            WriteVerbose(string.Format(Resources.CreatingJobSchedule, parameters.JobScheduleId));
            jobSchedule.Commit(parameters.AdditionalBehaviors);
        }
        /// <summary>
        /// Creates a new job.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the job.</param>
        public void CreateJob(NewJobParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
            CloudJob job = jobOperations.CreateJob();

            job.Id = parameters.JobId;
            job.DisplayName = parameters.DisplayName;
            job.Priority = parameters.Priority;

            if (parameters.CommonEnvironmentSettings != null)
            {
                List<EnvironmentSetting> envSettings = new List<EnvironmentSetting>();
                foreach (DictionaryEntry d in parameters.CommonEnvironmentSettings)
                {
                    EnvironmentSetting envSetting = new EnvironmentSetting(d.Key.ToString(), d.Value.ToString());
                    envSettings.Add(envSetting);
                }
                job.CommonEnvironmentSettings = envSettings;
            }

            if (parameters.Constraints != null)
            {
                job.Constraints = parameters.Constraints.omObject;
            }

            if (parameters.UsesTaskDependencies != null)
            {
                job.UsesTaskDependencies = parameters.UsesTaskDependencies;
            }

            if (parameters.JobManagerTask != null)
            {
                Utils.Utils.JobManagerTaskSyncCollections(parameters.JobManagerTask);
                job.JobManagerTask = parameters.JobManagerTask.omObject;
            }

            if (parameters.JobPreparationTask != null)
            {
                Utils.Utils.JobPreparationTaskSyncCollections(parameters.JobPreparationTask);
                job.JobPreparationTask = parameters.JobPreparationTask.omObject;
            }

            if (parameters.JobReleaseTask != null)
            {
                Utils.Utils.JobReleaseTaskSyncCollections(parameters.JobReleaseTask);
                job.JobReleaseTask = parameters.JobReleaseTask.omObject;
            }

            if (parameters.Metadata != null)
            {
                job.Metadata = new List<MetadataItem>();
                foreach (DictionaryEntry d in parameters.Metadata)
                {
                    MetadataItem metadata = new MetadataItem(d.Key.ToString(), d.Value.ToString());
                    job.Metadata.Add(metadata);
                }
            }

            if (parameters.PoolInformation != null)
            {
                Utils.Utils.PoolInformationSyncCollections(parameters.PoolInformation);
                job.PoolInformation = parameters.PoolInformation.omObject;
            }

            if (parameters.OnAllTasksComplete != null)
            {
                job.OnAllTasksComplete = parameters.OnAllTasksComplete;
            }

            if (parameters.OnTaskFailure != null)
            {
                job.OnTaskFailure = parameters.OnTaskFailure;
            }

            WriteVerbose(string.Format(Resources.CreatingJob, parameters.JobId));
            job.Commit(parameters.AdditionalBehaviors);
        }