Beispiel #1
0
        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);
        }
Beispiel #2
0
 private void LoadTemplateTypes()
 {
     var client = new TemplateManagerClient();
     cmbTemplateTypes.DataSource = null;
     cmbTemplateTypes.DataSource = client.GetTemplateTypes();
     cmbTemplateTypes.DisplayMember = "TemplateObject";
     cmbTemplateTypes.ValueMember = "TemplateTypeId";
     client.Close();
 }
Beispiel #3
0
 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();
 }
Beispiel #4
0
        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();
        }
Beispiel #5
0
        private void LoadTemplateTypes()
        {
            var client = new TemplateManagerClient();

            cmbTemplateTypes.DataSource    = null;
            cmbTemplateTypes.DataSource    = client.GetTemplateTypes();
            cmbTemplateTypes.DisplayMember = "TemplateObject";
            cmbTemplateTypes.ValueMember   = "TemplateTypeId";
            client.Close();
        }
Beispiel #6
0
        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();
        }
Beispiel #7
0
        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);
                   }
               }

               }
        }
Beispiel #9
0
        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();
            }
        }
Beispiel #10
0
        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);
                    }
                }
            }
        }
Beispiel #11
0
        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();
            }
        }
Beispiel #12
0
        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);
                }
            }
        }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        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();
        }
Beispiel #15
0
        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;
        }