public static Dictionary<string, string> GetDynamicFieldControlsProperties(string xml)
        {
            Dictionary<string, string> dicResult = new Dictionary<string, string>();

            DynamicFieldsSerialize serialize = new DynamicFieldsSerialize();
            DynamicFieldsAggregator aggregator = serialize.DeserializeObject(xml);

            foreach (var control in aggregator.Controls)
            {
                PropertyInfo propertyInfo = control.GetType().GetProperty(GetPropertyNameFromControl(control));
                if (propertyInfo != null && propertyInfo.GetValue(control, null) != null)
                {
                    string value = string.Empty;

                    if (control is DynamicDatePickerXml)
                    {
                        value = DateTime.Parse(propertyInfo.GetValue(control, null).ToString()).ToShortDateString();
                    }
                    else
                    {
                        value = propertyInfo.GetValue(control, null).ToString();
                    }

                    if (!string.IsNullOrEmpty(value))
                        dicResult.Add(control.Label.Text, value);
                }
            }

            return dicResult;
        }
        public static DynamicFieldsAggregator GetAggregatorFromXml(string Xml)
        {
            DynamicFieldsSerialize serializer = new DynamicFieldsSerialize();
            DynamicFieldsAggregator aggregator = serializer.DeserializeObject(Xml);

            return aggregator;
        }
        /// <summary>
        /// Receives an DynamicFieldsAggregator and serialize it creating a Xml String
        /// </summary>
        public static string CreateXmlFromField(DynamicFieldsAggregator aggregator)
        {
            DynamicFieldsSerialize serializer = new DynamicFieldsSerialize();

            return serializer.SerializeObject(aggregator);
        }
        public void DoStuff(object sender, EventArgs e)
        {
            bool mustEnter = true;
            if (_targetControl is DynamicTextBox)
            {
                if (!string.IsNullOrEmpty(((DynamicTextBox)_targetControl).Text))
                    mustEnter = false;
            }
            else if (_targetControl is DynamicCountableTextBox)
            {
                if (!string.IsNullOrEmpty(((DynamicCountableTextBox)_targetControl).Text))
                    mustEnter = false;
            }
            else if (_targetControl is DynamicDropDownList)
            {
                if (((DynamicDropDownList)_targetControl).SelectedIndex != 0)
                    mustEnter = false;
            }

            if (mustEnter)
            {
                switch (_type)
                {
                    case Globals.CallEntry.AutoFillType.JobCity:

                        using (JobModel model = new JobModel())
                        {
                            CS_LocationInfo locationInfo = model.GetLocationInfoByJobId(Convert.ToInt32(_filterId));
                            if (null != locationInfo && null != locationInfo.CS_City)
                            {
                                if (_targetControl is DynamicTextBox)
                                    ((DynamicTextBox)_targetControl).Text = locationInfo.CS_City.Name;
                                else if (_targetControl is DynamicCountableTextBox)
                                    ((DynamicCountableTextBox)_targetControl).Text = locationInfo.CS_City.Name;
                                else if (_targetControl is DynamicDropDownList)
                                {
                                    if (null != ((DynamicDropDownList)_targetControl).Items.FindByValue(locationInfo.CityID.ToString()))
                                        ((DynamicDropDownList)_targetControl).SelectedValue = locationInfo.CityID.ToString();
                                }
                            }
                        }

                        break;

                    case Globals.CallEntry.AutoFillType.JobState:

                        using (JobModel model = new JobModel())
                        {
                            CS_LocationInfo locationInfo = model.GetLocationInfoByJobId(Convert.ToInt32(_filterId));
                            if (null != locationInfo && null != locationInfo.CS_State)
                            {
                                if (_targetControl is DynamicTextBox)
                                    ((DynamicTextBox)_targetControl).Text = locationInfo.CS_State.Name;
                                else if (_targetControl is DynamicCountableTextBox)
                                    ((DynamicCountableTextBox)_targetControl).Text = locationInfo.CS_State.Name;
                                else if (_targetControl is DynamicDropDownList)
                                {
                                    if (null != ((DynamicDropDownList)_targetControl).Items.FindByValue(locationInfo.StateID.ToString()))
                                        ((DynamicDropDownList)_targetControl).SelectedValue = locationInfo.StateID.ToString();

                                    if (null != ((DynamicDropDownList)_targetControl)._cascadeExtender)
                                        ((DynamicDropDownList)_targetControl)._cascadeExtender.DoStuff(null, null);
                                }
                            }
                        }

                        break;

                    case Globals.CallEntry.AutoFillType.JobCountry:

                        using (JobModel model = new JobModel())
                        {
                            CS_LocationInfo locationInfo = model.GetLocationInfoByJobId(Convert.ToInt32(_filterId));
                            if (null != locationInfo && null != locationInfo.CS_Country)
                            {
                                if (_targetControl is DynamicTextBox)
                                    ((DynamicTextBox)_targetControl).Text = locationInfo.CS_Country.Name;
                                else if (_targetControl is DynamicCountableTextBox)
                                    ((DynamicCountableTextBox)_targetControl).Text = locationInfo.CS_Country.Name;
                                else if (_targetControl is DynamicDropDownList)
                                {
                                    if (null != ((DynamicDropDownList)_targetControl).Items.FindByValue(locationInfo.CountryID.ToString()))
                                        ((DynamicDropDownList)_targetControl).SelectedValue = locationInfo.CountryID.ToString();

                                    if (null != ((DynamicDropDownList)_targetControl)._cascadeExtender)
                                        ((DynamicDropDownList)_targetControl)._cascadeExtender.DoStuff(null, null);
                                }
                            }
                        }

                        break;

                    case Globals.CallEntry.AutoFillType.PreviousCallType:

                        using (CallLogModel model = new CallLogModel())
                        {
                            CS_CallLog callLog = model.GetLastCallEntryByFilter(Convert.ToInt32(_filterId), string.Empty);

                            if (null != callLog && !string.IsNullOrEmpty(callLog.CS_CallType.Description) && !string.IsNullOrEmpty(callLog.Xml))
                            {
                                DynamicFieldsSerialize serializer = new DynamicFieldsSerialize();
                                DynamicFieldsAggregator aggregator = serializer.DeserializeObject(callLog.Xml);

                                DynamicControls control = aggregator.Controls.Find(delegate(DynamicControls match) { return match.Name == _conditionalControlName; });

                                ((DynamicTextBox)_targetControl).Text = ((DynamicTextBoxXml)control).Text;

                            }
                        }

                        break;

                    default:
                        break;
                }
            }
        }
Ejemplo n.º 5
0
        public IList<int> GetSelectedCustomerSpecificInfoType(string xml)
        {
            DynamicFieldsSerialize serialize = new DynamicFieldsSerialize();
            DynamicFieldsAggregator aggregator = serialize.DeserializeObject(xml);
            List<int> returnList = new List<int>();

            for (int i = 0; i < aggregator.Controls.Count; i++)
            {
                returnList.Add(aggregator.Controls[i].CustomerSpecificInfoTypeID);
            }

            return returnList;
        }
Ejemplo n.º 6
0
 private string GetXmlFromAggregator(DynamicFieldsAggregator aggregator)
 {
     DynamicFieldsSerialize serializer = new DynamicFieldsSerialize();
     return serializer.SerializeObject(aggregator);
 }