protected IEnumerator DownloadWholeFile(FileURL _fileUrl, int _windowSize)
    {
        int rfsize = -1; // remote file size
        int lfsize = -1; // local file size
        var pd     = UnityWebRequestHelper.DownloadProcess.BeforeProcess;

        //check remote file status
        StartCoroutine(DownloadBehaviourCheck(_fileUrl,
                                              (UnityWebRequestHelper.DownloadProcess _dp, int _local, int _remote) =>
        {
            pd     = _dp;
            rfsize = _remote;
            lfsize = _local;
        }
                                              ));

        // wait until DownloadBehaviourCheck finished
        while (pd == UnityWebRequestHelper.DownloadProcess.BeforeProcess)
        {
            yield return(null);
        }

        Debug.LogFormat("remote file size {0}; local file size {1}; Next Process will be {2}", rfsize, lfsize, pd);

        switch (pd)
        {
        case UnityWebRequestHelper.DownloadProcess.RedownloadFromBeginning:
            myFileIOHelper.Remove(_fileUrl.localPath);     //Delete TargetFile first
            lfsize = -1;
            break;

        case UnityWebRequestHelper.DownloadProcess.Resume:     //just keep doing
            break;

        case UnityWebRequestHelper.DownloadProcess.DoNothing:
        default:
            Debug.Log("Do Nothing");
            yield break;
        }

        // ONLY ONE of this DownloadWholeFile() can be processed at any given time
        if (downloading)
        {
            yield return(new WaitForSeconds(1f));
        }

        downloading = true;
        for (int i = lfsize + 1; i < rfsize; i += _windowSize)
        {
            yield return(StartCoroutine(
                             myUnityWebRequestHelper.DownloadParts(
                                 (byte[] _bytes) => {
                myFileIOHelper.AppendTo(_fileUrl.localPath, _bytes);
                myProgressDelegate((float)i / (float)rfsize);
            }, _fileUrl.fullURL, i, _windowSize)
                             ));
        }
        myProgressDelegate(1);
        downloading = false;
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="_url">Target URL</param>
    /// <param name="_localPath">Path to Local File</param>
    /// <param name="_resultAct">First int is Local File Size; Second int tells Remote File Size</param>
    /// <returns></returns>
    public IEnumerator DownloadBehaviourCheck(FileURL _fileUrl, Action <UnityWebRequestHelper.DownloadProcess, int, int> _resultAct)
    {
        int localFileSize = myFileIOHelper.CheckFileSize(_fileUrl.localPath);

        bool processed        = false;
        bool supportPartialDL = false;
        int  remoteFileSize   = -1;

        StartCoroutine(myUnityWebRequestHelper.CheckFileSize(_fileUrl.fullURL,
                                                             (int _val, bool _supportPartialDL) =>
        {
            remoteFileSize   = _val;
            supportPartialDL = _supportPartialDL;
            processed        = true;
        }
                                                             ));

        while (!processed)
        {
            yield return(null);
        }

        //check remote server support
        if (!supportPartialDL)
        {
            //not support partial download
            Debug.Log("Remote Server Not Support Partial Download");

            _resultAct(UnityWebRequestHelper.DownloadProcess.RedownloadFromBeginning, localFileSize, remoteFileSize);
            yield break;
        }

        _resultAct(DownloadBehaviourCheck(localFileSize, remoteFileSize), localFileSize, remoteFileSize);
    }
        public async Task <IActionResult> Create([Bind("StaticPartInfoId,DrawingNumber,ApproxWeight,SurfaceArea,PartDescription,ImageName,ImageFile,FinishDrawingFile,BlankDrawingFile,CustomerId,DrawingImageBytes")] StaticPartInfo staticPartInfo)
        {
            if (ModelState.IsValid)
            {
                staticPartInfo.StaticPartInfoId = Guid.NewGuid();

                if (staticPartInfo.ImageFile != null)
                {
                    staticPartInfo.DrawingImageBytes = await FileURL.GetFileBytes(staticPartInfo.ImageFile);
                }
                if (staticPartInfo.FinishDrawingFile != null)
                {
                    staticPartInfo.FinishDrawingPdfBytes = await FileURL.GetFileBytes(staticPartInfo.FinishDrawingFile);
                }
                if (staticPartInfo.BlankDrawingFile != null)
                {
                    staticPartInfo.BlankDrawingPdfBytes = await FileURL.GetFileBytes(staticPartInfo.BlankDrawingFile);
                }
                SetUIDs();
                await _repo.AddStaticPartInfo(staticPartInfo);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(staticPartInfo));
        }
        public async Task <IActionResult> Edit(WorkType workType, Guid id, [Bind("WorkItemId,StaticPartInfoId,StartDate,InvoiceDate,WorkId,WorkItemImageFile,WorkItemImageBytes,ProcessSheetNotesFile,ProcessSheetNotesPdfBytes,ClearWorkItemImg,IsInitialized")] WorkItem workItem)
        {
            if (id != workItem.WorkItemId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (workItem.WorkItemImageFile != null && !workItem.ClearWorkItemImg)
                {
                    workItem.WorkItemImageBytes = await FileURL.GetFileBytes(workItem.WorkItemImageFile);
                }
                else if (workItem.ClearWorkItemImg)
                {
                    workItem.WorkItemImageBytes = null;
                }
                if (workItem.ProcessSheetNotesFile != null)
                {
                    workItem.ProcessSheetNotesPdfBytes = await FileURL.GetFileBytes(workItem.ProcessSheetNotesFile);
                }

                SetUIDs();
                await _repo.UpdateWorkItem(workItem);

                return(RedirectToAction("Index", "WorkItems", new { workType = workType, workId = workItem.WorkId }));
            }
            ViewData["StaticPartInfoId"] = new SelectList(await _repo.GetAllStaticPartInfos(), "StaticPartInfoId", "PartDescription");
            ViewBag.WorkType             = workType;

            return(View(workItem));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Initialize([Bind("LineItemId,StaticPowderInfoId,VendorDescription,Weight,LineItemCost,ParticleSizeMin,ParticleSizeMax,PowderOrderId,NumBottles,CertPdfFile")] LineItem lineItem)
        {
            lineItem.StaticPowderInfo = await _repo.GetStaticPowderInfo((Guid)lineItem.StaticPowderInfoId);

            if (lineItem.CertPdfFile != null)
            {
                lineItem.CertPdfBytes = await FileURL.GetFileBytes(lineItem.CertPdfFile);
            }
            SetUIDs();
            await _repo.UpdateLineItem(lineItem);

            List <PowderBottle> bottles = new List <PowderBottle>();

            for (int i = 0; i < lineItem.NumBottles; i++)
            {
                bottles.Add(new PowderBottle
                {
                    PowderBottleId     = Guid.NewGuid(),
                    BottleNumber       = "",
                    LotNumber          = "",
                    InitWeight         = 0,
                    Weight             = 0,
                    LineItem           = lineItem,
                    LineItemId         = lineItem.LineItemId,
                    StaticPowderInfo   = lineItem.StaticPowderInfo,
                    StaticPowderInfoId = lineItem.StaticPowderInfo.StaticPowderInfoId
                });
            }
            SetUIDs();
            await _repo.AddPowderBottles(bottles);

            lineItem.PowderOrder = await _repo.GetPowderOrder(lineItem.PowderOrderId);

            return(RedirectToAction("Index", "LineItems", new { powderOrderId = lineItem.PowderOrderId }));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LinkItem"/> class.
        /// </summary>
        /// <param name="link">The link.</param>
        public LinkItem(Link link) : base(link.Source)
        {
            Release = link.Release;
            Quality = link.Quality;
            Size    = link.Size;
            InfoURL = link.InfoURL;
            FileURL = link.FileURL;
            Infos   = link.Infos;
            Color   = "White";

            if (!Signature.IsActivated)
            {
                return;
            }

            switch (Source.Type)
            {
            case Types.Torrent:
                if (Infos.StartsWith("0 seed") && Settings.Get("Fade Dead Torrents", true))
                {
                    Color = "#50FFFFFF";
                }
                else if (Infos.Contains("Free") && Settings.Get <bool>("Highlight Free Torrents"))
                {
                    Color = "GreenYellow";
                }
                break;

            case Types.Usenet:
                var ret = Settings.Get("Usenet Retention", 0);

                if (ret != 0 && Infos.Contains("day") && int.Parse(Infos.Replace(",", string.Empty).Split(" ".ToCharArray()).First()) > ret)
                {
                    Color = "#50FFFFFF";
                }
                break;

            case Types.DirectHTTP:
                var typ = Settings.Get("One-Click Hoster List Type", "white");
                var lst = Settings.Get <List <string> >("One-Click Hoster List");

                if (typ == "white")
                {
                    if (string.IsNullOrWhiteSpace(FileURL) || !lst.Any(d => FileURL.Contains(d)))
                    {
                        Color = "#50FFFFFF";
                    }
                }
                else if (typ == "black")
                {
                    if (string.IsNullOrWhiteSpace(FileURL) || lst.Any(d => FileURL.Contains(d)))
                    {
                        Color = "#50FFFFFF";
                    }
                }
                break;
            }
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("StaticPartInfoId,DrawingNumber,ApproxWeight,SurfaceArea,PartDescription,ImageName,ImageFile,DrawingImageBytes,ClearImg,FinishDrawingFile,FinishDrawingPdfBytes,ClearFinish,BlankDrawingFile,BlankDrawingPdfBytes,ClearBlank,CustomerId")] StaticPartInfo staticPartInfo)
        {
            if (id != staticPartInfo.StaticPartInfoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (staticPartInfo.ImageFile != null && !staticPartInfo.ClearImg)
                    {
                        staticPartInfo.DrawingImageBytes = await FileURL.GetFileBytes(staticPartInfo.ImageFile);
                    }
                    else if (staticPartInfo.ClearImg)
                    {
                        staticPartInfo.DrawingImageBytes = null;
                    }

                    if (staticPartInfo.FinishDrawingFile != null)
                    {
                        staticPartInfo.FinishDrawingPdfBytes = await FileURL.GetFileBytes(staticPartInfo.FinishDrawingFile);
                    }
                    if (staticPartInfo.ClearFinish)
                    {
                        staticPartInfo.FinishDrawingPdfBytes = null;
                    }

                    if (staticPartInfo.BlankDrawingFile != null)
                    {
                        staticPartInfo.BlankDrawingPdfBytes = await FileURL.GetFileBytes(staticPartInfo.BlankDrawingFile);
                    }
                    if (staticPartInfo.ClearBlank)
                    {
                        staticPartInfo.BlankDrawingPdfBytes = null;
                    }
                    SetUIDs();
                    await _repo.UpdateStaticPartInfo(staticPartInfo);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!(await StaticPartInfoExists(staticPartInfo.StaticPartInfoId)))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(staticPartInfo));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create(WorkType workType, [Bind("WorkId,QuoteId,EndlasNumber,WorkDescription,Status,PurchaseOrderNum,NumWorkItems,DueDate,StartDate,PoDate,CompleteDate,UserId,CustomerId,SystemConfigurationPdfFile")] Work work)
        {
            ViewBag.WorkType = workType;
            var vm       = new WorkViewModel();
            var workList = await _repo.GetWorkWithEndlasNumber(work.EndlasNumber);

            var quotes = await _repo.GetQuotesWithEndlasNumber(work.EndlasNumber);

            if (workList.Any() || quotes.Count() > 1)
            {
                ViewBag.EndlasNumberConflict = true;
                ViewData["CustomerId"]       = new SelectList(await _repo.GetAllCustomers(), "CustomerId", "CustomerName");
                return(View(work));
            }
            if (ModelState.IsValid)
            {
                if (work.QuoteId == null && workType == WorkType.Job)
                {
                    ViewBag.NoQuoteWarning = true;
                    return(View(work));
                }
                work.WorkId = Guid.NewGuid();

                if (work.SystemConfigurationPdfFile != null)
                {
                    work.SystemConfigurationPdfBytes = await FileURL.GetFileBytes(work.SystemConfigurationPdfFile);
                }
                SetUIDs();

                if (workType == WorkType.Job)
                {
                    var quote = await _repo.GetQuote((Guid)work.QuoteId);

                    work.EndlasNumber = quote.EndlasNumber;
                    await _repo.AddJob(Job.CastWorkToJob(work));
                }
                else if (workType == WorkType.WorkOrder)
                {
                    await _repo.AddWorkOrder(WorkOrder.CastWorkToWorkOrder(work));
                }

                for (int i = 0; i < work.NumWorkItems; i++)
                {
                    WorkItem workItem = new WorkItem {
                        WorkItemId = Guid.NewGuid(), WorkId = work.WorkId
                    };
                    await _repo.AddWorkItem(workItem);
                }
                return(RedirectToAction(nameof(Index), new { workType = workType }));
            }
            await SetViewData();

            vm = new WorkViewModel(work, workType);
            return(View(vm));
        }
 private static MachiningToolForWork SetImageUrls(MachiningToolForWork machiningToolForWork)
 {
     if (machiningToolForWork.MachiningTool.ToolingImageBytes != null)
     {
         machiningToolForWork.MachiningTool.ToolingImageUrl = FileURL.GetImageUrl(machiningToolForWork.MachiningTool.ToolingImageBytes);
     }
     if (machiningToolForWork.WorkItem.StaticPartInfo.DrawingImageBytes != null)
     {
         machiningToolForWork.WorkItem.StaticPartInfo.ImageUrl = FileURL.GetImageUrl(machiningToolForWork.WorkItem.StaticPartInfo.DrawingImageBytes);
     }
     return(machiningToolForWork);
 }
        // GET: StaticPartInfoes
        public async Task <IActionResult> Index()
        {
            // get list of all static part information
            var staticPartInfos = await _repo.GetAllStaticPartInfos();

            // setup image url for each row
            foreach (StaticPartInfo partInfo in staticPartInfos)
            {
                FileURL.SetImageUrl(partInfo);
            }
            return(View(staticPartInfos));
        }
        // GET: MachiningTools
        public async Task <IActionResult> Index()
        {
            var tools = await _repo.GetAllMachiningTools();

            foreach (MachiningTool tool in tools)
            {
                if (tool.ToolingImageBytes != null)
                {
                    tool.ToolingImageUrl = FileURL.GetImageUrl(tool.ToolingImageBytes);
                }
            }
            return(View(tools));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Checks whether this link is available.
        /// </summary>
        public void CheckLink()
        {
            if (string.IsNullOrWhiteSpace(FileURL))
            {
                return;
            }

            var checker = Extensibility.GetNewInstances <LinkCheckerEngine>().FirstOrDefault(x => x.CanCheck(FileURL));

            if (checker == null)
            {
                return;
            }

            var inf = Infos;

            if (!string.IsNullOrWhiteSpace(inf))
            {
                inf += ", ";
            }

            Infos = inf + "Checking...";
            MainWindow.Active.Run(() => { try { PropertyChanged(this, new PropertyChangedEventArgs("Infos")); } catch { } });

            try
            {
                var result = checker.Check(FileURL.Split('\0').First());

                if (!result)
                {
                    Color = "#50FFFFFF";
                }

                Infos = inf + "Link is " + (result ? "online" : "broken");
                MainWindow.Active.Run(() =>
                {
                    try
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs("Infos"));
                        PropertyChanged(this, new PropertyChangedEventArgs("Color"));
                    } catch { }
                });
            }
            catch
            {
                Infos = inf + "Check error";
                MainWindow.Active.Run(() => { try { PropertyChanged(this, new PropertyChangedEventArgs("Infos")); } catch { } });
            }
        }
        public async Task <IActionResult> Create([Bind("StaticPowderInfoId,EndlasDescription,Density,Description,EstCostPerLb,Composition,FlowRateSlope,FlowRateYIntercept,InformationFile")] StaticPowderInfo staticPowderInfo)
        {
            if (ModelState.IsValid)
            {
                staticPowderInfo.StaticPowderInfoId = Guid.NewGuid();
                if (staticPowderInfo.InformationFile != null)
                {
                    staticPowderInfo.InformationFilePdfBytes = await FileURL.GetFileBytes(staticPowderInfo.InformationFile);
                }
                SetUIDs();
                await _repo.AddStaticPowderInfo(staticPowderInfo);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(staticPowderInfo));
        }
        public async Task <IActionResult> Uninitialize(WorkType workType, Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var vm = await CreateWorkItemViewModel(id);

            FileURL.SetImageUrl(vm.WorkItem.StaticPartInfo);

            if (vm.WorkItem.WorkItemImageBytes != null)
            {
                vm.WorkItem.WorkItemImageUrl = FileURL.GetImageUrl(vm.WorkItem.WorkItemImageBytes);
            }
            ViewBag.WorkType = workType;
            return(View(vm));
        }
        public async Task <IActionResult> Create([Bind("PartForWork,PartForWorkId,ImageName,ImageFile,ClearImg,ImageBytes")] PartForWork partForWork)
        {
            if (ModelState.IsValid)
            {
                partForWork.PartForWorkId = Guid.NewGuid();

                if (partForWork.WorkItem.WorkItemImageFile != null)
                {
                    partForWork.WorkItem.WorkItemImageBytes = await FileURL.GetFileBytes(partForWork.WorkItem.WorkItemImageFile);
                }
                SetUIDs();
                await _repo.AddPartForWork(partForWork);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StaticPartInfoId"] = new SelectList(await _repo.GetAllStaticPartInfos(), "StaticPartInfoId", "DrawingNumber", partForWork.WorkItem.StaticPartInfoId);
            return(View(partForWork));
        }
        // GET: MachiningTools/Delete/5
        public async Task <IActionResult> Delete(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var machiningTool = (MachiningTool)await _repo.GetMachiningTool(id);

            if (machiningTool == null)
            {
                return(NotFound());
            }
            if (machiningTool.ToolingImageBytes != null)
            {
                machiningTool.ToolingImageUrl = FileURL.GetImageUrl(machiningTool.ToolingImageBytes);
            }
            return(View(machiningTool));
        }
        public async Task <IActionResult> Create([Bind("MachiningToolId,ToolType,ToolDiameter,RadialMetric,Units,ToolDescription,VendorDescription,InitToolCount,ToolCount,PurchaseOrderNum,PurchaseOrderDate,PurchaseOrderCost,InvoiceNumber,VendorId,ToolingImageFile,ToolingImageBytes")] MachiningTool machiningTool)
        {
            if (ModelState.IsValid)
            {
                machiningTool.MachiningToolId = Guid.NewGuid();
                // default tool count to the initial tool count
                machiningTool.ToolCount = machiningTool.InitToolCount;
                if (machiningTool.ToolingImageFile != null)
                {
                    machiningTool.ToolingImageBytes = await FileURL.GetFileBytes(machiningTool.ToolingImageFile);
                }
                SetUIDs();
                await _repo.AddMachiningTool(machiningTool);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VendorId"] = new SelectList(await _repo.GetAllVendors(), "VendorId", "VendorName", machiningTool.VendorId);
            return(View(machiningTool));
        }
        public async Task <IActionResult> Edit(WorkType workType, Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var workItem = await _repo.GetWorkItem(id);

            if (workItem.WorkItemImageBytes != null)
            {
                workItem.WorkItemImageUrl = FileURL.GetImageUrl(workItem.WorkItemImageBytes);
            }

            ViewData["StaticPartInfoId"] = new SelectList(await _repo.GetAllStaticPartInfos(), "StaticPartInfoId", "PartDescription");
            ViewBag.WorkType             = workType;

            return(View(workItem));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("PartForWorkId,WorkItemId,WorkItem,Suffix,ConditionDescription,InitialWeight,CladdedWeight,FinishedWeight,ProcessingNotes,ImageName,ImageFile,ClearImg,ImageBytes")] PartForWork partForWork)
        {
            if (id != partForWork.PartForWorkId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (partForWork.WorkItem != null)
                    {
                        if (partForWork.WorkItem.WorkItemImageFile != null)
                        {
                            partForWork.WorkItem.WorkItemImageBytes = await FileURL.GetFileBytes(partForWork.WorkItem.WorkItemImageFile);
                        }
                        else if (partForWork.WorkItem.ClearWorkItemImg)
                        {
                            partForWork.WorkItem.WorkItemImageBytes = null;
                        }
                    }

                    SetUIDs();
                    await _repo.UpdatePartForWork(partForWork);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PartForWorkExists(partForWork.PartForWorkId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StaticPartInfoId"] = new SelectList(await _repo.GetAllStaticPartInfos(), "StaticPartInfoId", "DrawingNumber", partForWork.WorkItem.StaticPartInfoId);
            return(View(partForWork));
        }
        // GET: PartForWork/Delete/5
        public async Task <IActionResult> Delete(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var partForWork = await _repo.GetPartForWork(id);

            if (partForWork == null)
            {
                return(NotFound());
            }

            if (partForWork.WorkItem.WorkItemImageBytes != null)
            {
                partForWork.WorkItem.WorkItemImageUrl = FileURL.GetImageUrl(partForWork.WorkItem.WorkItemImageBytes);
            }
            return(View(partForWork));
        }
        public async Task <IActionResult> Details(WorkType workType, Guid id)
        {
            var workItem = await _repo.GetWorkItem(id);

            if (workItem == null)
            {
                return(NotFound());
            }
            var vm = await CreateWorkItemViewModel(id);

            FileURL.SetImageUrl(vm.WorkItem.StaticPartInfo);
            if (vm.WorkItem.WorkItemImageBytes != null)
            {
                vm.WorkItem.WorkItemImageUrl = FileURL.GetImageUrl(vm.WorkItem.WorkItemImageBytes);
            }
            ViewBag.WorkType = workType;
            ViewBag.Log      = await _repo.GetActivityLog(id);

            return(View(vm));
        }
        private PartForWork SetImageUrls(PartForWork partForWork)
        {
            if (partForWork.MachiningImageBytes != null)
            {
                partForWork.MachiningImageUrl = FileURL.GetImageUrl(partForWork.MachiningImageBytes);
            }
            if (partForWork.CladdingImageBytes != null)
            {
                partForWork.CladdingImageUrl = FileURL.GetImageUrl(partForWork.CladdingImageBytes);
            }
            if (partForWork.FinishedImageBytes != null)
            {
                partForWork.FinishedImageUrl = FileURL.GetImageUrl(partForWork.FinishedImageBytes);
            }
            if (partForWork.UsedImageBytes != null)
            {
                partForWork.UsedImageUrl = FileURL.GetImageUrl(partForWork.UsedImageBytes);
            }

            return(partForWork);
        }
        // GET: StaticPartInfoes/Edit/5
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var staticPartInfo = await _repo.GetStaticPartInfo(id);

            if (staticPartInfo == null)
            {
                return(NotFound());
            }

            if (staticPartInfo.DrawingImageBytes != null)
            {
                FileURL.SetImageUrl(staticPartInfo);
            }
            ViewBag.id = id;
            return(View(staticPartInfo));
        }
        // GET: MachiningTools/Details/5
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var machiningTool = (MachiningTool)await _repo.GetMachiningToolNoTracking(id);

            if (machiningTool == null)
            {
                return(NotFound());
            }
            ViewData["VendorId"] = new SelectList(await _repo.GetAllVendors(), "VendorId", "VendorName", machiningTool.VendorId);
            if (machiningTool.ToolingImageBytes != null)
            {
                machiningTool.ToolingImageUrl = FileURL.GetImageUrl(machiningTool.ToolingImageBytes);
            }
            ViewBag.Log = await _repo.GetActivityLog(id);

            return(View(machiningTool));
        }
        // GET: PartForWork/Edit/5
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var partForWork = await _repo.GetPartForWork(id);

            if (partForWork == null)
            {
                return(NotFound());
            }

            if (partForWork.WorkItem.WorkItemImageBytes != null)
            {
                partForWork.WorkItem.WorkItemImageUrl = FileURL.GetImageUrl(partForWork.WorkItem.WorkItemImageBytes);
            }
            ViewData["StaticPartInfoId"] = new SelectList(await _repo.GetAllStaticPartInfos(), "StaticPartInfoId", "DrawingNumber", partForWork.WorkItem.StaticPartInfoId);
            return(View(partForWork));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("MachiningToolId,ToolType,ToolDiameter,RadialMetric,Units,ToolDescription,VendorDescription,InitToolCount,ToolCount,PurchaseOrderNum,PurchaseOrderDate,PurchaseOrderCost,InvoiceNumber,VendorId,ToolingImageFile,ClearToolingImage,ToolingImageBytes")] MachiningTool machiningTool)
        {
            if (id != machiningTool.MachiningToolId)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    if (machiningTool.ToolingImageFile != null)
                    {
                        machiningTool.ToolingImageBytes = await FileURL.GetFileBytes(machiningTool.ToolingImageFile);
                    }
                    else if (machiningTool.ClearToolingImage)
                    {
                        machiningTool.ToolingImageBytes = null;
                    }



                    SetUIDs();
                    await _repo.UpdateMachiningTool(machiningTool);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!(await MachiningToolExists(machiningTool.MachiningToolId)))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VendorId"] = new SelectList(await _repo.GetAllVendors(), "VendorId", "VendorName", machiningTool.VendorId);
            return(View(machiningTool));
        }
        // GET: StaticPartInfoes/Details/5
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var staticPartInfo = (StaticPartInfo)await _repo.GetStaticPartInfo(id);

            if (staticPartInfo == null)
            {
                return(NotFound());
            }
            // set the part info's image url for rendering
            FileURL.SetImageUrl(staticPartInfo);
            ViewBag.id           = id;
            ViewBag.HasBlankPdf  = staticPartInfo.BlankDrawingPdfBytes;
            ViewBag.HasFinishPdf = staticPartInfo.FinishDrawingPdfBytes;
            ViewBag.Log          = await _repo.GetActivityLog(id);

            return(View(staticPartInfo));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("StaticPowderInfoId,EndlasDescription,Density,Description,EstCostPerLb,Composition,ClearInformation,FlowRateSlope,FlowRateYIntercept,InformationFile")] StaticPowderInfo staticPowderInfo)
        {
            if (id != staticPowderInfo.StaticPowderInfoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (staticPowderInfo.ClearInformation)
                    {
                        staticPowderInfo.InformationFilePdfBytes = null;
                    }
                    else if (staticPowderInfo.InformationFile != null)
                    {
                        staticPowderInfo.InformationFilePdfBytes = await FileURL.GetFileBytes(staticPowderInfo.InformationFile);
                    }
                    SetUIDs();
                    await _repo.UpdateStaticPowderInfo(staticPowderInfo);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!(await StaticPowderInfoExists(staticPowderInfo.StaticPowderInfoId)))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(staticPowderInfo));
        }
Exemplo n.º 29
0
 public async Task <IActionResult> Edit(Guid id, [Bind("LineItemId,LineItem,CertPdfBytes")] LineItemViewModel lineItemVm)
 {
     if (id != lineItemVm.LineItemId)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             if (lineItemVm.LineItem.CertPdfFile != null)
             {
                 lineItemVm.LineItem.CertPdfBytes = await FileURL.GetFileBytes(lineItemVm.LineItem.CertPdfFile);
             }
             if (lineItemVm.ClearCertPdf)
             {
                 lineItemVm.LineItem.CertPdfBytes = null;
             }
             SetUIDs();
             await _repo.UpdateLineItem(lineItemVm.LineItem);
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!(await LineItemExists(lineItemVm.LineItemId)))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction("Index", "LineItems", new { powderOrderId = lineItemVm.LineItem.PowderOrderId }));
     }
     return(View(lineItemVm));
 }
        // GET: MachiningTools/Edit/5
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var machiningTool = await _repo.FindMachiningTool(id);

            if (machiningTool == null)
            {
                return(NotFound());
            }

            if (machiningTool.ToolingImageBytes != null)
            {
                machiningTool.ToolingImageUrl = FileURL.GetImageUrl(machiningTool.ToolingImageBytes);
            }

            ViewBag.id = id;

            ViewData["VendorId"] = new SelectList(await _repo.GetAllVendors(), "VendorId", "VendorName", machiningTool.VendorId);
            return(View(machiningTool));
        }