Exemplo n.º 1
0
        public override async Task RunChildActivities()
        {
            if (ConfigurationControls == null)
            {
                RaiseError("Action was not configured correctly");
            }

            var actionUi = new ActivityUi();

            actionUi.ClonePropertiesFrom(ConfigurationControls);

            // Real-time search.
            var criteria          = JsonConvert.DeserializeObject <List <FilterConditionDTO> >(actionUi.QueryBuilder.Value);
            var existingEnvelopes = new HashSet <string>();
            var searchResult      = new StandardPayloadDataCM {
                Name = "Docusign Report"
            };

            // Merge data from QueryMT action.
            var queryMTResult = Payload.CrateContentsOfType <StandardPayloadDataCM>(x => x.Label == "Found MT Objects")
                                .FirstOrDefault();

            MergeMtQuery(queryMTResult, existingEnvelopes, searchResult);

            // Update report crate.
            Payload.Add(Crate.FromContent("Sql Query Result", searchResult));

            RequestClientActivityExecution("ShowTableReport");
        }
Exemplo n.º 2
0
        public StandardPayloadDataCM TransformStandardTableDataToStandardPayloadData(string curObjectType, StandardTableDataCM tableDataMS)
        {
            var payloadDataMS = new StandardPayloadDataCM()
            {
                PayloadObjects = new List <PayloadObjectDTO>(),
                ObjectType     = curObjectType,
            };

            int         staringRow;
            TableRowDTO columnHeadersRowDTO = null;

            if (tableDataMS.FirstRowHeaders)
            {
                staringRow          = 1;
                columnHeadersRowDTO = tableDataMS.Table[0];
            }
            else
            {
                staringRow = 0;
            }

            // Rows containing column names
            for (int i = staringRow; i < tableDataMS.Table.Count; ++i) // Since first row is headers; hence i starts from 1
            {
                try
                {
                    var tableRowDTO = tableDataMS.Table[i];
                    var fields      = new List <FieldDTO>();
                    int colNumber   = (tableDataMS.FirstRowHeaders) ? columnHeadersRowDTO.Row.Count : tableRowDTO.Row.Count;
                    for (int j = 0; j < colNumber; ++j)
                    {
                        var tableCellDTO = tableRowDTO.Row[j];
                        var listFieldDTO = new FieldDTO()
                        {
                            Key   = (tableDataMS.FirstRowHeaders) ? columnHeadersRowDTO.Row[j].Cell.Value : tableCellDTO.Cell.Key,
                            Value = tableCellDTO.Cell.Value
                        };
                        fields.Add(listFieldDTO);
                    }
                    payloadDataMS.PayloadObjects.Add(new PayloadObjectDTO()
                    {
                        PayloadObject = fields
                    });
                }
                catch (Exception)
                {
                    //Avoid general failure of the process if there is an error processing individual records in the table
                }
            }

            return(payloadDataMS);
        }
Exemplo n.º 3
0
        private ICrateStorage ExtractEventPayload(Envelope curEventEnvelope)
        {
            var stroage = new CrateStorage();

            var payloadDataCM = new StandardPayloadDataCM();

            foreach (var curNotification in curEventEnvelope.Body.Notifications.NotificationList)
            {
                payloadDataCM.PayloadObjects.Add(new PayloadObjectDTO(CreateKeyValuePairList(curNotification)));
            }

            var payloadCrate = Crate.FromContent("Salesforce Event Notification Payload", payloadDataCM);

            stroage.Add(payloadCrate);

            return(stroage);
        }
Exemplo n.º 4
0
        private StandardPayloadDataCM BuildStandardPayloadData(Table data, Dictionary <string, DbType> columnTypes)
        {
            var findObjectHelper = new FindObjectHelper();

            var payloadCM = new StandardPayloadDataCM();

            var tableData = new List <PayloadObjectDTO>();

            if (data.Rows != null)
            {
                foreach (var row in data.Rows)
                {
                    if (row.Values == null)
                    {
                        continue;
                    }

                    var payloadObject = new PayloadObjectDTO();
                    foreach (var fieldValue in row.Values)
                    {
                        var columnName = data.TableInfo.ToString() + "." + fieldValue.Field;

                        DbType dbType;
                        if (!columnTypes.TryGetValue(columnName, out dbType))
                        {
                            throw new ApplicationException("No column data type found.");
                        }

                        payloadObject.PayloadObject.Add(
                            new KeyValueDTO()
                        {
                            Key   = fieldValue.Field,
                            Value = findObjectHelper.ConvertValueToString(fieldValue.Value, dbType)
                        }
                            );
                    }

                    tableData.Add(payloadObject);
                }
            }

            payloadCM.PayloadObjects.AddRange(tableData);

            return(payloadCM);
        }
Exemplo n.º 5
0
        private static void MergeMtQuery(
            StandardPayloadDataCM queryMtResult,
            HashSet <string> existingEnvelopes,
            StandardPayloadDataCM searchResult)
        {
            if (queryMtResult == null)
            {
                return;
            }

            foreach (var queryMtObject in queryMtResult.PayloadObjects)
            {
                var id = queryMtObject.GetValue("EnvelopeId");
                if (!existingEnvelopes.Contains(id))
                {
                    searchResult.PayloadObjects.Add(ConvertQueryMtToRealTimeData(queryMtObject));
                }
            }
        }
        public static ICrateStorage PayloadDTO2()
        {
            var standardPayload = new StandardPayloadDataCM(
                new List <KeyValueDTO>()
            {
                new KeyValueDTO()
                {
                    Key = "EnvelopeId", Value = "EnvelopeIdValue"
                }
            }
                );

            var payload      = new PayloadDTO(TestContainer_Id_49());
            var crateManager = ObjectFactory.GetInstance <ICrateManager>();

            using (var crateStorage = crateManager.GetUpdatableStorage(payload))
            {
                crateStorage.Add(Crate.FromContent("Standard Payload Data", standardPayload));
            }

            AddOperationalStateCrate(payload);

            return(crateManager.GetStorage(payload));
        }
        public override async Task Run()
        {
            var feedText = FeedText;

            if (IsPostingToQueryiedChatter)
            {
                try
                {
                    var chatters = await _salesforceManager.Query(SelectedChatter.ToEnum <SalesforceObjectType>(),
                                                                  new[] { new FieldDTO("Id") },
                                                                  FilterConditionHelper.ParseConditionToText(JsonConvert.DeserializeObject <List <FilterConditionDTO> >(ChatterFilter)),
                                                                  AuthorizationToken);

                    var tasks = new List <Task <string> >(chatters.Table.Count);
                    foreach (var chatterId in chatters.DataRows.Select(x => x.Row[0].Cell.Value))
                    {
                        Logger.Info($"Posting message to chatter id: {chatterId}");

                        tasks.Add(_salesforceManager.PostToChatter(StripHTML(feedText), chatterId, AuthorizationToken).ContinueWith(x =>
                        {
                            Logger.Info($"Posting message to chatter succeded with feedId: {x.Result}");
                            return(x.Result);
                        }));
                    }
                    await Task.WhenAll(tasks);

                    //If we did not find any chatter object we don't fail activity execution but rather returns empty list and inform caller about it
                    if (!chatters.HasDataRows)
                    {
                        Logger.Info("No salesforce objects were found to use as chatter id.");
                        Success($"No {SelectedChatter} that satisfies specified conditions were found. No message were posted");
                    }
                    else
                    {
                        var resultPayload = new StandardPayloadDataCM();
                        resultPayload.PayloadObjects.AddRange(tasks.Select(x => new PayloadObjectDTO(new KeyValueDTO(FeedIdKeyName, x.Result))));
                        Payload.Add(Crate <StandardPayloadDataCM> .FromContent(PostedFeedCrateLabel, resultPayload));
                    }
                }
                catch (Exception ex)
                {
                    RaiseError(ex.Message);
                    return;
                }
            }
            else
            {
                var incomingChatterId = IncomingChatterId;
                if (string.IsNullOrWhiteSpace(incomingChatterId))
                {
                    throw new ActivityExecutionException("Upstream crates doesn't contain value for feed parent Id");
                }

                Logger.Info($"Posting message to chatter id: {incomingChatterId}");

                var feedId = await _salesforceManager.PostToChatter(StripHTML(feedText), incomingChatterId, AuthorizationToken);

                Logger.Info($"Posting message to chatter succeded with feedId: {feedId}");

                Payload.Add(Crate.FromContent(PostedFeedCrateLabel, new StandardPayloadDataCM(new KeyValueDTO(FeedIdKeyName, feedId))));
            }
        }
Exemplo n.º 8
0
        public override async Task Run()
        {
            var queryPicker = GetControl <RadioButtonGroup>("QueryPicker");
            List <FilterConditionDTO> conditions;
            Guid?selectedObjectId = null;

            if (queryPicker.Radios[0].Selected)
            {
                var             upstreamCrateChooser = (UpstreamCrateChooser)(queryPicker).Radios[0].Controls[0];
                var             selectedCrate        = upstreamCrateChooser.SelectedCrates.FirstOrDefault();
                StandardQueryCM queryCM = null;

                if (selectedCrate != null)
                {
                    queryCM = Payload.CratesOfType <StandardQueryCM>().FirstOrDefault(x => x.Label == selectedCrate.Label.selectedKey)?.Content;
                }

                if (queryCM?.Queries == null || queryCM.Queries.Count == 0)
                {
                    RaiseError("No upstream crate found");
                    return;
                }

                var query = queryCM.Queries[0];

                conditions       = query.Criteria ?? new List <FilterConditionDTO>();
                selectedObjectId = ExtractUpstreamTypeId(query);
            }
            else
            {
                var filterPane       = (FilterPane)queryPicker.Radios[1].Controls[1];
                var availableObjects = (DropDownList)queryPicker.Radios[1].Controls[0];
                var criteria         = filterPane.Value == null ? null : JsonConvert.DeserializeObject <FilterDataDTO>(filterPane.Value);

                if (availableObjects.Value == null)
                {
                    RaiseError("This action is designed to query the Fr8 Warehouse for you, but you don't currently have any objects stored there.");
                    return;
                }

                Guid objectId;
                if (Guid.TryParse(availableObjects.Value, out objectId))
                {
                    selectedObjectId = objectId;
                }

                conditions = criteria == null || criteria.ExecutionType == FilterExecutionType.WithoutFilter
                    ? new List <FilterConditionDTO>()
                    : criteria.Conditions;
            }

            // If no object is found in MT database, return empty result.
            if (!selectedObjectId.HasValue)
            {
                var searchResult = new StandardPayloadDataCM();
                Payload.Add(Crate.FromContent("Found MT Objects", searchResult));
                Success();
                return;
            }

            //STARTING NASTY CODE
            //TODO discuss this with Alex (bahadir)
            var envIdCondition = conditions.FirstOrDefault(c => c.Field == "EnvelopeId");

            if (envIdCondition != null && envIdCondition.Value == "FromPayload")
            {
                envIdCondition.Value = GetCurrentEnvelopeId();
            }
            //END OF NASTY CODE

            using (var uow = _container.GetInstance <IUnitOfWork>())
            {
                var objectId = selectedObjectId.GetValueOrDefault();
                var mtType   = uow.MultiTenantObjectRepository.FindTypeReference(objectId);

                if (mtType == null)
                {
                    RaiseError("Invalid object selected");
                    return;
                }
                Type manifestType = mtType.ClrType;
                var  queryBuilder = MTSearchHelper.CreateQueryProvider(manifestType);
                var  converter    = CrateManifestToRowConverter(manifestType);
                var  foundObjects = queryBuilder.Query(uow, CurrentUserId, conditions.ToList()).ToArray();
                var  searchResult = new StandardPayloadDataCM();
                foreach (var foundObject in foundObjects)
                {
                    searchResult.PayloadObjects.Add(converter(foundObject));
                }
                Payload.Add(Crate.FromContent("Found MT Objects", searchResult));
            }

            Success();
        }
Exemplo n.º 9
0
 public static object SearchDocuSign(DocuSignApiConfiguration config, List <FilterConditionDTO> conditions, HashSet <string> existing_envelopes, StandardPayloadDataCM search_result)
 {
     throw new NotImplementedException();
 }