コード例 #1
0
        public void Conf()
        {
            Service service = this.Connect();

            ConfCollection confs = service.GetConfs();

            // Make sure the collection contains some of the expected entries.
            Assert.IsTrue(confs.ContainsKey("eventtypes"), assertRoot + "#1");
            Assert.IsTrue(confs.ContainsKey("searchbnf"), assertRoot + "#2");
            Assert.IsTrue(confs.ContainsKey("indexes"), assertRoot + "#3");
            Assert.IsTrue(confs.ContainsKey("inputs"), assertRoot + "#4");
            Assert.IsTrue(confs.ContainsKey("props"), assertRoot + "#5");
            Assert.IsTrue(confs.ContainsKey("transforms"), assertRoot + "#6");
            Assert.IsTrue(confs.ContainsKey("savedsearches"), assertRoot + "#7");

            // Iterate over the confs just to make sure we can read them
            foreach (EntityCollection <Entity> conf in confs.Values)
            {
                string dummyString;
                dummyString = conf.Name;
                dummyString = conf.Title;
                dummyString = conf.Path;
                foreach (Entity stanza in conf.Values)
                {
                    try
                    {
                        dummyString = stanza.Name;
                        dummyString = stanza.Title;
                        dummyString = stanza.Path;
                    }
                    catch (Exception)
                    {
                        // IF the application is disabled, trying to get info
                        // on it will in fact give us a 404 exception.
                    }
                }
            }
        }
コード例 #2
0
        public void ConfCRUD()
        {
            Service service;
            string  app   = "sdk-tests";
            string  owner = "nobody";

            // Create a fresh app to use as the container for confs that we will
            // create in this test. There is no way to delete a conf once it's
            // created so we make sure to create in the context of this test app
            // and then we delete the app when we are done to make everything go
            // away.
            this.CreateApp(app);
            service = this.Connect();
            Assert.IsTrue(service.GetApplications().ContainsKey(app), assertRoot + "#8");

            // Create an app specific service instance
            Args args = new Args(this.SetUp().Opts);

            args.Add("app", app);
            args.Add("owner", owner);
            service = Service.Connect(args);

            ConfCollection confs = service.GetConfs();

            Assert.IsFalse(confs.ContainsKey("testconf"), assertRoot + "#9");
            confs.Create("testconf");
            Assert.IsTrue(confs.ContainsKey("testconf"), assertRoot + "#10");

            EntityCollection <Entity> stanzas = confs.Get("testconf");

            Assert.AreEqual(0, stanzas.Size, assertRoot + "#11");

            stanzas.Create("stanza1");
            stanzas.Create("stanza2");
            stanzas.Create("stanza3");
            Assert.AreEqual(3, stanzas.Size, assertRoot + "#12");
            Assert.IsTrue(stanzas.ContainsKey("stanza1"), assertRoot + "#13");
            Assert.IsTrue(stanzas.ContainsKey("stanza2"), assertRoot + "#14");
            Assert.IsTrue(stanzas.ContainsKey("stanza3"), assertRoot + "#15");

            // Grab the new stanza and check its content
            Entity stanza1 = stanzas.Get("stanza1");

            Assert.IsFalse(stanza1.IsEmpty, "Expected stanza1 to be non-empty");
            Assert.AreEqual(5, stanza1.Size, "Expected stanza1 to have 5 elements");
            Assert.AreEqual("nobody", stanza1.Get("eai:userName"), assertRoot + "#16");
            Assert.AreEqual(app, stanza1.Get("eai:appName"), assertRoot + "#17");
            Assert.IsFalse(stanza1.ContainsKey("key1"), assertRoot + "#18");
            Assert.IsFalse(stanza1.ContainsKey("key2"), assertRoot + "#19");
            Assert.IsFalse(stanza1.ContainsKey("key3"), assertRoot + "#20");

            // Add a couple of properties
            args = new Args();
            args.Add("key1", "value1");
            args.Add("key2", 42);
            stanza1.Update(args);

            // Make sure the properties showed up
            Assert.AreEqual("value1", stanza1.Get("key1"), assertRoot + "#21");
            Assert.AreEqual("42", stanza1.Get("key2"), assertRoot + "#22");
            Assert.IsFalse(stanza1.ContainsKey("key3"), assertRoot + "#23");

            // Update an existing property
            args = new Args();
            args.Add("key1", "value2");
            stanza1.Update(args);

            // Make sure the updated property shows up (and no other changes).
            Assert.AreEqual("value2", stanza1.Get("key1"), assertRoot + "#24");
            Assert.AreEqual("42", stanza1.Get("key2"), assertRoot + "#25");
            Assert.IsFalse(stanza1.ContainsKey("key3"), assertRoot + "#26");
            Assert.IsTrue(stanza1.ContainsValue("value2"), "Expected stanza1 to contain the value value2");
            Assert.IsTrue(stanza1.ContainsValue("42"), "Expected stanza1 to contain the value 42");

            // Delete the stanzas
            stanzas.Remove("stanza3");
            Assert.AreEqual(2, stanzas.Size, assertRoot + "#27");
            Assert.IsTrue(stanzas.ContainsKey("stanza1"), assertRoot + "#28");
            Assert.IsTrue(stanzas.ContainsKey("stanza2"), assertRoot + "#29");
            Assert.IsFalse(stanzas.ContainsKey("stanza3"), assertRoot + "#30");

            stanzas.Remove("stanza2");
            Assert.AreEqual(1, stanzas.Size, assertRoot + "#31");
            Assert.IsTrue(stanzas.ContainsKey("stanza1"), assertRoot + "#32");
            Assert.IsFalse(stanzas.ContainsKey("stanza2"), assertRoot + "#33");
            Assert.IsFalse(stanzas.ContainsKey("stanza3"), assertRoot + "#34");

            stanzas.Remove("stanza1");
            Assert.AreEqual(0, stanzas.Size, assertRoot + "#35");
            Assert.IsFalse(stanzas.ContainsKey("stanza1"), assertRoot + "#36");
            Assert.IsFalse(stanzas.ContainsKey("stanza2"), assertRoot + "#37");
            Assert.IsFalse(stanzas.ContainsKey("stanza3"), assertRoot + "#38");

            // Cleanup after ourselves
            this.RemoveApp(app);
        }
コード例 #3
0
 public void RemoveAppSettings(string name)
 {
     ConfCollection.Remove(name);
     Logger.Debug(String.Format("[{0}] has been removed from AppSettings but not saved yet => [{0}]", name));
     Save();
 }
コード例 #4
0
        protected void gvResult_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            ConfCollection dt = ((ConfCollection)this.gvResult.DataSource);

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Conf l_conf = dt[e.Item.ItemIndex];
                //((TableCell)e.Item.Cells[0]).Text = l_conf.ConfID.ToString();
                ((Label)e.Item.Cells[1].Controls[1]).Text = l_conf.ConfName;
                ((Label)e.Item.Cells[2].Controls[1]).Text = l_conf.StartDate.ToShortDateString();
                ((Label)e.Item.Cells[3].Controls[1]).Text = l_conf.EndDate.ToShortDateString();
                ((Label)e.Item.Cells[4].Controls[1]).Text = l_conf.MaxOrder_INTL.ToString();

                //delete btn col
                Button l_able = e.Item.Cells[6].FindControl("lnkbtnDel") as Button;
                l_able.Text = "Delete";
                Panel l_pnl = e.Item.Cells[6].FindControl("pnlConfirmDel") as Panel;
                ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to delete this Exhibit Record?";
            }
            else if (e.Item.ItemType == ListItemType.EditItem)
            {
                Conf l_conf = dt[e.Item.ItemIndex];

                //delete btn col
                Button l_able = e.Item.Cells[6].FindControl("lnkbtnDel") as Button;
                l_able.Text = "Delete";
                Panel l_pnl = e.Item.Cells[6].FindControl("pnlConfirmDel") as Panel;
                ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to delete this Exhibit Record?";

                //confirmation for cancel
                if (e.Item.Cells[5].Controls[2] is Button)
                {
                    Button l_btnCancel = ((Button)e.Item.Cells[5].Controls[2]);

                    Panel l_panel = new Panel();
                    l_panel.ID       = "l_panel";
                    l_panel.CssClass = "modalPopup";
                    l_panel.Style.Add("display", "none");
                    l_panel.Width = Unit.Pixel(233);

                    Label l_label = new Label();
                    l_label.Text = "Are you sure you want to continue?";

                    HtmlGenericControl l_div    = new HtmlGenericControl();
                    Button             l_ok     = new Button();
                    Button             l_cancel = new Button();
                    l_ok.ID       = "l_ok";
                    l_ok.Text     = "OK";
                    l_cancel.ID   = "l_cancel";
                    l_cancel.Text = "Cancel";
                    l_div.Controls.Add(l_ok);
                    l_div.Controls.Add(new LiteralControl("&nbsp;"));
                    l_div.Controls.Add(l_cancel);
                    l_div.Attributes.Add("align", "center");

                    l_panel.Controls.Add(l_label);
                    l_panel.Controls.Add(new LiteralControl("<br>"));
                    l_panel.Controls.Add(new LiteralControl("<br>"));
                    l_panel.Controls.Add(l_div);

                    ModalPopupExtender l_mpe = new ModalPopupExtender();
                    l_mpe.ID = "l_mpe";
                    l_mpe.TargetControlID    = l_btnCancel.ID;
                    l_mpe.PopupControlID     = l_panel.ID;
                    l_mpe.BackgroundCssClass = "modalBackground";
                    l_mpe.DropShadow         = true;
                    l_mpe.OkControlID        = l_ok.ID;
                    l_mpe.CancelControlID    = l_cancel.ID;

                    ConfirmButtonExtender l_cbe = new ConfirmButtonExtender();
                    l_cbe.TargetControlID     = l_btnCancel.ID;
                    l_cbe.ConfirmText         = "";
                    l_cbe.DisplayModalPopupID = l_mpe.ID;

                    e.Item.Cells[5].Controls.Add(l_panel);
                    e.Item.Cells[5].Controls.Add(l_mpe);
                    e.Item.Cells[5].Controls.Add(l_cbe);
                }

                if (this.gvResult.EditItemIndex != -1)
                {
                    ((MaskedEditValidator)e.Item.Cells[2].Controls[7]).Enabled = true;
                    ((MaskedEditValidator)e.Item.Cells[3].Controls[7]).Enabled = true;
                }
                else
                {
                    ((MaskedEditValidator)e.Item.Cells[2].Controls[7]).Enabled = false;
                    ((MaskedEditValidator)e.Item.Cells[3].Controls[7]).Enabled = false;
                }
            }
        }
コード例 #5
0
 public void AddAppSetting(string name, string value)
 {
     ConfCollection.Add(name, value);
     Logger.Debug(String.Format("New AppSetting has been added but not saved yet => [{0} = {1}]", name, value));
     Save();
 }