admin
export af forum poster er klar
af
d 5 Oct 2008 kl 11:39 (550 Visninger)
så mangler vi at lave trådene førend man vil kunne se alle posterne og via hovedmenuen/forumoversigten., som er en slags indholdsfortegnelse for forum posterne, koden til at lave poster se sådan ud, da vores forum er hjemmestrikket kan man ikke bruge bruge standardværktøjer så det er skrevet i hånden:
using System;
using System.IO;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace forumexport
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
/// vbulletin field pos , threadid, seqnr, parentid-hovedtråd.
int postid = 0;
int threadid = 1;
int parentid = 2;
int username = 03;
int userid = 04;
int title = 05;
int dateline = 06;
int pagetext = 07;
int allowsmilie = 08;
int showsignature = 09;
int ipaddress = 10;
int iconid = 11;
int visible = 12;
int attach = 13;
int infraction = 14;
int reportthreadid = 15;
/// importfile/data field count
int MessageID = 00;
;
// vbulleting def
string[] arInfo = new string[16];
char[] splitter = { ';' };
StreamWriter sw = new StreamWriter("post.txt",false,Encoding.GetEncoding ("utf-8"));
OleDbConnection Myconnection = null;
OleDbDataReader dbReader = null;
Myconnection = new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source=C:\www.club-corvette.dk\databases\forum.mdb");
Myconnection.Open();
OleDbCommand cmd = Myconnection.CreateCommand();
cmd.CommandText = "SELECT DISTINCT tblMessages.*, tblUsers.UserName, Vbulletin.userid FROM (tblUsers LEFT JOIN Vbulletin ON tblUsers.EmailAddress = Vbulletin.email) INNER JOIN tblMessages ON tblUsers.ID = tblMessages.User_ID ORDER BY tblMessages.MessageID;";
dbReader = cmd.ExecuteReader();
string tmp;
Int32 Intpostid = 1000;
string StrZero = "0";
string singlequote = "'";
string doublequote = "\"";
while(dbReader.Read())
{
arInfo[postid] = Intpostid.ToString();
arInfo[threadid] = add1000((string)dbReader.GetValue(MessageID).ToStr ing());
arInfo[parentid] = add1000((string)dbReader.GetValue(12).ToString());
arInfo[userid] = dbReader.GetValue(15).ToString();
arInfo[dateline] = convertdate((string)dbReader.GetValue(4).ToString( ));
arInfo[title] = (string)dbReader.GetValue(6).ToString();
arInfo[pagetext] = (string)dbReader.GetValue(7).ToString();
arInfo[username] = (string)dbReader.GetValue(14).ToString();
arInfo[reportthreadid] = StrZero;
arInfo[infraction] = StrZero;
arInfo[attach] = StrZero;
arInfo[visible] = "1";
arInfo[iconid] = StrZero;
arInfo[ipaddress] = StrZero;
arInfo[allowsmilie] = "1";
arInfo[showsignature] = StrZero;
// enclose strings in double quotes, convert double quotes in text to single quotes.
for (int i = 0; i < 16; i++)
{
tmp = arInfo[i];
tmp = tmp.Replace(doublequote, singlequote);
tmp = '"' + tmp + '"';
// tmp = tmp.Replace("\"", "\\\"");
arInfo[i] = tmp;
}
sw.WriteLine(String.Join(@";", arInfo));
Intpostid++;
if (Intpostid > 1010) break;
}
dbReader.Close();
Myconnection.Close();
sw.Close();
return;
}
public static string convertdate(string inputdate)
{
String s = "";
if (inputdate.Length > 0)
{
DateTime UnixBegin = new DateTime(1970, 1, 1);
DateTime outputdate = DateTime.Parse(inputdate);
long elapsedTicks = outputdate.Ticks - UnixBegin.Ticks;
TimeSpan elapsedSpan = new TimeSpan(elapsedTicks);
double numberofseconds = elapsedSpan.TotalSeconds;
s = numberofseconds.ToString();
}
return s;
}
public static string add1000(string inputstring)
{
int x = 0;
if (inputstring.Length>0)
{
x = (Int32.Parse(inputstring)) + 1000;
}
return x.ToString();
}
}
}


: