예제 #1
0
        //获取规则的详细信息
        public void TestGetRule()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();

            long ruleId = 321103;

            GetRuleRequest request = new GetRuleRequest();

            request.RuleId = ruleId;

            GetRuleResponse response = acsClient.GetAcsResponse(request);

            Console.WriteLine("Get Rule: " + response.Success);
            if (!(bool)response.Success)
            {
                Console.WriteLine(response.Code + ", " + response.ErrorMessage);
                return;
            }

            GetRuleResponse.GetRule_RuleInfo RuleInfo = response.RuleInfo;
            Console.WriteLine("Rule ID: " + RuleInfo.Id);
            Console.WriteLine("Rule Name: " + RuleInfo.Name);
            Console.WriteLine("Rule DataType: " + RuleInfo.DataType);
            Console.WriteLine("Rule ProductKey: " + RuleInfo.ProductKey);
            Console.WriteLine("Rule ShortTopic: " + RuleInfo.ShortTopic);
            Console.WriteLine("Rule Topic: " + RuleInfo.Topic);
            Console.WriteLine("Rule Select: " + RuleInfo.Select);
            Console.WriteLine("Rule Where: " + RuleInfo._Where);
            Console.WriteLine("Rule UtcCreated: " + RuleInfo.UtcCreated);
        }
        public static GetRuleResponse Unmarshall(UnmarshallerContext context)
        {
            GetRuleResponse getRuleResponse = new GetRuleResponse();

            getRuleResponse.HttpResponse = context.HttpResponse;
            getRuleResponse.RequestId    = context.StringValue("GetRule.RequestId");
            getRuleResponse.Success      = context.BooleanValue("GetRule.Success");
            getRuleResponse.Code         = context.StringValue("GetRule.Code");
            getRuleResponse.ErrorMessage = context.StringValue("GetRule.ErrorMessage");

            GetRuleResponse.GetRule_RuleInfo ruleInfo = new GetRuleResponse.GetRule_RuleInfo();
            ruleInfo.Id              = context.LongValue("GetRule.RuleInfo.Id");
            ruleInfo.Select          = context.StringValue("GetRule.RuleInfo.Select");
            ruleInfo.Topic           = context.StringValue("GetRule.RuleInfo.Topic");
            ruleInfo.ShortTopic      = context.StringValue("GetRule.RuleInfo.ShortTopic");
            ruleInfo._Where          = context.StringValue("GetRule.RuleInfo.Where");
            ruleInfo.Status          = context.StringValue("GetRule.RuleInfo.Status");
            ruleInfo.CreateUserId    = context.LongValue("GetRule.RuleInfo.CreateUserId");
            ruleInfo.ProductKey      = context.StringValue("GetRule.RuleInfo.ProductKey");
            ruleInfo.Name            = context.StringValue("GetRule.RuleInfo.Name");
            ruleInfo.RuleDesc        = context.StringValue("GetRule.RuleInfo.RuleDesc");
            ruleInfo.DataType        = context.StringValue("GetRule.RuleInfo.DataType");
            ruleInfo.Created         = context.StringValue("GetRule.RuleInfo.Created");
            ruleInfo.UtcCreated      = context.StringValue("GetRule.RuleInfo.UtcCreated");
            ruleInfo.Modified        = context.StringValue("GetRule.RuleInfo.Modified");
            ruleInfo.UtcModified     = context.StringValue("GetRule.RuleInfo.UtcModified");
            ruleInfo.TopicType       = context.IntegerValue("GetRule.RuleInfo.TopicType");
            getRuleResponse.RuleInfo = ruleInfo;

            return(getRuleResponse);
        }
예제 #3
0
        //更新规则的名称和描述
        public void TestUpdateRule()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();
            long             ruleId    = 321103;

            UpdateRuleRequest request = new UpdateRuleRequest();

            request.RuleId     = ruleId;
            request.Name       = "Rule_Test_082601";
            request.ProductKey = "a163Bcy1oyR";
            request.ShortTopic = "firstDevice/thing/event/property/post";
            request.Select     = " a, b, c";
            request._Where     = " a > 2";

            request.RuleDesc = "This is a test.";
            UpdateRuleResponse response = acsClient.GetAcsResponse(request);

            Console.WriteLine("Update Rule: " + response.Success);
            if (!(bool)response.Success)
            {
                Console.WriteLine(response.Code + ", " + response.ErrorMessage);
                return;
            }
            GetRuleRequest request2 = new GetRuleRequest();

            request2.RuleId = ruleId;

            GetRuleResponse response2 = acsClient.GetAcsResponse(request2);

            Console.WriteLine("Get Rule: " + response.Success);
            if (!(bool)response2.Success)
            {
                Console.WriteLine(response2.Code + ", " + response2.ErrorMessage);
                return;
            }

            GetRuleResponse.GetRule_RuleInfo RuleInfo = response2.RuleInfo;
            Console.WriteLine("Rule ID: " + RuleInfo.Id);
            Console.WriteLine("Rule Name: " + RuleInfo.Name);
            Console.WriteLine("Rule DataType: " + RuleInfo.DataType);
            Console.WriteLine("Rule ProductKey: " + RuleInfo.ProductKey);
            Console.WriteLine("Rule ShortTopic: " + RuleInfo.ShortTopic);
            Console.WriteLine("Rule Topic: " + RuleInfo.Topic);
            Console.WriteLine("Rule Select: " + RuleInfo.Select);
            Console.WriteLine("Rule Where: " + RuleInfo._Where);
            Console.WriteLine("Rule UtcCreated: " + RuleInfo.UtcCreated);
        }