private void FileDoc(string strDocId, string strDocClass, string strDocTitle, string strFolderPath) { // Create a Create verb, populate it to create a new RCR CEWSI.CreateAction createVerb = new CEWSI.CreateAction(); createVerb.autoUniqueContainmentName = true; createVerb.autoUniqueContainmentNameSpecified = true; createVerb.classId = "DynamicReferentialContainmentRelationship"; CEWSI.ChangeRequestType objChange = new CEWSI.ChangeRequestType(); objChange.Action = new CEWSI.ActionType[1]; objChange.Action[0] = (CEWSI.ActionType)createVerb; objChange.TargetSpecification = new CEWSI.ObjectReference(); objChange.TargetSpecification.classId = "ObjectStore"; objChange.TargetSpecification.objectId = MainForm.Library; objChange.id = "1"; // Create the properties of the new RCR CEWSI.ObjectReference objHeadRef = new CEWSI.ObjectReference(); objHeadRef.classId = strDocClass; objHeadRef.objectId = strDocId; objHeadRef.objectStore = MainForm.Library; CEWSI.SingletonObject propHead = new CEWSI.SingletonObject(); propHead.propertyId = "Head"; propHead.Value = (CEWSI.ObjectEntryType)objHeadRef; CEWSI.ObjectReference objTailRef = new CEWSI.ObjectReference(); objTailRef.classId = "Folder"; objTailRef.objectId = strFolderPath; objTailRef.objectStore = MainForm.Library; CEWSI.SingletonObject propTail = new CEWSI.SingletonObject(); propTail.propertyId = "Tail"; propTail.Value = (CEWSI.ObjectEntryType)objTailRef; CEWSI.SingletonString propContainmentName = new CEWSI.SingletonString(); propContainmentName.propertyId = "ContainmentName"; propContainmentName.Value = strDocTitle; CEWSI.ModifiablePropertyType[] objProps = new CEWSI.ModifiablePropertyType[3]; objProps[0] = propTail; objProps[1] = propHead; objProps[2] = propContainmentName; objChange.ActionProperties = objProps; // Fill in the security headers... CEWSI.FNCEWS40PortTypeClient objBinding = WSIUtil.ConfigureBinding(MainForm.User, MainForm.Domain, MainForm.Password, MainForm.URL); // Send off the request CEWSI.ChangeResponseType[] objResponseArray = null; CEWSI.ExecuteChangesRequest objRequest = new CEWSI.ExecuteChangesRequest(); objRequest.refresh = false; objRequest.refreshSpecified = true; objRequest.ChangeRequest = new CEWSI.ChangeRequestType[1]; objRequest.ChangeRequest[0] = objChange; try { objResponseArray = objBinding.ExecuteChanges(WSIUtil.GetLocalization(), objRequest); } catch (System.Net.WebException ex) { MessageBox.Show("An exception occurred while filing a document: [" + ex.Message + "]"); return; } catch (Exception allEx) { MessageBox.Show("An exception occurred: [" + allEx.Message + "]"); return; } MessageBox.Show("Successfully filed a document!"); return; }
///////////////////////////////////////////////////////////// // // Get property value in string format // ///////////////////////////////////////////////////////////// public static string getPropertyValue(CEWSI.PropertyType objProp) { if (objProp == null) { return("null"); } string strValue = ""; Type objType = objProp.GetType(); if (objType == typeof(CEWSI.SingletonString)) { strValue = (string)((CEWSI.SingletonString)objProp).Value; } else if (objType == typeof(CEWSI.SingletonBoolean)) { strValue = (string)((CEWSI.SingletonBoolean)objProp).Value.ToString(); } else if (objType == typeof(CEWSI.SingletonDateTime)) { strValue = (string)((CEWSI.SingletonDateTime)objProp).Value.ToString(); } else if (objType == typeof(CEWSI.SingletonFloat64)) { strValue = (string)((CEWSI.SingletonFloat64)objProp).Value.ToString(); } else if (objType == typeof(CEWSI.SingletonId)) { strValue = (string)((CEWSI.SingletonId)objProp).Value; } else if (objType == typeof(CEWSI.SingletonInteger32)) { strValue = (string)((CEWSI.SingletonInteger32)objProp).Value.ToString(); } else if (objType == typeof(CEWSI.SingletonObject)) { CEWSI.SingletonObject objSO = (CEWSI.SingletonObject)objProp; if (objSO.Value == null) { strValue = "null"; } else { try { CEWSI.ObjectReference objRef = (CEWSI.ObjectReference)objSO.Value; strValue = (string)(objRef.objectId); } catch (System.Exception) { strValue = "Unevaluated"; } } } else if (objType == typeof(CEWSI.EnumOfObject)) { StringBuilder buffer = new StringBuilder(); CEWSI.EnumOfObject objEnum = (CEWSI.EnumOfObject)objProp; if ((CEWSI.ObjectValue[])objEnum.Value != null) { buffer.Append("\r\n"); foreach (CEWSI.ObjectValue obj in (CEWSI.ObjectValue[])objEnum.Value) { buffer.Append(" " + obj.objectId + "\r\n"); } } strValue = buffer.ToString(); } else if (objType == typeof(CEWSI.ListOfString)) { if (((CEWSI.ListOfString)objProp).Value != null) { StringBuilder buffer = new StringBuilder(); foreach (string str in (string[])((CEWSI.ListOfString)objProp).Value) { buffer.Append(str + ","); } strValue = buffer.ToString(); } } else if (objType == typeof(CEWSI.ListOfObject)) { CEWSI.ListOfObject objList = (CEWSI.ListOfObject)objProp; if (objProp.propertyId == "ContentElements") { strValue = ("ContentElements"); } else { if (objList != null) { StringBuilder buffer = new StringBuilder(); foreach (CEWSI.DependentObjectType obj in (CEWSI.DependentObjectType[])((CEWSI.ListOfObject)objList).Value) { buffer.Append(obj.classId + ", "); } strValue = buffer.ToString(); } } } else { strValue = (string)objProp.ToString(); } //buffer.Append((objRet == null) ? "null" : objRet.ToString()); return(strValue); }
private void btnCreateSubclass_Click(object sender, System.EventArgs e) { String strParentClassName; String strParentClassId; int iRow; CEWSI.PropertyType prop; CEWSI.ObjectReference objRef; // First find the selected parent class, and extract the name and ID for it iRow = dgrdResults.CurrentRowIndex; if (iRow < 0) { MessageBox.Show("Please select a class first"); return; } prop = g_Classes[iRow].Property[4]; if (prop == null) { MessageBox.Show("Cannot find the This property"); return; } if (prop.GetType() == typeof(CEWSI.SingletonObject)) { CEWSI.SingletonObject objSO = (CEWSI.SingletonObject)prop; objRef = (CEWSI.ObjectReference)((CEWSI.SingletonObject)prop).Value; try { objRef = (CEWSI.ObjectReference)objSO.Value; strParentClassName = objRef.classId; strParentClassId = objRef.objectId; } catch (System.Exception) { MessageBox.Show("Cannot extract the class and Id of the selected item"); return; } } else { MessageBox.Show("Expected to find an object valued property"); return; } // Create a Create verb, populate it CEWSI.CreateAction createVerb = new CEWSI.CreateAction(); createVerb.classId = strParentClassName; CEWSI.ChangeRequestType objChange = new CEWSI.ChangeRequestType(); objChange.Action = new CEWSI.ActionType[1]; objChange.TargetSpecification = new CEWSI.ObjectReference(); objChange.TargetSpecification.classId = strParentClassName; objChange.TargetSpecification.objectId = strParentClassId; objChange.TargetSpecification.objectStore = MainForm.Library; objChange.id = "1"; // Build a list of properties to set in the new property template // The following meta-properties will be set: // SymbolicName String // DisplayNames ListOfObject CEWSI.ModifiablePropertyType[] objInputProps = new CEWSI.ModifiablePropertyType[2]; // Symbolic name CEWSI.SingletonString objSymName = new CEWSI.SingletonString(); objSymName.Value = txtSymbolicName.Text; objSymName.propertyId = "SymbolicName"; objInputProps[0] = objSymName; // Set up the DisplayNames property // DisplayNames is a dependent object that has the following properties: // LocaleName String // LocalizedText String CEWSI.ListOfObject objNameList = new CEWSI.ListOfObject(); objNameList.propertyId = "DisplayNames"; CEWSI.DependentObjectType[] theNames = new CEWSI.DependentObjectType[1]; CEWSI.DependentObjectType dispName = new CEWSI.DependentObjectType(); theNames[0] = dispName; objNameList.Value = theNames; dispName.dependentAction = CEWSI.DependentObjectTypeDependentAction.Insert; dispName.dependentActionSpecified = true; dispName.classId = "LocalizedString"; CEWSI.PropertyType[] nameProps = new CEWSI.PropertyType[2]; CEWSI.SingletonString objLocale = new CEWSI.SingletonString(); objLocale.propertyId = "LocaleName"; objLocale.Value = "en-us"; nameProps[0] = objLocale; CEWSI.SingletonString objText = new CEWSI.SingletonString(); objText.propertyId = "LocalizedText"; objText.Value = txtSymbolicName.Text; nameProps[1] = objText; dispName.Property = nameProps; objInputProps[1] = objNameList; objChange.ActionProperties = objInputProps; objChange.Action[0] = (CEWSI.ActionType)createVerb; // Fill in the security headers... CEWSI.FNCEWS40PortTypeClient objBinding = WSIUtil.ConfigureBinding(MainForm.User, MainForm.Domain, MainForm.Password, MainForm.URL); // Send off the request CEWSI.ChangeResponseType[] objResponseArray = null; CEWSI.ExecuteChangesRequest objRequest = new CEWSI.ExecuteChangesRequest(); objRequest.refresh = true; objRequest.refreshSpecified = true; objRequest.ChangeRequest = new CEWSI.ChangeRequestType[1]; objRequest.ChangeRequest[0] = objChange; try { objResponseArray = objBinding.ExecuteChanges(WSIUtil.GetLocalization(), objRequest); } catch (System.Net.WebException ex) { MessageBox.Show("An exception occurred while creating a new class: [" + ex.Message + "]"); return; } catch (Exception allEx) { MessageBox.Show("An exception occurred: [" + allEx.Message + "]"); return; } // Created a class! Sanity check the results string strObjectId = ""; bool bFound = false; if (objResponseArray == null || objResponseArray.Length < 1) { MessageBox.Show("The change request was executed, but a valid object was not returned"); return; } CEWSI.ChangeResponseType objResponse = objResponseArray[0]; foreach (CEWSI.PropertyType objProp in objResponse.Property) { if (objProp.propertyId.CompareTo("Id") == 0) { strObjectId = IdmObjectType.getPropertyValue(objProp); bFound = true; break; } } if (!bFound) { MessageBox.Show("The class was created, but the results do not contain an ID!"); return; } MessageBox.Show("Successfully created a new class! ID = [" + strObjectId + "]"); return; }
public static EcmResult CreateFolder(DocumentModel doc, string folderName, string parentFolder, string folderClass) { EcmResult ret = new EcmResult(); if (doc.IsUseCert == 1) { Addcert(doc.EcmUrl); } CEWSI.ChangeRequestType objChange = new CEWSI.ChangeRequestType(); CEWSI.CreateAction createVerb = new CEWSI.CreateAction(); createVerb.classId = folderClass; objChange.Action = new CEWSI.ActionType[1]; objChange.Action[0] = (CEWSI.ActionType)createVerb; objChange.TargetSpecification = new CEWSI.ObjectReference(); objChange.TargetSpecification.classId = "ObjectStore"; objChange.TargetSpecification.objectId = doc.ObjectStore; objChange.id = "1"; CEWSI.ModifiablePropertyType[] objInputProps = new CEWSI.ModifiablePropertyType[2]; objChange.ActionProperties = objInputProps; // Build a list of properties to set in the new folder (just the folder name and parent for now) // -Folder name property CEWSI.SingletonString objString = new CEWSI.SingletonString(); objString.Value = folderName; objString.propertyId = "FolderName"; objInputProps[0] = objString; // -Parent property CEWSI.ObjectSpecification objSpec = new CEWSI.ObjectSpecification(); CEWSI.SingletonObject objObject = new CEWSI.SingletonObject(); objSpec.classId = "Folder"; objSpec.path = parentFolder; objSpec.objectStore = doc.ObjectStore; objObject.propertyId = "Parent"; objObject.Value = (CEWSI.ObjectEntryType)objSpec; objInputProps[1] = objObject; // Fill in the security headers... CEWSI.FNCEWS40PortTypeClient objBinding = WSIUtil.ConfigureBinding(doc.EcmUser, doc.EcmDomain, doc.EcmPassword, doc.EcmUrl); // Send off the request CEWSI.ChangeResponseType[] objResponseArray = null; CEWSI.ExecuteChangesRequest objRequest = new CEWSI.ExecuteChangesRequest(); objRequest.refresh = true; objRequest.refreshSpecified = true; objRequest.ChangeRequest = new CEWSI.ChangeRequestType[1]; objRequest.ChangeRequest[0] = objChange; try { objResponseArray = objBinding.ExecuteChanges(WSIUtil.GetLocalization(), objRequest); } catch (System.Net.WebException ex) { ret.ErrorCode = -1; ret.ErrorMsg = ex.ToString(); return(ret); } catch (Exception allEx) { ret.ErrorCode = -1; ret.ErrorMsg = allEx.ToString(); return(ret); } // Created a folder! Sanity check the results string strObjectId = ""; bool bFound = false; if (objResponseArray == null || objResponseArray.Length < 1) { ret.ErrorCode = 0; ret.ErrorMsg = "The change request was executed, but a valid object was not returned"; return(ret); } CEWSI.ChangeResponseType objResponse = objResponseArray[0]; foreach (CEWSI.PropertyType objProp in objResponse.Property) { if (objProp.propertyId.CompareTo("Id") == 0) { strObjectId = IdmObjectType.getPropertyValue(objProp); bFound = true; break; } } if (!bFound) { ret.ErrorCode = 0; ret.ErrorMsg = "The folder was created, but the results do not contain a folder ID"; return(ret); } ret.ErrorCode = 1; ret.ErrorMsg = "Successfully created a folder"; ret.DocId = strObjectId; return(ret); }
private static EcmResult FileDoc(EcmInfo info) { EcmResult ret = new EcmResult(); // Create a Create verb, populate it to create a new RCR CEWSI.CreateAction createVerb = new CEWSI.CreateAction(); createVerb.autoUniqueContainmentName = true; createVerb.autoUniqueContainmentNameSpecified = true; createVerb.classId = "DynamicReferentialContainmentRelationship"; CEWSI.ChangeRequestType objChange = new CEWSI.ChangeRequestType(); objChange.Action = new CEWSI.ActionType[1]; objChange.Action[0] = (CEWSI.ActionType)createVerb; objChange.TargetSpecification = new CEWSI.ObjectReference(); objChange.TargetSpecification.classId = "ObjectStore"; objChange.TargetSpecification.objectId = info.ObjectStore; objChange.id = "1"; // Create the properties of the new RCR CEWSI.ObjectReference objHeadRef = new CEWSI.ObjectReference(); objHeadRef.classId = info.DocClass; objHeadRef.objectId = info.DocId; objHeadRef.objectStore = info.ObjectStore; CEWSI.SingletonObject propHead = new CEWSI.SingletonObject(); propHead.propertyId = "Head"; propHead.Value = (CEWSI.ObjectEntryType)objHeadRef; CEWSI.ObjectReference objTailRef = new CEWSI.ObjectReference(); objTailRef.classId = "Folder"; objTailRef.objectId = info.FolderPath; objTailRef.objectStore = info.ObjectStore; CEWSI.SingletonObject propTail = new CEWSI.SingletonObject(); propTail.propertyId = "Tail"; propTail.Value = (CEWSI.ObjectEntryType)objTailRef; CEWSI.SingletonString propContainmentName = new CEWSI.SingletonString(); propContainmentName.propertyId = "ContainmentName"; propContainmentName.Value = info.DocTitle; CEWSI.ModifiablePropertyType[] objProps = new CEWSI.ModifiablePropertyType[3]; objProps[0] = propTail; objProps[1] = propHead; objProps[2] = propContainmentName; objChange.ActionProperties = objProps; // Fill in the security headers... CEWSI.FNCEWS40PortTypeClient objBinding = WSIUtil.ConfigureBinding(info.User, info.Domain, info.Password, info.Url); // Send off the request CEWSI.ChangeResponseType[] objResponseArray = null; CEWSI.ExecuteChangesRequest objRequest = new CEWSI.ExecuteChangesRequest(); objRequest.refresh = false; objRequest.refreshSpecified = true; objRequest.ChangeRequest = new CEWSI.ChangeRequestType[1]; objRequest.ChangeRequest[0] = objChange; try { objResponseArray = objBinding.ExecuteChanges(WSIUtil.GetLocalization(), objRequest); } catch (System.Net.WebException ex) { //Console.WriteLine("An exception occurred while filing a document: [" + ex.Message + "]"); //Console.ReadLine(); ret.ErrorCode = -1; ret.ErrorMsg = ex.ToString(); return(ret); } //catch (Exception allEx) //{ // //Console.WriteLine("An exception occurred: [" + allEx.Message + "]"); // //Console.ReadLine(); // return false; //} //Console.WriteLine("Successfully filed a document!"); //Console.ReadLine(); ret.ErrorCode = 1; ret.ErrorMsg = "Successfully filed a document!"; return(ret); }
private void btnCreate_Click(object sender, System.EventArgs e) { // Create the ChangeRequest CEWSI.ChangeRequestType objChange = new CEWSI.ChangeRequestType(); CEWSI.CreateAction createVerb = new CEWSI.CreateAction(); createVerb.classId = txtFolderClass.Text; objChange.Action = new CEWSI.ActionType[1]; objChange.Action[0] = (CEWSI.ActionType)createVerb; objChange.TargetSpecification = new CEWSI.ObjectReference(); objChange.TargetSpecification.classId = "ObjectStore"; objChange.TargetSpecification.objectId = MainForm.Library; objChange.id = "1"; CEWSI.ModifiablePropertyType[] objInputProps = new CEWSI.ModifiablePropertyType[2]; objChange.ActionProperties = objInputProps; // Build a list of properties to set in the new folder (just the folder name and parent for now) // -Folder name property CEWSI.SingletonString objString = new CEWSI.SingletonString(); objString.Value = txtName.Text; objString.propertyId = "FolderName"; objInputProps[0] = objString; // -Parent property CEWSI.ObjectSpecification objSpec = new CEWSI.ObjectSpecification(); CEWSI.SingletonObject objObject = new CEWSI.SingletonObject(); objSpec.classId = "Folder"; objSpec.path = txtParent.Text; objSpec.objectStore = MainForm.Library; objObject.propertyId = "Parent"; objObject.Value = (CEWSI.ObjectEntryType)objSpec; objInputProps[1] = objObject; // Fill in the security headers... CEWSI.FNCEWS40PortTypeClient objBinding = WSIUtil.ConfigureBinding(MainForm.User, MainForm.Domain, MainForm.Password, MainForm.URL); // Send off the request CEWSI.ChangeResponseType[] objResponseArray = null; CEWSI.ExecuteChangesRequest objRequest = new CEWSI.ExecuteChangesRequest(); objRequest.refresh = true; objRequest.refreshSpecified = true; objRequest.ChangeRequest = new CEWSI.ChangeRequestType[1]; objRequest.ChangeRequest[0] = objChange; try { objResponseArray = objBinding.ExecuteChanges(WSIUtil.GetLocalization(), objRequest); } catch (System.Net.WebException ex) { MessageBox.Show("An exception occurred while creating a folder: [" + ex.Message + "]"); return; } catch (Exception allEx) { MessageBox.Show("An exception occurred: [" + allEx.Message + "]"); return; } // Created a folder! Sanity check the results string strObjectId = ""; bool bFound = false; if (objResponseArray == null || objResponseArray.Length < 1) { MessageBox.Show("The change request was executed, but a valid object was not returned"); return; } CEWSI.ChangeResponseType objResponse = objResponseArray[0]; foreach (CEWSI.PropertyType objProp in objResponse.Property) { if (objProp.propertyId.CompareTo("Id") == 0) { strObjectId = IdmObjectType.getPropertyValue(objProp); bFound = true; break; } } if (!bFound) { MessageBox.Show("The folder was created, but the results do not contain a folder ID!"); return; } MessageBox.Show("Successfully created a folder! ID = [" + strObjectId + "]"); return; }