private void btnCreate_Click_1(object sender, System.EventArgs e)
        {
            long   lngPropCount       = 1;
            long   lngActionCount     = 1;
            string strContentLocation = "";
            string strRetrievalName   = "";
            ulong  ulContentSize      = 0;

            // If content was specified, do some sanity checks and prepare...
            if (chkContent.Checked)
            {
                // Extract the location, retrieval name, and MIME type
                if (txtContentLocation.Text == "")
                {
                    MessageBox.Show("Looks like you forgot to specify a content location - aborting");
                    return;
                }
                if (txtMimeType.Text == "")
                {
                    MessageBox.Show("Looks like you forgot to specify a MIME type - aborting");
                    return;
                }
                strContentLocation = txtContentLocation.Text.Replace('/', '\\');
                int nStart = strContentLocation.LastIndexOf('\\');
                strRetrievalName = (nStart > 1) ? strContentLocation.Substring(nStart + 1, (strContentLocation.Length - nStart - 1)) : strContentLocation;

                // Verify that the file exists and get its size
                ulContentSize = getFileContentSize(strContentLocation);
                if (ulContentSize == 0)
                {
                    MessageBox.Show("The specified content file either does not exist, or is of zero length");
                    return;
                }
                lngPropCount += 1;
            }

            // Sanity checks if content by reference was specified...
            if (chkContentReference.Checked)
            {
                if (txtContentURL.Text == "")
                {
                    MessageBox.Show("Looks like you forgot to specify a content URL - aborting");
                    return;
                }
                if (txtMimeType.Text == "")
                {
                    MessageBox.Show("Looks like you forgot to specify a MIME type - aborting");
                    return;
                }
                lngPropCount += 1;
            }

            // Get the WS binding object
            //  (this will be used to set WS-Security parameters)
            CEWSI.FNCEWS40PortTypeClient objBinding = WSIUtil.ConfigureBinding(MainForm.User,
                                                                               MainForm.Domain, MainForm.Password, MainForm.URL);

            // We first need to create a Create verb, populate it
            CEWSI.CreateAction createVerb = new CEWSI.CreateAction();
            createVerb.classId = txtDocClass.Text;

            // If the user wants to check the document in, then we'll add a separate
            //  Checkin verb as well
            CEWSI.CheckinAction checkinVerb = new CEWSI.CheckinAction();
            if (chkCheckIn.Checked)
            {
                checkinVerb.checkinMinorVersion          = true;
                checkinVerb.checkinMinorVersionSpecified = true;
                lngActionCount += 1;
            }

            CEWSI.ChangeRequestType objChange = new CEWSI.ChangeRequestType();
            objChange.Action    = new CEWSI.ActionType[lngActionCount];
            objChange.Action[0] = (CEWSI.ActionType)createVerb;
            if (chkCheckIn.Checked)
            {
                objChange.Action[1] = (CEWSI.ActionType)checkinVerb;
            }

            objChange.TargetSpecification          = new CEWSI.ObjectReference();
            objChange.TargetSpecification.classId  = "ObjectStore";
            objChange.TargetSpecification.objectId = MainForm.Library;
            objChange.id = "1";

            // Build a list of properties to set in the new document
            CEWSI.ModifiablePropertyType[] objInputProps = new CEWSI.ModifiablePropertyType[lngPropCount];
            CEWSI.SingletonString          objString     = new CEWSI.SingletonString();
            objString.Value      = txtTitle.Text;
            objString.propertyId = "DocumentTitle";
            objInputProps[0]     = objString;

            if (chkContent.Checked || chkContentReference.Checked)
            {
                // Create content properties array
                //   ContentTransfer elements will take three properties:
                //		* RetrievalName
                //		* Content
                //		* ContentType
                //   ContentReference elements will take two properties:
                //		* ContentLocation
                //		* ContentType
                CEWSI.PropertyType[] ctProps = null;
                if (chkContent.Checked)
                {
                    ctProps = new CEWSI.PropertyType[3];
                }
                else
                {
                    ctProps = new CEWSI.PropertyType[2];
                }

                // Set the ContentType property
                CEWSI.SingletonString typeProp = new CEWSI.SingletonString();
                typeProp.propertyId = "ContentType";
                typeProp.Value      = txtMimeType.Text;
                ctProps[0]          = typeProp;

                // Create the dependent object type object
                CEWSI.DependentObjectType ct = new CEWSI.DependentObjectType();
                ct.dependentAction          = CEWSI.DependentObjectTypeDependentAction.Insert;
                ct.dependentActionSpecified = true;

                // ContentTransfer case
                if (chkContent.Checked)
                {
                    // create RetrievalName name property
                    CEWSI.SingletonString nameProp = new CEWSI.SingletonString();
                    nameProp.propertyId = "RetrievalName";
                    nameProp.Value      = strRetrievalName;
                    ctProps[1]          = nameProp;

                    // create content data object
                    CEWSI.ContentData contData = new CEWSI.ContentData();
                    contData.propertyId = "Content";

                    CEWSI.InlineContent ic = new CEWSI.InlineContent();
                    ic.Binary = getSouceFileContent(strContentLocation);

                    contData.Value = ic;
                    ctProps[2]     = contData;

                    // Dependent object is of type ContentTransfer
                    ct.classId = "ContentTransfer";
                }

                // ContentReference case
                else
                {
                    // Create the ContentLocation property
                    CEWSI.SingletonString locationProp = new CEWSI.SingletonString();
                    locationProp.propertyId = "ContentLocation";
                    locationProp.Value      = txtContentURL.Text;
                    ctProps[1] = locationProp;

                    // Dependent object is of type ContentReference
                    ct.classId = "ContentReference";
                }

                //	create content object list
                ct.Property = ctProps;
                CEWSI.DependentObjectType[] contentObjects = new CEWSI.DependentObjectType[1];
                contentObjects[0] = ct;

                //	Create the content element list and set it into the document's properties
                CEWSI.ListOfObject objContentList = new CEWSI.ListOfObject();
                objContentList.propertyId = "ContentElements";
                objContentList.Value      = contentObjects;
                objInputProps[1]          = objContentList;
            }
            objChange.ActionProperties = objInputProps;

            // 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 document: [" + ex.Message + "]");
                return;
            }
            catch (Exception allEx)
            {
                MessageBox.Show("An exception occurred: [" + allEx.Message + "]");
                return;
            }


            // Created a document!  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 document was created, but the results do not contain a document ID!");
                return;
            }

            if (chkFile.Checked)
            {
                MessageBox.Show("Successfully created a document!  ID = [" + strObjectId + "].  Now filing.");
                FileDoc(strObjectId, txtDocClass.Text, txtTitle.Text, txtFolderName.Text);
            }
            else
            {
                MessageBox.Show("Successfully created a document!  ID = [" + strObjectId + "]");
            }
            return;
        }
Пример #2
0
        /////////////////////////////////////////////////////////////
        //
        //	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;
        }
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            // We first need to create a Create verb, populate it
            CEWSI.CreateAction createVerb = new CEWSI.CreateAction();

            CEWSI.ChangeRequestType objChange = new CEWSI.ChangeRequestType();
            objChange.Action = new CEWSI.ActionType[1];
            objChange.TargetSpecification          = new CEWSI.ObjectReference();
            objChange.TargetSpecification.classId  = "ObjectStore";
            objChange.TargetSpecification.objectId = 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
            //   IsNameProperty		Boolean
            //   Cardinality		Integer
            //   IsPersistent		Boolean
            //   DisplayNames		ListOfObject
            CEWSI.ModifiablePropertyType[] objInputProps = new CEWSI.ModifiablePropertyType[5];

            // Symbolic name
            CEWSI.SingletonString objSymName = new CEWSI.SingletonString();
            objSymName.Value      = txtSymName.Text;
            objSymName.propertyId = "SymbolicName";
            objInputProps[0]      = objSymName;

            // Hardcode the IsNameProperty for now
            CEWSI.SingletonBoolean objIsName = new CEWSI.SingletonBoolean();
            objIsName.Value          = false;
            objIsName.ValueSpecified = true;
            objIsName.propertyId     = "IsNameProperty";
            objInputProps[1]         = objIsName;

            // Hardcode the Cardinality for now
            CEWSI.SingletonInteger32 objCardinality = new CEWSI.SingletonInteger32();
            objCardinality.Value          = 0;
            objCardinality.ValueSpecified = true;
            objCardinality.propertyId     = "Cardinality";
            objInputProps[2] = objCardinality;

            // Hardcode the IsPersistent property for now
            CEWSI.SingletonBoolean objIsPersistent = new CEWSI.SingletonBoolean();
            objIsPersistent.Value          = true;
            objIsPersistent.ValueSpecified = true;
            objIsPersistent.propertyId     = "IsPersistent";
            objInputProps[3] = objIsPersistent;

            // 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      = txtSymName.Text;
            nameProps[1]       = objText;
            dispName.Property  = nameProps;

            objInputProps[4] = objNameList;

            // Set the class of the new template according to the data type
            switch (cmbDataType.Text)
            {
            case "String":
                createVerb.classId = "PropertyTemplateString";
                break;

            case "Boolean":
                createVerb.classId = "PropertyTemplateBoolean";
                break;

            case "Float":
                createVerb.classId = "PropertyTemplateFloat64";
                break;

            case "Integer":
                createVerb.classId = "PropertyTemplateInteger32";
                break;

            case "ID":
                createVerb.classId = "PropertyTemplateId";
                break;

            case "Object":
                createVerb.classId = "PropertyTemplateObject";
                break;

            case "Binary":
                createVerb.classId = "PropertyTemplateBinary";
                break;

            case "DateTime":
                createVerb.classId = "PropertyTemplateDateTime";
                break;

            default:
                MessageBox.Show("Invalid property type selected!");
                return;
            }
            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 property template: [" + ex.Message + "]");
                return;
            }
            catch (Exception allEx)
            {
                MessageBox.Show("An exception occurred: [" + allEx.Message + "]");
                return;
            }


            // Created a template!  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 property template was created, but the results do not contain an ID!");
                return;
            }
            MessageBox.Show("Successfully created a property template!  ID = [" + strObjectId + "]");
            return;
        }
Пример #5
0
        public static EcmResult CreateDoc(DocumentModel doc)
        {
            EcmResult ret = new EcmResult();

            //string mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
            bool isCheckin = false;

            if (doc.IsUseCert == 1)
            {
                Addcert(doc.EcmUrl);
            }

            CEWSI.FNCEWS40PortTypeClient objBinding = WSIUtil.ConfigureBinding(doc.EcmUser, doc.EcmDomain, doc.EcmPassword, doc.EcmUrl);

            CEWSI.CreateAction createVerb = new CEWSI.CreateAction();
            createVerb.classId = doc.DocumentClass;

            CEWSI.CheckinAction checkinVerb = new CEWSI.CheckinAction();
            if (isCheckin)
            {
                checkinVerb.checkinMinorVersion          = true;
                checkinVerb.checkinMinorVersionSpecified = true;
            }

            CEWSI.ChangeRequestType objChange = new CEWSI.ChangeRequestType();
            objChange.Action    = new CEWSI.ActionType[2];
            objChange.Action[0] = (CEWSI.ActionType)createVerb;
            objChange.Action[1] = (CEWSI.ActionType)checkinVerb;

            objChange.TargetSpecification          = new CEWSI.ObjectReference();
            objChange.TargetSpecification.classId  = "ObjectStore";
            objChange.TargetSpecification.objectId = doc.ObjectStore;
            objChange.id = "1";

            int propLength = doc.Properties != null && doc.Properties.Count > 0 ? doc.Properties.Count + 1 : 1;

            CEWSI.ModifiablePropertyType[] objInputProps = new CEWSI.ModifiablePropertyType[propLength];

            #region properties have the must
            CEWSI.PropertyType[] ctProps = new CEWSI.PropertyType[3];

            CEWSI.SingletonString typeProp = new CEWSI.SingletonString();
            typeProp.propertyId = "ContentType";
            typeProp.Value      = doc.MimeTypeSource;
            ctProps[0]          = typeProp;

            CEWSI.DependentObjectType ct = new CEWSI.DependentObjectType();
            ct.dependentAction          = CEWSI.DependentObjectTypeDependentAction.Insert;
            ct.dependentActionSpecified = true;

            CEWSI.SingletonString nameProp = new CEWSI.SingletonString();
            nameProp.propertyId = "RetrievalName";
            nameProp.Value      = doc.FileName;
            ctProps[1]          = nameProp;

            CEWSI.ContentData contData = new CEWSI.ContentData();
            contData.propertyId = "Content";

            CEWSI.InlineContent ic = new CEWSI.InlineContent();
            ic.Binary = doc.BinaryFile;

            contData.Value = ic;
            ctProps[2]     = contData;

            ct.classId = "ContentTransfer";

            //	create content object list
            ct.Property = ctProps;
            CEWSI.DependentObjectType[] contentObjects = new CEWSI.DependentObjectType[1];
            contentObjects[0] = ct;

            //	Create the content element list and set it into the document's properties
            CEWSI.ListOfObject objContentList = new CEWSI.ListOfObject();
            objContentList.propertyId = "ContentElements";
            objContentList.Value      = contentObjects;
            objInputProps[0]          = objContentList;
            #endregion

            if (doc.Properties != null && doc.Properties.Count > 0)
            {
                int i = 1;
                foreach (var p in doc.Properties)
                {
                    CEWSI.SingletonString objProp = new CEWSI.SingletonString();
                    objProp.propertyId = p.Key;
                    objProp.Value      = p.Value;
                    objInputProps[i++] = objProp;
                }
            }

            objChange.ActionProperties = objInputProps;

            // 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)
            {
                //Console.WriteLine("An exception occurred while creating a document: [" + ex.Message + "]");
                ret.ErrorCode = -1;
                ret.ErrorMsg  = ex.ToString();
                return(ret);
            }
            catch (Exception allEx)
            {
                //Console.WriteLine("An exception occurred: [" + allEx.Message + "]");
                ret.ErrorCode = -1;
                ret.ErrorMsg  = allEx.ToString();
                return(ret);
            }

            // Created a document!  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 document was created, but the results do not contain a document ID";
                return(ret);
            }

            //Console.WriteLine("Successfully created a document!  ID = [" + strObjectId + "].  Now filing.");

            ret = FileDoc(new EcmInfo
            {
                DocId       = strObjectId,
                DocClass    = doc.DocumentClass,
                DocTitle    = doc.FileName,
                FolderPath  = doc.DestinationFolder,
                ObjectStore = doc.ObjectStore,
                User        = doc.EcmUser,
                Domain      = doc.EcmDomain,
                Password    = doc.EcmPassword,
                Url         = doc.EcmUrl
            });
            ret.DocId    = strObjectId;
            ret.FileName = doc.FileName;
            ret.Mime     = doc.MimeTypeSource;

            return(ret);
        }