Example #1
0
        private static string Start(string workflowCode)
        {
            string workflowId;
            var    startWorkflowRequest = new StartWorkflowRequest
            {
                Domain          = "google",
                WorkflowCode    = workflowCode,
                WfRuntimeValues = new[]
                {
                    new WfProperty
                    {
                        Name  = "Prop1",
                        Type  = "S",
                        Value = "Val1"
                    }
                }
            };

            StartWorkflowResponse startWorkflowResponse = null;

            using (var src = new FlowTasksService())
            {
                startWorkflowResponse = src.StartWorkflow(startWorkflowRequest);
            }

            System.Threading.Thread.Sleep(1000);

            workflowId = startWorkflowResponse.WorkflowId;

            return(workflowId);
        }
Example #2
0
        public string UploadFile()
        {
            try
            {
                var info = new DocumentInfo {
                    DocumentName = Path.GetFileName(FileName), Path = Path.GetDirectoryName(FileName), Description = "desc-test", Owner = "owner", Version = 1
                };

                var oid = _processDocs.UploadDocument(info, FileName, DocumentUploadMode.NewVersion);

                var startWorkflowRequest = new StartWorkflowRequest
                {
                    Domain          = ConfigHelper.WorkflowDomain,
                    WorkflowCode    = ConfigHelper.WorkflowCode,
                    WfRuntimeValues = new WfProperty[]
                    {
                        new WfProperty
                        {
                            Name  = ConfigHelper.WorkflowProperty,
                            Type  = PropertyType.FlowDoc.ToString(),
                            Value = oid.ToString()
                        }
                    }
                };

                if (_serviceTasks != null)
                {
                    _serviceTasks.StartWorkflow(startWorkflowRequest);
                }
                else
                {
                    using (FlowTasksService proxy = new FlowTasksService())
                    {
                        var startWorkflowResponse = proxy.StartWorkflow(startWorkflowRequest);
                    }
                }

                return(null);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Example #3
0
        public void DoProcess()
        {
            DateTime last;

            try
            {
                var tweets = _tweet.GetLatestTwitterForWorkflow(out last);

                DateTime lastRun = DateTime.MinValue;
                foreach (var t in tweets)
                {
                    var startWorkflowRequest = new StartWorkflowRequest
                    {
                        Domain          = ConfigHelper.WorkflowDomain,
                        WorkflowCode    = ConfigHelper.WorkflowCode,
                        WfRuntimeValues = new WfProperty[]
                        {
                            new WfProperty
                            {
                                Name  = ConfigHelper.WorkflowProperty,
                                Type  = "S",
                                Value = t.Text
                            }
                        }
                    };

                    StartWorkflowResponse startWorkflowResponse = null;
                    if (_flowTasksService == null)
                    {
                        using (FlowTasksService proxy = new FlowTasksService())
                        {
                            startWorkflowResponse = proxy.StartWorkflow(startWorkflowRequest);
                        }
                    }
                    else
                    {
                        startWorkflowResponse = _flowTasksService.StartWorkflow(startWorkflowRequest);
                    }

                    // check for errors
                    if (string.IsNullOrWhiteSpace(startWorkflowResponse.WorkflowId) ||
                        startWorkflowResponse.WorkflowId == Guid.Empty.ToString())
                    {
                        if (lastRun != DateTime.MinValue)
                        {
                            _tweet.SetLastTweetData(lastRun);
                        }

                        _log.Error("DoProcess: Start workflow failed!");

                        return;
                    }

                    // last tweet processed
                    lastRun = t.CreatedDate;
                }

                _tweet.SetLastTweetData(last);
            }
            catch (Exception e)
            {
                // log the error
                _log.Error("DoProcess: exception. ", e);
            }
        }