Example #1
0
        private void OnCreated(object source, FileSystemEventArgs e)
        {
            var folderExplorer = new FolderExplorer();

            if (folderExplorer.IsExists(e.FullPath))
            {
                return;
            }

            using Aes tempAes = Aes.Create();

            using var createdFileReader = new StreamReader(e.FullPath);
            var sourceText = createdFileReader.ReadToEnd();

            // get encrypted text
            var encryptedText = Encryption.Encrypt(sourceText, tempAes.Key, tempAes.IV);

            Console.WriteLine(tempAes.Key);

            // create a file in target directory and write encrypted byte array there
            var fileExplorer     = new FileExplorer();
            var pathToTargetFile = (string)EnvSettings.Env.TARGET_DIRECTORY + "/" + fileExplorer.GenerateExtractFileName(e.FullPath);
            var transferFile     = (FileStream)fileExplorer.Create(pathToTargetFile);

            transferFile.Write(encryptedText);
            transferFile.Dispose();

            Console.WriteLine(tempAes.Key);

            // decrypt the file
            var decryptedText = Encryption.Decrypt(File.ReadAllBytes(pathToTargetFile), tempAes.Key, tempAes.IV);

            File.WriteAllText(pathToTargetFile, decryptedText);
        }
Example #2
0
        public Form1()
        {
            InitializeComponent();

            _filesForm = new FilesForm();
            _filesForm.FileSelectionChanged += _filesForm_FileSelectionChanged;
            _filesForm.Show(dockPanel1);

            _explorer = new FolderExplorer();
            _explorer.FolderLocationChanged += explorer_FolderLocationChanged;
            _explorer.Show(dockPanel1, DockState.DockLeft);

            _errors = new ErrorsForm();
            _errors.Show(dockPanel1, DockState.DockBottom);

            _descriptionForm = new DescriptionForm();
            _descriptionForm.Show(dockPanel1, DockState.DockRight);

            var dirToOpen = Settings.Default.LastViewedDirectory;

            if (String.IsNullOrEmpty(dirToOpen))
            {
                dirToOpen = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            }

            OpenDirectory(dirToOpen);
            Descriptors = new List <IDescriptor>();
            LoadDescriptors();
        }
Example #3
0
        public static void InitializeTargetFolder(string path)
        {
            FolderExplorer folder = new FolderExplorer();

            if (!folder.IsExists(path))
            {
                folder.Create(path);
            }
        }
        private void SearchMainFolderPathButton_Click(object sender, RoutedEventArgs e)
        {
            FolderExplorer folder = new FolderExplorer();
            string         path   = folder.Open();

            if (!path.Equals(string.Empty))
            {
                SourceToMainFolderTextBox.Text = path;
                isDataDirty = true;
            }
        }
Example #5
0
 private void OpenFolder()
 {
     if (Company != null && Company.id > 0)
     {
         FolderExplorer.OpenCompanyFolder(Company.bin);
     }
     else
     {
         MessagesService.Show("Открытие папки", "Компании не существует или не сохранена");
     }
 }
        private void FormateAct()
        {
            if (ReconcilationsList.Count > 0)
            {
                // Variables info
                string path         = "";
                string templateFile = "";
                string templatePath = @"\\192.168.11.5\Archive\Templates\ForAll\ReconcilationAct.docx";

                // Get path to save template
                try {
                    path = Service.GetDirectory().FullName;
                } catch { path = ""; }

                if (!string.IsNullOrEmpty(path))
                {
                    // Get template file
                    templateFile = path + "\\Акт сверки для компании " + SelectedSupplier.companyName.Replace("\"", "'") + " за " + EndDate.ToShortDateString() + ".docx";

                    if (Service.CopyFile(templatePath, templateFile, true))
                    {
                        // Convert info
                        Broker broker = new Broker()
                        {
                            Name       = SelectedBroker.name,
                            Requisites = SelectedBroker.company.bin
                        };

                        Supplier supplier = new Supplier()
                        {
                            Name = SelectedSupplier.companyName,
                            BIN  = SelectedSupplier.companyBin
                        };

                        // Fill template file with info
                        try {
                            ReconcilationActService.FormateAct(StartDate, EndDate, broker, supplier, ReconcilationsList, templateFile);

                            // Open folder with file
                            FolderExplorer.OpenFolder(path + "\\");
                        } catch (Exception ex) { MessagesService.Show("Оповещение", "Произошла ошибка во время формирования акта\n" + ex.ToString()); }
                    }
                    else
                    {
                        MessagesService.Show("Оповещение", "Произошла ошибка во время копирования шаблона");
                    }
                }
            }
            else
            {
                MessagesService.Show("Оповещение", "Нет данных для формирования");
            }
        }
    public void BrowseSaveLocation()
    {
        Action <string> onComplete = (string path) =>
        {
            if (path != null)
            {
                SavePathField.text = path;
            }
        };

        FolderExplorer.BrowseFolder(onComplete);
    }
Example #8
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("Работа с договором", "Не выбран договор");
            }
        }
        private void FinalReportAllPLMT()
        {
            // Variables info
            string path         = "";
            string templateFile = "";
            string templatePath = @"\\192.168.11.5\Archive\Templates\ForAll\FinalReportPolyMetall.xlsx";

            // Get path to save template
            try {
                path = Service.GetDirectory().FullName;
            } catch { path = ""; }

            if (!string.IsNullOrEmpty(path))
            {
                // Get template file
                templateFile = path + "\\Отчет по прошедшим с " + StartDate.ToShortDateString() + " по " + EndDate.ToShortDateString() + ".xlsx";

                if (Service.CopyFile(templatePath, templateFile, true))
                {
                    // Get info from base
                    try {
                        var finalReportPlmtl = dataManager.GetFinalReportPlmtl(StartDate, EndDate);

                        if (finalReportPlmtl != null && finalReportPlmtl.Count > 0)
                        {
                            // Create report document
                            TechSpecReportService.CreateDocument(finalReportPlmtl, templateFile);
                            // Open folder with file
                            FolderExplorer.OpenFolder(path + "\\");
                        }
                        else
                        {
                            Service.DeleteFile(templateFile);
                            MessagesService.Show("Оповещение", "На эти даты записей нет");
                        }
                    } catch (Exception ex) { MessagesService.Show("Оповещение", "Произошла ошибка во время формирования отчета\n" + ex.ToString()); }
                }
                else
                {
                    MessagesService.Show("Оповещение", "Произошла ошибка во время копирования шаблона");
                }
            }
        }
        private void SaveInExcel()
        {
            if (DealNumbersList.Count > 0)
            {
                // Variables info
                string path         = "";
                string templateFile = "";
                string templatePath = @"\\192.168.11.5\Archive\Templates\ForAll\FinalReport.xlsx";

                // Get path to save template
                try {
                    path = Service.GetDirectory().FullName;
                } catch { path = ""; }

                if (!string.IsNullOrEmpty(path))
                {
                    // Get template file
                    templateFile = path + "\\Финальный отчет с " + FromDate.ToShortDateString() + " по " + ToDate.ToShortDateString() + ".xlsx";

                    if (Service.CopyFile(templatePath, templateFile, true))
                    {
                        // Fill template file with info
                        try {
                            FinalReportService.FormateDocument(templateFile, DealNumbersList);

                            // Open folder with file
                            FolderExplorer.OpenFolder(path + "\\");
                        } catch (Exception ex) { MessagesService.Show("Оповещение", "Произошла ошибка во время формирования отчета\n" + ex.ToString()); }
                    }
                    else
                    {
                        MessagesService.Show("Оповещение", "Произошла ошибка во время копирования шаблона");
                    }
                }
            }
            else
            {
                MessagesService.Show("Оповещение", "Нет данных для формирования");
            }
        }
        private void TechSpecReport(int type)
        {
            // Check for info for choosed data
            var lotExtended = DataBaseClient.ReadLotsExtended(StartDate, EndDate);

            if (lotExtended != null && lotExtended.Count > 0)
            {
                // Variables info
                string path         = "";
                string templateFile = "";
                string templatePath = @"\\192.168.11.5\Archive\Templates\ETS\TechSpecReport.xlsx";

                // Get path to save template
                try {
                    path = Service.GetDirectory().FullName;
                } catch { path = ""; }

                if (!string.IsNullOrEmpty(path))
                {
                    // Get template file
                    templateFile = path + "\\Отчет по тех. спец. с " + StartDate.ToShortDateString() + " по " + EndDate.ToShortDateString() + ".xlsx";

                    if (Service.CopyFile(templatePath, templateFile, true))
                    {
                        // Fill template file with info
                        try {
                            // Convert EF to BO
                            var techSpecReports = DataBaseClient.ReadTechSpecReport(1, StartDate, EndDate, new List <int>()
                            {
                                4
                            }, type == 1 ? new List <int>()
                            {
                                2
                            } : new List <int>()
                            {
                                2, 3, 4
                            });

                            if (techSpecReports != null && techSpecReports.Count > 1)
                            {
                                // Create report document
                                TechSpecReportService.CreateDocument(techSpecReports, templateFile);

                                // Open folder with file
                                FolderExplorer.OpenFolder(path + "\\");
                            }
                            else
                            {
                                MessagesService.Show("Оповещение", "На эти даты записей нет");
                            }
                        } catch (Exception ex) { MessagesService.Show("Оповещение", "Произошла ошибка во время формирования отчета\n" + ex.ToString()); }
                    }
                    else
                    {
                        MessagesService.Show("Оповещение", "Произошла ошибка во время копирования шаблона");
                    }
                }
            }
            else
            {
                MessagesService.Show("Оповещение", "Нет данных для формирования");
            }
        }
Example #12
0
        private void CreateBackMoneyTransfer()
        {
            // Log service
            AppJournal.Write("BackMoneyTransfer", "Create back money transfer documents", true);

            // Check for selected transaction
            if (SelectedClearingCount != null && SelectedClearingCount.statusid != 10)
            {
                // Get templates & copy to auction directory
                var fromCount = DataBaseClient.ReadSuppliersJournals(SelectedClearingCount.tosupplierid, SelectedClearingCount.brokerid);
                var toCount   = DataBaseClient.ReadSuppliersJournals(SelectedClearingCount.fromsupplierid, SelectedClearingCount.brokerid);

                DocumentRequisite docMoneyTransferReq = new DocumentRequisite()
                {
                    fileName = "Заявление на возврат из КЦ №" + SelectedClearingCount.lot.auction.number.Replace("/", "_") + " (c " + fromCount[0].code + " на " + toCount[0].code + ").docx",
                    market   = MarketPlaceEnum.ETS,
                    date     = SelectedClearingCount.lot.auction.date,
                    number   = SelectedClearingCount.lot.auction.number
                };

                var moneyTransferTemplateFile = archiveManager.GetTemplate(docMoneyTransferReq, DocumentTemplateEnum.MoneyTransfer);

                // Fill order with needed data
                Order order = new Order();
                order.Auction = new Auction();
                order.Auction.SupplierOrders = new System.Collections.ObjectModel.ObservableCollection <SupplierOrder>();

                order.Auction.SupplierOrders.Add(new SupplierOrder()
                {
                    BrokerName = SelectedClearingCount.broker.name,
                    BrokerCode = fromCount[0].code,
                    Code       = toCount[0].code
                });

                order.Auction.Lots = new System.Collections.ObjectModel.ObservableCollection <Lot>();

                order.Auction.Lots.Add(new Lot()
                {
                    Number = SelectedClearingCount.lot.number
                });

                // Formate money transfer document & open folder with new document
                if (MoneyTransferService.CreateDocument(order, moneyTransferTemplateFile, SelectedClearingCount.transaction))
                {
                    FolderExplorer.OpenAuctionFolder(MarketPlaceEnum.ETS, SelectedClearingCount.lot.auction.date.ToShortDateString(), SelectedClearingCount.lot.auction.number);

                    // Put records in base
                    ClearingCountingEF clearingCounting = new ClearingCountingEF()
                    {
                        brokerid       = SelectedClearingCount.brokerid,
                        fromsupplierid = fromCount[0].supplierid,
                        tosupplierid   = toCount[0].supplierid,
                        lotid          = SelectedClearingCount.lotid,
                        transaction    = SelectedClearingCount.transaction,
                        createdate     = DateTime.Now,
                        statusid       = 10
                    };

                    if (DataBaseClient.CreateClearingCounting(clearingCounting) == 0)
                    {
                        MessagesService.Show("Заявление об изменении денежных средств", "Произошла ошибка при занесении данных в базу");
                        AppJournal.Write("MoneyTransfer", "Fault when create record in base", true);
                    }
                    else
                    {
                        DataBaseClient.UpdateClearingCountStatus(toCount[0].supplierid, fromCount[0].supplierid, SelectedClearingCount.lotid);
                    }

                    Apply(0);
                }
                else
                {
                    MessagesService.Show("Заявление об изменении денежных средств", "Произошла ошибка при формировании заявления");
                }
            }
            else
            {
                MessagesService.Show("Заявление о возврате денежных средств", "Не выбрана транзакция или статус ОПЛАЧЕНО.");
                AppJournal.Write("BackMoneyTransfer", "Fault because not selected transaction or status payed.", true);
            }
        }
Example #13
0
        private void FormateTransfer()
        {
            // Check for auctions in selected date
            var procuratories = DataBaseClient.ReadProcuratories(FormateDate);

            var supplierOrders = DataBaseClient.ReadSupplierOrders().Where(s => s.auction.siteid == 4 && s.auction.date == FormateDate && s.supplierid != 3 && s.supplierid != 27 && s.supplierid != 354 && s.supplierid != 384 && s.supplierid != 385).ToList();

            if (procuratories != null && procuratories.Count() > 0)
            {
                // Set folder for files
                try
                {
                    path = Service.GetDirectory().FullName;
                }
                catch { path = ""; }

                if (!string.IsNullOrEmpty(path))
                {
                    for (var iBroker = 1; iBroker <= 4; iBroker++)
                    {
                        // Get template & copy them
                        if (supplierOrders.Where(s => s.contract.brokerid == iBroker).Count() > 0)
                        {
                            templateFile = path + "\\" + "Перевод в КЦ по ТОО " + (iBroker == 1 ? "'Альта и К'" : iBroker == 2 ? "'Корунд-777'" : iBroker == 3 ? "'Альтаир-Нур'" : "'Ак Алтын Ко'") + " для даты аукциона " + FormateDate.ToShortDateString() + ".docx";

                            if (Service.CopyFile(templatePath + "MoneyTransfer.docx", templateFile, true))
                            {
                                // Convert EF to BO
                                List <MoneyTransferList> moneyTransferList = new List <MoneyTransferList>();

                                var supplierJournal = DataBaseClient.ReadSuppliersJournals();
                                List <ClearingCountingEF> clearingCountingLst = new List <ClearingCountingEF>();

                                foreach (var item in supplierOrders.Where(s => s.contract.brokerid == iBroker))
                                {
                                    foreach (var subItem in procuratories.Where(p => p.supplierid == item.supplierid && p.auctionid == item.auctionid))
                                    {
                                        try
                                        {
                                            moneyTransferList.Add(new MoneyTransferList()
                                            {
                                                fromCompany = iBroker == 1 ? "altaik" : iBroker == 2 ? "korund" : iBroker == 3 ? "alta008" : "akaltko",
                                                toCompany   = supplierJournal.FirstOrDefault(s => s.supplierid == item.supplierid && s.brokerid == iBroker).code,
                                                lotNumber   = subItem.lot.number,
                                                sum         = (subItem.lot.sum / 100 * Convert.ToDecimal(0.1)).ToString()
                                            });

                                            //
                                            clearingCountingLst.Add(new ClearingCountingEF()
                                            {
                                                brokerid       = iBroker,
                                                fromsupplierid = iBroker == 1 ? 354 : iBroker == 2 ? 354 : iBroker == 3 ? 27 : 384,
                                                tosupplierid   = (int)subItem.supplierid,
                                                lotid          = (int)subItem.lotid,
                                                transaction    = subItem.lot.sum / 100 * Convert.ToDecimal(0.1),
                                                createdate     = DateTime.Now,
                                                statusid       = 9
                                            });

                                            // Put records in base

                                            /*if(DataBaseClient.CreateClearingCounting(clearingCounting) == 0) {
                                             *  MessagesService.Show("Заявление об изменении денежных средств", "Произошла ошибка при занесении данных в базу");
                                             *  AppJournal.Write("MoneyTransfer", "Fault when create record in base", true);
                                             * }*/
                                        }
                                        catch { }
                                    }
                                }

                                // Save into data base
                                foreach (var item in clearingCountingLst)
                                {
                                    // Check for exist
                                    var searchItem = DataBaseClient.ReadClearingCounting(item.brokerid, item.fromsupplierid, item.tosupplierid, item.lotid);

                                    // Save if not or remove old and create new record
                                    if (searchItem != null)
                                    { // Update
                                        DataBaseClient.UpdateClearingCounting(item.id, item.transaction);
                                    }
                                    else
                                    { // New
                                        if (DataBaseClient.CreateClearingCounting(item) == 0)
                                        {
                                            MessagesService.Show("Заявление об изменении денежных средств", "Произошла ошибка при занесении данных в базу");
                                            AppJournal.Write("MoneyTransfer", "Fault when create record in base", true);
                                        }
                                    }
                                }
                                //

                                // Formate file
                                MoneyTransferService.CreateDocument(templateFile, (iBroker == 1 ? "ТОО 'Альта и К'" : iBroker == 2 ? "ТОО 'Корунд-777'" : iBroker == 3 ? "ТОО 'Альтаир-Нур'" : "ТОО 'Ак Алтын Ко'"), moneyTransferList);
                            }
                        }
                    }
                }

                // Open folder
                FolderExplorer.OpenFolder(path + "\\");

                /*// Get templates & copy to auction directory
                 * var docMoneyTransferReq = GetDocumentRequisites("Заявление в КЦ №" + Auction.number.Replace("/", "_") + " (c " + Order.Auction.SupplierOrders[0].BrokerCode + " на " + Order.Auction.SupplierOrders[0].Code + ").docx", DocumentTypeEnum.MoneyTransfer);
                 * var moneyTransferTemplateFile = archiveManager.GetTemplate(docMoneyTransferReq, DocumentTemplateEnum.MoneyTransfer);
                 *
                 * // Get transaction sum
                 * var transactionSum = Order.Auction.Lots[0].Sum / 100 * Convert.ToDecimal(0.1);
                 *
                 * // Formate money transfer document & open folder with new document
                 * if(MoneyTransferService.CreateDocument(Order, moneyTransferTemplateFile, transactionSum)) {
                 *  OpenFolder();
                 *
                 *  // Put records in base
                 *  ClearingCountingEF clearingCounting = new ClearingCountingEF() {
                 *      brokerid = (int)SelectedSupplierOrder.contract.brokerid,
                 *      fromsupplierid = DataBaseClient.ReadSupplier(SelectedSupplierOrder.contract.broker.companyId).id,
                 *      tosupplierid = (int)SelectedSupplierOrder.supplierid,
                 *      lotid = SelectedLot.id,
                 *      transaction = transactionSum,
                 *      createdate = DateTime.Now,
                 *      statusid = 9
                 *  };
                 *
                 *  if(DataBaseClient.CreateClearingCounting(clearingCounting) == 0) {
                 *      MessagesService.Show("Заявление об изменении денежных средств", "Произошла ошибка при занесении данных в базу");
                 *      AppJournal.Write("MoneyTransfer", "Fault when create record in base", true);
                 *  }
                 * } else MessagesService.Show("Заявление об изменении денежных средств", "Произошла ошибка при формировании заявления");*/
                //
            }
            else
            {
                MessagesService.Show("Оповещение", "На эту дату нет аукционов или не созданы поручения");
            }
        }
        private void Print(int mode)
        {
            // Check for selected and for count
            if (SelectedListServ != null && SelectedListServ.envelopcount > 1)
            {
                // Get path to save template
                try
                {
                    path = Service.GetDirectory().FullName;
                }
                catch { path = ""; }

                if (!string.IsNullOrEmpty(path))
                {
                    // Get template file
                    templateFile = path + (mode == 1 ? "\\Конверты №" : mode == 2 ? "\\Уведомления №" : "\\Почтовый реестр №") + SelectedListServ.number + ".xlsx";

                    if (Service.CopyFile(templatePath + (mode == 1 ? "Envelop.xlsx" : mode == 2 ? "Notification.xlsx" : "Registral.xlsx"), templateFile, true))
                    {
                        // Convert info
                        List <PostRegister> postRegister = new List <PostRegister>();

                        foreach (var item in EnvelopsList)
                        {
                            postRegister.Add(new PostRegister()
                            {
                                name    = item.company == null ? "" : item.company,
                                index   = item.index == null ? "" : item.index,
                                address = item.address == null ? "" : item.address,
                                phones  = item.phones == null ? "" : item.phones,
                                code    = item.code == null ? "" : item.code
                            });
                        }

                        var brokerItem = DataBaseClient.ReadBrokers().FirstOrDefault(b => b.id == SelectedListServ.brokerid);

                        if (brokerItem != null)
                        {
                            Broker broker = new Broker();

                            broker.Name    = SelectedListServ.broker == null ? "" : SelectedListServ.broker;
                            broker.Index   = brokerItem.company.postcode == null ? "" : brokerItem.company.postcode;
                            broker.Address = brokerItem.company.addressactual == null ? "" : brokerItem.company.addressactual;
                            broker.Phones  = brokerItem.company.telephone == null ? "" : brokerItem.company.telephone;

                            // Formate document
                            try
                            {
                                PostRegisterService.CreateDocument(postRegister, templateFile, mode, broker);
                                FolderExplorer.OpenFolder(path + "\\");
                            }
                            catch (Exception) { MessagesService.Show("Оповещение", "во время формирования произошла ошибка"); }
                        }
                        else
                        {
                            MessagesService.Show("ОШИБКА", "Не найдены данные брокера");
                        }
                    }
                    else
                    {
                        MessagesService.Show("Оповещение", "Произошла ошибка во время копирования файла");
                    }
                }
            }
            else
            {
                MessagesService.Show("Оповещение", "Не выбран конверт или он пуст");
            }
        }
        private static void Main(string[] szArgs)
        {
            // new Thread(gc_).Start();
            if (Program.RunningInstance() != null)
            {
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            string szLanguagePath = "";
            string szLanguageFile = "";
            string baseDirectory  = AppDomain.CurrentDomain.BaseDirectory;

            if (!baseDirectory.EndsWith("\\"))
            {
                baseDirectory += "\\";
            }

            string szFolder = baseDirectory + "Language\\";
            string str1     = new ConfigFile(baseDirectory + "Config.ini").ReadConfig("$LANGUAGE_NAME");

            if (str1 == "")
            {
                str1 = "English";
            }

            string[] strArray = new FolderExplorer().ListFiles(szFolder);
            string   str2     = "";

            foreach (string szConfigPath in strArray)
            {
                if (new ConfigFile(szConfigPath).ReadConfig("$LANGUAGE_NAME").Trim() == str1)
                {
                    str2 = szConfigPath;
                    break;
                }
            }
            if (str2 != "")
            {
                szLanguagePath = szFolder;
                szLanguageFile = str2;
            }
            else if (str1 == "English")
            {
                int num1 = (int)MessageBox.Show("Can not load default language (English), use built-in language.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                string str3 = "English";
                foreach (string szConfigPath in strArray)
                {
                    if (new ConfigFile(szConfigPath).ReadConfig("$LANGUAGE_NAME").Trim() == str3)
                    {
                        str2 = szConfigPath;
                        break;
                    }
                }
                if (str2 != "")
                {
                    szLanguagePath = szFolder;
                    szLanguageFile = str2;
                }
                else
                {
                    int num2 = (int)MessageBox.Show("Can not load default language (English), use built-in language.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            if (szLanguagePath != "" && szLanguageFile != "")
            {
                GlobalMessages.LoadMessages(szLanguageFile);
            }

            if (!RegHelper.CheckConfigRegister())
            {
                int num3 = (int)MessageBox.Show(GlobalMessages.DRIVER_NOT_CONFIG, GlobalMessages.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                frmMain.SetLanguage(szLanguagePath, szLanguageFile);
                Application.Run(new frmMain(szArgs));
            }
        }
Example #16
0
        private void FormateContract()
        {
            // Prepare data
            // Get contract data
            var cContract = dataManager.ReadContracts(companyId, SelectedBroker != null ? SelectedBroker.id : 0);

            if (cContract == null || cContract.Count < 1)
            {
                MessagesService.Show("Формирование договора", "Нет данных договора");
                return;
            }

            Contract caspyContract = cContract.FirstOrDefault(c => c.number.ToLower() == Contract.number);

            // Get company data
            var cCompany = dataManager.GetCompany(companyId);

            if (cCompany == null)
            {
                MessagesService.Show("Формирование договора", "Нет данных компании");
                return;
            }

            Company caspyCompany = cCompany;

            caspyCompany.bank = Contract.bank != null ? Contract.bank.name : "";
            caspyCompany.bik  = Contract.bank != null ? Contract.bank.company.bik : "";

            // Get company broker data
            var cBroker = dataManager.GetCompany(SelectedBroker.companyId);

            if (cBroker == null)
            {
                MessagesService.Show("Формирование договора", "Нет данных компании брокера");
                return;
            }

            Company caspyBroker = cBroker;

            var bContracts = dataManager.ReadContracts(companyId, SelectedBroker.id);

            if (bContracts == null || bContracts.Count < 1)
            {
                MessagesService.Show("Формирование договора", "Нет данных договора брокера");
                return;
            }

            var bContract = DataBaseClient.ReadContract(bContracts[0].id);

            if (bContract == null)
            {
                MessagesService.Show("Формирование договора", "Нет данных договора брокера");
                return;
            }

            caspyBroker.bank = bContract.bank != null ? bContract.bank.name : "";
            caspyBroker.bik  = bContract.bank != null ? bContract.bank.company.bik : "";

            // Copy templates to end folder
            DocumentRequisite docContractReq = new DocumentRequisite()
            {
                date     = DateTime.Now,
                fileName = "Договор " + Contract.number + ".docx",
                number   = Contract.company.bin,
                section  = DocumentSectionEnum.Company,
                type     = DocumentTypeEnum.Contract,
                market   = MarketPlaceEnum.Caspy
            };

            var contractFileName = archiveManager.GetTemplate(docContractReq, DocumentTemplateEnum.Contract);

            if (string.IsNullOrEmpty(contractFileName))
            {
                MessagesService.Show("Формирование договора", "Ошибка копирования шаблона договора");
                return;
            }

            string newFileName = FolderExplorer.GetCompanyPath(Contract.company.bin);

            newFileName += docContractReq.fileName;

            if (Service.CopyFile(contractFileName, newFileName, true))
            {
                Service.DeleteFile(contractFileName);
            }
            else
            {
                MessagesService.Show("Формирование договора", "Ошибка копирования шаблона договора");
                return;
            }

            if (string.IsNullOrEmpty(newFileName))
            {
                MessagesService.Show("Формирование договора", "Ошибка копирования шаблона договора");
                return;
            }

            // Fill contract template with prepared data
            if (!ContractService.FillKaspiContract(newFileName, caspyContract, caspyCompany, caspyBroker))
            {
                MessagesService.Show("Формирование договора", "Произошла ошибка при формировании документа");
                return;
            }

            DataBaseClient.UpdateContractFile(Contract.id, archiveManager.SaveFile(docContractReq));
        }