Beispiel #1
0
        public IEnumerable <FieldDTO> GetTemplateUserDefinedFields(string templateId, string envelopeId = null)
        {
            if (String.IsNullOrEmpty(templateId))
            {
                throw new ArgumentNullException(nameof(templateId));
            }
            var conf = DocuSignManager.SetUp(AuthorizationToken);

            return(DocuSignManager.GetTemplateRecipientsAndTabs(conf, templateId).Select(x => new FieldDTO(x.Key)
            {
                Tags = x.Tags
            }));
        }
Beispiel #2
0
        public ControlDefinitionDTO CreateFolderDropDownListControl(string key, AuthorizationToken authToken)
        {
            var conf = _docuSignManager.SetUp(AuthorizationToken);

            return(new DropDownList()
            {
                Name = "QueryField_" + key,
                ListItems = DocuSignFolders.GetFolders(conf)
                            .Select(x => new ListItem()
                {
                    Key = x.Key, Value = x.Value
                })
                            .ToList()
            });
        }
        public async Task <PollingDataDTO> Poll(PollingDataDTO pollingData)
        {
            var          config = _docuSignManager.SetUp(pollingData.AuthToken);
            EnvelopesApi api    = new EnvelopesApi((Configuration)config.Configuration);
            List <DocuSignEnvelopeCM_v2> changed_envelopes = new List <DocuSignEnvelopeCM_v2>();

            // 1. Poll changes

            var changed_envelopes_info = api.ListStatusChanges(config.AccountId, new EnvelopesApi.ListStatusChangesOptions()
            {
                fromDate = DateTime.UtcNow.AddMinutes(-Convert.ToInt32(pollingData.PollingIntervalInMinutes)).ToString("o")
            });

            foreach (var envelope in changed_envelopes_info.Envelopes)
            {
                var envelopeCM = new DocuSignEnvelopeCM_v2()
                {
                    EnvelopeId            = envelope.EnvelopeId,
                    Status                = envelope.Status,
                    StatusChangedDateTime = DateTime.Parse(envelope.StatusChangedDateTime),
                    ExternalAccountId     = JToken.Parse(pollingData.AuthToken)["Email"].ToString(),
                };

                changed_envelopes.Add(envelopeCM);
            }

            // 2. Check if we processed these envelopes before and if so - retrieve them

            //TODO: add overlapping minute handling
            var recorded_crates = new List <DocuSignEnvelopeCM_v2>();

            //    var recorded_crates = await _hubCommunicator.GetStoredManifests(curFr8UserId, changed_envelopes);
            // 3. Fill polled envelopes with data
            changed_envelopes = FillChangedEnvelopesWithData(config, changed_envelopes);
            // 4. Exclude envelopes that came from a 1 minute overlap
            var envelopesToNotify = ExcludeCollisions(changed_envelopes, recorded_crates);

            // 5. Push envelopes to event controller
            await PushEnvelopesToTerminalEndpoint(envelopesToNotify);

            pollingData.Result = true;
            return(pollingData);
        }
        public override async Task Run()
        {
            //Get envlopeId from configuration
            var    control    = GetControl <TextSource>("EnvelopeIdSelector");
            string envelopeId = control.TextValue;

            if (envelopeId.IsGuid())
            {
                try
                {
                    var conf     = _docusihManager.SetUp(AuthorizationToken.Token);
                    var envelope = _docusihManager.GetEnvelope(conf, envelopeId);
                    envelope.ExternalAccountId = AuthorizationToken.ExternalAccountId;
                    Payload.Add <DocuSignEnvelopeCM_v2>(AllFieldsCrateName, envelope);
                }
                catch { RaiseError($"Couldn't find an envelope with id={envelopeId}"); return; }
            }
            else
            {
                RaiseError("EnvelopeId is invalid"); return;
            }

            Success();
        }
Beispiel #5
0
        //only create a connect when running on dev/production
        public void CreateConnect(IHubCommunicator hubCommunicator, AuthorizationToken authToken)
        {
            Logger.Info($"CreateConnect called {authToken.UserId}");
            var authTokenDO = new AuthorizationTokenDO()
            {
                Token = authToken.Token, ExternalAccountId = authToken.ExternalAccountId
            };
            var    config        = _docuSignManager.SetUp(authToken);
            string terminalUrl   = CloudConfigurationManager.GetSetting("terminalDocuSign.TerminalEndpoint");
            string prodUrl       = CloudConfigurationManager.GetSetting("terminalDocuSign.DefaultProductionUrl");
            string devUrl        = CloudConfigurationManager.GetSetting("terminalDocuSign.DefaultDevUrl");
            string demoUrl       = CloudConfigurationManager.GetSetting("terminalDocuSign.DefaultDemoUrl");
            bool   isSelfHosting = CloudConfigurationManager.GetSetting("terminalDocusign.NotSelfHosting") == null;
            string connectName   = "";
            string connectId     = "";

            Logger.Info($"CreateConnect terminalUrl {terminalUrl}");
            if (!isSelfHosting)
            {
                if (terminalUrl.Contains(devUrl, StringComparison.InvariantCultureIgnoreCase))
                {
                    connectName = DevConnectName;
                    // DS doesn't accept port in url, so instead of
                    //http://dev-terminals.fr8.co:53234/terminals/terminalDocuSign/events
                    // we should use
                    //http://dev-terminaldocusign.fr8.co/terminals/terminalDocuSign/events
                    terminalUrl = CloudConfigurationManager.GetSetting("terminalDocuSign.OverrideDevUrl");
                }
                else
                if (terminalUrl.Contains(prodUrl, StringComparison.InvariantCultureIgnoreCase))
                {
                    connectName = ProdConnectName;
                }
                else
                if (terminalUrl.Contains(demoUrl, StringComparison.InvariantCultureIgnoreCase))
                {
                    connectName = DemoConnectName;
                }
                else
                {
                    Logger.Info($"Unable to set connectName from {terminalUrl}");
                }

                string publishUrl = terminalUrl + "/terminals/terminalDocuSign/events";

                Logger.Info("Connect creation: publishUrl = {0}");

                if (!string.IsNullOrEmpty(connectName))
                {
                    connectId = _docuSignConnect.CreateOrActivateConnect(config, connectName, publishUrl);
                    Logger.Info($"Created connect named {connectName} pointing to {publishUrl} with id {connectId}");
                }
                else
                {
                    // terminal has a temporary url
                    var connectsInfo = _docuSignConnect.ListConnects(config);
                    var connects     = connectsInfo.Where(a => a.name == TemporaryConnectName).ToList();
                    foreach (var connect in connects)
                    {
                        _docuSignConnect.DeleteConnect(config, connect.connectId);
                    }

                    connectId = _docuSignConnect.CreateConnect(config, TemporaryConnectName, publishUrl);
                    Logger.Info($"Created connect named {TemporaryConnectName} pointing to {publishUrl} with id {connectId}");
                }
            }
            else
            {
                Logger.Info($"terminalUrl is empty, no work has been done in DocuSignPlan.CreateConnect: prodUrl -> {prodUrl}, devUrl -> {devUrl}, demoUrl -> {demoUrl}");
            }
        }