コード例 #1
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);
        }
コード例 #2
0
ファイル: FrmDateFormat.cs プロジェクト: rwlamont/GLEON
        private void update()
        {
            //Update format
            if (checkCustom.Checked == true)
            {
                format = txtCustomFormat.Text;
            }
            else
            {
                format = getValue(comboFirst.Text);
                if (comboSecond.Text != "")
                {
                    format += " ";
                }
                format += getValue(comboSecond.Text);
                if (comboThird.Text != "")
                {
                    format += " ";
                }
                format += getValue(comboThird.Text);
                if (comboFourth.Text != "")
                {
                    format += " ";
                }
                format += getValue(comboFourth.Text);
            }
            DateTime ConvertedDate;

            input = input.Replace('/', ' ');
            input = input.Replace('-', ' ');
            if (DateTime.TryParseExact(input, format, null, DateTimeStyles.None, out ConvertedDate))
            {
                string output = ConvertedDate.ToString("yyyy-MM-dd HH:mm");
                lblOut.Text      = output;
                lblOut.ForeColor = Color.Green;
                validFormat      = true;
            }
            else
            {
                lblOut.Text      = "Invalid format. Please reselect fields above or enter custom format below.";
                validFormat      = false;
                lblOut.ForeColor = Color.Red;
            }
        }
コード例 #3
0
        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());
            }
        }