/// <summary> /// Получает ДЕЙСТВУЮЩУЮ цену на бумагу по отправленному ISIN и записывает в Storage.CurrentQuoteAll /// </summary> /// <param name="currentISIN"></param> internal static void StorageISINandQuoteSave(List <string> currentISIN) { int i = 0; List <object> AllXMLMass = new List <object>(); try { WebRequest request = WebRequest.Create(XMLFTPFILE); request.Credentials = new NetworkCredential(userftp, passftp); using (WebResponse responce = request.GetResponse()) { using (var reader = XmlReader.Create(responce.GetResponseStream())) { while (reader.ReadToFollowing("Data")) { if (reader.GetAttribute("Type", "urn:schemas-microsoft-com:office:spreadsheet") == "String" || reader.GetAttribute("Type", "urn:schemas-microsoft-com:office:spreadsheet") == "Number") { i++; if (i > 4) { AllXMLMass.Add(reader.ReadElementContentAsString()); } } } } } AddQuoteintoStorageCurrentQuoteAll(AllXMLMass, currentISIN); } catch (ArgumentOutOfRangeException) { } catch (FormatException) { BOX.ShowInformation("Failed to get topical values from XML"); } catch (Exception ex) { BOX.ShowError(ex.Message, ex.Source); } }
private void HoldingsTable() { try { Holdings = new DataTable(); var holdings = ClientReportVM.InvestCollection; DataColumn[] ColumnsCollection = new DataColumn[10] { new DataColumn("Type", typeof(String)), new DataColumn("Currency", typeof(String)), new DataColumn("Date", typeof(String)), new DataColumn("Units", typeof(String)), new DataColumn("Aq. Prise", typeof(String)), new DataColumn("Isin", typeof(String)), new DataColumn("Marced Value", typeof(String)), new DataColumn("Marced Value USD", typeof(String)), new DataColumn("Profit", typeof(String)), new DataColumn("Weight", typeof(String)) }; Holdings.ColumnCollectionAdd(ColumnsCollection); var list = holdings.MassObjToList(); foreach (var item in list) { Holdings.Rows.Add(item.Type, item.Value, item.Date, item.Units, item.AqPr, item.Isin, item.Markedvalue, item.MarkedvalueUSD, item.profit, item.Percent); } } catch (Exception ex) { BOX.ShowInformation(ex.Message); } }
/// <summary> /// Загружает документ на сервер через FTP /// </summary> /// <param name="URLpath"></param> /// <param name="Pass"></param> /// <param name="username"></param> /// <param name="filePath"></param> /// <param name="fileOnFTPName"> Указывать папку с именем клиента для приватной загрузки. Например fileOnFTPName + '//order'. Расширение (.PDF) указывать во время вызова метода </param> /// <param name="delimiter"></param> internal static void FTPLoadFileOnly(string URLpath, string Pass, string username, string filePath, string fileOnFTPName) { using (WebClient client = new WebClient()) { client.Credentials = new NetworkCredential(username, Pass); client.BaseAddress = URLpath; client.UploadFile(fileOnFTPName, WebRequestMethods.Ftp.UploadFile, filePath); BOX.ShowInformation("File was successful upload"); } }
public void CreateReport() { try { ReportAsync(); } catch (System.IO.IOException) { //BOX.ShowInformation("Close Your Report File"); } catch (Exception ex) { BOX.ShowInformation(ex.Message); } }
/// <summary> /// Создает папку на сервере через FTP. /// </summary> /// <param name="URLpath"></param> /// <param name="Pass"></param> /// <param name="username"></param> /// <param name="folder_order">Название папки должно соответствовать номеру договора</param> internal static void FolderCreate(string URLpath, string Pass, string username, string folder_order) { try { string fullPath = URLpath + "//" + folder_order; FtpWebRequest zapros = (FtpWebRequest)WebRequest.Create(fullPath); zapros.Method = WebRequestMethods.Ftp.MakeDirectory; zapros.Credentials = new NetworkCredential(username, Pass); zapros.KeepAlive = false; using (FtpWebResponse otvet = (FtpWebResponse)zapros.GetResponse()) { BOX.ShowInformation(otvet.StatusCode.ToString()); } } catch (Exception ex) { BOX.ShowError(ex.Message, ex.Source); } }
/// <summary> /// Скачивает файл по строке, называет его и может открыть его в случае bool=true /// </summary> internal void DownloadFile(string ftpPath, string nameondisc, bool open = true) { GetInfoCorrectDownloadFolder(); try { string downloadDoc = string.Empty; using (WebClient client = new WebClient()) {//ftp://[email protected]/Documents/BrochuresClient/%7CFactsheet%20ENG.pdf downloadDoc = Directory.GetCurrentDirectory() + "\\" + downFolderName + nameondisc.Remove(0, 1); client.Credentials = new NetworkCredential(nameFTP, passwordFTP); client.DownloadFile(ftpPath, downloadDoc); } if (open == true) { Process.Start(Directory.GetCurrentDirectory() + "\\" + downFolderName + nameondisc.Remove(0, 1)); } } catch (Exception ex) { BOX.ShowInformation(ex.Message); } }
/// <summary> /// Скачивает файл - фото по номеру адвайзера в папку /// </summary> /// <param name="adviser"></param> internal string DownloadFile(string adviser) { string path = string.Empty; GetInfoCorrectDownloadFolder(); try { using (WebClient client = new WebClient()) { client.Credentials = new NetworkCredential(nameFTP, passwordFTP); string patch = FTP + "Photos/" + adviser + "/|Photo.jpg"; client.DownloadFile(patch, downFolderName + "Photo.jpg"); } path = Directory.GetCurrentDirectory() + "/" + downFolderName + "Photo.jpg"; } catch (WebException) { BOX.ShowInformation("The server found an error (xxx). File not available. Please contact us for more information."); } catch (Exception ex) { BOX.ShowInformation(ex.Message); } return(path); }
private void Button_Click(object sender, RoutedEventArgs e) { TotalRBTN.IsChecked = true; dynamic.Background = Brushes.White; CurrentPortfel.Background = Brushes.White; //if (MessageBoxResult.Yes == BOX.ShowQuestion("Do you want to open Report?", "Report")) if (BOX.ShowQuestion("Do you want to open Report?", "CGAAF Report") == true) { ReportPDFCreator creator = new ReportPDFCreator((ClientReportVM)this.DataContext, "Report.pdf", CurrentPortfel, RecomendPort, dynamic, Legeng, Convert.ToDouble(ClientReportVM.AllPortfelSumminUSD), true); creator.CreateReport(); } else { ReportPDFCreator creator = new ReportPDFCreator((ClientReportVM)this.DataContext, "Report.pdf", CurrentPortfel, RecomendPort, dynamic, Legeng, Convert.ToDouble(ClientReportVM.AllPortfelSumminUSD), false); creator.CreateReport(); BOX.ShowInformation("Report was created successfully!"); } dynamic.Background = null; CurrentPortfel.Background = null; }
private void SelectedFile() { OpenFileDialog dialog = new OpenFileDialog() { Multiselect = true }; dialog.ShowDialog(); Fullpathtofile = dialog.FileNames; Filenames = dialog.SafeFileNames; if (Fullpathtofile != null) { FileOkVisible = true; NotifyPropertyChanged("FileOkVisible"); int sizeMB = 0; for (int i = 0; i < Fullpathtofile.Length; i++) { info = new FileInfo(Fullpathtofile[i]); sizeMB = (int)Math.Abs(info.Length / 1048576); if (sizeMB < 50) { LoadFilesCollection.Add(new FilesNameControll(Filenames[i]) { DataContext = MainWindow.chat }); } else { BOX.ShowInformation("Selected File is too Big for load (You File must be less or equal 50MB)."); FileOkVisible = false; base.NotifyPropertyChanged("FileOkVisible"); break; } } } }
private void _send() { if (Formaterrorflag != false) { return; } if (_Bnumber <= 0 && _Snumber <= 0 && _Cnumber <= 0 && _Tnumber <= 0 && _Onumber <= 0) { return; } Random rand = new Random(); order = Storage.datasetKlient.Tables["ClientInfo"].Rows[0][6].ToString(); string adminID = Storage.datasetKlient.Tables["ClientInfo"].Rows[0][18].ToString(); try { if (string.IsNullOrWhiteSpace(PathToMain) != true && string.IsNullOrWhiteSpace(PathToTermSheet) == true) { int index = userDAL.AddTask(order, adminID, _Bnumber, _Snumber, _Tnumber, _Cnumber, _Inumber, _Onumber); string taskNameMain = "|" + order + "_main_user_task_№_" + index.ToString() + PathToMain.Remove(0, PathToMain.IndexOf('.')); InterfaceService.FTPLoadToServer.FTPLoadFileOnly(FTPURL + taskNameMain, ftppass, ftpUser, PathToMain, taskNameMain); userDAL.AddDocumentTask(index.ToString(), taskNameMain, FTPURL + taskNameMain); } else if (string.IsNullOrWhiteSpace(PathToMain) != true && string.IsNullOrWhiteSpace(PathToTermSheet) != true) { int index = userDAL.AddTask(order, adminID, _Bnumber, _Snumber, _Tnumber, _Cnumber, _Inumber, _Onumber); string taskNameMain = "|" + order + "_main_user_task_№_" + index.ToString() + PathToMain.Remove(0, PathToMain.IndexOf('.')); InterfaceService.FTPLoadToServer.FTPLoadFileOnly(FTPURL + taskNameMain, ftppass, ftpUser, PathToMain, taskNameMain); string taskNameStruct = "|" + order + "_struct_ user_task_№_" + index.ToString() + PathToTermSheet.Remove(0, PathToMain.IndexOf('.')); InterfaceService.FTPLoadToServer.FTPLoadFileOnly(FTPURL + taskNameStruct, ftppass, ftpUser, PathToTermSheet, taskNameStruct); userDAL.AddDocumentTask(index.ToString(), taskNameMain, taskNameStruct, FTPURL + taskNameMain, FTPURL + taskNameStruct); } else { BOX.ShowInformation("Not Selecten document(s) file(s)"); } } catch (Exception ex) { Logger.WriteLog(ex.Message, ex.Source); } finally { DocNumbers = "Selected Documents 0"; mainSelect = "Not select"; termSelect = "Not select"; PathToMain = ""; PathToTermSheet = ""; Model.TasksModel.collectionsReset(); _Bnumber = 0; _Snumber = 0; _Tnumber = 0; _Cnumber = 0; _Inumber = 0; _Onumber = 0; NotifyPropertyChanged("mainSelect"); NotifyPropertyChanged("termSelect"); NotifyPropertyChanged("Bnumber"); NotifyPropertyChanged("Snumber"); NotifyPropertyChanged("Tnumber"); NotifyPropertyChanged("Cnumber"); NotifyPropertyChanged("Inumber"); NotifyPropertyChanged("Onumber"); NotifyPropertyChanged("DocNumbers"); } }