/// <summary> /// <c>listService_GetListItemsCompleted</c> event handler /// calls <c>ListItemCompleted</c> method /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void listService_GetListItemsCompleted(object sender, SharePoint_Link.ListWebService.GetListItemsCompletedEventArgs e) { try { XmlNode xmlnode = e.Result; UploadItemsData uploaditemdata = (UploadItemsData)e.UserState; ListItemCompleted(xmlnode, uploaditemdata); } catch (Exception ex) { m_isUploadingCompleted = true; DelegateUpdateGridRow pdSteps = new DelegateUpdateGridRow(UpdataGridRows); this.Invoke(pdSteps, new object[] { false, "uploaded with error", "", null }); EncodingAndDecoding.ShowMessageBox("Error occured, may be th document Library does not exists", "Error occured, may be th document Library does not exists", MessageBoxIcon.Error); } }
/// <summary> /// <c>m_WC_UploadDataCompleted</c> Event handler /// WebCLinet Async completed event /// executes oncompleting uploading and call method to update grid row. and /// GetListItemsAsyncWrapper method to complete the process of uploading in sharepoint 2007. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void m_WC_UploadDataCompleted(object sender, UploadDataCompletedEventArgs e) { try { int test = sendingRequestCount; string outMessage = string.Empty; string sucessURL = string.Empty; UploadItemsData uploadData = (UploadItemsData)e.UserState; try { receivingRequestCount++; // execute the CopyIntoItems method //Set the file name to global variable m_uploadingFileName = uploadData.UploadFileName; if (e.Error != null) { Exception ex = e.Error; if (Convert.ToString(ex.Message) == "Object reference not set to an instance of an object.") { outMessage = "Cause :: No prermission to access the List.(OR) List or Library is deleted or moved"; } else if (Convert.ToString(ex.Message) == "InvalidUrl") { outMessage = "Upload Falied.Filename contains some special characters." + ex.Message; } else { outMessage = ex.Message; } m_isUploadingCompleted = true; UpdataGridRows(false, outMessage, sucessURL, uploadData); //return false; } else { Byte[] result = e.Result; XmlDocument xmlDoc = new XmlDocument(); XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", ""); XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", ""); XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", ""); ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" + "<DateInUtc>TRUE</DateInUtc>"; //send required fields information ndViewFields.InnerXml = "<FieldRef Name='ID'/> <FieldRef Name='LinkTitle'/>"; ndQuery.InnerXml = "<Where><Eq><FieldRef Name='FileLeafRef'></FieldRef><Value Type='Text'>" + uploadData.UploadFileName + "</Value></Eq></Where>"; //Call items details ASYNC // listService.GetListItemsAsync(m_uploadDocLibraryName, null, ndQuery, ndViewFields, "2", ndQueryOptions, null, uploadData); // lstwebclass.GetListItemsAsync(m_uploadDocLibraryName, null, ndQuery, ndViewFields, "2", ndQueryOptions, null, uploadData, cmproperties); if (SPVersionClass.SPSiteVersion == SPVersionClass.SiteVersion.SP2007.ToString()) { GetListItemsAsyncWrapper(m_uploadDocLibraryName, null, ndQuery, ndViewFields, "2", ndQueryOptions, null, uploadData, cmproperties); } m_isUploadingCompleted = false; // HideProgressPanel(true); } } catch (Exception ex) { outMessage = ex.Message; if (ex.InnerException != null) { outMessage = ex.InnerException.Message; } m_isUploadingCompleted = true; DelegateUpdateGridRow pdSteps = new DelegateUpdateGridRow(UpdataGridRows); this.Invoke(pdSteps, new object[] { false, "Exception in CopyIntoItemsCompleted Event." + outMessage, sucessURL, uploadData }); // ShowMessageBox(ex.Message, MessageBoxIcon.Error); } } catch (Exception ex) { EncodingAndDecoding.ShowMessageBox("UploadDataAsync", ex.Message, MessageBoxIcon.Error); } }
/// <summary> /// <c>ListItemCompleted</c> function /// gets uploaded file url and calls <c>UpdataGridRows</c> method to add new row in grid. /// </summary> /// <param name="ndvolListItem"></param> /// <param name="uitemdata"></param> public void ListItemCompleted(XmlNode ndvolListItem, UploadItemsData uitemdata) { try { XmlNode ndVolunteerListItems = ndvolListItem; string test = uitemdata.UploadFileName; if (ndVolunteerListItems != null) { if (ndVolunteerListItems.ChildNodes.Count == 3) { if (ndVolunteerListItems.ChildNodes[1].ChildNodes.Count > 1) { string id = Convert.ToString(ndVolunteerListItems.ChildNodes[1].ChildNodes[1].Attributes["ows_ID"].Value); ////////// UpdateItemAttributes(id, uitemdata); ////////// string sucessURL1 = m_LibSite + m_uploadFolderNode.ChildNodes[3].InnerText + "/Forms/EditForm.aspx?ID=" + id + "&UpFName=" + uitemdata.UploadFileName; ; m_isUploadingCompleted = true; DelegateUpdateGridRow pdSteps = new DelegateUpdateGridRow(UpdataGridRows); this.Invoke(pdSteps, new object[] { true, "Success", sucessURL1, uitemdata }); UploadItemsData item = uitemdata; //(UploadItemsData)e.UserState; //try //{ // string fileCheckin = m_sharepointLibraryURL.Substring(0, m_sharepointLibraryURL.LastIndexOf("Forms")) + item.UploadFileName; // bool b = listService.CheckInFile(fileCheckin, "Uplaod Completed.", "1"); //} //catch (Exception ex) //{ //} } } } } catch (Exception ex) { string outMessage1 = ex.Message; if (ex.InnerException != null) { outMessage1 = ex.InnerException.Message; } m_isUploadingCompleted = true; DelegateUpdateGridRow pdSteps = new DelegateUpdateGridRow(UpdataGridRows); this.Invoke(pdSteps, new object[] { false, "Exception in GetListItemsCompleted Event." + outMessage1, " ", uitemdata }); } }