Пример #1
0
        private void DrawBody(BodyModel model)
        {
            if (model == null)
            {
                throw new ArgumentException();
            }

            var geometry = new MeshGeometry3D();

            _meshService.Reset();
            _meshService.Xs  = model.X;
            _meshService.Ys  = model.Y;
            _meshService.Z1s = model.UpperZ;
            _meshService.Z2s = model.LowerZ;

            geometry.Positions = (Point3DCollection) new Point3DCollectionConverter().ConvertFromString(_meshService.CalculatePositions());
            var triangleIndices = _meshService.CalculateTriangleIndices();

            for (var i = 0; i < triangleIndices.Count(); i++)
            {
                geometry.TriangleIndices.Add(triangleIndices[i]);
            }

            GeometryGroup.Add(new GeometryModel3D
            {
                Geometry = geometry,
                Material = new DiffuseMaterial(Brushes.PaleVioletRed)
            });

            Volume = _meshService.Volume();

            OnPropertyChanged(nameof(GeometryGroup));
        }
Пример #2
0
        /// <summary>
        /// Create the best stub of a request that we can using the message level and body
        /// </summary>
        /// <param name="level"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        protected DataModel Create(string level, BodyModel body)
        {
            var model = new DataModel(level, body);

            model.CodeVersion = Configuration.CodeVersion;
            model.Environment = Configuration.Environment;
            model.Platform    = Configuration.Platform;
            model.Language    = Configuration.Language;
            model.Framework   = Configuration.Framework;

            model.Timestamp = (ulong)Now();

            model.Notifier = NotifierModelBuilder.CreateFromAssemblyInfo();

            var currentHttpRequest = GetCurrentHttpRequest();

            if (currentHttpRequest == null)
            {
                model.Request = new RequestModel();
                model.Server  = new ServerModel();
                model.Person  = new PersonModel();
            }
            else
            {
                model.Request = RequestModelBuilder.CreateFromHttpRequest(currentHttpRequest, HttpContext.Current.Session, Configuration.ScrubParams);
                model.Server  = ServerModelBuilder.CreateFromHttpRequest(currentHttpRequest);
                model.Person  = PersonModelBuilder.CreateFromHttpRequest(currentHttpRequest);
            }

            model.Server.GitSha = Configuration.GitSha;

            return(model);
        }
Пример #3
0
        /// <summary>
        /// Create the best stub of a request that we can using the message level and body
        /// </summary>
        /// <param name="level"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        protected DataModel Create(string level, BodyModel body)
        {
            var model = new DataModel(level, body);

            model.CodeVersion = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
            model.Environment = Configuration.Environment;
            model.Platform    = Configuration.Platform;
            model.Language    = Configuration.Language;
            model.Framework   = Configuration.Framework;

            model.Timestamp = (ulong)Now();

            model.Notifier = NotifierModelBuilder.CreateFromAssemblyInfo();

            model.Request = new RequestModel();
            model.Server  = new ServerModel();

            //Obtain person information on non-hosted environment only
            model.Person = PersonModelBuilder.CreateFromEnvironment();

            model.Server.GitSha  = Configuration.GitSha;
            model.Server.Machine = Environment.MachineName;
                        #if __MonoCS__
            model.Custom.Add("Compiler", "Mono");
                        #else
            model.Custom.Add("Compiler", "VS");
                        #endif
            model.Custom.Add("Commandline", Environment.CommandLine);
            model.Custom.Add("CWD", Environment.CurrentDirectory);
            model.Custom.Add("ProcessorCount", Environment.ProcessorCount);

            return(model);
        }
Пример #4
0
        public async Task <BodyDTO> GetOneBodyAsync(int id)
        {
            BodyModel invoice = await DbContext.Bodies
                                .Where(b => b.Id == id)
                                .Include(b => b.Causale)
                                .Include(b => b.DatiDDT)
                                .ThenInclude(ddt => ddt.RiferimentoNumeroLinea)
                                .Include(b => b.DatiPagamento)
                                .ThenInclude(dp => dp.DettaglioPagamento)
                                .Include(b => b.DatiRiepilogo)
                                .Include(b => b.DettaglioLinee)
                                .ThenInclude(dl => dl.CodiceArticolo)
                                .Include(b => b.DettaglioLinee)
                                .ThenInclude(dl => dl.ScontoMaggiorazione)
                                .Include(b => b.CedentePrestatore)
                                .Include(b => b.CessionarioCommittente)
                                .Include(b => b.Metadata)
                                .Include(b => b.Vettore)
                                .AsNoTracking()
                                .FirstOrDefaultAsync()
                                .ConfigureAwait(false);

            if (invoice.Id != 0)
            {
                invoice.CedentePrestatore.BodyModelCP      = null;
                invoice.CedentePrestatore.BodyModelCC      = null;
                invoice.CessionarioCommittente.BodyModelCP = null;
                invoice.CessionarioCommittente.BodyModelCC = null;
            }

            BodyDTO bodyDTO = Mapper.Map <BodyModel, BodyDTO>(invoice);

            return(bodyDTO);
        }
Пример #5
0
        public async Task <string> KeyPhrasesRequest(string data, string language)
        {
            try
            {
                var client = await GetClient();

                client.BaseAddress = new Uri(KeyPhrasesUrl);
                client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", SubscriptionString);

                BodyModel body = new BodyModel();
                body.documents.Add(new BodyModel.Document()
                {
                    id       = "1",
                    language = language,
                    text     = data
                });

                byte[] byteData = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(body));
                using (var content = new ByteArrayContent(byteData))
                {
                    content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    response = await client.PostAsync(KeyPhrasesUrl, content);
                }

                return(await response.Content.ReadAsStringAsync());
            }
            catch (Exception ex)
            {
                return("Error: " + ex.Message);
            }
        }
Пример #6
0
        public async Task <QueryResModel <BodyDTO> > UpdateAsync(BodyModel invoice)
        {
            QueryResModel <BodyDTO> queryResult = new QueryResModel <BodyDTO>();

            int changes = -1;

            if (await DbContext.Bodies.AnyAsync(b => b.Id == invoice.Id).ConfigureAwait(false))
            {
                DbContext.Bodies.Update(invoice);
                changes = await DbContext.SaveChangesAsync().ConfigureAwait(false);
            }

            if (changes <= 0)
            {
                queryResult.Succeeded = false;
                queryResult.Error     = changes == -1 ? "Error: invoice not found" : "Error: Update failed.";
                return(queryResult);
            }
            else
            {
                BodyModel bodyModel = await DbContext.Bodies
                                      .Where(cf => cf.Id == invoice.Id)
                                      .AsNoTracking()
                                      .FirstAsync()
                                      .ConfigureAwait(false);

                queryResult.Data = Mapper.Map <BodyModel, BodyDTO>(bodyModel);

                return(queryResult);
            }
        }
Пример #7
0
            public void Should_Add_Request_Body()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                BodyModel    model    = new BodyModel
                {
                    Id     = 1234567,
                    Active = true,
                    name   = "Rob Test",
                    Parts  = new []
                    {
                        "Legs",
                        "Arms",
                        "Head"
                    },
                    SubModel = new BodySubModel
                    {
                        Description = "Body Sub Model Description",
                        Dttm        = DateTime.Now.Date,
                        Type        = "different type"
                    }
                };

                //When
                settings.SetJsonRequestBody(model);

                //Then
                Assert.NotNull(settings.RequestBody);

                var actual = new JavaScriptSerializer().Deserialize <BodyModel>(Encoding.UTF8.GetString(settings.RequestBody));

                Assert.Equal(model, actual);
            }
Пример #8
0
        /*
         * IMAGE MODERATION
         * This example moderates images from URLs.
         */
        public static void ModerateImages(ContentModeratorClient client, string urlFile, string outputFile)
        {
            Console.WriteLine("--------------------------------------------------------------");
            Console.WriteLine();
            Console.WriteLine("IMAGE MODERATION");
            Console.WriteLine();
            // Create an object to store the image moderation results.
            List <EvaluationData> evaluationData = new List <EvaluationData>();

            using (client)
            {
                // Read image URLs from the input file and evaluate each one.
                using (StreamReader inputReader = new StreamReader(urlFile))
                {
                    while (!inputReader.EndOfStream)
                    {
                        string line = inputReader.ReadLine().Trim();
                        if (line != String.Empty)
                        {
                            Console.WriteLine("Evaluating {0}...", Path.GetFileName(line));
                            var imageUrl  = new BodyModel("URL", line.Trim());
                            var imageData = new EvaluationData
                            {
                                ImageUrl = imageUrl.Value,

                                // Evaluate for adult and racy content.
                                ImageModeration =
                                    client.ImageModeration.EvaluateUrlInput("application/json", imageUrl, true)
                            };
                            Thread.Sleep(1000);

                            // Detect and extract text.
                            imageData.TextDetection =
                                client.ImageModeration.OCRUrlInput("eng", "application/json", imageUrl, true);
                            Thread.Sleep(1000);

                            // Detect faces.
                            imageData.FaceDetection =
                                client.ImageModeration.FindFacesUrlInput("application/json", imageUrl, true);
                            Thread.Sleep(1000);

                            // Add results to Evaluation object
                            evaluationData.Add(imageData);
                        }
                    }
                }
                // Save the moderation results to a file.
                using (StreamWriter outputWriter = new StreamWriter(outputFile, false))
                {
                    outputWriter.WriteLine(JsonConvert.SerializeObject(
                                               evaluationData, Formatting.Indented));

                    outputWriter.Flush();
                    outputWriter.Close();
                }
                Console.WriteLine();
                Console.WriteLine("Image moderation results written to output file: " + outputFile);
                Console.WriteLine();
            }
        }
Пример #9
0
        private void DrawOilBody()
        {
            if (!UpperLayers.Any() || !LowerLayers.Any())
            {
                throw new ArgumentException();
            }

            var x      = UpperLayers.FirstOrDefault().X;
            var y      = UpperLayers.FirstOrDefault().Y;
            var upperZ = new List <double>();
            var lowerZ = new List <double>();

            // assuming that all layers have the same x, y
            for (var i = 0; i < UpperLayers.FirstOrDefault().Z.Length; i++)
            {
                var upperMin = UpperLayers.Select(l => l.Z[i]).Min();
                var lowerMax = LowerLayers.Select(l => l.Z[i]).Max();

                upperZ.Add(lowerMax > upperMin ? lowerMax : upperMin);
                lowerZ.Add(lowerMax);
            }

            var oilBody = new BodyModel
            {
                X      = x,
                Y      = y,
                UpperZ = upperZ.ToArray(),
                LowerZ = lowerZ.ToArray()
            };

            _requestBodyDrawEvent.Publish(oilBody);
        }
Пример #10
0
        /// <summary>
        /// Evaluates an image using the Image Moderation APIs.
        /// </summary>
        /// <param name="client">The Content Moderator API wrapper to use.</param>
        /// <param name="imageUrl">The URL of the image to evaluate.</param>
        /// <returns>Aggregated image moderation results for the image.</returns>
        /// <remarks>This method throttles calls to the API.
        /// Your Content Moderator service key will have a requests per second (RPS)
        /// rate limit, and the SDK will throw an exception with a 429 error code
        /// if you exceed that limit. A free tier key has a 1 RPS rate limit.
        /// </remarks>
        private static EvaluationData EvaluateImage(
            ContentModeratorClient client, string imageUrl)
        {
            var url = new BodyModel("URL", imageUrl.Trim());

            var imageData = new EvaluationData();

            imageData.ImageUrl = url.Value;

            // Evaluate for adult and racy content.
            imageData.ImageModeration =
                client.ImageModeration.EvaluateUrlInput("application/json", url, true);
            Thread.Sleep(1000);

            // Detect and extract text.
            imageData.TextDetection =
                client.ImageModeration.OCRUrlInput("eng", "application/json", url, true);
            Thread.Sleep(1000);

            // Detect faces.
            imageData.FaceDetection =
                client.ImageModeration.FindFacesUrlInput("application/json", url, true);
            Thread.Sleep(1000);

            return(imageData);
        }
Пример #11
0
 public void ValidateNullName(BodyModel body)
 {
     if (body.BodyName == null)
     {
         throw new Exception(nameof(body.BodyName) + " cannot be null!");
     }
 }
Пример #12
0
        public async Task <IActionResult> DeleteGroupAsync([FromBody] BodyModel model)
        {
            var id = HttpContext.User.Claims.ToArray()[5].Value;
            await _groupService.DeleteGroupAsync(id);

            return(Ok());
        }
Пример #13
0
        public async Task <Domain.Body> Put(BodyModel putBody)
        {
            Logger.LogTrace($"Put {putBody.BodyName} invoked");

            Domain.Body Body = await BodyBL.Create(putBody);

            return(Body);
        }
Пример #14
0
        public async Task <Domain.Body> Patch(BodyModel putBody)
        {
            Logger.LogTrace($"Patch {putBody.BodyName} invoked");

            Domain.Body Body = await BodyBL.Update(putBody);

            return(Body);
        }
Пример #15
0
        public PartialViewResult Body1()
        {
            var model = new BodyModel();

            //slider
            model.Slider = db.Slider.Where(sld => sld.Aktif == true).OrderBy(sld => sld.Sira).ToList();

            return(PartialView("~/Views/_Partial/_Body1.cshtml", model));
        }
Пример #16
0
        private void AddBodyControl()
        {
            var body = new BodyModel(this.Bodies)
            {
                IsChecked = true
            };

            this.Bodies.Add(body);
        }
Пример #17
0
        public async Task <Body> InsertAsync(BodyModel body)
        {
            ValidateNullName(body);

            var result = await Context.AddAsync(Mapper.Map <BodyEntity>(body));

            await Context.SaveChangesAsync();

            return(Mapper.Map <Body>(result.Entity));
        }
Пример #18
0
        public PartialViewResult Body2()
        {
            var model = new BodyModel();

            // haberler
            model.Haberler = db.HaberKategorileri.Where(h => h.Slug.Contains("haberler") || h.Slug.Contains("roportajlar")).OrderByDescending(h => h.KategoriId).ToList();
            model.Slider   = db.Slider.Where(s => s.Aktif == true).ToList();

            return(PartialView("~/Views/_Partial/_Body2.cshtml", model));
        }
Пример #19
0
 public void Teleport()
 {
     if (groundDetected)
     {
         BodyModel.Teleport(detectedGroundPos, lastDetectedSurfaceNormal * 0.1f);
     }
     else
     {
         Debug.Log("Ground wasn't detected");
     }
 }
Пример #20
0
            public void Should_Throw_On_Null_Or_Empty_Data_Parameter()
            {
                //Given
                HttpSettings settings = new HttpSettings();
                BodyModel    data     = null;

                //When
                var actual = Record.Exception(() => HttpSettingsExtensions.SetJsonRequestBody(settings, data));

                //Then
                CakeAssert.IsArgumentNullException(actual, nameof(data));
            }
Пример #21
0
        public async Task <IActionResult> UpdateBodyAsync([FromBody] BodyModel invoice)
        {
            QueryResModel <BodyDTO> qrm = await InvService.UpdateAsync(invoice).ConfigureAwait(false);

            if (qrm.Succeeded)
            {
                return(Ok(qrm.Data));
            }
            else
            {
                return(BadRequest(qrm.Error));
            }
        }
Пример #22
0
        //** GetModel **
        // Retrieve a body model record
        public BodyModel GetModel(int id)
        {
            BodyModel toReturn = new BodyModel();

            if (modelsList.Count == 0)
            {
                Debug.LogWarning("Cannot get Body Model. Table is empty.");
            }

            toReturn = modelsList.Find(x => x.ID == id);

            return(toReturn);
        }
Пример #23
0
        // ** EditModel **
        //Update record
        public void EditModel(BodyModel record)
        {
            BodyModel toChange = modelsList.Find(x => x.ID == record.ID);

            if (toChange != null)
            {
                toChange = record;
            }
            else
            {
                Debug.LogWarning("Cannot edit Body Model. Record not found");
            }
        }
        public EvaluationData ValidateImage(string url)
        {
            var url1      = new BodyModel("URL", url);
            var imageData = new EvaluationData();

            imageData.ImageUrl = url1.Value;

            // Evaluate for adult and racy content.
            imageData.ImageModeration =
                _contentModeratorClient.ImageModeration.EvaluateUrlInput("application/json", url1, true);
            Thread.Sleep(1000);
            return(imageData);
        }
Пример #25
0
        static async Task <bool> IsAllowed(string imageUrl)
        {
            var url        = new BodyModel("URL", imageUrl.Trim());
            var moderation = await ContentModeratorClient.ImageModeration
                             .EvaluateUrlInputAsync("application/json", url);

            if (moderation.IsImageAdultClassified.GetValueOrDefault() ||
                moderation.IsImageRacyClassified.GetValueOrDefault())
            {
                return(false);
            }

            return(true);
        }
Пример #26
0
            public void Should_Throw_On_Null_Settings_Parameter()
            {
                //Given
                HttpSettings settings = null;
                BodyModel    model    = new BodyModel {
                    Id = 1234567, Active = true, name = "Rob Test"
                };

                //When
                var record = Record.Exception(() => HttpSettingsExtensions.SetJsonRequestBody(settings, model));

                //Then
                CakeAssert.IsArgumentNullException(record, "settings");
            }
Пример #27
0
        public async Task CreateBody_Normal_CreatesNewBody()
        {
            BodyModel body    = new BodyModel();
            Body      newBody = new Body();

            var BodyDA = new Mock <IBodyDataAccess>();

            BodyDA.Setup(x => x.InsertAsync(body)).ReturnsAsync(newBody);

            var BodyBL = new BodyServant(BodyDA.Object);

            var result = await BodyBL.Create(body);

            result.Should().Be(newBody);
        }
Пример #28
0
        public BodyModel GetBodyModel()
        {
            BodyModel body = new BodyModel();

            body.Measurement = this.GetMeasurements(this.user.UserId);
            body.LastWeight  = this.GetLastWeighIn(this.user.UserId);
            if (this.user.Measurements != null)
            {
                body.Ratio   = this.GetGoldenRatio(this.user.Measurements);
                body.Fat     = this.GetBodyFat(this.user.Measurements, this.user.Height, body.LastWeight);
                body.User    = this.user;
                body.History = this.GetBodyHistory();
            }
            return(body);
        }
Пример #29
0
        /// <summary>
        /// Create the best stub of a request that we can using the message level and body
        /// </summary>
        /// <param name="level"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        protected DataModel Create(string level, BodyModel body, IDictionary <string, string> requestSession, PersonModel person)
        {
            var model = new DataModel(level, body);

            model.CodeVersion = Configuration.CodeVersion;
            model.Environment = Configuration.Environment;
            model.Platform    = Configuration.Platform;
            model.Language    = Configuration.Language;
            model.Framework   = Configuration.Framework;

            model.Timestamp = (ulong)Now();

            model.Notifier = NotifierModelBuilder.CreateFromAssemblyInfo();

            var currentHttpRequest = GetCurrentHttpRequest();

            if (currentHttpRequest == null)
            {
                model.Request = new RequestModel();
                model.Server  = new ServerModel();
                model.Person  = new PersonModel();
            }
            else
            {
                model.Request = RequestModelBuilder.CreateFromHttpRequest(currentHttpRequest, HttpContext.Current.Session, Configuration.ScrubParams);
                model.Server  = ServerModelBuilder.CreateFromHttpRequest(currentHttpRequest);
                model.Person  = PersonModelBuilder.CreateFromHttpRequest(currentHttpRequest);
            }

            if (requestSession != null)
            {
                foreach (var key in requestSession.Keys)
                {
                    model.Request.Session[key] = requestSession[key];
                }
            }

            if (person != null)
            {
                model.Person.Email    = person.Email ?? model.Person.Email;
                model.Person.Id       = person.Id ?? model.Person.Id;
                model.Person.Username = person.Username ?? model.Person.Username;
            }

            model.Server.GitSha = Configuration.GitSha;

            return(model);
        }
Пример #30
0
        //** AddModel **
        //Insert new model in the table
        public int AddModel(BodyModel record)
        {
            int iReturn = 1;

            //ID is an "auto-number" field
            if (modelsList.Count > 0)
            {
                iReturn = modelsList.OrderBy(x => x.ID).Last().ID + 1;
            }

            record.ID = iReturn;

            modelsList.Add(record);

            return(iReturn);
        }
Пример #31
0
        /// <summary>
        /// Create the best stub of a request that we can using the message level and body
        /// </summary>
        /// <param name="level"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        protected DataModel Create(string level, BodyModel body)
        {
            var model = new DataModel(level, body);

            model.Environment = Configuration.Environment;
            model.Platform = Configuration.Platform;
            model.Language = Configuration.Language;
            model.Framework = Configuration.Framework;

            model.Timestamp = (ulong)Now();

            model.Notifier = NotifierModelBuilder.CreateFromAssemblyInfo();

            model.Request = RequestModelBuilder.CreateFromCurrentRequest(Configuration.ScrubParams);
            model.Server = ServerModelBuilder.CreateFromCurrentRequest();
            model.Server.GitSha = Configuration.GitSha;
            model.Person = PersonModelBuilder.CreateFromCurrentRequest();

            return model;
        }
Пример #32
0
 public DataModel(string level, BodyModel body)
 {
     Level = level;
     Body = body;
     Custom = new Dictionary<string, object>();
 }
Пример #33
0
        /// <summary>
        /// Create the best stub of a request that we can using the message level and body
        /// </summary>
        /// <param name="level"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        protected DataModel Create(string level, BodyModel body)
        {
            var model = new DataModel(level, body);

            model.CodeVersion = Configuration.CodeVersion;
            model.Environment = Configuration.Environment;
            model.Platform = Configuration.Platform;
            model.Language = Configuration.Language;
            model.Framework = Configuration.Framework;

            model.Timestamp = (ulong)Now();

            model.Notifier = NotifierModelBuilder.CreateFromAssemblyInfo();

            var currentHttpRequest = GetCurrentHttpRequest();

            if (currentHttpRequest == null)
            {
                model.Request = new RequestModel();
                model.Server = new ServerModel();
                model.Person = new PersonModel();
            }
            else
            {
                model.Request = RequestModelBuilder.CreateFromHttpRequest(currentHttpRequest, HttpContext.Current.Session, Configuration.ScrubParams);
                model.Server = ServerModelBuilder.CreateFromHttpRequest(currentHttpRequest);
                model.Person = PersonModelBuilder.CreateFromHttpRequest(currentHttpRequest);
            }

            model.Server.GitSha = Configuration.GitSha;

            return model;
        }
Пример #34
0
        /// <summary>
        /// Create the best stub of a request that we can using the message level and body
        /// </summary>
        /// <param name="level"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        protected DataModel Create(string level, BodyModel body, IDictionary<string, string> requestSession, PersonModel person)
        {
            var model = new DataModel(level, body);

            model.CodeVersion = Configuration.CodeVersion;
            model.Environment = Configuration.Environment;
            model.Platform = Configuration.Platform;
            model.Language = Configuration.Language;
            model.Framework = Configuration.Framework;

            model.Timestamp = (ulong)Now();

            model.Notifier = NotifierModelBuilder.CreateFromAssemblyInfo();

            var currentHttpRequest = GetCurrentHttpRequest();

            if (currentHttpRequest == null)
            {
                model.Request = new RequestModel();
                model.Server = new ServerModel();
                model.Person = new PersonModel();
            }
            else
            {
                model.Request = RequestModelBuilder.CreateFromHttpRequest(currentHttpRequest, HttpContext.Current.Session, Configuration.ScrubParams);
                model.Server = ServerModelBuilder.CreateFromHttpRequest(currentHttpRequest);
                model.Person = PersonModelBuilder.CreateFromHttpRequest(currentHttpRequest);
            }

            if (requestSession != null)
            {
                foreach(var key in requestSession.Keys)
                {
                    model.Request.Session[key] = requestSession[key];
                }
            }

            if (person != null)
            {
                model.Person.Email = person.Email ?? model.Person.Email;
                model.Person.Id = person.Id ?? model.Person.Id;
                model.Person.Username = person.Username ?? model.Person.Username;
            }

            model.Server.GitSha = Configuration.GitSha;

            return model;
        }