Beispiel #1
0
        /// <summary>
        /// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例)
        /// </summary>
        /// <param name="strSQL">SQL语句</param>
        /// <param name="fs">图像字节,数据库的字段类型为image的情况</param>
        /// <returns>影响的记录数</returns>
        public int ExecuteSqlInsertImg(string strSQL, byte[] fs)
        {
            int intValue = 0;

            //if (DBA.CheckIsKJ128A())
            //{
            //    SM.FuntionName = "Helper_ExecuteSql10";
            //    SM.strSql = strSQL;
            //    SM.fs = fs;
            //    if (SARO.DataReceived(SARO.SerialOperate(SM)))
            //    {
            //        intValue = 1;
            //    }
            //    else
            //    {
            //        intValue = -1;
            //    }

            //}
            //else
            //{
            intValue = NDBH.ExecuteSqlInsertImg(strSQL, fs);
            //}

            return(intValue);
        }
Beispiel #2
0
        /// <summary>
        /// 反序列化
        /// </summary>
        /// <param name="RecieveData">接收到的流</param>
        /// <returns></returns>
        public bool DeserialOperate(byte[] RecieveData, bool bFlag)
        {
            int       ComandTime = 0;
            ArrayList Arraylist  = null;
            string    strContent = string.Empty;;

            byte[]        fs1     = null;
            int           intRows = 0;
            SqlConnection conn    = new SqlConnection();
            string        strErr  = string.Empty;

            SqlParameter[] parameters = null;
            string         strsql     = string.Empty;

            if (bFlag)
            {
                // strsql = "server=.;database=KJ128N;uid=sa;pwd=sa;Timeout=5";
                strsql = GetConfigValue("ConnectionString").Trim();
            }
            else
            {
                // strsql = "server=.;database=KJ128NBackUp;uid=sa;pwd=sa;Timeout=5";
                strsql = GetConfigValue("ConnectionString").Trim();
            }
            File.WriteAllText(Application.StartupPath + "\\Conn.dw", strsql, Encoding.Default);

            string err = string.Empty;

            err = "";
            int        intFlag         = 0;
            bool       Flag            = false;
            string     strDeserialPath = Application.StartupPath.ToString() + "\\DesialsData.dat";
            FileStream fs = File.Create(strDeserialPath);

            fs.Write(RecieveData, 2, RecieveData.Length - 2);
            fs.Close();
            fs.Dispose();

            Stream          stream = new FileStream(strDeserialPath, FileMode.Open);
            BinaryFormatter bf     = new BinaryFormatter();


            SerialModel sbc = (SerialModel)bf.Deserialize(stream);

            stream.Close();
            if (sbc.parameter != null)
            {
                parameters = new SqlParameter[sbc.parameter.Length];
                for (int i = 0; i < sbc.parameter.Length; i++)
                {
                    parameters[i] = new SqlParameter();
                    parameters[i].ParameterName = sbc.parameter[i].ParameterName;
                    parameters[i].SqlDbType     = sbc.parameter[i].ParameterType;
                    parameters[i].Size          = sbc.parameter[i].intLongth;
                    parameters[i].Value         = sbc.parameter[i].objValue;
                }
            }
            if (sbc.ComandTime != 0)
            {
                ComandTime = sbc.ComandTime;
            }
            if (sbc.Arraylist != null)
            {
                Arraylist = sbc.Arraylist;
            }
            if (sbc.fs != null)
            {
                fs1 = sbc.fs;
            }
            if (sbc.strContent != null)
            {
                strContent = sbc.strContent;
            }

            New_DBAcess     NDBA;
            New_DbHelperSQL NDH;

            switch (sbc.FuntionName)
            {
            case "ACCESS_ExecuteSql1":
                NDBA = new New_DBAcess();
                NDBA.ExecuteSql(sbc.RestoryProcedureName, parameters);
                break;

            case "ACCESS_ExecuteSql2":
                NDBA = new New_DBAcess();
                NDBA.ExecuteSql(sbc.RestoryProcedureName, parameters, out strErr);
                break;

            case "ACCESS_ExecuteSql3":
                NDBA = new New_DBAcess();
                NDBA.ExecuteSql(sbc.RestoryProcedureName, parameters, conn);
                break;

            case "ACCESS_ExecuteSql4":
                NDBA = new New_DBAcess();
                NDBA.ExecuteSql(sbc.strSql, conn);
                break;

            case "ACCESS_ExecuteSql5":
                NDBA = new New_DBAcess();
                NDBA.ExecuteSql(sbc.strSql);
                break;

            case "ACCESS_ExecuteSql6":
                NDBA = new New_DBAcess();
                NDBA.ExistsSql(sbc.strSql);
                break;

            case "Helper_ExecuteSql1":
                NDH = new New_DbHelperSQL();
                NDH.RunProcedureByInt64(sbc.RestoryProcedureName, parameters, out strErr);
                break;

            case "Helper_ExecuteSql2":
                NDH = new New_DbHelperSQL();
                NDH.RunProcedureByInt(sbc.RestoryProcedureName, parameters, out strErr);
                break;

            case "Helper_ExecuteSql3":
                NDH = new New_DbHelperSQL();
                NDH.RunProcedureByInt(sbc.RestoryProcedureName, out strErr);
                break;

            case "Helper_ExecuteSql4":
                NDH = new New_DbHelperSQL();
                NDH.RunProcedureReturnInt(sbc.RestoryProcedureName, parameters, out strErr);
                break;

            case "Helper_ExecuteSql5":
                NDH = new New_DbHelperSQL();
                NDH.ExecuteSql(sbc.strSql);
                break;

            case "Helper_ExecuteSql6":
                NDH = new New_DbHelperSQL();
                NDH.ExecuteSqlByTime(sbc.strSql, ComandTime);
                break;

            case "Helper_ExecuteSql7":
                NDH = new New_DbHelperSQL();
                NDH.ExecuteSqlTran(Arraylist);
                break;

            case "Helper_ExecuteSql8":
                NDH = new New_DbHelperSQL();
                NDH.ExecuteSql(sbc.strSql, sbc.strContent);
                break;

            case "Helper_ExecuteSql9":
                NDH = new New_DbHelperSQL();
                NDH.ExecuteSqlGet(sbc.strSql, sbc.strContent);
                break;

            case "Helper_ExecuteSql10":
                NDH = new New_DbHelperSQL();
                NDH.ExecuteSqlInsertImg(sbc.strSql, fs1);
                break;

            case "Helper_ExecuteSql11":
                NDH = new New_DbHelperSQL();
                NDH.ExecuteSql(sbc.strSql, parameters);
                break;

            case "Helper_ExecuteSql12":
                NDH = new New_DbHelperSQL();
                NDH.RunProcedure(sbc.RestoryProcedureName, parameters, out intRows);
                break;

            case "Helper_ExecuteSql13":
                NDH = new New_DbHelperSQL();
                NDH.RunProcedure(sbc.RestoryProcedureName);
                break;

            default:
                break;
            }

            if (intFlag != -1)
            {
                Flag = true;
            }
            else
            {
                Flag = false;
            }

            if (File.Exists(Application.StartupPath + "\\Conn.dw"))
            {
                File.Delete(Application.StartupPath + "\\Conn.dw");
            }
            return(Flag);
        }