Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[已解决] 如何将dvbbs的短消息导入到discuz

[复制链接]
开心27375 发表于 2014-2-9 13:38:20 | 显示全部楼层 |阅读模式
由于官方提供的程序不可用,或者报错导致中止,
所以我现在是自己用asp.net写程序,将数据转移到discuz的数据库中。

用户数据和主题数据都转换好了,用户之间的短消息数据转换有点麻烦。
谁对官方3.1的程序比较熟悉,要如何将数据写到数据库?
我自己不懂php
baxter 发表于 2014-2-9 15:21:53 | 显示全部楼层
用官方的程序转换一下DV短消息这步到DZ就可以了
回复

使用道具 举报

 楼主| 开心27375 发表于 2014-2-9 18:35:42 | 显示全部楼层

  1.     public void SaveMessage(string FromUserName,int FromUID, int ToUID, string Title,string Message, DateTime sendtime) {
  2.         Title = Data.Filter(Title);
  3.         Message = Data.Filter(Message);
  4.         FromUserName = Data.Filter(FromUserName);
  5.         string value = ToUID.ToString()+"_"+FromUID.ToString();
  6.         long basetime=Discuz.MyMath.GetPhpTime(sendtime);
  7.         string LastMessage="a:3:{s:12:"lastauthorid";s:1:""+FromUID.ToString()+"";s:10:"lastauthor";s:15:""+FromUserName+"";s:11:"lastsummary";s:"+(Title.Length+10).ToString()+":""+Message+"";}";
  8.         int Plid=0;

  9.         Data.MySqlDataVisit mysql=new Data.MySqlDataVisit("Discuz");
  10.         if (Plid == 0)
  11.         {
  12.             mysql.Sql = "INSERT INTO pre_ucenter_pm_lists(authorid, pmtype, subject, members, min_max, dateline, lastmessage) VALUES('" + FromUID.ToString() + "', '1', '" + Title + "', 2, '" + value + "', '" + basetime + "', '" + LastMessage + "')";
  13.             mysql.Execute();

  14.             mysql.Sql = "Select max(Plid) from pre_ucenter_pm_lists";
  15.             Plid = mysql.SelectFirstInt();

  16.             mysql.Sql = "INSERT INTO pre_ucenter_pm_indexes(plid) VALUES('" + Plid.ToString() + "')";
  17.             mysql.Execute();

  18.             mysql.Sql = "Select max(Pmid) from pre_ucenter_pm_indexes";
  19.             int Pmid = mysql.SelectFirstInt();

  20.             mysql.Sql = "INSERT INTO " + getposttablename(Plid) + "(pmid, plid, authorid, message, dateline, delstatus) VALUES('" + Pmid.ToString() + "', '" + Plid.ToString() + "', '" + FromUID.ToString() + "', '" + Message + "', '" + basetime.ToString() + "', 0)";
  21.             mysql.Execute();
  22.             mysql.Sql = "INSERT INTO pre_ucenter_pm_members(plid, uid, isnew, pmnum, lastupdate, lastdateline) VALUES('" + Plid.ToString() + "', '" + ToUID.ToString() + "', '1', '1', '0', '" + basetime.ToString() + "')";
  23.             mysql.Execute();
  24.             mysql.Sql = "INSERT INTO pre_ucenter_pm_members(plid, uid, isnew, pmnum, lastupdate, lastdateline) VALUES('" + Plid.ToString() + "', '" + FromUID.ToString() + "', '0', '1', '" + basetime.ToString() + "', '" + basetime.ToString() + "')";
  25.             mysql.Execute();
  26.         }
  27.         else
  28.         {
  29.             mysql.Sql = "INSERT INTO pre_ucenter_pm_indexes(plid) VALUES('" + Plid.ToString() + "')";
  30.             mysql.Execute();
  31.             mysql.Sql = "Select max(Pmid) from pre_ucenter_pm_indexes";
  32.             int Pmid = mysql.SelectFirstInt();
  33.             mysql.Sql = "INSERT INTO pre_ucenter_"+getposttablename(Plid)+"(pmid, plid, authorid, message, dateline, delstatus) VALUES('" + Pmid.ToString() + "', '" + Plid.ToString() + "', '" + FromUID.ToString() + "', '" + Message + "', '" + basetime.ToString() + "', 0)";
  34.                         mysql.Execute();               
  35.             mysql.Sql = "INSERT INTO pre_ucenter_pm_members(plid, uid, isnew, pmnum, lastupdate, lastdateline) VALUES('" + Plid.ToString() + "', '"+ToUID.ToString()+"', '1', '1', '0', '" + basetime.ToString() + "')";
  36.                         mysql.Execute();
  37.             if(!mysql.IsHaveErrorPrivate) {
  38.                             mysql.Sql = "UPDATE pre_ucenter_pm_members SET isnew=1, pmnum=pmnum+1, lastdateline='" + basetime.ToString() + "' WHERE plid='" + Plid.ToString() + "' AND uid='"+ToUID.ToString()+"'";
  39.                             mysql.Execute();
  40.             }
  41.                         mysql.Sql = "INSERT INTO pre_ucenter_pm_members(plid, uid, isnew, pmnum, lastupdate, lastdateline) VALUES('" + Plid.ToString() + "', '" + FromUID.ToString() + "', '0', '1', '" + basetime.ToString() + "', '" + basetime.ToString() + "')";
  42.                         mysql.Execute();               
  43.             if(!!mysql.IsHaveErrorPrivate) {
  44.                                 mysql.Sql = "UPDATE pre_ucenter_pm_members SET isnew=0, pmnum=pmnum+1, lastupdate='" + basetime.ToString() + "', lastdateline='" + basetime.ToString() + "' WHERE plid='" + Plid.ToString() + "' AND uid='" + FromUID.ToString() + "'";
  45.                 mysql.Execute();               
  46.             }

  47.                         mysql.Sql = "UPDATE pre_ucenter_pm_lists SET lastmessage='"+LastMessage+"' WHERE plid='" + Plid.ToString() + "'";
  48.             mysql.Execute();               
  49.         }
  50.     }

  51.     public string getposttablename(int id)
  52.     {
  53.         string str = id.ToString();
  54.         string tableid = str.Substring(str.Length-1, 1);
  55.         return "pre_ucenter_pm_messages_" + tableid;
  56.     }
复制代码
回复

使用道具 举报

 楼主| 开心27375 发表于 2014-2-9 18:38:43 | 显示全部楼层
自己动手转换了一下
可以看到别人给自己发的消息了,但是别人发给我的消息看不到
我估计是:
  1. string LastMessage="a:3:{s:12:"lastauthorid";s:1:""+FromUID.ToString()+"";s:10:"lastauthor";s:15:""+FromUserName+"";s:11:"lastsummary";s:"+(Title.Length+10).ToString()+":""+Message+"";}";
复制代码
这里模拟
  1. $lastmessage = array('lastauthorid' => $fromuid, 'lastauthor' => $fromusername, 'lastsummary' => $lastsummary);
复制代码
出错了
回复

使用道具 举报

crx349 发表于 2014-2-17 16:44:39 来自手机 | 显示全部楼层
dvbbs可以转化的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-6-2 04:32 , Processed in 0.136701 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表