//public ActionResult ParcaGuncelle(SubPiece subPiece, FormCollection form)
        //{
        //    var id = Convert.ToInt32(form["par"]);
        //    using (var ctx = new TakimOmruDBEntities())
        //    {
        //        var existingsubpiece = ctx.SubPiece.Where(s => s.SubPieceID == id)
        //                                                .FirstOrDefault();

        //        if (existingsubpiece != null)
        //        {
        //            existingsubpiece.SubPieceName = subPiece.SubPieceName;
        //            existingsubpiece.ToolLife = subPiece.ToolLife;

        //            ctx.SaveChanges();
        //        }
        //    }
        //    return RedirectToAction("TakimOmru", "Home");
        //}

        public ActionResult ParcaGuncelle(int ID)
        {
            TakimOmruDBEntities db   = new TakimOmruDBEntities();
            ThreeModel          test = new ThreeModel();

            test.subPiece = db.SubPiece.Find(ID);
            return(RedirectToAction("TakimOmru", "Home", test));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            // database gave us this:
            ThreeModel model = new ThreeModel {
                Name = "Three Thing"
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public static ThreeModel ToThreeJSGeometry(this RhinoObject rhinoObject)
        {
            ThreeModel threeModel = new ThreeModel();

            threeModel.metadata = new MetaData()
            {
                version   = 4,
                type      = "BufferGeometry",
                generator = "BufferGeometryExporter"
            };

            threeModel.data            = new Data();
            threeModel.data.attributes = new Attributes();


            var geo = rhinoObject.Geometry;

            if (geo.HasBrepForm)
            {
                Brep brep = Brep.TryConvertBrep(geo);

                Mesh[] meshes = Mesh.CreateFromBrep(brep, new MeshingParameters());
                Mesh   mesh   = null;

                if (meshes.Length > 1)
                {
                    Mesh meshfirst = meshes[0];

                    for (int i = 1; i < meshes.Length; i++)
                    {
                        meshfirst.Append(meshes[i]);
                    }

                    mesh = meshfirst;
                }
                else
                {
                    mesh = meshes[0];
                }

                Rhino.RhinoDoc.ActiveDoc.Objects.AddMesh(mesh);

                mesh.Faces.ConvertQuadsToTriangles();


                double[] verticeArray = new double[(mesh.Faces.Count * 3) * 3];
                double[] normals      = new double[(mesh.Faces.Count * 3) * 3];

                mesh.Normals.ComputeNormals();

                //int normCounter = 0;
                //foreach (var normy in mesh.Normals)
                //{
                //    normy.Unitize();
                //    normals[normCounter++] = normy.X;
                //    normals[normCounter++] = normy.Y;
                //    normals[normCounter++] = normy.Z;
                //}

                int counter = 0;

                foreach (MeshFace mface in mesh.Faces)
                {
                    normals[counter]        = mesh.Normals[mface.A].X;
                    verticeArray[counter++] = mesh.Vertices[mface.A].X;
                    verticeArray[counter++] = mesh.Vertices[mface.A].Y;
                    verticeArray[counter++] = mesh.Vertices[mface.A].Z;

                    verticeArray[counter++] = mesh.Vertices[mface.B].X;
                    verticeArray[counter++] = mesh.Vertices[mface.B].Y;
                    verticeArray[counter++] = mesh.Vertices[mface.B].Z;

                    verticeArray[counter++] = mesh.Vertices[mface.C].X;
                    verticeArray[counter++] = mesh.Vertices[mface.C].Y;
                    verticeArray[counter++] = mesh.Vertices[mface.C].Z;
                }

                //foreach (Point3f vert in mesh.Vertices)
                //{
                //    verticeArray[counter++] = Math.Round(vert.X, 3);
                //    verticeArray[counter++] = Math.Round(vert.Y, 3);
                //    verticeArray[counter++] = Math.Round(vert.Z, 3);
                //}

                threeModel.data.attributes.position = new AttributeObj()
                {
                    itemSize = 3,
                    type     = "Float32Array",
                    array    = verticeArray,
                };

                //threeModel.data.attributes.normal = new AttributeObj()
                //{
                //    itemSize = 3,
                //    type = "Float32Array",
                //    array = normals
                //};

                threeModel.data.boundingSphere = new BoundingSphere()
                {
                    center = new int[] { 0, 0, 0 },
                    radius = 1000,
                };
            }

            return(threeModel);
        }
        public ActionResult TakimOmru(Notification noti, [Bind(Include = "NoteID,NoteHeader,NoteDescription,CreatedDate,FkPieceID,FkSubPieceID,FkUserID")] Note note)
        {
            //ActionResult result = null;
            TakimOmruDBEntities db = new TakimOmruDBEntities();

            ViewBag.FKPieceID = new SelectList(db.Piece, "PieceID", "PieceName");
            //ViewBag.FkSubPieceID = new SelectList(db.SubPiece, "SubPieceID", "SubPieceName");
            //ViewBag.FkUserID = new SelectList(db.User, "UserID", "UserName");

            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            ViewBag.UserID  = Session["UserID"];
            ViewBag.Company = Session["Company"];
            ViewBag.Logo    = Session["Logo"];
            ViewBag.Name    = Session["FirstName"];
            int        UserId = Convert.ToInt32(Session["UserID"]);
            ThreeModel tm     = new ThreeModel();

            tm.notification = db.Notification.ToList();
            tm.pieces       = db.Piece.ToList();
            tm.subpieces    = db.SubPiece.ToList();
            tm.notes        = db.Notes.ToList();

            ViewBag.FkPieceIDd   = new SelectList(db.Piece, "PieceID", "PieceName", note.FkPieceID);
            ViewBag.FkSubPieceID = new SelectList(db.SubPiece, "SubPieceID", "SubPieceName", note.FkSubPieceID);
            ViewBag.FkUserID     = new SelectList(db.User, "UserID", "UserName", note.FkUserID);

            var altkategori = from s in db.SubPiece
                              join dt in db.Detail on s.SubPieceID equals dt.FKSubPieceID
                              where s.FKUserID == UserId
                              select new
            {
                SubPieceId   = s.SubPieceID,
                SubPieceName = s.SubPieceName,
                ToolLife     = s.ToolLife,
                PieceID      = s.FKPieceID,
                PieceCount   = dt.PieceCount,
            };
            var data = altkategori.GroupBy(x => x.SubPieceId).Select(x => new
            {
                SubPieceId   = x.FirstOrDefault().SubPieceId,
                SubPieceName = x.FirstOrDefault().SubPieceName,
                ToolLife     = x.FirstOrDefault().ToolLife,
                PieceID      = x.FirstOrDefault().PieceID,
                PieceCount   = x.Sum(y => y.PieceCount),
            }).Where(v => v.PieceCount > (v.ToolLife * 2) / 3);

            if (data != null && data.Any())
            {
                foreach (var item in data)
                {
                    db.Notification.Add(new Notification()
                    {
                        NotificationID           = noti.NotificationID,
                        Notification_Description = noti.Notification_Description = (item.SubPieceName) + " " + "parçasının ömrü tükenmek üzere Kalan parça sayısı " + (item.ToolLife - item.PieceCount),
                        Count             = noti.Count = 0,
                        FKUserId          = UserId,
                        Notification_Date = noti.Notification_Date.GetValueOrDefault(DateTime.Now),
                    });
                }

                db.SaveChanges();
            }

            //var noti = db.Notification.ToList();


            //ViewBag.PieceID = new SelectList(db.Piece, "PieceId", "PieceName", subPiece.FKPieceID);
            //ViewBag.Message = "Your application description page.";

            //ViewBag.Piece = new SelectList(db.Piece, "PieceId", "PieceName");
            //var prodecure= db.SP_Notification_Update_Counter_v1(UserId);
            return(View(tm));
        }
Exemplo n.º 5
0
 public ActionResult Index(ThreeModel Model)
 {
     // Save to database
     return(RedirectToAction("Index"));
 }