public ObservableCollection <DocumentVM> ConvertDocumentToDocumentVM(List <Document> docs)
        {
            List <DocumentVM> result = new List <DocumentVM>();

            foreach (Document doc in docs)
            {
                doc.company = ServiceFunctions.CompanyRenamer(doc.company);
                result.Add(new DocumentVM(doc));
            }
            return(new ObservableCollection <DocumentVM>(result));
        }
Ejemplo n.º 2
0
        private void AttachContract()
        {
            AppJournal.Write("Company", "Attach contract", true);

            if (SelectedContract != null && SelectedContract.id > 0)
            {
                try
                {
                    sourceFileName = Service.GetFile("Выберите файл договора", "(*.*) | *.*").FullName;
                }
                catch (Exception) { }

                if (!string.IsNullOrEmpty(sourceFileName))
                {
                    newFileName  = FolderExplorer.GetCompanyPath(Company.bin);
                    newFileName += "Договор " + SelectedContract.number.Replace("/", "_").Replace("\\", "_") + " с " + ServiceFunctions.CompanyRenamer(Company.name) + sourceFileName.Substring(sourceFileName.LastIndexOf("."));

                    if (Service.CopyFile(sourceFileName, newFileName, true))
                    {
                        try
                        {
                            DocumentRequisite docReq = new DocumentRequisite()
                            {
                                date     = DateTime.Now,
                                fileName = newFileName.Substring(newFileName.LastIndexOf("\\") + 1),
                                number   = Company.bin,
                                section  = AltaBO.specifics.DocumentSectionEnum.Company,
                                type     = AltaBO.specifics.DocumentTypeEnum.Contract
                            };

                            DataBaseClient.UpdateContractFile(SelectedContract.id, archiveManager.SaveFile(docReq));
                            MessagesService.Show("АРХИВ", "Файл скопирован в архив.");
                            UpdateContractList();
                        }
                        catch (Exception ex)
                        {
                            MessagesService.Show("АРХИВ", "При занесении файла в базу произошла ошибка");
                            AppJournal.Write("Company", "Put contract into db error :" + ex.ToString(), true);
                        }
                    }
                    else
                    {
                        MessagesService.Show("ОШИБКА", "Проверьте доступ к архиву.");
                    }
                }
            }
            else
            {
                MessagesService.Show("Работа с договором", "Не выбран договор");
            }
        }