Ejemplo n.º 1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            FormMain.m_mq = new MQ();
            saveDataToLog = string.Equals(bool.TrueString, System.Configuration.ConfigurationManager.AppSettings["SaveDataToLog"], StringComparison.CurrentCultureIgnoreCase);

            //初始化数据解析类
            bool iniCheck = CheckIniConfig();

            DataBase   = new MySQLDBHelper();
            dataHelper = new DataDealHelper(DataBase);

            //初始化处理线程
            dealThread = new Thread(dataHelper.DealStatus);
            saveThread = new Thread(dataHelper.SaveStatus);

            textTcpPort.Text = ini.ReadValue("LocalHost", "TCPLocalPort");
            textUdpPort.Text = ini.ReadValue("LocalHost", "UDPLocalPort");

            //初始化存储数据库的计时器(5秒更新一次数据库)
            dbTimer           = new System.Timers.Timer(10000);
            dbTimer.AutoReset = true;
            dbTimer.Elapsed  += DbTimer_Elapsed;

            EquipmentHelper.MyEvent += new EquipmentHelper.MyDelegate(SendDataResponse);
            DataDealHelper.MyEvent  += new DataDealHelper.MyDelegate(SendDataResponse);

            this.timercounter = 0;
        }
Ejemplo n.º 2
0
 private void LoginMysqlbutton_Click(object sender, EventArgs e)
 {
     ip     = ipAddressControl1.Text;
     user   = UserNametextBox.Text;
     pwd    = PwdtextBox.Text;
     basedb = BaseDatatextBox.Text;
     try
     {
         string        ConnectMysql = null;
         MySQLDBHelper _Mysql       = new MySQLDBHelper();
         ConnectMysql = MySQLDBHelper.GetConnectString(ipAddressControl1.Text, UserNametextBox.Text, PwdtextBox.Text, BaseDatatextBox.Text);
         if (0 == _Mysql.Open(ConnectMysql, null))
         {
             this.Visible = false;
             DataMakerFm fm = new DataMakerFm(_Mysql);
             fm.ShowDialog();
             this.Close();
         }
         else
         {
             MessageBox.Show("Mysql连接失败!!!");
         }
     }
     catch (Exception ex)
     {
         string info = StringUtil.buildExceptionInfo(ex);
         MessageBox.Show(info);
     }
 }
Ejemplo n.º 3
0
 public iot_storageFm(MySQLDBHelper Mysql)
 {
     _Mysql = Mysql;
     InitializeComponent();
     // 加入这行多线程操作控件
     Control.CheckForIllegalCrossThreadCalls = false;
 }
Ejemplo n.º 4
0
 public EventFm(string NodeTag, string NodeName, MySQLDBHelper Mysql)
 {
     _NodeTag  = NodeTag;
     _NodeName = NodeName;
     _Mysql    = Mysql;
     InitializeComponent();
     DataInit();
 }
Ejemplo n.º 5
0
        public static void attach(MySQLDBHelper db, string orgId)
        {
            QuickLoadUtil.attach(db, orgId);//预加载机构相关信息
            DataTable dt = db.GetDataTable("SELECT id from acs_doorfbsconfig");

            acsCfgList = new List <string>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                acsCfgList.Add(dt.Rows[i]["id"].ToString());
            }
            dt.Dispose();
        }
Ejemplo n.º 6
0
 //已弃用的执行方法
 public virtual new void excute(MySQLDBHelper db)
 {
     deviceBase.excute(db);
     db.ExcuteNoneQuery(buildSqlStr());
     if (childList != null && childList.Count > 0)
     {
         foreach (List <Device> childs in childList)
         {
             AddDeviceHelper.multiExcute(db, childs);
         }
     }
     Console.WriteLine("====================添加一条数据:" + this.getId());
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 初始化数据库信息
        /// </summary>
        public void InitDatabase()
        {
            if (DataBase == null)
            {
                DataBase = new MySQLDBHelper();
            }
            string serverName = ini.ReadValue("Database", "ServerName");
            string database   = ini.ReadValue("Database", "DataBase");
            string logID      = ini.ReadValue("Database", "LogID");
            string logPass    = ini.ReadValue("Database", "LogPass");

            DataBase.SetConnectString(serverName, logID, logPass, database);
        }
Ejemplo n.º 8
0
 public DataMakerFm(MySQLDBHelper Mysql)
 {
     try
     {
         //string a = GetClientLocalIPv4Address();
         _Mysql = Mysql;
         InitializeComponent();
         OrgtreeView.Nodes.Clear();
         OrgbindTreeView1();
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 9
0
        public static void attach(MySQLDBHelper db, string orgId)
        {
            if (curOrg != null && orgId == curOrg.id)
            {
                return;
            }

            curOrg = new Organization(orgId);

            //获取机构信息
            DataTable orgTable = db.GetDataTable("SELECT Code,name from org_Dept WHERE id='" + orgId + "'");

            if (orgTable.Rows.Count == 0)
            {
                return;
            }
            curOrg.num  = orgTable.Rows[0]["Code"].ToString(); //机构编号
            curOrg.name = orgTable.Rows[0]["name"].ToString(); //机构名称
            orgTable.Dispose();

            //获取机构的区域点位信息
            areaList   = new List <string>();
            sitePoints = new List <List <string> >();

            //查找机构下的区域
            DataTable dt = db.GetDataTable("SELECT id from Institution_area_BaseInfo WHERE jigoumingchen='" + orgId + "'");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                areaList.Add(dt.Rows[i]["id"].ToString());
            }
            curOrg.areaList = areaList;
            dt.Dispose();
            //查找区域下的点位
            for (int i = 0; i < areaList.Count; i++)
            {
                DataTable     position  = db.GetDataTable("SELECT id from Institution_area_Position WHERE AreaId='" + areaList[i] + "'");
                List <string> pointList = new List <string>();
                for (int j = 0; j < position.Rows.Count; j++)
                {
                    pointList.Add(dt.Rows[j]["id"].ToString());
                }
                sitePoints.Add(pointList);
                position.Dispose();
            }
            curOrg.pointList = sitePoints;
        }
Ejemplo n.º 10
0
 public static MySQLDBHelper getNewDbHelper()
 {
     try
     {
         string        ConnectMysql = null;
         MySQLDBHelper _Mysql       = new MySQLDBHelper();
         ConnectMysql = MySQLDBHelper.GetConnectString(ip, user, pwd, basedb);
         if (0 == _Mysql.Open(ConnectMysql, null))
         {
             return(_Mysql);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(StringUtil.buildExceptionInfo(ex));
     }
     return(null);
 }
Ejemplo n.º 11
0
 public new void excute(MySQLDBHelper db)
 {
     asset.excute(db);
     db.ExcuteNoneQuery(buildSqlStr());
     Console.WriteLine("====================创建设备基类表数据:id = " + getId());
 }
Ejemplo n.º 12
0
 public AddPersonnel(string NodeTag, MySQLDBHelper Mysql)
 {
     _NodeTag = NodeTag;
     _Mysql   = Mysql;
     InitializeComponent();
 }
Ejemplo n.º 13
0
        //多合一insert
        public static void multiExcute(MySQLDBHelper db, List <Device> devices)
        {
            if (devices == null || devices.Count <= 0)
            {
                return;
            }
            //父设备列表<子设备种类<子设备列表<子设备>>>
            List <List <List <Device> > > allChilds = new List <List <List <Device> > >();
            StringBuilder asset      = new StringBuilder(devices[0].deviceBase.asset.initHead());
            StringBuilder assetState = new StringBuilder(devices[0].deviceBase.asset.state.initHead());
            StringBuilder deviceBase = new StringBuilder(devices[0].deviceBase.buildSQLHead());
            StringBuilder device     = new StringBuilder(devices[0].initHead());

            foreach (Device d in devices)
            {
                asset.Append(d.deviceBase.asset.buildSQLValue() + ",");
                assetState.Append(d.deviceBase.asset.state.buildSQLValue() + ",");
                deviceBase.Append(d.deviceBase.buildSQLValue() + ",");
                device.Append(d.buildSQLValue() + ",");
                if (d.getChildList() != null && d.getChildList().Count > 0)
                {
                    allChilds.Add(d.getChildList());
                }
            }
            asset.Remove(asset.Length - 1, 1);
            assetState.Remove(assetState.Length - 1, 1);
            deviceBase.Remove(deviceBase.Length - 1, 1);
            device.Remove(device.Length - 1, 1);
            Console.WriteLine("==========excute:-----Asset--------:" + "asset.ToString()");
            db.ExcuteNoneQuery(asset.ToString());
            Console.WriteLine("==========excute:-----AssetState---:" + "assetState.ToString()");
            db.ExcuteNoneQuery(assetState.ToString());
            Console.WriteLine("==========excute:-----DeviceBase---:" + "deviceBase.ToString()");
            db.ExcuteNoneQuery(deviceBase.ToString());
            Console.WriteLine("==========excute:-----Device-------:" + "device.ToString()");
            db.ExcuteNoneQuery(device.ToString());
            if (allChilds != null && allChilds.Count > 0)
            {
                Console.WriteLine("====excute:开始添加子设备:设备种类:" + allChilds[0].Count);
                //子设备种类<子设备列表<子设备>>
                List <List <Device> > allChildDevices = new List <List <Device> >(allChilds[0].Count);
                for (int c = 0; c < allChilds[0].Count; c++)
                {
                    allChildDevices.Add(new List <Device>());
                }
                foreach (List <List <Device> > childDevices in allChilds)
                {
                    for (int i = 0; i < childDevices.Count; i++)
                    {
                        allChildDevices[i].AddRange(childDevices[i]);
                    }
                }
                int num = 1;
                foreach (List <Device> deviceList in allChildDevices)
                {
                    Console.WriteLine("-----添加第" + num++ + "种子设备----");
                    multiExcute(db, deviceList);
                }
                Console.WriteLine("==========excute:-----子设备添加完成-------\n\n");
            }
        }
Ejemplo n.º 14
0
 public new void excute(MySQLDBHelper db)
 {
     db.ExcuteNoneQuery(buildSqlStr() + ";" + state.buildSqlStr());
     Console.WriteLine("====================创建资产及公有附属表数据:资产id = " + getId());
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            IBase         _cb = new IBase();
            MySQLDBHelper db  = new MySQLDBHelper();
            //db.ConnStr = "sl";
            List <SLCourse> list = XlsxOpe.ReadSLCourseXlsx(@"C:\Users\admin\Desktop\2017级第2期课表4.16.xlsx", 0, 6, 0, (cname, type) => {
                string str = string.Empty;
                if (cname.Length < 3)
                {
                    cname = "0" + cname;
                }
                if (type == "1")//学生
                {
                    DataTable dt = db.ExecuteDataTable("select u.ri_realname,u.ri_studentid,u.ri_realname from map_classes m left join ri_user u on m.ri_classid=u.ri_classid where m.ri_classname='" + cname + "' and m.ri_gradeid='G2017' and m.ri_delflag='0' and u.ri_delflag='0'");
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            str += dt.Rows[i][0].ToString() + "/" + dt.Rows[i][1].ToString() + ",";
                        }
                        str = str.Substring(0, str.Length - 1);
                    }
                }
                if (type == "2")
                {
                    DataTable dt = db.ExecuteDataTable("select u.ri_realname,u.ri_tel from map_classes m left join ri_user u on m.ri_teacher=u.ri_userid where m.ri_classname='" + cname + "' and m.ri_gradeid='G2017' and m.ri_delflag='0' and u.ri_delflag='0'");
                    if (dt.Rows.Count > 0)
                    {
                        str = dt.Rows[0][0].ToString() + "/" + dt.Rows[0][1].ToString();
                    }
                }
                return(str);
            });

            XlsxOpe.WriteXlsxFile(list);

            /*XlsxOpe.ReadXlsx1(@"D:\工作夹\单科试卷得分明细表110 - 副本.xls", 1, 2, 0, (rname,ac) =>
             * {
             *  //db.ConnStr = "connStr";
             *  if (rname == "罗壁嘉华")
             *  {
             *      rname = "罗璧嘉华";
             *  }
             *  if(rname== "蔡沁坤")
             *  {
             *      rname = "花生米";
             *  }
             *  if (rname == "陈冠廷")
             *  {
             *      rname = "陈冠西";
             *  }
             *  if (rname == "赖楚汉")
             *  {
             *      rname = "路星河";
             *  }
             *  if (rname == "文阅政")
             *  {
             *      rname = "文跃帧";
             *  }
             *  if (rname == "车林嵘")
             *  {
             *      rname = "车";
             *  }
             *  if (rname == "高航1"|| rname == "高航2")
             *  {
             *      rname = "高航";
             *  }
             *  DataTable dt= db.ExecuteDataTable("select ri_examcode,c.RI_ClassName from ri_user u LEFT JOIN map_classes c ON u.RI_ClassId=c.RI_ClassId where ri_realname like '%" + rname+ "%' and u.ri_type='0' and u.ri_gradeid='G2017' and u.ri_delflag='0'");
             *  if (dt.Rows.Count > 0)
             *  {
             *      ac(dt.Rows[0]["RI_ClassName"].ToString());
             *      if (rname == "高航1")
             *      {
             *          return "510117300311";
             *      }
             *      if (rname == "高航2")
             *      {
             *          return "510117300312";
             *      }
             *      return dt.Rows[0]["ri_examcode"].ToString();
             *  }
             *  return "";
             * });*/
            //IBase _cb = new IBase();
            //MySQLDBHelper db = new MySQLDBHelper();

            ////课表数据
            //List<Model.Schedule> slist = XlsOperate.ReadXlsxFile(@"D:\asp.net\workspace\2017级第2期课表3.5 - 副本.xlsx");
            ////教师上课对应班级数据
            //List<Model.TeacherCourse> tlist = XlsOperate.ReadXlsxFile1(@"D:\asp.net\workspace\教室上课对应班级表 - 副本 - 副本.xlsx");
            ////合并数据
            //for (int i = 0; i < slist.Count; i++)
            //{
            //    string tname = "";
            //    if (slist[i].CourseName.IndexOf('/') != -1)
            //    {
            //        string[] temp = slist[i].CourseName.Split('/');

            //        var tc0 = tlist.Find(t => t.ClassName.Equals(slist[i].ClassName) && t.CourseName.Equals(temp[0]));
            //        var tc1 = tlist.Find(t => t.ClassName.Equals(slist[i].ClassName) && t.CourseName.Equals(temp[1]));
            //        tname = (tc0 == null ? "" : tc0.TeacherName) + "/" + (tc1 == null ? "" : tc1.TeacherName);
            //        slist[i].TeacherName = tname;
            //        if (slist[i].CourseName.IndexOf("数学")!=-1)
            //        {
            //            slist[i].CourseName = slist[i].CourseName.Replace("数学", slist[i].SubjectType + "科" + slist[i].CourseName);
            //        }
            //        continue;
            //    }

            //    var tc = tlist.Find(t => t.ClassName.Equals(slist[i].ClassName) && t.CourseName.Equals(slist[i].CourseName));
            //    tname = tc == null ? "" : tc.TeacherName;
            //    slist[i].TeacherName = tname;
            //    if (slist[i].CourseName == "数学")
            //    {
            //        slist[i].CourseName = slist[i].SubjectType + "科" + slist[i].CourseName;
            //    }
            //}

            ////XlsOperate.WriteXlsxFile(slist);
            //DateTime dt = Convert.ToDateTime("2018-3-5");
            //DateTime dt1 = Convert.ToDateTime("2018-7-31");
            //int flag = 1;
            //int type = 1;
            //while (dt < dt1)
            //{

            //    List<Model.Map_Coursegroup_Beta> mcblist = GetOneData(GetData(slist, type), dt);
            //    for (int i = 0; i < mcblist.Count; i++)
            //    {
            //        db.ConnStr = "connStr";
            //        string sql = _cb.InsertModel<Model.Map_Coursegroup_Beta>(mcblist[i]);
            //        db.ExecuteNonQuery(sql);
            //    }
            //    dt = dt.AddDays(1);

            //    if (flag % 7 == 0)
            //    {
            //        type = -type;
            //        flag = 1;
            //    }
            //    else
            //    {
            //        flag++;
            //    }

            //}
        }
Ejemplo n.º 16
0
 public CascadeFm(MySQLDBHelper Mysql)
 {
     _Mysql = Mysql;
     InitializeComponent();
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 执行insert操作,已弃用,由AddDeviceHelper统一调度执行
 /// </summary>
 /// <param name="db"></param>
 public virtual void excute(MySQLDBHelper db)
 {
     db.ExcuteNoneQuery(buildSqlStr());
     Console.WriteLine("====================添加一条数据:" + id);
 }
Ejemplo n.º 18
0
 public AddAlmDevFm(string NodeTag, MySQLDBHelper Mysql)
 {
     _NodeTag = NodeTag;
     _Mysql   = Mysql;
     InitializeComponent();
 }