Пример #1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (File.Exists(this.FilePath))
            {
                var node = this.treeFolders.SelectedNode;
                if (node != null)
                {
                    if (node.Level > 0)
                    {
                        this.buttonSave.Enabled = false;

                        Thread t = new Thread(() =>
                        {
                            String name = this.boxName.Text.TrimStart().TrimEnd();

                            if (!String.IsNullOrEmpty(name))
                            {
                                String obs = this.boxObs.Text.TrimStart().TrimEnd();
                                area @area = (area)this.treeFolders.Nodes[0].Tag;

                                if (@area != null)
                                {
                                    bool sucess = false;
                                    Int64 groupId = 0;
                                    Int64 subId = 0;

                                    if (node.Level == 1)
                                    {
                                        group tag = (group)node.Tag;

                                        if (tag != null)
                                        {
                                            groupId = tag.id;
                                            sucess = true;
                                        }
                                    }
                                    else
                                    {
                                        subGroup tag = (subGroup)node.Tag;

                                        if (tag != null)
                                        {
                                            groupId = tag.idGroup;
                                            subId = tag.id;
                                            sucess = true;
                                        }
                                    }

                                    if (sucess)
                                    {
                                        //build document
                                        documento doc = new documento();
                                        doc.active = true;
                                        doc.areaid = @area.id;
                                        doc.format = Path.GetExtension(this.FilePath);
                                        doc.grupoid = groupId;
                                        doc.idacc = Addin.CurrentAccount.id;
                                        doc.name = name;
                                        doc.observacao = obs;
                                        doc.pages = 1;
                                        doc.subid = subId;

                                        Cloud cloud = new Cloud();
                                        cloud.UploadFile(this.FilePath, doc, this);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Não foi possível salvar o documento.");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Não foi possível salvar o documento.");
                                }
                            }

                            else
                            {
                                MessageBox.Show("Digite um nome para o documento");
                            }

                            this.Invoke((MethodInvoker)(() => this.buttonSave.Enabled = true));                            
                        });

                        t.Start();                        
                    }
                    else
                    {
                        MessageBox.Show("Selecione uma pasta para salvar o documento");
                    }
                }
            }
            else
            {
                MessageBox.Show("Não foi possível enviar. O arquivo não existe.");
            }            
        }
Пример #2
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            String dir = Convert.ToString(this.buttonChoiceFile.Tag);
            String name = Path.GetFileNameWithoutExtension(this.buttonChoiceFile.Text);
            String ext = Path.GetExtension(this.buttonChoiceFile.Text);

            if(File.Exists(dir))
            {
                this.buttonSend.Enabled = false;

                //build document
                documento doc = new documento();
                doc.active = true;
                doc.idacc = Addin.CurrentAccount.id;
                doc.name = name;
                doc.observacao = this.boxObs.Text.TrimStart().TrimEnd();
                doc.pages = 1;
                doc.format = ext;
                doc.areaid = Util.User.CurrentArea.id;

                bool change = false;

                Cloud cloud = new Cloud();

                if(this.Level > 0)
                {
                    if (this.Level == 1)
                    {
                        group tag = (group)this.tag;

                        if (tag != null)
                        {
                            doc.grupoid = tag.id;
                            doc.subid = 0;
                            change = true;
                        }
                    }
                    else
                    {
                        subGroup tag = (subGroup)this.tag;

                        if(tag != null)
                        {
                            doc.grupoid = tag.idGroup;
                            doc.subid = tag.id;
                            change = true;
                        }
                    }
                }

                if(change)
                {
                    cloud.UploadFile(dir, doc, this);
                }
                else
                {
                    MessageBox.Show("Não foi possível enviar o arquivo. Tente novamente");
                }
            }
            else
            {
                MessageBox.Show("Não foi possível enviar. O arquivo não existe.");
            }
        }
Пример #3
0
        private void buttonDownloadDocument_Click(object sender, EventArgs e)
        {
            if (this.list.SelectedItems != null && this.list.SelectedItems.Count > 0 && this.list.Columns.Count > 1)
            {
                this.buttonDownloadDocument.Enabled = false;

                Cloud cloud = new Cloud();

                for(Int32 i = 0; i < this.list.SelectedItems.Count; i++)
                {
                    documento tag = (documento)this.list.SelectedItems[i].Tag;

                    if(tag != null && !String.IsNullOrEmpty(tag.hash))
                    {
                        cloud.DownloadFile(tag, this);                        
                    }
                    else
                    {
                        MessageBox.Show("Não foi possível completar o download.");
                    }
                }
            }
            else
            {
                MessageBox.Show("Selecione algum arquivo para fazer download");
            }
        }