Beispiel #1
0
        protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            string   aiSetupJson = AiSetupJson.Get(context);
            AiLogger aiLogger    = new AiLogger(aiSetupJson, localContext.OrganizationService, localContext.TracingService,
                                                localContext.WorkflowExecutionContext, null, localContext.WorkflowExecutionContext.WorkflowCategory);

            string name   = Name.Get(context);
            int    value  = MetricValue.Get(context);
            int?   count  = Count.Get(context);
            int?   min    = Min.Get(context);
            int?   max    = Max.Get(context);
            int    stdDev = StdDev.Get(context);

            bool logSuccess = aiLogger.WriteMetric(name, value, count, min, max, stdDev);

            LogSuccess.Set(context, logSuccess);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            int[,] matrix = { { 90, 5, 3, 4 }, { 4, 9, 6, 7 }, { 1, 17, 1, 7 }, { 15, 15, 14, 0 } };

            Sum.Get(matrix, "down");
            Console.WriteLine();
            Max.Get(matrix, "up");
            Console.WriteLine();
            Min.Get(matrix, "dsds");
        }
        protected override void Execute(CodeActivityContext context)
        {
            var chID         = Channel__ID.Get(context);
            var readKey      = Read_API_Key.Get(context) == null ? "" : "api_key=" + Read_API_Key.Get(context);
            var chosenFormat = Format.ToString();
            var chosenField  = (FieldNumber.GetHashCode() + 1).ToString();

            var results   = Results.Get(context) == 0 ? "" : "&results=" + Results.Get(context).ToString();
            var days      = Days.Get(context) == 0 ? "" : "&days=" + Days.Get(context).ToString();
            var minutes   = Minutes.Get(context) == 0 ? "" : "&minutes=" + Minutes.Get(context).ToString();
            var start     = Start.Get(context) == null ? "" : "&start=" + Start.Get(context);
            var end       = End.Get(context) == null ? "" : "&end=" + End.Get(context);
            var timezone  = Timezone.Get(context) == null ? "" : "&timezone=" + Timezone.Get(context);
            var offset    = Offset.Get(context) == 0 ? "" : "&offset=" + Offset.Get(context).ToString();
            var status    = Status.Get(context) == true ? "&status=true" : "";
            var metadata  = Metadata.Get(context) == true ? "&metadata=true" : "";
            var location  = Location.Get(context) == true ? "&location=true" : "";
            var min       = Min.Get(context) == 0 ? "" : "&min=" + Min.Get(context).ToString();
            var max       = Max.Get(context) == 0 ? "" : "&max=" + Max.Get(context).ToString();
            var round     = Round.Get(context) == 0 ? "" : "&round=" + Round.Get(context).ToString();
            var timescale = Timescale.Get(context) == null ? "" : "&timescale=" + Timescale.Get(context);
            var sum       = Sum.Get(context) == null ? "" : "&sum=" + Sum.Get(context);
            var average   = Average.Get(context) == null ? "" : "&average=" + Average.Get(context);
            var median    = Median.Get(context) == null ? "" : "&median=" + Median.Get(context);
            var callback  = Callback.Get(context) == null ? "" : "&callback=" + Callback.Get(context);


            string URL = "https://api.thingspeak.com/channels/" + chID + "/fields/" + chosenField + "." + chosenFormat + "?";

            URL = URL + readKey + results + days + minutes + start + end + timezone + offset + status + metadata + location
                  + min + max + round + timescale + sum + average + median + callback;

            WebRequest   wrGETURL  = WebRequest.Create(URL);
            Stream       objStream = wrGETURL.GetResponse().GetResponseStream();
            StreamReader objReader = new StreamReader(objStream);

            string sLine        = "";
            string httpResponse = "";

            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null)
                {
                    httpResponse = httpResponse + sLine + "\n";
                }
            }
            objStream.Close();
            //objReader.Close();
            Response.Set(context, httpResponse);
        }