Пример #1
0
        //==========================================================================================
        // *** Walkthrough #7 - Embedded Sending
        //==========================================================================================
        private void EmbeddedSending()
        {
            //*****************************************************************
            // ENTER VALUES FOR FOLLOWING VARIABLES!
            //*****************************************************************
            string AccountEmail = "***";
            string AccountPassword = "******";
            string documentPath = "***";
            //*****************************************************************

            // user credentials 
            Account account = new Account();
            account.Email = AccountEmail;
            account.Password = AccountPassword;

            // make the login call (retrieves your baseUrl and accountId)
            bool result = account.Login();
            if (!result)
            {
                Console.WriteLine("Login API call failed for user {0}.\nError Code:  {1}\nMessage:  {2}", account.Email, account.RestError.errorCode, account.RestError.message);
                return;
            }

            // create envelope object and assign login info
            Envelope envelope = new Envelope();
            envelope.Login = account;

            // create a new DocuSign envelope (i.e. server side)
            envelope.Create(documentPath);

            // generate sender view token
            result = envelope.GetSenderView("http://www.nuget.org/packages/DocuSign.Integration.Client.dll/");

            if (!result)
            {
                if (envelope.RestError != null)
                {
                    Console.WriteLine("Error code:  {0}\nMessage:  {1}", envelope.RestError.errorCode, envelope.RestError.message);
                    return;
                }
                else
                {
                    Console.WriteLine("Error encountered retrieving signing token, please review your envelope and recipient data.");
                    return;
                }
            }
            else
            {
                // open the envelope's sending view
                Process.Start(envelope.SenderViewUrl);
            }
        }