Exemplo n.º 1
0
 public int GetFieldValue(DateTimeField field)
 {
     if (ContainField(field))
         return int.Parse(_result.Groups[field.ToString()].Value);
     else
         return -1;
 }
Exemplo n.º 2
0
 public void DateTimeFieldTest()
 {
     DateTime val = new DateTime( 2009, 9, 4, 3, 44, 1 );
     DateTime newval = new DateTime(2009, 9, 4, 3, 44, 1);
     DateTimeField field = new DateTimeField(200, val);
     Assert.That(field.Obj, Is.EqualTo(val));
     Assert.That(field.getValue(), Is.EqualTo(val));
     Assert.That(field.Tag, Is.EqualTo(200));
     field.Obj = newval;
     Assert.That(field.Obj, Is.EqualTo(newval));
     Assert.That(field.ToString(), Is.EqualTo("20090904-03:44:01.000"));
 }
Exemplo n.º 3
0
        public static Field[] ToFieldArray(this IEnumerable<ICustomFieldDefinition> items,
            ICollection<Field> collection, string namePrefix, Action<Field, ICustomFieldDefinition> initialize = null)
        {
            var result = new List<Field>();
            foreach (var item in items)
            {
                var flags = item.IsRequired ? Required : NotRequired;
                var caption = ToLocalText(item.Title);
                var name = (namePrefix ?? "") + item.Name;
                Field field;

                switch (item.FieldType)
                {
                    case CustomFieldType.Boolean:
                        field = new BooleanField(collection, name, caption, 0, flags);
                        break;
                    case CustomFieldType.Date:
                        field = new DateTimeField(collection, name, caption, 0, flags) { DateTimeKind = DateTimeKind.Unspecified };
                        break;
                    case CustomFieldType.DateTime:
                        field = new DateTimeField(collection, name, caption, 0, flags) { DateTimeKind = DateTimeKind.Local };
                        break;
                    case CustomFieldType.Decimal:
                        field = new DecimalField(collection, name, caption, item.Size, flags);
                        break;
                    case CustomFieldType.Int32:
                        field = new Int32Field(collection, name, caption, item.Size, flags);
                        break;
                    case CustomFieldType.Int64:
                        field = new Int64Field(collection, name, caption, item.Size, flags);
                        break;
                    default:
                        field = new StringField(collection, name, caption, item.Size, flags);
                        break;
                }

                field.DefaultValue = item.DefaultValue.TrimToNull();
                result.Add(field);

                if (initialize != null)
                    initialize(field, item);
            }

            return result.ToArray();
        }
Exemplo n.º 4
0
 public void DefaultValTest()
 {
     BooleanField bf = new BooleanField(110);
     Assert.That(false, Is.EqualTo(bf.Obj));
     Assert.That(110, Is.EqualTo(bf.Tag));
     CharField cf = new CharField(300);
     Assert.That('\0', Is.EqualTo(cf.getValue()));
     Assert.That(300, Is.EqualTo(cf.Tag));
     DateTimeField dtf = new DateTimeField(3);
     Assert.That(3, Is.EqualTo(dtf.Tag));
     StringField sf = new StringField(32);
     Assert.That(32, Is.EqualTo(sf.Tag));
     Assert.That("", Is.EqualTo(sf.Obj));
     IntField ifld = new IntField(239);
     Assert.That(239, Is.EqualTo(ifld.Tag));
     Assert.That(0, Is.EqualTo(ifld.Obj));
     DecimalField df = new DecimalField(1);
     Assert.That(1, Is.EqualTo(df.Tag));
     Assert.That(new Decimal(0.0), Is.EqualTo(df.Obj));
 }
Exemplo n.º 5
0
 protected override string DateTimeToField(string datetime, DateTimeField field)
 {
     switch (field)
     {
         case DateTimeField.Year:
             return string.Concat("DATEPART(YYYY, ", datetime, ")");
         case DateTimeField.Month:
             return string.Concat("DATEPART(mm, ", datetime, ")");
         case DateTimeField.Day:
             return string.Concat("DATEPART(dd, ", datetime, ")");
         case DateTimeField.Hour:
             return string.Concat("DATEPART(hh, ", datetime, ")");
         case DateTimeField.Minute:
             return string.Concat("DATEPART(mi, ", datetime, ")");
         case DateTimeField.Second:
             return string.Concat("DATEPART(ss, ", datetime, ")");
         case DateTimeField.Week:
             return string.Concat("(DATEPART(w, ", datetime, ") - 1)");
         default:
             throw new ArgumentOutOfRangeException("field");
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initialisation de filtre
        /// </summary>
        protected void initFiltre()
        {
            // Postion et Taille par défaut
            int width_label    = 100;
            int height_label   = 25;
            int width_control  = 100;
            int height_control = 20;
            int TabIndex       = 0;


            var propertyListFilter = from i in Service.TypeEntity.GetProperties()
                                     where i.GetCustomAttribute(typeof(FilterAttribute)) != null
                                     orderby((FilterAttribute)i.GetCustomAttribute(typeof(FilterAttribute))).Ordre
                                     select i;


            // Insertion des critère de recherche par Type
            foreach (PropertyInfo propertyInfo in propertyListFilter)
            {
                ConfigProperty attributesOfProperty = new ConfigProperty(propertyInfo, this.ConfigEntity);

                // Utiliser le Largeur de la configuration s'il existe
                int item_width_control = width_control;
                if (attributesOfProperty.Filter?.WidthControl != 0)
                {
                    item_width_control = attributesOfProperty.Filter.WidthControl;
                }

                if (propertyInfo.PropertyType.Name == "String")
                {
                    StringField stringFiled = new StringField(
                        propertyInfo,
                        Orientation.Horizontal,
                        new Size(width_label, height_label),
                        new Size(item_width_control, height_control)
                        , this.ConfigEntity);
                    stringFiled.Name          = propertyInfo.Name;
                    stringFiled.TabIndex      = TabIndex++;
                    stringFiled.Text_Label    = attributesOfProperty.DisplayProperty.Titre;
                    stringFiled.FieldChanged += Filtre_TextBox_SelectedValueChanged;
                    MainContainer.Controls.Add(stringFiled);
                }
                if (propertyInfo.PropertyType.Name == "Int32")
                {
                    Int32Filed int32Filed = new Int32Filed(propertyInfo,
                                                           Orientation.Vertical,
                                                           new Size(width_label, height_label),
                                                           new Size(item_width_control, height_control), this.ConfigEntity
                                                           );
                    int32Filed.Name          = propertyInfo.Name;
                    int32Filed.TabIndex      = TabIndex++;
                    int32Filed.Text_Label    = attributesOfProperty.DisplayProperty.Titre;
                    int32Filed.FieldChanged += Filtre_TextBox_SelectedValueChanged;
                    MainContainer.Controls.Add(int32Filed);
                }
                if (propertyInfo.PropertyType.Name == "DateTime")
                {
                    DateTimeField dateTimeField = new DateTimeField(propertyInfo, Orientation.Vertical,
                                                                    new Size(width_label, height_label),
                                                                    new Size(item_width_control, height_control), this.ConfigEntity
                                                                    );
                    dateTimeField.Name       = propertyInfo.Name;
                    dateTimeField.TabIndex   = TabIndex++;
                    dateTimeField.Text_Label = attributesOfProperty.DisplayProperty.Titre;


                    dateTimeField.FieldChanged += Filtre_TextBox_SelectedValueChanged;
                    MainContainer.Controls.Add(dateTimeField);
                }

                //
                // Relation ManyToOne
                //
                if (attributesOfProperty.Relationship?.Relation != RelationshipAttribute.Relations.Empty &&
                    attributesOfProperty.Relationship?.Relation == RelationshipAttribute.Relations.ManyToOne)
                {
                    // La valeurs pardéfaut
                    Int64 default_value = 0;
                    if (ValeursFiltre != null && ValeursFiltre.Keys.Contains(propertyInfo.PropertyType.Name))
                    {
                        default_value = (Int64)ValeursFiltre[propertyInfo.PropertyType.Name];
                    }

                    ManyToOneField manyToOneField = new ManyToOneField(this.Service, propertyInfo,
                                                                       this.MainContainer,
                                                                       Orientation.Horizontal,
                                                                       new Size(width_label, height_label),
                                                                       new Size(item_width_control, height_control),
                                                                       default_value, ConfigEntity
                                                                       );
                    manyToOneField.Name          = propertyInfo.Name;
                    manyToOneField.TabIndex      = TabIndex++;
                    manyToOneField.Text_Label    = attributesOfProperty.DisplayProperty.Titre;
                    manyToOneField.FieldChanged += Filtre_ComboBox_SelectedValueChanged;
                    MainContainer.Controls.Add(manyToOneField);


                    //
                    // Remplissage de ComboBox
                    //
                    //Type ServicesEntityEnRelationType = typeof(BaseRepository<>).MakeGenericType(propertyInfo.PropertyType);
                    //IBaseRepository ServicesEntity = (IBaseRepository)Activator.CreateInstance(ServicesEntityEnRelationType);
                    //List<object> ls = ServicesEntity.GetAllDetached();
                    //manyToOneField.ValueMember = "Id";
                    //manyToOneField.DisplayMember = AffichagePropriete.DisplayMember;
                    //manyToOneField.DataSource = ls;
                    //if (AffichagePropriete.isValeurFiltreVide) manyToOneField.SelectedIndex = -1;

                    //// Affectation de valeur initial
                    //if (this.ValeursFiltre != null && this.ValeursFiltre.ContainsKey(propertyInfo.Name))
                    //{
                    //    manyToOneField.CreateControl();
                    //    manyToOneField.Value = Convert.ToInt64(this.ValeursFiltre[propertyInfo.Name]);
                    //}
                }



                //if (MainContainer.Controls.Count > 0)
                //{
                //    int max_h = this.MainContainer.Controls.Cast<Control>().Max(c => c.Size.Height);
                //    this.MainContainer.Size = new Size(this.MainContainer.Size.Width, max_h);
                //}
            } // End For
        }
Exemplo n.º 7
0
 public static void AttachToDateTimeField(this Date date, DateTimeField field)
 {
     date.Item  = field.InnerField.Item;
     date.Field = field.Id.ToString();
 }
Exemplo n.º 8
0
 protected override string DateTimeToField(string datetime, DateTimeField field)
 {
     switch (field)
     {
         case DateTimeField.Year:
             return string.Concat("EXTRACT(YEAR FROM ", datetime, ")");
         case DateTimeField.Month:
             return string.Concat("EXTRACT(MONTH FROM ", datetime, ")");
         case DateTimeField.Day:
             return string.Concat("EXTRACT(DAY FROM ", datetime, ")");
         case DateTimeField.Hour:
             return string.Concat("EXTRACT(HOUR FROM ", datetime, ")");
         case DateTimeField.Minute:
             return string.Concat("EXTRACT(MINUTE FROM ", datetime, ")");
         case DateTimeField.Second:
             return string.Concat("EXTRACT(SECOND FROM ", datetime, ")");
         case DateTimeField.Week:
         default:
             throw new ArgumentOutOfRangeException("field");
     }
 }
Exemplo n.º 9
0
 public IEdmTypeReference Visit(DateTimeField field)
 {
     return(CreatePrimitive(EdmPrimitiveTypeKind.DateTimeOffset, field));
 }
Exemplo n.º 10
0
        public static JsValue Show(JavaScriptUi ui, string title, JsValue fields, JsValue validate)
        {
            if (ui == null)
            {
                throw new ArgumentNullException(nameof(ui));
            }

            using (var form = new UiForm())
            {
                if (String.IsNullOrEmpty(title))
                {
                    form.Text = ui.Owner.Text;
                }
                else
                {
                    form.Text = title;
                }

                form.Icon = ui.Owner.Icon;

                if (!fields.IsArray())
                {
                    throw new JavaScriptException("fields must be an array");
                }

                var controls = new List <Field>();

                fields.AsArray().ForEach((index, value) =>
                {
                    var container = form._container;

                    while (container.RowStyles.Count <= index)
                    {
                        container.RowCount++;
                        container.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                    }

                    var field          = value.AsObject();
                    string name        = field.Get("name").ConvertToString();
                    string label       = field.Get("label").ConvertToString();
                    var type           = ParseType(field.Get("type").ConvertToString());
                    ArrayInstance list = null;
                    if (field.HasOwnProperty("list"))
                    {
                        list = field.Get("list").AsArray();
                    }

                    Field control;
                    switch (type)
                    {
                    case FieldType.Text:
                        control = new TextField(name, label);
                        break;

                    case FieldType.CheckBox:
                        control = new CheckBoxField(name, label);
                        break;

                    case FieldType.Numeric:
                        control = new NumericField(name, label);
                        break;

                    case FieldType.Date:
                        control = new DateField(name, label);
                        break;

                    case FieldType.DateTime:
                        control = new DateTimeField(name, label);
                        break;

                    case FieldType.ComboBox:
                        control = new ComboBoxField(name, label, list);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    controls.Add(control);

                    if (field.HasOwnProperty("value"))
                    {
                        control.SetValue(field.Get("value"));
                    }

                    if (control.ShowLabel)
                    {
                        var labelControl = new Label
                        {
                            AutoSize  = true,
                            Text      = label,
                            Dock      = DockStyle.Fill,
                            TextAlign = ContentAlignment.MiddleLeft
                        };

                        container.SetRow(labelControl, index);
                        container.Controls.Add(labelControl);
                    }

                    control.Control.Dock     = DockStyle.Fill;
                    control.Control.AutoSize = true;
                    container.SetRow(control.Control, index);
                    container.SetColumn(control.Control, 1);
                    container.Controls.Add(control.Control);
                });

                form._acceptButton.Click += (s, e) =>
                {
                    try
                    {
                        if (validate.IsObject())
                        {
                            var values = BuildValues(ui.Engine, controls);
                            var result = validate.Invoke(values);
                            if (!result.ConvertToBoolean().GetValueOrDefault())
                            {
                                return;
                            }
                        }
                        form.DialogResult = DialogResult.OK;
                    }
                    catch (JavaScriptException exception)
                    {
                        JintDebugger.ExceptionForm.Show(form, exception);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(
                            form,
                            new StringBuilder()
                            .AppendLine("An exception occurred while executing the script:")
                            .AppendLine()
                            .Append(exception.Message).Append(" (").Append(exception.GetType().FullName).AppendLine(")")
                            .AppendLine()
                            .AppendLine(exception.StackTrace)
                            .ToString(),
                            "Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error
                            );
                    }
                };

                var owner = ui.Owner;

                using (ui.PushOwner(form))
                {
                    if (form.ShowDialog(owner) == DialogResult.OK)
                    {
                        return(BuildValues(ui.Engine, controls));
                    }
                }
            }

            return(JsValue.Null);
        }
Exemplo n.º 11
0
        protected void AddDynamicControls(ContentChannel channel)
        {
            // Remove all columns
            gContentChannelItems.Columns.Clear();
            phAttributeFilters.Controls.Clear();

            if (channel != null)
            {
                // Add Reorder column
                var reorderField = new ReorderField();
                gContentChannelItems.Columns.Add(reorderField);

                // Add Title column
                var titleField = new BoundField();
                titleField.DataField      = "Title";
                titleField.HeaderText     = "Title";
                titleField.SortExpression = "Title";
                gContentChannelItems.Columns.Add(titleField);

                // Add Attribute columns
                int    entityTypeId  = EntityTypeCache.Get(typeof(Rock.Model.ContentChannelItem)).Id;
                string channelId     = channel.Id.ToString();
                string channelTypeId = channel.ContentChannelTypeId.ToString();
                foreach (var attribute in AvailableAttributes)
                {
                    var control = attribute.FieldType.Field.FilterControl(attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter);
                    if (control != null)
                    {
                        if (control is IRockControl)
                        {
                            var rockControl = ( IRockControl )control;
                            rockControl.Label = attribute.Name;
                            rockControl.Help  = attribute.Description;
                            phAttributeFilters.Controls.Add(control);
                        }
                        else
                        {
                            var wrapper = new RockControlWrapper();
                            wrapper.ID    = control.ID + "_wrapper";
                            wrapper.Label = attribute.Name;
                            wrapper.Controls.Add(control);
                            phAttributeFilters.Controls.Add(wrapper);
                        }

                        string savedValue = gfFilter.GetUserPreference(MakeKeyUniqueToChannel(channel.Id, attribute.Key));
                        if (!string.IsNullOrWhiteSpace(savedValue))
                        {
                            try
                            {
                                var values = JsonConvert.DeserializeObject <List <string> >(savedValue);
                                attribute.FieldType.Field.SetFilterValues(control, attribute.QualifierValues, values);
                            }
                            catch
                            {
                                // intentionally ignore
                            }
                        }
                    }

                    string dataFieldExpression = attribute.Key;
                    bool   columnExists        = gContentChannelItems.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField   = dataFieldExpression;
                        boundField.AttributeId = attribute.Id;
                        boundField.HeaderText  = attribute.Name;
                        boundField.ItemStyle.HorizontalAlign = attribute.FieldType.Field.AlignValue;
                        gContentChannelItems.Columns.Add(boundField);
                    }
                }

                if (channel.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates)
                {
                    RockBoundField startDateTimeField;
                    RockBoundField expireDateTimeField;
                    if (channel.ContentChannelType.IncludeTime)
                    {
                        startDateTimeField  = new DateTimeField();
                        expireDateTimeField = new DateTimeField();
                    }
                    else
                    {
                        startDateTimeField  = new DateField();
                        expireDateTimeField = new DateField();
                    }

                    startDateTimeField.DataField      = "StartDateTime";
                    startDateTimeField.HeaderText     = channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Date";
                    startDateTimeField.SortExpression = "StartDateTime";
                    gContentChannelItems.Columns.Add(startDateTimeField);

                    expireDateTimeField.DataField      = "ExpireDateTime";
                    expireDateTimeField.HeaderText     = "Expire";
                    expireDateTimeField.SortExpression = "ExpireDateTime";
                    if (channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange)
                    {
                        gContentChannelItems.Columns.Add(expireDateTimeField);
                    }
                }

                if (!channel.ContentChannelType.DisablePriority)
                {
                    // Priority column
                    var priorityField = new BoundField();
                    priorityField.DataField                 = "Priority";
                    priorityField.HeaderText                = "Priority";
                    priorityField.SortExpression            = "Priority";
                    priorityField.DataFormatString          = "{0:N0}";
                    priorityField.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                    gContentChannelItems.Columns.Add(priorityField);
                }

                // Status column
                if (channel.RequiresApproval)
                {
                    var statusField = new BoundField();
                    gContentChannelItems.Columns.Add(statusField);
                    statusField.DataField      = "Status";
                    statusField.HeaderText     = "Status";
                    statusField.SortExpression = "Status";
                    statusField.HtmlEncode     = false;
                }

                // Add occurrences Count column
                var occurrencesField = new BoolField();
                occurrencesField.DataField  = "Occurrences";
                occurrencesField.HeaderText = "Event Occurrences";
                gContentChannelItems.Columns.Add(occurrencesField);

                // Add Created By column
                var createdByPersonNameField = new BoundField();
                createdByPersonNameField.DataField  = "CreatedByPersonName";
                createdByPersonNameField.HeaderText = "Created By";
                createdByPersonNameField.HtmlEncode = false;
                gContentChannelItems.Columns.Add(createdByPersonNameField);

                // Add Tag Field
                if (channel.IsTaggingEnabled)
                {
                    var tagField = new BoundField();
                    gContentChannelItems.Columns.Add(tagField);
                    tagField.DataField          = "Tags";
                    tagField.HeaderText         = "Tags";
                    tagField.ItemStyle.CssClass = "taglist";
                    tagField.HtmlEncode         = false;
                }

                bool canEditChannel = channel.IsAuthorized(Rock.Security.Authorization.EDIT, CurrentPerson);
                gContentChannelItems.Actions.ShowAdd = canEditChannel;
                gContentChannelItems.IsDeleteEnabled = canEditChannel;
                if (canEditChannel)
                {
                    var securityField = new SecurityField();
                    gContentChannelItems.Columns.Add(securityField);
                    securityField.TitleField   = "Title";
                    securityField.EntityTypeId = EntityTypeCache.Get(typeof(Rock.Model.ContentChannelItem)).Id;

                    var deleteField = new DeleteField();
                    gContentChannelItems.Columns.Add(deleteField);
                    deleteField.Click += gContentChannelItems_Delete;
                }
            }
        }
Exemplo n.º 12
0
        protected override void ConstructFields()
        {
            TableName = "TBL_TESTPERSON";
               StoreFlag = StoreFlag.LoadAndStore;

               m_fldName = new StringField()
               {
             Owner = this,
             FieldName = "PERSON_NAME",
             Required = true,
             Size = 50
               };

               m_fldSex = new StringField()
               {
             Owner = this,
             FieldName = "SEX",
             Required = true,
             Size = 1,
             DataEntryType = DataEntryType.DirectEntryOrLookupWithValidation,
             LookupType = LookupType.Dictionary
               };
               m_fldSex.LookupDictionary.AddRange(new string[]{"M,Male", "F,Female", "U,Unspecified"});

               m_fldRating = new IntField()
               {
             Owner = this,
             FieldName = "RATING",
             MinMaxChecking = true,
             MinValue = 0,
             MaxValue = 10
               };

               m_fldRegistered = new BoolField()
               {
             Owner = this,
             FieldName = "IS_REGISTERED",
             Required = true
               };

               m_fldDOB = new DateTimeField()
               {
             Owner = this,
             FieldName = "DOB"
               };

               m_fldSalary = new DecimalField()
               {
             Owner = this,
             FieldName = "PAYROLL_VOLUME",
             MinMaxChecking = true,
             MinValue = 0M,
             MaxValue = Decimal.MaxValue
               };

               //calculated field returns salary * 10 years
               m_fldDecadeSalary = new DecimalField()
               {
             Owner = this,
             FieldName = "DECADE_SALARY",
             StoreFlag = StoreFlag.None,
             DataEntryType = DataEntryType.None,
             Calculated = true,
             Formula = "850-10 +(::PAYROLL_VOLUME * 10)"
               };

               m_fldScore = new DoubleField()
               {
             Owner = this,
             FieldName = "SCORE"
               };

               m_fldMovieNames = new ListField<string>()
               {
             Owner = this,
             FieldName = "MOVIES",
             Required = true
               };

               //ths is business logic-driven computed column for GUI
               m_fldBusinessCode = new StringField()
               {
             Owner = this,
             FieldName = "BUSINESS_CODE",
             StoreFlag = StoreFlag.None,
             DataEntryType = DataEntryType.None
               };
        }
        protected void AddColumns(ContentChannel channel)
        {
            // Remove all columns
            gContentChannelItems.Columns.Clear();

            if (channel != null)
            {
                // Add Title column
                var titleField = new BoundField();
                titleField.DataField      = "Title";
                titleField.HeaderText     = "Title";
                titleField.SortExpression = "Title";
                gContentChannelItems.Columns.Add(titleField);

                // Add Attribute columns
                int    entityTypeId  = EntityTypeCache.Read(typeof(Rock.Model.ContentChannelItem)).Id;
                string channelId     = channel.Id.ToString();
                string channelTypeId = channel.ContentChannelTypeId.ToString();
                foreach (var attribute in new AttributeService(new RockContext()).Queryable()
                         .Where(a =>
                                a.EntityTypeId == entityTypeId &&
                                a.IsGridColumn && ((
                                                       a.EntityTypeQualifierColumn.Equals("ContentChannelTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                       a.EntityTypeQualifierValue.Equals(channelTypeId)
                                                       ) || (
                                                       a.EntityTypeQualifierColumn.Equals("ContentChannelId", StringComparison.OrdinalIgnoreCase) &&
                                                       a.EntityTypeQualifierValue.Equals(channelId)
                                                       )))
                         .OrderBy(a => a.Order)
                         .ThenBy(a => a.Name))
                {
                    string dataFieldExpression = attribute.Key;
                    bool   columnExists        = gContentChannelItems.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField      = dataFieldExpression;
                        boundField.HeaderText     = attribute.Name;
                        boundField.SortExpression = string.Empty;

                        var attributeCache = Rock.Web.Cache.AttributeCache.Read(attribute.Id);
                        if (attributeCache != null)
                        {
                            boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                        }

                        gContentChannelItems.Columns.Add(boundField);
                    }
                }

                // Add Start column
                var startField = new DateTimeField();
                startField.DataField      = "StartDateTime";
                startField.HeaderText     = channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Date";
                startField.SortExpression = "StartDateTime";
                gContentChannelItems.Columns.Add(startField);

                // Expire column
                if (channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange)
                {
                    var expireField = new DateTimeField();
                    expireField.DataField      = "ExpireDateTime";
                    expireField.HeaderText     = "Expire";
                    expireField.SortExpression = "ExpireDateTime";
                    gContentChannelItems.Columns.Add(expireField);
                }

                // Priority column
                var priorityField = new BoundField();
                priorityField.DataField                 = "Priority";
                priorityField.HeaderText                = "Priority";
                priorityField.SortExpression            = "Priority";
                priorityField.DataFormatString          = "{0:N0}";
                priorityField.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                gContentChannelItems.Columns.Add(priorityField);

                // Status column
                if (channel.RequiresApproval)
                {
                    var statusField = new BoundField();
                    gContentChannelItems.Columns.Add(statusField);
                    statusField.DataField      = "Status";
                    statusField.HeaderText     = "Status";
                    statusField.SortExpression = "Status";
                    statusField.HtmlEncode     = false;
                }

                bool canEditChannel = channel.IsAuthorized(Rock.Security.Authorization.EDIT, CurrentPerson);
                gContentChannelItems.Actions.ShowAdd = canEditChannel;
                gContentChannelItems.IsDeleteEnabled = canEditChannel;
                if (canEditChannel)
                {
                    var deleteField = new DeleteField();
                    gContentChannelItems.Columns.Add(deleteField);
                    deleteField.Click += gContentChannelItems_Delete;
                }
            }
        }
Exemplo n.º 14
0
 public static ValidationError InvalidDateRangeError(Row row, DateTimeField start, DateTimeField finish)
 {
     return(new ValidationError("InvalidDateRange", start.Name + "," + finish.Name, Texts.Validation.FieldInvalidDateRange, start.Title, finish.Title));
 }
Exemplo n.º 15
0
 public static ValidationError InvalidDateRangeError(Row row, DateTimeField start, DateTimeField finish)
 {
     return(new ValidationError("InvalidDateRange", start.Name + "," + finish.Name, "{0} için girilen tarih {1}'den önce olamaz!", start.Title, finish.Title));
 }
Exemplo n.º 16
0
        protected virtual void ExecuteDelete()
        {
            var isActiveDeletedRow = Row as IIsActiveDeletedRow;
            var isDeletedRow       = Row as IIsDeletedRow;
            var deleteLogRow       = Row as IDeleteLogRow;
            var idField            = Row.IdField;
            var id = idField.ConvertValue(Request.EntityId, CultureInfo.InvariantCulture);

            if (isActiveDeletedRow == null && isDeletedRow == null && deleteLogRow == null)
            {
                var delete = new SqlDelete(Row.Table)
                             .WhereEqual(idField, id);

                InvokeDeleteAction(() =>
                {
                    if (delete.Execute(Connection) != 1)
                    {
                        throw DataValidation.EntityNotFoundError(Row, id, Localizer);
                    }
                });
            }
            else
            {
                if (isDeletedRow != null || isActiveDeletedRow != null)
                {
                    var update = new SqlUpdate(Row.Table)
                                 .WhereEqual(idField, id)
                                 .Where(ServiceQueryHelper.GetNotDeletedCriteria(Row));

                    if (isActiveDeletedRow != null)
                    {
                        update.Set(isActiveDeletedRow.IsActiveField, -1);
                    }
                    else if (isDeletedRow != null)
                    {
                        update.Set(isDeletedRow.IsDeletedField, true);
                    }

                    if (deleteLogRow != null)
                    {
                        update.Set(deleteLogRow.DeleteDateField, DateTimeField.ToDateTimeKind(DateTime.Now,
                                                                                              deleteLogRow.DeleteDateField.DateTimeKind))
                        .Set(deleteLogRow.DeleteUserIdField, User?.GetIdentifier().TryParseID());
                    }
                    else if (Row is IUpdateLogRow updateLogRow)
                    {
                        update.Set(updateLogRow.UpdateDateField, DateTimeField.ToDateTimeKind(DateTime.Now,
                                                                                              updateLogRow.UpdateDateField.DateTimeKind))
                        .Set(updateLogRow.UpdateUserIdField, User?.GetIdentifier().TryParseID());
                    }

                    InvokeDeleteAction(() =>
                    {
                        if (update.Execute(Connection) != 1)
                        {
                            throw DataValidation.EntityNotFoundError(Row, id, Localizer);
                        }
                    });
                }
                else //if (deleteLogRow != null)
                {
                    var update = new SqlUpdate(Row.Table)
                                 .Set(deleteLogRow.DeleteDateField, DateTimeField.ToDateTimeKind(DateTime.Now,
                                                                                                 deleteLogRow.DeleteDateField.DateTimeKind))
                                 .Set(deleteLogRow.DeleteUserIdField, User?.GetIdentifier().TryParseID())
                                 .WhereEqual(idField, id)
                                 .Where(new Criteria(deleteLogRow.DeleteUserIdField).IsNull());

                    InvokeDeleteAction(() =>
                    {
                        if (update.Execute(Connection) != 1)
                        {
                            throw DataValidation.EntityNotFoundError(Row, id, Localizer);
                        }
                    });
                }
            }

            InvalidateCacheOnCommit();
        }
Exemplo n.º 17
0
		protected IStorageDateTimeField CreateEmptyDateTimeFieldObject(DateTimeField field)
		{
			var storageService = service.StorageService;
			return (IStorageDateTimeField)storageService.GetObjectFactory().CreateEmptyFieldObject(field.GetType());
		}
Exemplo n.º 18
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 internal DateTimeFieldHelper(DateTimeField fieldEntity)
 {
     _field = fieldEntity;
 }
Exemplo n.º 19
0
        public void Should_instantiate_field()
        {
            var sut = new DateTimeField(1, "my-datetime", Partitioning.Invariant);

            Assert.Equal("my-datetime", sut.Name);
        }
Exemplo n.º 20
0
        protected override void ConstructFields()
        {
            TableName = "TBL_PATIENT";

            m_fldID = new StringField()
            {
                Owner       = this,
                FieldName   = "PATIENT_ID",
                Description = "ID",
                Size        = 12,
                Required    = true,
                KeyField    = true
            };

            m_fldFirstName = new StringField()
            {
                Owner       = this,
                FieldName   = "FIRST_NAME",
                Description = "First Name",
                Size        = 50,
                Required    = true
            };

            m_fldLastName = new StringField()
            {
                Owner       = this,
                FieldName   = "LAST_NAME",
                Description = "Last Name",
                Size        = 50,
                Required    = true
            };

            m_fldContactPhone = new StringField()
            {
                Owner           = this,
                FieldName       = "PHONE_CONTACT",
                Description     = "Contact Phone#",
                DataEntryFormat = DataEntryFormat.Phone,
                Size            = 25
            };

            m_fldDOB = new DateTimeField()
            {
                Owner       = this,
                FieldName   = "DOB",
                Description = "Date of Birth",
                Required    = true
            };

            m_fldAdmissionDate = new DateTimeField()
            {
                Owner       = this,
                FieldName   = "ADM_DATE",
                Description = "Admission Date"
            };

            m_fldMonthlyCost = new DecimalField()
            {
                Owner         = this,
                FieldName     = "MONTHLY_COST",
                Description   = "Monthly Cost",
                MinValue      = 0,
                DisplayFormat = "C"
            };

            m_fldClassification = new StringField()
            {
                Owner         = this,
                FieldName     = "ATTITUDE_CLASSIFICATION",
                Description   = "Classification",
                Required      = true,
                Size          = 3,
                LookupType    = LookupType.Dictionary,
                DataEntryType = DataEntryType.Lookup,

                HasDefaultValue = true,
                DefaultValue    = "BUD"
            };

            m_fldClassification.LookupDictionary.Add("MRX, Marxist",
                                                     "CAP, Capitalist",
                                                     "NEH, Nehilist",
                                                     "BUD, Buddhist");

            m_fldReligious = new BoolField()
            {
                Owner           = this,
                FieldName       = "IS_RELIGIOUS",
                Description     = "Religious",
                Required        = true,
                DefaultValue    = false,
                HasDefaultValue = true
            };
        }
Exemplo n.º 21
0
        /// <summary>
        /// Obtient les valeurs du filtre
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, object> CritereRechercheFiltre()
        {
            // Application de filtre
            Dictionary <string, object> RechercheInfos = new Dictionary <string, object>();


            var PropertyListFilter = from i in Service.TypeEntity.GetProperties()
                                     where i.GetCustomAttribute(typeof(FilterAttribute)) != null
                                     orderby((FilterAttribute)i.GetCustomAttribute(typeof(FilterAttribute))).Ordre
                                     select i;


            foreach (PropertyInfo propertyInfo in PropertyListFilter)
            {
                switch (propertyInfo.PropertyType.Name)
                {
                case "String":
                {
                    StringField stringFiled = (StringField)this.groupBoxFiltrage.Controls.Find(propertyInfo.Name, true).First();
                    if (stringFiled.Value != String.Empty)
                    {
                        RechercheInfos[propertyInfo.Name] = stringFiled.Value;
                    }
                }
                break;

                case "Int32":
                {
                    Int32Filed int32Filed = (Int32Filed)this.groupBoxFiltrage.Controls.Find(propertyInfo.Name, true).First();
                    if ((int)int32Filed.Value != 0)
                    {
                        RechercheInfos[propertyInfo.Name] = int32Filed.Value;
                    }
                }
                break;

                case "DateTime":
                {
                    DateTimeField dateTimeField = (DateTimeField)this.groupBoxFiltrage.Controls.Find(propertyInfo.Name, true).First();
                    if ((DateTime)dateTimeField.Value != DateTime.MinValue)
                    {
                        RechercheInfos[propertyInfo.Name] = dateTimeField.Value;
                    }
                }
                break;

                default:     // Dans le cas d'un objet de type BaseEntity
                {
                    ConfigProperty ConfigProperty = new ConfigProperty(propertyInfo, this.ConfigEntity);

                    if (ConfigProperty.Relationship.Relation == RelationshipAttribute.Relations.ManyToOne)
                    {
                        // [bug] groupBoxFiltrage doit être MainContainner
                        ManyToOneField ComboBoxEntity = (ManyToOneField)this.groupBoxFiltrage.Controls.Find(propertyInfo.Name, true).First();
                        BaseEntity     obj            = (BaseEntity)ComboBoxEntity.SelectedItem;
                        if (obj != null && Convert.ToInt32(obj.Id) != 0)
                        {
                            RechercheInfos[propertyInfo.Name] = obj.Id;
                        }
                    }
                }
                break;
                }
            }

            return(RechercheInfos);
        }
Exemplo n.º 22
0
 /// <summary> 解释 DateTime 中的数据
 /// </summary>
 /// <param name="datetime">方法调用者</param>
 protected virtual string DateTimeToField(string datetime, DateTimeField field)
 {
     throw new NotImplementedException("不支持当前操作,或请重新实现 MethodToMonthr");
 }
Exemplo n.º 23
0
 public object GetTestValue(PropertyInfo propertyInfo)
 {
     return(DateTimeField.GetTestValue());
 }
Exemplo n.º 24
0
        protected virtual void ExecuteDelete()
        {
            var isDeletedRow = Row as IIsActiveDeletedRow;
            var deleteLogRow = Row as IDeleteLogRow;
            var idField      = (Field)Row.IdField;
            var id           = idField.ConvertValue(Request.EntityId, CultureInfo.InvariantCulture);

            if (isDeletedRow == null && deleteLogRow == null)
            {
                if (new SqlDelete(Row.Table)
                    .WhereEqual(idField, id)
                    .Execute(Connection) != 1)
                {
                    throw DataValidation.EntityNotFoundError(Row, id);
                }
            }
            else
            {
                if (isDeletedRow != null)
                {
                    var updateLogRow = Row as IUpdateLogRow;

                    var update = new SqlUpdate(Row.Table)
                                 .Set(isDeletedRow.IsActiveField, -1)
                                 .WhereEqual(idField, id)
                                 .Where(new Criteria(isDeletedRow.IsActiveField) >= 0);

                    if (deleteLogRow != null)
                    {
                        update.Set(deleteLogRow.DeleteDateField, DateTimeField.ToDateTimeKind(DateTime.Now,
                                                                                              deleteLogRow.DeleteDateField.DateTimeKind))
                        .Set((Field)deleteLogRow.DeleteUserIdField, Authorization.UserId.TryParseID());
                    }
                    else if (updateLogRow != null)
                    {
                        update.Set(updateLogRow.UpdateDateField, DateTimeField.ToDateTimeKind(DateTime.Now,
                                                                                              updateLogRow.UpdateDateField.DateTimeKind))
                        .Set((Field)updateLogRow.UpdateUserIdField, Authorization.UserId.TryParseID());
                    }

                    if (update.Execute(Connection) != 1)
                    {
                        throw DataValidation.EntityNotFoundError(Row, id);
                    }
                }
                else //if (deleteLogRow != null)
                {
                    if (new SqlUpdate(Row.Table)
                        .Set(deleteLogRow.DeleteDateField, DateTimeField.ToDateTimeKind(DateTime.Now,
                                                                                        deleteLogRow.DeleteDateField.DateTimeKind))
                        .Set((Field)deleteLogRow.DeleteUserIdField, Authorization.UserId.TryParseID())
                        .WhereEqual(idField, id)
                        .Where(new Criteria((Field)deleteLogRow.DeleteUserIdField).IsNull())
                        .Execute(Connection) != 1)
                    {
                        throw DataValidation.EntityNotFoundError(Row, id);
                    }
                }
            }

            InvalidateCacheOnCommit();
        }
Exemplo n.º 25
0
        internal static BaseField CreateField(FieldType type)
        {
            BaseField field = null;

            switch (type)
            {
            case FieldType.ObjectKey:
                field = new ObjectKeyField();
                break;

            case FieldType.BigInt:
                field = new BigIntField();
                break;

            case FieldType.Bool:
                field = new BoolField();
                break;

            case FieldType.Date:
                field = new DateField();
                break;

            case FieldType.DateTime:
                field = new DateTimeField();
                break;

            case FieldType.Decimal:
                field = new DecimalField();
                break;

            case FieldType.Image:
                field = new ImageField();
                break;

            case FieldType.Integer:
                field = new IntegerField();
                break;

            case FieldType.LongText:
                field = new LongTextField();
                break;

            case FieldType.Password:
                field = new PasswordField();
                break;

            case FieldType.MonataryAmount:
                field = new DecimalField();
                break;

            case FieldType.Html:
                field = new HtmlField();
                break;

            case FieldType.Xml:
                field = new XmlField();
                break;

            case FieldType.Json:
                field = new JsonField();
                break;

            case FieldType.Email:
                field = new EmailField();
                break;

            case FieldType.Phone:
                field = new PhoneField();
                break;

            case FieldType.ObjectLink:
                field = new ObjectLinkField();
                break;

            case FieldType.MultiObjectLink:
                field = new MultiObjectLinkField();
                break;

            case FieldType.Select:
                field = new SelectField();
                break;

            case FieldType.MultiSelect:
                field = new MultiSelectField();
                break;

            case FieldType.FilterField:
                field = new FilterField();
                break;

            case FieldType.OneToMany:
                field = new OneToManyField();
                break;

            default:
                field = new StringField();
                break;
            }
            return(field);
        }
Exemplo n.º 26
0
        private void CalcMomentary(List <Field> Fields, DateTime Now, ushort Raw)
        {
            Fields.Add(new Int32Field(this, Now, "Raw", Raw, FieldType.Momentary, FieldQoS.AutomaticReadout, typeof(Module).Namespace, 26));

            if (this.exp == null && !string.IsNullOrEmpty(this.expression))
            {
                this.exp = new Expression(this.expression);
            }

            if (this.exp != null)
            {
                Variables v = new Variables()
                {
                    { "Raw", (double)Raw }
                };

                object Value = this.exp.Evaluate(v);
                Field  F;

                if (Value is double dbl)
                {
                    F = new QuantityField(this, Now, this.fieldName, dbl, this.nrDecimals, this.unit, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is PhysicalQuantity qty)
                {
                    F = new QuantityField(this, Now, this.fieldName, qty.Magnitude, this.nrDecimals, qty.Unit.ToString(), FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is bool b)
                {
                    F = new BooleanField(this, Now, this.fieldName, b, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is DateTime DT)
                {
                    F = new DateTimeField(this, Now, this.fieldName, DT, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is Duration D)
                {
                    F = new DurationField(this, Now, this.fieldName, D, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is Enum E)
                {
                    F = new EnumField(this, Now, this.fieldName, E, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is int i32)
                {
                    if (string.IsNullOrEmpty(this.unit))
                    {
                        F = new Int32Field(this, Now, this.fieldName, i32, FieldType.Momentary, FieldQoS.AutomaticReadout);
                    }
                    else
                    {
                        F = new QuantityField(this, Now, this.fieldName, i32, 0, this.unit, FieldType.Momentary, FieldQoS.AutomaticReadout);
                    }
                }
                else if (Value is long i64)
                {
                    if (string.IsNullOrEmpty(this.unit))
                    {
                        F = new Int64Field(this, Now, this.fieldName, i64, FieldType.Momentary, FieldQoS.AutomaticReadout);
                    }
                    else
                    {
                        F = new QuantityField(this, Now, this.fieldName, i64, 0, this.unit, FieldType.Momentary, FieldQoS.AutomaticReadout);
                    }
                }
                else if (Value is string s)
                {
                    F = new StringField(this, Now, this.fieldName, s, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is TimeSpan TS)
                {
                    F = new TimeField(this, Now, this.fieldName, TS, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else
                {
                    F = new StringField(this, Now, this.fieldName, Value.ToString(), FieldType.Momentary, FieldQoS.AutomaticReadout);
                }

                if (this.fieldName == "Value")
                {
                    F.Module        = typeof(Module).Namespace;
                    F.StringIdSteps = new LocalizationStep[] { new LocalizationStep(13) };
                }

                Fields.Add(F);
            }
        }
Exemplo n.º 27
0
        protected override void ConstructFields()
        {
            TableName = "TBL_PATIENT";

               m_fldID = new StringField()
               {
             Owner = this,
             FieldName = "PATIENT_ID",
             Description = "ID",
             Size = 12,
             Required = true,
             KeyField = true
               };

               m_fldFirstName = new StringField(){
              Owner = this,
              FieldName = "FIRST_NAME",
              Description = "First Name",
              Size = 50,
              Required = true
               };

               m_fldLastName = new StringField()
               {
             Owner = this,
             FieldName = "LAST_NAME",
             Description = "Last Name",
             Size = 50,
             Required = true
               };

               m_fldContactPhone = new StringField()
               {
             Owner = this,
             FieldName = "PHONE_CONTACT",
             Description = "Contact Phone#",
             DataEntryFormat = DataEntryFormat.Phone,
             Size = 25
               };

               m_fldDOB = new DateTimeField()
               {
             Owner = this,
             FieldName = "DOB",
             Description = "Date of Birth",
             Required = true
               };

               m_fldAdmissionDate = new DateTimeField()
               {
             Owner = this,
             FieldName = "ADM_DATE",
             Description = "Admission Date"
               };

               m_fldMonthlyCost = new DecimalField()
               {
             Owner = this,
             FieldName = "MONTHLY_COST",
             Description = "Monthly Cost",
             MinValue = 0,
             DisplayFormat = "C"
               };

               m_fldClassification = new StringField()
               {
             Owner = this,
             FieldName = "ATTITUDE_CLASSIFICATION",
             Description = "Classification",
             Required = true,
             Size = 3,
             LookupType = LookupType.Dictionary,
             DataEntryType = DataEntryType.Lookup,

             HasDefaultValue = true,
             DefaultValue = "BUD"
               };

               m_fldClassification.LookupDictionary.Add("MRX, Marxist",
                                                     "CAP, Capitalist",
                                                     "NEH, Nehilist",
                                                     "BUD, Buddhist");

               m_fldReligious = new BoolField()
               {
             Owner = this,
             FieldName = "IS_RELIGIOUS",
             Description = "Religious",
             Required = true,
             DefaultValue = false,
             HasDefaultValue = true
               };
        }
Exemplo n.º 28
0
        /// <summary>
        /// Adds the attribute columns.
        /// </summary>
        private void AddDynamicControls()
        {
            // Clear the filter controls
            phAttributeFilters.Controls.Clear();

            // Remove attribute columns
            foreach (var column in gWorkflows.Columns.OfType <AttributeField>().ToList())
            {
                gWorkflows.Columns.Remove(column);
            }

            if (AvailableAttributes != null)
            {
                foreach (var attribute in AvailableAttributes)
                {
                    var control = attribute.FieldType.Field.FilterControl(attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter);
                    if (control != null)
                    {
                        if (control is IRockControl)
                        {
                            var rockControl = ( IRockControl )control;
                            rockControl.Label = attribute.Name;
                            rockControl.Help  = attribute.Description;
                            phAttributeFilters.Controls.Add(control);
                        }
                        else
                        {
                            var wrapper = new RockControlWrapper();
                            wrapper.ID    = control.ID + "_wrapper";
                            wrapper.Label = attribute.Name;
                            wrapper.Controls.Add(control);
                            phAttributeFilters.Controls.Add(wrapper);
                        }
                    }


                    string dataFieldExpression = attribute.Key;
                    bool   columnExists        = gWorkflows.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField   = dataFieldExpression;
                        boundField.AttributeId = attribute.Id;
                        boundField.HeaderText  = attribute.Name;
                        boundField.Condensed   = false;

                        var attributeCache = Rock.Web.Cache.AttributeCache.Get(attribute.Id);
                        if (attributeCache != null)
                        {
                            boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                        }

                        gWorkflows.Columns.Add(boundField);
                    }
                }
            }

            var dateField = new DateTimeField();

            gWorkflows.Columns.Add(dateField);
            dateField.DataField           = "CreatedDateTime";
            dateField.SortExpression      = "CreatedDateTime";
            dateField.HeaderText          = "Created";
            dateField.FormatAsElapsedTime = true;

            var statusField = new BoundField();

            gWorkflows.Columns.Add(statusField);
            statusField.DataField        = "Status";
            statusField.SortExpression   = "Status";
            statusField.HeaderText       = "Status";
            statusField.DataFormatString = "<span class='label label-info'>{0}</span>";
            statusField.HtmlEncode       = false;

            var stateField = new CallbackField();

            gWorkflows.Columns.Add(stateField);
            stateField.DataField          = "IsCompleted";
            stateField.SortExpression     = "CompletedDateTime";
            stateField.HeaderText         = "State";
            stateField.HtmlEncode         = false;
            stateField.OnFormatDataValue += (sender, e) =>
            {
                if (( bool )e.DataValue)
                {
                    e.FormattedValue = "<span class='label label-default'>Completed</span>";
                }
                else
                {
                    e.FormattedValue = "<span class='label label-success'>Active</span>";
                }
            };
        }
Exemplo n.º 29
0
        protected override void ConstructFields()
        {
            TableName = "TBL_TESTPERSON";
            StoreFlag = StoreFlag.LoadAndStore;

            m_fldName = new StringField()
            {
                Owner     = this,
                FieldName = "PERSON_NAME",
                Required  = true,
                Size      = 50
            };

            m_fldSex = new StringField()
            {
                Owner         = this,
                FieldName     = "SEX",
                Required      = true,
                Size          = 1,
                DataEntryType = DataEntryType.DirectEntryOrLookupWithValidation,
                LookupType    = LookupType.Dictionary
            };
            m_fldSex.LookupDictionary.AddRange(new string[] { "M,Male", "F,Female", "U,Unspecified" });

            m_fldRating = new IntField()
            {
                Owner          = this,
                FieldName      = "RATING",
                MinMaxChecking = true,
                MinValue       = 0,
                MaxValue       = 10
            };

            m_fldRegistered = new BoolField()
            {
                Owner     = this,
                FieldName = "IS_REGISTERED",
                Required  = true
            };

            m_fldDOB = new DateTimeField()
            {
                Owner     = this,
                FieldName = "DOB"
            };

            m_fldSalary = new DecimalField()
            {
                Owner          = this,
                FieldName      = "PAYROLL_VOLUME",
                MinMaxChecking = true,
                MinValue       = 0M,
                MaxValue       = Decimal.MaxValue
            };

            //calculated field returns salary * 10 years
            m_fldDecadeSalary = new DecimalField()
            {
                Owner         = this,
                FieldName     = "DECADE_SALARY",
                StoreFlag     = StoreFlag.None,
                DataEntryType = DataEntryType.None,
                Calculated    = true,
                Formula       = "850-10 +(::PAYROLL_VOLUME * 10)"
            };

            m_fldScore = new DoubleField()
            {
                Owner     = this,
                FieldName = "SCORE"
            };


            m_fldMovieNames = new ListField <string>()
            {
                Owner     = this,
                FieldName = "MOVIES",
                Required  = true
            };


            //ths is business logic-driven computed column for GUI
            m_fldBusinessCode = new StringField()
            {
                Owner         = this,
                FieldName     = "BUSINESS_CODE",
                StoreFlag     = StoreFlag.None,
                DataEntryType = DataEntryType.None
            };
        }
Exemplo n.º 30
0
        /// <summary>
        /// Adds the attribute columns.
        /// </summary>
        private void AddDynamicControls()
        {
            // Clear the filter controls
            phAttributeFilters.Controls.Clear();

            // Remove attribute columns
            foreach (var column in gWorkflows.Columns.OfType <AttributeField>().ToList())
            {
                gWorkflows.Columns.Remove(column);
            }

            if (AvailableAttributes != null)
            {
                foreach (var attribute in AvailableAttributes)
                {
                    var control = attribute.FieldType.Field.FilterControl(attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false);
                    if (control is IRockControl)
                    {
                        var rockControl = (IRockControl)control;
                        rockControl.Label = attribute.Name;
                        rockControl.Help  = attribute.Description;
                        phAttributeFilters.Controls.Add(control);
                    }
                    else
                    {
                        var wrapper = new RockControlWrapper();
                        wrapper.ID    = control.ID + "_wrapper";
                        wrapper.Label = attribute.Name;
                        wrapper.Controls.Add(control);
                        phAttributeFilters.Controls.Add(wrapper);
                    }

                    string savedValue = gfWorkflows.GetUserPreference(MakeKeyUniqueToType(attribute.Key));
                    if (!string.IsNullOrWhiteSpace(savedValue))
                    {
                        try
                        {
                            var values = JsonConvert.DeserializeObject <List <string> >(savedValue);
                            attribute.FieldType.Field.SetFilterValues(control, attribute.QualifierValues, values);
                        }
                        catch { }
                    }

                    string dataFieldExpression = attribute.Key;
                    bool   columnExists        = gWorkflows.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField      = dataFieldExpression;
                        boundField.HeaderText     = attribute.Name;
                        boundField.SortExpression = string.Empty;

                        var attributeCache = Rock.Web.Cache.AttributeCache.Read(attribute.Id);
                        if (attributeCache != null)
                        {
                            boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                        }

                        gWorkflows.Columns.Add(boundField);
                    }
                }
            }

            var dateField = new DateTimeField();

            gWorkflows.Columns.Add(dateField);
            dateField.DataField           = "CreatedDateTime";
            dateField.SortExpression      = "CreatedDateTime";
            dateField.HeaderText          = "Created";
            dateField.FormatAsElapsedTime = true;

            var statusField = new BoundField();

            gWorkflows.Columns.Add(statusField);
            statusField.DataField      = "Status";
            statusField.SortExpression = "Status";
            statusField.HeaderText     = "Status";
            statusField.HtmlEncode     = false;

            var stateField = new BoundField();

            gWorkflows.Columns.Add(stateField);
            stateField.DataField      = "State";
            stateField.SortExpression = "CompletedDateTime";
            stateField.HeaderText     = "State";
            stateField.HtmlEncode     = false;

            var manageField = new EditField();

            gWorkflows.Columns.Add(manageField);
            manageField.IconCssClass = "fa fa-edit";
            manageField.Click       += gWorkflows_Manage;

            var deleteField = new DeleteField();

            gWorkflows.Columns.Add(deleteField);
            deleteField.Click += gWorkflows_Delete;
        }
Exemplo n.º 31
0
        /// <summary>
        /// Add all of the columns to the Registrations grid after the Registrants column.
        /// The Column.Insert method does not play well with buttons.
        /// </summary>
        private void RegistrationsTabAddDynamicControls()
        {
            var registrantsField      = gRegistrations.ColumnsOfType <RockTemplateField>().FirstOrDefault(a => a.HeaderText == "Registrants");
            int registrantsFieldIndex = gRegistrations.Columns.IndexOf(registrantsField);

            // Remove all columns to the right of Registrants
            for (int i = registrantsFieldIndex + 2; i < gRegistrations.Columns.Count; i++)
            {
                gRegistrations.Columns.RemoveAt(i);
            }

            // Add Attribute columns if necessary
            if (AvailableRegistrationAttributeIdsForGrid != null)
            {
                foreach (var attributeCache in AvailableRegistrationAttributeIdsForGrid.Select(a => AttributeCache.Get(a)))
                {
                    bool columnExists = gRegistrations.Columns.OfType <AttributeField>().FirstOrDefault(a => a.AttributeId == attributeCache.Id) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField   = attributeCache.Key;
                        boundField.AttributeId = attributeCache.Id;
                        boundField.HeaderText  = attributeCache.Name;
                        boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                        gRegistrations.Columns.Add(boundField);
                    }
                }
            }

            // Add the rest of the columns
            var dtWhen = new DateTimeField {
                DataField = "CreatedDateTime", HeaderText = "When", SortExpression = "CreatedDateTime"
            };

            dtWhen.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
            dtWhen.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            gRegistrations.Columns.Add(dtWhen);

            var lDiscount = new RockLiteralField {
                ID = "lDiscount", HeaderText = "Discount Code", SortExpression = "DiscountCode", Visible = false
            };

            lDiscount.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
            lDiscount.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            gRegistrations.Columns.Add(lDiscount);

            var lRegistrationCost = new RockLiteralField {
                ID = "lRegistrationCost", HeaderText = "Total Cost", SortExpression = "TotalCost"
            };

            lRegistrationCost.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
            lRegistrationCost.ItemStyle.HorizontalAlign   = HorizontalAlign.Right;
            gRegistrations.Columns.Add(lRegistrationCost);

            var lBalance = new RockLiteralField {
                ID = "lBalance", HeaderText = "Balance Due", SortExpression = "BalanceDue"
            };

            lBalance.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
            lBalance.ItemStyle.HorizontalAlign   = HorizontalAlign.Right;
            gRegistrations.Columns.Add(lBalance);

            DeleteField deleteField = new DeleteField();

            deleteField.Click += gRegistrations_Delete;
            gRegistrations.Columns.Add(deleteField);
        }
Exemplo n.º 32
0
        private void CreateGrids(RockContext rockContext)
        {
            if (ContentChannels.Any())
            {
                this.Visible = true;

                phContentChannelGrids.Controls.Clear();

                foreach (var contentChannel in ContentChannels)
                {
                    bool canEdit = UserCanEdit || contentChannel.IsAuthorized(Authorization.EDIT, CurrentPerson);

                    string iconClass = "fa fa-bullhorn";
                    if (!string.IsNullOrWhiteSpace(contentChannel.IconCssClass))
                    {
                        iconClass = contentChannel.IconCssClass;
                    }

                    var pwItems = new PanelWidget();
                    phContentChannelGrids.Controls.Add(pwItems);
                    pwItems.ID       = string.Format("pwItems_{0}", contentChannel.Id);
                    pwItems.Title    = string.Format("<i class='{0}'></i> {1}", iconClass, contentChannel.Name);
                    pwItems.Expanded = ExpandedPanels.Contains(contentChannel.Id);

                    var divItems = new HtmlGenericControl("div");
                    pwItems.Controls.Add(divItems);
                    divItems.ID = string.Format("divItems_{0}", contentChannel.Id);
                    divItems.AddCssClass("grid");
                    divItems.AddCssClass("grid-panel");

                    Grid gItems = new Grid();
                    divItems.Controls.Add(gItems);
                    gItems.ID                = string.Format("gItems_{0}", contentChannel.Id);
                    gItems.DataKeyNames      = new string[] { "Id" };
                    gItems.EmptyDataText     = "No Items Found";
                    gItems.RowItemText       = "Item";
                    gItems.AllowSorting      = true;
                    gItems.Actions.ShowAdd   = canEdit;
                    gItems.IsDeleteEnabled   = canEdit;
                    gItems.Actions.AddClick += gItems_Add;
                    gItems.RowSelected      += gItems_Edit;
                    gItems.GridRebind       += gItems_GridRebind;

                    //
                    // Add the "Link Existing Item" button.
                    //
                    if (OccurrenceId.HasValue)
                    {
                        var lbtnLinkExisting = new LinkButton();
                        lbtnLinkExisting.Attributes.Add("title", "Link Existing Item");
                        lbtnLinkExisting.CommandArgument = contentChannel.Id.ToString();
                        lbtnLinkExisting.CssClass        = "btn btn-default btn-sm";
                        lbtnLinkExisting.Click          += lbtnLinkExisting_Click;
                        lbtnLinkExisting.Text            = "<i class='fa fa-link'></i>";

                        gItems.Actions.AddCustomActionControl(lbtnLinkExisting);
                    }

                    gItems.Columns.Add(new RockBoundField
                    {
                        DataField      = "Title",
                        HeaderText     = "Title",
                        SortExpression = "Title"
                    });

                    if (contentChannel.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates)
                    {
                        RockBoundField startDateTimeField;
                        RockBoundField expireDateTimeField;
                        if (contentChannel.ContentChannelType.IncludeTime)
                        {
                            startDateTimeField  = new DateTimeField();
                            expireDateTimeField = new DateTimeField();
                        }
                        else
                        {
                            startDateTimeField  = new DateField();
                            expireDateTimeField = new DateField();
                        }

                        startDateTimeField.DataField      = "StartDateTime";
                        startDateTimeField.HeaderText     = contentChannel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";
                        startDateTimeField.SortExpression = "StartDateTime";
                        gItems.Columns.Add(startDateTimeField);

                        expireDateTimeField.DataField      = "ExpireDateTime";
                        expireDateTimeField.HeaderText     = "Expire";
                        expireDateTimeField.SortExpression = "ExpireDateTime";
                        if (contentChannel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange)
                        {
                            gItems.Columns.Add(expireDateTimeField);
                        }
                    }

                    if (!contentChannel.ContentChannelType.DisablePriority)
                    {
                        var priorityField = new RockBoundField
                        {
                            DataField        = "Priority",
                            HeaderText       = "Priority",
                            SortExpression   = "Priority",
                            DataFormatString = "{0:N0}",
                        };
                        priorityField.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                        gItems.Columns.Add(priorityField);
                    }

                    // Add attribute columns
                    int    entityTypeId = EntityTypeCache.Get(typeof(Rock.Model.ContentChannelItem)).Id;
                    string qualifier    = contentChannel.ContentChannelTypeId.ToString();
                    foreach (var attributeCache in new AttributeService(rockContext).GetByEntityTypeQualifier(entityTypeId, "ContentChannelTypeId", qualifier, false)
                             .Where(a => a.IsGridColumn)
                             .OrderBy(a => a.Order)
                             .ThenBy(a => a.Name).ToAttributeCacheList())
                    {
                        string dataFieldExpression = attributeCache.Key;
                        bool   columnExists        = gItems.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                        if (!columnExists)
                        {
                            AttributeField boundField = new AttributeField();
                            boundField.DataField   = dataFieldExpression;
                            boundField.AttributeId = attributeCache.Id;
                            boundField.HeaderText  = attributeCache.Name;

                            if (attributeCache != null)
                            {
                                boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                            }

                            gItems.Columns.Add(boundField);
                        }
                    }

                    if (contentChannel.RequiresApproval && !contentChannel.ContentChannelType.DisableStatus)
                    {
                        var statusField = new BoundField();
                        gItems.Columns.Add(statusField);
                        statusField.DataField      = "Status";
                        statusField.HeaderText     = "Status";
                        statusField.SortExpression = "Status";
                        statusField.HtmlEncode     = false;
                    }

                    var deleteField = new DeleteField();
                    gItems.Columns.Add(deleteField);
                    deleteField.Click += gItems_Delete;
                }
            }
            else
            {
                this.Visible = false;
            }
        }
Exemplo n.º 33
0
 public static ValidationError InvalidDateRangeError(DateTimeField start, DateTimeField finish, ITextLocalizer localizer)
 {
     return(new ValidationError("InvalidDateRange", start.Name + "," + finish.Name,
                                Texts.Validation.FieldInvalidDateRange.ToString(localizer),
                                start.GetTitle(localizer), finish.GetTitle(localizer)));
 }
Exemplo n.º 34
0
        /// <summary>
        /// Adds the grid columns.
        /// </summary>
        /// <param name="dataTable">The data table.</param>
        private void AddGridColumns(Grid grid, DataTable dataTable)
        {
            bool showColumns     = GetAttributeValue("ShowColumns").AsBoolean();
            var  columnList      = GetAttributeValue("Columns").SplitDelimitedValues().ToList();
            var  encryptedFields = GetAttributeValue("EncryptedFields").SplitDelimitedValues().ToList();

            int rowsToEval = 10;

            if (dataTable.Rows.Count < 10)
            {
                rowsToEval = dataTable.Rows.Count;
            }

            grid.Columns.Clear();

            if (!string.IsNullOrWhiteSpace(grid.PersonIdField))
            {
                grid.Columns.Add(new SelectField());
            }

            GridFilterColumnLookup = new Dictionary <Control, string>();

            foreach (DataColumn dataTableColumn in dataTable.Columns)
            {
                if (columnList.Count > 0 &&
                    ((showColumns && !columnList.Contains(dataTableColumn.ColumnName, StringComparer.OrdinalIgnoreCase)) ||
                     (!showColumns && columnList.Contains(dataTableColumn.ColumnName, StringComparer.OrdinalIgnoreCase))))
                {
                    continue;
                }

                BoundField bf            = new BoundField();
                var        splitCaseName = dataTableColumn.ColumnName.SplitCase();

                if (dataTableColumn.DataType == typeof(bool))
                {
                    bf = new BoolField();

                    if (GridFilter != null)
                    {
                        var id = "ddl" + dataTableColumn.ColumnName.RemoveSpecialCharacters();

                        var filterControl = new RockDropDownList()
                        {
                            Label = splitCaseName,
                            ID    = id
                        };

                        GridFilterColumnLookup.Add(filterControl, dataTableColumn.ColumnName);

                        filterControl.Items.Add(BoolToString(null));
                        filterControl.Items.Add(BoolToString(true));
                        filterControl.Items.Add(BoolToString(false));
                        GridFilter.Controls.Add(filterControl);

                        var value = GridFilter.GetUserPreference(id);

                        if (value != null)
                        {
                            filterControl.SetValue(value);
                        }
                    }
                }
                else if (dataTableColumn.DataType == typeof(DateTime))
                {
                    bf = new DateField();

                    for (int i = 0; i < rowsToEval; i++)
                    {
                        object dateObj = dataTable.Rows[i][dataTableColumn];
                        if (dateObj is DateTime)
                        {
                            DateTime dateTime = ( DateTime )dateObj;
                            if (dateTime.TimeOfDay.Seconds != 0)
                            {
                                bf = new DateTimeField();
                                break;
                            }
                        }
                    }

                    if (GridFilter != null)
                    {
                        var id = "drp" + dataTableColumn.ColumnName.RemoveSpecialCharacters();

                        var filterControl = new DateRangePicker()
                        {
                            Label = splitCaseName,
                            ID    = id,
                        };

                        GridFilterColumnLookup.Add(filterControl, dataTableColumn.ColumnName);

                        GridFilter.Controls.Add(filterControl);

                        var value = GridFilter.GetUserPreference(id);

                        if (value != null)
                        {
                            DateTime upper;
                            DateTime lower;

                            if (DateRangePicker.TryParse(value, out lower, out upper))
                            {
                                filterControl.LowerValue = lower;
                                filterControl.UpperValue = upper;
                            }
                        }
                    }
                }
                else
                {
                    if (encryptedFields.Contains(dataTableColumn.ColumnName))
                    {
                        bf = new EncryptedField();
                    }

                    bf.HtmlEncode = false;

                    if (GridFilter != null)
                    {
                        var id            = "tb" + dataTableColumn.ColumnName.RemoveSpecialCharacters();
                        var filterControl = new RockTextBox()
                        {
                            Label = splitCaseName,
                            ID    = id
                        };

                        GridFilterColumnLookup.Add(filterControl, dataTableColumn.ColumnName);

                        GridFilter.Controls.Add(filterControl);
                        var key   = filterControl.ID;
                        var value = GridFilter.GetUserPreference(key);

                        if (value != null)
                        {
                            filterControl.Text = value;
                        }
                    }
                }

                bf.DataField      = dataTableColumn.ColumnName;
                bf.SortExpression = dataTableColumn.ColumnName;
                bf.HeaderText     = splitCaseName;
                grid.Columns.Add(bf);
            }
        }
        /// <summary>
        /// Initialisation de filtre
        /// </summary>
        protected void initFiltre()
        {
            // Postion et Taille par défaut
            int width_label    = 50;
            int height_label   = 20;
            int width_control  = 50;
            int height_control = 20;
            int TabIndex       = 0;

            // Insertion des critère de recherche par Type
            foreach (PropertyInfo propertyInfo in PropertyListFilter())
            {
                // Trouver l'objet AffichagePropriete depuis l'annotation
                Attribute getAffichagePropriete = propertyInfo.GetCustomAttribute(typeof(AffichageProprieteAttribute));
                if (getAffichagePropriete == null)
                {
                    continue;
                }
                AffichageProprieteAttribute AffichagePropriete = (AffichageProprieteAttribute)getAffichagePropriete;
                if (AffichagePropriete.Filtre == false)
                {
                    continue;
                }

                // Utiliser le Largeur de la configuration s'il existe
                int item_width_control = width_control;
                if (AffichagePropriete.WidthColonne != 0)
                {
                    item_width_control = AffichagePropriete.WidthColonne;
                }

                if (propertyInfo.PropertyType.Name == "String")
                {
                    StringFiled stringFiled = new StringFiled(propertyInfo,
                                                              Orientation.Horizontal,
                                                              new Size(width_label, height_label),
                                                              new Size(item_width_control, height_control));
                    stringFiled.Name          = propertyInfo.Name;
                    stringFiled.TabIndex      = TabIndex++;
                    stringFiled.Text_Label    = AffichagePropriete.Titre;
                    stringFiled.FieldChanged += Filtre_TextBox_SelectedValueChanged;
                    MainContainer.Controls.Add(stringFiled);
                }
                if (propertyInfo.PropertyType.Name == "Int32")
                {
                    Int32Filed int32Filed = new Int32Filed(propertyInfo,
                                                           Orientation.Vertical,
                                                           new Size(width_label, height_label),
                                                           new Size(item_width_control, height_control)
                                                           );
                    int32Filed.Name          = propertyInfo.Name;
                    int32Filed.TabIndex      = TabIndex++;
                    int32Filed.Text_Label    = AffichagePropriete.Titre;
                    int32Filed.FieldChanged += Filtre_TextBox_SelectedValueChanged;
                    MainContainer.Controls.Add(int32Filed);
                }
                if (propertyInfo.PropertyType.Name == "DateTime")
                {
                    DateTimeField dateTimeField = new DateTimeField(propertyInfo, Orientation.Vertical,
                                                                    new Size(width_label, height_label),
                                                                    new Size(item_width_control, height_control)
                                                                    );
                    dateTimeField.Name       = propertyInfo.Name;
                    dateTimeField.TabIndex   = TabIndex++;
                    dateTimeField.Text_Label = AffichagePropriete.Titre;


                    dateTimeField.FieldChanged += Filtre_TextBox_SelectedValueChanged;
                    MainContainer.Controls.Add(dateTimeField);
                }

                //
                // Relation ManyToOne
                //
                if (AffichagePropriete.Relation != String.Empty &&
                    AffichagePropriete.Relation == AffichageProprieteAttribute.RELATION_MANYTOONE)
                {
                    // La valeurs pardéfaut
                    Int64 default_value = 0;
                    if (ValeursFiltre != null && ValeursFiltre.Keys.Contains(propertyInfo.Name))
                    {
                        default_value = (Int64)ValeursFiltre[propertyInfo.Name];
                    }

                    ManyToOneField manyToOneField = new ManyToOneField(this.Service, propertyInfo,
                                                                       this.MainContainer,
                                                                       Orientation.Horizontal,
                                                                       new Size(width_label, height_label),
                                                                       new Size(item_width_control, height_control),
                                                                       default_value
                                                                       );
                    manyToOneField.Name          = propertyInfo.Name;
                    manyToOneField.TabIndex      = TabIndex++;
                    manyToOneField.Text_Label    = AffichagePropriete.Titre;
                    manyToOneField.FieldChanged += Filtre_ComboBox_SelectedValueChanged;
                    MainContainer.Controls.Add(manyToOneField);


                    //
                    // Remplissage de ComboBox
                    //
                    //Type ServicesEntityEnRelationType = typeof(BaseRepository<>).MakeGenericType(propertyInfo.PropertyType);
                    //IBaseRepository ServicesEntity = (IBaseRepository)Activator.CreateInstance(ServicesEntityEnRelationType);
                    //List<object> ls = ServicesEntity.GetAllDetached();
                    //manyToOneField.ValueMember = "Id";
                    //manyToOneField.DisplayMember = AffichagePropriete.DisplayMember;
                    //manyToOneField.DataSource = ls;
                    //if (AffichagePropriete.isValeurFiltreVide) manyToOneField.SelectedIndex = -1;

                    //// Affectation de valeur initial
                    //if (this.ValeursFiltre != null && this.ValeursFiltre.ContainsKey(propertyInfo.Name))
                    //{
                    //    manyToOneField.CreateControl();
                    //    manyToOneField.Value = Convert.ToInt64(this.ValeursFiltre[propertyInfo.Name]);
                    //}
                }



                //if (MainContainer.Controls.Count > 0)
                //{
                //    int max_h = this.MainContainer.Controls.Cast<Control>().Max(c => c.Size.Height);
                //    this.MainContainer.Size = new Size(this.MainContainer.Size.Width, max_h);
                //}
            } // End For
        }
Exemplo n.º 36
0
        /// <summary>
        /// Adds the attribute columns.
        /// </summary>
        private void AddDynamicControls()
        {
            // Clear the filter controls
            phAttributeFilters.Controls.Clear();

            // Remove attribute columns
            foreach (var column in gWorkflows.Columns.OfType <AttributeField>().ToList())
            {
                gWorkflows.Columns.Remove(column);
            }

            if (AvailableAttributes != null)
            {
                foreach (var attribute in AvailableAttributes)
                {
                    var control = attribute.FieldType.Field.FilterControl(attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter);
                    if (control != null)
                    {
                        if (control is IRockControl)
                        {
                            var rockControl = (IRockControl)control;
                            rockControl.Label = attribute.Name;
                            rockControl.Help  = attribute.Description;
                            phAttributeFilters.Controls.Add(control);
                        }
                        else
                        {
                            var wrapper = new RockControlWrapper();
                            wrapper.ID    = control.ID + "_wrapper";
                            wrapper.Label = attribute.Name;
                            wrapper.Controls.Add(control);
                            phAttributeFilters.Controls.Add(wrapper);
                        }
                    }

                    string savedValue = gfWorkflows.GetUserPreference(MakeKeyUniqueToType(attribute.Key));
                    if (!string.IsNullOrWhiteSpace(savedValue))
                    {
                        try
                        {
                            var values = JsonConvert.DeserializeObject <List <string> >(savedValue);
                            attribute.FieldType.Field.SetFilterValues(control, attribute.QualifierValues, values);
                        }
                        catch { }
                    }

                    string dataFieldExpression = attribute.Key;
                    bool   columnExists        = gWorkflows.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField   = dataFieldExpression;
                        boundField.AttributeId = attribute.Id;
                        boundField.HeaderText  = attribute.Name;
                        boundField.Condensed   = false;

                        var attributeCache = Rock.Web.Cache.AttributeCache.Read(attribute.Id);
                        if (attributeCache != null)
                        {
                            boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                        }

                        gWorkflows.Columns.Add(boundField);
                    }
                }
            }

            var dateField = new DateTimeField();

            gWorkflows.Columns.Add(dateField);
            dateField.DataField           = "CreatedDateTime";
            dateField.SortExpression      = "CreatedDateTime";
            dateField.HeaderText          = "Created";
            dateField.FormatAsElapsedTime = true;

            var statusField = new BoundField();

            gWorkflows.Columns.Add(statusField);
            statusField.DataField        = "Status";
            statusField.SortExpression   = "Status";
            statusField.HeaderText       = "Status";
            statusField.DataFormatString = "<span class='label label-info'>{0}</span>";
            statusField.HtmlEncode       = false;

            var stateField = new CallbackField();

            gWorkflows.Columns.Add(stateField);
            stateField.DataField          = "IsCompleted";
            stateField.SortExpression     = "CompletedDateTime";
            stateField.HeaderText         = "State";
            stateField.HtmlEncode         = false;
            stateField.OnFormatDataValue += (sender, e) =>
            {
                if ((bool)e.DataValue)
                {
                    e.FormattedValue = "<span class='label label-default'>Completed</span>";
                }
                else
                {
                    e.FormattedValue = "<span class='label label-success'>Active</span>";
                }
            };

            if (_canView)
            {
                var manageField = new LinkButtonField();
                gWorkflows.Columns.Add(manageField);
                manageField.CssClass = "btn btn-default btn-sm fa fa-file-text-o";
                manageField.Click   += gWorkflows_Manage;
            }

            if (_canEdit)
            {
                var deleteField = new DeleteField();
                gWorkflows.Columns.Add(deleteField);
                deleteField.Click += gWorkflows_Delete;
            }
        }
        /// <summary>
        /// Obtient les valeurs du filtre
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, object> CritereRechercheFiltre()
        {
            // Application de filtre
            Dictionary <string, object> RechercheInfos = new Dictionary <string, object>();

            foreach (PropertyInfo propertyInfo in PropertyListFilter())
            {
                // Trouver l'objet AffichagePropriete depuis l'annotation avec Filtre = True
                Attribute getAffichagePropriete = propertyInfo.GetCustomAttribute(typeof(AffichageProprieteAttribute));
                if (getAffichagePropriete == null)
                {
                    continue;
                }
                AffichageProprieteAttribute AffichagePropriete = (AffichageProprieteAttribute)getAffichagePropriete;
                if (AffichagePropriete.Filtre == false)
                {
                    continue;
                }


                switch (propertyInfo.PropertyType.Name)
                {
                case "String":
                {
                    StringFiled stringFiled = (StringFiled)this.groupBoxFiltrage.Controls.Find(propertyInfo.Name, true).First();
                    if (stringFiled.Value != String.Empty)
                    {
                        RechercheInfos[propertyInfo.Name] = stringFiled.Value;
                    }
                }
                break;

                case "Int32":
                {
                    Int32Filed int32Filed = (Int32Filed)this.groupBoxFiltrage.Controls.Find(propertyInfo.Name, true).First();
                    if ((int)int32Filed.Value != 0)
                    {
                        RechercheInfos[propertyInfo.Name] = int32Filed.Value;
                    }
                }
                break;

                case "DateTime":
                {
                    DateTimeField dateTimeField = (DateTimeField)this.groupBoxFiltrage.Controls.Find(propertyInfo.Name, true).First();
                    if ((DateTime)dateTimeField.Value != DateTime.MinValue)
                    {
                        RechercheInfos[propertyInfo.Name] = dateTimeField.Value;
                    }
                }
                break;

                default:     // Dans le cas d'un objet de type BaseEntity
                {
                    // [bug] groupBoxFiltrage doit être MainContainner
                    ManyToOneField ComboBoxEntity = (ManyToOneField)this.groupBoxFiltrage.Controls.Find(propertyInfo.Name, true).First();
                    BaseEntity     obj            = (BaseEntity)ComboBoxEntity.SelectedItem;
                    if (obj != null && Convert.ToInt32(obj.Id) != 0)
                    {
                        RechercheInfos[propertyInfo.Name] = obj.Id;
                    }
                }
                break;
                }
            }

            return(RechercheInfos);
        }
Exemplo n.º 38
0
 public bool ContainField(DateTimeField field)
 {
     return _result.Groups[field.ToString()].Success;
 }
Exemplo n.º 39
0
        protected IStorageDateTimeField CreateEmptyDateTimeFieldObject(DateTimeField field)
        {
            var storageService = service.StorageService;

            return((IStorageDateTimeField)storageService.GetObjectFactory().CreateEmptyFieldObject(field.GetType()));
        }
Exemplo n.º 40
0
        protected override void ConstructFields()
        {
            SupportsNotificationBinding = false;
               NoBuildCrosschecks = true;
               FieldValidationSuspended = true;

               TableName = "TBL_TESTPERSON";
               StoreFlag = StoreFlag.LoadAndStore;

               m_fldName = new StringField()
               {
             Owner = this,
             FieldName = "PERSON_NAME",
             Required = true,
             Size = 50
               };

               m_fldRating = new IntField()
               {
               Owner = this,
               FieldName = "RATING",
               MinMaxChecking = true,
               MinValue = 0,
               MaxValue = 10
               };

               m_fldRegistered = new BoolField()
               {
               Owner = this,
               FieldName = "IS_REGISTERED",
               Required = true
               };

               m_fldDOB = new DateTimeField()
               {
               Owner = this,
               FieldName = "DOB"
               };

               m_fldScore = new DoubleField()
               {
               Owner = this,
               FieldName = "SCORE"
               };

               m_fldData1 = new StringField()
               {
               Owner = this,
               FieldName = "Data1"
               };

               m_fldData2 = new StringField()
               {
               Owner = this,
               FieldName = "Data2"
               };

               m_fldData3 = new StringField()
               {
               Owner = this,
               FieldName = "Data3"
               };

               m_fldData4 = new IntField()
               {
               Owner = this,
               FieldName = "Data4"
               };

               m_fldData5 = new IntField()
               {
               Owner = this,
               FieldName = "Data5"
               };

               m_fldData6 = new IntField()
               {
               Owner = this,
               FieldName = "Data6"
               };

               m_fldData7 = new BoolField()
               {
               Owner = this,
               FieldName = "Data7"
               };

               m_fldData8 = new BoolField()
               {
               Owner = this,
               FieldName = "Data8"
               };

               m_fldData9 = new BoolField()
               {
               Owner = this,
               FieldName = "Data9"
               };

               m_fldData10 = new DoubleField()
               {
               Owner = this,
               FieldName = "Data10"
               };
        }
Exemplo n.º 41
0
        /// <summary>
        /// Reads the list of articles from the stream and returns the feed item.
        /// </summary>
        /// <param name="f">Information about the feed. This information is updated based
        /// on the results of processing the feed.</param>
        /// <param name="newsgroupListStream">A stream containing an nntp news group list.</param>
        /// <param name="response">The response.</param>
        /// <param name="cacheDataService">The cache data service to store embedded binary content.</param>
        /// <param name="cachedStream">Flag states update last retrieved date on feed only
        /// if the item was not cached. Indicates whether the lastretrieved date is updated
        /// on the NewsFeed object passed in.</param>
        /// <returns>
        /// A FeedInfo containing the NewsItem objects
        /// </returns>
        internal static FeedInfo GetItemsForNewsGroup(INewsFeed f, Stream newsgroupListStream, WebResponse response, IUserCacheDataService cacheDataService, bool cachedStream)
        {
            int readItems          = 0;
            List <INewsItem> items = new List <INewsItem>();
            NewsItem         item;

            StringBuilder content = new StringBuilder();

#if DEBUG
            // just to have the source for the item to build to track down issues:
            StringBuilder itemSource = new StringBuilder();
#endif
            NntpWebResponse nntpResponse = (NntpWebResponse)response;

            FeedInfo fi = new FeedInfo(f.id, f.cacheurl, items, f.title, f.link, String.Empty);

            try
            {
                foreach (MimeMessage msg in nntpResponse.Articles)
                {
                    string   parentId;
                    string   id;
                    string   author  = parentId = id = null;
                    DateTime pubDate = DateTime.UtcNow;

                    content.Length = 0;

                    string title;
                    if (msg.Subject != null)
                    {
                        title = EscapeXML(msg.Subject.Value);
                    }
                    else
                    {
                        title = "";
                    }

                    UnstructuredField fld = msg.Header.GetField(MimeField.MessageID) as UnstructuredField;
                    if (fld != null)
                    {
                        id = fld.Value;
                    }

                    MailboxListField mfld = msg.Header.GetField(MimeField.From) as MailboxListField;
                    if (mfld != null && mfld.MailboxList.Count > 0)
                    {
                        author = mfld.MailboxList[0].AddressString;
                    }

                    fld = msg.Header.GetField(MimeField.References) as UnstructuredField;
                    if (fld != null)
                    {
                        // returns the hierarchy path: the last one is our real parent:
                        string[] singleRefs = fld.Value.Split(' ');
                        if (singleRefs.Length > 0)
                        {
                            parentId = CreateGoogleUrlFromID(singleRefs[singleRefs.Length - 1]);
                        }
                    }
                    DateTimeField dfld = msg.Header.GetField(MimeField.Date) as DateTimeField;
                    if (dfld != null)
                    {
                        pubDate = dfld.DateValue;
                    }

                    ITextBody txtBody = msg.Body as ITextBody;
                    if (txtBody != null)
                    {
                        content.Append(txtBody.Reader.ReadToEnd());

                        content = NntpClient.DecodeBody(content,
                                                        (fileName, bytes) =>
                        {
                            string name = PrepareEmbeddedFileUrl(fileName, id, nntpResponse.ResponseUri);
                            // we replace the uuencoded/yencoded binary content with a clickable link:
                            if (IsImage(fileName))
                            {
                                return(String.Format("<img src='{1}' alt='{0}'></img>", fileName,
                                                     cacheDataService.SaveBinaryContent(name, bytes).AbsoluteUri));
                            }
                            return(String.Format("<a href='{1}'>{0}</a>", fileName,
                                                 cacheDataService.SaveBinaryContent(name, bytes).AbsoluteUri));
                        },
                                                        line =>
                        {
                            // escape HTML/XML special chars:
                            return(line.Replace("<", "&lt;").Replace("]]>", "]]&gt;"));
                        });

                        content = content.Replace(Environment.NewLine, "<br>");
                    }

                    if (id != null)
                    {
                        item              = new NewsItem(f, title, CreateGoogleUrlFromID(id), content.ToString(), author, pubDate, id, parentId);
                        item.FeedDetails  = fi;
                        item.CommentStyle = SupportedCommentStyle.NNTP;
                        item.Enclosures   = Collections.GetList <IEnclosure> .Empty;
                        items.Add(item);
                        FeedSource.ReceivingNewsChannelServices.ProcessItem(item);
                    }
                    else
                    {
#if DEBUG
                        _log.Warn("No message-id header found for item:\r\n" + itemSource.ToString());
#else
                        _log.Warn("No message-id header found for item.");
#endif
                    }
                }


                //update last retrieved date on feed only if the item was not cached.)
                if (!cachedStream)
                {
                    f.lastretrieved          = new DateTime(DateTime.Now.Ticks);
                    f.lastretrievedSpecified = true;
                }

                //any new items in feed?
                if ((items.Count == 0) || (readItems == items.Count))
                {
                    f.containsNewMessages = false;
                }
                else
                {
                    f.containsNewMessages = true;
                }

                FeedSource.ReceivingNewsChannelServices.ProcessItem(fi);
                FeedSource.RelationCosmosAddRange(items);
                fi.itemsList.AddRange(items);
            }
            catch (Exception e)
            {
                _log.Error("Retriving NNTP articles from " + nntpResponse.ResponseUri + " caused an exception", e);
            }


            return(fi);
        }