Browse Source

UsersImporter up-to-date

main
Inga 🏳‍🌈 11 years ago
parent
commit
3fc84d5627
  1. 2
      Builder/IISMainHandler/build.txt
  2. 6
      FLocal.Migration.Console/Program.cs
  3. 10
      FLocal.Migration.Console/UsersImporter.cs
  4. 10
      FLocal.Migration.Gateway/ShallerConnector.cs

2
Builder/IISMainHandler/build.txt

@ -1 +1 @@ @@ -1 +1 @@
2053
2060

6
FLocal.Migration.Console/Program.cs

@ -25,13 +25,15 @@ namespace FLocal.Migration.Console { @@ -25,13 +25,15 @@ namespace FLocal.Migration.Console {
}
[Action]
public static void ImportUsers() {
public static void ImportUsers(int startFromPage) {
initializeConfig();
try {
UsersImporter.ImportUsers();
UsersImporter.ImportUsers(startFromPage);
} catch(Exception e) {
System.Console.WriteLine(e.GetType().FullName + ": " + e.Message);
System.Console.WriteLine(e.StackTrace);
System.Console.WriteLine("==============");
System.Console.WriteLine(e.ToString());
}
}

10
FLocal.Migration.Console/UsersImporter.cs

@ -11,9 +11,9 @@ using FLocal.Common.actions; @@ -11,9 +11,9 @@ using FLocal.Common.actions;
namespace FLocal.Migration.Console {
class UsersImporter {
public static void ImportUsers() {
public static void ImportUsers(int startFromPage) {
for(int i=1; i<800; i++) {
for(int i=startFromPage; i<1000; i++) {
System.Console.Write("[" + i + "]");
foreach(string userName in ShallerGateway.getUserNames(i)) {
User user;
@ -30,10 +30,12 @@ namespace FLocal.Migration.Console { @@ -30,10 +30,12 @@ namespace FLocal.Migration.Console {
{ User.TableSpec.FIELD_LOCATION, new ScalarFieldValue(userData["location"]) },
{ User.TableSpec.FIELD_SHOWPOSTSTOUSERS, new ScalarFieldValue("All") },
{ User.TableSpec.FIELD_SIGNATURE, new ScalarFieldValue(userData["signature"]) },
{ User.TableSpec.FIELD_SIGNATUREUBB, new ScalarFieldValue(userData["signature"]) },
{ User.TableSpec.FIELD_TITLE, new ScalarFieldValue(userData["title"]) },
{ User.TableSpec.FIELD_TOTALPOSTS, new ScalarFieldValue("0") },
{ User.TableSpec.FIELD_USERGROUPID, new ScalarFieldValue("1") },
{ User.TableSpec.FIELD_BIOGRAPHY, new ScalarFieldValue(userData["biography"]) },
{ User.TableSpec.FIELD_BIOGRAPHYUBB, new ScalarFieldValue(userData["biography"]) },
}
);
AbstractChange addAccount = new InsertChange(
@ -42,6 +44,10 @@ namespace FLocal.Migration.Console { @@ -42,6 +44,10 @@ namespace FLocal.Migration.Console {
{ Account.TableSpec.FIELD_NAME, new ScalarFieldValue(userName.ToLower()) },
{ Account.TableSpec.FIELD_NEEDSMIGRATION, new ScalarFieldValue("1") },
{ Account.TableSpec.FIELD_PASSWORDHASH, new ScalarFieldValue("*") },
{ Account.TableSpec.FIELD_IPADDRESS, new ScalarFieldValue("127.0.0.1") },
{ Account.TableSpec.FIELD_ISSTATUSHIDDEN, new ScalarFieldValue("0") },
{ Account.TableSpec.FIELD_ISDETAILEDSTATUSHIDDEN, new ScalarFieldValue("0") },
{ Account.TableSpec.FIELD_REGISTRATIONEMAIL, new ScalarFieldValue("migra@te.d") },
{ Account.TableSpec.FIELD_USERID, new ReferenceFieldValue(addUser) },
}
);

10
FLocal.Migration.Gateway/ShallerConnector.cs

@ -13,6 +13,14 @@ namespace FLocal.Migration.Gateway { @@ -13,6 +13,14 @@ namespace FLocal.Migration.Gateway {
public static readonly Encoding encoding = Encoding.GetEncoding(1251);
private const int BUFFER = 1024;
private static HttpWebResponse TryGetResponse(HttpWebRequest request) {
try {
return (HttpWebResponse)request.GetResponse();
} catch(WebException e) {
throw new ApplicationException("Unable to load " + request.Address, e);
}
}
public static FileInfo getPageInfo(string requestUrl, Dictionary<string, string> postData, CookieContainer cookies) {
string baseUrl = ConfigurationManager.AppSettings["Importer_BaseUrl"];
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseUrl + requestUrl);
@ -43,7 +51,7 @@ namespace FLocal.Migration.Gateway { @@ -43,7 +51,7 @@ namespace FLocal.Migration.Gateway {
stream.Close();
}
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; FDM; .NET4.0C; .NET4.0E)";
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
using(HttpWebResponse response = TryGetResponse(request)) {
cookies.Add(response.Cookies);
byte[] content;

Loading…
Cancel
Save