Пример #1
0
 public RFCatalogEntryDTO(RFCatalogEntry e)
 {
     if (e != null)
     {
         TypeName = e.GetType().FullName;
         Content  = RFXMLSerializer.SerializeContract(e);
     }
 }
 public bool RequiresApply(RFDate valueDate)
 {
     try
     {
         var template = LoadTemplateEntry(valueDate);
         var latest   = LoadLatestEntry(valueDate);
         if (template != null && latest != null)
         {
             return(RFXMLSerializer.SerializeContract(template.Content) != RFXMLSerializer.SerializeContract(latest.Content));
         }
     }
     catch (Exception ex)
     {
         Log.Warning(this, ex.Message);
     }
     return(false);
 }
Пример #3
0
 public void CleanUpMaxAge(DateTime utcNow, decimal?maxAge)
 {
     if (maxAge.HasValue)
     {
         foreach (var fileEntry in SeenAttributes)
         {
             var toRemove = fileEntry.Value.Where(e => IsExpired(e, utcNow, maxAge)).ToList();
             if (toRemove.Count > 0)
             {
                 foreach (var tr in toRemove)
                 {
                     RFStatic.Log.Debug(this, "Removing max aged entry: {0}", RFXMLSerializer.SerializeContract(tr));
                 }
             }
             foreach (var remove in toRemove)
             {
                 fileEntry.Value.Remove(remove);
             }
         }
     }
 }
Пример #4
0
        public void SerializationTests()
        {
            var ds1 = new TestSet
            {
                Rows = new List <TestSet.Row>
                {
                    new TestSet.Row {
                        A = "b", B = 2
                    },
                    new TestSet.Row {
                        A = "a", B = 1
                    },
                    new TestSet.Row {
                        A = "c", B = 3
                    },
                }
            };

            var ds2 = new TestSet
            {
                Rows = new List <TestSet.Row>
                {
                    new TestSet.Row {
                        A = "a", B = 1
                    },
                    new TestSet.Row {
                        A = "c", B = 3
                    },
                    new TestSet.Row {
                        A = "b", B = 2
                    },
                }
            };

            var ds1text = RFXMLSerializer.SerializeContract(ds1);
            var ds2text = RFXMLSerializer.SerializeContract(ds2);

            Assert.Equal(ds1text, ds2text);
        }
Пример #5
0
        public JsonResult GetProcesses(string instanceName, DateTime?instanceDate)
        {
            using (var activity = new RFEngineActivity(Context, EngineConfig))
            {
                var engineConfig  = activity.GetEngineConfig();
                var graphInstance = new RFGraphInstance
                {
                    Name      = string.IsNullOrWhiteSpace(instanceName) ? RFGraphInstance.DEFAULT_INSTANCE : instanceName,
                    ValueDate = instanceDate.HasValue ? new RFDate(instanceDate.Value.Date) : RFDate.NullDate
                };
                var stats = activity.GetEngineStats(graphInstance);

                var allProcesses = new List <object>();
                foreach (var process in engineConfig.Processes.Values)
                {
                    var processor = process.Processor();
                    var stat      = stats.GetStat(process.Name);
                    allProcesses.Add(new
                    {
                        Graph        = "(none)",
                        Name         = process.Name,
                        FullName     = process.Name,
                        Description  = process.Description,
                        Type         = processor.GetType().FullName,
                        RequiresIdle = false,
                        IsGraph      = false,
                        LastRun      = stat != null ? (DateTimeOffset?)stat.LastRun : null,
                        LastDuration = stat != null ? (long?)stat.LastDuration : null,
                    });
                }

                foreach (var graph in engineConfig.Graphs.Values)
                {
                    foreach (var process in graph.Processes.Values)
                    {
                        var fullName  = RFGraphDefinition.GetFullName(graph.GraphName, process.Name);
                        var stat      = stats.GetStat(fullName);
                        var processor = process.Processor();
                        var domain    = processor.CreateDomain();
                        var io        = new List <object>();
                        if (domain != null)
                        {
                            foreach (var propertyInfo in domain.GetType().GetProperties())
                            {
                                var          ioBehaviourAttribute = (propertyInfo.GetCustomAttributes(typeof(RFIOBehaviourAttribute), true).FirstOrDefault() as RFIOBehaviourAttribute);
                                string       direction            = "-";
                                string       dateType             = "-";
                                RFCatalogKey ioKey = null;
                                if (ioBehaviourAttribute != null)
                                {
                                    var ioBehaviour = ioBehaviourAttribute.IOBehaviour;
                                    direction = ioBehaviour.ToString();

                                    var ioMapping = process.IOMappings.FirstOrDefault(m => m.PropertyName == propertyInfo.Name);
                                    if (ioMapping != null)
                                    {
                                        ioKey = ioMapping.Key.CreateForInstance(graphInstance);
                                        var options = RFGraphInstance.ImplyOptions(ioMapping);
                                        dateType = options.DateBehaviour.ToString();
                                    }
                                }

                                io.Add(new
                                {
                                    Field     = propertyInfo.Name,
                                    Direction = direction,
                                    DateType  = dateType,
                                    DataType  = propertyInfo.PropertyType.Name,
                                    KeyType   = ioKey != null ? ioKey.GetType().Name : null,
                                    ShortKey  = ioKey != null ? ioKey.FriendlyString() : null,
                                    FullKey   = ioKey != null ? RFXMLSerializer.SerializeContract(ioKey) : null
                                });
                            }
                        }
                        allProcesses.Add(new
                        {
                            Graph        = graph.GraphName,
                            Name         = process.Name,
                            FullName     = fullName,
                            IsGraph      = true,
                            Description  = process.Description,
                            Type         = processor.GetType().FullName,
                            IO           = io,
                            LastRun      = stat != null ? (DateTimeOffset?)stat.LastRun : null,
                            LastDuration = stat != null ? (long?)stat.LastDuration : null
                        });
                    }
                }

                return(Json(allProcesses));
            }
        }
Пример #6
0
        public bool HaveSeenFile(string fileKey, RFFileTrackedAttributes attributes)
        {
            if (SeenAttributes.ContainsKey(fileKey))
            {
                var seenAttributes = SeenAttributes[fileKey];
                var haveSeen       = seenAttributes.Any(a => a.Equals(attributes));
                if (!haveSeen)
                {
                    RFStatic.Log.Debug(this, "File {0} ({1}) is new. None of existing {2} have-seens match:", fileKey, RFXMLSerializer.SerializeContract(attributes), seenAttributes.Count);

                    /*foreach(var a in seenAttributes)
                     * {
                     *  RFStatic.Log.Debug(this, RFXMLSerializer.SerializeContract(a));
                     * }*/
                }
                return(haveSeen);
            }
            else
            {
                RFStatic.Log.Debug(this, "No seen files entries for file {0}", fileKey);
            }
            return(false);
        }
Пример #7
0
 private void OnSerializing(StreamingContext ctx)
 {
     // resort rows by serialized representation - slow but ensures dataset equality
     Rows = Rows?.Select(r => new { Key = RFXMLSerializer.SerializeContract(r), Row = r }).OrderBy(r => r.Key).Select(r => r.Row).ToList();
 }