public EventSubscriber(Global global, string sCallbackURL, EventSubscription subscription)
 {
     this.global       = global;
     this.sCallbackURL = sCallbackURL;
     this.subscription = subscription;
 }
Esempio n. 2
0
        public void AddSubscriber(string sCallbackURL, EventSubscription subscription)
        {
            lock (subscribers)
            {
                try
                {
                    // create new subscriber
                    EventSubscriber subscriber = new EventSubscriber(this, sCallbackURL, subscription);

                    // add it to the list
                    subscribers.Add(subscription.sGUID, subscriber);

                    // store it to the DB (for display purposes)
                    DataRow newRow = mainService.tblSubscriptions.NewRow();
                    newRow["Variable"] = subscription.sVariable;
                    string sCondition;
                    Range  range = (Range)(subscription.conditions[0]);


                    //Null means no limit
                    if (range.min == null)
                    {
                        if (range.max == null)
                        {
                            sCondition = "upon change";
                        }
                        else
                        {
                            sCondition = "< " + range.max.ToString();
                        }
                    }
                    else
                    {
                        if (range.max == null)
                        {
                            if (range.bStrict)
                            {
                                sCondition = "> " + range.min;
                            }
                            else
                            {
                                sCondition = ">= " + range.min;
                            }
                        }
                        else
                        {
                            if (range.bStrict)
                            {
                                sCondition = "Range=(" + range.min.ToString() + ";" + range.max.ToString() + ")";
                            }
                            else
                            {
                                sCondition = "Range=<" + range.min.ToString() + ";" + range.max.ToString() + ">";
                            }
                        }
                    }
                    newRow["Condition"]      = sCondition;
                    newRow["GUID"]           = subscription.sGUID.ToString();
                    newRow["Subscriber URL"] = subscriber.sCallbackURL;
                    mainService.tblSubscriptions.Rows.Add(newRow);
                    //mainForm.dataGridSubscriptions.ResizeColumns(ColumnResizeType.FitToContent);
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp);
                }
            }
        }