触发&在SharePoint Server 2010中使用自定义Visual Web部件进行扫描 [英] Triggering & Scanning Using A Custom Visual Web Part in SharePoint Server 2010

查看:98
本文介绍了触发&在SharePoint Server 2010中使用自定义Visual Web部件进行扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我已经尝试构建一个SharePoint 2010可视化Web部件,

启用平板扫描器并使用该扫描从一个触发的图像触发网页部分。源代码如下所示。



CreateFolderUserControl.ascx



Hi all I have tried to build a SharePoint 2010 Visual Web Part that
enables a Flat-Bed Scanner and using that scan an image triggering from a
SharePoint Visual Web Part. The source code is as the below.

CreateFolderUserControl.ascx

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Data;
using System.IO;
using System.Text;
using System.Linq;
using WIA;

namespace SPCreateFolder.CreateFolder
{
    public partial class CreateFolderUserControl : UserControl
    {
        private string strNewLibName;
        private string strNewFolName;
        private string strNewLibDesc;

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {

            strNewLibName = txtNewLibName.Text;
            strNewLibDesc = txtLibDesc.Text;
            strNewFolName = txtNewFolName.Text;

            SPSite mySite = new SPSite("Http://thekingsbury/");
            {
                SPWeb myWeb = mySite.OpenWeb();
                {
                    myWeb.Lists.Add(strNewLibName, strNewLibDesc, SPListTemplateType.DocumentLibrary);
                    myWeb.Update();

                    SPDocumentLibrary newDocLibrary = (SPDocumentLibrary)myWeb.Lists[strNewLibName];
                    SPFolderCollection newFolders = myWeb.Folders;
                    newFolders.Add("http://thekingsbury/" + strNewLibName + "/" + strNewFolName + "/");
                    newDocLibrary.Update();
                }
            }

            ClearAll();

        }

        private void ClearAll()
        {
            txtNewLibName.Text = "";
            txtLibDesc.Text = "";
            txtNewFolName.Text = "";
        }

        protected void btnScanTheDoc_Click(object sender, EventArgs e)
        {
            litScanner.Items.Clear();

            //Creating a device manager.
            var DeviceManager = new DeviceManager();

            // Loop through the list of devices and add the name to the listbox
            for (int i = 1; i <= DeviceManager.DeviceInfos.Count; i++)
            {
                var deviceName = DeviceManager.DeviceInfos[i].Properties["Name"].get_Value().ToString();
                litScanner.Items.Add(deviceName);
            }
            
            // Scanner selected?
            var device = litScanner.SelectedItem as Scanner;

            if (device == null)
            {
                //MessageBox.Show("Please select a device.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                lblDetScan.Enabled = true;
                return;
            }

            // Scan
           // var image = device.

            // Save the image
            var path = @"c:\scan.jpeg";


            if (File.Exists(path))
            {
                File.Delete(path);
            }
            image.SaveFile(path);
        }
    }
}





扫描仪类(Scanner.cs )





Scanner Class (Scanner.cs)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using WIA;


namespace SPCreateFolder
{
    public class Scanner
    {
        private readonly DeviceInfo _deviceInfo;

        public Scanner(DeviceInfo deviceInfo)
        {
            this._deviceInfo = deviceInfo;
        }

        public Scanner()
        {
            // TODO: Complete member initialization
        }

        public ImageFile Scan()
        {
            // Connect to the device
            var device = this._deviceInfo.Connect();

            // Start the scan
            var item = device.Items[1];
            var imageFile = (ImageFile)item.Transfer(FormatID.wiaFormatJPEG);

            // Return the imageFile
            return imageFile;
        }
    }
}





但是我我在CreateFolderUserControl.ascx文件中收到错误,如下所示。





But I've got an error at the CreateFolderUserControl.ascx file as the below.

var device = litScanner.SelectedItem as Scanner;





错误是:不能

将类型'System.Web.UI.WebControls.ListItem'转换为

'SPCreateFolder.Scanner '通过引用转换,装箱转换,

取消装箱转换,换行转换或空类型转换

D:\ Job \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ CreateFolderUserControl.ascx.cs

72 26 SPCreateFolder



那么

我应该解决这个问题错误?我使用Visual Web中的Visual Web部件来支持SharePoint 2010. Visual Web部件使我能够像使用SharePoint Foundation的SharePoint Server一样执行
。所以

有人可以帮我解决这个问题。请帮帮我。



谢谢,



问候,



Chiranthaka



The error is: "Cannot
convert type 'System.Web.UI.WebControls.ListItem' to
'SPCreateFolder.Scanner' via a reference conversion, boxing conversion,
unboxing conversion, wrapping conversion, or null type conversion
D:\Jobs\SPCreateFolder\SPCreateFolder\CreateFolder\CreateFolderUserControl.ascx.cs
72 26 SPCreateFolder "

Then how
am I supposed to solve that error? I use Visual Web Part in Visual
Studio 2010 for SharePoint 2010. Visual Web Part Gives me the ability to
do the same as in SharePoint Server with SharePoint Foundation. So
someone can help me to solve this matter. Please help me.

Thanks,

Regards,

Chiranthaka

推荐答案

我找到了一个解决方案,解决方案是当通过ASP.Net或SharePoint连接硬件设备时,我们必须依赖第3个派对软件应用程序,如Kodak Capture Pro等。无论是否使用SDK,Atlasoft都会提供相同类型的软件工具。
I have found a solution & the solution is that when connecting hardware devices via ASP.Net or SharePoint we have to rely on 3rd party software application like Kodak Capture Pro and suchlike. Atlasoft also provies the same type of software tools with or without the SDK.


这篇关于触发&amp;在SharePoint Server 2010中使用自定义Visual Web部件进行扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆