Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                Hashtable hshParms = new Hashtable();
                hshParms.Add("intlistid", Request["intlistid"]);
                hshParms.Add("type", ddlLevel.SelectedValue);

                API.Integration.IntegrationCore core = new API.Integration.IntegrationCore(Web.Site.ID, Web.ID);
                DataSet dsLog = core.GetDataSet("SELECT * FROM INT_LOG WHERE INT_LIST_ID=@intlistid and LOGTYPE>=@type order by dtlogged desc", hshParms);


                gvLog.DataSource = dsLog.Tables[0];
                gvLog.DataBind();
            });
        }
        internal IntegrationAdmin(API.Integration.IntegrationCore core, Guid Intlistid, Guid Moduleid)
        {
            _core             = core;
            this.intlistid    = Intlistid;
            this.ModuleID     = Moduleid;
            hshProperties     = new Hashtable();
            ControlCollection = new ArrayList();

            if (intlistid != Guid.Empty && ModuleID == Guid.Empty)
            {
                Hashtable hshProps = new Hashtable();
                hshProps.Add("intlistid", intlistid);

                DataSet ds = _core.GetDataSet("SELECT MODULE_ID,LIST_ID FROM INT_LISTS where INT_LIST_ID=@intlistid", hshProps);

                try
                {
                    ModuleID = new Guid(ds.Tables[0].Rows[0]["MODULE_ID"].ToString());
                }
                catch { }
                ListId = new Guid(ds.Tables[0].Rows[0]["LIST_ID"].ToString());
            }
        }
        internal bool DeleteIntegration(Guid intlistid, out string message)
        {
            message = "";
            if (_core.RemoveIntegration(intlistid, ListId, out message))
            {
                Hashtable hshProps = new Hashtable();
                hshProps.Add("intlistid", intlistid);


                string sql = "SELECT SITE_ID,WEB_ID,LIST_ID, INT_COLID from INT_LISTS where INT_LIST_ID=@intlistid";

                DataSet ds     = _core.GetDataSet(sql, hshProps);
                DataRow dr     = ds.Tables[0].Rows[0];
                Guid    listid = new Guid(dr["LIST_ID"].ToString());
                string  colid  = "INTUID" + dr["INT_COLID"].ToString();
                Guid    SiteId = new Guid(dr["SITE_ID"].ToString());
                Guid    WebId  = new Guid(dr["WEB_ID"].ToString());

                sql = "DELETE FROM INT_LISTS where INT_LIST_ID=@intlistid";

                _core.ExecuteQuery(sql, hshProps, false);


                sql = "DELETE FROM INT_LOG where INT_LIST_ID=@intlistid";
                _core.ExecuteQuery(sql, hshProps, false);

                sql = "DELETE FROM INT_COLUMNS where INT_LIST_ID=@intlistid";
                _core.ExecuteQuery(sql, hshProps, false);

                sql = "DELETE FROM INT_PROPS where INT_LIST_ID=@intlistid";
                _core.ExecuteQuery(sql, hshProps, true);

                using (SPSite site = new SPSite(SiteId))
                {
                    using (SPWeb web = site.OpenWeb(WebId))
                    {
                        web.AllowUnsafeUpdates = true;
                        SPList  list  = web.Lists[listid];
                        SPField field = null;
                        try
                        {
                            field = list.Fields.GetFieldByInternalName(colid);
                        }
                        catch { }

                        if (field != null)
                        {
                            field.Hidden = false;
                            field.Update();
                            list.Fields.Delete(field.InternalName);
                        }
                        list.Update();

                        RemoveEventHandlers(list);
                    }
                }

                _core.UpdatePriorityNumbers(listid);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public void execute(SPSite site, SPWeb web, string data)
        {
            try
            {
                Guid intlistid = new Guid(base.key);

                API.Integration.IntegrationCore core = new API.Integration.IntegrationCore(site.ID, web.ID);
                Hashtable hshParms = new Hashtable();
                hshParms.Add("intlistid", intlistid);
                DateTime dtStarted = DateTime.Now;

                DataSet   DS            = core.GetDataSet("SELECT * FROM INT_LISTS where INT_LIST_ID=@intlistid", hshParms);
                DataRow   drIntegration = DS.Tables[0].Rows[0];
                Hashtable hshProperties = null;
                DataSet   dsColumns     = null;
                DataTable dtCols        = null;
                DataTable dtItem        = null;
                DataSet   dsUserFields  = null;
                DataTable dtUserFields  = null;
                Hashtable hshUserMap    = null;
                DataTable dtRet         = null;
                DataSet   dsItem        = null;
                try
                {
                    hshProperties = core.GetProperties(intlistid);

                    dsColumns = core.GetDataSet("SELECT * FROM INT_COLUMNS where INT_LIST_ID=@intlistid", hshParms);
                    dtCols    = dsColumns.Tables[0];

                    dtItem = new DataTable();
                    dtItem.Columns.Add("ID");
                    foreach (DataRow drCol in dtCols.Rows)
                    {
                        dtItem.Columns.Add(drCol["IntegrationColumn"].ToString());
                    }

                    DateTime dtLastSynch = new DateTime(1900, 1, 1);

                    try
                    {
                        dtLastSynch = DateTime.Parse(drIntegration["LASTSYNCH"].ToString());
                    }
                    catch { }

                    if (drIntegration["TIMEINCOMING"].ToString() == "True")
                    {
                        dtItem = core.PullData(dtItem, intlistid, new Guid(drIntegration["LIST_ID"].ToString()), dtLastSynch);

                        base.totalCount = dtItem.Rows.Count + 1;

                        int count = 0;

                        bool allowAdd = false;

                        try
                        {
                            allowAdd = bool.Parse(hshProperties["AllowAddList"].ToString());
                        }
                        catch { }

                        SPList list = web.Lists[new Guid(drIntegration["LIST_ID"].ToString())];

                        GridGanttSettings settings = new GridGanttSettings(list);

                        bool bBuildTeamSec = settings.BuildTeamSecurity;

                        dsUserFields = core.GetDataSet(list, "", intlistid);
                        dtUserFields = dsUserFields.Tables[1];
                        if (dtUserFields.Select("Type='1'").Length > 0 || bBuildTeamSec)
                        {
                            hshUserMap = core.GetUserMap(drIntegration["INT_LIST_ID"].ToString(), true);
                        }

                        bool bSPCol = false;
                        try
                        {
                            if (hshProperties["SPColumn"].ToString() != "")
                            {
                                bSPCol = true;
                            }
                        }
                        catch { }

                        dtRet = new DataTable();
                        dtRet.Columns.Add("ID");

                        if (bSPCol)
                        {
                            dtRet.Columns.Add(hshProperties["SPColumn"].ToString());
                        }

                        foreach (DataRow dr in dtItem.Rows)
                        {
                            int spid = core.iProcessItemRow(dr, list, dtCols, hshProperties, drIntegration["INT_COLID"].ToString(), intlistid, new Guid(drIntegration["MODULE_ID"].ToString()), allowAdd, dtUserFields, hshUserMap);

                            try
                            {
                                if (spid != 0 && bSPCol)
                                {
                                    dtRet.Rows.Add(new string[] { dr["ID"].ToString(), spid.ToString() });
                                }
                            }
                            catch { }

                            base.updateProgress(count++);
                        }

                        if (bSPCol)
                        {
                            core.PostIntegrationUpdateToExternal(dtRet, intlistid, list.ID);
                        }

                        core.LogMessage(intlistid.ToString(), drIntegration["LIST_ID"].ToString(), "Timer: Imported " + dtItem.Rows.Count + " Items", 1);
                    }
                    else if (drIntegration["TIMEOUTGOING"].ToString() == "True")
                    {
                        SPList list = web.Lists[new Guid(drIntegration["LIST_ID"].ToString())];
                        core.OpenConnection();
                        dsItem = core.GetDataSet(list, "", intlistid);

                        SPQuery query = new SPQuery();
                        query.Query = "<Where><Gt><FieldRef Name=\"Modified\" /><Value IncludeTimeValue=\"TRUE\" Type=\"DateTime\">" + Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime(dtLastSynch) + "</Value></Gt></Where>";
                        SPListItemCollection lic = list.GetItems(query);

                        base.totalCount = lic.Count * 2;
                        int count = 0;
                        foreach (SPListItem li in lic)
                        {
                            core.ProcessItem(dsItem, li, list);
                            updateProgress(count++);
                        }

                        core.PostIntegration(dsItem.Tables[0].Copy(), dsItem.Tables[1], dsItem.Tables[2], list);

                        core.LogMessage(intlistid.ToString(), drIntegration["LIST_ID"].ToString(), "Timer: Exported " + lic.Count + " Items", 1);
                    }

                    hshParms.Add("lastsynch", dtStarted.ToString());
                    core.ExecuteQuery("UPDATE INT_LISTS set lastsynch=@lastsynch where INT_LIST_ID=@intlistid", hshParms, true);

                    core.CloseConnection(true);
                }
                catch (Exception ex)
                {
                    core.LogMessage(intlistid.ToString(), drIntegration["LIST_ID"].ToString(), "Timer: " + ex.Message, 3);
                    sErrors += "General Error: " + ex.Message;
                    bErrors  = true;
                }
                finally
                {
                    hshParms      = null;
                    hshUserMap    = null;
                    hshProperties = null;
                    if (DS != null)
                    {
                        DS.Dispose();
                    }
                    if (dsColumns != null)
                    {
                        dsColumns.Dispose();
                    }
                    if (dtCols != null)
                    {
                        dtCols.Dispose();
                    }
                    if (dtItem != null)
                    {
                        dtItem.Dispose();
                    }
                    if (dsUserFields != null)
                    {
                        dsUserFields.Dispose();
                    }
                    if (dtUserFields != null)
                    {
                        dtUserFields.Dispose();
                    }
                    if (dtRet != null)
                    {
                        dtRet.Dispose();
                    }
                    if (dsItem != null)
                    {
                        dsItem.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                sErrors += "General Error: " + ex.Message;
                bErrors  = true;
            }
            finally
            {
                if (web != null)
                {
                    web.Dispose();
                }
                if (site != null)
                {
                    site.Dispose();
                }
                data = null;
            }
        }
Ejemplo n.º 5
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();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                try
                {
                    intlistid = new Guid(Request["intlistid"]);
                }
                catch { }

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

                bool bWizard = false;

                try
                {
                    if (Request["wizard"] == "1")
                    {
                        bWizard = true;
                    }
                }catch {}



                PageHead = intadmin.GetIntegrationHeader();

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

                SPList list = Web.Lists[intadmin.ListId];

                List <ColumnProperty> ColumnList = intcore.GetColumns(hshProps, intadmin.ModuleID, intlistid, list);

                DropDownList ddlColsTemp = new DropDownList();

                foreach (ColumnProperty Column in ColumnList)
                {
                    ListItem li1 = new ListItem(Column.DiplayName, Column.ColumnName);
                    ddlIDColumn.Items.Add(li1);

                    ListItem li2 = new ListItem(Column.DiplayName, Column.ColumnName);
                    ddlSPColumn.Items.Add(li2);

                    ListItem li3 = new ListItem(Column.DiplayName, Column.ColumnName);
                    ddlSecMatch.Items.Add(li3);

                    ListItem li4 = new ListItem(Column.DiplayName, Column.ColumnName);
                    ddlIntegrationMatch.Items.Add(li4);
                }


                SPList List = Web.Lists[new Guid(Request["List"])];


                pnlColumns.Controls.Add(new LiteralControl("<table>"));
                pnlColumns.Controls.Add(new LiteralControl("<tr><td><b>SharePoint Column</b></td><td><b>Integration Column</b></td></tr>"));

                SortedList sl = new SortedList();
                foreach (SPField field in List.Fields)
                {
                    if (field.Reorderable)
                    {
                        if (!sl.Contains(field.Title))
                        {
                            sl.Add(field.Title, field.InternalName);
                        }
                    }
                }

                sl.Add("Created By", "Author");

                Hashtable hshParams = new Hashtable();
                hshParams.Add("intlistid", intlistid);

                DataSet ds          = intcore.GetDataSet("SELECT * FROM INT_COLUMNS WHERE INT_LIST_ID=@intlistid", hshParams);
                DataTable dtColumns = ds.Tables[0];

                foreach (DictionaryEntry de in sl)
                {
                    DropDownList ddl = new DropDownList();
                    ddl.ID           = de.Value.ToString();
                    ddl.Items.Add(new ListItem("--Select Column--", ""));


                    ListItem li3 = new ListItem(de.Key.ToString(), de.Value.ToString());
                    ddlSharePointMatch.Items.Add(li3);

                    string curCol = "";

                    if (!IsPostBack)
                    {
                        DataRow [] drCol = dtColumns.Select("SharePointColumn='" + de.Value.ToString() + "'");
                        if (drCol.Length > 0)
                        {
                            curCol = drCol[0]["IntegrationColumn"].ToString();
                        }
                    }

                    foreach (ColumnProperty Column in ColumnList)
                    {
                        ListItem li2 = new ListItem(Column.DiplayName, Column.ColumnName);
                        if (!IsPostBack)
                        {
                            if (bWizard && Column.DefaultListColumn == de.Value.ToString())
                            {
                                li2.Selected = true;
                            }
                            else if (curCol == Column.ColumnName)
                            {
                                li2.Selected = true;
                            }
                        }

                        ddl.Items.Add(li2);
                    }

                    bool selectedFound = false;

                    foreach (ListItem listItem in ddl.Items)
                    {
                        if (!selectedFound)
                        {
                            selectedFound = listItem.Selected;
                        }
                        else
                        {
                            listItem.Selected = false;
                        }
                    }

                    ArrControls.Add(ddl);

                    pnlColumns.Controls.Add(new LiteralControl("<tr><td>" + de.Key.ToString() + "</td><td>"));

                    pnlColumns.Controls.Add(ddl);

                    pnlColumns.Controls.Add(new LiteralControl("</td></tr>"));
                }

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

                if (!IsPostBack)
                {
                    if (bWizard)
                    {
                        foreach (ColumnProperty Column in ColumnList)
                        {
                            ListItem li2 = new ListItem(Column.DiplayName, Column.ColumnName);
                            if (Column.DefaultListColumn == "INTUID")
                            {
                                ddlIDColumn.SelectedValue = Column.ColumnName;
                            }
                            if (Column.DefaultListColumn == "SPID")
                            {
                                ddlSPColumn.SelectedValue = Column.ColumnName;
                            }
                            if (Column.DefaultListColumn == "SECMATCH")
                            {
                                ddlSecMatch.SelectedValue = Column.ColumnName;
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            ddlIDColumn.SelectedValue = hshProps["IDColumn"].ToString();
                        }
                        catch { }

                        try
                        {
                            ddlSPColumn.SelectedValue = hshProps["SPColumn"].ToString();
                        }
                        catch { }

                        try
                        {
                            ddlSecMatch.SelectedValue = hshProps["SecMatch"].ToString();
                        }
                        catch { }

                        try
                        {
                            string[] match = hshProps["ItemMatch"].ToString().Split('|');
                            ddlSharePointMatch.SelectedValue  = match[0];
                            ddlIntegrationMatch.SelectedValue = match[1];
                        }
                        catch { }
                    }
                }


                if (bWizard)
                {
                    Button1.Text          = "Finish";
                    Button1.OnClientClick = "Install();";
                }
                else
                {
                    Button1.OnClientClick = "DisableButtons();";
                }
            });
        }