示例#1
0
        public ActionResult Run(int idRecipe)
        {
            var recipe             = _context.Recipes.First(r => r.Id == idRecipe);
            var integrationRecipes = recipe.IntegrationRecipes;

            if (integrationRecipes.Count > 2)
            {
                throw new Exception("Algo não saiu como deveria.");
            }

            var isFirstCycle = true;

            foreach (var ir in integrationRecipes)
            {
                var integrationManager = new IntegrationSystemFactory().Build(ir.Integration.IntegrationSystem,
                                                                              ir.Integration.Settings);

                if (isFirstCycle)
                {
                    var files = integrationManager.GetFiles(ir.Configurations["Folder"]);
                    foreach (var file in files)
                    {
                        var completedPath = string.Format(@"C:\CoDelivery\{0}\{1}", UserName, file.Key);
                        var path          = completedPath.Remove(completedPath.LastIndexOf('/') + 1);

                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        System.IO.File.Create(completedPath).Close();

                        System.IO.File.WriteAllBytes(completedPath, file.Value);
                    }

                    isFirstCycle = false;
                }
                else
                {
                    var pathName = string.Format(@"C:\CoDelivery\{0}", UserName);
                    DirSearch(pathName, integrationManager, ir);
                }
            }

            return(RedirectToAction("Index"));
        }
示例#2
0
 public void SendFiles(IntegrationSystemFactory integrationSystemFactory, string localPath)
 {
 }
 public IntegrationController(CoDeliveryContext context, IntegrationSystemFactory integrationSystemFactory)
 {
     _context = context;
     _integrationSystemFactory = integrationSystemFactory;
 }
示例#4
0
        public List <string> GetFolders(IntegrationSystemFactory integrationSystemFactory, string path)
        {
            var integrationSystem = integrationSystemFactory.Build(IntegrationSystem, Settings);

            return(integrationSystem.GetFolders(path));
        }