// 接收服务端发来信息的方法 public void recv() { //持续监听服务端发来的消息 while (true) { try { //定义一个1M的内存缓冲区,用于临时性存储接收到的消息 byte[] byteRec = new byte[1024 * 1024]; //将客户端套接字接收到的数据存入内存缓冲区,并获取长度 int length = socketclient.Receive(byteRec); string strRec = Encoding.Default.GetString(byteRec, 0, length); foreach (string itemRec in strRec.Trim('$').Split('$')) { Tran tran = JsonConvert.DeserializeObject <Tran>(itemRec); GameLogic(tran); } } catch (Exception ex) { throw ex; } } }
public static bool DeleteLeaveType(int LeaveTypeID) { GetConnection Conn = new GetConnection(); OracleConnection DBConn; OracleTransaction Tran; string DeleteLeaveTypeSql = "SP_DEL_LEAVE_TYPES"; try { DBConn = Conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); OracleParameter[] ParamArray = new OracleParameter[1]; ParamArray[0] = Utilities.GetOraParam(":p_LEAVE_TYPE_ID", LeaveTypeID, OracleDbType.Int64, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, DeleteLeaveTypeSql, ParamArray); Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } finally { Conn.CloseDbConn(); } }
public static void SendAllGamer(Tran tran) { foreach (Gamer gamer in GameTool.Gamers) { gamer.socket.Send(Poker.Bizlogic.Common.GetSendBytes(tran)); } }
/// <summary> /// トランザクションを開始する /// </summary> /// <returns>Tranオブジェクト</returns> /// <remarks></remarks> public Tran CreateTran() { if (this.IsDisposed) { throw new InvalidOperationException("Dbオブジェクトは既に破棄されています"); } Tran tran = new Tran(this); //_tranListにおいて、Tranオブジェクトへの参照が切れている要素を、1件だけ削除する //(参照切れ要素が残る可能性あり、暫定実装) try { _rwLock.AcquireWriterLock(_timeout); for (int i = 0; i <= _tranList.Count - 1; i++) { if (!_tranList[i].IsAlive) { _tranList.RemoveAt(i); break; } } //_tranListにTranオブジェクトへの弱い参照を追加する _tranList.Add(new WeakReference(tran)); } finally { _rwLock.ReleaseWriterLock(); } return(tran); }
internal void GivePoints(Tran tran) { if (Finished || tran.lastOwner == -1) { return; } pointsCollected[tran.lastOwner] += Mathf.Min(tran.pointsWorth, pointsTarget - TotalPointsCollected); if (Finished) { pointsCollected[tran.lastOwner] += lastDropAward; if (Winner != -1) { ++Match.Instance.gamesWon[Winner]; } StartCoroutine(EaseTimeStop()); Match.Instance.HandleGameFinished(); } Destroy(tran.gameObject); if (StateChanged != null) { StateChanged(); } }
public static bool DeletePost(int PostID) { GetConnection Conn = new GetConnection(); OracleConnection DBConn; OracleTransaction Tran; string DeletePostSql = "SP_DEL_POST "; try { DBConn = Conn.GetDbConn(Module.DLPDS); Tran = DBConn.BeginTransaction(); OracleParameter[] ParamArray = new OracleParameter[1]; ParamArray[0] = Utilities.GetOraParam(":p_POST_ID", PostID, OracleDbType.Int64, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, DeletePostSql, ParamArray); Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } }
// GET: /Tran/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tran tran = db.Tran.Find(id); if (tran == null) { return(HttpNotFound()); } ViewBag.AgentID = new SelectList(db.Agent, "AgentID", "AgentName", tran.AgentID); ViewBag.CommodityID = new SelectList(db.Commodity, "CommodityID", "CommodityName", tran.CommodityID); ViewBag.OriginCountryID = new SelectList(db.Country, "CountryID", "CountryName", tran.OriginCountryID); ViewBag.ConsigneeID = new SelectList(db.Customer, "CustomerID", "CustomerName", tran.ConsigneeID); ViewBag.ShipperID = new SelectList(db.Customer, "CustomerID", "CustomerName", tran.ShipperID); ViewBag.CourierID = new SelectList(db.Courier, "CourierID", "CourierName", tran.CourierID); ViewBag.SalesManID = new SelectList(db.SalesMan, "SalesManID", "SalesManName", tran.SalesManID); ViewBag.ShippingTermID = new SelectList(db.ShippingTerm, "ShippingTermID", "ShippingTermName", tran.ShippingTermID); // ZAATAR-MULTIST ViewBag.ShippingTypeID = new SelectList(db.ShippingType, "ShippingTypeID", "ShippingTypeName", tran.ShippingTypeID); ViewBag.POL = new SelectList(db.Port, "PortID", "PortName", tran.POL); ViewBag.POD = new SelectList(db.Port, "PortID", "PortName", tran.POD); if (tran.SalesMan != null) { ViewBag.SalesManName = tran.SalesMan.SalesManName; } else { ViewBag.SalesManName = "None"; } return(View(tran)); }
/// <summary> /// データベースから抽出条件に一致するレコードの件数を返す /// </summary> /// <typeparam name="TRecord"></typeparam> /// <param name="aIQuery">Queryオブジェクト</param> /// <returns>レコード件数</returns> /// <remarks>aQueryがQuery(Of TRecord)型でないのは、 /// オーバーロード解決時に、ジェネリックパラメータの制約が無視される為</remarks> public int Count <TRecord>(Query <TRecord> aIQuery) where TRecord : class, IRecord, new() { using (Tran aTran = this.CreateTran()) { return(aTran.Count <TRecord>(aIQuery)); } }
public void ChargeAccount(int userId, int value, string desc, TransactionType transactionType) { using (var dataModel = new MibarimEntities()) { var userInfo = dataModel.vwUserInfoes.FirstOrDefault(x => x.UserId == userId); //var desc = string.Format(getResource.getMessage("GiftPayDesc"), GetUserNameFamilyString(userInfo), value); var trans = new Tran(); trans.TransCreateTime = DateTime.Now; trans.TransType = (short)transactionType; trans.TransUserId = userId; trans.TransValue = value; trans.TransDescription = desc; dataModel.Trans.Add(trans); dataModel.SaveChanges(); try { NotifModel notifModel = new NotifModel(); notifModel.Title = getResource.getString("Transaction"); notifModel.Body = desc; notifModel.RequestCode = (int)trans.TransId; notifModel.NotificationId = (int)trans.TransId; _notifManager.SendNotifToUser(notifModel, userId); var mobileBrief = userInfo.UserName.Substring(1); var smsService = new SmsService(); smsService.SendSmsMessages(mobileBrief, desc); } catch (Exception e) { _logmanager.Log(Tag, "ChargeAccount", e.Message); } } }
/// <summary> /// 現在実行中のAPトランザクションIDを取得する /// </summary> /// <returns></returns> /// <remarks></remarks> public List <long> GetAllTranId() { if (this.IsDisposed) { throw new InvalidOperationException("Dbオブジェクトは既に破棄されています"); } List <long> ret = new List <long>(); try { _rwLock.AcquireWriterLock(_timeout); Tran aTran = null; for (int i = 0; i <= _tranList.Count - 1; i++) { aTran = (Tran)_tranList[i].Target; //Tranオブジェクトへの参照が切れている要素があれば削除する if (aTran == null) { _tranList.RemoveAt(i); i -= 1; continue; } ret.Add(aTran.ApTranId); } } finally { _rwLock.ReleaseWriterLock(); } return(ret); }
/// <summary> /// データベースから抽出条件に一致するレコードの件数を返す /// </summary> /// <typeparam name="TRecord"></typeparam> /// <param name="criteriaRec">抽出条件を格納したレコード</param> /// <returns>レコード件数</returns> /// <remarks></remarks> public int Count <TRecord>(TRecord criteriaRec) where TRecord : class, IRecord, new() { using (Tran aTran = this.CreateTran()) { return(aTran.Count(criteriaRec)); } }
protected override void DisposeImp(bool disposing) { //RecordReaderオブジェクトの破棄 try { if (_aRecordReader != null) { _aRecordReader.Dispose(); _aRecordReader = null; } } catch (Exception ex) { //GCによる回収時には例外を送出しない if (disposing) { throw; } } //Tranオブジェクトの破棄 try { if (_aTran != null) { _aTran.Dispose(); _aTran = null; } } catch (Exception ex) { //GCによる回収時には例外を送出しない if (disposing) { throw; } } }
public void dayend() { Debug.consol(" \n"); for (int i = 0; i < tranList.Count; i++) { Tran t = tranList[i]; if (t.isOuputed) { continue; } Debug.consol((t.orientation > 0?"[ +":"[ -") + " ] 買入 " + t.buyPrice + " " + t.kLData.sysTime.ToShortTimeString() + " 賣出 " + t.sellPrice + " " + t.skLData.sysTime.ToShortTimeString() + " " + t.result + Math.Abs(t.buyPrice - t.sellPrice) + " ::" + t.other + "\n"); if (!t.isClose) { draw++; t.isClose = true; } t.isOuputed = true; tranList[i] = t; } Debug.consol("Today win = " + cutSellPoint * (win - toDay_win) + ", lost = " + cutOffPoint * (lost - toDay_lost) + ". " + (int)(100.0 * ((cutSellPoint * (win - toDay_win)) / ((cutSellPoint * (win - toDay_win)) + (cutOffPoint * (lost - toDay_lost))))) + "% draw = " + (draw - toDay_draw) + "\n"); toDay_win = win; toDay_lost = lost; toDay_draw = draw; tranList_closed.AddRange(tranList); tranList.Clear(); //Debug.consol(" \n"); }
public static bool AddApplication(ATTApplication Applicationobj) { string InsertAppSQL = ""; InsertAppSQL = "SP_ADD_APPLICATIONS"; GetConnection GetConn = new GetConnection(); OracleTransaction Tran; try { OracleConnection DBConn = GetConn.GetDbConn(); Tran = DBConn.BeginTransaction(); OracleParameter[] paramArray = new OracleParameter[4]; paramArray[0] = Utilities.GetOraParam(":p_APPL_ID", Applicationobj.ApplicationID, OracleDbType.Int64, ParameterDirection.InputOutput); paramArray[1] = Utilities.GetOraParam(":p_DESCRIPTION", Applicationobj.ApplicationDescription, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[2] = Utilities.GetOraParam(":p_APPL_FULL_NAME", Applicationobj.ApplicationFullName, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[3] = Utilities.GetOraParam(":p_APPL_SHORT_NAME", Applicationobj.ApplicationShortName, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertAppSQL, paramArray[0], paramArray); double applicationID = double.Parse(paramArray[0].Value.ToString()); Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } finally { GetConn.CloseDbConn(); } }
/// <summary> /// 游戏开始 /// </summary> public static void GameStart() { Tran tran = new Tran(); foreach (Gamer gamer in Gamers) { //创建一个通信线程 ParameterizedThreadStart pts = new ParameterizedThreadStart(SocketTool.Recv); Thread thread = new Thread(pts); //设置为后台线程,随着主线程退出而退出 thread.IsBackground = true; //启动线程 thread.Start(gamer.socket); } InitPoker(); //随机确认一名玩家作为候选地主 Polling = new Random((int)DateTime.Now.Ticks).Next(0, 3); Polling = 2;//todo tran = new Tran() { type = 2, msg = "请确认是否当选地主!\r\n" }; Gamers[Polling].socket.Send(Poker.Bizlogic.Common.GetSendBytes(tran)); }
private void Add() { id = id + 1; Tran tran = new Tran(); if (AmmountTextBox.Text.ToString() == "") { MessageBox.Show("Enter Ammount"); } else if (dateTextBox.Text.ToString() == "") { MessageBox.Show("Enter Date"); } else { tran.Id = id; tran.Ammount = AmmountTextBox.Text.ToString(); tran.AgentName = AgentNameComboBox.Text.ToString(); tran.Date = dateTextBox.Text.ToString(); tran.BankName = DetailsTextBox1.Text.ToString(); TransactionsServices transervices = new TransactionsServices(); if (transervices.Add(tran) == 1) { MessageBox.Show("Insert Successfull"); } } }
private void Updates() { AddTransaction atd = new AddTransaction(); Tran tran = new Tran(); if (AmmountTextBox.Text.ToString() == "") { MessageBox.Show("Enter Ammount"); } else if (dateTextBox.Text.ToString() == "") { MessageBox.Show("Enter Date"); } else { tran.Id = Convert.ToInt32(deleteCompanygridview.CurrentRow.Cells[4].Value.ToString()); tran.Ammount = AmmountTextBox.Text.ToString(); tran.AgentName = AgentNameComboBox.Text.ToString(); tran.Date = dateTextBox.Text.ToString(); tran.BankName = DetailsTextBox1.Text.ToString(); TransactionsServices transervices = new TransactionsServices(); if (transervices.Update(tran) == 1) { MessageBox.Show("Successfull Updated"); } } }
public void Commit() { if (!IsTransaction) { throw new BDException("尚未启用事务或已经关闭"); } Tran.Commit(); }
private void Serialize(Tran aTran) { var bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); using (var fs = new System.IO.FileStream(tempDir + "\\test.bin", System.IO.FileMode.Create)){ bf.Serialize(fs, aTran); } }
public ActionResult DeleteConfirmed(int id) { Tran tran = db.Tran.Find(id); db.Tran.Remove(tran); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Rollback() { if (!IsTransaction) { throw new BDException("尚未启用事务或已经关闭"); } Tran.Rollback(); }
/// <summary> /// データベースからレコードを削除する /// </summary> /// <typeparam name="TRecord"></typeparam> /// <param name="criteriaRec">削除条件を格納したレコード</param> /// <param name="aPlaceHolders">プレースホルダ</param> /// <returns></returns> /// <remarks></remarks> public int Delete <TRecord>(TRecord criteriaRec , Dictionary <string, string> aPlaceHolders = null) where TRecord : class, IRecord, new() { using (Tran aTran = this.CreateTran()) { return(aTran.Delete(criteriaRec, aPlaceHolders)); } }
internal TranInfo(Tran tran) { _tran = tran; _apTranId = tran.ApTranId; _state = 0; _startTime = System.DateTime.Now; _endTime = default(System.DateTime); }
/// <summary> /// データベースにレコードを保存する /// </summary> /// <typeparam name="TRecord"></typeparam> /// <param name="saveRec">保存するレコード</param> /// <param name="aPlaceHolders">プレースホルダ</param> /// <returns></returns> /// <remarks></remarks> public int Save <TRecord>(TRecord saveRec , Dictionary <string, string> aPlaceHolders = null) where TRecord : class, IRecord, new() { using (Tran aTran = this.CreateTran()) { return(aTran.Save(saveRec, aPlaceHolders)); } }
public ObservableCollection <IMap> ModelObj(string RunAsChainFile) { var xml = XDocument.Load(RunAsChainFile); var RunAsChainXml = xml?.Descendants("Map") .Select(Chain => new { Sequence = Chain?.Attribute("Sequence")?.Value, MapFilePath = Chain?.Element("MapFilePath")?.Attribute("Location").Value, SourceFilePath = Chain?.Element("SourceFilePath")?.Attribute("Location").Value, TargetFilePath = Chain?.Element("TargetFilePath")?.Attribute("Location").Value, BasFiles = Chain?.Descendants("CodeModulePath") .Select(bas => new { BasPath = bas?.Attribute("Location").Value }).ToList(), TransformationVariable = Chain?.Descendants("Variable") .Select(Tran => new { Variable = Tran?.Attribute("Value").Value, IsPublic = Tran?.Attribute("IsPublic").Value, InitialValue = Tran?.Attribute("InitialValue").Value }).ToList() }).ToList(); var Trans = RunAsChainXml.ToList(); var ml = new ObservableCollection <IMap>(); foreach (var item in RunAsChainXml) { string mp = item.MapFilePath; string sp = item.SourceFilePath; string tp = item.TargetFilePath; ICodeModule basobj = new CodeModule.CodeModule(); var BasList = new ObservableCollection <ICodeModule>(); foreach (var bas in item.BasFiles) { basobj = new CodeModule.CodeModule() { BasPath = bas.BasPath }; BasList.Add(basobj); } var bl = new CodeModules(BasList); var Transobj = new ObservableCollection <ITransformationVariable>(); foreach (var tran in item.TransformationVariable) { Transobj.Add(new TransformationVariable("", false, "")); } var tl = new TransFormationVariableList(Transobj); ml.Add(new Map.Map(mp, sp, tp, bl, tl)); } return(ml); }
public int Call <TRecord>(string sqlEntryName , Query <TRecord> aQuery , Dictionary <string, string> aPlaceHolders = null) where TRecord : class, IRecord, new() { using (Tran aTran = this.CreateTran()) { return(aTran.Call(sqlEntryName, aQuery, aPlaceHolders)); } }
/// <summary> /// 提交事务 /// </summary> public void Commit() { if (IsTran) { IsTran = false; Tran.Commit(); Dispose(); } }
/// <summary> /// データベースからレコードを1件取得する /// </summary> /// <typeparam name="TRecord"></typeparam> /// <param name="aQuery">Queryオブジェクト</param> /// <param name="aLoadMode">読込モード</param> /// <param name="aCacheStrategy">キャッシュ動作方式</param> /// <returns>取得したレコード</returns> /// <remarks>指定された抽出条件で2件以上のレコードが該当した場合は、例外を送出する</remarks> public TRecord FindOne <TRecord>(Query <TRecord> aQuery , Tran.LoadMode aLoadMode = Tran.LoadMode.ReadOnly , Tran.CacheStrategy aCacheStrategy = Tran.CacheStrategy.UseCache) where TRecord : class, IRecord, new() { using (Tran aTran = this.CreateTran()) { return(aTran.FindOne <TRecord>(aQuery, null, aLoadMode, aCacheStrategy)); } }
/// <summary> /// 回滚事务 /// </summary> public void RollBack() { if (IsTran) { IsTran = false; Tran.Rollback(); Dispose(); } }
public static bool SaveAward(List <ATTAwardPunishment> LSTAward) { OracleTransaction Tran; GetConnection conn = new GetConnection(); OracleConnection DBConn = conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); string InsertUpdateDelete = ""; try { foreach (ATTAwardPunishment var in LSTAward) { if (var.Action == "A") { InsertUpdateDelete = "SP_ADD_EMP_AWARDS"; } else if (var.Action == "E") { InsertUpdateDelete = "SP_EDIT_EMP_AWARDS"; } else if (var.Action == "D") { InsertUpdateDelete = "SP_DEL_EMP_AWARDS"; } if (var.Action == "A" || var.Action == "E") { List <OracleParameter> paramArray = new List <OracleParameter>(); paramArray.Add(Utilities.GetOraParam("P_EMP_ID", var.EmpID, OracleDbType.Double, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_SEQ_NO", var.SequenceNo, OracleDbType.Int32, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_AWARD ", var.Award, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_AWARD_DATE", var.AwardDate, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_VERIFIED_BY", var.VerifiedBy, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_VERIFIED_DATE", var.VerifiedDate, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_REMARKS", var.Remarks, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_ENTRY_BY", var.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input)); DataSet ds = SqlHelper.ExecuteDataset(DBConn, CommandType.StoredProcedure, InsertUpdateDelete, paramArray.ToArray()); } else if (var.Action == "D") { List <OracleParameter> paramArray = new List <OracleParameter>(); paramArray.Add(Utilities.GetOraParam("P_EMP_ID", var.EmpID, OracleDbType.Double, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_SEQ_NO", var.SequenceNo, OracleDbType.Int32, ParameterDirection.Input)); DataSet ds = SqlHelper.ExecuteDataset(DBConn, CommandType.StoredProcedure, InsertUpdateDelete, paramArray.ToArray()); } } } catch (Exception ex) { Tran.Rollback(); throw ex; } Tran.Commit(); return(true); }
public static Tran CreateTran(int trans_num, int trans_amt, global::System.DateTime trans_dt, string card_num, string email_message, int acc_num) { Tran tran = new Tran(); tran.trans_num = trans_num; tran.trans_amt = trans_amt; tran.trans_dt = trans_dt; tran.card_num = card_num; tran.email_message = email_message; tran.acc_num = acc_num; return tran; }
public void AddToTrans(Tran tran) { base.AddObject("Trans", tran); }