public string DownloadDocument(ListView fileList) { var filePath = string.Empty; ListViewItem item = fileList.SelectedItems[0]; // Strip off 'Root' from the full path var path = item.SubItems[1].Text; filePath = Properties.Settings.Default.DefaultPath.ToString() + path; if (!string.IsNullOrEmpty(filePath)) { // Get the file from the server using (var output = new FileStream(filePath, FileMode.Create)) { Stream downloadStream; using (var client = new TemplateManagerClient()) { downloadStream = client.GetFile(path); } downloadStream.CopyTo(output); } return(filePath); } return(string.Empty); }
private void LoadTemplateTypes() { var client = new TemplateManagerClient(); cmbTemplateTypes.DataSource = null; cmbTemplateTypes.DataSource = client.GetTemplateTypes(); cmbTemplateTypes.DisplayMember = "TemplateObject"; cmbTemplateTypes.ValueMember = "TemplateTypeId"; client.Close(); }
private void GetTemplates(int templetTypeId) { var client = new TemplateManagerClient(); LstTemplates.DataSource = null; LstTemplates.DataSource = client.GetTemplates(templetTypeId); LstTemplates.DisplayMember = "Name"; LstTemplates.ValueMember = "TemplateId"; client.Close(); }
private void ShowFields(int templateId) { var client = new TemplateManagerClient(); LstFields.DataSource = null; LstFields.Items.Clear(); LstFields.DataSource = client.GetFieldsByTemplateId(templateId); LstFields.DisplayMember = "Field"; LstFields.ValueMember = "TemplateId"; client.Close(); }
private void InsertToLetterTemplate(string name, int templateType) { name = name.Substring(3); var letter = new LetterTemplate() { Name = name, FileName = name, TemplateType = templateType }; var client = new TemplateManagerClient(); client.InsertToLetterTemplate(letter); }
public void UploadDocument(int templateType, string filepath) { if (!string.IsNullOrEmpty(filepath)) { string virtualPath = AppendToFileName(templateType, Path.GetFileName(filepath)); using (Stream uploadStream = new FileStream(filepath, FileMode.Open)) { using (var client = new TemplateManagerClient()) { client.PutFile(new FileUploadMessage() { VirtualPath = virtualPath, DataStream = uploadStream }.VirtualPath, uploadStream); } } } }
private void DeleteButton_Click(object sender, EventArgs e) { if (FileList.SelectedItems.Count == 0) { MessageBox.Show("You must select a file to delete"); } else { string virtualPath = FileList.SelectedItems[0].SubItems[1].Text; using (TemplateManagerClient client = new TemplateManagerClient()) { client.DeleteFile(virtualPath); } RefreshFileList(); } }
private void RefreshFileList() { StorageFileInfo[] files = null; using (TemplateManagerClient client = new TemplateManagerClient()) { files = client.List(null); } FileList.Items.Clear(); int width = FileList.ClientSize.Width - SystemInformation.VerticalScrollBarWidth; float[] widths = { .2f, .6f, .2f }; for (int i = 0; i < widths.Length; i++) { FileList.Columns[i].Width = (int)((float)width * widths[i]); } foreach (var file in files) { ListViewItem item = new ListViewItem(Path.GetFileName(file.VirtualPathk__BackingField)); if (CheckFile(int.Parse(cmbTemplateTypes.SelectedValue.ToString()), file.VirtualPathk__BackingField)) { item.SubItems.Add(file.VirtualPathk__BackingField); float fileSize = (float)file.Sizek__BackingField / 1024.0f; string suffix = "Kb"; if (fileSize > 1000.0f) { fileSize /= 1024.0f; suffix = "Mb"; } item.SubItems.Add(string.Format("{0:0.0} {1}", fileSize, suffix)); FileList.Items.Add(item); } } }
private void InsertToLetterTemplate(string name,int templateType) { name = name.Substring(3); var letter = new LetterTemplate() { Name = name, FileName = name, TemplateType = templateType }; var client= new TemplateManagerClient(); client.InsertToLetterTemplate(letter); }
private void RefreshFileList() { StorageFileInfo[] files = null; using (TemplateManagerClient client = new TemplateManagerClient()) { files = client.List(null); } FileList.Items.Clear(); int width = FileList.ClientSize.Width - SystemInformation.VerticalScrollBarWidth; float[] widths = { .2f, .6f, .2f }; for (int i = 0; i < widths.Length; i++) FileList.Columns[i].Width = (int)((float)width * widths[i]); foreach (var file in files) { ListViewItem item = new ListViewItem(Path.GetFileName(file.VirtualPathk__BackingField)); if (CheckFile(int.Parse(cmbTemplateTypes.SelectedValue.ToString()), file.VirtualPathk__BackingField)) { item.SubItems.Add(file.VirtualPathk__BackingField); float fileSize = (float) file.Sizek__BackingField/1024.0f; string suffix = "Kb"; if (fileSize > 1000.0f) { fileSize /= 1024.0f; suffix = "Mb"; } item.SubItems.Add(string.Format("{0:0.0} {1}", fileSize, suffix)); FileList.Items.Add(item); } } }
public string DownloadDocument(ListView fileList) { var filePath = string.Empty; ListViewItem item = fileList.SelectedItems[0]; // Strip off 'Root' from the full path var path = item.SubItems[1].Text; filePath = Properties.Settings.Default.DefaultPath.ToString() + path; if (!string.IsNullOrEmpty(filePath)) { // Get the file from the server using (var output = new FileStream(filePath, FileMode.Create)) { Stream downloadStream; using (var client = new TemplateManagerClient()) { downloadStream = client.GetFile(path); } downloadStream.CopyTo(output); } return filePath; } return string.Empty; }