Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the and save.
        /// </summary>
        /// <param name="nextdate">The next date.</param>
        /// <param name="info">The information.</param>
        /// <param name="scheduleEdit">The schedule edit.</param>
        /// <param name="fp">The fp.</param>
        /// <param name="calendar">The calendar.</param>
        /// <exception cref="Cebos.Veyron.SharedTypes.VeyronException"></exception>
        private static void CalculateAndSave(ref DateTime nextdate, IInfoClass info, ISupportScheduling scheduleEdit, IFrequencyPattern fp, ICalendar calendar)
        {
            var edit = info == null
                           ? TheDynamicTypeManager.NewEditableRoot<ISupportScheduling>(scheduleEdit.ProcessName)
                           : TheDynamicTypeManager.GetEditableRoot<ISupportScheduling>(scheduleEdit.ProcessName, info.Id);

            if (!edit.IsNew && scheduleEdit.SchedulingSeriesItemNumber > edit.SchedulingSeriesItemNumber)
                return;

            scheduleEdit.CopyScheduledPropertiesTo(edit);

            nextdate = CalculateNextDate(nextdate, fp, calendar);

            if (scheduleEdit.SchedulingEndOption == SchedulingEndOption.EndByDate.ToString() && nextdate > scheduleEdit.SchedulingEndByDate)
            {
                return;
            }

            edit.ScheduleDisplayDate = fp.PatternType.Equals(FrequencyPatternType.Daily.ToString()) ?
                nextdate :
                CheckAdjustWorkingExceptions(ref nextdate, calendar, fp);
            //duplicated due to exceptions, go to next frequency
            while ((_scheduledList.Contains(((DateTime)edit.ScheduleDisplayDate).Date) ||
                       _previousScheduleDate > ((DateTime)edit.ScheduleDisplayDate).Date) && calendar != null) 
            {
                nextdate = CalculateNextDate(nextdate, fp, calendar);

                if (scheduleEdit.SchedulingEndOption == SchedulingEndOption.EndByDate.ToString() && nextdate > scheduleEdit.SchedulingEndByDate)
                {
                    return;
                }
                edit.ScheduleDisplayDate = fp.PatternType.Equals(FrequencyPatternType.Daily.ToString()) ?
               nextdate :
               CheckAdjustWorkingExceptions(ref nextdate, calendar, fp);
            }
            _scheduledList.Add(((DateTime)edit.ScheduleDisplayDate).Date);
            _previousScheduleDate = ((DateTime)edit.ScheduleDisplayDate).Date;

            edit.SchedulingSeriesGuid = scheduleEdit.SchedulingSeriesGuid;
            edit.SchedulingEndOption = scheduleEdit.SchedulingEndOption;
            edit.SchedulingEndAfterOccurrences = scheduleEdit.SchedulingEndAfterOccurrences;
            edit.SchedulingEndAfterOccurrencesIndex = scheduleEdit.SchedulingEndAfterOccurrencesIndex;
            edit.SchedulingEndByDate = scheduleEdit.SchedulingEndByDate;
            edit.ScheduledItemsCount = scheduleEdit.ScheduledItemsCount;
            edit.SchedulingFrequencyPatternId = scheduleEdit.SchedulingFrequencyPatternId;
            edit.ProcessingScheduling = true;

            var businessBase = edit as BusinessBase;
            if (businessBase != null && !businessBase.IsValid)
            {
                var allValidationErrors = businessBase.BrokenRulesCollection.Select(x => string.IsNullOrEmpty(x.Description) ? x.RuleName : x.Description).ToList();

                var parent = edit.GetBaseEdit() as BusinessBase;
                if (parent != null && !parent.IsValid)
                    allValidationErrors.AddRange(parent.BrokenRulesCollection.Select(x => string.IsNullOrEmpty(x.Description) ? x.RuleName : x.Description).ToList());

                throw new VeyronException(string.Format(CultureInfo.InvariantCulture, "Scheduled process '{0}' is not valid and cannot be saved{1}{2}", edit.ProcessDisplayName, Environment.NewLine, string.Join(Environment.NewLine, allValidationErrors)));
            }

            var savedObject = (ISupportScheduling)((ISavable)edit).Save();

            scheduleEdit.CopyScheduledPropertiesAfterEditableRootWasSaved(savedObject);
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Gets the value.
            /// </summary>
            /// <param name="property">The property.</param>
            /// <param name="ancestor">The ancestor.</param>
            /// <returns>System.Object.</returns>
            private object GetValue(PropertyInfo property, IInfoClass ancestor)
            {
                if (PropertyType == typeof(byte[]))
                {
                    var value = property.GetValue(ancestor, null);

                    if (value != null && ((byte[])value).Length > 0)
                        return Image.FromStream(new MemoryStream((byte[])value));
                    else
                        return GetDefault(PropertyType).PropertyValue;
                }
                else
                {
                    var value = property.GetValue(ancestor, null);
                    if (value != null)
                    {
                        return Convert.ToString(value);
                    }
                }

                return string.Empty;
            }
 private static IDictionary<string, object> GetFieldValues(IInfoClass item, IEnumerable<string> resultColumns)
 {
     return resultColumns.ToDictionary(columnName => columnName, columnName => (object)item.GetValueByPropertyName(columnName));
 }
        private static object FormatImageColumn(IInfoClass infoItem, ColumnMetadata column)
        {
            var bytes = infoItem.GetValueByPropertyName(column.SystemName) as byte[];

            if (bytes != null && bytes.Length > 0)
            {
                var width = column.ImageWidth ?? Constants.DefaultImageWidthOnSearch;
                var height = column.ImageHeight ?? Constants.DefaultImageHeightOnSearch;

                bytes = Utils.ResizeImage(bytes, width, height);
            }

            return bytes;
        }
Ejemplo n.º 5
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ReportData"/> class.
            /// </summary>
            /// <param name="property">The property.</param>
            /// <param name="ancestor">The ancestor.</param>
            /// <param name="attributes">The attributes.</param>
            /// <param name="report">The report.</param>
            public ReportData(PropertyInfo property, IInfoClass ancestor, FieldParametres attributes, Report report)
            {
                PropertyType = property.PropertyType;
                PropertyValue = GetValue(property, ancestor);
                PropertyAttributes = attributes;
                CurrentReport = report;

                Width = GetWidth();
                Height = GetHeight();
            }
        private object FormatBackcolorColumn(IInfoClass infoItem, ColumnMetadata column)
        {
            var argb = (long)infoItem.GetValueByPropertyName(column.SystemName);
            if (argb == 0)
            {
                // 0 represents no color.
                return null;
            }

            return ColorTranslator.ToHtml(argb);
        }
        private static object FormatApprovalColumn(IInfoClass infoItem, ColumnMetadata column)
        {
            var approvalState = ApprovalStates.NotReadyForApproval;
            var propertyValue = (string)infoItem.GetValueByPropertyName(column.SystemName);

            if (!string.IsNullOrEmpty(propertyValue))
            {
                approvalState = (ApprovalStates)Enum.Parse(typeof(ApprovalStates), propertyValue);
            }

            return approvalState.GetDisplayName();
        }
        private object FormatColumn(IInfoClass infoItem, ColumnMetadata column)
        {
            switch (column.ColumnType)
            {
                case ColumnTypes.Approval:
                    return FormatApprovalColumn(infoItem, column);

                case ColumnTypes.FieldBackcolor:
                    return FormatBackcolorColumn(infoItem, column);

                case ColumnTypes.Image:
                    return FormatImageColumn(infoItem, column);

                default:
                    return infoItem.GetValueByPropertyName(column.SystemName);
            }
        }
        private InternalSearchItem FormatItem(IInfoClass infoItem, IEnumerable<ColumnMetadata> resultColumns)
        {
            var columnEnumerator = resultColumns.GetEnumerator();
            var searchItem = new InternalSearchItem(infoItem.Id);

            for (var i = 0; columnEnumerator.MoveNext(); ++i)
            {
                var column = columnEnumerator.Current;
                object formattedValue = null;

                if (infoItem.CanReadPropertyByName(column.SystemName))
                {
                    formattedValue = FormatColumn(infoItem, column);
                }
                else
                {
                    searchItem.BlockedColumns.Add(i);
                }

                searchItem.Values.Add(formattedValue);
            }

            return searchItem;
        }
Ejemplo n.º 10
0
        private void ElementExporting(object sender, GridViewElementExportingEventArgs e)
        {
            var bHtml = (TheExportOptionsViewModel.Value.ExportFileType != ExportFileType.ExcelML &&
                        TheExportOptionsViewModel.Value.ExportFileType != ExportFileType.Csv);
            if (!bHtml)
                return;

            switch (e.Element)
            {
                case ExportElement.HeaderRow:
                    if (TheExportOptionsViewModel.Value.ExportFileType == ExportFileType.Pdf)
                    {
                        if (TheExportOptionsViewModel.Value.HeaderBackground.HasValue)
                            ((GridViewHtmlVisualExportParameters)e.VisualParameters).Styles.Add("background-color", TheExportOptionsViewModel.Value.HeaderBackground.Value.ToString().Remove(1, 2));
                    }
                    else
                    {
                        ((GridViewHtmlVisualExportParameters)e.VisualParameters).Background = TheExportOptionsViewModel.Value.HeaderBackground;
                    }

                    ((GridViewHtmlVisualExportParameters)e.VisualParameters).FontSize = 20;
                    ((GridViewHtmlVisualExportParameters)e.VisualParameters).FontWeight = FontWeights.Bold;
                    break;

                case ExportElement.HeaderCell:
                    ((GridViewHtmlVisualExportParameters)e.VisualParameters).Foreground = TheExportOptionsViewModel.Value.HeaderForeground;
                    ((GridViewHtmlVisualExportParameters)e.VisualParameters).Height = 20;
                    break;

                case ExportElement.Row:
                    _row = (IInfoClass)e.Value;
                    if (TheExportOptionsViewModel.Value.ExportFileType == ExportFileType.Pdf)
                    {
                        if (TheExportOptionsViewModel.Value.RowBackground.HasValue)
                            ((GridViewHtmlVisualExportParameters)e.VisualParameters).Styles.Add("background-color", TheExportOptionsViewModel.Value.RowBackground.Value.ToString().Remove(1, 2));
                    }
                    else
                    {
                        ((GridViewHtmlVisualExportParameters)e.VisualParameters).Background = TheExportOptionsViewModel.Value.RowBackground;
                    }

                    break;

                case ExportElement.GroupHeaderRow:
                    ((GridViewHtmlVisualExportParameters)e.VisualParameters).FontFamily = new FontFamily("Arial Unicode MS");
                    ((GridViewHtmlVisualExportParameters)e.VisualParameters).Background = Colors.LightGray;
                    ((GridViewHtmlVisualExportParameters)e.VisualParameters).Height = 30;
                    var qcvGroup = e.Value as QueryableCollectionViewGroup;
                    if (qcvGroup != null)
                        e.Value = string.Format(CultureInfo.InvariantCulture, "{0} Items", qcvGroup.Items.Count);

                    break;

                case ExportElement.GroupFooterRow:
                case ExportElement.FooterRow:
                    if (TheExportOptionsViewModel.Value.ExportFileType == ExportFileType.Pdf)
                        ((GridViewHtmlVisualExportParameters)e.VisualParameters).Styles.Add("background-color", Colors.LightGray.ToString().Remove(1, 2));
                    else
                        ((GridViewHtmlVisualExportParameters)e.VisualParameters).Background = Colors.LightGray;

                    break;

                case ExportElement.Cell:
                    if (_accessDeniedProperties.Any(x => x == ((GridViewColumn)e.Context).UniqueName))
                    {
                        e.Value = "<Blocked>";
                        ((GridViewHtmlVisualExportParameters)e.VisualParameters).Foreground = Colors.Red;
                        break;
                    }

                    if (e.Value is string && (string)e.Value == "<Rich Text>")
                    {
                        ((GridViewHtmlVisualExportParameters)e.VisualParameters).Foreground = Colors.Blue;
                        break;
                    }

                    if (e.Value is byte[])
                    {
                        e.Value = "binary data";
                    }

                    var propertyName = ((GridViewDataColumn)e.Context).UniqueName + Constants.FieldBackColorPostfix;
                    var value = _row.GetValueByPropertyName(propertyName);
                    if (value is long)
                    {
                        var color = ((long)value);
                        if (color != 0)
                        {
                            ((GridViewHtmlVisualExportParameters)e.VisualParameters).Background = ((long)value).ToColor();
                        }
                    }
                    ((GridViewHtmlVisualExportParameters)e.VisualParameters).Foreground = TheExportOptionsViewModel.Value.RowForeground;

                    break;

                case ExportElement.GroupFooterCell:
                    if (e.Value == null)
                        return;

                    var qcvg = e.Value as QueryableCollectionViewGroup;
                    if (qcvg != null)
                    {
                        var resultList = new List<string>();
                        foreach (var aggr in qcvg.AggregateResults)
                        {
                            if (aggr.FunctionName.StartsWith(((GridViewColumn)e.Context).UniqueName, StringComparison.Ordinal))
                            {
                                resultList.Add(string.Format(CultureInfo.InvariantCulture, "{0} {1}", aggr.Caption, aggr.Value));
                            }
                        }

                        e.Value = string.Join(", ", resultList);
                    }
                    break;

                case ExportElement.FooterCell:
                    if (e.Value == null)
                        return;

                    var result = new List<string>();
                    var array = ((string)e.Value).Split(',');

                    for (byte i = 0; i < ((GridViewColumn)e.Context).AggregateFunctions.Count; i++)
                        result.Add(string.Format(CultureInfo.InvariantCulture, "{0} {1}", ((GridViewColumn)e.Context).AggregateFunctions[i].Caption, array[i]));

                    e.Value = string.Join(", ", result);

                    break;
            }
        }