internal Panel GetPropertyPanel(XmlNode ndProps, Hashtable hshProps, LayoutsPageBase page)
        {
            Panel pnl = new Panel();

            pnl.Controls.Add(new LiteralControl("<table width=\"100%\">"));

            hshProperties = hshProps;

            foreach (XmlNode ndProperty in ndProps.SelectNodes("Input"))
            {
                string Property       = GetNodeAttribute(ndProperty, "Property");
                string Title          = GetNodeAttribute(ndProperty, "Title");
                string Type           = GetNodeAttribute(ndProperty, "Type");
                string ParentProperty = GetNodeAttribute(ndProperty, "ParentProperty");


                InputFormSection section = (InputFormSection)page.LoadControl("~/_controltemplates/InputFormSection.ascx");
                section.ID    = Property + "_Section";
                section.Title = Title;

                IntegrationDescriptionTemplate controlDescription = new IntegrationDescriptionTemplate(ndProperty.InnerText);
                section.Template_Description = controlDescription;

                string curVal = "";

                if (page.IsPostBack)
                {
                    curVal = page.Request[""];
                }
                else
                {
                    try
                    {
                        curVal = hshProps[Property].ToString();
                    }
                    catch { }
                }

                hshProps[Property] = curVal;

                Control c = null;



                switch (Type.ToLower())
                {
                case "text":
                    TextBox txt = new TextBox();
                    txt.ID   = Property;
                    txt.Text = curVal;
                    c        = txt;
                    break;

                case "password":
                    TextBox txt1 = new TextBox();
                    txt1.ID       = Property;
                    txt1.TextMode = TextBoxMode.Password;
                    if (page.IsPostBack)
                    {
                        txt1.Text = curVal;
                    }

                    c = txt1;
                    break;

                case "textarea":
                    TextBox txt4 = new TextBox();
                    txt4.ID       = Property;
                    txt4.TextMode = TextBoxMode.MultiLine;
                    txt4.Columns  = 30;
                    txt4.Rows     = 4;
                    txt4.Text     = curVal;
                    c             = txt4;
                    break;

                case "select":
                    DropDownList ddl = new DropDownList();
                    ddl.ID = Property;
                    //TODO: parent property
                    Dictionary <String, String> props = _core.GetDropDownProperties(ModuleID, intlistid, new Guid(page.Request["List"]), Property, "");
                    foreach (KeyValuePair <String, String> prop in props)
                    {
                        System.Web.UI.WebControls.ListItem li = new System.Web.UI.WebControls.ListItem(prop.Value.ToString(), prop.Key.ToString());
                        if (curVal == prop.Key.ToString())
                        {
                            li.Selected = true;
                        }

                        ddl.Items.Add(li);
                    }
                    ddl.EnableViewState = true;
                    c = ddl;
                    break;

                case "checkbox":
                    CheckBox chk = new CheckBox();
                    chk.ID = Property;
                    try
                    {
                        chk.Checked = bool.Parse(curVal);
                    }
                    catch { }
                    c = chk;
                    break;

                default:
                    TextBox txt3 = new TextBox();
                    txt3.ID   = Property;
                    txt3.Text = curVal;
                    c         = txt3;
                    break;
                }

                ControlCollection.Add(c);

                IntegrationControlTemplate controlTemplate = new IntegrationControlTemplate(c, page, Title);
                section.Template_InputFormControls = controlTemplate;

                pnl.Controls.Add(section);
            }

            pnl.Controls.Add(new LiteralControl("</table>"));

            return(pnl);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ddlTimed.Attributes.Add("OnChange", "ChangeTimed()");
            ddlScheduleType.Attributes.Add("OnChange", "ChangeSchedule()");

            //if(!IsPostBack)
            {
                for (int i = 1; i < 31; i++)
                {
                    ddlDayOfMonth.Items.Add(i.ToString());
                }


                for (int i = 0; i < 24; i++)
                {
                    ddlHour.Items.Add(new ListItem(i.ToString() + ":00", i.ToString()));
                }
            }

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                try
                {
                    intlistid = new Guid(Request["intlistid"]);
                }
                catch { }

                lblID.Text = intlistid.ToString();

                try
                {
                    moduleid = new Guid(Request["module"]);
                }
                catch { }

                intcore  = new API.Integration.IntegrationCore(Web.Site.ID, Web.ID);
                intadmin = new API.Integration.IntegrationAdmin(intcore, intlistid, moduleid);


                PageHead = intadmin.GetIntegrationHeader();

                Hashtable hshProps = new Hashtable();
                if (intlistid != Guid.Empty)
                {
                    hshProps = intcore.GetProperties(intlistid);
                }

                XmlDocument doc = intcore.GetModuleProperties(intlistid, moduleid);

                XmlNode ndCon = doc.FirstChild.SelectSingleNode("/Properties/General");

                lblMain.Controls.AddAt(0, intadmin.GetPropertyPanel(ndCon, hshProps, this));

                try
                {
                    lblURL.Text = intcore.GetAPIUrl(Web.Site.WebApplication.Id);
                }
                catch { }
                Dictionary <string, string> sASO = intcore.GetDropDownProperties(intadmin.ModuleID, intadmin.intlistid, new Guid(Request["LIST"]), "AvailableSynchOptions", "") ??
                                                   new Dictionary <string, string>();

                if (sASO.Count == 0)
                {
                    sASO.Add("LI", "LI");
                    sASO.Add("LO", "LO");
                    sASO.Add("TO", "TO");
                    sASO.Add("TI", "TI");
                }

                if (!sASO.ContainsKey("LI"))
                {
                    chkLin.Enabled = false;
                }
                if (!sASO.ContainsKey("LO"))
                {
                    chkLout.Enabled = false;
                }
                if (!sASO.ContainsKey("TO"))
                {
                    ddlTimed.Items.Remove(ddlTimed.Items.FindByValue("out"));
                }
                if (!sASO.ContainsKey("TI"))
                {
                    ddlTimed.Items.Remove(ddlTimed.Items.FindByValue("in"));
                }

                if (intlistid != Guid.Empty)
                {
                    if (!IsPostBack)
                    {
                        Hashtable hshParms = new Hashtable();
                        hshParms.Add("intlistid", intlistid);
                        DataSet dsInfo = intcore.GetDataSet("SELECT * FROM INT_LISTS where INT_LIST_ID=@intlistid", hshParms);
                        DataRow dr     = dsInfo.Tables[0].Rows[0];

                        lblKey.Text = dr["INT_KEY"].ToString();

                        if (dr["LIVEOUTGOING"].ToString() == "True")
                        {
                            chkLout.Checked = true;
                        }
                        if (dr["LiveIncoming"].ToString() == "True")
                        {
                            chkLin.Checked = true;
                        }


                        if (dr["TIMEOUTGOING"].ToString() == "True")
                        {
                            ddlTimed.SelectedValue = "out";
                        }
                        if (dr["TIMEINCOMING"].ToString() == "True")
                        {
                            ddlTimed.SelectedValue = "in";
                        }

                        try
                        {
                            chkDeleteList.Checked = bool.Parse(hshProps["AllowDeleteList"].ToString());
                        }
                        catch { }
                        try
                        {
                            chkDeleteInt.Checked = bool.Parse(hshProps["AllowDeleteInt"].ToString());
                        }
                        catch { }

                        try
                        {
                            chkAddList.Checked = bool.Parse(hshProps["AllowAddList"].ToString());
                        }
                        catch { }
                        try
                        {
                            chkAddInt.Checked = bool.Parse(hshProps["AllowAddInt"].ToString());
                        }
                        catch { }
                    }
                }
                else
                {
                    chkLout.Checked = true;
                }


                if (lblKey.Text == "")
                {
                    lblKey.Text = Guid.NewGuid().ToString("N") + Guid.NewGuid().ToString("N");
                }

                if (Request["wizard"] == "1")
                {
                    Button1.Text = "Next >";
                }

                if (!IsPostBack)
                {
                    if (ddlTimed.SelectedValue != "")
                    {
                        using (var connection = new SqlConnection(CoreFunctions.getConnectionString(Web.Site.WebApplication.Id)))
                        {
                            connection.Open();

                            using (var command = new SqlCommand("SELECT scheduletype, runtime, days from TIMERJOBS where listguid=@listguid and jobtype=70 and [key]=@key", connection))
                            {
                                command.Parameters.AddWithValue("@listguid", Request["List"]);
                                command.Parameters.AddWithValue("@key", Request["intlistid"]);
                                using (var dataReader = command.ExecuteReader())
                                {
                                    if (dataReader.Read())
                                    {
                                        ddlScheduleType.SelectedValue = dataReader.GetInt32(0).ToString();
                                        if (ddlScheduleType.SelectedValue == "2")
                                        {
                                            ddlHour.SelectedValue = dataReader.GetInt32(1).ToString();

                                            var arrayList = new ArrayList(dataReader.GetString(2).Split(','));
                                            foreach (ListItem listItem in chkDayOfWeek.Items)
                                            {
                                                if (arrayList.Contains(listItem.Value))
                                                {
                                                    listItem.Selected = true;
                                                }
                                            }
                                        }
                                        else if (ddlScheduleType.SelectedValue == "3")
                                        {
                                            ddlDayOfMonth.SelectedValue = dataReader.GetInt32(1).ToString();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }