Exemple #1
0
        private SortedDictionary <string, int> createUniqueListOfColumnValues()
        {
            SortedDictionary <string, int> uniqueValues = new SortedDictionary <string, int>();

            //--validate
            if (cboColumnNames.SelectedItem == null)
            {
                return(uniqueValues);
            }

            //--
            FieldAndContentType fnwc = (FieldAndContentType)cboColumnNames.SelectedItem;

            foreach (SPListItem listitem in ((SPList)cboDocLibs.SelectedItem).Items)
            {
                string val = Util.ToStr(listitem[fnwc.Field.Id]);
                if (!uniqueValues.ContainsKey(val))
                {
                    uniqueValues.Add(val, 1);
                }
                else
                {
                    uniqueValues[val] = uniqueValues[val] + 1;
                }
            }

            return(uniqueValues);
        }
        private void btnAddMap_Click(object sender, EventArgs e)
        {
            if (lstSource.SelectedItem == null || lstDest.SelectedItem == null)
            {
                return;
            }

            FieldAndContentType fcS = (FieldAndContentType)lstSource.SelectedItem;
            FieldAndContentType fcD = (FieldAndContentType)lstDest.SelectedItem;

            //lstSource.Items.Remove(fcS);
            //lstDest.Items.Remove(fcD);

            MappingItem mi = new MappingItem(fcS.Field.InternalName, fcD.Field.InternalName);

            m_mpWorking.MappingItems.Add(mi);
            m_mpWorking.MappingItems.Sort();
            displayMappingProfileInRtb(mi.ToString(), "added");
        }
Exemple #3
0
        private void lnkShowColumnInfo_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (cboColumnNames.SelectedItem == null)
            {
                return;
            }
            FieldAndContentType fct = (FieldAndContentType)cboColumnNames.SelectedItem;

            rtbDisplay.Clear();
            SmartStepUtil.AddToRTB(rtbDisplay, "Information about the Column ", Color.Blue, 13, true);
            SmartStepUtil.AddToRTB(rtbDisplay, fct.Field.Title + "\r\n", Color.MediumBlue, 13, true);
            //--
            SortedDictionary <string, int> uniqueValues = createUniqueListOfColumnValues();

            SmartStepUtil.AddToRTB(rtbDisplay, "List of unique values:\r\n", Color.Black, 8, true);
            foreach (KeyValuePair <string, int> de in uniqueValues)
            {
                SmartStepUtil.AddToRTB(rtbDisplay, "   " + de.Key + " (" + de.Value + ")\r\n");
            }

            //--
            List <string> fieldPropertyNames = new List <string>();

            System.Collections.Hashtable fieldPropertyValues = new System.Collections.Hashtable();
            AddToRtbLocal("\r\n\r\n", StyleType.bodyBlack);
            SmartStepUtil.AddToRTB(rtbDisplay, "Technical Info: (All properties of the column)\r\n ", Color.Black, 8, true);
            foreach (System.Reflection.PropertyInfo propInfo in fct.Field.GetType().GetProperties())
            {
                object val = propInfo.GetValue(fct.Field, null);
                fieldPropertyNames.Add(propInfo.Name);
                fieldPropertyValues.Add(propInfo.Name, val);
            }

            //--
            fieldPropertyNames.Sort();
            foreach (string item in fieldPropertyNames)
            {
                AddToRtbLocal(item + ": ", StyleType.bodyBlack);
                SmartStepUtil.AddToRTB(rtbDisplay, fieldPropertyValues[item] + "\r\n", Color.Blue, 8, false);
            }
        }
Exemple #4
0
        private void updateSingleColumn(bool onlyValidate)
        {
            int counterUpdated          = 0;
            int counterTotalItemsInList = 0;

            try
            {
                FrmCancelRunning.ToggleEnabled(true);//toggleEnabled(true);

                SmartStepUtil.ClearRtbSafely(rtbDisplay);
                //--validate
                if (cboCurrentValue.SelectedItem == null)
                {
                    AddToRtbLocal("Please select a Current Value", StyleType.bodyBlack);
                    return;
                }
                if (cboColumnNames.SelectedItem == null)
                {
                    AddToRtbLocal("Please select a Column", StyleType.bodyBlack);
                    return;
                }

                FieldAndContentType fnwc = (FieldAndContentType)cboColumnNames.SelectedItem;
                //--messagebox to validate if the user really wants to update value to blank. (prevent accident).
                if (txtNewValue.Text.Trim() == "" && !onlyValidate)
                {
                    if (MessageBox.Show(this, "You have selected to update to a blank, Are you sure?", "SUSHI", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        return;
                    }
                }

                //--
                string s = onlyValidate ? "Displaying" : "Updating";
                SmartStepUtil.AddToRTB(rtbDisplay, s + " values for column ", Color.Green, 14, true);
                SmartStepUtil.AddToRTB(rtbDisplay, fnwc.Field.Title, Color.Chocolate, 14, true);
                SmartStepUtil.AddToRTB(rtbDisplay, " where value = ", Color.Green, 14, true);
                SmartStepUtil.AddToRTB(rtbDisplay, "\"" + cboCurrentValue.Text + "\"\r\n", Color.Chocolate, 14, true);

                SPList list = (SPList)cboDocLibs.SelectedItem;
                counterTotalItemsInList = list.Items.Count;
                foreach (SPListItem listitem in (list.Items))
                {
                    if (GlobalVars.CancelRunning)
                    {
                        throw new Eh.CancelException();
                    }
                    SmartStepUtil.ScrollToBottom(rtbDisplay);
                    Application.DoEvents();


                    if (Util.ToStr(listitem[fnwc.Field.Id]) == cboCurrentValue.Text)
                    {
                        //object o = listitem[fnwc.Field.Id];
                        //

                        SmartStepUtil.AddToRTB(rtbDisplay, listitem.File.Name, Color.Blue, 8, false);

                        AddToRtbLocal(" column ", StyleType.bodyBlack);
                        SmartStepUtil.AddToRTB(rtbDisplay, fnwc.Field.Title, Color.DarkCyan, 8, false);

                        if (onlyValidate)
                        {
                            AddToRtbLocal(" = ", StyleType.bodyBlack);
                            SmartStepUtil.AddToRTB(rtbDisplay, "\"" + cboCurrentValue.Text + "\"\r\n", Color.DarkGreen, 8, false);
                        }
                        else
                        {
                            listitem[fnwc.Field.Id] = txtNewValue.Text;
                            listitem.Update();
                            //idea: ability to replace part of a field, rather than the whole thing.
                            //mySPLI[mySPField.Title]=mySPLI[mySPField.Title].ToString().Replace(oldValue.Text,newValue.Text);mySPLI.Update();
                            if (listitem[fnwc.Field.Id].ToString() == txtNewValue.Text)
                            {
                                AddToRtbLocal(" updated to ", StyleType.bodyBlack);
                                SmartStepUtil.AddToRTB(rtbDisplay, "\"" + txtNewValue.Text + "\"\r\n", Color.DarkBlue, 8, false);
                                counterUpdated++;
                            }
                            else
                            {
                                SmartStepUtil.AddToRTB(rtbDisplay, " NOT successfully updated\r\n", Color.Red, 8, false);
                            }
                        }
                    }
                }

                //--
                if (!onlyValidate)
                {
                    cboColumnNames_SelectedIndexChanged(null, null);
                    SmartStepUtil.AddToRTB(rtbDisplay, "update completed successfully\r\n", Color.Black, 8, true);
                }
            }
            catch (Eh.CancelException)
            {
                SmartStepUtil.AddToRTB(rtbDisplay, "Canceled by user\r\n", Color.Black, 10, true);
            }
            catch (Exception ex)
            {
                Eh.GlobalErrorHandler(ex);
            }
            finally
            {
                FrmCancelRunning.ToggleEnabled(false); //toggleEnabled(false);
            }
            SmartStepUtil.AddToRTB(rtbDisplay, "STATS: total items in list:" + counterTotalItemsInList + ", items updated:" + counterUpdated + "\r\n", Color.DarkGray, 8, false);
            SmartStepUtil.ScrollToBottom(rtbDisplay);
        }