Example #1
0
        private void treealfresco_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ResultSetRowNode node = (ResultSetRowNode)treealfresco.SelectedNode.Tag;

            LocationUuid = node.id;
            LocationName = treealfresco.SelectedNode.Text;
        }
        /// <summary>
        /// Constructs and adds a child node to the tree view at the parentNode supplied
        /// </summary>
        private TreeNode addChildNode(TreeNode parentNode, String name, ResultSetRowNode rsrNode)
        {
            TreeNode node = new TreeNode(name);

            node.Text = name;
            node.Tag  = rsrNode;
            parentNode.Nodes.Add(node);
            return(node);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ResultSetRowNode node = (ResultSetRowNode)treeView1.SelectedNode.Tag;
            // get the parent form
            UploadExample parentForm = (UploadExample)this.Owner;

            parentForm.LocationUuid = node.id;
            parentForm.LocationName = treeView1.SelectedNode.Text;

            this.Close();
        }
Example #4
0
        public void CanPerformSearches()
        {
            AuthenticationUtils.startSession("admin", "admin");
            try {
                RepositoryService repositoryService = WebServiceFactory.getRepositoryService();
                Store             spacesStore       = new Store(StoreEnum.workspace, "SpacesStore");
                String            luceneQuery       = "PATH:\"/app:company_home\"";
                Query             query             = new Query(Constants.QUERY_LANG_LUCENE, luceneQuery);
                QueryResult       queryResult       = repositoryService.query(spacesStore, query, false);
                ResultSet         resultSet         = queryResult.resultSet;
                ResultSetRow[]    results           = resultSet.rows;

                //your custom list
                IList <CustomResultVO> customResultList = new List <CustomResultVO>();

                //retrieve results from the resultSet
                foreach (ResultSetRow resultRow in results)
                {
                    ResultSetRowNode nodeResult = resultRow.node;

                    //create your custom value object
                    CustomResultVO customResultVo = new CustomResultVO();
                    customResultVo.Id   = nodeResult.id;
                    customResultVo.Type = nodeResult.type;

                    //retrieve properties from the current node
                    foreach (NamedValue namedValue in resultRow.columns)
                    {
                        if (Constants.PROP_NAME.Equals(namedValue.name))
                        {
                            customResultVo.Name = namedValue.value;
                        }
                        else if (Constants.PROP_DESCRIPTION.Equals(namedValue.name))
                        {
                            customResultVo.Description = namedValue.value;
                        }
                    }

                    //add the current result to your custom list
                    customResultList.Add(customResultVo);
                }

                Assert.AreEqual(1, customResultList.Count);

                CustomResultVO firstResult = customResultList[0];
                Assert.IsNotNull(firstResult.Id);
                Assert.AreEqual("{http://www.alfresco.org/model/content/1.0}folder", firstResult.Type);
            } finally {
                AuthenticationUtils.endSession();
            }
        }
Example #5
0
        /// <summary>
        /// Double click event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listViewBrowse_DoubleClick(object sender, EventArgs e)
        {
            ListViewItem item = listViewBrowse.SelectedItems[0];

            if (item != null)
            {
                ResultSetRowNode node = item.Tag as ResultSetRowNode;
                if (node != null)
                {
                    if (node.type.Contains("folder") == true)
                    {
                        // Create the reference for the node selected
                        Alfresco.RepositoryWebService.Reference reference = new Alfresco.RepositoryWebService.Reference();
                        reference.store = this.spacesStore;
                        reference.uuid  = node.id;

                        // Parent references
                        this.parentReferences.Add(this.currentReference);

                        // Populate the list with the children of the selected node
                        populateListBox(reference);
                    }
                    else
                    {
                        // Create the reference for the node selected
                        Alfresco.ContentWebService.Store spacesStore2 = new Alfresco.ContentWebService.Store();
                        spacesStore2.scheme  = Alfresco.ContentWebService.StoreEnum.workspace;
                        spacesStore2.address = "SpacesStore";

                        Alfresco.ContentWebService.Reference reference = new Alfresco.ContentWebService.Reference();
                        reference.store = spacesStore2;
                        reference.uuid  = node.id;

                        // Lets try and get the content
                        Alfresco.ContentWebService.Predicate predicate = new Alfresco.ContentWebService.Predicate();
                        predicate.Items = new Object[] { reference };
                        Content[] contents = this.contentService.read(predicate, "{http://www.alfresco.org/model/content/1.0}content");
                        Content   content  = contents[0];
                        if (content.url != null && content.url.Length != 0)
                        {
                            string url = content.url + "?ticket=" + AuthenticationUtils.Ticket;
                            webBrowser.Url = new Uri(url);
                        }
                    }
                }
            }
        }
Example #6
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ResultSetRowNode node = (ResultSetRowNode)this.treeView1.SelectedNode.Tag;

            this.parentForm.LocationUuid = node.id;
            this.parentForm.LocationName = treeView1.SelectedNode.FullPath;
            TreeNode selectedNode = this.treeView1.SelectedNode;

            selectedNode.BackColor = SystemColors.Highlight;
            selectedNode.ForeColor = SystemColors.HighlightText;

            if (this.preTreeNode != null)
            {
                this.preTreeNode.BackColor = Color.Empty;
                this.preTreeNode.ForeColor = Color.Empty;
            }
            this.preTreeNode = treeView1.SelectedNode;
        }
Example #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            ListViewItem item = listViewBrowse.SelectedItems[0];

            if (item != null)
            {
                ResultSetRowNode node = item.Tag as ResultSetRowNode;
                if (node != null)
                {
                    if (node.type.Contains("folder") == false)
                    {
                        // Create the reference for the node selected
                        Alfresco.AuthoringWebService.Store spacesStore2 = new Alfresco.AuthoringWebService.Store();
                        spacesStore2.scheme  = Alfresco.AuthoringWebService.StoreEnum.workspace;
                        spacesStore2.address = "SpacesStore";

                        Alfresco.AuthoringWebService.Reference reference = new Alfresco.AuthoringWebService.Reference();
                        reference.store = spacesStore2;
                        reference.uuid  = node.id;

                        // Lets try to check out
                        Alfresco.AuthoringWebService.Predicate predicate = new Alfresco.AuthoringWebService.Predicate();
                        predicate.Items = new Object[] { reference };
                        Alfresco.AuthoringWebService.ParentReference pr = new Alfresco.AuthoringWebService.ParentReference();
                        pr.store           = spacesStore2;;
                        pr.uuid            = this.currentReference.uuid;
                        pr.associationType = Constants.ASSOC_CONTAINS;
                        pr.childName       = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, item.Text);
                        this.authoringService.checkout(predicate, pr);
                        int i = 0;
                    }
                    else
                    {
                    }
                }
            }
        }
Example #8
0
        private void button2_Click(object sender, EventArgs e)
        {
            Alfresco.RepositoryWebService.Store[] stores = this.repoService.getStores();

            Alfresco.RepositoryWebService.Store vStore = stores[3];

            ListViewItem item = listViewBrowse.SelectedItems[0];

            if (item != null)
            {
                ResultSetRowNode node = item.Tag as ResultSetRowNode;
                if (node != null)
                {
                    if (node.type.Contains("folder") == false)
                    {
                        // Create the reference for the node selected
                        Alfresco.AuthoringWebService.Store spacesStore2 = new Alfresco.AuthoringWebService.Store();
                        spacesStore2.scheme  = Alfresco.AuthoringWebService.StoreEnum.workspace;
                        spacesStore2.address = "SpacesStore";

                        Alfresco.AuthoringWebService.Reference reference = new Alfresco.AuthoringWebService.Reference();
                        reference.store = spacesStore2;
                        reference.uuid  = node.id;

                        VersionHistory VH = this.authoringService.getVersionHistory(reference);

                        int    i    = 0;
                        char[] temp = new char[1];
                        temp[0] = '0';
                        string versions = new string(temp);
                        Alfresco.AuthoringWebService.Version first;
                        foreach (Alfresco.AuthoringWebService.Version version in VH.versions)
                        {
                            if (i == 0)
                            {
                                first = version;
                            }
                            versions += version.label + (";") + version.id.uuid + (";");
                        }

                        {
                            // Create the reference for the node selected
                            Alfresco.ContentWebService.Store spacesStore3 = new Alfresco.ContentWebService.Store();
                            spacesStore3.scheme  = Alfresco.ContentWebService.StoreEnum.versionStore;
                            spacesStore3.address = vStore.address;

                            Alfresco.ContentWebService.Reference reference1 = new Alfresco.ContentWebService.Reference();
                            reference1.store = spacesStore3;
                            reference1.uuid  = VH.versions[VH.versions.GetUpperBound(0)].id.uuid;

                            // Lets try and get the content
                            Alfresco.ContentWebService.Predicate predicate = new Alfresco.ContentWebService.Predicate();
                            predicate.Items = new Object[] { reference1 };
                            Content[] contents = this.contentService.read(predicate, "{http://www.alfresco.org/model/content/1.0}content");
                            Content   content  = contents[0];
                            if (content.url != null && content.url.Length != 0)
                            {
                                string url = content.url + "?ticket=" + AuthenticationUtils.Ticket;
                                webBrowser.Url = new Uri(url);
                            }
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
Example #9
0
        private void DoScan()
        {
            WIA.Item         item            = default(WIA.Item);
            WIA.ImageFile    Img             = default(WIA.ImageFile);
            WIA.CommonDialog WiaCommonDialog = new CommonDialogClass();
            bool             hasMorePages    = true;
            int    x           = 0;
            int    numPages    = 0;
            string ImgMain     = null;
            string ImgMainName = null;

            try
            {
                if (treealfresco.SelectedNode == null)
                {
                    MessageBox.Show("Please select a Space to store your data into", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                ResultSetRowNode node = (ResultSetRowNode)treealfresco.SelectedNode.Tag;
                LocationUuid = node.id;

                LocationName = treealfresco.SelectedNode.Text;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            while (hasMorePages)
            {
                //Create DeviceManager
                DeviceManager manager = new DeviceManagerClass();
                Device        WiaDev  = null;
                foreach (DeviceInfo info in manager.DeviceInfos)
                {
                    if (info.DeviceID == this.DeviceID)
                    {
                        WIA.Properties infoprop = null;
                        infoprop = info.Properties;
                        //connect to scanner
                        WiaDev = info.Connect();
                        break; // TODO: might not be correct. Was : Exit For
                    }
                }

                //Start Scan

                Img = null;

                item = WiaDev.Items[1] as WIA.Item;

                try
                {
                    Img = (ImageFile)WiaCommonDialog.ShowTransfer(item, wiaFormatTIFF, false);

                    //process image:
                    //one would do image processing here

                    //Save to file
                    string jpegGuid = null;
                    //retrieves jpegKey from registry, used in saving JPEG
                    Microsoft.Win32.RegistryKey jpegKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID\\{D2923B86-15F1-46FF-A19A-DE825F919576}\\SupportedExtension\\.jpg");
                    jpegGuid = (string)jpegKey.GetValue("FormatGUID");
                    //loops through available formats for the captured item, looking for the JPG format
                    foreach (string format in item.Formats)
                    {
                        if ((format == jpegGuid))
                        {
                            //transfers image to an imagefile object
                            Img = (WIA.ImageFile)item.Transfer(WIA.FormatID.wiaFormatTIFF);
                            int Counter = 0;
                            //counter in loop appended to filename
                            bool LoopAgain = true;
                            //searches directory, gets next available picture name
                            while (!(LoopAgain == false))
                            {
                                string File = SavePath + "\\";
                                File += txtPrefix.Text;
                                File += Counter;
                                File += ".tiff";
                                string Filename = txtPrefix.Text;
                                Filename += Counter;
                                Filename += ".tiff";


                                if (System.IO.File.Exists(Filename))
                                {
                                    //file exists, delete it
                                    System.IO.File.Delete(Filename);
                                }
                                if (numPages == 0)
                                {
                                    Img.SaveFile(Filename);
                                }
                                ImgMain     = File;
                                ImgMainName = Filename;
                                if (numPages > 0)
                                {
                                    int y = Counter;
                                    y            = Counter - 1;
                                    ImgMain      = SavePath + "\\";
                                    ImgMain     += txtPrefix.Text;
                                    ImgMain     += y;
                                    ImgMain     += ".tiff";
                                    ImgMainName  = txtPrefix.Text;
                                    ImgMainName += y;
                                    ImgMainName += ".tiff";
                                    //createtiff(ImgMain, File);
                                }
                                numPages += 1;

                                Counter = Counter + 1;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message);
                }
                finally
                {
                    item = null;
                    //determine if there are any more pages waiting
                    WIA.Property documentHandlingSelect = null;
                    WIA.Property documentHandlingStatus = null;
                    foreach (WIA.Property prop in WiaDev.Properties)
                    {
                        if (prop.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_SELECT)
                        {
                            documentHandlingSelect = prop;
                        }
                        if (prop.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_STATUS)
                        {
                            documentHandlingStatus = prop;
                        }
                    }
                    hasMorePages = false;
                    UploadNow(ImgMainName, ImgMain);
                    MessageBox.Show(ImgMain + " uploaded");
                    //assume there are no more pages
                    if (documentHandlingSelect != null)
                    {
                        //may not exist on flatbed scanner but required for feeder
                        //check for document feeder

                        if ((Convert.ToUInt32(documentHandlingSelect.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER) != 0)
                        {
                            hasMorePages = ((Convert.ToUInt32(documentHandlingStatus.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_STATUS.FEED_READY) != 0);
                        }
                    }
                    x += 1;
                }
            }
        }
Example #10
0
        private void btncapture_Click(object sender, EventArgs e)
        {
            if (treealfresco.SelectedNode == null)
            {
                MessageBox.Show("Please select a Space to store your data into", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //exit btncapture_Click;
            }

            if (rdscanner.Checked == true)
            {
                Enabled = false;

                _settings = new ScanSettings()
                {
                    UseDocumentFeeder = useAdfCheckBox.Checked,
                    ShowTwainUI       = useUICheckBox.Checked,
                    Resolution        = blackAndWhiteCheckBox.Checked
                        ? ResolutionSettings.Fax
                        : ResolutionSettings.ColourPhotocopier
                };

                try
                {
                    _twain.StartScanning(_settings);
                }
                catch (TwainException ex)
                {
                    MessageBox.Show(ex.Message);
                    Enabled = true;
                }
            }
            else
            {
                WIA.Item         item            = default(WIA.Item);
                WIA.CommonDialog WiaCommonDialog = new CommonDialogClass();
                try
                {
                    //Check if the device is scanner or not
                    if (rdscanner.Checked == true)
                    {
                        //scans the image using the Scanner only (ADF or Flatbed)
                        DoScan();
                    }
                    else
                    {
                        item = SelectedDevice.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture);
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Problem Taking Picture. Please make sure that the camera is plugged in and is not in use by another application. " + "\r\n" + "Extra Info:" + ex.Message, "Problem Grabbing Picture", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    return;
                }

                try
                {
                    //Validate if a image location is selected or not
                    if (treealfresco.SelectedNode == null)
                    {
                        MessageBox.Show("Please select a Space to store your data into", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    ResultSetRowNode node = (ResultSetRowNode)treealfresco.SelectedNode.Tag;
                    LocationUuid = node.id;

                    LocationName = treealfresco.SelectedNode.Text;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                try
                {
                    //Executes the device's TakePicture command based on selected image format
                    if (rdjpeg.Checked == true)
                    {
                        string jpegGuid = null;
                        //retrieves jpegKey from registry, used in saving JPEG
                        Microsoft.Win32.RegistryKey jpegKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID\\{D2923B86-15F1-46FF-A19A-DE825F919576}\\SupportedExtension\\.jpg");
                        jpegGuid = (string)jpegKey.GetValue("FormatGUID");
                        //loops through available formats for the captured item, looking for the JPG format
                        foreach (string format in item.Formats)
                        {
                            if ((format == jpegGuid))
                            {
                                //transfers image to an imagefile object
                                WIA.ImageFile imagefile = (WIA.ImageFile)item.Transfer(format);
                                int           Counter   = 0;
                                //counter in loop appended to filename
                                bool LoopAgain = true;
                                //searches directory, gets next available picture name
                                while (!(LoopAgain == false))
                                {
                                    string File = SavePath + "\\";
                                    File += txtPrefix.Text;
                                    File += Counter;
                                    File += ".jpg";
                                    string Filename = txtPrefix.Text;
                                    Filename += Counter;
                                    Filename += ".jpg";
                                    //if file doesnt exist, save the file
                                    if (!System.IO.File.Exists(Filename))
                                    {
                                        SavedFilePath = Filename;
                                        imagefile.SaveFile(Filename);
                                        //saves file to disk
                                        //Upload the file to Alfresco
                                        UploadNow(Filename, File);
                                        MessageBox.Show(File + " uploaded");
                                        LoopAgain = false;
                                    }
                                    Counter = Counter + 1;
                                }
                            }
                        }
                    }
                    else if (rdgif.Checked == true)
                    {
                        string jpegGuid = null;
                        //retrieves jpegKey from registry, used in saving JPEG
                        Microsoft.Win32.RegistryKey jpegKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID\\{D2923B86-15F1-46FF-A19A-DE825F919576}\\SupportedExtension\\.jpg");
                        jpegGuid = (string)jpegKey.GetValue("FormatGUID");
                        //loops through available formats for the captured item, looking for the JPG format
                        foreach (string format in item.Formats)
                        {
                            if ((format == jpegGuid))
                            {
                                //transfers image to an imagefile object
                                WIA.ImageFile imagefile = (WIA.ImageFile)item.Transfer(WIA.FormatID.wiaFormatGIF);
                                int           Counter   = 0;
                                //counter in loop appended to filename
                                bool LoopAgain = true;
                                //searches directory, gets next available picture name
                                while (!(LoopAgain == false))
                                {
                                    string File = SavePath + "\\";
                                    File += txtPrefix.Text;
                                    File += Counter;
                                    File += ".gif";
                                    string Filename = txtPrefix.Text;
                                    Filename += Counter;
                                    Filename += ".gif";
                                    //if file doesnt exist, save the file
                                    if (!System.IO.File.Exists(Filename))
                                    {
                                        SavedFilePath = Filename;
                                        imagefile.SaveFile(Filename);
                                        //saves file to disk
                                        // Upload the file to Alfresco
                                        UploadNow(Filename, File);
                                        MessageBox.Show(File + " uploaded");
                                        LoopAgain = false;
                                    }
                                    Counter = Counter + 1;
                                }
                            }
                        }
                    }
                    else if (rdtiff.Checked == true)
                    {
                        string jpegGuid = null;
                        //retrieves jpegKey from registry, used in saving JPEG
                        Microsoft.Win32.RegistryKey jpegKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID\\{D2923B86-15F1-46FF-A19A-DE825F919576}\\SupportedExtension\\.jpg");
                        jpegGuid = (string)jpegKey.GetValue("FormatGUID");
                        //loops through available formats for the captured item, looking for the JPG format
                        foreach (string format in item.Formats)
                        {
                            if ((format == jpegGuid))
                            {
                                //transfers image to an imagefile object
                                WIA.ImageFile imagefile = (WIA.ImageFile)item.Transfer(WIA.FormatID.wiaFormatTIFF);
                                int           Counter   = 0;
                                //counter in loop appended to filename
                                bool LoopAgain = true;
                                //searches directory, gets next available picture name
                                while (!(LoopAgain == false))

                                {
                                    string File = SavePath + "\\";
                                    File += txtPrefix.Text;
                                    File += Counter;
                                    File += ".tiff";
                                    string Filename = txtPrefix.Text;
                                    Filename += Counter;
                                    Filename += ".tiff";
                                    //if file doesnt exist, save the file
                                    if (!System.IO.File.Exists(Filename))
                                    {
                                        SavedFilePath = Filename;
                                        imagefile.SaveFile(Filename);
                                        //saves file to disk
                                        UploadNow(Filename, File);
                                        MessageBox.Show(File + " uploaded");
                                        LoopAgain = false;
                                    }
                                    Counter = Counter + 1;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }