Beispiel #1
0
        private void TestCreateNode()
        {
            ContentServerContentService.ContentServiceClient contentServiceClient;
            ContentServerContentService.OTAuthentication     contentServiceAuthentication;

            Stream content = null;

            OpenFileDialog openFile = new OpenFileDialog();

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                //connect
                try
                {
                    documentManagementClient = new ContentServerDocumentManagement.DocumentManagementClient();
                    documentManagementClient.Endpoint.Address            = new System.ServiceModel.EndpointAddress(documentManagementUri);
                    documentManagementAuthentication                     = new ContentServerDocumentManagement.OTAuthentication();
                    documentManagementAuthentication.AuthenticationToken = contentServerToken;
                }
                catch (Exception ex)
                {
                }

                try
                {
                    //BrowseDialog
                    FormBrowseContentServer formBrowse;
                    using (formBrowse = new FormBrowseContentServer())
                    {
                        formBrowse.StartPosition = FormStartPosition.CenterParent;
                        if (formBrowse.ShowDialog(this) == DialogResult.OK)
                        {
                            ContentServerDocumentManagement.Node testNode = new ContentServerDocumentManagement.Node();

                            if (formBrowse.Destination.NodeType.Equals("SawNodeMediaCollection"))
                            {
                                testNode.Type = "SawNodeImage"; //30024
                            }
                            else
                            {
                                testNode.Type = "Document"; //144
                            }
                            testNode.Comment  = "imageLinks node";
                            testNode.Name     = "webservice " + DateTime.Now.ToString().Replace(":", "");
                            testNode.VolumeID = formBrowse.Destination.VolumeID;
                            testNode.ParentID = formBrowse.Destination.ParentID;

                            documentManagementAuthentication.AuthenticationToken = contentServerToken;
                            ContentServerDocumentManagement.Node testNodeResult = documentManagementClient.CreateNode(ref documentManagementAuthentication, testNode);

                            ContentServerDocumentManagement.Metadata testMetadata = new ContentServerDocumentManagement.Metadata();

                            documentManagementAuthentication.AuthenticationToken = contentServerToken;
                            String addVersionContext = documentManagementClient.AddVersionContext(ref documentManagementAuthentication, testNodeResult.ID, testMetadata);

                            ContentServerContentService.FileAtts testFileAtts = new ContentServerContentService.FileAtts();
                            FileInfo testFileInfo = new FileInfo(openFile.FileName);
                            testFileAtts.CreatedDate  = testFileInfo.CreationTime;
                            testFileAtts.FileName     = testFileInfo.Name;
                            testFileAtts.FileSize     = testFileInfo.Length;
                            testFileAtts.ModifiedDate = testFileInfo.LastWriteTime;

                            content = File.Open(openFile.FileName, FileMode.Open);

                            contentServiceClient = new ContentServerContentService.ContentServiceClient();
                            contentServiceClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(contentServiceUri);
                            contentServiceAuthentication          = new ContentServerContentService.OTAuthentication();

                            contentServiceAuthentication.AuthenticationToken = contentServerToken;
                            contentServiceClient.UploadContent(ref contentServiceAuthentication, addVersionContext, testFileAtts, content);

                            System.Windows.Forms.MessageBox.Show(String.Format("Node {0} was created!", testNodeResult.ID.ToString()));
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (content != null)
                    {
                        content.Close();
                        content.Dispose();
                    }
                }
            }
        }
Beispiel #2
0
        private void TestCreateNode()
        {
            ContentServerContentService.ContentServiceClient contentServiceClient;
            ContentServerContentService.OTAuthentication contentServiceAuthentication;

            Stream content = null;

            OpenFileDialog openFile = new OpenFileDialog();

            if (openFile.ShowDialog() == DialogResult.OK)
            {

                //connect
                try
                {
                    documentManagementClient = new ContentServerDocumentManagement.DocumentManagementClient();
                    documentManagementClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(documentManagementUri);
                    documentManagementAuthentication = new ContentServerDocumentManagement.OTAuthentication();
                    documentManagementAuthentication.AuthenticationToken = contentServerToken;
                }
                catch (Exception ex)
                {
                }

                try
                {
                    //BrowseDialog
                    FormBrowseContentServer formBrowse;
                    using (formBrowse = new FormBrowseContentServer())
                    {
                        formBrowse.StartPosition = FormStartPosition.CenterParent;
                        if (formBrowse.ShowDialog(this) == DialogResult.OK)
                        {
                            ContentServerDocumentManagement.Node testNode = new ContentServerDocumentManagement.Node();

                            if (formBrowse.Destination.NodeType.Equals("SawNodeMediaCollection"))
                                testNode.Type = "SawNodeImage"; //30024
                            else
                                testNode.Type = "Document"; //144

                            testNode.Comment = "imageLinks node";
                            testNode.Name = "webservice " + DateTime.Now.ToString().Replace(":", "");
                            testNode.VolumeID = formBrowse.Destination.VolumeID;
                            testNode.ParentID = formBrowse.Destination.ParentID;

                            documentManagementAuthentication.AuthenticationToken = contentServerToken;
                            ContentServerDocumentManagement.Node testNodeResult = documentManagementClient.CreateNode(ref documentManagementAuthentication, testNode);

                            ContentServerDocumentManagement.Metadata testMetadata = new ContentServerDocumentManagement.Metadata();

                            documentManagementAuthentication.AuthenticationToken = contentServerToken;
                            String addVersionContext = documentManagementClient.AddVersionContext(ref documentManagementAuthentication, testNodeResult.ID, testMetadata);

                            ContentServerContentService.FileAtts testFileAtts = new ContentServerContentService.FileAtts();
                            FileInfo testFileInfo = new FileInfo(openFile.FileName);
                            testFileAtts.CreatedDate = testFileInfo.CreationTime;
                            testFileAtts.FileName = testFileInfo.Name;
                            testFileAtts.FileSize = testFileInfo.Length;
                            testFileAtts.ModifiedDate = testFileInfo.LastWriteTime;

                            content = File.Open(openFile.FileName, FileMode.Open);

                            contentServiceClient = new ContentServerContentService.ContentServiceClient();
                            contentServiceClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(contentServiceUri);
                            contentServiceAuthentication = new ContentServerContentService.OTAuthentication();

                            contentServiceAuthentication.AuthenticationToken = contentServerToken;
                            contentServiceClient.UploadContent(ref contentServiceAuthentication, addVersionContext, testFileAtts, content);

                            System.Windows.Forms.MessageBox.Show(String.Format("Node {0} was created!", testNodeResult.ID.ToString()));
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (content != null)
                    {
                        content.Close();
                        content.Dispose();
                    }
                }
            }
        }
Beispiel #3
0
        private void TestAddVersion(int p)
        {
            ContentServerContentService.ContentServiceClient contentServiceClient;
            ContentServerContentService.OTAuthentication     contentServiceAuthentication;

            Stream content = null;

            OpenFileDialog openFile = new OpenFileDialog();

            openFile.InitialDirectory = @"C:\Users\Public\Documents\LEADTOOLS Images\ImageProcessingDemo";

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                //connect
                try
                {
                    documentManagementClient = new ContentServerDocumentManagement.DocumentManagementClient();
                    documentManagementClient.Endpoint.Address            = new System.ServiceModel.EndpointAddress(documentManagementUri);
                    documentManagementAuthentication                     = new ContentServerDocumentManagement.OTAuthentication();
                    documentManagementAuthentication.AuthenticationToken = contentServerToken;
                }
                catch (Exception ex)
                {
                }

                try
                {
                    documentManagementAuthentication.AuthenticationToken = contentServerToken;
                    ContentServerDocumentManagement.Node testNodeResult = documentManagementClient.GetNode(ref documentManagementAuthentication, p);

                    ContentServerDocumentManagement.Metadata testMetadata = new ContentServerDocumentManagement.Metadata();

                    documentManagementAuthentication.AuthenticationToken = contentServerToken;
                    String addVersionContext = documentManagementClient.AddVersionContext(ref documentManagementAuthentication, testNodeResult.ID, testMetadata);

                    ContentServerContentService.FileAtts testFileAtts = new ContentServerContentService.FileAtts();
                    FileInfo testFileInfo = new FileInfo(openFile.FileName);
                    testFileAtts.CreatedDate  = testFileInfo.CreationTime;
                    testFileAtts.FileName     = testFileInfo.Name;
                    testFileAtts.FileSize     = testFileInfo.Length;
                    testFileAtts.ModifiedDate = testFileInfo.LastWriteTime;

                    content = File.Open(openFile.FileName, FileMode.Open);

                    contentServiceClient = new ContentServerContentService.ContentServiceClient();
                    contentServiceClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(contentServiceUri);
                    contentServiceAuthentication          = new ContentServerContentService.OTAuthentication();

                    contentServiceAuthentication.AuthenticationToken = contentServerToken;
                    contentServiceClient.UploadContent(ref contentServiceAuthentication, addVersionContext, testFileAtts, content);

                    System.Windows.Forms.MessageBox.Show(String.Format("Version to {0} succesfully added!", testNodeResult.ID.ToString()));
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (content != null)
                    {
                        content.Close();
                        content.Dispose();
                    }
                }
            }
        }
Beispiel #4
0
        private void TestAddVersion(int p)
        {
            ContentServerContentService.ContentServiceClient contentServiceClient;
            ContentServerContentService.OTAuthentication contentServiceAuthentication;

            Stream content = null;

            OpenFileDialog openFile = new OpenFileDialog();
            openFile.InitialDirectory = @"C:\Users\Public\Documents\LEADTOOLS Images\ImageProcessingDemo";

            if (openFile.ShowDialog() == DialogResult.OK)
            {

                //connect
                try
                {
                    documentManagementClient = new ContentServerDocumentManagement.DocumentManagementClient();
                    documentManagementClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(documentManagementUri);
                    documentManagementAuthentication = new ContentServerDocumentManagement.OTAuthentication();
                    documentManagementAuthentication.AuthenticationToken = contentServerToken;
                }
                catch (Exception ex)
                {
                }

                try
                {
                    documentManagementAuthentication.AuthenticationToken = contentServerToken;
                    ContentServerDocumentManagement.Node testNodeResult = documentManagementClient.GetNode(ref documentManagementAuthentication, p);

                    ContentServerDocumentManagement.Metadata testMetadata = new ContentServerDocumentManagement.Metadata();

                    documentManagementAuthentication.AuthenticationToken = contentServerToken;
                    String addVersionContext = documentManagementClient.AddVersionContext(ref documentManagementAuthentication, testNodeResult.ID, testMetadata);

                    ContentServerContentService.FileAtts testFileAtts = new ContentServerContentService.FileAtts();
                    FileInfo testFileInfo = new FileInfo(openFile.FileName);
                    testFileAtts.CreatedDate = testFileInfo.CreationTime;
                    testFileAtts.FileName = testFileInfo.Name;
                    testFileAtts.FileSize = testFileInfo.Length;
                    testFileAtts.ModifiedDate = testFileInfo.LastWriteTime;

                    content = File.Open(openFile.FileName, FileMode.Open);

                    contentServiceClient = new ContentServerContentService.ContentServiceClient();
                    contentServiceClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(contentServiceUri);
                    contentServiceAuthentication = new ContentServerContentService.OTAuthentication();

                    contentServiceAuthentication.AuthenticationToken = contentServerToken;
                    contentServiceClient.UploadContent(ref contentServiceAuthentication, addVersionContext, testFileAtts, content);

                    System.Windows.Forms.MessageBox.Show(String.Format("Version to {0} succesfully added!", testNodeResult.ID.ToString()));
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (content != null)
                    {
                        content.Close();
                        content.Dispose();
                    }
                }
            }
        }