Beispiel #1
0
 public static void OpenURLinDefaultBrowser(string url, RichTextBox rtbIfError)
 {
     try
     {
         SmartStepUtil.ClearRtbSafely(rtbIfError);
         if (string.IsNullOrEmpty(url))
         {
             SmartStepUtil.AddToRTB(rtbIfError, "Unable to browse because URL is blank.", StyleType.bodyOrange);
             return;
         }
         Process.Start(url);
     }
     catch (Exception ex)
     {
         SmartStepUtil.AddToRTB(rtbIfError, "Unable to browse to " + url + ", error:" + ex.Message, StyleType.bodyRed);
     }
 }
Beispiel #2
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);
        }