public HttpResponseMessage Register(string username, string password, string email, string rancode)
        {
            Boolean flag = false;
            string  Msg  = "方法异常";
            int     code = 205;

            try
            {
                string    newpassword = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
                DbCommand cmd         = db.GetStoredProcCommond("user_register_User");
                db.AddInParameter(cmd, "@username", DbType.String, username);
                db.AddInParameter(cmd, "@password", DbType.String, newpassword);
                db.AddInParameter(cmd, "@email", DbType.String, email);
                db.AddInParameter(cmd, "@rancode", DbType.String, rancode);
                DataTable dt = db.ExecuteDataTable(cmd);
                flag = true;
                Msg  = dt.Rows[0][0].ToString();
                string str = "";
                if (dt.Rows[0][0].ToString() == "用户邮箱已存在")
                {
                    code = 204;
                }
                else if (dt.Rows[0][0].ToString() == "用户名已存在")
                {
                    code = 210;
                }
                else if (dt.Rows[0][0].ToString() == "用户名、邮箱已存在")
                {
                    code = 215;
                }
                else if (dt.Rows[0][0].ToString() == "验证码错误")
                {
                    code = 216;
                }
                else if (dt.Rows[0][0].ToString() == "注册成功")
                {
                    code = 200;
                    str += "{\"_userid\":\"" + dt.Rows[0]["newid"].ToString()
                           + "\"}";
                }
                String returnString = "{\"Success\":\"" + flag.ToString() + "\",\"Msg\":\"" + Msg.ToString() + "\", \"Data\":[" + str + "],\"Code\":" + code + "}";
                String decryptStr   = aes.Encrypt(returnString);
                String ret          = "{\"data\":\"" + decryptStr + "\"}";
                return(ToJson.toJson(ret.ToString()));
            }
            catch (Exception ex)
            {
                logger.WriteLogFile("Register(string username, string password, string email)", ex.Message.ToString());
                String returnString = "{\"Success\":\"" + flag.ToString() + "\",\"Msg\":\"" + Msg.ToString() + "\", \"Data\":[" + "" + "],\"Code\":" + code + "}";
                String decryptStr   = aes.Encrypt(returnString);
                String ret          = "{\"data\":\"" + decryptStr + "\"}";
                return(ToJson.toJson(ret.ToString()));
            }
        }
        public HttpResponseMessage AddStatistics(string pageid, string userid, string personid)
        {
            Boolean flag = false;
            string  Msg  = "方法异常";
            int     code = 205;

            try
            {
                userid   = userid == null ? "" : userid;
                personid = personid == null ? "" : personid;
                DbCommand cmd = db.GetStoredProcCommond("user_save_AddStatistics");
                db.AddInParameter(cmd, "@pageid", DbType.String, pageid);
                db.AddInParameter(cmd, "@userid", DbType.String, userid);
                db.AddInParameter(cmd, "@personid", DbType.String, personid);
                DataTable dt = db.ExecuteDataTable(cmd);
                Msg  = dt.Rows[0][0].ToString();
                flag = true;
                code = 200;
                String returnString = "{\"Success\":\"" + flag.ToString() + "\",\"Msg\":\"" + Msg.ToString() + "\", \"Data\":[],\"Code\":" + code + "}";
                String decryptStr   = aes.Encrypt(returnString);
                String ret          = "{\"data\":\"" + decryptStr + "\"}";
                return(ToJson.toJson(ret.ToString()));
            }
            catch (Exception ex)
            {
                logger.WriteLogFile("AddStatistics(string userid)", ex.Message.ToString());
                String returnString = "{\"Success\":\"" + flag.ToString() + "\",\"Msg\":\"" + Msg.ToString() + "\", \"Data\":[],\"Code\":" + code + "}";
                String decryptStr   = aes.Encrypt(returnString);
                String ret          = "{\"data\":\"" + decryptStr + "\"}";
                return(ToJson.toJson(ret.ToString()));
            }
        }
Пример #3
0
        //
        /// <summary>
        /// 查询结果集并返回datatable
        /// </summary>
        /// <param MySqlConnection="connection"></param>
        /// <param sql语句="sqlCmd_select"></param>
        /// <param sql参数="cmdParams"></param>
        /// <returns></returns>
        public static DataTable GetDataTable(MySqlConnection connection, string sqlCmd_select, params MySqlParameter[] cmdParams)
        {
            DataTable Dt = new DataTable();

            try
            {
                MySqlCommand cmd = new MySqlCommand(sqlCmd_select);
                cmd.Connection = connection;
                if (cmdParams != null && cmdParams.Length > 0)
                {
                    cmd.Parameters.AddRange(cmdParams);
                }
                MySqlDataAdapter Da = new MySqlDataAdapter(cmd);

                try
                {
                    Da.Fill(Dt);
                }
                catch (MySqlException ex)
                {
                    Dt = null;
                    LogClass.WriteLogFile("DataTable填充数据异常" + ex.Message);
                }
            }
            catch (MySqlException ex)
            {
                Dt = null;
                LogClass.WriteLogFile("DataTable填充数据异常" + ex.Message);
            }
            return(Dt);
        }
Пример #4
0
        /// <summary>
        /// 执行sql命令
        /// </summary>
        /// <param 数据库名="dbname"></param>
        /// <param 用户名="user"></param>
        /// <param 密码="pwd"></param>
        /// <param 端口号="port"></param>
        /// <param sql命令="command"></param>
        /// <returns></returns>
        protected static bool ExecuteCommand(string dbname, string user, string pwd, int port, string command)
        {
            bool issuc = true;

            try
            {
                using (MySqlConnection conn = getMySqlCon(dbname, user, pwd, port))
                {
                    conn.Open();

                    MySqlCommand cmd = new MySqlCommand(command, conn);

                    cmd.ExecuteNonQuery();
                }
            }
            catch (MySqlException e)
            {
                issuc = false;
                //PISTrace.WriteStrLine(e.Message);
                LogClass.WriteLogFile("Class-AccessDBBase;Fun-ExcuteCommand;行号201;" + e.Message);
                //throw;
            }

            return(issuc);
        }
Пример #5
0
        private void query()
        {
            DataSet ds        = new DataSet();//数据库操作
            string  mTreeView = Main.MTreeName.ToString();
            string  mQuery    = "Select TestHisData as 序号, Htest_type as 测试模态,Test_Psernum as 生产批号 ,HA_STime as 测试时间,Test_Name as 测试名称,Test_Fsernum as 滤器序号,Test_filt as 滤材种类,Test_LIQU as 测试液体,Test_Filt_Hight as 滤芯高度,Test_Filt_Num as 滤芯数量,Test_Result as 结果,Test_startp as 起测压力,Test_SetBp as 最小泡点,Test_Up_Volm as 上游体积,Test_Dif_max as 最大扩散流,Htest_DifValue as 测试值1,Htest_Value as 测试值2,Test_Filter_Area as 过滤面积,Test_Meme_Aper as 孔径,Test_Filter_type as 过滤器种类,Htest_DiffePress as 压力衰减,Test_CDifValue as 最大扩散流值,Test_testimes as 采样次数,Test_Sampling_Frequency as 采样点的频率,Htest_DifStart as 扩散流的起始位置,Htest_Name as 测试人员名,Htest_Press_Line as 压力的曲线值,Htest_Dif_Line as 扩散流的曲线值  From {0}";

            mQuery      = string.Format(mQuery, mTreeView);
            mConnection = new OleDbConnection(sAccessConnection);

            OleDbDataAdapter dataAdapter = new OleDbDataAdapter(mQuery, mConnection);

            //DataGridView dz = new DataGridView();
            //dz.DataSource = ds.Tables[0].DefaultView;
            //如果需要再次查询,需清空dataset里面的数据
            try
            {
                mConnection.Open();


                dataAdapter.Fill(ds);
                dataGridViewExportInfo.DataSource         = ds.Tables[0].DefaultView;
                dataGridViewExportInfo.AllowUserToAddRows = false;
            }
            catch (Exception ex)
            {
                LogClass.WriteLogFile("Exception:" + ex.ToString());
            }

            finally
            {
                mConnection.Close();
            }
        }
Пример #6
0
 //strMsg 提示信息,
 //iErrorLvl 0-正常,1-提示,2-错误
 public void SendMsgShow(string strMsg, int iErrorLvl)
 {
     try
     {
         textBox_msg.Text = strMsg;
         if (iErrorLvl == 0)
         {
             textBox_msg.ForeColor = Color.Black;
             textBox_msg.BackColor = Color.GreenYellow;
             //textBox_msg.Font.
         }
         else if (iErrorLvl == 1)
         {
             textBox_msg.ForeColor = Color.Black;
             textBox_msg.BackColor = Color.Yellow;
         }
         else
         {
             textBox_msg.ForeColor = Color.Yellow;
             textBox_msg.BackColor = Color.Red;
         }
         LogClass.WriteLogFile(strMsg);
         Application.DoEvents();   //处理所有的当前在消息队列中的Windows消息
     }
     catch (Exception exp)
     {
         MessageBox.Show("显示提示信息失败:" + exp.Message, "错误");
         LogClass.WriteLogFile("显示提示信息失败:" + exp.Message);
     }
 }
Пример #7
0
 //**清除超过一段时间的数据(三个月或者多少天之前)---被动/
 //创建定时任务
 /// <summary>
 /// 定时事件
 /// </summary>
 /// <param 设置默认删除多少天前的数据="timeRange"></param>
 public static bool AutoCleanData(string timeRange, string tableName)
 {
     try
     {
         //createtable是防止表不存在
         if (CreateTable(tableName) && ExecuteCommand(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port), sqlCmd_event_scheduler) && ExecuteCommand(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port), sqlCmd_drop_oldevent(tableName)))
         {
             if (!ExecuteCommand(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port), AutoDeleteSqlStr(timeRange, tableName)))
             {
                 //PISTrace.WriteStrLine("定时事件创建失败");
                 LogClass.WriteLogFile("Class-AcessDBApply;Fun-AutoCleanData; 150行:" + "定时事件创建失败");
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(false);
         }
     }
     catch (MySqlException ex)
     {
         //PISTrace.WriteStrLine("定时事件创建失败:" + ex.Message);
         LogClass.WriteLogFile("Class-AcessDBApply;Fun-AutoCleanData; 167行:" + "定时事件创建失败" + ex.Message);
         return(false);
     }
 }
Пример #8
0
        public static bool CreateTable(string tableName)
        {
            bool issuc = true;

            try
            {
                //**判断数据库是否存在,以及数据库是否创建成功*/

                if (!AccessDBBase.ExistDB("reflowertester", "root", "pempenn", GlobalData.MySqlPort))
                {
                    if (!AccessDBBase.CreateDB("reflowertester", "root", "pempenn"))
                    {
                        LogClass.WriteLogFile("创建数据库失败->");
                    }
                    return(false);
                }

                //**建表*/
                if (!AccessDBBase.ExecuteCommand("reflowertester", "root", "pempenn", GlobalData.MySqlPort, SqlCmd_baseProfile_m(tableName)))//sqlCmd_baseProfile
                {
                    // LogClass.WriteLogFile("创建表baseprofile失败");
                    LogClass.WriteLogFile("创建表RTfile失败->" + tableName);
                    return(false);
                }
            }
            catch (MySqlException ex)
            {
                // LogClass.WriteLogFile(ex.Message);
                LogClass.WriteLogFile(ex.Message);
                return(false);
            }
            return(issuc);
        }
        /// <summary>
        /// 画曲线
        /// </summary>
        /// <returns></returns>
        private DataTable ds()
        {
            DataTable mDataTable = new DataTable("ds2");

            try
            {
                mDataTable.Columns.Add("DataPressure", typeof(Int32));
                mDataTable.Columns.Add("DataTime", typeof(Int32));


                for (int i = 0; i <= 49; i++)
                {
                    if (WaterImmersionTest.mCurPT[i].ToString() == "\0" || WaterImmersionTest.mCurPT[i].ToString() == "")
                    {
                        DataRow dr = mDataTable.NewRow();
                        dr["DataPressure"] = 0;
                        dr["DataTime"]     = i;
                        mDataTable.Rows.Add(dr);
                    }
                    else
                    {
                        DataRow dr = mDataTable.NewRow();
                        dr["DataPressure"] = WaterImmersionTest.mCurPT[i];
                        dr["DataTime"]     = i;
                        mDataTable.Rows.Add(dr);
                    }
                }
            }
            catch (Exception ex)
            {
                LogClass.WriteLogFile("Exception:" + ex.ToString());
            }
            return(mDataTable);
        }
        private void WaterImmersionTestPrinter_Load(object sender, EventArgs e)
        {
            try
            {
                this.reportViewer.Reset();
                this.reportViewer.LocalReport.ReportEmbeddedResource = "SunManage.AllCheck.ReportWITPT.rdlc";
                reportViewer.LocalReport.DataSources.Clear();
                reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSetWITReport", GetDataSet()));

                reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSetWITPTReport", ds()));


                this.reportViewer.RefreshReport();


                //// 将显示模式切换到打印布局模式
                this.reportViewer.SetDisplayMode(DisplayMode.PrintLayout);

                // 将缩放模式设置为百分比
                this.reportViewer.ZoomMode = ZoomMode.Percent;

                // 设为 100%
                this.reportViewer.ZoomPercent = 35;
            }
            catch (Exception ex)
            {
                LogClass.WriteLogFile("Exception:" + ex.ToString());
            }
        }
 /// <summary>
 /// 企业会员审核结果的异步委托的方式
 /// </summary>
 /// <param name="pay_result">SortedList</param>
 /// <param name="logs">日志class</param>
 /// <returns></returns>
 public bool audit_status_syncAsyncMethod(SortedList <string, string> pay_result, LogClass notifylogs)
 {
     System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + "/********进入异步方法调用区域********/");
     Thread.Sleep(3000);//测试企业会员审核结果异步委托,3秒。
     notifylogs.WriteLogFile("日志——开始异步委托取出数组模拟执行业务逻辑:" + new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(pay_result));
     return(true);
 }
Пример #12
0
        /// <summary>
        /// 刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonSearchALLHis_Click(object sender, EventArgs e)
        {
            string mTreeView = "UserInfo";
            string mQuery    = "Select [UserNameInfo] as 用户名,[LevelInfo] as 级别 From {0}";

            mQuery      = string.Format(mQuery, mTreeView);
            mConnection = new OleDbConnection(sAccessConnection);

            OleDbDataAdapter dataAdapter = new OleDbDataAdapter(mQuery, mConnection);

            //DataGridView dz = new DataGridView();
            //dz.DataSource = ds.Tables[0].DefaultView;
            //如果需要再次查询,需清空dataset里面的数据
            try
            {
                mConnection.Open();
                ds.Tables[0].Clear();
                dataAdapter.Fill(ds);
                dataGridViewUserInfo.DataSource         = ds.Tables[0].DefaultView;
                dataGridViewUserInfo.AllowUserToAddRows = false;
            }
            catch (Exception ex)
            {
                LogClass.WriteLogFile("Exception:" + ex.ToString());
            }
            finally
            {
                mConnection.Close();
            }
        }
Пример #13
0
        private void saveWork()
        {
            while (EnableThread)
            {
                try
                {
                    if (baseProfileQueue_save.Count > 0)
                    {
                        BaseProfile baseData = baseProfileQueue_save.Dequeue(); // 有任务时,出列任务

                        if (baseData == null)                                   // 退出机制:当遇见一个null任务时,代表任务结束
                        {
                            return;
                        }
                        else
                        {
                            SaveData(baseData, _saveWorker.Name);  // 任务不为null时,处理并保存数据
                        }
                    }
                }
                catch (Exception e)
                {
                    //PISLog.PISTrace.WriteStrLine("savework:" + e.Message);
                    LogClass.WriteLogFile("Class-AutosolderService;Fun-saveWork; 198行 " + e.Message);
                }
                Thread.Sleep(300);
            }
        }
Пример #14
0
        //*******************************************************************insert
        /// <summary>
        /// insert into data
        /// </summary>
        /// <param 温度="Temperature"></param>
        /// <param 湿度="Humidity"></param>
        /// <param 生产线="ProductLine"></param>
        /// <param 时间点="TimePoint"></param>
        /// <returns></returns>
        ///
        public static bool InsertBaseProfile(double Temperature, double Humidity, string ProductLine, int RemainSolderPercent, int UsedSolderNum, int AddTimes, DateTime TimePoint, string tableName)
        {
            string timePoint = string.Format("{0:yyyy-MM-dd HH:mm:ss}", TimePoint);
            string getCommandInsertInto_Baseprofile = string.Format(baseProfile_insertFormat(tableName), Temperature, Humidity, "'" + ProductLine + "'", RemainSolderPercent, UsedSolderNum, AddTimes, "'" + timePoint + "'");

            try
            {
                if (ExecuteCommand(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port), getCommandInsertInto_Baseprofile))
                {
                    return(true);
                }
                else
                {
                    //PISTrace.WriteStrLine("baseProfile插入数据失败");
                    LogClass.WriteLogFile("Class-AcessDBApply;Fun-InsertBaseProfile; 73行:" + "插入数据失败");
                    return(false);
                }
            }
            catch (MySqlException ex)
            {
                //PISTrace.WriteStrLine(ex.Message);
                LogClass.WriteLogFile("Class-AcessDBApply;Fun-InsertBaseProfile; 73行:" + "插入数据失败" + ex.Message);
                return(false);
            }
        }
Пример #15
0
        void RecMsg()
        {
            while ((this.clientSocket != null) && (this.NetStat == NetConnectStat.Connect))
            {
                // 定义一个100b的缓存区;
                byte[] arrMsgRec = new byte[100];
                // 将接受到的数据存入到输入  arrMsgRec中;
                int length = -1;
                try
                {
                    length = clientSocket.Receive(arrMsgRec); // 接收数据,并返回数据的长度;

                    //Console.WriteLine("------------------------------");
                    if (length < 0)
                    {
                        this.NetStat = NetConnectStat.DisConnect;
                        return;
                    }

                    this.ReciveBuffer = arrMsgRec;
                    arrMsgRec         = null;
                    //GC.Collect();
                }
                catch (Exception e)
                {
                    LogClass.WriteLogFile("Class-NetWorkServer;Fun-RecMsg;行号116" + e.Message);
                    this.NetStat = NetConnectStat.DisConnect;
                    return;
                }

                Thread.Sleep(500);
            }
        }
Пример #16
0
        /// <summary>
        /// 关闭串口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonClose_Click(object sender, EventArgs e)
        {
            try
            {
                buttonOpen.Enabled        = true;
                comboBoxPortName.Enabled  = true;
                comboBoxBaudRate.Enabled  = true;
                comboBoxDataBits.Enabled  = true;
                comboBoxParity.Enabled    = true;
                comboBoxStopBits.Enabled  = true;
                comboBoxHandshake.Enabled = true;
                CommPort com = CommPort.Instance;



                if (com.IsOpen == false)
                {
                    MessageBox.Show("串口没被打开", "提示");
                }
                if (com.IsOpen == true)
                {
                    com.Close();
                }
            }
            catch (Exception ex)
            {
                LogClass.WriteLogFile("Exception:" + ex.ToString());
            }
        }
Пример #17
0
        /// <summary>
        /// 判断数据库历史数据是否为空
        /// </summary>
        public bool GetTables(OleDbConnection conn, string TableName)
        {
            int       result      = 0;
            DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
                                                             new object[] { null, null, null, "TABLE" });

            try
            {
                if (schemaTable != null)
                {
                    for (Int32 row = 0; row < schemaTable.Rows.Count; row++)
                    {
                        string col_name = schemaTable.Rows[row]["TABLE_NAME"].ToString();
                        if (col_name == TableName)
                        {
                            result++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogClass.WriteLogFile("Exception:" + ex.ToString());
            }
            if (result == 0)
            {
                return(false);
            }
            return(true);
        }
Пример #18
0
        public static bool ExecuteBat(string batPath)
        {
            bool result = false;

            try
            {
                using (Process pro = new Process())
                {
                    pro.StartInfo.UseShellExecute = false;
                    pro.StartInfo.CreateNoWindow  = true;
                    // pro.StartInfo.WorkingDirectory = file.Directory.FullName;
                    pro.StartInfo.FileName = batPath;

                    pro.StartInfo.Verb = "runas";
                    pro.Start();
                    pro.WaitForExit();
                }

                result = true;
            }
            catch (Exception e)
            {
                //写入日志
                //System.Diagnostics.Trace.WriteLine(e.Message);
                LogClass.WriteLogFile("Class-AutoSolderBatMain;Fun-ExecuteBat;行号50:" + e.Message);
            }
            return(result);
        }
Пример #19
0
        public static bool CreateTable(string tableName)
        {
            bool issuc = true;

            try
            {
                //**判断数据库是否存在,以及数据库是否创建成功*/
                if (!ExistDB(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port)))
                {
                    if (!CreateDB(dbConfig.Catalog, dbConfig.User, dbConfig.Password))
                    {
                        return(false);
                    }
                }
                //**建表*/
                if (!ExecuteCommand(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port), sqlCmd_baseProfile_m(tableName)))//sqlCmd_baseProfile
                {
                    LogClass.WriteLogFile("Web Solution;Class-AccessDBApply;Fun-CreatTable;创建表" + tableName + "失败");
                    return(false);
                }
            }
            catch (MySqlException ex)
            {
                LogClass.WriteLogFile("Web Solution; Class - AccessDBApply; Fun - CreatTable;" + ex.Message);
                return(false);
            }
            return(issuc);
        }
Пример #20
0
 //**清除超过一段时间的数据(三个月或者多少天之前)---被动/
 //创建定时任务
 /// <summary>
 /// 定时事件
 /// </summary>
 /// <param 设置默认删除多少天前的数据="timeRange"></param>
 public static bool AutoCleanData(string timeRange, string tableName)
 {
     try
     {
         if (ExecuteCommand(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port), sqlCmd_event_scheduler) && ExecuteCommand(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port), sqlCmd_drop_oldevent))
         {
             if (!ExecuteCommand(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port), AutoDeleteSqlStr(timeRange, tableName)))
             {
                 LogClass.WriteLogFile("Web Solution; Class - AccessDBApply; Fun - AutoCleanData;定时事件创建失败");
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(false);
         }
     }
     catch (MySqlException ex)
     {
         LogClass.WriteLogFile("Web Solution; Class - AccessDBApply; Fun - AutoCleanData;定时事件创建失败:" + ex.Message);
         return(false);
     }
 }
Пример #21
0
        private static void CreateBatFile(string context, string path)
        {
            FileStream   fs = null;
            StreamWriter sw = null;

            try
            {
                if (!Directory.Exists(Path.GetDirectoryName(path)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                }
                fs = new FileStream(path, FileMode.CreateNew, FileAccess.Write);
                sw = new StreamWriter(fs);
                sw.WriteLine(context);
            }
            catch (Exception ex)
            {
                LogClass.WriteLogFile("Class-AutoSolder;Fun-CreateBatFile();行号73:" + ex.Message);
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
Пример #22
0
        /// <summary>
        /// 去重查询字段下数据(只限字符字段)
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public static List <string> selectAllLineData(string tableName, string field)
        {
            List <string> listStr = new List <string>();

            try
            {
                using (MySqlConnection connection = AccessDBBase.getMySqlCon("ReflowerTester", "root", "pempenn", GlobalData.MySqlPort))
                {
                    connection.Open();
                    MySqlCommand    cmd    = new MySqlCommand(sqlCmd_selectAllLine(tableName, field), connection);
                    MySqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        listStr.Add(reader[0].ToString());
                    }
                    reader.Close();
                }
            }
            catch (MySqlException ex)
            {
                LogClass.WriteLogFile("Reflower Tester:去重查询Line数据失败" + ex.Message);
                listStr = null;
            }

            return(listStr);
        }
Пример #23
0
        //建表
        /// <summary>
        /// Create Table
        /// </summary>
        /// <returns></returns>
        public static bool CreateTable(string tableName)
        {
            bool issuc = true;

            try
            {
                //**判断数据库是否存在,以及数据库是否创建成功*/
                if (!ExistDB(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port)))
                {
                    if (!CreateDB(dbConfig.Catalog, dbConfig.User, dbConfig.Password))
                    {
                        return(false);
                    }
                }
                //**建表*/
                if (!ExecuteCommand(dbConfig.Catalog, dbConfig.User, dbConfig.Password, int.Parse(dbConfig.Port), sqlCmd_baseProfile(tableName)))
                {
                    // PISTrace.WriteStrLine("创建表baseprofile失败");
                    LogClass.WriteLogFile("Class-AcessDBApply;Fun-selectDataTable_baseprofile; 37行:" + "创建表baseprofile失败:");
                    return(false);
                }
            }
            catch (MySqlException ex)
            {
                // PISTrace.WriteStrLine("CreateTable " +ex.Message);
                LogClass.WriteLogFile("Class-AcessDBApply;Fun-Create; 44行:" + ex.Message);
                return(false);
            }
            return(issuc);
        }
Пример #24
0
        public void ExecuteAddBaseProfile(string tableName)
        {
            try
            {
                TableName = tableName;

                T2.Elapsed += T2_Elapsed;
                //T2.Interval = timer * 1000;
                _saveWorker = new Thread(saveWork);
                _saveWorker.IsBackground = true;
                _saveWorker.Name         = tableName;
                _saveWorker.Start();
            }
            catch (Exception e)
            {
                LogClass.WriteLogFile("Class-ExecuteQueue;Fun-ExecuteAddBaseProfile; 行号157:" + e.Message);
                //throw;
            }
            //T1.Interval = timer * 1000;
            //T1.Elapsed += T1_Elapsed;


            // Dispose_save();

            //_showWorker = new Thread(showWork);
            //_showWorker.IsBackground = true;
            //_showWorker.Start();
            // Dispose_show();
        }
Пример #25
0
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonHistoricalDelete_Click(object sender, EventArgs e)
        {
            if (dataGridViewUserInfo.SelectedRows.Count <= 0)
            {
                return;
            }

            if (!checkLevel(comboBoxLevel.SelectedIndex + 1))
            {
                MessageBox.Show("该权限不能操作!");
                return;
            }
            if (string.IsNullOrEmpty(tBUserName.Text.ToString()))
            {
                MessageBox.Show("用户名不能为空!");
                return;
            }
            string mTreeView = "UserInfo";

            string mDeleteUserInfoIndex = dataGridViewUserInfo.Rows[dataGridViewUserInfo.CurrentRow.Index].Cells[1].Value.ToString();

            if (!checkLevel(int.Parse(mDeleteUserInfoIndex)))
            {
                MessageBox.Show("该权限不能操作!");
                return;
            }
            string userName = dataGridViewUserInfo.Rows[dataGridViewUserInfo.CurrentRow.Index].Cells[0].Value.ToString();

            if (userName != "Admin")
            {
                string mQuery = "delete * From {0} where [UserNameInfo]='" + userName + "'";
                mQuery      = string.Format(mQuery, mTreeView);
                mConnection = new OleDbConnection(sAccessConnection);
                OleDbCommand da = new OleDbCommand(mQuery, mConnection);
                try
                {
                    mConnection.Open();
                    if ((MessageBox.Show("你确定删除当前用户吗?", "警告!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) == DialogResult.Yes)
                    {
                        //删除数据
                        //首先删除数据集 中的该条记录
                        int i = dataGridViewUserInfo.CurrentCell.RowIndex;//得到当前记录号
                        if (i >= 0)
                        {
                            ds.Tables[0].Rows[i].Delete();
                        }
                    }
                    da.ExecuteNonQuery();
                }

                catch (Exception ex)
                {
                    LogClass.WriteLogFile("Exception:" + ex.ToString());
                }
                finally
                {
                    mConnection.Close();
                }
            }
        }
Пример #26
0
        public HttpResponseMessage Get(string username, string password)
        {
            Boolean flag = false;
            string  Msg  = "方法异常";
            int     code = 205;

            try
            {
                string    newpassword = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
                DbCommand cmd         = db.GetStoredProcCommond("user_login_User");
                db.AddInParameter(cmd, "@username", DbType.String, username);
                db.AddInParameter(cmd, "@password", DbType.String, newpassword);
                DataTable dt  = db.ExecuteDataTable(cmd);
                string    str = "";
                Msg = dt.Rows[0]["msg"].ToString();
                if (Msg == "登录成功")
                {
                    str = "{\"_User_Name\":\"" + username.ToString()
                          + "\",\"_User_ID\":\"" + dt.Rows[0]["userid"].ToString()
                          + "\"}";
                    flag = true;
                    code = 200;
                }
                else if (Msg == "用户未注册")
                {
                    flag = true;
                    code = 209;
                }
                else if (Msg == "用户名或密码错误")
                {
                    flag = true;
                    code = 217;
                }
                String returnString = "{\"Success\":\"" + flag.ToString() + "\",\"Msg\":\"" + Msg.ToString() + "\", \"Data\":[" + str.ToString() + "],\"Code\":" + code + "}";
                String decryptStr   = aes.Encrypt(returnString);
                String ret          = "{\"data\":\"" + decryptStr + "\"}";
                return(ToJson.toJson(ret.ToString()));
            }
            catch (Exception ex)
            {
                logger.WriteLogFile("Get(string username, string password)", ex.Message.ToString());
                String returnString = "{\"Success\":\"" + flag.ToString() + "\",\"Msg\":\"" + Msg.ToString() + "\", \"Data\":[" + "" + "],\"Code\":" + code + "}";
                String decryptStr   = aes.Encrypt(returnString);
                String ret          = "{\"data\":\"" + decryptStr + "\"}";
                return(ToJson.toJson(ret.ToString()));
            }
        }
Пример #27
0
        /// <summary>
        /// 此方法重启服务 顺序并不是按照停止再启动,因此换成在部署服务后设置 遇到错误自动重启(而这个错误是程序给的)
        /// </summary>
        private static void RestartService()
        {
            ServiceController serv = new ServiceController("Autosolder");

            //if (serv.CanStop)
            //{
            //    // 如果权限不够是不能Stop()的。
            //    serv.Stop();

            //    // 这句话如果没有对该服务的后续操作可以不要,C#程序只是以权限向操作系统发出关闭某服务的消息而已,真正关闭该服务的是操作系统而非此C#程序(下面的Start的也一样)
            //    serv.WaitForStatus(ServiceControllerStatus.Stopped);
            //}

            //if (!serv.CanStop) // 不能停止,反过来就是可以开启
            //{
            //    serv.Start();
            //    serv.WaitForStatus(ServiceControllerStatus.Running);
            //}

            //// 释放对该服务的控制权及释放相应资源。
            //serv.Close();
            try
            {
                TimeSpan timeout = TimeSpan.FromMilliseconds(10000);
                if (serv.Status == ServiceControllerStatus.Running)
                {
                    //object lockThis = new object();


                    serv.Stop();
                    serv.WaitForStatus(ServiceControllerStatus.Stopped, timeout);



                    writeTest("是确定的服务关闭");
                }
                if (serv.Status == ServiceControllerStatus.Stopped)
                {
                    serv.WaitForStatus(ServiceControllerStatus.Running, timeout);
                    writeTest("是确定的服务开启");
                }
            }
            catch (Exception e)
            {
                //PISTrace.WriteStrLine("restartservice:" + e.Message);
                LogClass.WriteLogFile("Class-AutosolderService;Fun-RestartService; " + e.Message);
            }
            finally
            {
                //*/
                if (serv.Status == ServiceControllerStatus.Stopped)
                {
                    serv.Start();
                    serv.WaitForStatus(ServiceControllerStatus.Running);
                }
                serv.Close();
            }
        }
Пример #28
0
        public HttpResponseMessage GetFindPlay(string type)
        {
            Boolean flag = false;
            string  Msg  = "方法异常";
            int     code = 205;

            try
            {
                DbCommand cmd = db.GetStoredProcCommond("user_get_GetFindPlay");
                db.AddInParameter(cmd, "@type", DbType.String, type);
                DataTable dt  = db.ExecuteDataTable(cmd);
                int       len = dt.Rows.Count;
                string    str = "";
                if (len > 0)
                {
                    for (int i = 0; i < len; i++)
                    {
                        string _FMpath = dt.Rows[i]["CoverImg_Path"].ToString().Trim();
                        if (!string.IsNullOrEmpty(_FMpath))
                        {
                            if (_FMpath.Substring(0, 1) == "~")
                            {
                                _FMpath = _FMpath.Replace("~", "");
                            }
                            _FMpath = ManagerPath + System.Web.HttpUtility.UrlEncode(_FMpath);
                        }
                        str += "{\"_titleid\":\"" + dt.Rows[i]["Title_ID"].ToString().Trim()
                               + "\",\"_FMpath\":\"" + _FMpath
                               + "\"},";
                    }
                    str  = str.Substring(0, str.Length - 1);
                    flag = true;
                    code = 200;
                    Msg  = "获取成功";
                }
                else
                {
                    flag = true;
                    code = 202;
                    Msg  = "没有查询到数据";
                }
                String returnString = "{\"Success\":\"" + flag.ToString() + "\",\"Msg\":\"" + Msg.ToString() + "\", \"Data\":[" + str.ToString() + "],\"Code\":" + code + "}";
                String decryptStr   = aes.Encrypt(returnString);
                String ret          = "{\"data\":\"" + decryptStr + "\"}";
                return(ToJson.toJson(ret.ToString()));
            }
            catch (Exception ex)
            {
                logger.WriteLogFile("GetFindPlay", ex.Message.ToString());
                String returnString = "{\"Success\":\"" + flag.ToString() + "\",\"Msg\":\"" + Msg.ToString() + "\", \"Data\":[" + "" + "],\"Code\":" + code + "}";
                String decryptStr   = aes.Encrypt(returnString);
                String ret          = "{\"data\":\"" + decryptStr + "\"}";
                return(ToJson.toJson(ret.ToString()));
            }
        }
    static void callback(IAsyncResult result)
    {
        //result 是“deposit_status_sync_AsyncMethod()方法”的返回值
        //AsyncResult 是IAsyncResult接口的一个实现类,引用空间:System.Runtime.Remoting.Messaging
        //AsyncDelegate 属性可以强制转换为用户定义的委托的实际类。
        AddHandler handler    = (AddHandler)((AsyncResult)result).AsyncDelegate;
        LogClass   notifylogs = (LogClass)result.AsyncState;

        notifylogs.WriteLogFile("日志——异步委托执行结果是 :" + handler.EndInvoke(result), LOGending: true);
    }
 private void labelCancel_Click(object sender, EventArgs e)
 {
     try
     {
         this.Close();
     }
     catch (Exception ex)
     {
         LogClass.WriteLogFile("Exception:" + ex.ToString());
     }
 }