Exemple #1
0
        public void DoLocalImport(IMostreDB mostre, string localRoot)
        {
            logger.Info(string.Format("DoLocalImport started"));

            foreach (var machine in mManager.GetMachines())
            {
                RetrieveAndProcessFiles(machine, string.Format(machine.LocalDownloadPathFormat, localRoot), mostre);
            }
        }
Exemple #2
0
        public void DoRemoteImport(IMostreDB mostre)
        {
            logger.Info(string.Format("DoRemoteImport started"));

            foreach (var machine in mManager.GetMachines())
            {
                RetrieveAndProcessFiles(machine, machine.RemotePath, mostre);
            }
        }
		public void DoLocalImport(IMostreDB mostre, string localRoot)
		{
			logger.Info(string.Format("DoLocalImport started"));

			foreach (var machine in mManager.GetMachines())
			{
				RetrieveAndProcessFiles(machine, string.Format(machine.LocalDownloadPathFormat, localRoot), mostre);
			}
		}
		public void DoRemoteImport(IMostreDB mostre)
		{
			logger.Info(string.Format("DoRemoteImport started"));

			foreach (var machine in mManager.GetMachines())
			{
				RetrieveAndProcessFiles(machine, machine.RemotePath, mostre);
			}
		}
Exemple #5
0
    protected void importap_Click(object sender, EventArgs e)
    {
        string adresafizicaserver = Server.MapPath("~");

        IMostreDB    mostre   = (IMostreDB) new MostreDB();
        FileImporter importer = new FileImporter(StaticDataHelper.FCCLDbContext, adresafizicaserver);

        importer.DoRemoteImport(mostre);

        BindData();
    }
Exemple #6
0
    protected void importa_Click(object sender, EventArgs e)
    {
        string adresafizicaserver = Server.MapPath("~");
        string cale_import        = Server.MapPath("~/Downloads/");

        IMostreDB    mostre   = (IMostreDB) new MostreDB();
        FileImporter importer = new FileImporter(StaticDataHelper.FCCLDbContext, adresafizicaserver);

        importer.DoLocalImport(mostre, cale_import);

        BindData();
    }
Exemple #7
0
        private int RetrieveAndProcessFiles(Machine machine, string fromFolder, IMostreDB mostre)
        {
            int fileProcessed = 0;

            try
            {
                foreach (string remoteFilePath in Directory.GetFiles(fromFolder, machine.FileFilter))
                {
                    string filename          = Path.GetFileName(remoteFilePath);
                    string localFilePath     = Path.Combine(string.Format(machine.LocalSavePathFormat, localServer), filename);
                    string newRemoteFilePath = Path.Combine(fromFolder, Constants.FOLDER_REMOTE_PROCESSED_RELATIVE, filename);
                    logger.Info(string.Format("RetrieveAndProcessFiles|filename:{0}|localFilePath:{1}|newRemoteFilePath:{2}", filename, localFilePath, newRemoteFilePath));
                    if (!Directory.Exists(Path.GetDirectoryName(localFilePath)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(localFilePath));
                    }
                    if (File.Exists(localFilePath))
                    {
                        File.Delete(localFilePath);
                        logger.Info(string.Format("RetrieveAndProcessFiles|localFilePath:{0} EXISTED!", localFilePath));
                    }
                    File.Copy(remoteFilePath, localFilePath, true);
                    if (!Directory.Exists(Path.GetDirectoryName(newRemoteFilePath)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(newRemoteFilePath));
                    }
                    if (File.Exists(newRemoteFilePath))
                    {
                        File.Delete(newRemoteFilePath);
                        logger.Info(string.Format("RetrieveAndProcessFiles|newRemoteFilePath:{0} EXISTED!", newRemoteFilePath));
                    }
                    File.Move(remoteFilePath, newRemoteFilePath);

                    mostre.ImportManual(localFilePath);

                    File.Move(newRemoteFilePath, newRemoteFilePath + "_importat" + (DateTime.Now).ToString("yyyyMMddhhmm"));
                    fileProcessed++;
                }
            }
            catch (Exception ex)
            {
                logger.DebugException(string.Format("RetrieveAndProcessFiles|machine:{0}|fromFolder:{1}", machine.Name, fromFolder), ex);
                loggerRezultate.Error("exceptie import: " + machine.Name + "  " + ex.Message + ex.StackTrace);
            }
            return(fileProcessed);
        }
		private int RetrieveAndProcessFiles(Machine machine, string fromFolder, IMostreDB mostre)
		{
			int fileProcessed = 0;
			try
			{
				foreach (string remoteFilePath in Directory.GetFiles(fromFolder, machine.FileFilter))
				{
					string filename = Path.GetFileName(remoteFilePath);
					string localFilePath = Path.Combine(string.Format(machine.LocalSavePathFormat, localServer), filename);
					string newRemoteFilePath = Path.Combine(fromFolder, Constants.FOLDER_REMOTE_PROCESSED_RELATIVE, filename);
					logger.Info(string.Format("RetrieveAndProcessFiles|filename:{0}|localFilePath:{1}|newRemoteFilePath:{2}", filename, localFilePath, newRemoteFilePath));
					if (!Directory.Exists(Path.GetDirectoryName(localFilePath)))
					{
						Directory.CreateDirectory(Path.GetDirectoryName(localFilePath));
					}
					if(File.Exists(localFilePath))
					{
						File.Delete(localFilePath);
						logger.Info(string.Format("RetrieveAndProcessFiles|localFilePath:{0} EXISTED!", localFilePath));
					}
					File.Copy(remoteFilePath, localFilePath, true);
					if (!Directory.Exists(Path.GetDirectoryName(newRemoteFilePath)))
					{
						Directory.CreateDirectory(Path.GetDirectoryName(newRemoteFilePath));
					}
					if (File.Exists(newRemoteFilePath))
					{
						File.Delete(newRemoteFilePath);
						logger.Info(string.Format("RetrieveAndProcessFiles|newRemoteFilePath:{0} EXISTED!", newRemoteFilePath));
					}
					File.Move(remoteFilePath, newRemoteFilePath);

					mostre.ImportManual(localFilePath);

					File.Move(newRemoteFilePath, newRemoteFilePath + "_importat" + (DateTime.Now).ToString("yyyyMMddhhmm"));
					fileProcessed++;
				}
			}
			catch (Exception ex)
			{
				logger.DebugException(string.Format("RetrieveAndProcessFiles|machine:{0}|fromFolder:{1}", machine.Name, fromFolder), ex);
				loggerRezultate.Error("exceptie import: " + machine.Name + "  " + ex.Message + ex.StackTrace);
			}
			return fileProcessed;
		}