Ejemplo n.º 1
0
 void documentoCheckIn_Click(object sender, EventArgs e)
 {
     try
     {
         ServiceReferenceDocument.Document document = (ServiceReferenceDocument.Document)radGridView2.SelectedRows[0].DataBoundItem;
         if (MessageBox.Show("Si vuole modificare il contenuto del file?", "Modificare il file?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             if (openFileDialog1.ShowDialog() == DialogResult.OK)
             {
                 document.Content      = new Content();
                 document.Content.Blob = File.ReadAllBytes(openFileDialog1.FileName);
             }
         }
         Forms.AttributeEdit attrEdit = new AttributeEdit(document.Archive.Name, document.AttributeValues);
         if (attrEdit.ShowDialog() == DialogResult.OK)
         {
             document.AttributeValues = attrEdit.GetAttributeValue();
             BackgroundWorker bcw = new BackgroundWorker();
             waitForm = new WaitForm();
             waitForm.Show();
             string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
             bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
             {
                 using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
                 {
                     client.CheckInDocument(document, user, ContentFormat.Bynary, null);
                 }
             };
             bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
             {
                 waitForm.Close();
                 if (e1.Error != null)
                 {
                     MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     radGridView2.SelectedRows[0].Cells["IsCheckOut"].Value     = true;
                     radGridView2.SelectedRows[0].Cells["IdUserCheckOut"].Value = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                     radGridView1_CurrentRowChanged();
                 }
             };
             bcw.RunWorkerAsync();
         }
     }
     catch (Exception ex)
     {
         RadMessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error);
     }
 }
Ejemplo n.º 2
0
 private void WriteChainToFile(ServiceReferenceDocument.Document document, bool compatybility)
 {
     //Chain chain = new Chain();
     //chain.IdChain = document.IdDocument;
     //chain.IdArchive = document.Archive.IdArchive;
     //chain.ArchiveName = document.Archive.Name;
     //chain.IdBiblos = document.IdBiblos.HasValue ? document.IdBiblos.Value : 0;
     //chain.IsCompatibility = compatybility;
     //chain.Name = txtName.Text;
     //chain.Description = txtDesc.Text;
     //chain.DateCreated = DateTime.Now;
     //using (ChainContexDataContext cn = new ChainContexDataContext(ConfigurationManager.ConnectionStrings["DocumentConnectionString"].ConnectionString))
     //{
     //    cn.Chains.InsertOnSubmit(chain);
     //    cn.SubmitChanges();
     //}
     //BindChain(CurrentArchive.IdArchive);
 }
Ejemplo n.º 3
0
        private void btnAddChain_Click(object sender, EventArgs e)
        {
            ServiceReferenceDocument.Document document = new ServiceReferenceDocument.Document();
            document.Archive = CurrentArchive;

            try
            {
                waitForm = new WaitForm();
                waitForm.Show();
                BackgroundWorker bcw = new BackgroundWorker();
                bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
                {
                    using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
                    {
                        document.IdDocument = client.CreateDocumentChain(CurrentArchive.Name, new BindingList <AttributeValue>());
                    }
                };
                bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
                {
                    waitForm.Close();
                    if (e1.Error != null)
                    {
                        MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        WriteChainToFile(document, false);
                    }
                };
                bcw.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                waitForm.Close();
                MessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 4
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Directory.Exists(txtPath.Text))
                {
                    MessageBox.Show("Directory not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                this.radGridStatus.Rows.Clear();
                DocumentsClient client  = new DocumentsClient("Binding_Documents");
                string[]        files   = Directory.GetFiles(txtPath.Text, "*.xml");
                string          pathOut = Path.Combine(txtPath.Text, "OUT");
                if (!Directory.Exists(pathOut))
                {
                    Directory.CreateDirectory(pathOut);
                }
                string pathErr = Path.Combine(txtPath.Text, "ERR");
                if (!Directory.Exists(pathErr))
                {
                    Directory.CreateDirectory(pathErr);
                }
                foreach (var file in files)
                {
                    string[]      xmlRow = File.ReadAllLines(file);
                    StringBuilder xml    = new StringBuilder();
                    foreach (var str in xmlRow)
                    {
                        if (!str.StartsWith("<!-- "))
                        {
                            xml.AppendLine(str);
                        }
                    }
                    XElement settingsDoc = XElement.Parse(xml.ToString());
                    var      dictionary  = from element in settingsDoc.Descendants("Zone")
                                           select new
                    {
                        Name  = element.Attribute("Name").Value,
                        Value = element.Value
                    };
                    var tmpName = Path.GetFileNameWithoutExtension(settingsDoc.Attributes("DocumentFileName").FirstOrDefault().Value) + txtSuffix.Text + Path.GetExtension(settingsDoc.Attributes("DocumentFileName").FirstOrDefault().Value);
                    BindingList <AttributeValue> attributeValues = new BindingList <AttributeValue>();
                    foreach (var attribute in attributes)
                    {
                        if (dictionary.Where(x => x.Name == attribute.Name).FirstOrDefault() != null)
                        {
                            object val = null;
                            string obj = dictionary.Where(x => x.Name == attribute.Name).FirstOrDefault().Value;
                            switch (attribute.AttributeType)
                            {
                            case "System.String":
                                val = obj;
                                break;

                            case "System.Int64":
                                val = int.Parse(obj);
                                break;

                            case "System.Double":
                                val = Double.Parse(obj);
                                break;

                            case "System.DateTime":
                                val = DateTime.Parse(obj);
                                break;

                            default:
                                break;
                            }
                            attributeValues.Add(new AttributeValue {
                                Attribute = attribute, Value = val
                            });
                        }
                    }
                    ServiceReferenceDocument.Document document = new ServiceReferenceDocument.Document();
                    document.Name            = Path.GetFileName(tmpName);
                    document.Content         = new Content();
                    document.Content.Blob    = File.ReadAllBytes(Path.Combine(txtPath.Text, tmpName));
                    document.AttributeValues = attributeValues;
                    document.Archive         = CurrentArchive;
                    try
                    {
                        client.AddDocumentToChainAsync(document, null, ContentFormat.Bynary, new string[] { txtPath.Text, file, tmpName });
                        client.AddDocumentToChainCompleted += new EventHandler <AddDocumentToChainCompletedEventArgs>(client_AddDocumentToChainCompleted);
                    }
                    catch (Exception exx)
                    {
                        this.radGridStatus.Rows.Add(new string[] {
                            document.Name,
                            "EXC",
                            exx.Message
                        });
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (radComboBoxArchive.SelectedValue == null)
            {
                MessageBox.Show("Selezionare un Archive per proseguire.", "Incomplete data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            BindingList <AttributeValue> attributeValues = new BindingList <AttributeValue>();
            AttributeValue attributeValue;

            ServiceReferenceDocument.Document document = new ServiceReferenceDocument.Document();
            document.Archive         = archives[radComboBoxArchive.SelectedIndex];
            document.AttributeValues = attributeValues;
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    for (int i = 0; i < gwAttributes.Rows.Count; i++)
                    {
                        if (gwAttributes.Rows[i].Cells["colValue"].Value == null || string.IsNullOrEmpty(gwAttributes.Rows[i].Cells["colValue"].Value.ToString()))
                        {
                            continue;
                        }
                        attributeValue           = new AttributeValue();
                        attributeValue.Attribute = attributes.Where(x => x.IdAttribute.ToString() == gwAttributes.Rows[i].Cells["IdAttribute"].Value.ToString()).Single();
                        switch (attributeValue.Attribute.AttributeType)
                        {
                        case "System.String":
                            attributeValue.Value = gwAttributes.Rows[i].Cells["colValue"].Value.ToString();
                            break;

                        case "System.Int64":
                            attributeValue.Value = Int64.Parse(gwAttributes.Rows[i].Cells["colValue"].Value.ToString());
                            break;

                        case "System.Double":
                            attributeValue.Value = Double.Parse(gwAttributes.Rows[i].Cells["colValue"].Value.ToString());
                            break;

                        case "System.DateTime":
                            attributeValue.Value = DateTime.Parse(gwAttributes.Rows[i].Cells["colValue"].Value.ToString());
                            break;

                        default:
                            break;
                        }
                        attributeValues.Add(attributeValue);
                    }

                    document.Name         = Path.GetFileName(openFileDialog1.FileName);
                    document.Content      = new Content();
                    document.Content.Blob = File.ReadAllBytes(openFileDialog1.FileName);


                    Nullable <Guid> parentId = null;

                    waitForm = new WaitForm();
                    waitForm.Show();
                    BackgroundWorker bcw = new BackgroundWorker();
                    bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
                    {
                        using (DocumentsClient client = new DocumentsClient("Binding_Documents"))
                            document = client.AddDocumentToChain(document, parentId, ContentFormat.Bynary);
                    };
                    bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
                    {
                        waitForm.Close();
                        if (e1.Error != null)
                        {
                            MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            if (!parentId.HasValue)
                            {
                                WriteChainToFile(document.DocumentParent, false);
                            }
                            for (int i = 0; i < gwAttributes.Rows.Count; i++)
                            {
                                gwAttributes.Rows[i].Cells["colValue"].Value = string.Empty;
                            }
                        }
                    };
                    bcw.RunWorkerAsync();
                }
            }
            catch (Exception ex)
            {
                waitForm.Close();
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 6
0
        private static ServiceReferenceDocument.Document createDocumentFromContentSearch(ServiceReferenceContentSearch.Document sourceDoc)
        {
            ServiceReferenceDocument.Document retval = null;

            if (sourceDoc != null)
            {
                retval = new ServiceReferenceDocument.Document
                {
                    ChainOrder       = sourceDoc.ChainOrder,
                    DateCreated      = sourceDoc.DateCreated,
                    DateExpire       = sourceDoc.DateExpire,
                    DateMain         = sourceDoc.DateMain,
                    DocumentHash     = sourceDoc.DocumentHash,
                    ExtensionData    = sourceDoc.ExtensionData,
                    FullSign         = sourceDoc.FullSign,
                    IdBiblos         = sourceDoc.IdBiblos,
                    IdDocument       = sourceDoc.IdDocument,
                    IdPreservation   = sourceDoc.IdPreservation,
                    IdUserCheckOut   = sourceDoc.IdUserCheckOut,
                    IsCheckOut       = sourceDoc.IsCheckOut,
                    IsConservated    = sourceDoc.IsConservated,
                    IsLinked         = sourceDoc.IsLinked,
                    IsVisible        = sourceDoc.IsVisible,
                    Name             = sourceDoc.Name,
                    PreservationName = sourceDoc.PreservationName,
                    PrimaryKeyValue  = sourceDoc.PrimaryKeyValue,
                    SignHeader       = sourceDoc.SignHeader,
                    Size             = sourceDoc.Size,
                    Version          = sourceDoc.Version,
                };


                if (sourceDoc.Archive != null)
                {
                    retval.Archive = new ServiceReferenceDocument.Archive {
                        IdArchive = sourceDoc.Archive.IdArchive, Name = sourceDoc.Archive.Name
                    };
                }
                ;

                if (sourceDoc.AttributeValues != null)
                {
                    retval.AttributeValues = new BindingList <ServiceReferenceDocument.AttributeValue>();
                    foreach (var values in sourceDoc.AttributeValues.Where(x => x.Attribute != null))
                    {
                        retval.AttributeValues.Add(new ServiceReferenceDocument.AttributeValue
                        {
                            IdAttribute = values.IdAttribute,
                            Value       = values.Value,
                            Attribute   = new ServiceReferenceDocument.Attribute
                            {
                                IdAttribute = values.Attribute.IdAttribute,
                                Name        = values.Attribute.Name,
                            },
                        });
                    }
                }
            }

            return(retval);
        }