protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); if (string.IsNullOrEmpty(SiteUrl)) { return; } if (settings != null) { chkAppLists.Checked = settings.ShowApplicationLists; chkHidden.Checked = settings.ShowHiddenLists; chkGallery.Checked = settings.ShowGalleryLists; } tsLabel.Text = string.Format(tsLabel.Text, SiteUrl); UpdateControlsState(false); if (SelectedList != null) { IList <SPColumn> codeCols = SelectedList.GetColumnsForCode(); if (codeCols != null && codeCols.Count > 0) { originalColumns = new List <SPColumn>(codeCols.Count); foreach (SPColumn col in codeCols) { originalColumns.Add(SPColumn.Clone(col)); } } } System.Threading.ThreadStart starter = new System.Threading.ThreadStart(RetrieveLists); _listThread = new System.Threading.Thread(starter); _listThread.SetApartmentState(System.Threading.ApartmentState.STA); _listThread.IsBackground = true; _listThread.Start(); this.Cursor = Cursors.WaitCursor; }
public void AddColumnToCode(SPColumn col) { IList <SPColumn> cols = GetColumnsForCode(); col.includeInCode = true; col.SASOrder = cols.Count; }
public List <SPColumn> GetColumns(bool refresh = false) { if (refresh || _columns.Count == 0) { IList <SPColumn> original = null; if (refresh) { original = GetColumnsForCode(); } _columns = spWrap.GetColumnList(this); if (original != null && original.Count > 0) { foreach (SPColumn col in original) { int ndx = _columns.IndexOf(col); if (ndx >= 0) { SPColumn.CopyColumnSettings(_columns[ndx], col); } } } } return(new List <SPColumn>(_columns)); }
private void ListPicker_FormClosed(object sender, FormClosedEventArgs e) { try { SelectedList = lstLists.SelectedItem as SPList; if (lvColumns.Items.Count > 0) { foreach (ListViewItem lvi in lvColumns.Items) { SPColumn col = lvi.Tag as SPColumn; if (col != null) { if (lvi.Selected) { if (!col.includeInCode) { SelectedList.AddColumnToCode(col); } } else //don't include in code { if (col.includeInCode) { SelectedList.RemoveColumnFromCode(col); } } } } } } catch (Exception ex) { ImportFromSharePointListTaskForm.DisplayError("Unexpected Error closing List Form", ex); } }
private void LoadColumns() { SPColumn selCol = lstColumns.SelectedItem as SPColumn; lstColumns.Items.Clear(); if (_list != null) { SortedList <string, SPColumn> sortedCols = new SortedList <string, SPColumn>(); foreach (SPColumn curCol in _list.GetColumns(true)) { if (!curCol.includeInCode) { if (!curCol.Hidden || _settings.ShowHiddenColumns) { sortedCols.Add(curCol.ToString(), curCol); } } } lstColumns.Items.AddRange(sortedCols.Values.ToArray()); if (selCol != null && lstColumns.Items.Contains(selCol)) { lstColumns.SelectedItem = selCol; } } btnOK.Enabled = lstColumns.SelectedItem != null; }
public string GetDataStepCode(string outputLibrary, string outputDataName, bool stopOnBadNumData = false, bool removeHTML = true) { this.removeHTML = removeHTML; StringBuilder sbCode = new StringBuilder(); //start data statement sbCode.AppendFormat("DATA {0}.{1};{2}", outputLibrary, outputDataName, Environment.NewLine); IList <SPColumn> codeCols = GetColumnsForCode(); //get format statement string fmtStatment = GetFormatStatement(codeCols); if (!string.IsNullOrEmpty(fmtStatment)) { sbCode.Append(fmtStatment); } sbCode.AppendFormat("INFILE CARDS4 DSD;{0}INPUT ", Environment.NewLine); //append columns foreach (SPColumn curCol in codeCols) { string fmtString = curCol.getDATAStepInFormat(stopOnBadNumData); sbCode.AppendFormat("{0} : {1}{2}", curCol.SASName, fmtString, Environment.NewLine); } //add closing ; after input statement sbCode.AppendFormat(";{0}", Environment.NewLine); //add cards sbCode.AppendFormat("CARDS4;{0}", Environment.NewLine); string[,] data = GetCardsData(); int upperCol = data.GetUpperBound(1); for (int row = 0; row <= data.GetUpperBound(0); row++) { for (int col = 0; col <= upperCol; col++) { string strValue = data[row, col]; //if this is a char column, we need to truncate to the informat length SPColumn column = codeCols[col]; if (0 == string.Compare(SPColumn.SASChar, column.SASType, true)) { int informatLen = column.InformatLength; if (strValue.Length > informatLen) { strValue = strValue.Substring(0, informatLen); if (!strValue.EndsWith("\"")) { strValue += '"'; } } } sbCode.AppendFormat("{0}, ", strValue); } sbCode.Append(Environment.NewLine); } //append end of everything line sbCode.AppendFormat("{0}{1}", endCards4, Environment.NewLine); return(sbCode.ToString()); }
internal static void CopyColumnSettings(SPColumn newCol, SPColumn oldCol) { newCol.includeInCode = oldCol.includeInCode; newCol.SASOrder = oldCol.SASOrder; newCol.SASFormat = oldCol.SASFormat; newCol.SASInFormat = oldCol.SASInFormat; newCol.SASType = oldCol.SASType; }
private void btnDown_Click(object sender, EventArgs e) { SPColumn col = lvColumns.SelectedItems[0].Tag as SPColumn; _selList.MoveColumn(col, false); UpdateColInfo(); lvColumns.Items[col.SASOrder].Selected = true; }
public void RemoveColumnFromCode(SPColumn col) { IList <SPColumn> cols = GetColumnsForCode(); for (int i = col.SASOrder + 1; i < cols.Count; i++) { SPColumn curCol = cols[i]; --curCol.SASOrder; } col.includeInCode = false; col.SASOrder = -1; }
private void btnDel_Click(object sender, EventArgs e) { if (lvColumns.SelectedItems.Count > 0) { SPColumn col = lvColumns.SelectedItems[0].Tag as SPColumn; if (col != null) { _selList.RemoveColumnFromCode(col); UpdateColInfo(); UpdateColButtons(); } } }
public static SPList Clone(SPList original) { SPList clone = new SPList(); clone.siteUrl = original.siteUrl; clone.Title = original.Title; clone.ID = original.ID; clone.Description = original.Description; clone.Hidden = original.Hidden; clone.IsAppList = original.IsAppList; clone.IsGallery = original.IsGallery; foreach (SPColumn col in original._columns) { clone._columns.Add(SPColumn.Clone(col)); } return(clone); }
public static SPColumn Clone(SPColumn original) { SPColumn clone = new SPColumn(); clone._sasName = original._sasName; clone.Description = original.Description; clone.Hidden = original.Hidden; clone.ID = original.ID; clone.includeInCode = original.includeInCode; clone.SASFormat = original.SASFormat; clone.SASInFormat = original.SASInFormat; clone.SASName = original.SASName; clone.SASOrder = original.SASOrder; clone.SASType = original.SASType; clone.SPFieldType = original.SPFieldType; clone.SPName = original.SPName; clone.Title = original.Title; return(clone); }
public void MoveColumn(SPColumn column, bool up) { //find column to switch with int targetOrder = up ? column.SASOrder - 1 : column.SASOrder + 1; SPColumn targetCol = null; foreach (SPColumn curCol in GetColumns(false)) { if (curCol.SASOrder == targetOrder) { targetCol = curCol; break; } } if (targetCol != null) { targetCol.SASOrder = column.SASOrder; column.SASOrder = targetOrder; } }
public SPList(XmlElement xParent) { _columns = new List<SPColumn>(); XmlNode xTop = xParent["SPList"]; this.Title = xTop.Attributes["Title"].Value; this.ID = new Guid(xTop.Attributes["ID"].Value); Hidden = Convert.ToBoolean(xTop.Attributes["Hidden"].Value); IsGallery = Convert.ToBoolean(xTop.Attributes["isGallery"].Value); IsAppList = Convert.ToBoolean(xTop.Attributes["isAppList"].Value); this.siteUrl = xTop["url"].InnerText; XmlNode colNode = xTop["Columns"]; foreach (XmlNode xChild in colNode.ChildNodes) { if (xChild.Name == "Column") { SPColumn col = new SPColumn(xChild); _columns.Add(col); } } }
public SPList(XmlElement xParent) { _columns = new List <SPColumn>(); XmlNode xTop = xParent["SPList"]; this.Title = xTop.Attributes["Title"].Value; this.ID = new Guid(xTop.Attributes["ID"].Value); Hidden = Convert.ToBoolean(xTop.Attributes["Hidden"].Value); IsGallery = Convert.ToBoolean(xTop.Attributes["isGallery"].Value); IsAppList = Convert.ToBoolean(xTop.Attributes["isAppList"].Value); this.siteUrl = xTop["url"].InnerText; XmlNode colNode = xTop["Columns"]; foreach (XmlNode xChild in colNode.ChildNodes) { if (xChild.Name == "Column") { SPColumn col = new SPColumn(xChild); _columns.Add(col); } } }
private void EditSelectedColumnProperties() { if (lvColumns.SelectedItems.Count > 0) { //Show ColProps Dialog SPColumn col = lvColumns.SelectedItems[0].Tag as SPColumn; if (col != null) { SPColumnProperties props = new SPColumnProperties(col, Consumer); try { Cursor = Cursors.WaitCursor; if (FormatDialog == null || FormatDialog.SASWorkspace == null) { if (FormatDialog == null) { FormatDialog = new SAS.SharedUI.FormatsDialog(); } FormatDialog.SASWorkspace = (SAS.IWorkspace)Consumer.Workspace(Consumer.AssignedServer); } props.FormatDialog = FormatDialog; } finally { Cursor = Cursors.Default; } if (DialogResult.OK == props.ShowDialog(this)) { col.SASName = props.SASName; col.SASType = props.SASType; col.SASFormat = props.SASFormat; col.SASInFormat = props.SASInFormat; UpdateColInfo(); UpdateColButtons(); } } } }
private string[,] GetCardsData() { string[,] rc = null; using (ClientContext SPContext = new ClientContext(siteUrl)) { Web site = SPContext.Web; SPContext.Load(site); SPContext.ExecuteQuery(); List list = site.Lists.GetById(this.ID); StringBuilder sbQuery = new StringBuilder(); IList <SPColumn> columns = GetColumnsForCode(); int cols = columns.Count; if (cols > 0) { sbQuery.AppendFormat("<View>{0}", Environment.NewLine); sbQuery.AppendFormat(" <Query>{0}", Environment.NewLine); sbQuery.AppendFormat(" <OrderBy>{0}", Environment.NewLine); sbQuery.AppendFormat(" <FieldRef Name='{0}'/>{1}", columns[0].SPName, Environment.NewLine); sbQuery.AppendFormat(" </OrderBy>{0}", Environment.NewLine); sbQuery.AppendFormat(" </Query>{0}", Environment.NewLine); sbQuery.AppendFormat(" <ViewFields>{0}", Environment.NewLine); foreach (SPColumn curcol in columns) { sbQuery.AppendFormat(" <FieldRef Name='{0}'/>{1}", curcol.SPName, Environment.NewLine); } sbQuery.AppendFormat(" </ViewFields>{0}", Environment.NewLine); sbQuery.AppendFormat("</View>{0}", Environment.NewLine); CamlQuery query = new CamlQuery(); query.ViewXml = sbQuery.ToString(); SPContext.Load(list); SPContext.ExecuteQuery(); ListItemCollection items = list.GetItems(query); SPContext.Load(items); SPContext.ExecuteQuery(); int rows = items.Count; rc = new string[rows, cols]; for (int i = 0; i < rows; i++) { ListItem li = items[i]; var itemTextValues = li.FieldValuesAsText; SPContext.Load(itemTextValues); SPContext.ExecuteQuery(); for (int j = 0; j < cols; j++) { SPColumn curcol = columns[j]; string origSASType = SPColumn.SASTypeFromFieldType(curcol.SPFieldType); string spValue = (origSASType == SPColumn.SASChar ? "\"\"" : "."); if (li[curcol.SPName] != null) { spValue = GetStringValueFromField(li[curcol.SPName], itemTextValues[curcol.SPName], curcol.SASType, curcol.SPFieldType); } rc[i, j] = spValue; } } } } return(rc); }
private void PopulateColumns(bool refresh) { Cursor backup = Cursor.Current; lvColumns.Items.Clear(); SPList selList = lstLists.SelectedItem as SPList; if (selList != null) { try { lvColumns.Columns.Clear(); if (settings.ShowHiddenColumns) { this.lvColumns.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, this.columnHeader3, this.colHeaderHidden, this.columnHeader2 }); } else { this.lvColumns.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, this.columnHeader3, this.columnHeader2 }); } tsLabel.Text = string.Format("Retrieving Field Information for {0}", selList.Title); Application.DoEvents(); Cursor.Current = Cursors.WaitCursor; List <SPColumn> fields = selList.GetColumns(refresh); if (refresh && originalColumns != null && originalColumns.Count > 0) { foreach (SPColumn col in fields) { if (originalColumns.Contains(col)) { int ndx = originalColumns.IndexOf(col); SPColumn orig = originalColumns[ndx]; col.includeInCode = orig.includeInCode; col.SASOrder = orig.SASOrder; originalColumns.RemoveAt(ndx); } if (originalColumns.Count == 0) { originalColumns = null; break; } } } foreach (SPColumn col in fields) { if (chkHiddenCols.Checked || !col.Hidden) { ListViewItem lvi = new ListViewItem(); lvi.Text = col.Title; string[] subranges = null; if (settings.ShowHiddenColumns) { subranges = new string[] { col.SPFieldType, col.Hidden.ToString(), col.Description } } ; else { subranges = new string[] { col.SPFieldType, col.Description } }; lvi.SubItems.AddRange(subranges); lvi.Tag = col; lvi.Selected = col.includeInCode; lvColumns.Items.Add(lvi); } } } catch (Exception ex) { ImportFromSharePointListTaskForm.DisplayError("Error getting list information", ex); } finally { Cursor.Current = backup; tsLabel.Text = "Ready"; _bNeedRefresh = false; } } }
public static SPColumn Clone(SPColumn original) { SPColumn clone = new SPColumn(); clone._sasName = original._sasName; clone.Description = original.Description; clone.Hidden = original.Hidden; clone.ID = original.ID; clone.includeInCode = original.includeInCode; clone.SASFormat = original.SASFormat; clone.SASInFormat = original.SASInFormat; clone.SASName = original.SASName; clone.SASOrder = original.SASOrder; clone.SASType = original.SASType; clone.SPFieldType = original.SPFieldType; clone.SPName = original.SPName; clone.Title = original.Title; return clone; }
public void RemoveColumnFromCode(SPColumn col) { IList<SPColumn> cols = GetColumnsForCode(); for (int i = col.SASOrder + 1; i < cols.Count; i++) { SPColumn curCol = cols[i]; --curCol.SASOrder; } col.includeInCode = false; col.SASOrder = -1; }
public SPColumnProperties(SPColumn col, ISASTaskConsumer3 cons) { _column = col; consumer = cons; InitializeComponent(); }
public SPColumnProperties(SPColumn col,ISASTaskConsumer3 cons) { _column = col; consumer = cons; InitializeComponent(); }
public void AddColumnToCode(SPColumn col) { IList<SPColumn> cols = GetColumnsForCode(); col.includeInCode = true; col.SASOrder = cols.Count; }