如何验证需要签出的sharepoint文档?

时间:2013-10-09 01:04:21

标签: c# sharepoint outlook

我正在尝试确保只有在特定文档的库设置被设置为必需时才会出现要求用户签出的消息框。但是,尽管文档要求首先检出消息框,但消息框甚至不会出现。这是我的代码。

                    WS.FYPJASMX serviceproxy = new WS.FYPJASMX();
                    serviceproxy.PreAuthenticate = true;
                    serviceproxy.UseDefaultCredentials = true;

                    string url = "";
                    string folderurl = "";
                    Boolean reqCheckout = serviceproxy.ValidateCheckout(urlpath, folderurl);

                    if (reqCheckout == true)
                    {
                        DialogResult dialogResult = MessageBox.Show("Do you want to Check out?", "Checking out...", MessageBoxButtons.YesNo);
                        if (dialogResult == DialogResult.Yes)
                        {
                            //SPSite oSiteCollection = SPContext.Current.Site;


                            //Boolean reqCheckout= serviceproxy.ValidateCheckout(urlpath, folderurl);
                            string checkoutSucces = serviceproxy.CheckoutFile(urlpath);

                            System.Diagnostics.Process.Start(webservice + urlpath);
                        }


                        else if (dialogResult == DialogResult.No)
                        {
                            this.Close();
                        }
                        //CheckInForm c = new CheckInForm();
                        //c.ShowDialog();

                    }



                    else if (reqCheckout == false) 
                    {

                        System.Diagnostics.Process.Start(webservice + urlpath);
                    }
                }
            }

这是我的网络服务方法。请检查我。

 [WebMethod(EnableSession = true, Description = "Typical Web Method")]
    public Boolean ValidateCheckout(string url, string folderurl)
    {

        try
        {
            //url = "http://it3127:30091/Shared%20Documents/Folder1/Testing%20new%20document.docx";
            SPSite site = new SPSite(url);
            SPWeb oWebsite = site.OpenWeb();
            //SPFolder oFolder = oWebsite.Folders["Shared Documents"];
            //SPFileCollection collFiles = oFolder.Files;
            SPList _MyDocLibrary = oWebsite.Lists[folderurl];
            return _MyDocLibrary.ForceCheckout;

            //SPFile file = oWebsite.GetFile(url);
            //file.CheckOut();
        }

        catch (Exception ex)
        {
            return false;
        }
        return true;

    }

0 个答案:

没有答案