コード例 #1
0
 /// <summary>
 /// 执行选择单个值的参数化SQL。
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="parameters"></param>
 /// <param name="commandType"></param>
 /// <returns></returns>
 public object ExecuteScalar(string sql, DynamicParameters parameters = null, CommandType?commandType = null)
 {
     if (CurrentTransaction != null)
     {
         return(DbExecProxy <object>((param) => CurrentConnection.ExecuteScalar(sql, param, CurrentTransaction, null, commandType), sql, parameters));
     }
     using var connection = GetDbConnection(DataSourceEnum.SLAVE);
     return(DbExecProxy <object>((param) => connection.ExecuteScalar(sql, param, CurrentTransaction, null, commandType), sql, parameters));
 }
コード例 #2
0
 public Task <int> ExecuteAsync(string sql, DynamicParameters parameters = null, CommandType?commandType = null)
 {
     if (CurrentTransaction != null)
     {
         return(DbExecProxyAsync <int>((param) => CurrentConnection.ExecuteAsync(sql, param, CurrentTransaction, null, commandType), sql, parameters));
     }
     using var connection = GetDbConnection(DataSourceEnum.MASTER);
     return(DbExecProxyAsync <int>((param) => connection.ExecuteAsync(sql, param, CurrentTransaction, null, commandType), sql, parameters));
 }
コード例 #3
0
 private void loadAllHouses()
 {
     loadedVillagerHouses = new List <VillagerHouse2>();
     byte[] houses = CurrentConnection.ReadBytes(CurrentVillagerHouseAddress, VillagerHouse2.SIZE * 10);
     for (int i = 0; i < 10; ++i)
     {
         loadedVillagerHouses.Add(new VillagerHouse2(houses.Slice(i * VillagerHouse2.SIZE, VillagerHouse2.SIZE)));
     }
 }
コード例 #4
0
 public void Commit()
 {
     CurrentTransaction?.Commit();
     CurrentTransaction?.Dispose();
     if (CurrentConnection?.State == ConnectionState.Open)
     {
         CurrentConnection.Close();
     }
     CurrentConnection?.Dispose();
 }
コード例 #5
0
        /// <summary>
        /// 条件判断是否存在
        /// </summary>
        /// <returns>是否存在</returns>
        /// <param name="predicate">判断条件委托</param>
        public bool Exist <T>(Expression <Func <T, bool> > predicate = null)
            where T : ModelBase
        {
            string      tableName   = GetTableName <T>();
            QueryResult queryResult = DynamicQuery.GetDynamicQuery(tableName, predicate);

            object result = CurrentConnection.ExecuteScalar(queryResult.Sql, (object)queryResult.Param, CurrentTransaction);

            return(result != null);
        }
コード例 #6
0
 public void Rollback()
 {
     CurrentTransaction?.Rollback();
     CurrentTransaction?.Dispose();
     if (CurrentConnection?.State == ConnectionState.Open)
     {
         CurrentConnection.Close();
     }
     CurrentConnection?.Dispose();
 }
コード例 #7
0
        /// <summary>
        /// 内部方法,sql不处理
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entityToDelete"></param>
        /// <returns></returns>
        public bool Delete <T>(T entityToDelete) where T : class
        {
            if (CurrentTransaction != null)
            {
                return(CurrentConnection.Delete <T>(entityToDelete, CurrentTransaction, CommandTimeout));
            }
            using var connection = GetDbConnection(DataSourceEnum.MASTER);

            return(connection.Delete <T>(entityToDelete, CurrentTransaction, CommandTimeout));
        }
コード例 #8
0
        private void GridNetwork_MouseMove(object sender, MouseEventArgs e)
        {
            if (isDragging == true)
            {
                Debug.WriteLine("Moving mouse on network canvas");
                Debug.WriteLine("MAKING connection");
                var currentPosition = e.GetPosition(net_canvas);
                Debug.WriteLine("Current position: " + currentPosition.X.ToString() + "," + currentPosition.Y.ToString());
                secondPosition = currentPosition;
                var currentLine = new Line {
                    From = new Point(firstPosition.X, firstPosition.Y), To = new Point(secondPosition.X, secondPosition.Y), Stroke = Brushes.Green, StrokeThickness = 10
                };
                if (indexCurrentLine >= 1)
                {
                    Debug.WriteLine(indexCurrentLine);
                    CurrentConnection.RemoveAt(indexCurrentLine - 1);
                }
                CurrentConnection.Add(currentLine);
            }
            else
            {
                if (Nodes.Count() != 0)
                {
                    //CurrentConnection.Add(new Line
                    //{
                    //    From = new Point(firstPosition.X, firstPosition.Y),
                    //    To = new Point(Nodes[0].X, Nodes[0].Y),
                    //    Stroke = Brushes.BlueViolet,
                    //    StrokeThickness = 3
                    //});

                    //var currentLine = new Line { From = new Point(Nodes[0].X, Nodes[0].Y + Nodes[0].ActualHeight/ 2),
                    //    To = new Point(secondPosition.X, secondPosition.Y),
                    //    Stroke = Brushes.BlueViolet, StrokeThickness = 3 };
                    //if (indexCurrentLine >= 1)
                    //{
                    //    Debug.WriteLine(indexCurrentLine);
                    //    CurrentConnection.RemoveAt(indexCurrentLine - 1);
                    //}
                    //CurrentConnection.Add(currentLine);
                    //for (int i = 0; i < Connections.Count(); i++)
                    //{
                    //    var currentLine = new Line
                    //    {
                    //        From = new Point(Nodes[0].X, Nodes[0].Y + Nodes[0].ActualHeight / 2),
                    //        To = new Point(secondPosition.X, secondPosition.Y),
                    //        Stroke = Brushes.BlueViolet,
                    //        StrokeThickness = 3
                    //    };
                    //    Connections.Add(currentLine);
                    //}
                }
            }
            indexCurrentLine = CurrentConnection.Count() - 1;
        }
コード例 #9
0
    private void loadVillagerBytes(byte[] bytes)
    {
        var villagerBytes      = bytes.Take(VillagersSize).ToArray();
        var villagerHouseBytes = bytes.Skip(VillagersSize).ToArray();

        UI_Popup.CurrentInstance.CreatePopupMessage(0.001f, "Sending all villager data, this may take a long time...", () =>
        {
            CurrentConnection.WriteBytes(villagerBytes, CurrentVillagerAddress);
            CurrentConnection.WriteBytes(villagerHouseBytes, CurrentVillagerHouseAddress);
        });
    }
コード例 #10
0
        public IConsumer GetConsumer(string queueName)
        {
            if (string.IsNullOrWhiteSpace(queueName))
            {
                throw new ArgumentNullException(nameof(queueName));
            }

            var channel = CurrentConnection.CreateModel();

            return(new Consumer(channel, queueName));
        }
コード例 #11
0
        public IPublisher GetPublisher(string exchangeName)
        {
            if (string.IsNullOrWhiteSpace(exchangeName))
            {
                throw new ArgumentNullException(nameof(exchangeName));
            }

            var channel = CurrentConnection.CreateModel();

            return(new Publisher(channel, exchangeName));
        }
コード例 #12
0
        public void DeclareExchange(string exchangeName, string exchangeType)
        {
            if (string.IsNullOrWhiteSpace(exchangeName))
            {
                throw new ArgumentNullException(nameof(exchangeName));
            }

            using (var channel = CurrentConnection.CreateModel())
            {
                channel.ExchangeDeclare(exchangeName.ToLowerInvariant(), exchangeType, this.Durable);
            }
        }
コード例 #13
0
        public ICollection <ContactsBackendMap> GetPerEntita(int idEntita)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("WITH T_BACK AS (");
            sb.Append(" SELECT REF_ID_BACKEND");
            sb.Append(" FROM RUBR_CONTATTI_BACKEND");
            sb.Append(" WHERE REF_ID_ENTITA = :pID_ENTITA),");
            sb.Append("T_CONT_BACK AS (");
            sb.Append(" SELECT *");
            sb.Append(" FROM RUBR_CONTATTI_BACKEND");
            sb.Append(" WHERE REF_ID_BACKEND IN ");
            sb.Append("     (SELECT DISTINCT REF_ID_BACKEND");
            sb.Append("      FROM T_BACK))");
            sb.Append(" SELECT *");
            sb.Append(" FROM T_CONT_BACK");
            sb.Append(" UNION");
            sb.Append(" SELECT NULL, 1, REF_ID_BACKEND, NULL, ID_TITOLO, NULL");
            sb.Append(" FROM COMUNICAZIONI_TITOLI CT, T_BACK TB");
            sb.Append(" WHERE ID_TITOLO != 0");
            sb.Append(" AND NOT EXISTS (");
            sb.Append("     SELECT 1");
            sb.Append("     FROM T_CONT_BACK TCB");
            sb.Append("     WHERE TCB.REF_ID_TITOLO = CT.ID_TITOLO");
            sb.Append("     AND TCB.REF_ID_BACKEND = TB.REF_ID_BACKEND)");
            sb.Append(" ORDER BY 3, 5");

            try
            {
                using (OracleCommand cmd = CurrentConnection.CreateCommand())
                {
                    cmd.CommandText = sb.ToString();
                    cmd.BindByName  = true;
                    cmd.Parameters.Add("pID_ENTITA", OracleDbType.Decimal, idEntita, System.Data.ParameterDirection.Input);

                    ICollection <ContactsBackendMap> contacts = DaoOracleDbHelper <ContactsBackendMap> .ExecSelectCommand(cmd,
                                                                                                                          DaoOracleDbHelper.MapToContactsBackendMap);

                    if (contacts != null)
                    {
                        foreach (ContactsBackendMap c in contacts)
                        {
                            Complete(c);
                        }
                    }
                    return(contacts);
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #14
0
 public string EntityToUpdateSql <T>(T entity) where T : class
 {
     if (CurrentConnection != null)
     {
         return(CurrentConnection.EntityToUpdateSql(entity));
     }
     else
     {
         using var connection = GetDbConnection(DataSourceEnum.MASTER);
         return(connection.EntityToUpdateSql(entity));
     }
 }
コード例 #15
0
 public IActionResult SetCurrentConnection(CurrentConnection connection)
 {
     try
     {
         _communicator.CurrentConnection = connection;
         return(NoContent());
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
コード例 #16
0
 /// <summary>
 /// Clones the current connection in a new one
 /// </summary>
 public void Clone()
 {
     if (CurrentConnection != null)
     {
         SqlConnectionInfo newItem = CurrentConnection.Clone();
         newItem.ConnectionID += "(Copy)";
         SqlConnections.Add(newItem);
         CurrentConnection = newItem;
         IsInEditMode      = true;
         IsChanged         = true;
     }
 }
コード例 #17
0
 public void SetTimeFreeze(bool freeze)
 {
     if (freeze)
     {
         CurrentConnection.WriteBytes(BitConverter.GetBytes(FreezeTimeValue), OffsetHelper.TimeStateAddress, NHSE.Injection.RWMethod.Main);
     }
     else
     {
         CurrentConnection.WriteBytes(BitConverter.GetBytes(UnFreezeTimeValue), OffsetHelper.TimeStateAddress, NHSE.Injection.RWMethod.Main);
         FetchTime();
     }
 }
コード例 #18
0
 public RabbitMQConnectionFactory(IConnectionFactory connectionFactory)
 {
     _connectionFactory = connectionFactory;
     _lazyConnection    = new Lazy <IConnection>(
         () => _connectionFactory.CreateConnection(),
         LazyThreadSafetyMode.ExecutionAndPublication
         );
     _lazyChannel = new Lazy <IModel>(
         () => CurrentConnection.CreateModel(),
         LazyThreadSafetyMode.ExecutionAndPublication
         );
 }
コード例 #19
0
    public void ClearCustomFreeze()
    {
        bool success = uint.TryParse(OffsetField.text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out var res);

        if (!success)
        {
            PopupHelper.CreateError($"Cannot parse {OffsetField.text} as a hexadecimal value.", 3f);
            return;
        }
        CurrentConnection.UnFreezeBytes(res);
        UpdateFreezeCount();
    }
コード例 #20
0
 public string FapDynamicToUpdateSql(FapDynamicObject fdo, string tableName, IEnumerable <FapColumn> columns)
 {
     if (CurrentConnection != null)
     {
         return(CurrentConnection.FapDynamicDataToUpdateSql(tableName, columns, fdo));
     }
     else
     {
         using var connection = GetDbConnection(DataSourceEnum.MASTER);
         return(connection.FapDynamicDataToUpdateSql(tableName, columns, fdo));
     }
 }
コード例 #21
0
        /// <summary>
        /// 执行与释放或重置非托管资源关联的应用程序定义的任务。
        /// </summary>
        public void Dispose()
        {
            if (CurrentTransaction != null)
            {
                CurrentTransaction.Dispose();
                CurrentTransaction = null;
            }

            if (CurrentConnection != null)
            {
                CurrentConnection.Dispose();
            }
        }
コード例 #22
0
 public void CloseConnection()
 {
     if (CurrentTransaction != null)
     {
         CurrentTransaction.Rollback();
     }
     if (CurrentConnection != null)
     {
         CurrentConnection.Close();
         CurrentConnection  = null;
         CurrentTransaction = null;
     }
 }
コード例 #23
0
    public PosRotAnchor GetCurrentPlayerPositionalData(string name)
    {
        var offset            = PointerSolver.FollowMainPointer(CurrentConnection, OffsetHelper.PlayerCoordJumps, beriBase);
        var bytesA            = CurrentConnection.ReadBytes(offset, 0xC, NHSE.Injection.RWMethod.Absolute);
        var bytesB            = CurrentConnection.ReadBytes(offset + 0x3C, 0x4, NHSE.Injection.RWMethod.Absolute);
        var sequentinalAnchor = bytesA.Concat(bytesB).ToArray();

        //testing
        //var bytesAAlt = CurrentConnection.PeekMainPointer(OffsetHelper.PlayerCoordJumps, 0xC);
        //Debug.Log($"Match: {bytesA.SequenceEqual(bytesAAlt)}");

        return(new PosRotAnchor(sequentinalAnchor, name));
    }
コード例 #24
0
ファイル: CharSpace.cs プロジェクト: Charspace/CHARS.LMS
        private void loadTrail()
        {
            try
            {
                #region "Trial"
                if (mConnectionBLL.checkConnection())
                {
                    mCurretnConnection = new CurrentConnection(Application.StartupPath);
                    bindGlobalConnection();
                    bindGlobalOrganization();
                    mLogin = new ProLogin(mLoginUserBLL.readLoginUser(), Application.StartupPath);
                    mLogin.ShowDialog();
                    if (mLogin.DialogResult == DialogResult.OK)
                    {
                        bindGlobalLoginUser();
                        bindGlobalPC();
                        bindGlobalControl();


                        Dictionary <string, string> dic = new Dictionary <string, string>();
                        dic.Add("@UserID", ApplicationMember.mLoginID);
                        DataTable tbl = mMasterBLL.executeSelectProcedure("CS_SP_SELECT_USER_MENU", dic);
                        mUtility.loadMenu(ref ribbon, ref tcHR, tbl);
                        mUtility.loadHome(ref tcHR);
                    }
                    else
                    {
                        this.Dispose();
                        this.Close();
                    }
                }
                else
                {
                    mDBController = new SetDBController(Application.StartupPath, 1);
                    if (mDBController.ShowDialog() == DialogResult.OK)
                    {
                        MessageBox.Show("System will restart");
                        Application.Restart();
                    }
                    else
                    {
                        //MessageBox.Show(mLogin.ShowDialog().ToString());
                        //this.Close();
                    }
                }
                #endregion
            }
            catch
            {
            }
        }
コード例 #25
0
        public virtual DbCommand CreateCommand(string statement, CommandType commandType)
        {
            if (CurrentConnection == null)
            {
                throw new ApplicationException("Not connected to database");
            }

            DbCommand dc = CurrentConnection.CreateCommand();

            dc.CommandText = statement.Replace("\r", " ").Replace("\n", " ");
            dc.CommandType = commandType;
            dc.Transaction = CurrentTransaction;
            return(dc);
        }
コード例 #26
0
        private Dictionary <string, DbParameterAccessor> ReadIntoParams(String[] queryParameters, String query)
        {
            DbCommand dc = CurrentConnection.CreateCommand();

            dc.Transaction = CurrentTransaction;
            dc.CommandText = query;
            dc.CommandType = CommandType.Text;
            for (int i = 0; i < queryParameters.Length; i++)
            {
                AddInput(dc, ":" + i, queryParameters[i].ToUpper());
            }
            DbDataReader reader = dc.ExecuteReader();
            Dictionary <String, DbParameterAccessor>
                allParams = new Dictionary <string, DbParameterAccessor>();
            int position  = 0;

            while (reader.Read())
            {
                String          paramName = (reader.IsDBNull(0)) ? null : reader.GetString(0);
                String          dataType  = reader.GetString(1);
                int             length    = (reader.IsDBNull(2)) ? 0 : reader.GetInt32(2);
                String          direction = reader.GetString(3);
                OracleParameter dp        = new OracleParameter();
                dp.Direction = GetParameterDirection(direction);
                if (paramName != null)
                {
                    dp.ParameterName = paramName; dp.SourceColumn = paramName;
                }
                else
                {
                    dp.Direction = ParameterDirection.ReturnValue;
                }

                dp.OracleType = GetDBType(dataType);
                if (length > 0)
                {
                    dp.Size = length;
                }
                else
                {
                    if (!ParameterDirection.Input.Equals(dp.Direction) || typeof(String).Equals(GetDotNetType(dataType)))
                    {
                        dp.Size = 4000;
                    }
                }
                allParams[NameNormaliser.NormaliseName(paramName)] =
                    new DbParameterAccessor(dp, GetDotNetType(dataType), position++, dataType);
            }
            return(allParams);
        }
コード例 #27
0
        public void DetachDatabase(string anotherDatabaseAliasName)
        {
            using (var command = CurrentConnection.CreateCommand())
            {
                string sql = $"detach database {anotherDatabaseAliasName}";
                command.CommandText = sql;
                command.CommandType = CommandType.Text;

                s_logger.Debug(sql);
                command.ExecuteNonQuery();

                _attachedDatabaseAliasNames.Remove(anotherDatabaseAliasName);
            }
        }
コード例 #28
0
 public void ResendOriginalLayerBytes()
 {
     UI_Popup.CurrentInstance.CreatePopupMessage(0.001f, "Resending original items, this may help if the items on your floor have shifted. This may take a few minutes... \r\nPlease disconnect from the internet, enter a building and stay in there for the duration of this function.", () =>
     {
         var bytes = layer1Dump.SetArray(Item.SIZE);
         CurrentConnection.WriteBytes(bytes, CurrentMapAddress);
         CurrentConnection.WriteBytes(bytes, CurrentMapAddress + (uint)OffsetHelper.BackupSaveDiff);
         if (Layer2Affect.isOn && layer2Dump != null)
         {
             bytes = layer2Dump.SetArray(Item.SIZE);
             CurrentConnection.WriteBytes(bytes, CurrentMapAddress + FieldItemLayerSize);
             CurrentConnection.WriteBytes(bytes, CurrentMapAddress + FieldItemLayerSize + (uint)OffsetHelper.BackupSaveDiff);
         }
     });
 }
コード例 #29
0
 public void Dispose()
 {
     try
     {
         CurrentTransaction.Rollback();
     }
     catch { }
     try
     {
         CurrentConnection._endTransaction(this);
     }
     catch { }
     CurrentTransaction = null;
     CurrentConnection  = null;
 }
コード例 #30
0
 /// <summary>
 /// Execute the SQL query and return the results in a new DataSet.
 /// </summary>
 /// <param name="theCmdStr">SQL Query</param>
 /// <returns>DataSet object</returns>
 public System.Data.DataSet ExecuteDataSet(string theCmdStr)
 {
     System.Data.DataSet ds = new DataSet();
     try
     {
         SqlDataAdapter adapter = new SqlDataAdapter(theCmdStr, CurrentConnection);
         adapter.Fill(ds, "dataSet");
         CurrentConnection.Close();
     }
     catch
     {
         throw;
     }
     return(ds);
 }