how to handle multiple uploads? - vb.net

I'm writing a program that can upload files to multiple FTP servers.
There is a table, at the top row there are the sites, and at the far left column there are the files. through this table I define what should be uploaded to where.
the program is already working, but what i want to do now is to upload the files parallely on each site. so when i hit start each column will go through the rows on its own and upload the files to that site if the content of the specific cell says so. sites can be any number between 1 and 50. and all uploads should be in parallel. (one file at the time for each site)
what i am asking is what is the best way to handle such thing? i know i have to set up multiple uploaders, but what is confusing me is how to keep track what each site is doing. the only thing i can come up with is an array of arrays. where each position is for a site, and the array at that position defines what file is beeing uploaded and all the informations it needs for that. would that be a good solution?
thanks!

You can put your data into array then use for loop
use this code
$web = ['www.firstSite.com','www.secondSite.com']
$user = ['firstUser','secondUser']
$pass = ['firstPass','secondPass']
for($i=0;$i<sizeof($web);$i++)
{
$conn_id = ftp_connect($web[$i]);
$login_result = ftp_login($conn_id,$user[$i],$pass[$i]);
if (ftp_put($conn_id, $server_file, $local_file, FTP_BINARY))
{echo "Success";}
else {echo "Failed";}
}

You can make a custom class and use a List(Of SiteFiles) for a collection of them. You iterate the sites data and create a new SiteFiles object for each site and add the files names to the Files property that need to be uploaded to that site. Then when your done making this List(Of SiteFiles) then you can iterate each file in SiteFiles.Files for each SiteFiles object and use threading/async methods if needed and upload the files. This gives you a neat and tidy way to organize what your doing.
Public Class SiteFiles
Public Property Site As String
Public Property Files As New List(Of String)
End Class

Related

Is there a way to list the directories in a using PySpark in a notebook?

I'm trying to see every file is a certain directory, but since each file in the directory is very large, I can't use sc.wholeTextfile or sc.textfile. I wanted to just get the filenames from them, and then pull the file if needed in a different cell. I can access the files just fine using Cyberduck and it shows the names on there.
Ex: I have the link for one set of data at "name:///mainfolder/date/sectionsofdate/indiviual_files.gz", and it works, But I want to see the names of the files in "/mainfolder/date" and in "/mainfolder/date/sectionsofdate" without having to load them all in via sc.textFile or sc.Wholetextfile. Both those functions work, so I know my keys are correct, but it takes too long for them to be loaded.
Considering that the list of files can be retrieve by one single node, you can just list the files in the directory. Look at this response.
wholeTextFiles returns a tuple (path, content) but I don't know if the file content is lazy to get only the first part of the tuple.

ruby on rails AWS-S3 list files in a bucket

I have a select box the I wish to fill with filenames from a clients S3 bucket.
In my controller I set the variable as this:
#files = AWS::S3::Bucket.find("clientsbucket").objects
which when called in the view as options_for_select(#files) gives a list of objects but in the format of <AWS::S3::Object:0x4f9e5b8>, <AWS::S3::Object:0x4f9e5a0> etc
For the life of me I cant figure out how to list the filename instead of this object info?
Any help muchly appreciated
Well, access the key property of the each object in the view!
key property is the entire path to the file in the bucket.
objects.each do |object|
= object.key
Even though the AWS SDK Documentation isn't as informative try and dig around..
Use the as_tree method on the objects so you can get the specific data you want.
http://docs.amazonwebservices.com/AWSRubySDK/latest/AWS/S3/Tree.html
Good luck!!

Getting the data from backend to display it on Front end in X-CART

I am working on a X-Cart Module. I need the backend configuration values to the front end. In admin/configuration file I have created an array which contains the value which I need to use it in adv_search.php which is in the root folder. I don't know how to pass that array to adv_search.php.
Thanks in advance.
It is not quite clear how you store the configuration values. It may be easier to store them in the table xcart_config and access them directly as $config['Option-category']['option_name'] in php files and {$config.Option-category.option_name} in the Smarty-templates.
Or just define an array in module's config.php file and this array will be available everywhere in php-scripts. Look at the modules/UPS_OnLine_Tools/config.php file for example.

Connection strings for different users

How do I send two users coming from different company domains to different SQL databases to retrieve/store data? I use Application variables to store the connection strings and the Request.ServerVariables("LOGON_USER") variable is an effective way to get the domain name. Is the GLOBAL.AsA file to be modified? The table names are exactly the same in both databases, so I think changing the connection strings based on the user domain should do the trick.
User A with domain ABC --> Application("ConnecttoDB") send to database A
User B with domain XYZ --> Application("ConnecttoDB") send to database B
I have roughly 900+ classic ASP pages so I would really hate to add a bunch of IF-THEN's to choose the correct database in each page. All ideas are greatly appreciated!
UPDATE: To make things simple I'm envisioning one single Application variable (i.e.: ConnecttoDB) However, wouldn't its value be constantly changing every time a different user gets access and altering page results?
You can't use an Application variable since that's shared across all users. This would be a race condition. Instead you'll need to use the Session object to store the connection and then use that whenever you need to connect to the DB.
myDB=Server.CreateObject("ADODB.Connection")
StrConn = Session("ConnecttoDB")
myDB.Open StrConn
Here's one way of doing it:
I'm guessing that your classes for your web page codebehind files inheit the Page class. Create a new class file in your ASP.net project that inherits Page. Call it JorgePage. Then, make your codebehind file classes inherit JorgePage.
In JorgePage, write two functions:
private string getUsersDomain()
{
// returns the user's domain
}
protected string getUsersConnectionString()
{
switch (getUsersDomain().ToUpper())
{
case "ABC":
return Application("ConnecttoDB_ABC");
break;
case "xYZ":
return Application("ConnecttoDB_XYZ");
break;
}
}
Now, the function getUsersConnectionString() is available in the context of all your pages and returns the correct connection string. Furthermore, you have the code in only one place, so if you need to change the logic later, you can do so easily.
Given that you're using classic ASP, you can define a function to return the appropriate connection string in another .asp file and use the #include directive to add it to all your pages.

Create files using list of filenames and add content to each

I need to make a bunch of redirect pages as I've recently updated my web site which previously used .html files and now all the files are .aspx. I have a tab-delimited file containing a list of original filenames and the corresponding new filename.
It seems like there should be a language out there that I should be able to create a file using the first column for the filename and insert the second column as its content with some additional text for the 301 redirect.
Could someone point me in the right direction as to what language(s) would be able to accomplish this? Also, if you could also point out the name of the method/function I would be using so I know where to begin when creating the file.
I've needed to do this type of thing many times and am willing to learn a new language (Perl, Python, or whatever) to accomplish this, but I just need pointed in the right direction. I am using Windows XP to develop on.
Thank you for your time.
This can be done in a few lines of C# if you already are working with aspx you can process this in the codebehind on a dummy page.
System.IO.StreamReader myreader = new System.IO.StreamReader(Server.MapPath("~/Text.txt"));
while (!myreader.EndOfStream)
{
//9 is Ascii value of Tab bad idea to split if the second set of values might contain tabs but can reconstruct the data if inputString.length >2
string[] inputString = myreader.ReadLine().Split(char.ConvertFromUtf32(9).ToCharArray());
//construct the path to where you want to save the file, or if the filename is the full path all the better
System.IO.StreamWriter filemaker = new System.IO.StreamWriter(#"C:\" + inputString[0]);
filemaker.Write(inputString[1]);
filemaker.Close();
}