1

我试图确保仅在将特定文档的库设置设置为必需时才会出现要求用户签出的消息框。但是,即使文档要求先签出该消息框,也不会出现该消息框。这是我的代码。

                    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;

    }
4

0 回答 0