protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            string textToConvert = TextToConvert.Get(context);

            if (string.IsNullOrEmpty(textToConvert))
            {
                IsValid.Set(context, false);
                return;
            }

            bool isNumber = decimal.TryParse(textToConvert, out var convertedNumber);

            if (isNumber)
            {
                ConvertedNumber.Set(context, convertedNumber);
                IsValid.Set(context, true);
            }
            else
            {
                IsValid.Set(context, false);
            }
        }
Beispiel #2
0
        public int Execute()
        {
            try
            {
                string convertedText = TextToConvert.ToLower();

                if (ConvertIntoCaseComboIndex == 0)
                {
                    convertedText = TextToConvert.ToUpper();
                }

                else if (ConvertIntoCaseComboIndex == 2)
                {
                    TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

                    convertedText = textInfo.ToTitleCase(convertedText);
                }
                else if (ConvertIntoCaseComboIndex == 3)    // For Sentence Case
                {
                    // matches the first sentence of a string, as well as subsequent sentences
                    var regx = new Regex(@"(^[a-z])|\.\s+(.)", RegexOptions.ExplicitCapture);

                    // MatchEvaluator delegate defines replacement of setence starts to uppercase
                    convertedText = regx.Replace(convertedText, s => s.Value.ToUpper());
                }

                if (VariableStorage.CaseConvetedTextVar.ContainsKey(ConveredTextStoreVar))
                {
                    VariableStorage.CaseConvetedTextVar.Remove(ConveredTextStoreVar);
                }

                VariableStorage.CaseConvetedTextVar.Add(ConveredTextStoreVar, Tuple.Create(this.ID, convertedText));


                //if (testVar.TestVariable.ContainsKey(ConveredTextStoreVar))
                //{
                //    testVar.TestVariable.Remove(ConveredTextStoreVar);
                //}

                ////Application.Current.Resources["something"] = something;

                //testVar.TestVariable.Add(ConveredTextStoreVar, convertedText);



                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
        protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            string textToConvert = TextToConvert.Get(context);

            bool isValid = DateTime.TryParse(textToConvert, out var convertedDate);

            ConvertedDate.Set(context, convertedDate);
            IsValid.Set(context, isValid);
        }
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracer = executionContext.GetExtension <ITracingService>();

            try
            {
                string textToConvert = TextToConvert.Get(executionContext);

                DateTime convertedDate;
                bool     isValid = DateTime.TryParse(textToConvert, out convertedDate);

                ConvertedDate.Set(executionContext, convertedDate);
                IsValid.Set(executionContext, isValid);
            }
            catch (Exception ex)
            {
                tracer.Trace("Exception: {0}", ex.ToString());
            }
        }