Esempio n. 1
0
        public List <PressureResistanceTestforFactorySamplePhoto> ViewIndex()
        {
            var samples = context.ConcreteSample1.Where(v => DbFunctions.DiffDays(v.ReportDate, DateTime.Now) == 28);
            List <PressureResistanceTestforFactorySamplePhoto> pList = new List <PressureResistanceTestforFactorySamplePhoto>();

            foreach (var item in samples)
            {
                SampleCubePath paths = new SampleCubePath();
                if (samples != null)
                {
                    paths = context.SampleCubePaths.Where(s => s.SampleNumber == item.SampleNumber).FirstOrDefault();
                }

                if (paths != null)
                {
                    PressureResistanceTestforFactorySamplePhoto p = new PressureResistanceTestforFactorySamplePhoto();
                    p.SampleNo = item.SampleNumber;
                    pList.Add(p);
                }
            }
            return(pList);
        }
Esempio n. 2
0
        public ActionResult ConcreteSample(CubeSamplesWithPath sample)
        {
            foreach (var file in sample.Cube1P1Path)
            {
                if (file != null)
                {
                    Random   random         = new Random();
                    FileInfo fi             = new FileInfo(file.FileName);
                    DateTime d              = DateTime.Now;
                    var      InputFileName  = d.Ticks + random.Next(100, 100000000).ToString();
                    var      ServerSavePath = System.IO.Path.Combine(Server.MapPath("~/Content"), InputFileName + fi.Extension);
                    //Save file to server folder
                    file.SaveAs(ServerSavePath);
                    sample.Cube1P1 = InputFileName + fi.Extension;
                }
            }
            foreach (var file in sample.Cube1P2Path)
            {
                if (file != null)
                {
                    Random   random         = new Random();
                    FileInfo fi             = new FileInfo(file.FileName);
                    DateTime d              = DateTime.Now;
                    var      InputFileName  = d.Ticks + random.Next(100, 100000000).ToString();
                    var      ServerSavePath = System.IO.Path.Combine(Server.MapPath("~/Content"), InputFileName + fi.Extension);
                    //Save file to server folder
                    file.SaveAs(ServerSavePath);
                    sample.Cube1P2 = InputFileName + fi.Extension;
                }
            }
            foreach (var file in sample.Cube2P1Path)
            {
                if (file != null)
                {
                    Random   random         = new Random();
                    FileInfo fi             = new FileInfo(file.FileName);
                    DateTime d              = DateTime.Now;
                    var      InputFileName  = d.Ticks + random.Next(100, 100000000).ToString();
                    var      ServerSavePath = System.IO.Path.Combine(Server.MapPath("~/Content"), InputFileName + fi.Extension);
                    //Save file to server folder
                    file.SaveAs(ServerSavePath);
                    sample.Cube2P1 = InputFileName + fi.Extension;
                }
            }
            foreach (var file in sample.Cube2P2Path)
            {
                if (file != null)
                {
                    Random   random = new Random();
                    FileInfo fi     = new FileInfo(file.FileName);

                    DateTime d              = DateTime.Now;
                    var      InputFileName  = d.Ticks + random.Next(100, 100000000).ToString();
                    var      ServerSavePath = System.IO.Path.Combine(Server.MapPath("~/Content"), InputFileName + fi.Extension);
                    //Save file to server folder
                    file.SaveAs(ServerSavePath);
                    sample.Cube2P2 = InputFileName + fi.Extension;
                }
            }
            foreach (var file in sample.Cube3P1Path)
            {
                if (file != null)
                {
                    Random   random         = new Random();
                    FileInfo fi             = new FileInfo(file.FileName);
                    DateTime d              = DateTime.Now;
                    var      InputFileName  = d.Ticks + random.Next(100, 100000000).ToString();
                    var      ServerSavePath = System.IO.Path.Combine(Server.MapPath("~/Content"), InputFileName + fi.Extension);
                    //Save file to server folder
                    file.SaveAs(ServerSavePath);
                    sample.Cube3P1 = InputFileName + fi.Extension;
                }
            }
            foreach (var file in sample.Cube3P2Path)
            {
                if (file != null)
                {
                    Random   random         = new Random();
                    FileInfo fi             = new FileInfo(file.FileName);
                    DateTime d              = DateTime.Now;
                    var      InputFileName  = d.Ticks + random.Next(100, 100000000).ToString();
                    var      ServerSavePath = System.IO.Path.Combine(Server.MapPath("~/Content"), InputFileName + fi.Extension);
                    //Save file to server folder
                    file.SaveAs(ServerSavePath);
                    sample.Cube3P2 = InputFileName + fi.Extension;
                }
            }
            SampleCubePath s = new SampleCubePath()
            {
                SampleNumber = sample.SampleNumber,

                Cube1P1 = sample.Cube1P1,
                Cube1P2 = sample.Cube1P2,
                Cube2P1 = sample.Cube2P1,
                Cube2P2 = sample.Cube2P2,
                Cube3P1 = sample.Cube3P1,
                Cube3P2 = sample.Cube3P2
            };

            context.SampleCubePaths.Add(s);
            context.SaveChanges();
            return(RedirectToAction("BrokenSample", "Home", new
            {
                id = 1
            }));
        }