Exemplo n.º 1
0
        public static long ExportCatalogUpdates(IRFProcessingContext context, string path, RFDate startDate, RFDate?endDate = null, string password = null)
        {
            long c = 0;

            var keysInScope = context.SearchKeys(typeof(RFCatalogKey), startDate, endDate, 99999, null, false).Where(k => k.IsValid && k.Key.Plane == RFPlane.User).ToList();

            foreach (var keyDate in keysInScope.GroupBy(k => k.UpdateTime.Date))
            {
                var fileName = Path.Combine(path, String.Format("RIFF_{0}_Updates_{1}.zip", context.Environment, keyDate.Key.ToString("yyyyMMdd")));

                context.SystemLog.Info(typeof(RFCatalogMaintainer), "Exporting {0} documents into {1}", keyDate.Count(), fileName);

                var  exportableDocuments = new Dictionary <string, byte[]>();
                long cnt = 1;
                foreach (var key in keyDate)
                {
                    var doc = context.LoadEntry(key.Key) as RFDocument;
                    if (doc != null)
                    {
                        var docName = RFFileHelpers.SanitizeFileName(string.Format("{0}_{1}_{2}_{3}_{4}.xml",
                                                                                   doc.Key.GraphInstance?.ValueDate?.ToString() ?? "none",
                                                                                   doc.Key.GraphInstance?.Name ?? "none",
                                                                                   doc.Key.GetType().Name,
                                                                                   doc.Key.FriendlyString(),
                                                                                   cnt++));
                        exportableDocuments.Add(docName, Encoding.UTF8.GetBytes(RFXMLSerializer.PrettySerializeContract(doc)));
                        c++;
                    }
                }
                ZIPUtils.ZipFiles(fileName, exportableDocuments, password);
            }
            return(c);
        }
Exemplo n.º 2
0
 public FileResult GetFile(int mirroredFileID)
 {
     using (var activity = new RFMirrorActivity(Context, Username))
     {
         var file = activity.GetFile(mirroredFileID);
         if (file.content != null)
         {
             return(File(file.content, RFFileHelpers.GetContentType(file.mirroredFile.FileName), file.mirroredFile.FileName));
         }
         return(null);
     }
 }
Exemplo n.º 3
0
        public override void PutFile(RFFileAvailableEvent file, RFMonitoredFile fileConfig, byte[] data)
        {
            var directory = GetUnixDirectory(fileConfig.PutSubDirectory);

            if (UseTemporaryName)
            {
                var tmpFileName = file.FileAttributes.FileName + ".tmp";
                _connection.PutFile(directory, tmpFileName, data);
                _connection.MoveFile(
                    RFFileHelpers.GetUnixPath(directory, tmpFileName),
                    RFFileHelpers.GetUnixPath(directory, file.FileAttributes.FileName));
            }
            else
            {
                _connection.PutFile(directory, file.FileAttributes.FileName, data);
            }
        }
Exemplo n.º 4
0
        public void PutFile(string directory, string fileName, byte[] data)
        {
            var destinationPath = RFFileHelpers.GetUnixPath(directory, fileName);

            _client.UploadFile(new MemoryStream(data), destinationPath, true);
        }