Exemple #1
0
        private void Scheduler_DataBound(object sender, EventArgs e)
        {
            ASPxSchedulerListEditor listEditor = (ASPxSchedulerListEditor)this.View.Editor;
            ASPxScheduler           scheduler  = listEditor.SchedulerControl;

            if (this._schedulerViewType != SchedulerViewType.Agenda)
            {
                List <object> value = IEventControllerResourceManager.Resources.Value;

                if (value.Count == 0 && scheduler.Storage.Resources.Items.Count >= 1)
                {
                    WorkflowResource workflowResource = this.CurrentObjectSpace.GetObjects <WorkflowResource>(CriteriaOperator.Parse("ObjectOid == ?", SecuritySystem.CurrentUserId.ToString())).FirstOrDefault();

                    for (int i = 0; i < scheduler.Storage.Resources.Items.Count; i++)
                    {
                        DevExpress.XtraScheduler.Resource res = scheduler.Storage.Resources.Items[i];

                        if (res.Caption.Contains(workflowResource.Description))
                        {
                            value.Add(res.Id);
                            break;
                        }
                    }
                }

                scheduler.SetVisibleResources(value);
            }
        }
Exemple #2
0
 /// <summary>
 /// 赋值工作流资源数据操作
 /// </summary>
 /// <param name="resource"></param>
 /// <param name="reader"></param>
 /// <param name="prefix"></param>
 public static void SetWorkflowResourceStoreSelectFields(WorkflowResource resource, DbDataReader reader, string prefix)
 {
     resource.ID         = (Guid)reader[string.Format("{0}id", prefix)];
     resource.Type       = reader[string.Format("{0}type", prefix)].ToString();
     resource.Key        = reader[string.Format("{0}key", prefix)].ToString();
     resource.Status     = (int)reader[string.Format("{0}status", prefix)];
     resource.InitStatus = (int)reader[string.Format("{0}initstatus", prefix)];
     resource.CreateTime = (DateTime)reader[string.Format("{0}createtime", prefix)];
     resource.ModifyTime = (DateTime)reader[string.Format("{0}modifytime", prefix)];
 }
        public virtual WorkflowResource CreateWorkflow(string workspaceSid, IDictionary <string, TaskQueueResource> taskQueues)
        {
            var voiceQueue = taskQueues[VoiceQueue];
            var smsQueue   = taskQueues[SmsQueue];
            var allQueue   = taskQueues[AllQueue];

            var voiceFilter = new {
                friendlyName = "Voice",
                expression   = "selected_product==\"ProgrammableVoice\"",
                targets      = new List <object>()
                {
                    new { queue = voiceQueue.Sid, Priority = "5", Timeout = "30" },
                    new { queue = allQueue.Sid, Expression = "1==1", Priority = "1", Timeout = "30" }
                }
            };

            var smsFilter = new {
                friendlyName = "SMS",
                expression   = "selected_product==\"ProgrammableSMS\"",
                targets      = new List <object>()
                {
                    new { queue = smsQueue.Sid, Priority = "5", Timeout = "30" },
                    new { queue = allQueue.Sid, Expression = "1==1", Priority = "1", Timeout = "30" }
                }
            };

            var workflowConfiguration = new
            {
                task_routing = new
                {
                    filters = new List <object>()
                    {
                        voiceFilter,
                        smsFilter
                    },
                    default_filter = new
                    {
                        queue      = allQueue.Sid,
                        expression = "1==1",
                        priority   = "1",
                        timeout    = "30"
                    }
                }
            };

            // Call REST API
            return(WorkflowResource.Create(
                       workspaceSid,
                       "Tech Support",
                       Json.Encode(workflowConfiguration),
                       new Uri($"{_hostUrl}/callback/assignment"),
                       new Uri($"{_hostUrl}/callback/assignment"),
                       15));
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid   = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken    = "your_auth_token";
        const string workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string workflowSid  = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        WorkflowResource.Delete(workspaceSid, workflowSid);
    }
Exemple #5
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid   = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken    = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
        const string workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string workflowSid  = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        WorkflowResource.Delete(workspaceSid, workflowSid);
    }
        public void TestReadEmptyResponse()
        {
            var twilioRestClient = Substitute.For<ITwilioRestClient>();
            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any<Request>())
                            .Returns(new Response(
                                         System.Net.HttpStatusCode.OK,
                                         "{\"meta\": {\"first_page_url\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0\",\"key\": \"workflows\",\"last_page_url\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0\"},\"workflows\": []}"
                                     ));

            var response = WorkflowResource.Read("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);
            Assert.NotNull(response);
        }
        public void TestUpdateResponse()
        {
            var twilioRestClient = Substitute.For<ITwilioRestClient>();
            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any<Request>())
                            .Returns(new Response(
                                         System.Net.HttpStatusCode.OK,
                                         "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"assignment_callback_url\": \"http://example.com\",\"configuration\": \"task-routing:\\\\n- filter: \\\\n- 1 == 1\\\\ntarget:\\\\n- queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\\nset-priority: 0\\\\n\",\"date_created\": \"2014-05-14T10:50:02Z\",\"date_updated\": \"2014-05-14T23:26:06Z\",\"document_content_type\": \"application/json\",\"fallback_assignment_callback_url\": null,\"friendly_name\": \"Default Fifo Workflow\",\"sid\": \"WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"task_reservation_timeout\": 120,\"url\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"links\": {\"statistics\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics\",\"real_time_statistics\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics\",\"cumulative_statistics\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics\"},\"workspace_sid\": \"WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}"
                                     ));

            var response = WorkflowResource.Update("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);
            Assert.NotNull(response);
        }
        public void TestDeleteResponse()
        {
            var twilioRestClient = Substitute.For<ITwilioRestClient>();
            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any<Request>())
                            .Returns(new Response(
                                         System.Net.HttpStatusCode.NoContent,
                                         "null"
                                     ));

            var response = WorkflowResource.Delete("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);
            Assert.NotNull(response);
        }
Exemple #9
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid   = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken    = "your_auth_token";
        const string workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string workflowSid  = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        var workflow = WorkflowResource.Fetch(workspaceSid, workflowSid);

        Console.WriteLine(workflow.FriendlyName);
    }
Exemple #10
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        WorkflowResource.Delete(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );
    }
        public void TestReadFullResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"meta\": {\"first_page_url\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0\",\"key\": \"workflows\",\"last_page_url\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0\"},\"workflows\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"assignment_callback_url\": \"http://example.com\",\"configuration\": \"task-routing:\\\\n- filter: \\\\n- 1 == 1\\\\ntarget:\\\\n- queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\\nset-priority: 0\\\\n\",\"date_created\": \"2014-05-14T10:50:02Z\",\"date_updated\": \"2014-05-15T16:47:51Z\",\"document_content_type\": \"application/json\",\"fallback_assignment_callback_url\": null,\"friendly_name\": \"Default Fifo Workflow\",\"sid\": \"WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"task_reservation_timeout\": 120,\"url\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"links\": {\"statistics\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics\"},\"workspace_sid\": \"WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}]}"
                         ));

            var response = WorkflowResource.Read("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);

            Assert.NotNull(response);
        }
Exemple #12
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflow = WorkflowResource.Fetch(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(workflow.FriendlyName);
    }
Exemple #13
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflow = WorkflowResource.Update(
            taskReservationTimeout: 20,
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(workflow.FriendlyName);
    }
Exemple #14
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflow = WorkflowResource.Create(
            friendlyName: "FriendlyName",
            configuration: "Configuration",
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(workflow.Sid);
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid   = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken    = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
        const string workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        var workflows = WorkflowResource.Read(workspaceSid);

        foreach (var workflow in workflows)
        {
            Console.WriteLine(workflow.FriendlyName);
        }
    }
Exemple #16
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflows = WorkflowResource.Read(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        foreach (var record in workflows)
        {
            Console.WriteLine(record.Sid);
        }
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflow = WorkflowResource.Create(
            assignmentCallbackUrl: new Uri("http://example.com"),
            fallbackAssignmentCallbackUrl: new Uri("http://example2.com"),
            taskReservationTimeout: 30,
            friendlyName: "Sales, Marketing, Support Workflow",
            configuration: "{\"task_routing\": {\"filters\": [{\"expression\": \"type=='sales'\", \"targets\": [{\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}]}, {\"expression\": \"type=='marketing'\", \"targets\": [{\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}]}, {\"expression\": \"type=='support'\", \"targets\": [{\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}]}], \"default_filter\": {\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}}}",
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(workflow.Sid);
    }
        public void TestDeleteRequest()
        {
            var twilioRestClient = Substitute.For<ITwilioRestClient>();
            var request = new Request(
                HttpMethod.Delete,
                Twilio.Rest.Domain.Taskrouter,
                "/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                ""
            );
            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                WorkflowResource.Delete("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
Exemple #19
0
        //Actual meat of construction is done here. This ctor is also used for testing
        internal ClubHouseClient(HttpMessageHandler messageHandler)
        {
            if (messageHandler == null)
            {
                throw new ArgumentNullException(nameof(messageHandler));
            }

            HttpClient = new ClubHouseHttpClient(EndPoint, messageHandler);

            Epics       = new EpicResource(HttpClient);
            Files       = new FileResource(HttpClient);
            Labels      = new LabelResource(HttpClient);
            LinkedFiles = new LinkedFileResource(HttpClient);
            Projects    = new ProjectResource(HttpClient);
            StoryLinks  = new StoryLinkResource(HttpClient);
            Stories     = new StoryResource(HttpClient);
            Users       = new UserResource(HttpClient);
            Workflows   = new WorkflowResource(HttpClient);
        }
Exemple #20
0
        /// <summary>
        /// 赋值工作流步骤数据操作
        /// </summary>
        /// <param name="step"></param>
        /// <param name="reader"></param>
        /// <param name="prefixForResource"></param>
        /// <param name="prefixForStep"></param>
        public static void SetWorkflowStepStoreSelectFields(WorkflowStep step, DbDataReader reader, string prefixForResource, string prefixForStep)
        {
            var wfResource = new WorkflowResource();

            SetWorkflowResourceStoreSelectFields(wfResource, reader, prefixForResource);

            step.ID         = (Guid)reader[string.Format("{0}id", prefixForStep)];
            step.ResourceID = (Guid)reader[string.Format("{0}resourceid", prefixForStep)];
            step.Resource   = wfResource;
            step.ActionName = reader[string.Format("{0}actionname", prefixForStep)].ToString();
            step.Status     = (int)reader[string.Format("{0}status", prefixForStep)];
            step.SerialNo   = reader[string.Format("{0}serialno", prefixForStep)].ToString();
            step.UserType   = reader[string.Format("{0}usertype", prefixForStep)].ToString();
            step.UserKey    = reader[string.Format("{0}userkey", prefixForStep)].ToString();
            step.UserCount  = (int)reader[string.Format("{0}usercount", prefixForStep)];
            step.Complete   = (bool)reader[string.Format("{0}complete", prefixForStep)];
            step.CreateTime = (DateTime)reader[string.Format("{0}createtime", prefixForStep)];
            step.ModifyTime = (DateTime)reader[string.Format("{0}modifytime", prefixForStep)];
        }
        public void TestCreateRequest()
        {
            var twilioRestClient = Substitute.For<ITwilioRestClient>();
            var request = new Request(
                HttpMethod.Post,
                Twilio.Rest.Domain.Taskrouter,
                "/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows",
                ""
            );
            request.AddPostParam("FriendlyName", Serialize("FriendlyName"));
            request.AddPostParam("Configuration", Serialize("Configuration"));
            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                WorkflowResource.Create("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "FriendlyName", "Configuration", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var configuration = JsonConvert.SerializeObject(new Dictionary <string, Object>()
        {
            { "task_routing", new Dictionary <string, Object>()
              {
                  { "filters", new object [] {
                        new Dictionary <string, Object>()
                        {
                            { "expression", "selected_product=='sales'" },
                            { "targets", new object [] {
                                    new Dictionary <string, Object>()
                                    {
                                        { "queue", sales_taskqueue_sid }
                                    }
                                } }
                        },
                        new Dictionary <string, Object>()
                        {
                            { "expression", "selected_product=='marketing'" },
                            { "targets", new object [] {
                                    new Dictionary <string, Object>()
                                    {
                                        { "queue", marketing_taskqueue_sid }
                                    }
                                } }
                        },
                        new Dictionary <string, Object>()
                        {
                            { "expression", "type=='support'" },
                            { "targets", new object [] {
                                    new Dictionary <string, Object>()
                                    {
                                        { "queue", support_taskqueue_sid }
                                    }
                                } }
                        },
                        new Dictionary <string, Object>()
                        {
                            { "expression", "selected_product ==manager" },
                            { "targets", new object [] {
                                    new Dictionary <string, Object>()
                                    {
                                        { "queue", manager_taskqueue_sid }
                                    }
                                } }
                        }
                    } },
                  { "default_filter", new Dictionary <string, Object>()
                    {
                        { "queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
                    } }
              } }
        }, Formatting.Indented);

        var workflow = WorkflowResource.Create(
            friendlyName: "Sales, Marketing, Support Workflow",
            configuration: configuration,
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(workflow.Sid);
    }
Exemple #23
0
 private WorkflowResource workflowFromObject(object obj)
 {
     return(WorkflowResource.FromJson(Json.Encode(obj)));
 }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid   = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken    = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
        const string workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        const string salesQueue     = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string marketingQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string supportQueue   = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string everyoneQueue  = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        // sales
        var salesRule = new {
            friendlyName = "Sales",
            expression   = "type == 'sales'",
            targets      = new List <object>()
            {
                new {
                    queue = salesQueue
                }
            }
        };

        // marketing
        var marketingRule = new {
            friendlyName = "Marketing",
            expression   = "type == 'marketing'",
            targets      = new List <object>()
            {
                new {
                    queue = marketingQueue
                }
            }
        };

        // support
        var supportRule = new {
            friendlyName = "Support",
            expression   = "type == 'support'",
            targets      = new List <object>()
            {
                new {
                    queue = supportQueue
                }
            }
        };

        var workflowConfiguration = new {
            filters = new List <object>()
            {
                salesRule,
                marketingRule,
                supportRule
            },
            default_filter = new {
                queue = everyoneQueue
            }
        };

        // convert to json
        var workflowJSON = JObject.FromObject(workflowConfiguration).ToString();

        // call rest api
        var workflow = WorkflowResource.Create(workspaceSid,
                                               "Sales, Marketing, Support Workflow", workflowJSON,
                                               new Uri("http://example.com"), new Uri("http://example2.com"), 30);

        Console.WriteLine(workflow.FriendlyName);
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var configuration = JsonConvert.SerializeObject(new Dictionary <string, Object>()
        {
            { "task_routing", new Dictionary <string, Object>()
              {
                  { "filters", new object [] {
                        new Dictionary <string, Object>()
                        {
                            { "expression", "type=='sales'" },
                            { "targets", new object [] {
                                    new Dictionary <string, Object>()
                                    {
                                        { "queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
                                    }
                                } }
                        },
                        new Dictionary <string, Object>()
                        {
                            { "expression", "type=='marketing'" },
                            { "targets", new object [] {
                                    new Dictionary <string, Object>()
                                    {
                                        { "queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
                                    }
                                } }
                        },
                        new Dictionary <string, Object>()
                        {
                            { "expression", "type=='support'" },
                            { "targets", new object [] {
                                    new Dictionary <string, Object>()
                                    {
                                        { "queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
                                    }
                                } }
                        }
                    } },
                  { "default_filter", new Dictionary <string, Object>()
                    {
                        { "queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
                    } }
              } }
        }, Formatting.Indented);

        var workflow = WorkflowResource.Create(
            assignmentCallbackUrl: new Uri("http://example.com"),
            fallbackAssignmentCallbackUrl: new Uri("http://example2.com"),
            taskReservationTimeout: 30,
            friendlyName: "Sales, Marketing, Support Workflow",
            configuration: configuration,
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(workflow.Sid);
    }
Exemple #26
0
        public async Task Add(WorkflowResource resource)
        {
            var dbInfo = await StoreInfoHelper.GetHashStoreInfo(_storeInfoResolveService, _hashGroupRepository, _hashGroupName, resource.Type, resource.Key);

            if (!dbInfo.TableNames.TryGetValue(HashEntityNames.WorkflowResource, out string tableName))
            {
                var fragment = new TextFragment()
                {
                    Code = TextCodes.NotFoundKeyInHashNodeKeyInfo,
                    DefaultFormatting = "哈希组{0}中的哈希节点关键信息中找不到键值{1}",
                    ReplaceParameters = new List <object>()
                    {
                        _hashGroupName, HashEntityNames.WorkflowResource
                    }
                };

                throw new UtilityException((int)Errors.NotFoundKeyInHashNodeKeyInfo, fragment);
            }

            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, false, false, dbInfo.DBConnectionNames.ReadAndWrite, async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (var command = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                })
                {
                    SqlParameter parameter;
                    if (resource.ID == Guid.Empty)
                    {
                        command.CommandText = string.Format(@"INSERT INTO {0}
                                                       ([id], [type], [key], [status], [initstatus], [createtime], [modifytime])
                                                VALUES (default, @type, @key, @status, @initstatus, GETUTCDATE(), GETUTCDATE());
                                                SELECT @newid = [id] FROM {0} WHERE [sequence] = SCOPE_IDENTITY()", tableName);

                        parameter = new SqlParameter("@newid", SqlDbType.UniqueIdentifier)
                        {
                            Direction = ParameterDirection.Output
                        };
                        command.Parameters.Add(parameter);
                    }
                    else
                    {
                        command.CommandText = string.Format(@"INSERT INTO {0}
                                                       ([id], [type], [key], [status], [initstatus], [createtime], [modifytime])
                                                VALUES (@id, @type, @key, @status, @initstatus, GETUTCDATE(), GETUTCDATE())", tableName);

                        parameter = new SqlParameter("@id", SqlDbType.UniqueIdentifier)
                        {
                            Value = resource.ID
                        };
                        command.Parameters.Add(parameter);
                    }

                    parameter = new SqlParameter("@type", SqlDbType.NVarChar, 256)
                    {
                        Value = resource.Type
                    };
                    command.Parameters.Add(parameter);

                    parameter = new SqlParameter("@key", SqlDbType.NVarChar, 256)
                    {
                        Value = resource.Key
                    };
                    command.Parameters.Add(parameter);

                    parameter = new SqlParameter("@status", SqlDbType.Int)
                    {
                        Value = resource.Status
                    };
                    command.Parameters.Add(parameter);

                    parameter = new SqlParameter("@initstatus", SqlDbType.Int)
                    {
                        Value = resource.InitStatus
                    };
                    command.Parameters.Add(parameter);

                    await command.PrepareAsync();


                    try
                    {
                        await command.ExecuteNonQueryAsync();
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number == 2601)
                        {
                            var fragment = new TextFragment()
                            {
                                Code = TextCodes.ExistWorkflowResourceKey,
                                DefaultFormatting = "工作流资源已存在相同关键字\"{0},{1}\"数据",
                                ReplaceParameters = new List <object>()
                                {
                                    resource.Type, resource.Key
                                }
                            };

                            throw new UtilityException((int)Errors.ExistWorkflowResourceKey, fragment);
                        }

                        throw;
                    }


                    if (resource.ID == Guid.Empty)
                    {
                        resource.ID = (Guid)command.Parameters["@newid"].Value;
                    }
                }
            });
        }
Exemple #27
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid   = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken    = "your_auth_token";
        const string workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        const string salesQueue     = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string marketingQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string supportQueue   = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string everyoneQueue  = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        // sales
        var salesRule = new {
            FriendlyName = "Sales",
            Expression   = "type == 'sales'",
            Targets      = new List <object>()
            {
                new {
                    Queue = salesQueue
                }
            }
        };

        // marketing
        var marketingRule = new {
            FriendlyName = "Marketing",
            Expression   = "type == 'marketing'",
            Targets      = new List <object>()
            {
                new {
                    Queue = marketingQueue
                }
            }
        };

        // support
        var supportRule = new {
            FriendlyName = "Support",
            Expression   = "type == 'support'",
            Targets      = new List <object>()
            {
                new {
                    Queue = supportQueue
                }
            }
        };

        var workflowConfiguration = new {
            Filters = new List <object>()
            {
                salesRule,
                marketingRule,
                supportRule
            },
            DefaultFilter = new {
                Queue = everyoneQueue
            }
        };

        // convert to json
        var workflowJSON = JObject.FromObject(workflowConfiguration).ToString();

        // call rest api
        var workflow = WorkflowResource.Create(workspaceSid,
                                               "Sales, Marketing, Support Workflow", workflowJSON,
                                               new Uri("http://example.com"), new Uri("http://example2.com"), 30);

        Console.WriteLine(workflow.FriendlyName);
    }
Exemple #28
0
        /// <summary>
        /// 根据type和Key查询
        /// </summary>
        /// <param name="type"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public async Task <WorkflowResource> QueryByKey(string type, string key)
        {
            var dbInfo = await StoreInfoHelper.GetHashStoreInfo(_storeInfoResolveService, _hashGroupRepository, _hashGroupName, type, key);

            if (!dbInfo.TableNames.TryGetValue(HashEntityNames.WorkflowResource, out string tableName))
            {
                var fragment = new TextFragment()
                {
                    Code = TextCodes.NotFoundKeyInHashNodeKeyInfo,
                    DefaultFormatting = "哈希组{0}中的哈希节点关键信息中找不到键值{1}",
                    ReplaceParameters = new List <object>()
                    {
                        _hashGroupName, HashEntityNames.WorkflowResource
                    }
                };

                throw new UtilityException((int)Errors.NotFoundKeyInHashNodeKeyInfo, fragment);
            }

            WorkflowResource result = null;
            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, dbInfo.DBConnectionNames.Read, async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (var command = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                    CommandText = string.Format(@"SELECT {0}
                                                  FROM {1}
                                                  WHERE [type] = @type
                                                        AND [key] = @key
                                                  ORDER BY createtime DESC ", StoreHelper.GetWorkflowResourceStoreSelectFields(string.Empty),
                                                tableName)
                })
                {
                    var parameter = new SqlParameter("@type", SqlDbType.NVarChar, 256)
                    {
                        Value = type
                    };
                    command.Parameters.Add(parameter);

                    parameter = new SqlParameter("@key", SqlDbType.NVarChar, 256)
                    {
                        Value = key
                    };
                    command.Parameters.Add(parameter);

                    await command.PrepareAsync();

                    SqlDataReader reader = null;

                    await using (reader = await command.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            result = new WorkflowResource();
                            StoreHelper.SetWorkflowResourceStoreSelectFields(result, reader, string.Empty);
                        }

                        reader.Close();
                    }
                }
            });

            return(result);
        }