コード例 #1
0
ファイル: ExportXmlFile.cs プロジェクト: cskies/Rpts
        public static void Processamento(string _typeOfFolder)
        {
            var guidID = AplTrace.GenerateNewId();

            try
            {
                //var baseDirectory = new DirectoryInfo(directoryName.Name);
                var baseDirectory = new DirectoryInfo(ConfigurationSettings.AppSettings["BaseDirectory"].ToString());

                foreach (var directory in baseDirectory.GetDirectories().Where(x => x.Name.ToUpper() == _typeOfFolder.ToUpper()))
                {
                    //var directoryOfTextFiles = $@"{directory.FullName}\XML";
                    var files = ReadXmlFiles.GetXmlFiles(directory.FullName);


                    foreach (var xmlFile in files)
                    {
                        try
                        {
                            // Verificacao de arquivo em uso
                            if (HandlingFiles.FileIsLocked(xmlFile.FullName) == false)
                            {
                                try
                                {
                                    var _class = TransformXmlToClass.xmlToClass(xmlFile.FullName);

                                    //if (WriteClassIntoBPCS(xmlFile, _class, guidID))
                                    //{
                                    //    BasicStructure.ModeFileToBackupArea(xmlFile, guidID);
                                    //}
                                }
                                catch (Exception)
                                {
                                    // BasicStructure.ModeFileToErrorArea(xmlFile, guidID);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            AplTrace.InsertTrace(guidID, typeof(ExportXmlFile).Namespace, "(Processamento)", ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AplTrace.InsertTrace(guidID, typeof(ExportXmlFile).Namespace, "(Processamento)", ex.Message);
            }
        }
コード例 #2
0
ファイル: ReadXmlFiles.cs プロジェクト: cskies/Rpts
        public static IList <FileInfo> GetXmlFiles(string _fileDirectory)
        {
            var directory = new DirectoryInfo(_fileDirectory);
            var files     = new List <FileInfo>();

            foreach (var file in directory.GetFiles("*.xml"))
            {
                if (HandlingFiles.FileIsLocked(file.FullName) == false)
                {
                    files.Add(file);
                }
            }

            return(files);
        }