protected void Button1_Click(object sender, EventArgs e)
        {
            string message = "";

            Hashtable Properties = intadmin.GetCurrentPageProperties();


            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                if (intcore.TestModuleConnection(intadmin.ModuleID, intlistid, new Guid(Request["List"]), Properties, out message))
                {
                    lblError.Visible = false;

                    Hashtable hshProps = new Hashtable();

                    if (Request["wizard"] == "1")
                    {
                        intadmin.CreateIntegration(Web.Site.ID, Web.ID, new Guid(Request["List"]), Guid.NewGuid().ToString("N") + Guid.NewGuid().ToString("N"), false, false, false, false);
                        intadmin.SaveProperties(hshProps);
                        SPUtility.Redirect("epmlive/integration/properties.aspx?intlistid=" + intadmin.intlistid + "&LIST=" + Request["List"] + "&wizard=1&ret=" + Request["ret"], SPRedirectFlags.RelativeToLayoutsPage, System.Web.HttpContext.Current);
                    }
                    else
                    {
                        SPList list = Web.Lists[new Guid(Request["List"])];
                        //intadmin.UpdateIntegration(intlistid, lblKey.Text, chkLout.Checked, chkLin.Checked, chkTout.Checked, chkTin.Checked);
                        intadmin.SaveProperties(hshProps);
                        intadmin.InstallEventHandlers(list);
                        if (Request["ret"] == "Manage")
                        {
                            SPUtility.Redirect("epmlive/integration/manage.aspx", SPRedirectFlags.RelativeToLayoutsPage, System.Web.HttpContext.Current);
                        }
                        else
                        {
                            SPUtility.Redirect("epmlive/integration/integrationlist.aspx?LIST=" + Request["List"], SPRedirectFlags.RelativeToLayoutsPage, System.Web.HttpContext.Current);
                        }
                    }
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = message;
                }
            });
        }
Ejemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string message = "";

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                if (intcore.TestModuleConnection(intadmin.ModuleID, intlistid, new Guid(Request["List"]), out message))
                {
                    lblError.Visible = false;

                    Hashtable hshProps = new Hashtable();
                    hshProps.Add("AllowDeleteList", chkDeleteList.Checked.ToString());
                    hshProps.Add("AllowDeleteInt", chkDeleteInt.Checked.ToString());
                    hshProps.Add("AllowAddList", chkAddList.Checked.ToString());
                    hshProps.Add("AllowAddInt", chkAddInt.Checked.ToString());

                    intadmin.UpdateIntegration(intlistid, lblKey.Text, chkLout.Checked, chkLin.Checked, ddlTimed.SelectedValue == "out", ddlTimed.SelectedValue == "in");
                    intadmin.SaveProperties(hshProps);

                    using (var connection = new SqlConnection(CoreFunctions.getConnectionString(Web.Site.WebApplication.Id)))
                    {
                        connection.Open();

                        using (var command = new SqlCommand("DELETE FROM TIMERJOBS WHERE listguid=@listid and jobtype=70 and [key]=@data", connection))
                        {
                            command.Parameters.AddWithValue("@listid", Request["LIST"]);
                            command.Parameters.AddWithValue("@data", Request["intlistid"]);
                            command.ExecuteNonQuery();
                        }

                        if (!string.IsNullOrWhiteSpace(ddlTimed.SelectedValue))
                        {
                            var days          = string.Empty;
                            var stringBuilder = new StringBuilder();
                            var runtime       = 0;
                            if (ddlScheduleType.SelectedValue == "3")
                            {
                                runtime = int.Parse(ddlDayOfMonth.SelectedValue);
                            }
                            else if (ddlScheduleType.SelectedValue == "2")
                            {
                                runtime = int.Parse(ddlHour.SelectedValue);
                                foreach (ListItem listItem in chkDayOfWeek.Items)
                                {
                                    if (listItem.Selected)
                                    {
                                        stringBuilder.Append(",")
                                        .Append(listItem.Value);
                                    }
                                }
                                days = stringBuilder.ToString().Trim(',');
                            }

                            using (var command = new SqlCommand("INSERT INTO TIMERJOBS (jobname, siteguid, webguid, listguid, jobtype, runtime, scheduletype, days, [key]) VALUES ('Integration', @siteguid, @webguid, @listguid, 70, @runtime, @scheduletype, @days, @key)", connection))
                            {
                                command.Parameters.AddWithValue("@siteguid", Web.Site.ID);
                                command.Parameters.AddWithValue("@webguid", Web.ID);
                                command.Parameters.AddWithValue("@listguid", Request["LIST"]);
                                command.Parameters.AddWithValue("@runtime", runtime);
                                command.Parameters.AddWithValue("@scheduletype", ddlScheduleType.SelectedValue);
                                command.Parameters.AddWithValue("@days", days);
                                command.Parameters.AddWithValue("@key", Request["intlistid"]);

                                command.ExecuteNonQuery();
                            }
                        }
                    }

                    if (Request["wizard"] == "1")
                    {
                        SPUtility.Redirect("epmlive/integration/columns.aspx?intlistid=" + intadmin.intlistid + "&LIST=" + Request["List"] + "&wizard=1&ret=" + Request["ret"], SPRedirectFlags.RelativeToLayoutsPage, System.Web.HttpContext.Current);
                    }
                    else
                    {
                        if (Request["ret"] == "Manage")
                        {
                            SPUtility.Redirect("epmlive/integration/manage.aspx", SPRedirectFlags.RelativeToLayoutsPage, System.Web.HttpContext.Current);
                        }
                        else
                        {
                            SPUtility.Redirect("epmlive/integration/integrationlist.aspx?LIST=" + Request["List"], SPRedirectFlags.RelativeToLayoutsPage, System.Web.HttpContext.Current);
                        }
                    }
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = message;
                }
            });
        }