简体   繁体   English

使用C#进行Docusign移动信封-如何将XML / JSON请求和“ PUT”方法转换为有效的C#代码?

[英]Docusign Move Envelope using C# - How can I turn XML/JSON requests and “PUT” methods into working C# code?

First, my code: 首先,我的代码:

    string accountID = loginInfo.LoginAccounts[0].AccountId;

        Console.WriteLine("Account ID:" + accountID);
        FoldersApi foldApi = new FoldersApi();
        var folders = foldApi.List(accountID);
        //this is pointing to my "Sent" folder
        string folderID = folders.Folders[1].FolderId;
        var envID = foldApi.ListItems(accountID, folderID);

        foreach (FolderItem fi in envID.FolderItems)
        {
            EnvelopesApi envApi = new EnvelopesApi();

            EnvelopeDocumentsResult docsList = envApi.ListDocuments(accountID, fi.EnvelopeId);
            Recipients listRecip = envApi.ListRecipients(accountID, fi.EnvelopeId);
            string listOfInfo = "";
            Envelope myEnv = envApi.GetEnvelope(accountID, fi.EnvelopeId);
            if (myEnv.Status == "completed")
            {
                foreach (var signer in listRecip.Signers)
                {
                    var listTabs = envApi.ListTabs(accountID, fi.EnvelopeId, signer.RecipientId);
                    foreach (var tab in listTabs.TextTabs)
                    {
                        //listOfInfo is for each specific document, just to view results
                        listOfInfo += tab.TabLabel + " - " + tab.Value + " \n ";
                        //bigString is an aggregation of all documents tab values
                        bigString += tab.TabLabel + " - " + tab.Value + " \n ";
                    }
                    Console.WriteLine("Stop here");//breakpoint
                }
                //Move code should go here.
            }
        }

Currently my code enters into my account, gets a list of all the folders, and I then point towards my "Sent" folder. 当前,我的代码进入我的帐户,获取所有文件夹的列表,然后指向“已发送”文件夹。 After that, I look at all of the documents in the sent folder, check if their status is "completed", and when it is, go "into" that document and strip out all of the information living in the texttabs I've placed on a document. 之后,我查看已发送文件夹中的所有文档,检查它们的状态是否为“完成”,然后查看状态,进入该文档并删除我放置的文本选项卡中的所有信息。在文档上。

Onto my question! 我的问题! Where the comment "//Move code should go here." 注释“ //将代码移到此处”的位置。 after I have stripped out my needed information, I would like to move an envelope from my "Sent" folder (Folders[1]) and place it into my "Loaded" folder (Folders[3]). 删除所需信息后,我想从“已发送”文件夹(文件夹[1])中移动信封并将其放入“已加载”文件夹(文件夹[3])中。

I have reviewed : https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Move%20Envelope.htm 我已经审查了: https : //www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Move%20Envelope.htm

but I am unable to make sense of how to turn XML/JSON requests and "PUT" methods into working C# code. 但是我无法理解如何将XML / JSON请求和“ PUT”方法转换为有效的C#代码。

Any assistance would be greatly appreciated. 任何帮助将不胜感激。 Thanks, 谢谢,

-Kyle. 凯尔

Updated Code. 更新的代码。

        Console.WriteLine("Account ID:" + accountID);
        FoldersApi foldApi = new FoldersApi();
        //create fr object
        FoldersRequest fr = new FoldersRequest();
        //instantiate EnvelopeIds string list, to a new string list..
        fr.EnvelopeIds = new List<string>();
        //get folders
        var folders = foldApi.List(accountID);
        string sentFolderID = "";
        string loadedFolderID = "";
        foreach (var fold in folders.Folders)
        {//get sent/loaded folder IDs
            if (fold.Name == "Sent Items") { sentFolderID = fold.FolderId; }
            else if(fold.Name == "Loaded") { loadedFolderID = fold.FolderId; }
        }
        //list the items in the folder
        var envID = foldApi.ListItems(accountID, sentFolderID);
        //for each item in the folder...
        foreach (FolderItem fi in envID.FolderItems)
        {
            EnvelopesApi envApi = new EnvelopesApi();
            //get a list of documents in the envelope
            EnvelopeDocumentsResult docsList = envApi.ListDocuments(accountID, fi.EnvelopeId);
            //list recipients
            Recipients listRecip = envApi.ListRecipients(accountID, fi.EnvelopeId);
            string listOfInfo = "";
            Envelope myEnv = envApi.GetEnvelope(accountID, fi.EnvelopeId);
            if (myEnv.Status == "completed")
            {
                foreach (var signer in listRecip.Signers)
                {
                    var listTabs = envApi.ListTabs(accountID, fi.EnvelopeId, signer.RecipientId);
                    foreach (var tab in listTabs.TextTabs)
                    {
                        //get info out of document
                        listOfInfo += tab.TabLabel + " - " + tab.Value + " \n ";
                        bigString += tab.TabLabel + " - " + tab.Value + " \n ";
                    }
                    Console.WriteLine("Stop here");//breakpoint
                }
                //add this envelope ID to the list of envelopes to be moved
                fr.EnvelopeIds.Add(myEnv.EnvelopeId);                    
            }
        }
        //move all the envelopes in the list
        if (fr.EnvelopeIds.Count >= 1) { foldApi.MoveEnvelopes(accountID, loadedFolderID, fr); }

I found a solution. 我找到了解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM