コード例 #1
0
        public string recDetailsCoreValue(int recognitionId)
        {
            string        strReturn     = "";
            string        dbConnection  = "DefaultConnection";
            string        query         = "SELECT coreValue FROM [RecognitionModels] WHERE recognitionId=@recognitionId";
            SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.
                                                            ConnectionStrings[dbConnection].ToString());
            SqlCommand queryCommand = new SqlCommand(query, sqlConnection);

            queryCommand.Parameters.Add("@recognitionId", SqlDbType.Int).Value = recognitionId;
            try
            {
                sqlConnection.Open();
                SqlDataReader dbReader = queryCommand.ExecuteReader();
                while (dbReader.Read())
                {
                    CoreValues coreValue = (CoreValues)(Convert.ToInt32(dbReader["coreValue"]));
                    strReturn = coreValue.ToString();
                }
                dbReader.Close();
            }
            catch (Exception exeception)
            {
                // Do nothing.
            }
            finally
            {
                queryCommand.Dispose();
                sqlConnection.Close();
            }
            return(strReturn);
        }
コード例 #2
0
        public void Start(CoreValues cv)
        {
            CoreValues = cv;
            MyCamera   = new Camera(cv.Origin, cv.LookAt, cv.VecUp, cv.FovY, cv.AspectRatio, cv.Aperture, cv.DistToFocus);
            Image      = new Vec3[cv.Width * cv.Height];
            World      = HitableList.DefaultWorld;
            Count      = cv.Width * cv.Height;

            PixelFloats = new TransformManyBlock <int, InfoStruct>(GetSampleRays);
            MergeColors = new ActionBlock <InfoStruct>(DoMergeColors, new ExecutionDataflowBlockOptions {
                EnsureOrdered = false, MaxDegreeOfParallelism = -1
            });
            //writeImage = new ActionBlock<InfoStruct>(DoWriteImage, new ExecutionDataflowBlockOptions { EnsureOrdered = false, MaxDegreeOfParallelism = -1 });

            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            PixelFloats.LinkTo(MergeColors, linkOptions);
            //MergeColors.LinkTo(writeImage, linkOptions);

            PixelFloats.Post(0);

            PixelFloats.Complete();
            MergeColors.Completion.Wait();
            DoSaveImage();
        }
コード例 #3
0
 public InfoStruct(CoreValues coreValues)
 {
     X     = 0;
     Y     = 0;
     Depth = coreValues.MaxDepth;
     Color = new Vec3(0, 0, 0);
 }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            CoreValues coreValues = db.CoreValues.Find(id);

            db.CoreValues.Remove(coreValues);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        static public void Main(string[] _)
        {
            var cv       = new CoreValues();
            var dataflow = false;

            Console.WriteLine($"Width ({cv.Width}):");
            if (int.TryParse(Console.ReadLine(), out var width))
            {
                cv.Width = width;
            }

            Console.WriteLine($"Samplecount ({cv.SamplesPerPixel}):");
            if (int.TryParse(Console.ReadLine(), out var samplecount))
            {
                cv.SamplesPerPixel = samplecount;
            }

            Console.WriteLine($"maxDepth ({cv.MaxDepth}):");
            if (int.TryParse(Console.ReadLine(), out var maxDepth))
            {
                cv.MaxDepth = maxDepth;
            }

            Console.WriteLine($"DistToFocus ({cv.DistToFocus}):");
            if (float.TryParse(Console.ReadLine(), out var distToFocus))
            {
                cv.DistToFocus = distToFocus;
            }

            Console.WriteLine($"FovY ({cv.FovY}):");
            if (float.TryParse(Console.ReadLine(), out var fovY))
            {
                cv.FovY = fovY;
            }

            Console.WriteLine($"Dataflow? ({dataflow}):");
            if (bool.TryParse(Console.ReadLine(), out var flow))
            {
                dataflow = flow;
            }
            Task.Factory.StartNew(creationOptions: TaskCreationOptions.LongRunning, action: () => {
                var start = DateTime.Now;
                Console.WriteLine("Started.....");
                if (dataflow)
                {
                    new RaytraceDataflow().Start(cv);
                }
                else
                {
                    Raytrace.Calculate(cv);
                }

                var elapsed = DateTime.Now - start;
                Console.WriteLine($"Process Took: {elapsed:dd\\.hh\\:mm\\:ss} days");
            });
            Console.ReadLine();
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "coreValueId,coreValueName")] CoreValues coreValues)
 {
     if (ModelState.IsValid)
     {
         db.Entry(coreValues).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(coreValues));
 }
コード例 #7
0
        public ActionResult Create([Bind(Include = "coreValueId,coreValueName")] CoreValues coreValues)
        {
            if (ModelState.IsValid)
            {
                db.CoreValues.Add(coreValues);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(coreValues));
        }
コード例 #8
0
ファイル: App.xaml.cs プロジェクト: Veraatversus/Raytracing
 public App()
 {
     AllocConsole();
     Task.Run(() => {
         var cv = new CoreValues {
             Samplecount = 1000,
             maxDepth    = 20,
         };
         Raytrace.Calculate(cv);
     });
 }
コード例 #9
0
 public ActionResult Edit([Bind(Include = "ID,award,recognizor,recognized,description,recognizationDate")] CoreValues coreValues)
 {
     if (ModelState.IsValid)
     {
         db.Entry(coreValues).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.recognizor = new SelectList(db.ProfileInfos, "ProfileId", "fullName", coreValues.recognizor);
     ViewBag.recognized = new SelectList(db.ProfileInfos, "ProfileId", "fullName", coreValues.recognized);
     return(View(coreValues));
 }
コード例 #10
0
        // GET: Values/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CoreValues coreValues = db.CoreValues.Find(id);

            if (coreValues == null)
            {
                return(HttpNotFound());
            }
            return(View(coreValues));
        }
コード例 #11
0
ファイル: Raytrace.cs プロジェクト: Veraatversus/Raytracing
        public static void Calculate(CoreValues cv)
        {
            var image    = new float[cv.Width * cv.Height * 4];
            var scene    = HitableList.DefaultWorld;
            var stepping = 5;
            var m        = Mat4.RotationY(stepping);

            for (var k = 0; k < 360; k += stepping)
            {
                var watch = new Stopwatch();
                watch.Start();

                cv.Origin = m * cv.Origin;
                var myCamera = new Camera(cv.Origin, cv.LookAt, cv.VecUp, cv.FovY, cv.AspectRatio, cv.Aperture, cv.DistToFocus);

                for (var s = 1; s <= cv.SamplesPerPixel; s++)
                {
                    Parallel.For(0, cv.Height, new ParallelOptions {
                        MaxDegreeOfParallelism = 2 * Environment.ProcessorCount
                    }, (y) => {
                        Console.Write(".");
                        for (var x = 0; x < cv.Width; x++)
                        {
                            var pixelColor = new Vec3(0, 0, 0);
                            var u          = (x + Rand.Rand01()) / (cv.Width - 1);
                            var v          = (y + Rand.Rand01()) / (cv.Height - 1);
                            var primary    = myCamera.GetRay(u, v);

                            pixelColor += GetColor(primary, scene, cv.MaxDepth);

                            var index       = ((y * cv.Width) + x) * 4;
                            image[index++] += pixelColor.R;
                            image[index++] += pixelColor.G;
                            image[index++] += pixelColor.B;
                            image[index++] += 255;
                        }
                    });
                    var filename  = $"result{k:0000}:{s}.bmp";
                    var imgToSave = image.Select(b => FinalizeColor(b, s)).ToArray();
                    BMP_Writer.Save(filename, cv.Width, cv.Height, imgToSave);
                    Process.Start(gimpPath, Path.Combine(Directory.GetCurrentDirectory(), filename));
                    Console.WriteLine($"{watch.ElapsedMilliseconds}");
                }

                watch.Stop();
                Console.WriteLine($"Done with {""} {watch.ElapsedMilliseconds} ms passed");
            }
        }
コード例 #12
0
        // GET: CoreValues/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CoreValues coreValues = db.CoreValues.Find(id);

            if (coreValues == null)
            {
                return(HttpNotFound());
            }
            ViewBag.recognizor = new SelectList(db.ProfileInfos, "ProfileId", "fullName", coreValues.recognizor);
            ViewBag.recognized = new SelectList(db.ProfileInfos, "ProfileId", "fullName", coreValues.recognized);
            return(View(coreValues));
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "ID,award,recognizor,recognized,description,recognizationDate")] CoreValues coreValues)
        {
            if (ModelState.IsValid)
            {
                Guid id;
                Guid.TryParse(User.Identity.GetUserId(), out id);
                coreValues.recognizor        = id;
                coreValues.recognizationDate = DateTime.Now;
                db.CoreValues.Add(coreValues);

                db.SaveChanges();

                // first, the customer found in the order is used to locate the customer record
                var employee = db.ProfileInfos.Find(coreValues.recognized);
                // then extract the email address from the customer record
                var EmployeeEmail = employee.WorkEmail;
                // finally, add the email address to the “To” list


                var fullName = employee.fullName;
                var email    = employee.WorkEmail;
                var cv       = coreValues.award;
                var msg      = "Hi " + fullName + ",\n\nWe wanted to congratulate you on being recognized for displaying the core value of " + cv;
                msg += ". Our firm values you as an employee. We could not be more proud that you are becoming an asset to our firm! ";
                msg += "Please check your profile to see the recognition displayed. ";
                msg += "\n\nKeep up the great work!\n\n -Centric Recognition Team";

                MailMessage myMessage = new MailMessage();
                // the syntax here is email address, username (that will appear in the email)
                MailAddress from = new MailAddress("*****@*****.**", "SysAdminMIS4200Team7");
                myMessage.From = from;
                myMessage.To.Add(email);     // this should be replaced with model data
                                             // as shown at the end of this document
                myMessage.Subject = "You Have Been Recognized!";

                myMessage.Body = msg;

                try
                {
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = "smtp.gmail.com";
                    smtp.Port = 587;
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "T3st123!");
                    smtp.EnableSsl             = true;
                    smtp.Send(myMessage);
                    TempData["mailError"] = "";
                }
                catch (Exception ex)
                {
                    // this captures an Exception and allows you to display the message in the View
                    TempData["mailError"] = ex.Message;
                }
                return(View("Email"));
            }

            ViewBag.recognizor = new SelectList(db.ProfileInfos, "ProfileId", "firstName", coreValues.recognizor);
            ViewBag.recognized = new SelectList(db.ProfileInfos, "ProfileId", "firstName", coreValues.recognized);



            return(View(coreValues));
        }
コード例 #14
0
        public async Task <CoreValues> SaveCoreValuesAsync(Brand brand, Level level, CoreValues values)
        {
            var url = string.Format(Endpoints.CoreValuesEndpoint, brand.Id == 0 ? "rst" : brand.Id.ToString(), level.Id);

            return(await RequestWrapper.PutAsyncWrapper <CoreValues, CoreValues>(values, url));
        }