private static ApiResult InvokeApi(ITradeService service, MainAccount account, string methodName, object[] arguments) { var host = ManagerCore.Instance.ApiHostManager.GetFastHost(service.GetType()); service.Account = account; service.Host = host; service.Login(); var method = service.GetType().GetMethod(methodName); if (method == null) { throw new Exception("没有找到接口" + methodName); } var result = (ApiResult)method.Invoke(service, arguments); if (!string.IsNullOrEmpty(result.Error)) { //尝试一次登录 if (result.Error.Contains("连接已断开")) { service.Logout(); service.Login(); result = (ApiResult)method.Invoke(service, arguments); } } return(result); }
public void addForCurrentAssets(MainAccount account) { this.newAccount("Petty Cash", true, account); this.newAccount("Cash", true, account); this.newAccount("Debtors", true, account); this.newAccount("Prepaid Expense", true, account); }
public void addForFixedAssets(MainAccount account) { this.newAccount("Furniture and fixtures", true, account); this.newAccount("Vehicles", true, account); this.newAccount("Land and Building", true, account); this.newAccount("Accumulated Depreciation", true, account); }
protected override async void Run(Session session, C2G_AddMainAccount message, Action <G2C_AddMainAccount> reply) { G2C_AddMainAccount response = new G2C_AddMainAccount(); try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); MainAccount mainAccount = ComponentFactory.Create <MainAccount>(); mainAccount._AccountID = message.AccountID; mainAccount._InfoID = message.InfoID; mainAccount._Account = message.Account; mainAccount._Password = message.Password; mainAccount._ManagerPassword = message.ManagerPassword; mainAccount._EMail = message.EMail; mainAccount._LastOnlineTime = message.LastOnlineTime; mainAccount._RegistrTime = message.RegistrTime; mainAccount._CumulativeTime = message.CumulativeTime; mainAccount._State = 0; await dBProxyComponent.Save(mainAccount); await dBProxyComponent.SaveLog(mainAccount); reply(response); } catch (Exception e) { response.IsOk = false; response.Message = "数据库异常"; ReplyError(response, e, reply); } }
// Delete Start // public ActionResult Delete(int id) { try { MainAccount main = service.findMainAcc(id); DateTime updateTime = DateTime.UtcNow; main.is_active = "N"; main.update_at = updateTime; foreach (HeadAccount head in main.HeadAccounts) { head.is_active = "N"; head.update_at = updateTime; foreach (SubHeadAccount sub in head.SubHeadAccounts) { sub.is_active = "N"; sub.update_at = updateTime; foreach (TransactionAccount trans in sub.TransactionAccounts) { trans.is_active = "N"; trans.updated_at_ = updateTime; } } } service.save(); return(RedirectToAction("Index")); } catch { return(View()); } }
public void UpdateChildAccountMoneyAndStocks(MainAccount account) { using (var db = GetDbContext()) { //更新所有子帐户的可取余额 var childIds = GetChildIds(account.MainID); foreach (var childId in childIds) { var child = db.ChildAccounts.FirstOrDefault(e => e.ChildID == childId); child.AdvisableMoney = child.UseableMoney; } //更新所有子帐户的持仓余额 var stocks = db.ChildStocks.Where(e => childIds.Contains(e.ChildID)); foreach (var stock in stocks) { stock.UseableCount = stock.AllCount; //如果持仓为0,则删除该股票 if (stock.UseableCount == 0) { db.ChildStocks.Remove(stock); } } db.SaveChanges(); } }
public ApiResult InvokeMethod(MainAccount account, string methodName, object[] arguments) { var service = GetTradeService(); var result = InvokeApi(service, account, methodName, arguments); //如果出错,调用其它服务 if (!string.IsNullOrEmpty(result.Error)) { foreach (var kv in _services) { if (kv.Key.GetType() == service.GetType()) { continue; } if (!kv.Value) { result = InvokeApi(kv.Key, account, methodName, arguments); if (string.IsNullOrEmpty(result.Error)) { SetMainService(kv.Key); break; } } } } return(result); }
public void ConcurrentTransactionTest() { long concurrent_threads = 10000; long repeat_count = 10000; List <Thread> threads = new List <Thread>(); MainAccount q = new MainAccount(0); for (int i = 0; i < concurrent_threads; i++) { Thread t = new Thread(() => { for (int j = 0; j < repeat_count; j++) { q.Transfer(1); } }); threads.Add(t); t.Start(); } foreach (Thread t in threads) { t.Join(); } Assert.AreEqual <long>( concurrent_threads * repeat_count, q.GetBalance()); }
public MainAccount findMainHead(int id) { HeadAccount head = db.HeadAccounts.Find(id); MainAccount main = db.MainAccounts.Find(head.main_id); return(main); }
public AccountViewModel(IContainer ioc) { _logger = ioc.Get <ILogger>(); _windowManager = ioc.Get <IWindowManager>(); MainAccount = ioc.Get <MainAccount>(); _sender = ioc.Get <ISender>(); _logger = ioc.Get <ILogger>(); }
public MainAccountDetailUI() { InitializeComponent(); lId = ""; lOperation = GlobalVariables.Operation.Add; loLookupValue = new LookUpValueUI(); loMainAccount = new MainAccount(); }
public ServiceHost(MainAccount account) { _account = account; _services.Add(new AuthorizeService()); _services.Add(new CloseAccountService()); _services.Add(new RefreshDataService()); _services.Add(new StockSyncService()); }
public void UpdateMainAccount(MainAccount account) { _account = account; foreach (var service in _services) { service.Account = account; } }
public LookUpAccountUI() { InitializeComponent(); loChartOfAccount = new ChartOfAccount(); loMainAccount = new MainAccount(); loClassification = new Classification(); loSubClassification = new SubClassification(); lFromSelection = false; }
public MainAccountDetailUI(string[] pRecords) { InitializeComponent(); lId = ""; lOperation = GlobalVariables.Operation.Edit; loLookupValue = new LookUpValueUI(); loMainAccount = new MainAccount(); lRecords = pRecords; }
public Payment(Property property, Customer customer, Users user) { InitializeComponent(); this.property = property; this.customer = customer; this.user = user; this.transaction = new Transaction(); this.da = new DataAccess(); this.mainAcc = new MainAccount(); }
public Reporter(IContainer ioc) { _logger = ioc.Get <ILogger>(); _settings = ioc.Get <AppSettingsModel>().ReaderSettings; _notification = ioc.Get <INotification>(); _reporter = ioc.Get <ILoadReceivers>(); _receivers = ioc.Get <BindableCollection <Receiver> >(); _account = ioc.Get <AppSettingsModel>().MainAccount; _dbService = ioc.Get <ILoadReceivers>(); }
public ChartOfAccountDetailUI() { InitializeComponent(); lId = ""; lOperation = GlobalVariables.Operation.Add; loLookupValue = new LookUpValueUI(); loChartOfAccount = new ChartOfAccount(); loMainAccount = new MainAccount(); loClassification = new Classification(); loSubClassification = new SubClassification(); }
public ChartOfAccountDetailUI(string[] pRecords) { InitializeComponent(); lId = ""; lOperation = GlobalVariables.Operation.Edit; loLookupValue = new LookUpValueUI(); loChartOfAccount = new ChartOfAccount(); loMainAccount = new MainAccount(); loClassification = new Classification(); loSubClassification = new SubClassification(); lRecords = pRecords; }
private void addMainAccount(string name, bool dbIncrease, BaseAccount baseAccount) { MainAccount tempAccount = new MainAccount(); tempAccount.name = name; tempAccount.dbIncrease = dbIncrease; tempAccount.isIncrease = true; tempAccount.amount = 0; tempAccount.balance = 0; tempAccount.BaseAccountId = baseAccount.BaseAccountId; _context.MainAccounts.Add(tempAccount); }
public void addExpenseOE(MainAccount accounts) { this.newAccount("Bad Debts", true, accounts); this.newAccount("Advertising", true, accounts); this.newAccount("Travel Expense", true, accounts); this.newAccount("Equipment lease", true, accounts); this.newAccount("Fuel", true, accounts); this.newAccount("Rent Expense", true, accounts); this.newAccount("Interest Expense", true, accounts); this.newAccount("Licence Expense", true, accounts); this.newAccount("Telephone", true, accounts); this.newAccount("Tax Expense", true, accounts); this.newAccount("Supplies", true, accounts); }
/// <summary> /// 查询持仓接口 /// </summary> /// <returns></returns> public List <ChildStock> QueryStocks(MainAccount account) { var list = new List <ChildStock>(); var result = Core.ServiceManager.QueryStocks(account); if (result.Result) { foreach (var line in result.Data.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)) { list.Add(ChildStock.Parse(line)); } } return(list); }
public ActionResult Edit(int id, FormCollection collection) { try { MainAccount main = service.findMainAcc(id); main.name = collection["name"]; main.update_at = DateTime.UtcNow; service.save(); return(RedirectToAction("Index")); } catch { return(View()); } }
protected override async void Run(Session session, C2R_RegistForSaveAccount message, Action <R2C_RegistForSaveAccount> reply) { R2C_RegistForSaveAccount response = new R2C_RegistForSaveAccount(); try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <MainAccount>("{'_Account' : '" + message.Account + "'}"); //判断账号是否存在 if (acounts.Count > 0) { Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "此号码已注册,请检查号码"); response.IsSuccess = false; response.Message = "此号码已注册,请检查号码"; } else { MainAccount mainAccount = ComponentFactory.Create <MainAccount>(); mainAccount._Account = message.Account; mainAccount._AccountID = mainAccount.Id; mainAccount._CumulativeTime = 0; mainAccount._EMail = ""; mainAccount._InfoID = -1; mainAccount._LastOnlineTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); mainAccount._ManagerPassword = ""; mainAccount._Password = message.Password; mainAccount._RegistrTime = message.RegistTime; mainAccount._State = 0; await dBProxyComponent.Save(mainAccount); response.UserID = mainAccount.Id; response.IsSuccess = true; response.Message = "注册成功"; } reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "注册失败,服务器维护中。"; ReplyError(response, e, reply); } }
protected void Delete_Click(object sender, EventArgs e) { if (EditFlag == true) { Main_Account = new MainAccount(); Main_Account_List = new List <MainAccount>(); Sub_Account = new SubAccount(); Sub_Account_List = new List <SubAccount>(); AccountIDTxt.Text = subAccountID.ToString(); int AccountID = int.Parse(AccountIDTxt.Text); try { int level = int.Parse(AccountLevelDrop.SelectedValue); if (level < 4)//Main account { Main_Account = db.MainAccount.Where(main => main.ID == AccountID).FirstOrDefault(); if (Main_Account != null) { db.MainAccount.Remove(Main_Account); db.SaveChanges(); } } else//SubAccount { Sub_Account = db.SubAccount.Where(sub => sub.ID == AccountID).FirstOrDefault(); if (Sub_Account != null) { db.SubAccount.Remove(Sub_Account); db.SaveChanges(); } } AddErrorTxt.Text = "تم الحذف"; AddErrorTxt.ForeColor = System.Drawing.Color.Green; Initialize_Page(); } catch (Exception ex) { AddErrorTxt.Text = " حدث خطأ لا يمكن الحذف من فضلك تأكد من مسح الحسابات الفرعية منه"; AddErrorTxt.ForeColor = System.Drawing.Color.Red; } } else { AddErrorTxt.Text = "من فضلك ابحث عن حساب اولا"; AddErrorTxt.ForeColor = System.Drawing.Color.Red; } }
public async Task <Guid> Handle(CreateMainAccountCommand request, CancellationToken cancellationToken) { var entity = new MainAccount { MainAccountIdByCustomer = request.MainAccountIdByCustomer, MainAccountNameAr = request.MainAccountNameAr, MainAccountNameEn = request.MainAccountNameEn, CustomerId = request.CustomerId, GeneralLeadgerId = request.GeneralLeadgerId }; _context.MainAccounts.Add(entity); await _context.SaveChangesAsync(cancellationToken); return(entity.Id); }
private void newAccount(string name, bool dbIncrease, MainAccount mainAccount) { Accounts account = new Accounts(); account.name = name; account.isDebtor = false; account.isCreditor = false; account.dbIncrease = dbIncrease; account.isIncrease = true; account.isBank = false; account.mainAccountId = mainAccount.mainAccountId; account.ClientId = 0; account.SupplierId = 0; account.amount = 0; account.balance = 0; _context.Accounts.Add(account); }
protected override void Seed(EFDbContext context) { //在这里初始化数据,经测试:注释部分均为非必要代码 CashAccount cashAccount = new CashAccount(); var singleCurrencyCashAccounts = new List <SingleCurrencyCashAccount>(); singleCurrencyCashAccounts.Add(new SingleCurrencyCashAccount() { Balance = 0, CurrencyType = CurrencyType.USD, CashAccount = cashAccount }); singleCurrencyCashAccounts.Add(new SingleCurrencyCashAccount() { Balance = 1000m, CurrencyType = CurrencyType.HKD, CashAccount = cashAccount }); singleCurrencyCashAccounts.Add(new SingleCurrencyCashAccount() { Balance = 0, CurrencyType = CurrencyType.CNY, CashAccount = cashAccount }); cashAccount.SingleCurrencyCashAccounts = singleCurrencyCashAccounts; MarginAccount marginAccount = new MarginAccount(); marginAccount.CashBalance = 0m; marginAccount.TotalAssets = 0; marginAccount.PositionValue = 0; marginAccount.PositionValue = 0; marginAccount.CashAccount = new CashAccount(); MainAccount mainAccount = new MainAccount(); mainAccount.CashAccount = cashAccount; cashAccount.Account = mainAccount; marginAccount.MainAccount = mainAccount; mainAccount.MarginAccount = marginAccount; //以下注释部分为非必要代码 //foreach (var tmp in singleCurrencyCashAccounts) // context.Set<SingleCurrencyCashAccount>().Add(tmp); //context.Set<CashAccount>().Add(cashAccount); context.Set <Account>().Add(mainAccount); base.Seed(context); }
/// <summary> /// 通过接口获取“当日委托”列表 /// </summary> public List <ChildAuthorize> GetTodayAuthorize(MainAccount account) { var result = Core.ServiceManager.QueryAuthroizes(account); if (!result.Result) { throw new Exception("当日委托获取失败\n" + result.Error); } var list = new List <ChildAuthorize>(); var rows = result.Data.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var row in rows) { list.Add(ChildAuthorize.Parse(row)); } return(list); }
/// <summary> /// 同步持仓股票市价 /// </summary> public void SyncStocks(MainAccount account) { using (var db = GetDbContext()) { var childIds = Core.AccountManager.GetChildIds(account.MainID); var list = db.ChildStocks.Where(e => childIds.Contains(e.ChildID)); var stockCodes = list.Select(e => e.StockCode).ToArray(); var data = QueryMarket(stockCodes); var rows = data.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var row in rows) { var market = StockMarket.Parse(row); var entity = list.FirstOrDefault(e => e.StockCode == market.StockCode); entity.CurrentPrice = market.CurrentPrice; } db.SaveChanges(); } }
/// <summary> /// 呼叫Gash Web Service 取得 玩家擁有gash+專用點數 //edit 2009/11/10 /// </summary> /// <param name="tmpGash">Gash帳號</param> /// <returns>(成功:玩家的點數 失敗:-1)</returns> public static int GetUserGashPoint(string tmpGash, string str_Region) { string ServiceCode = (string)ConfigurationManager.AppSettings["PayServiceCode"]??""; string ServiceRegion = (string) ConfigurationManager.AppSettings["PayServiceRegion"] ?? ""; string x = string.Empty; try { ServiceAccount Gash_sp = new ServiceAccount(); MainAccount sp = new MainAccount(); switch (str_Region.ToUpper()) { case "TW": Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount"] ?? ""); sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount"] ?? ""); break; case "HK": Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount_HK"] ?? ""); sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount_HK"] ?? ""); ServiceRegion = (string) ConfigurationManager.AppSettings["PayServiceRegion_HK"] ?? ""; break; default: Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount"] ?? ""); sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount"] ?? ""); break; } if (tmpGash.Length <= 0) { return -1; } else { string myresult = Gash_sp.ServiceAccount_GetRemainingPoints(ServiceCode, ServiceRegion, tmpGash); Gash_sp.Dispose(); if (myresult.Length > 0) { if (myresult.Substring(0, 2).ToString() == "1;") { x = myresult.Substring(2, myresult.Length - 2); return System.Int32.Parse(x); } else if (myresult == "-1;Check_ServiceAccount_Failed") { myresult = sp.MainAccount_GetRemainingPoints(tmpGash); if (myresult.Length > 0) { if (myresult.Substring(0, 2).ToString() == "1;") { x = myresult.Substring(2, myresult.Length - 2); return System.Int32.Parse(x); } else return -1; } else return -1; } else return -1; } else return -1; } } catch { return -1; } }
///// <summary> ///// 呼叫Gash Web Service 取得 玩家擁有gash點數 ///// </summary> ///// <param name="tmpGash">Gash帳號</param> ///// <returns>(成功:玩家的點數 失敗:-1)</returns> public static int GetUserGashPoint_old(string tmpGash, string str_Region) { string ServiceCode = (string)ConfigurationManager.AppSettings["PayServiceCode"] ?? ""; string ServiceRegion = (string)ConfigurationManager.AppSettings["PayServiceRegion"] ?? ""; try { MainAccount Gash_sp = new MainAccount(); switch (str_Region.ToUpper()) { case "TW": Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount"] ?? ""); break; case "HK": Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount_HK"] ?? ""); ServiceRegion = (string)ConfigurationManager.AppSettings["PayServiceRegion_HK"] ?? ""; break; default: Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount"] ?? ""); break; } if (tmpGash.Length <= 0) { return -1; } else { //取得遊戲專用點數 int iServicePoints = 0; //if (ConfigurationManager.AppSettings["Gash_HaveServicePoints"] == "true" && str_Region.ToUpper() == "TW") //{ using (GashGetServicePoint.Service Gash_sp2 = new GashGetServicePoint.Service()) { DataSet ds = new DataSet(); ds = Gash_sp2.Service_GetInfo(tmpGash, ServiceCode, ServiceRegion); if (ds.Tables.Count > 0) iServicePoints = Convert.ToInt32(ds.Tables[0].Rows[0][2].ToString()); ds.Dispose(); } //} string myresult = Gash_sp.MainAccount_GetRemainingPoints(tmpGash); if (myresult.Length > 0) { if (myresult.Substring(0, 2).ToString() == "1;") { string x = myresult.Substring(2, myresult.Length - 2); return System.Int32.Parse(x) + iServicePoints; } else return -1; } else return -1; } } catch { return -1; } }
/// <summary> /// 注意:2007/8/27以後改使用MainAccount_Authentication_New /// 呼叫Gash Web Service 進行 GASH主帳號認證 /// </summary> /// <param name="Str_GashAccount">Gash帳號</param> /// <param name="Str_GashPassWord">Gash密碼</param> /// <returns>(1 = Success, 0 = Failed, -1 = Error, -2;ErrorMessage = 呼叫Web Service發生錯誤,ErrorMessage為錯誤訊息)</returns> public static string MainAccount_Authentication(string Str_GashAccount, string Str_GashPassWord) { string Str_Result=""; MainAccount ws = new MainAccount(); try { Str_Result = ws.MainAccount_Authentication(Str_GashAccount, Str_GashPassWord); } catch (Exception ex) { Str_Result = "-2;" +ex.Message; } ws.Dispose(); return Str_Result; }
/// <summary> /// 呼叫Gash Web Service 進行 GASH主帳號認證 /// </summary> /// <param name="Str_GashAccount">Gash帳號</param> /// <param name="Str_GashPassWord">Gash密碼</param> /// <returns>(1 = Success, 0 = Failed, -1 = Error, -2;ErrorMessage = 呼叫Web Service發生錯誤,ErrorMessage為錯誤訊息)</returns> public static string MainAccount_Authentication_New(string Str_GashAccount, string Str_GashPassWord) { try { MainAccount ws = new MainAccount(); if (Str_GashAccount.Length <= 0 || Str_GashPassWord.Length <= 0) { return "0"; } else { string myresult = ws.MainAccount_Authentication(Str_GashAccount, Str_GashPassWord); string myresult1 = myresult; myresult = myresult.Substring(0, 1); if (myresult == "1") { return "1"; } else if (myresult1.IndexOf("0;Too_Many_Error_Try", 0, myresult1.Length) > -1) { return "2"; } else if (myresult1.IndexOf("0;MainAccount_is_Locked", 0, myresult1.Length) > -1) { return "3"; } else if (myresult1.IndexOf("-1;System Error:", 0, myresult1.Length) > -1) { return "0"; } else { return "0"; } } } catch { return "0"; } }
/// <summary> /// 取得玩家擁有gash點數 /// </summary> /// <param name="GashAccount"></param> /// <param name="GashRegion"></param> /// <returns>-1 失敗; else Point</returns> public int GetUserGashPoint(string GashAccount, string GashRegion) { int Result = -1; string wsResult = string.Empty; string[] aryResult; using (MainAccount ws = new MainAccount()) { ws.Url = GetGashWSUrl("MainAccount", GashRegion.ToUpper()); try { //WS return: intResult;Outstring //intResult: (1 Success, 0 Failed, -1 Error) //Outstring: will be RemainingPoints when intResult is 1 wsResult = ws.MainAccount_GetRemainingPoints(GashAccount); aryResult = wsResult.Split(";".ToCharArray()); if(aryResult[0] == "1") int.TryParse(aryResult[1], out Result); OutputResult = aryResult[0]; } catch (Exception ex) { Result = -1; WSException = ex; aryResult = new string[] { "" }; } } OutputMsg = (aryResult != null && aryResult.Length > 1) ? aryResult[1] : wsResult; return Result; }