Exemplo n.º 1
0
        private async void SubmitITR()
        {
            bool retvalue = false;
            List<QaqcformDTO> ReadyDto = new List<QaqcformDTO>();
            List<QaqcformtemplateDTO> NotReadyToSubmit = new List<QaqcformtemplateDTO>();
            List<QaqcformtemplateDTO> ReadyToSubmit = new List<QaqcformtemplateDTO>();
            string filename = "";
            WinAppLibrary.Utilities.Helper helper = new WinAppLibrary.Utilities.Helper();

            try
            {
                if (_ofiles.Count > 0)
                {
                    ReadyToSubmit = _ofiles.Where(x => x.QAQCFormCode == "3").ToList();
                    NotReadyToSubmit = _ofiles.Where(x => x.QAQCFormCode != "3").ToList();
                }
                //Search : Ready To Sumbmit List 
                foreach (QaqcformtemplateDTO item in ReadyToSubmit)
                {
                    QaqcformDTO dto = new QaqcformDTO();
                    filename = item.QAQCFormTemplateID.ToString() + "_" + item.QAQCTypeLUID.ToString() + ".xml";
                    dto = await LoadToQaqcform(filename);
                    if (item.DTOStatus != (int)WinAppLibrary.Utilities.RowStatus.Delete)
                    {
                        dto.UpdatedDate = DateTime.Now;
                        dto.UpdatedBy = Login.UserAccount.UserName;
                        dto.IsSubmitted = 1;  //0=Download / 1=Submit
                        dto.DTOStatus = (int)WinAppLibrary.Utilities.RowStatus.Update;
                    }
                    ReadyDto.Add(dto);
                }

                //Save To Server
                retvalue = await _FillOutSubmitITR.SaveQaqcformForSubmit(ReadyDto);

                //Delete Files
                foreach (QaqcformtemplateDTO item in _ofiles.Where(x => x.QAQCFormCode == "3"))
                {
                    filename = item.QAQCFormTemplateID.ToString() + "_" + item.QAQCTypeLUID.ToString() + ".xml";
                    await helper.DeleteFileStream(BaseFolder, filename);
                }

                //Update FileList
                await SaveToQaqcformtemplate(NotReadyToSubmit, BaseFolder, Lib.ITRList.DownloadList);

                BindList();

                WinAppLibrary.Utilities.Helper.SimpleMessage("Submit Complete", "Complete!");
            }
            catch (Exception ex)
            {
                (new WinAppLibrary.Utilities.Helper()).ExceptionHandler(ex, "SubmitITR");
            }
                        
        }
Exemplo n.º 2
0
        private async void RemoveITR()
        {
            List<QaqcformDTO> removeDto = new List<QaqcformDTO>();
            List<QaqcformtemplateDTO> forKeep =new List<QaqcformtemplateDTO>();
            List<QaqcformtemplateDTO> forRemove = new List<QaqcformtemplateDTO>();
            string filename = "";
            WinAppLibrary.Utilities.Helper helper = new WinAppLibrary.Utilities.Helper();

            try
            {
                if (gvDocument.SelectedItems.Count > 0)
                {
                    List<QaqcformtemplateDTO> targets = (List<QaqcformtemplateDTO>)gvDocument.SelectedItems;

                    if (_ofiles.Count <= 0)
                    {
                        return;
                    }

                    forRemove = _ofiles.Intersect(targets).ToList();  // 삭제
                    forKeep = _ofiles.Except(targets).ToList();  // 유지

                    foreach (QaqcformtemplateDTO data in _ofiles)
                    {
                        if (targets.Contains(data) == true)
                        {
                            QaqcformDTO dto = new QaqcformDTO();
                            filename = data.QAQCFormTemplateID.ToString() + "_" + data.QAQCTypeLUID.ToString() + ".xml";
                            dto = await LoadToQaqcform(filename);
                            dto.UpdatedDate = DateTime.Now;
                            dto.UpdatedBy = Login.UserAccount.UserName;
                            dto.DTOStatus = (int)WinAppLibrary.Utilities.RowStatus.Delete;  // QaqcformDTO Delete mark
                            dto.QaqcfromDetails.Select(c => { c.DTOStatus = (int)WinAppLibrary.Utilities.RowStatus.Delete; return c; });  // QaqcformdetailDTO Delete mark

                            removeDto.Add(dto);

                            data.DTOStatus = (int)WinAppLibrary.Utilities.RowStatus.Delete;
                            data.QAQCFormCode = "3";  // Status for Submit

                            // Update local file
                            await SaveToQaqcForm(dto, BaseFolder, filename);
                        }
                    }

                    switch (Login.LoginMode)
                    {
                        // OnMode일 때 서버로 내용 전달하고 file 삭제 / List 갱신
                        case WinAppLibrary.UI.LogMode.OnMode:
                            //Save To Server
                            await _FillOutSubmitITR.SaveQaqcformForSubmit(removeDto);

                            // Delete files
                            foreach (QaqcformtemplateDTO item in forRemove)
                            {
                                filename = item.QAQCFormTemplateID.ToString() + "_" + item.QAQCTypeLUID.ToString() + ".xml";
                                await helper.DeleteFileStream(BaseFolder, filename);
                            }

                            // Update for keep FileList
                            await SaveToQaqcformtemplate(forKeep, BaseFolder, Lib.ITRList.DownloadList);
                            break;
                        case WinAppLibrary.UI.LogMode.OffMode:
                            // Update for All FileList
                            await SaveToQaqcformtemplate(_ofiles, BaseFolder, Lib.ITRList.DownloadList);
                            break;
                    }

                    BindList();

                    WinAppLibrary.Utilities.Helper.SimpleMessage("Remove Complete", "Complete!");
                }
            }
            catch (Exception ex)
            {
                (new WinAppLibrary.Utilities.Helper()).ExceptionHandler(ex, "btnRemove_Click");
            }
        }