示例#1
0
    void NumRes(Message message)
    {
        DBinfo datas = (DBinfo)message;

        FrameB   = datas.FrameB;
        FrameT   = datas.FrameT;
        TimeB    = datas.TimeB;
        TimeT    = datas.TimeT;
        id       = datas.id;
        Xmin     = datas.Xmin;
        Ymin     = datas.Ymin;
        Width    = datas.Width;
        Height   = datas.Height;
        Depth    = datas.Depth;
        Yobi     = datas.Yobi;
        YobiYobi = datas.YobiYobi;
        cnt      = datas.cnt;

        MaxTime = 0;
        MinTime = 0;



        num_check_topic = true;
    }
示例#2
0
    void Start()
    {
        please_data = "0";
        message     = new DBinfo();
        transI      = new TransformInfo();
        newPlane    = new GameObject[6]; //物体の画像が貼られるPlane
        newPlane[0] = newPlane0;
        newPlane[1] = newPlane1;
        newPlane[2] = newPlane2;
        newPlane[3] = newPlane3;
        newPlane[4] = newPlane4;
        newPlane[5] = newPlane5;



        dbsub = this.GetComponent <DBsubscriber>();
        px    = new float[10];
        py    = new float[10];
        pz    = new float[10];
        rx    = new float[10];
        ry    = new float[10];
        rz    = new float[10];
        sx    = new float[10];
        sy    = new float[10];
        sz    = new float[10];

        Invoke("Init", 1.0f);
    }
示例#3
0
    void NumRes(Message message)
    {
        DBinfo datas = (DBinfo)message;

        //Frame = datas.Frame;
        id     = datas.id;
        Xmin   = datas.Xmin;
        Ymin   = datas.Ymin;
        Width  = datas.Width;
        Height = datas.Height;
        Depth  = datas.Depth;
        //WhatNo = datas.WhatNo;
        cnt = datas.cnt;


        num_check_topic = true;
    }
示例#4
0
 public DBinfoDAL(DBinfo dbinfo)
 {
     db = dbinfo;
     ConnectionString = "server = " + dbinfo.DBip + "; user id = " + dbinfo.Uid + "; password = "******"; database = " + dbinfo.DBname + "";
 }
示例#5
0
文件: DBInfoBLL.cs 项目: korreny/MVC
 public DBInfoBLL(DBinfo db)
 {
     dbinfo = db;
 }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="caches"></param>
        /// <param name="striphtml"></param>
        /// <param name="doc"></param>
        /// <param name="dbi"></param>
        public void InsertGeocaches(List <Geocache> caches, bool striphtml, HtmlAgilityPack.HtmlDocument doc, ref DBinfo dbi)
        {
            List <Waypoint> wpts = new List <Waypoint>();
            List <CacheLog> logs = new List <CacheLog>();
            Dictionary <String, Tuple <String, String> > tbs = new Dictionary <string, Tuple <string, string> >();

            using (SQLiteConnection con = new SQLiteConnection(_dbpath))
            {
                con.Open();
                using (SQLiteCommand cmd = new SQLiteCommand(con))
                {
                    // Prepare transaction
                    SQLiteTransaction transaction = con.BeginTransaction();

                    cmd.CommandText =
                        @"INSERT OR REPLACE INTO GeocacheFull(
Code,
CacheID,
Name,
Type,
Latitude,
Longitude,
Difficulty,
Terrain,
Owner,
OwnerId,
PlacedBy,
DateCreation,
ShortDescription,
LongDescription,
ShortDescriptionAsHTML,
LongDescriptionAsHTML,
Available,
Archived,
Container,
Hint,
Found,
AttributesIds,
AttributesStatus,
LogIds,
WaypointsIds,
TBIds,
Country,
State,
DateExport,
Owned
) VALUES(
@Code,
@CacheID,
@Name,
@Type,
@Latitude,
@Longitude,
@Difficulty,
@Terrain,
@Owner,
@OwnerId,
@PlacedBy,
@DateCreation,
@ShortDescription,
@LongDescription,
@ShortDescriptionAsHTML,
@LongDescriptionAsHTML,
@Available,
@Archived,
@Container,
@Hint,
@Found,
@AttributesIds,
@AttributesStatus,
@LogIds,
@WaypointsIds,
@TBIds,
@Country,
@State,
@DateExport,
@Owned
)";
                    cmd.Parameters.AddWithValue("@Code", "");
                    cmd.Parameters.AddWithValue("@CacheID", "");
                    cmd.Parameters.AddWithValue("@Name", "");
                    cmd.Parameters.AddWithValue("@Type", "");
                    cmd.Parameters.AddWithValue("@Latitude", 0.0);
                    cmd.Parameters.AddWithValue("@Longitude", 0.0);
                    cmd.Parameters.AddWithValue("@Difficulty", "");
                    cmd.Parameters.AddWithValue("@Terrain", "");
                    cmd.Parameters.AddWithValue("@Owner", "");
                    cmd.Parameters.AddWithValue("@OwnerId", "");
                    cmd.Parameters.AddWithValue("@PlacedBy", "");
                    cmd.Parameters.AddWithValue("@DateCreation", "");
                    cmd.Parameters.AddWithValue("@ShortDescription", "");
                    cmd.Parameters.AddWithValue("@LongDescription", "");
                    cmd.Parameters.AddWithValue("@ShortDescriptionAsHTML", false);
                    cmd.Parameters.AddWithValue("@LongDescriptionAsHTML", false);
                    cmd.Parameters.AddWithValue("@Available", false);
                    cmd.Parameters.AddWithValue("@Archived", false);
                    cmd.Parameters.AddWithValue("@Container", "");
                    cmd.Parameters.AddWithValue("@Hint", "");
                    cmd.Parameters.AddWithValue("@Found", false);
                    cmd.Parameters.AddWithValue("@AttributesIds", "");
                    cmd.Parameters.AddWithValue("@AttributesStatus", "");
                    cmd.Parameters.AddWithValue("@LogIds", "");
                    cmd.Parameters.AddWithValue("@WaypointsIds", "");
                    cmd.Parameters.AddWithValue("@TBIds", "");
                    cmd.Parameters.AddWithValue("@Country", "");
                    cmd.Parameters.AddWithValue("@State", "");
                    cmd.Parameters.AddWithValue("@DateExport", "");
                    cmd.Parameters.AddWithValue("@Owned", false);


                    foreach (Geocache geo in caches)
                    {
                        // Area
                        if (geo._dLatitude < dbi.latmin)
                        {
                            dbi.latmin = geo._dLatitude;
                        }
                        if (geo._dLatitude > dbi.latmax)
                        {
                            dbi.latmax = geo._dLatitude;
                        }
                        if (geo._dLongitude < dbi.lonmin)
                        {
                            dbi.lonmin = geo._dLongitude;
                        }
                        if (geo._dLongitude > dbi.lonmax)
                        {
                            dbi.lonmax = geo._dLongitude;
                        }

                        // Insert values using preparedcommands
                        cmd.Parameters["@Code"].Value         = geo._Code;
                        cmd.Parameters["@CacheID"].Value      = geo._CacheId;
                        cmd.Parameters["@Name"].Value         = (striphtml)?MyTools.StripHtmlTags(geo._Name, doc):geo._Name;
                        cmd.Parameters["@Type"].Value         = geo._Type;
                        cmd.Parameters["@Latitude"].Value     = geo._dLatitude;
                        cmd.Parameters["@Longitude"].Value    = geo._dLongitude;
                        cmd.Parameters["@Difficulty"].Value   = geo._D;
                        cmd.Parameters["@Terrain"].Value      = geo._T;
                        cmd.Parameters["@Owner"].Value        = geo._Owner;
                        cmd.Parameters["@OwnerId"].Value      = geo._OwnerId;
                        cmd.Parameters["@PlacedBy"].Value     = geo._PlacedBy;
                        cmd.Parameters["@DateCreation"].Value = geo._DateCreation;

                        if (striphtml)
                        {
                            cmd.Parameters["@ShortDescription"].Value       = (striphtml)?MyTools.StripHtmlTags(geo._ShortDescription, doc):geo._ShortDescription;
                            cmd.Parameters["@LongDescription"].Value        = (striphtml)?MyTools.StripHtmlTags(geo._LongDescription, doc):geo._LongDescription;
                            cmd.Parameters["@ShortDescriptionAsHTML"].Value = "False";
                            cmd.Parameters["@LongDescriptionAsHTML"].Value  = "False";
                        }
                        else
                        {
                            cmd.Parameters["@ShortDescription"].Value       = geo._ShortDescription;
                            cmd.Parameters["@LongDescription"].Value        = geo._LongDescription;
                            cmd.Parameters["@ShortDescriptionAsHTML"].Value = (geo._ShortDescHTML == "True");
                            cmd.Parameters["@LongDescriptionAsHTML"].Value  = (geo._LongDescHTML == "True");
                        }

                        cmd.Parameters["@Available"].Value     = (geo._Available == "True");
                        cmd.Parameters["@Archived"].Value      = (geo._Archived == "True");;
                        cmd.Parameters["@Container"].Value     = geo._Container;
                        cmd.Parameters["@Hint"].Value          = (striphtml)?MyTools.StripHtmlTags(geo._Hint, doc):geo._Hint;
                        cmd.Parameters["@Found"].Value         = geo.IsFound();
                        cmd.Parameters["@AttributesIds"].Value = "";
                        foreach (String s in geo._listAttributesId)
                        {
                            cmd.Parameters["@AttributesIds"].Value += s + ";";
                        }
                        cmd.Parameters["@AttributesStatus"].Value = "";
                        foreach (String s in geo._Attributes)
                        {
                            cmd.Parameters["@AttributesStatus"].Value += s + ";";
                        }
                        cmd.Parameters["@LogIds"].Value = "";
                        foreach (CacheLog log in geo._Logs)
                        {
                            cmd.Parameters["@LogIds"].Value += log._LogId + ",";
                            logs.Add(log);
                        }
                        cmd.Parameters["@WaypointsIds"].Value = "";
// Standard waypoints
                        foreach (KeyValuePair <String, Waypoint> pair in geo._waypoints)
                        {
                            cmd.Parameters["@WaypointsIds"].Value += pair.Value._name + ",";
                            wpts.Add(pair.Value);
                        }
// MGM waypoints
                        foreach (KeyValuePair <String, Waypoint> pair in geo._waypointsFromMGM)
                        {
                            cmd.Parameters["@WaypointsIds"].Value += pair.Value._name + ",";
                            wpts.Add(pair.Value);
                        }

                        cmd.Parameters["@TBIds"].Value = "";
                        int    i   = 0;
                        String sid = "";
                        foreach (KeyValuePair <String, String> att in geo._listTB)
                        {
                            sid = geo._listTBId[i];
                            cmd.Parameters["@TBIds"].Value += sid + ",";
                            if (!tbs.ContainsKey(sid))
                            {
                                tbs.Add(sid, new Tuple <String, String>(att.Key, att.Value));
                            }
                            i++;
                        }

                        cmd.Parameters["@Country"].Value    = geo._Country;
                        cmd.Parameters["@State"].Value      = geo._State;
                        cmd.Parameters["@DateExport"].Value = geo._DateExport;
                        cmd.Parameters["@Owned"].Value      = geo._bOwned;
                        cmd.ExecuteNonQuery();
                    }

                    // en transaction
                    transaction.Commit();
                }
                con.Close();
            }

            InsertLogs(logs, striphtml, doc);
            InsertWaypoints(wpts, striphtml, doc);
            InsertTBs(tbs);
            InsertArea(dbi.latmin, dbi.latmax, dbi.lonmin, dbi.lonmax);
        }
示例#7
0
文件: TaskAction.cs 项目: korreny/MVC
        /// <summary>
        /// 定时器委托任务 调用的方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        public static void SetContent(object source, System.Timers.ElapsedEventArgs e)
        {
            if (DateTime.Now.ToString("HH:mm:ss") == StratTime)
            {
                DateTime startTime = DateTime.Now;
                ProMaintain.Writelog("===========================================================");
                //记录表中最大的tid
                int maxtid = 0;

                Hwdbapi hwdbapi = new Hwdbapi();
                DBinfo  dbinfo  = new DBinfo(Convert.ToInt32(ConfigurationManager.AppSettings["DBtype"]), ConfigurationManager.AppSettings["DBIp"], ConfigurationManager.AppSettings["DBUid"], ConfigurationManager.AppSettings["DBPwd"], ConfigurationManager.AppSettings["DBname"]);//存放数据信息
                DBInfoBLL.dbinfo = dbinfo;
                DBInfoBLL  dbbll = new DBInfoBLL(dbinfo);
                HwdbapiBLL hwbll = new HwdbapiBLL();
                //判断表的状态
                DataTable dt = hwbll.GetTableType(ConfigurationManager.AppSettings["ResultTableName"]);

                try
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string tName = dt.Rows[i][0].ToString();
                        if (dt.Rows.Count == 22 && (tName == "Id" || tName == "TableId" || tName == "EnTableName" || tName == "CnTableName" || tName == "Field" || tName == "Type" || tName == "Name" || tName == "Remark" || tName == "IsDelete" || tName == "CreateTime" || tName == "ReviseTime" || tName == "AuditorName" || tName == "IsPass" ||
                                                    tName == "AuditorId" || tName == "AuditorIp" || tName == "AuditorMac" || tName == "PassTime" || tName == "SubmitterId" || tName == "SubmitterName" || tName == "SubmitterIp" || tName == "SubmitterMac" || tName == "SubmitTime"
                                                    ))
                        {
                        }
                        else
                        {
                            //创建表
                            // 1修改配置文件
                            AppConfigHelper.ModifyAppSettings("ResultTableName", ConfigurationManager.AppSettings["ResultTableName"] + "_bak");
                            ProMaintain.ChangeConfiguration("ResultTableName", ConfigurationManager.AppSettings["ResultTableName"]);
                            ProMaintain.Writelog(DateTime.Now + "\r\n输出的表字段有误,创建表:" + ConfigurationManager.AppSettings["ResultTableName"]);
                            hwbll.CreateTable(ConfigurationManager.AppSettings["ResultTableName"]);
                            break;
                        }
                    }
                }
                catch (System.NullReferenceException ex)
                {
                    ProMaintain.Writelog(DateTime.Now + "\r\n输出的表不存在,创建表:" + ConfigurationManager.AppSettings["ResultTableName"]);
                    hwbll.CreateTable(ConfigurationManager.AppSettings["ResultTableName"]);
                }
                try
                {
                    if (dt.Rows.Count == 0)
                    {
                        ProMaintain.Writelog(DateTime.Now + "\r\n输出的表不存在,创建表:" + ConfigurationManager.AppSettings["ResultTableName"]);
                        hwbll.CreateTable(ConfigurationManager.AppSettings["ResultTableName"]);
                    }
                }
                catch (System.NullReferenceException ex)
                {
                    ProMaintain.Writelog(DateTime.Now + "创建表失败,本次终止");
                    return;
                }
                try
                {
                    //寻找表中最大是ID号
                    maxtid = Convert.ToInt32(hwbll.FindMaxId().Rows[0][0].ToString());
                }
                catch (Exception ex)
                {
                    maxtid = 0;
                }

                DataTable tables = dbbll.GetTables();//获取表的集合

                if (tables == null)
                {
                    ProMaintain.Writelog(DateTime.Now + "\r\n数据连接失败,正在重新获取...");
                    //数据库不存在
                    //return;
                }

                //设置超过50张表就分进度写日志
                int outflage = -1;
                int CurCount = 0;
                if (tables.Rows.Count > 50)
                {
                    outflage = 0;
                }
                int tableCount = tables.Rows.Count;

                //开始处理表
                ProMaintain.Writelog(DateTime.Now + "\r\n开始处理表");
                for (int i = 0; i < tables.Rows.Count; i++)
                {
                    CurCount++;
                    if (outflage > -1)
                    {
                        if (50 / ++outflage == 0)
                        {
                            outflage = 0;
                            double percent = (double)CurCount / tables.Rows.Count;
                            ProMaintain.Writelog(DateTime.Now + "共" + tableCount + "张表,已经处理" + percent.ToString("0.0%") + "剩余" + (tableCount - CurCount).ToString() + "张表");
                        }
                    }
                    hwbll.SetDel(tables.Rows[i][2].ToString());

                    //判断是否有格式如:tablename11,tablename12的表名
                    string tableName = tables.Rows[i][2].ToString();
                    string s         = "^\\D+\\d{1,2}$";
                    //;
                    if (Regex.IsMatch(tableName, s))
                    {
                        for (int k = 0; k < tables.Rows.Count; k++)
                        {
                            if ((tables.Rows[i][2].ToString().IndexOf(tables.Rows[k][2].ToString()) == 0 && k != i))
                            {
                                //有的话则处理一下
                                tables.Rows.RemoveAt(i);
                                break;
                            }
                        }
                        continue;
                        //  break;
                    }
                    int tid = ++maxtid;

                    DataTable tableType = dbbll.GetTableType(tables.Rows[i][2].ToString());
                    //遍历表
                    try
                    {
                        for (int j = 0; j < tableType.Rows.Count; j++)
                        {
                            hwdbapi.EnTableName = tables.Rows[i][2].ToString();
                            hwdbapi.Field       = tableType.Rows[j][0].ToString();
                            hwdbapi.Type        = tableType.Rows[j][1].ToString();
                            hwdbapi.Tableid     = tid;
                            hwdbapi.ReviseTime  = null;
                            hwdbapi.IsDelete    = 0;
                            int?res = hwbll.UpDate(hwdbapi);
                            if (res == 0 || res == null)
                            {
                                //获取当前表的id
                                try
                                {
                                    hwdbapi.Tableid = Convert.ToInt32(hwbll.SelectBytid(tables.Rows[i][2].ToString()).Rows[0][0].ToString());
                                }
                                catch (Exception ex)
                                {
                                    //当获取出错的时候,就是数据库中没有的表
                                }
                                hwdbapi.CreateTime = DateToString.Tostr(DateTime.Now);
                                hwbll.Insert(hwdbapi);
                            }
                        }
                        try
                        {
                            //处理完成
                        }
                        catch (Exception ex)
                        {
                            break;
                            //在datetable用已经删除
                            //直接忽略
                        }
                    }catch (System.NullReferenceException ex)
                    {
                        ProMaintain.Writelog("表" + tables.Rows[i][2].ToString() + "处理异常,可能表中不存在数据");
                    }
                }
                //结束时间
                DateTime endTime = DateTime.Now;

                System.TimeSpan t3         = endTime - startTime;
                double          getSeconds = t3.TotalSeconds;
                ProMaintain.Writelog(DateTime.Now + "共" + tableCount + "张表,已处理100%\r\n" + "本次执行完毕,本次耗时" + getSeconds.ToString("0.000") + "秒 系统将在下次" + ConfigurationManager.AppSettings["StartTime"]);
                if (SendMeail.SendMsg("处理完成,本次执行完毕,本次耗时" + getSeconds.ToString("0.000") + "秒 系统将在下次" + ConfigurationManager.AppSettings["StartTime"]) == 1)
                {
                    ProMaintain.Writelog("已经发送邮件");
                }
                else
                {
                    ProMaintain.Writelog("邮件发送失败");
                }
            }
        }