Пример #1
0
        public async Task GetAndListOperations(bool useTokenCredential)
        {
            var client = CreateDocumentModelAdministrationClient(useTokenCredential);

            // Guarantee there is going to be at least one operation
            var modelId = Recording.GenerateId();

            await using var trainedModel = await CreateDisposableBuildModelAsync(modelId);

            var modelOperationFromList = client.GetOperationsAsync().ToEnumerableAsync().Result;

            Assert.GreaterOrEqual(modelOperationFromList.Count, 1);

            ValidateModelOperationInfo(modelOperationFromList.FirstOrDefault());

            ModelOperation modelOperationInfo = await client.GetOperationAsync(modelOperationFromList.FirstOrDefault().OperationId);

            ValidateModelOperationInfo(modelOperationInfo);
            if (modelOperationInfo.Status == DocumentOperationStatus.Failed)
            {
                Assert.NotNull(modelOperationInfo.Error);
                Assert.NotNull(modelOperationInfo.Error.Code);
                Assert.NotNull(modelOperationInfo.Error.Message);
            }
            else
            {
                ValidateDocumentModel(modelOperationInfo.Result);
            }
        }
Пример #2
0
        public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, ModelOperation requiredOperation)
        {
            if (usernames.Split(',').ToList().Contains(userName))
            {
                return(true);
            }

            var acl = DeserializeAcl(secDesc);

            foreach (AceStruct ace in acl)
            {
                if (0 == string.Compare(userName, ace.PrincipalName, true, CultureInfo.CurrentCulture))
                {
                    foreach (ModelOperation operation in ace.ModelOperations)
                    {
                        if (operation == requiredOperation)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #3
0
        public async Task GetAndListOperationsWithTags()
        {
            var client           = CreateDocumentModelAdministrationClient();
            var trainingFilesUri = new Uri(TestEnvironment.BlobContainerSasUrl);
            var modelId          = Recording.GenerateId();
            var options          = new BuildModelOptions();

            foreach (var tag in TestingTags)
            {
                options.Tags.Add(tag);
            }

            BuildModelOperation operation = await client.StartBuildModelAsync(trainingFilesUri, DocumentBuildMode.Template, modelId, options);

            ModelOperationInfo modelOperationInfo = client.GetOperationsAsync().ToEnumerableAsync().Result
                                                    .FirstOrDefault(op => op.OperationId == operation.Id);

            Assert.NotNull(modelOperationInfo);

            CollectionAssert.AreEquivalent(TestingTags, modelOperationInfo.Tags);

            ModelOperation modelOperation = await client.GetOperationAsync(operation.Id);

            CollectionAssert.AreEquivalent(TestingTags, modelOperation.Tags);

            await client.DeleteModelAsync(modelId);
        }
Пример #4
0
 public Designer(IServiceRegistry services)
 {
     this.services   = services;
     device          = services.GetService <IGraphicsDeviceService>().DirectXDevice;
     shapes          = new List <ShapeMeshDescription>();
     ModelOperations = ModelOperation.None;
 }
Пример #5
0
    public bool Execute(ModelOperation operation, ProjectModel model, SectionChoisedEventArgs attribute)
    {
        if (model == null)
        {
            Debug.Log("Model is null");
            return(false);
        }

        //TODO: Перед установкой индексов модель должна запросить данные из сервера

        switch (operation)
        {
        case ModelOperation.ChoiseSection:
            model.CurrentSectionIndex = attribute.Index;
            break;

        case ModelOperation.ChoiseQuestionBlock:
            model.CurrentQuestionBlockIndex = attribute.Index;
            break;

        case ModelOperation.GetQuestion:
            break;

        default:     //Message Box
            break;
        }

        return(true);
    }
Пример #6
0
        public void AverageforCategoryTestYearIncams()
        {
            var jsonArray = TestsHelper.GetJonsArrayFromFile("TransactionsArray.json");
            List <AccountMovement> accountMovements = ModelConverter.GetAccountMovmentsFromJarray(jsonArray);

            accountMovements.Count.Should().Be(122);

            jsonArray = TestsHelper.GetJonsArrayFromFile("CategoriesArray.json");
            List <SubCategory> categorisModel = ModelConverter.GetCategoriesFromJarray(jsonArray);

            categorisModel.Count.Should().Be(105);

            var modementsViewModels = ModelConverter.CreateMovementsViewModels(accountMovements, categorisModel, "Felles");

            modementsViewModels[0].Category.Should().BeEquivalentTo("Altibox");

            string category       = "Mat";
            int?   year           = null;
            int?   month          = null;
            bool   justExtrations = false;

            var average = ModelOperation.AverageforCategory(modementsViewModels, category, 2017, month, justExtrations);

            average.Should().Be(117.5);
        }
        public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, ModelOperation modelOperation)
        {
            // If the user is the administrator, allow unrestricted access.
            // Because SQL Server defaults to case-insensitive, we have to
            // perform a case insensitive comparison. Ideally you would check
            // the SQL Server instance CaseSensitivity property before making
            // a case-insensitive comparison.
            if (0 == String.Compare(userName, m_adminUserName, true, CultureInfo.CurrentCulture))
            {
                return(true);
            }

            AceCollection acl = DeserializeAcl(secDesc);

            foreach (AceStruct ace in acl)
            {
                // First check to see if the user or group has an access control
                //  entry for the item
                if (0 == String.Compare(userName, ace.PrincipalName, true, CultureInfo.CurrentCulture))
                {
                    // If an entry is found,
                    // return true if the given required operation
                    // is contained in the ACE structure
                    foreach (ModelOperation aclOperation in ace.ModelOperations)
                    {
                        if (aclOperation == modelOperation)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #8
0
        public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, ModelOperation requiredOperation)
        {
            //Check Overrides
            if (IsSecurityOverride(userName))
            {
                return(true);
            }

            //Check ACL Permissions
            AceCollection acl = DeserializeAcl(secDesc);

            foreach (AceStruct ace in acl)
            {
                if (ValidateACLPrincipal(ace.PrincipalName, userName))
                {
                    foreach (ModelOperation aclOperation in ace.ModelOperations)
                    {
                        if (aclOperation == requiredOperation)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #9
0
 public void ClassNameTest()
 {
     ModelOperation target = new ModelOperation();
     string expected = "TestModel";
     string actual;
     target.ClassName = expected;
     actual = target.ClassName;
     Assert.AreEqual(expected, actual);
 }
Пример #10
0
 public void NamespaceTest()
 {
     ModelOperation target = new ModelOperation();
     string expected = "Test.Model";
     string actual;
     target.Namespace = expected;
     actual = target.Namespace;
     Assert.AreEqual(expected, actual);
 }
Пример #11
0
 public bool CheckAccess(
     string userName,
     IntPtr userToken,
     byte[] secDesc,
     ModelOperation modelOperation)
 {
     EventLog.WriteEntry("SSRS-AZ", "CheckAccess - ModelOperation", EventLogEntryType.Information);
     return(true);
 }
Пример #12
0
 public ParserTask(Source source)
 {
     _source          = source;
     ModelOperation   = new ModelOperation();
     RSSParser        = new RSSParserOperation();
     _timer           = new Timer(10000);
     _timer.AutoReset = true;
     _timer.Elapsed  += Process;
     _timer.Start();
 }
Пример #13
0
        public static Model New(DirectXDevice device, float width = 1.0f, float height = 1.0f, float depth = 1.0f, float tileX = 1.0f, float tileY = 1.0f, float tileZ = 1.0f, PrimitiveTopology primitiveTopology = PrimitiveTopology.TriangleList,
                                ModelOperation modelOperations    = ModelOperation.None)
        {
            BoxCubeMapMesh cube = new BoxCubeMapMesh(width, height, depth, tileX, tileY, tileZ);

            VertexPositionNormalTextureCube[] vertices;
            int[] indices;
            cube.GenerateMesh(out vertices, out indices);

            return(GeometricPrimitive <VertexPositionNormalTextureCube> .New(device, "CubeUVW", vertices, indices, primitiveTopology, modelOperations));
        }
Пример #14
0
        public static Model New(DirectXDevice device, int points, ModelOperation modelOperations = ModelOperation.None)
        {
            var pointCloud = new PointCloud(points);

            VertexPositionNormalTexture[] vertices;
            int[] indices;

            pointCloud.GenerateMesh(out vertices, out indices);
            return(GeometricPrimitive.New(device, "PointCloud", vertices, indices, PrimitiveTopology.PointList,
                                          modelOperations));
        }
Пример #15
0
        public static Model New(DirectXDevice device, float semiMajorAxis = 1.0f, float semiMinorAxis = 1.0f, int tessellation = 64, float innerRadiusRatio = 0f, float tileX = 1.0f,
                                float tileY = 1.0f, ModelOperation modelOperations = ModelOperation.None)
        {
            Contract.Requires <ArgumentException>(tessellation >= 3, "tessellation must be >= 3");
            var ellipse = new EllipseMesh(semiMajorAxis, semiMinorAxis, tessellation, innerRadiusRatio, tileX, tileY);

            VertexPositionNormalTexture[] vertices;
            int[] indices;
            ellipse.GenerateMesh(out vertices, out indices);

            return(GeometricPrimitive.New(device, "Ellipse", vertices, indices, PrimitiveTopology.TriangleList, modelOperations));
        }
Пример #16
0
        public static Model New(DirectXDevice device, float tileX = 1.0f, float tileY = 1.0f, float tileZ = 1.0f, PrimitiveTopology primitiveTopology = PrimitiveTopology.TriangleList,
                                ModelOperation modelOperations    = ModelOperation.None)
        {
            VertexPositionNormalTextureCube[] vertices;
            int[] indices;
            var   skybox = new SkyboxMesh(tileX, tileY, tileZ);

            skybox.GenerateMesh(out vertices, out indices);

            return(GeometricPrimitive <VertexPositionNormalTextureCube> .New(device, "SkyBoxMesh",
                                                                             vertices, indices, primitiveTopology, modelOperations));
        }
Пример #17
0
        /// <summary>
        /// Creates a sphere primitive.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="diameter">The diameter.</param>
        /// <param name="tessellation">The tessellation.</param>
        /// <returns>A sphere primitive.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">tessellation;Must be >= 3</exception>
        public static Model New(DirectXDevice device, float diameter = 2.0f, int tessellation = 16, float tileX = 1.0f,
                                float tileY = 1.0f, ModelOperation modelOperations            = ModelOperation.None)
        {
            Contract.Requires <ArgumentException>(tessellation >= 3, "tessellation must be >= 3");
            SphereMesh sphere = new SphereMesh(tileX, tileY, tessellation, diameter);

            VertexPositionNormalTexture[] vertices;
            int[] indices;
            sphere.GenerateMesh(out vertices, out indices);

            return(GeometricPrimitive.New(device, "Sphere", vertices, indices, PrimitiveTopology.TriangleList, modelOperations));
        }
Пример #18
0
        /// <summary>
        ///     Creates a cone primitive.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="height">The height.</param>
        /// <param name="baseRadius">The radius of the base.</param>
        /// <param name="tessellationH">The horizontal tessellation.</param>
        /// <param name="tessellationV">The vertical tessellation.</param>
        /// <param name="tileX">Horizontal texture coordinate scale factor.</param>
        /// <param name="tileY">Vertical texture coordinate scale factor.</param>
        /// <param name="modelOperations">Operations to perform on the model.</param>
        /// <returns>A cone primitive.</returns>
        public static Model New(DirectXDevice device,
                                float baseRadius, float height, float topRadius = 0,
                                int tessellationH = 8, int tessellationV = 8,
                                float tileX       = 1.0f, float tileY    = 1.0f,
                                ModelOperation modelOperations = ModelOperation.None)
        {
            var cylinder = new ConeMesh(baseRadius, topRadius, height, tessellationH, tessellationV, tileX, tileY);

            VertexPositionNormalTexture[] vertices;
            int[] indices;
            cylinder.GenerateMesh(out vertices, out indices);

            return(GeometricPrimitive.New(device, "Cone", vertices, indices, PrimitiveTopology.TriangleList, modelOperations));
        }
Пример #19
0
 private void Process(object sender, ElapsedEventArgs e)
 {
     lock (_source)
     {
         System.Console.WriteLine($"Process source: '{_source.Name}'");
         var topics      = RSSParser.GetTopics(_source);
         var savedTopics = 0;
         foreach (var topic in topics)
         {
             if (ModelOperation.SaveTopic(topic, _source))
             {
                 savedTopics++;
             }
         }
         System.Console.WriteLine($"Source '{_source.Name}' are completed. Topics total count: {topics.Count()}. Saved count: {savedTopics}");
     }
 }
Пример #20
0
        public bool CheckAccess(


            string userName,


            IntPtr userToken,


            byte[] secDesc,


            ModelOperation modelOperation)


        {
            return(true);
        }
Пример #21
0
        protected override bool ProcessFile(string inputFilePath, string outputFilePath, string dependencyFilePath, OdItem item)
        {
            ModelOperation op = ModelOperation.None;
            
            if (ModelOperations != null)
                op = ModelOperations.Aggregate(ModelOperation.None, (current, t) => current | (ModelOperation) Enum.Parse(typeof (ModelOperation), t.ItemSpec));

            var compilerOptions = new ModelCompilerOptions()
            {
                DependencyFile = dependencyFilePath,
                Quality = Debug ? ModelRealTimeQuality.Low : ModelRealTimeQuality.Maximum,
                ExcludeElements = ExcludeElements != null ? ExcludeElements.Select(element => element.ItemSpec).ToArray() : new string[0],
                ModelOperations = op
            };

            var result = ModelCompiler.CompileAndSave(inputFilePath, outputFilePath, compilerOptions);

            return result.HasErrors;
        }
Пример #22
0
        public void AverageforCategoryTestMonth()
        {
            var jsonArray = TestsHelper.GetJonsArrayFromFile("TransactionsArray.json");
            List <AccountMovement> accountMovements = ModelConverter.GetAccountMovmentsFromJarray(jsonArray);

            accountMovements.Count.Should().Be(122);

            jsonArray = TestsHelper.GetJonsArrayFromFile("CategoriesArray.json");
            List <SubCategory> categorisModel = ModelConverter.GetCategoriesFromJarray(jsonArray);

            categorisModel.Count.Should().Be(105);

            var modementsViewModels = ModelConverter.CreateMovementsViewModels(accountMovements, categorisModel, "Felles");

            modementsViewModels[0].Category.Should().BeEquivalentTo("Altibox");

            var average = ModelOperation.AverageforCategory(modementsViewModels, "Mat", null, 6, true);

            average.Should().Be(117.5);
        }
Пример #23
0
    // Запоминаем прошлый выбор чтобы не грузить одни и те же данные
    // int prevSectionIndex = -1;
    // int questionBLockIndex = -1;

    public bool Execute(ModelOperation operation, ProjectModel model, QuestionBlock attribute)
    {
        if (model == null)
        {
            Debug.Log("Model is null");
            return(false);
        }

        switch (operation)
        {
        case ModelOperation.UpdateQuestionBlockStat:
            model.QuestionBlockStat = attribute;
            break;

        default:     //Message Box
            break;
        }

        return(true);
    }
Пример #24
0
        public void Test2()
        {
            //Get MovementsModel
            JArray   JsonmodementsViewModels;
            Encoding encoding = Encoding.GetEncoding(28591);

            using (StreamReader stream = new StreamReader(TestsHelper.GetAssemblyFile("TransactionViewModelArray.json"), encoding, true))
            {
                JsonmodementsViewModels = JArray.Parse(stream.ReadToEnd());
            }

            var movementsViewModels = new List <MovementsViewModel>();

            foreach (var item in JsonmodementsViewModels)
            {
                movementsViewModels.Add(new ModelConverter().JsonToMovementsViewModels(item));
            }

            // Get Categories
            JArray JsonCategoryList;

            using (StreamReader stream = new StreamReader(TestsHelper.GetAssemblyFile("CategoriesArray.json"), encoding, true))
            {
                JsonCategoryList = JArray.Parse(stream.ReadToEnd());
            }
            List <string> categoryListTemp = new List <string>();

            foreach (var item in JsonCategoryList)
            {
                categoryListTemp.Add(item.ToString());
            }

            IEnumerable <string> categoryList = categoryListTemp;


            var noko  = ModelOperation.AverageforCategory(movementsViewModels, "Mat", null, 6, true);
            var noko1 = ModelOperation.AverageforCategory(movementsViewModels, "Mat", 2018, null, true);
            var noko2 = ModelOperation.AverageforCategory(movementsViewModels, "Mat", 2018, 6, true);

            noko.Should().BeGreaterThan(0);
        }
Пример #25
0
        public bool CheckAccess(
            string userName,
            IntPtr userToken,
            byte[] secDesc,
            ModelOperation modelOperation)
        {
            // If the user is not report viewer username, allow unrestricted access.
            if (!userName.Equals(m_reportViewerUserName))
            {
                return(true);
            }

            AceCollection acl = DeserializeAcl(secDesc);

            foreach (AceStruct ace in acl)
            {
                // First check to see if the user or group has an access control
                //  entry for the item
                if (0 == String.Compare(userName, ace.PrincipalName, true,
                                        CultureInfo.CurrentCulture))
                {
                    // If an entry is found,
                    // return true if the given required operation
                    // is contained in the ACE structure
                    foreach (ModelOperation aclOperation in ace.ModelOperations)
                    {
                        if (aclOperation == modelOperation)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #26
0
 public bool CheckAccess(
     string userName,
     IntPtr userToken,
     byte[] secDesc,
     ModelOperation modelOperation)
 {
     return true;
 }
        public bool CheckAccess(
	   string userName,
	   IntPtr userToken,
	   byte[] secDesc,
	   ModelOperation modelOperation)
        {
            // If the user is the administrator, allow unrestricted access.
              // Because SQL Server defaults to case-insensitive, we have to
              // perform a case insensitive comparison. Ideally you would check
              // the SQL Server instance CaseSensitivity property before making
              // a case-insensitive comparison.
              if (0 == String.Compare(userName, m_adminUserName, true,
            CultureInfo.CurrentCulture))
            return true;

              AceCollection acl = DeserializeAcl(secDesc);
              foreach (AceStruct ace in acl)
              {
            // First check to see if the user or group has an access control
            //  entry for the item
            if (0 == String.Compare(userName, ace.PrincipalName, true,
               CultureInfo.CurrentCulture))
            {
              // If an entry is found,
              // return true if the given required operation
              // is contained in the ACE structure
              foreach (ModelOperation aclOperation in ace.ModelOperations)
              {
            if (aclOperation == modelOperation)
              return true;
              }
            }
              }

              return false;
        }
Пример #28
0
        public async Task GetAndListOperationsAsync()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            #region Snippet:FormRecognizerSampleGetAndListOperations

            var client = new DocumentModelAdministrationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            // Make sure there is at least one operation, so we are going to build a custom model.
#if SNIPPET
            Uri trainingFileUri = new Uri("<trainingFileUri>");
#else
            Uri trainingFileUri = new Uri(TestEnvironment.BlobContainerSasUrl);
#endif
            BuildModelOperation operation = await client.StartBuildModelAsync(trainingFileUri, DocumentBuildMode.Template);

            await operation.WaitForCompletionAsync();

            // List the first ten or fewer operations that have been executed in the last 24h.
            AsyncPageable <ModelOperationInfo> modelOperations = client.GetOperationsAsync();

            string operationId = string.Empty;
            int    count       = 0;
            await foreach (ModelOperationInfo modelOperationInfo in modelOperations)
            {
                Console.WriteLine($"Model operation info:");
                Console.WriteLine($"  Id: {modelOperationInfo.OperationId}");
                Console.WriteLine($"  Kind: {modelOperationInfo.Kind}");
                Console.WriteLine($"  Status: {modelOperationInfo.Status}");
                Console.WriteLine($"  Percent completed: {modelOperationInfo.PercentCompleted}");
                Console.WriteLine($"  Created on: {modelOperationInfo.CreatedOn}");
                Console.WriteLine($"  LastUpdated on: {modelOperationInfo.LastUpdatedOn}");
                Console.WriteLine($"  Resource location of successful operation: {modelOperationInfo.ResourceLocation}");

                if (count == 0)
                {
                    operationId = modelOperationInfo.OperationId;
                }

                if (++count == 10)
                {
                    break;
                }
            }

            // Get an operation by ID
            ModelOperation specificOperation = await client.GetOperationAsync(operationId);

            if (specificOperation.Status == DocumentOperationStatus.Succeeded)
            {
                Console.WriteLine($"My {specificOperation.Kind} operation is completed.");
                DocumentModel result = specificOperation.Result;
                Console.WriteLine($"Model ID: {result.ModelId}");
            }
            else if (specificOperation.Status == DocumentOperationStatus.Failed)
            {
                Console.WriteLine($"My {specificOperation.Kind} operation failed.");
                ResponseError error = specificOperation.Error;
                Console.WriteLine($"Code: {error.Code}: Message: {error.Message}");
            }
            else
            {
                Console.WriteLine($"My {specificOperation.Kind} operation status is {specificOperation.Status}");
            }
            #endregion
        }
Пример #29
0
        public static Model New(DirectXDevice device, float size = 1.0f, int tessellation = 8, float tileX = 1.0f,
                                float tileY = 1.0f, PrimitiveTopology primitiveTopology   = PrimitiveTopology.TriangleList, ModelOperation modelOperations = ModelOperation.None)
        {
            var teapot = new TeapotMesh(size, tileX, tileY, tessellation);

            VertexPositionNormalTexture[] vertices;
            int[] indices;
            teapot.GenerateMesh(out vertices, out indices);
            return(GeometricPrimitive.New(device, "Teapot", vertices, indices, primitiveTopology, modelOperations));
        }
Пример #30
0
 public BookStoreController()
 {
     modelOperation = new ModelOperation();
 }
Пример #31
0
 public BookStoreController(ModelOperation modelOperation)
 {
     this.modelOperation = modelOperation;
 }
Пример #32
0
 public void WriteSourceFileTest()
 {
     // Setup
     string name = "TestModel";
     string space = "Test.Model";
     ModelOperation target = new ModelOperation()
     {
         ClassName = name,
         Namespace = space
     };
     target.PropertyMap.Add("Description", typeof(String));
     target.PropertyMap.Add("Value", typeof(Decimal));
     string location = TestSettings.ENVIRONMENT_PATH;
     string path = String.Format("{0}\\{1}.cs", location, name);
     // exercise
     target.WriteSourceFile(location);
     // verify
     Assert.IsTrue(File.Exists(path));
 }
Пример #33
0
 public int Add(ModelOperation operation)
 {
     return(base.InnerList.Add(operation));
 }
Пример #34
0
        public static Model New <TVertex>(DirectXDevice device, string name, TVertex[] vertices, int[] indices,
                                          PrimitiveTopology primitiveTopology = PrimitiveTopology.TriangleList, ModelOperation modelOperations = ModelOperation.None)
            where TVertex : struct
        {
            bool toLeftHanded = modelOperations.HasFlag(ModelOperation.ReverseIndices);

            return(new GeometricPrimitive <TVertex>(name, vertices, indices, primitiveTopology, toLeftHanded).ToModel(device));
        }
Пример #35
0
 public SetModelOperationsInstruction(ModelOperation modelOperations)
 {
     this.modelOperations = modelOperations;
 }