Пример #1
0
        public int InsertDCDevice(DC_DEVICE device)
        {
            string          sql  = $@"INSERT INTO DC.DC_DEVICE(
SERVER_ID, 
NUM, 
NAME, 
IP_ADDRESS, 
MAC_ADDRESS, 
CHANNEL, 
S7CONNECTION, 
DESCRIPTION, 
ENABLE,
CRA_ID)VALUES(
{GetValueStr(device.SERVER_ID)},
{GetValueStr(device.NUM)},
{GetValueStr(device.NAME)},
{GetValueStr(device.IP_ADDRESS)},
{GetValueStr(device.MAC_ADDRESS)},
{GetValueStr(device.CHANNEL)},
{GetValueStr(device.S7CONNECTION)},
{GetValueStr(device.DESCRIPTION)},
{GetValueStr(device.ENABLE)},
{GetValueStr(device.CRA_ID)}
) RETURNING ID INTO :ID";
            OracleParameter para = new OracleParameter("ID", OracleDbType.Int32);
            int             res  = OracleDataHelper.ExecuteNonQuery(sql, new OracleParameter[] { para });

            device.ID = ((OracleDecimal)para.Value).ToInt32();
            return(res);
        }
Пример #2
0
        /// <summary>
        /// 获取设备集合
        /// </summary>
        /// <param name="server"></param>
        /// <returns></returns>
        private List <DC_DEVICE> GetDCDevices(string whereSql)
        {
            string           sql    = $"SELECT * FROM DC.DC_DEVICE WHERE 1=1 {whereSql}";
            OracleDataReader reader = OracleDataHelper.ExecuteReader(sql);
            List <DC_DEVICE> lst    = new List <DC_DEVICE>();

            while (reader.Read())
            {
                DC_DEVICE device = new DC_DEVICE()
                {
                    CHANNEL      = reader["CHANNEL"].ToString(),
                    DESCRIPTION  = reader["DESCRIPTION"].ToString(),
                    ENABLE       = GetValue(reader, "ENABLE"),
                    ID           = Convert.ToInt32(reader["ID"]),
                    IP_ADDRESS   = reader["IP_ADDRESS"].ToString(),
                    MAC_ADDRESS  = reader["MAC_ADDRESS"].ToString(),
                    NAME         = reader["NAME"].ToString(),
                    NUM          = reader["NUM"].ToString(),
                    S7CONNECTION = reader["S7CONNECTION"].ToString(),
                    SERVER_ID    = GetValue(reader, "SERVER_ID"),
                    CRA_ID       = GetValue(reader, "CRA_ID"),
                    FIELD1       = reader["FIELD1"].ToString(),
                    FIELD2       = reader["FIELD2"].ToString(),
                    FIELD3       = reader["FIELD3"].ToString(),
                };
                lst.Add(device);
            }
            reader.Close();
            return(lst);
        }
Пример #3
0
        /// <summary>
        /// 查询数据库表单列
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public DataTable GetColumns(string table)
        {
            string sql = $@" select OWNER, TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE 
from all_tab_columns where Table_Name='{table}' ";

            return(OracleDataHelper.ExecuteDataTable(sql));
        }
 /// <summary>
 /// 获取未处理的记录
 /// </summary>
 /// <returns></returns>
 public List <CRANE_ACTION_RECORD_X> GetCraneActionRecords()
 {
     //List<int> lstID = new List<int>() { 6,7,8,9,10,11};
     //List<int> lstID = new List<int>() { 1,2,3,4};
     //List<int> lstSymbol = new List<int>() { 1,2,3,4,6};
     return(OracleDataHelper.Query <CRANE_ACTION_RECORD_X>(s => s.DEAL_SYMBOL == null || s.DEAL_SYMBOL != 2).OrderBy(s => s.OPERATION_TIME).ToList());
 }
Пример #5
0
        /// <summary>
        /// 获取服务器
        /// </summary>
        /// <param name="serverNum"></param>
        /// <returns></returns>
        public List <DC_SERVER> GetDCServers()
        {
            string           sql    = $"SELECT * FROM DC.DC_SERVER";
            OracleDataReader reader = OracleDataHelper.ExecuteReader(sql);
            List <DC_SERVER> lst    = new List <DC_SERVER>();

            while (reader.Read())
            {
                DC_SERVER server = new DC_SERVER()
                {
                    DESCRIPTION = reader["DESCRIPTION"].ToString(),
                    ENABLE      = GetValue(reader, "ENABLE"),
                    ID          = Convert.ToInt32(reader["ID"]),
                    IP_ADDRESS  = reader["IP_ADDRESS"].ToString(),
                    NAME        = reader["NAME"].ToString(),
                    NUM         = reader["NUM"].ToString(),
                    FIELD1      = reader["FIELD1"].ToString(),
                    FIELD2      = reader["FIELD2"].ToString(),
                    FIELD3      = reader["FIELD3"].ToString(),
                };
                lst.Add(server);
            }
            reader.Close();
            return(lst);
        }
Пример #6
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        /*select distinct lsh,sfzmhm,xm,kscx,pxshrq,kchp,ykrq,jbr,dmmc1 from drv_admin.drv_preasign t left join drv_admin.drv_code m on m.dmlb=42
         * and m.dmz=t.dlr where t.glbm like '4405%'*/
        string date = this.txtDate.Value;

        if (date.Length == 0)
        {
            WebTools.Alert(this, "必须选择一个日期!");
            return;
        }
        string glbm = System.Configuration.ConfigurationManager.AppSettings["DrvHelperSystem_glbm"];
        string sql  = "select distinct lsh,sfzmhm,decode(kskm,1,'科目一',2,'科目二',3,'科目三') kskm,xm,kscx,to_char(pxshrq,'yyyy-MM-dd') pxshrq,kchp,to_char(ykrq,'yyyy-MM-dd') ykrq,jbr,dmmc1  from drv_admin.drv_preasign t left join drv_admin.drv_code m on m.dmlb=42 and m.dmz=t.dlr ";

        sql += " where t.glbm like '" + glbm + "%'";
        //天排班
        if (this.RadioButtonList1.SelectedIndex == 0)
        {
            sql += " and trunc(ykrq)=trunc(to_date('" + this.txtDate.Value + "','yyyy-MM-dd'))";
        }
        else if (this.RadioButtonList1.SelectedIndex == 1)
        {
            sql += " and trunc(ykrq)=trunc(to_date('" + this.txtDate.Value + "','yyyy-MM-dd'))";
            sql += " and kskm= " + this.cbKm.SelectedItem.Value + " and kscc ='" + this.cbKscc.SelectedItem.Value + "'"
                   + "  and ksdd='" + this.cbKsdd.SelectedItem.Value + "'";
        }
        IDataAccess access = new OracleDataHelper(System.Configuration.ConfigurationManager.AppSettings["DefaultConnString2"]);
        DataTable   dt     = access.SelectDataTable(sql, "tmp");

        if (dt != null)
        {
            this.DataGrid1.DataSource = dt;
            this.DataGrid1.DataBind();
        }
    }
Пример #7
0
        /// <summary>
        /// 查询 DC_WRITE_DATA
        /// </summary>
        /// <returns></returns>
        public List <DC_WRITE_DATA> GetWriteDatasUpdated()
        {
            string               sql    = $@"SELECT * FROM DC.DC_WRITE_DATA WHERE UPDATED=1";
            OracleDataReader     reader = OracleDataHelper.ExecuteReader(sql);
            List <DC_WRITE_DATA> lst    = new List <DC_WRITE_DATA>();

            while (reader.Read())
            {
                DC_WRITE_DATA data = new DC_WRITE_DATA()
                {
                    ID             = Convert.ToInt32(reader["ID"]),
                    DATA_CONFIG_ID = GetValue(reader, "DATA_CONFIG_ID"),
                    VALUE          = GetValue(reader, "VALUE"),
                    UPDATED        = GetValue(reader, "UPDATED"),
                    WRITE_TIME     = GetValue(reader, "WRITE_TIME"),
                    UPDATE_TIME    = GetValue(reader, "UPDATE_TIME"),
                    FIELD1         = reader["FIELD1"].ToString(),
                    FIELD2         = reader["FIELD2"].ToString(),
                    FIELD3         = reader["FIELD3"].ToString(),
                };
                lst.Add(data);
            }
            reader.Close();
            return(lst);
        }
Пример #8
0
        public int DeleteDataConfig(DC_DATA_CONFIG config)
        {
            DeleteRealData(config.ID);
            string sql = $@"DELETE FROM DC.DC_DATA_CONFIG WHERE ID={GetValueStr(config.ID)}";

            return(OracleDataHelper.ExecuteNonQuery(sql));
        }
Пример #9
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        string      sql    = "select distinct dmz,dmz||':'||dmmc1 as dmmc1 from drv_admin.drv_code t where dmlb=33 and (dmz = '" + this.txtCode.Text.Trim() + "' or dmmc1='" + this.txtName.Text.Trim() + "')";
        IDataAccess access = new OracleDataHelper(FT.Commons.Security.SecurityFactory.GetSecurity().Decrypt(System.Configuration.ConfigurationManager.AppSettings["DefaultConnString2"]));
        DataTable   dt1    = access.SelectDataTable(sql, "tmp");

        if (dt1 != null && dt1.Rows.Count > 0)
        {
            string code = dt1.Rows[0][0].ToString();
            if (code.EndsWith("0000"))
            {
                this.ddlProvince.SelectedValue = code;
            }
            else if (code.EndsWith("00"))
            {
                this.ddlProvince.SelectedValue = code.Substring(0, 2) + "0000";
                this.ddlProvince_SelectedIndexChanged(null, null);
                this.ddlCity.SelectedValue = code;
            }
            else
            {
                this.ddlProvince.SelectedValue = code.Substring(0, 2) + "0000";
                this.ddlProvince_SelectedIndexChanged(null, null);
                this.ddlCity.SelectedValue = code.Substring(0, 4) + "00";
                this.ddlCity_SelectedIndexChanged(null, null);

                this.ddlArea.SelectedValue = code;
            }
        }
    }
Пример #10
0
        public int InsertRealData(int configID)
        {
            string sql = $@"INSERT INTO DC.DC_REAL_DATA(
DATA_CONFIG_ID, 
UPDATED)VALUES(
'{configID}',0)";

            return(OracleDataHelper.ExecuteNonQuery(sql));
        }
Пример #11
0
        /// <summary>
        /// 更新实时数据
        /// </summary>
        /// <param name="dataPointID"></param>
        /// <param name="value"></param>
        /// <param name="quality"></param>
        /// <param name="stamp"></param>
        /// <param name="updateTime"></param>
        /// <param name="updated"></param>
        /// <returns></returns>
        public int UpdateRealData(int dataID, object value, string quality, DateTime stamp, DateTime updateTime, int updated)
        {
            string sql = $@"UPDATE DC.DC_REAL_DATA SET VALUE='{value}',QUALITY='{quality}',
TIME_STAMP=TO_DATE('{stamp.ToString("yyyy/MM/dd HH:mm:ss")}','yyyy/mm/dd hh24:mi:ss'),
UPDATE_TIME=TO_DATE('{updateTime.ToString("yyyy/MM/dd HH:mm:ss")}','yyyy/mm/dd hh24:mi:ss'),
UPDATED={updated} WHERE DATA_CONFIG_ID={dataID}";

            return(OracleDataHelper.ExecuteNonQuery(sql));
        }
Пример #12
0
        private static IDataAccess GetInnerDbAccess()
        {
            string tmp = System.Configuration.ConfigurationManager.AppSettings["DefaultConnString2"];

            log.Debug("DefaultConnString2 is:" + tmp);
            string connStr = FT.Commons.Security.SecurityFactory.GetSecurity().Decrypt(tmp);

            IDataAccess access = new OracleDataHelper(connStr);

            return(access);
        }
Пример #13
0
        public int ModifyDCServer(DC_SERVER server)
        {
            string sql = $@"UPDATE DC.DC_SERVER SET
NUM={GetValueStr(server.NUM)},
NAME={GetValueStr(server.NAME)},
IP_ADDRESS={GetValueStr(server.IP_ADDRESS)},
DESCRIPTION={GetValueStr(server.DESCRIPTION)},
ENABLE={GetValueStr(server.ENABLE)}
WHERE ID={GetValueStr(server.ID)}";

            return(OracleDataHelper.ExecuteNonQuery(sql));
        }
Пример #14
0
        /// <summary>
        /// 插入动作
        /// </summary>
        /// <param name="craID"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="l_y"></param>
        /// <param name="z"></param>
        /// <param name="l_z"></param>
        /// <param name="wgt"></param>
        /// <param name="l_wgt"></param>
        /// <param name="symbol"></param>
        /// <param name="count"></param>
        /// <param name="cNum"></param>
        /// <returns></returns>
        public int InsertAction(int craID, object time, object x, object y, object l_y, object z, object l_z, object wgt, object l_wgt, object symbol, object count, object cNum)
        {
            if (CraneActionColumns == null)
            {
                CraneActionColumns = GetColumns("CRANE_ACTION_RECORD").Rows.Cast <DataRow>().ToList();
            }

            DataRow timerow   = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "OPERATION_TIME");
            DataRow xrow      = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "COORD_X");
            DataRow yrow      = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "COORD_Y");
            DataRow l_yrow    = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "LIITLT_HOOK_Y");
            DataRow zrow      = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "COORD_Z");
            DataRow l_zrow    = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "LITTLE_HOOK_Z");
            DataRow wgtrow    = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "WEIGHT");
            DataRow symbolrow = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "ACTION_SYMBOL");
            DataRow countrow  = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "HANGE_QUAN");
            DataRow cNumrow   = CraneActionColumns.First(s => s["COLUMN_NAME"].ToString() == "CACHE_NUM");

            time   = ParseValue(time, timerow);
            x      = ParseValue(x, xrow);
            y      = ParseValue(y, yrow);
            l_y    = ParseValue(l_y, l_yrow);
            z      = ParseValue(z, zrow);
            l_z    = ParseValue(l_z, l_zrow);
            wgt    = ParseValue(wgt, wgtrow);
            symbol = ParseValue(symbol, symbolrow);
            count  = ParseValue(count, countrow);
            cNum   = ParseValue(cNum, cNumrow);

            time   = ValidateValueRange(timerow, time.ToString())? time : null;
            x      = ValidateValueRange(xrow, x.ToString())?x: null;
            y      = ValidateValueRange(yrow, y.ToString())?y: null;
            l_y    = ValidateValueRange(l_yrow, l_y.ToString())? l_y : null;
            z      = ValidateValueRange(zrow, z.ToString())? z : null;
            l_z    = ValidateValueRange(l_zrow, l_z.ToString())? l_z : null;
            wgt    = ValidateValueRange(wgtrow, wgt.ToString())? wgt : null;
            symbol = ValidateValueRange(symbolrow, symbol.ToString())? symbol : null;
            count  = ValidateValueRange(countrow, count.ToString())? count : null;
            cNum   = ValidateValueRange(cNumrow, cNum.ToString())? cNum : null;

            string guid = Guid.NewGuid().ToString("N");
            string sql  = $@"INSERT INTO PUB.CRANE_ACTION_RECORD(ID,CRA_ID,ACCEPT_TIME,OPERATION_TIME,COORD_X,COORD_Y,LIITLT_HOOK_Y,COORD_Z,LITTLE_HOOK_Z,
WEIGHT,LITTLE_HOOK_WEIGHT,ACTION_SYMBOL,HANGE_QUAN,CACHE_NUM)
VALUES('{guid}','{craID}',{GetDateTimeStr(DateTime.Now)},{GetDateTimeStr(time)},{GetValueStr(x)},{GetValueStr(y)},{GetValueStr(l_y)},{GetValueStr(z)},{GetValueStr(l_z)},
{GetValueStr(wgt)},{GetValueStr(l_wgt)},{GetValueStr(symbol)},{GetValueStr(count)},{GetValueStr(cNum)})";

            return(OracleDataHelper.ExecuteNonQuery(sql));
        }
Пример #15
0
        public int InsertDataConfig(DC_DATA_CONFIG config)
        {
            string          sql  = $@"INSERT INTO DC.DC_DATA_CONFIG(
DEVICE_ID, 
NUM, 
NAME, 
MEMORY_ADDRESS, 
SUBSCRIPTION, 
DESCRIPTION, 
ENABLE,
TABLE_USER,
TABLE_NAME,
IDENTITY_COLUMN,
IDENTITY_VALUE,
FIELD_NAME,
FIELD_DATA_TYPE,
FIELD_DATA_LENGTH,
FIELD_DATA_PRECISION,
FIELD_DATA_SCALE,
CONVERTER
)VALUES(
{GetValueStr(config.DEVICE_ID)},
{GetValueStr(config.NUM)},
{GetValueStr(config.NAME)},
{GetValueStr(config.MEMORY_ADDRESS)},
{GetValueStr(config.SUBSCRIPTION)},
{GetValueStr(config.DESCRIPTION)},
{GetValueStr(config.ENABLE)},
{GetValueStr(config.TABLE_USER)},
{GetValueStr(config.TABLE_NAME)},
{GetValueStr(config.IDENTITY_COLUMN)},
{GetValueStr(config.IDENTITY_VALUE)},
{GetValueStr(config.FIELD_NAME)},
{GetValueStr(config.FIELD_DATA_TYPE)},
{GetValueStr(config.FIELD_DATA_LENGTH)},
{GetValueStr(config.FIELD_DATA_PRECISION)},
{GetValueStr(config.FIELD_DATA_SCALE)},
{GetValueStr(config.CONVERTER)}
) RETURNING ID INTO :ID";
            OracleParameter para = new OracleParameter("ID", OracleDbType.Int32);
            int             res  = OracleDataHelper.ExecuteNonQuery(sql, new OracleParameter[] { para });

            config.ID = ((OracleDecimal)para.Value).ToInt32();
            InsertRealData(config.ID);
            return(res);
        }
Пример #16
0
        public int ModifyDevice(DC_DEVICE device)
        {
            string sql = $@"UPDATE DC.DC_DEVICE SET
SERVER_ID={GetValueStr(device.SERVER_ID)},
NUM={GetValueStr(device.NUM)},
NAME={GetValueStr(device.NAME)},
IP_ADDRESS={GetValueStr(device.IP_ADDRESS)},
MAC_ADDRESS={GetValueStr(device.MAC_ADDRESS)},
CHANNEL={GetValueStr(device.CHANNEL)},
S7CONNECTION={GetValueStr(device.S7CONNECTION)},
DESCRIPTION={GetValueStr(device.DESCRIPTION)},
ENABLE={GetValueStr(device.ENABLE)},
CRA_ID={GetValueStr(device.CRA_ID)}
WHERE ID={GetValueStr(device.ID)}";

            return(OracleDataHelper.ExecuteNonQuery(sql));
        }
Пример #17
0
        public bool DeleteGroupInfo(string groupId)
        {
            string query = "CHAT.GROUP_DISABLE";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                helper.ExecuteNonQuery(query, groupId);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #18
0
        /// <summary>
        /// 更新实时数据至业务表
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="dic"></param>
        /// <returns></returns>
        public int UpdateRealData2BusiTable(string user, string table, string identityValue, Dictionary <DC_DATA_CONFIG, DC_REAL_DATA> dic)
        {
            var datas = dic.Where(s => ValidateValueQuality(s.Value));                                                                                                                      //校验质量

            datas = ConvertValue(datas);                                                                                                                                                    //转换值

            datas = datas.Where(s => ValidateValueRange(s.Key.FIELD_DATA_TYPE, s.Key.FIELD_DATA_PRECISION ?? 0, s.Key.FIELD_DATA_SCALE ?? 0, s.Key.FIELD_DATA_LENGTH ?? 0, s.Value.VALUE)); //校验范围

            if (datas.Count() != 0)
            {
                string str = string.Join(",", datas.Select(s => $"{s.Key.FIELD_NAME}={GetValueStr(s.Key, s.Value)}")); //字段赋值字符串

                string sql = $@"UPDATE {user}.{table} SET {str} WHERE ID='{identityValue}'";                           //完整sql

                return(OracleDataHelper.ExecuteNonQuery(sql));                                                         //执行
            }
            return(0);
        }
Пример #19
0
        public bool ChangeLastOnline(string customerId, DateTime time)
        {
            string query = "CHAT.CUSTOMER_LASTONLINE";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                helper.ExecuteNonQuery(query, customerId, time);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #20
0
        public bool UnFriend(string customerId, string requestId)
        {
            string query = "CHAT.FRIEND_DELETE";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                helper.ExecuteNonQuery(query, customerId, requestId);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #21
0
        public bool AddMessage(MessageInfo msg)
        {
            string query = "CHAT.MESSAGE_CREATE";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                helper.ExecuteNonQuery(query, msg.Id, msg.SenderId, msg.ReceiverId, msg.Content, msg.Datetime, msg.MessageType);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #22
0
        public bool DeleteFriendRequest(string requestId)
        {
            string query = "CHAT.FRIENDREQUEST_DELETE";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                helper.ExecuteNonQuery(query, requestId);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #23
0
        public bool UpdateCustomerInfo(CustomerInfo cus)
        {
            string query = "CHAT.CUSTOMER_UPDATE";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                helper.ExecuteNonQuery(query, cus.CustomerId, cus.CustomerName);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #24
0
        public bool AddFriendRequest(AddFriendRequest request)
        {
            string query = "CHAT.FRIENDREQUEST_CREATE";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                helper.ExecuteNonQuery(query, request.Id, request.Sender, request.Receiver, request.Datetime);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #25
0
        public bool LeaveGroup(string customerId, string groupId)
        {
            string query = "CHAT.LEAVEGROUP";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                helper.ExecuteNonQuery(query, customerId, groupId);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #26
0
        public bool UpdateGroupInfo(GroupInfo group)
        {
            string query = "CHAT.GROUP_UPDATE";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                helper.ExecuteNonQuery(query, group.GroupId, group.GroupName, group.Description, group.IsPrivate);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #27
0
        public int InsertDCServer(DC_SERVER server)
        {
            string          sql  = $@"INSERT INTO DC.DC_SERVER(
NUM, 
NAME, 
IP_ADDRESS, 
DESCRIPTION, 
ENABLE
)VALUES(
{GetValueStr(server.NUM)},
{GetValueStr(server.NAME)},
{GetValueStr(server.IP_ADDRESS)},
{GetValueStr(server.DESCRIPTION)},
{GetValueStr(server.ENABLE)}
) RETURNING ID INTO :ID";
            OracleParameter para = new OracleParameter("ID", OracleDbType.Int32);
            int             res  = OracleDataHelper.ExecuteNonQuery(sql, new OracleParameter[] { para });

            server.ID = ((OracleDecimal)para.Value).ToInt32();
            return(res);
        }
Пример #28
0
        public static void TestConnection2(int num)
        {
            IDataAccess accessOracle = new OracleDataHelper("oradrv", "aspnet", "stjj117");

            Console.WriteLine(System.DateTime.Now.ToLocalTime().ToString() + "开始执行");
            for (int i = 0; i < num; i++)
            {
                try
                {
                    string sql = "insert into table_test(name,sex) values('name" + i.ToString() + "','male')";
                    accessOracle.SelectDataTable("select 1 from dual", "tmp");
                    // accessOracle.ExecuteSql(sql);
                }
                catch (Exception e)
                {
                    Console.WriteLine("执行到第几次打开关闭连接出现异常-》" + i.ToString());
                    Console.WriteLine(e.ToString());
                    break;
                }
            }
            Console.WriteLine(System.DateTime.Now.ToLocalTime().ToString() + "执行完毕");
            Console.ReadLine();
        }
Пример #29
0
        public bool SetAdminGroup(string customerId, string groupId, bool isAdmin)
        {
            string query = "CHAT.SETADMINGROUP";

            try
            {
                OracleDataHelper helper = OracleHelper;
                helper.BeginTransaction();
                int admin = 0;
                if (isAdmin)
                {
                    admin = 1;
                }
                helper.ExecuteNonQuery(query, customerId, groupId, admin);
                helper.Commit();
            }
            catch (Exception ex)
            {
                OracleHelper.Rollback();
                throw ex;
            }
            return(true);
        }
Пример #30
0
        /// <summary>
        /// 获取数据点配置集合
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public List <DC_DATA_CONFIG> GetDCDataConfigs(string whereSql)
        {
            string                sql    = $"SELECT * FROM DC.DC_DATA_CONFIG WHERE 1=1 {whereSql}";
            OracleDataReader      reader = OracleDataHelper.ExecuteReader(sql);
            List <DC_DATA_CONFIG> lst    = new List <DC_DATA_CONFIG>();

            while (reader.Read())
            {
                DC_DATA_CONFIG config = new DC_DATA_CONFIG()
                {
                    DESCRIPTION          = reader["DESCRIPTION"].ToString(),
                    ENABLE               = GetValue(reader, "ENABLE"),
                    ID                   = Convert.ToInt32(reader["ID"]),
                    NAME                 = reader["NAME"].ToString(),
                    NUM                  = reader["NUM"].ToString(),
                    DEVICE_ID            = GetValue(reader, "DEVICE_ID"),
                    CONVERTER            = GetValue(reader, "CONVERTER"),
                    FIELD_DATA_LENGTH    = GetValue(reader, "FIELD_DATA_LENGTH"),
                    FIELD_DATA_PRECISION = GetValue(reader, "FIELD_DATA_PRECISION"),
                    FIELD_DATA_SCALE     = GetValue(reader, "FIELD_DATA_SCALE"),
                    FIELD_DATA_TYPE      = GetValue(reader, "FIELD_DATA_TYPE"),
                    TABLE_NAME           = GetValue(reader, "TABLE_NAME"),
                    TABLE_USER           = GetValue(reader, "TABLE_USER"),
                    IDENTITY_VALUE       = GetValue(reader, "IDENTITY_VALUE"),
                    IDENTITY_COLUMN      = GetValue(reader, "IDENTITY_COLUMN"),
                    FIELD_NAME           = GetValue(reader, "FIELD_NAME"),
                    MEMORY_ADDRESS       = reader["MEMORY_ADDRESS"].ToString(),
                    SUBSCRIPTION         = GetValue(reader, "SUBSCRIPTION"),
                    FIELD1               = reader["FIELD1"].ToString(),
                    FIELD2               = reader["FIELD2"].ToString(),
                    FIELD3               = reader["FIELD3"].ToString(),
                };
                lst.Add(config);
            }
            reader.Close();
            return(lst);
        }