Ejemplo n.º 1
0
        public void InitValues(StorageValues storageValues, bool initInvisible)
        {
            if (Plugin == null)
            {
                throw new Exception("Свойство Plugin не может быть равен null");
            }

            foreach (var filter in Plugin.Conditions)
            {
                if (!filter.Visible && !initInvisible)
                {
                    continue;
                }
                var storage = filter.ColumnFilter.GetStorage();
                storageValues.SetStorage(storage);
                filter.ColumnFilter.SetStorage(storage);
            }
            Plugin.SetCountCircleFillConditions(storageValues.CountListValues, true);
            for (int i = 0; i < storageValues.CountListValues; i++)
            {
                foreach (var filter in Plugin.CircleFillConditions[i])
                {
                    if (!filter.Visible && !initInvisible)
                    {
                        continue;
                    }
                    var storage = filter.ColumnFilter.GetStorage();
                    storageValues.SetListStorage(storage, i);
                    filter.ColumnFilter.SetStorage(storage);
                }
            }
        }
Ejemplo n.º 2
0
        private void LoadFiltersState()
        {
            var sid = GetSidBytes();
            // Loading user dependend filters state settings
            // In case there is no user setting apply default settings
            StorageValues storageValues = StorageValues.GetStorageValues(string.Format("{0}_{1}", Page.AppRelativeVirtualPath, ClientID), sid);

            if (storageValues != null)
            {
                foreach (ColumnFilterStorage storage in ColumnFilterStorages)
                {
                    storageValues.SetStorage(storage);
                }
            }
            else
            {
                WebInitializer.Initialize();
                foreach (ColumnFilterStorage storage in ColumnFilterStorages)
                {
                    ColumnFilterType columnFilterType = (ColumnFilterType)(DataSetResourceManager.GetColumnExtProperty(
                                                                               dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_CONDITION) ?? ColumnFilterType.None);
                    if (columnFilterType != ColumnFilterType.None)
                    {
                        if (!dataTable.Columns.Contains(storage.Name))
                        {
                            continue;
                        }
                        object[] values = new object[2];
                        values[0] = DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_1) ?? null;
                        values[1] = DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_2) ?? null;

                        string codeField = (String)DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_CODE_FIELD);

                        if (storage.IsRefBound && !string.IsNullOrEmpty(codeField))
                        {
                            for (int i = 0; i < values.Length; i++)
                            {
                                if (values[i] != null)
                                {
                                    DataTable table = (DataTable)storage.RefDataSource;

                                    QueryConditionList queryConditionList = new QueryConditionList();
                                    QueryCondition     queryCondition     = new QueryCondition(codeField, ColumnFilterType.Equal, values[i], null);
                                    queryConditionList.Add(queryCondition);
                                    Type tableAdapterType = TableAdapterTools.GetTableAdapterType(table.GetType());

                                    QueryGenerator queryGenerator;

                                    if (table.Columns.IndexOf("dateEnd") != -1 && table.Columns.IndexOf("dateStart") != -1)
                                    {
                                        Component adapter = HistoricalData.GetTableAdapterToHistoricalData("dateEnd", "dateStart", DateTime.Now, tableAdapterType, 0);
                                        queryGenerator = new QueryGenerator(adapter);
                                    }
                                    else
                                    {
                                        queryGenerator = new QueryGenerator(table);
                                    }

                                    queryGenerator.TopCount = 1;
                                    queryGenerator.Fill(table, queryConditionList);
                                    if (table.Rows.Count != 0)
                                    {
                                        values[i] = table.Rows[0][storage.ValueColumn];
                                    }
                                }
                            }
                        }
                        storage.FilterType = columnFilterType;
                        try
                        {
                            for (int i = 0; i != 2; i++)
                            {
                                if (values[i] != null)
                                {
                                    storage.SetValue(i, Convert.ChangeType(values[i], storage.DataType));
                                }
                            }
                        }
                        catch (InvalidCastException)
                        {
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void CreateReportSubscriptionParams(
            DBDataContext db,
            long refReportSubscriptions,
            List <BaseReportCondition> conditionsRu,
            List <BaseReportCondition> conditionsKz,
            PlaceHolder ph,
            StorageValues values,
            int?index)
        {
            var i = -1;

            foreach (var conditionRu in conditionsRu)
            {
                i++;
                if (!conditionRu.Visible)
                {
                    continue;
                }
                var conditionKz = conditionsKz[i];

                ph.Controls.Add((Control)conditionRu.ColumnFilter);
                var storageRu = conditionRu.ColumnFilter.GetStorage();
                if (index == null)
                {
                    values.SetStorage(storageRu);
                }
                else
                {
                    values.SetListStorage(storageRu, index.Value);
                }
                conditionRu.ColumnFilter.SetStorage(storageRu);

                ph.Controls.Add((Control)conditionKz.ColumnFilter);
                var storageKz = conditionKz.ColumnFilter.GetStorage();
                if (index == null)
                {
                    values.SetStorage(storageKz);
                }
                else
                {
                    values.SetListStorage(storageKz, index.Value);
                }
                conditionKz.ColumnFilter.SetStorage(storageKz);

                string[] textValues        = conditionsKz[i].ColumnFilter.GetTexts();
                var      paramTextValuesKz = string.Empty;
                if (textValues != null)
                {
                    paramTextValuesKz = string.Join(", ", textValues);
                }
                var paramCaptionKz = storageKz.Caption;

                var paramTextValuesRu = string.Empty;
                textValues = conditionRu.ColumnFilter.GetTexts();
                if (textValues != null)
                {
                    paramTextValuesRu = string.Join(", ", textValues);
                }
                var paramCaptionRu = storageRu.Caption;

                var record = new ReportSubscriptions_Param
                {
                    refReportSubscriptions = refReportSubscriptions,
                    ParamName             = storageRu.Name,
                    ParamCaptionKz        = paramCaptionKz,
                    ParamCaptionRu        = paramCaptionRu,
                    ParamTextValuesKz     = paramTextValuesKz,
                    ParamTextValuesRu     = paramTextValuesRu,
                    DynamicAttributeIndex = index,
                    ParamDataType         = storageRu.DataType.Name,
                    ParamFilterType       = storageRu.FilterType.ToString()
                };
                db.ReportSubscriptions_Params.InsertOnSubmit(record);

                ph.Controls.Remove((Control)conditionRu.ColumnFilter);
                ph.Controls.Remove((Control)conditionKz.ColumnFilter);
            }
        }