/// <summary> /// 根据ID修改单个实体 /// </summary> /// <returns></returns> public bool UpdateExampaper(tbExampaper tbE) { try { MongoCollection <tbExampaper> coll = BaseDB.CreateInstance().GetCollection <tbExampaper>("tbExampaper"); tbExampaper exam = coll.FindOne(Query.EQ("_id", tbE._id)); tbE.UserID = exam.UserID; coll.Remove(Query.EQ("_id", tbE._id)); coll.Insert(tbE); return(true); } catch { return(false); } finally { BaseDB.MongoService.Disconnect(); } }
public static DataTable GetAllCategories() { DbCommand dbComm = BaseDB.CreateCommand(); dbComm.CommandText = "E_Front_Sections_GetAllCategories"; dbComm.CommandType = CommandType.StoredProcedure; DataTable fieldData; try { fieldData = BaseDB.ExecuteSelect(dbComm); } catch (Exception exc) { throw exc; } return(fieldData); }
void _setReceivers(string configReceivers) { var list = JsonHelper.ToList(configReceivers); foreach (var item in list) { var type = item.GetValue("Type"); if (type == "User") { _addUser(this.ConfigReceivers, item.GetValue("ID"), item.GetValue("Name")); } else if (type == "SysRole" || type == "OrgRole") { string sql = @"SELECT UserID,Name FROM S_A__RoleUser LEFT JOIN S_A_User ON UserID=S_A_USER.ID WHERE RoleID ='" + item.GetValue("ID") + "'"; var userDt = BaseDB.ExecuteDataTable(sql); foreach (DataRow userRow in userDt.Rows) { _addUser(this.ConfigReceivers, userRow["UserID"].ToString(), userRow["Name"].ToString()); } } } }
/// <summary> /// 添加用户 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Add(UserModel model) { //如果为空 返回false if (model == null) { return(false); } if (model.user == null) { return(false); } if (model.organizationUser == null) { return(false); } using (SqlSugarClient db = BaseDB.GetClient()) { try { //db.BeginTran();//开启事务 //特别说明:在事务中,默认情况下是使用锁的,也就是说在当前事务没有结束前,其他的任何查询都需要等待 //ReadCommitted:在正在读取数据时保持共享锁,以避免脏读,但是在事务结束之前可以更改数据,从而导致不可重复的读取或幻像数据。 //db.BeginTran(System.Data.IsolationLevel.ReadCommitted); //重载指定事务的级别 db.BeginTran();//开始事物 db.Insertable <User>(model.user); db.Insertable <OrganizationUser>(model.organizationUser); db.CommitTran();//提交事务 return(true); } catch (Exception ex) { db.RollbackTran();//回滚 return(false); } } }
public static void DeleteMember(string memberID) { DbCommand dbComm = BaseDB.CreateCommand(); dbComm.CommandText = "E_Admin_Members_DeleteMember"; DbParameter param = dbComm.CreateParameter(); param.ParameterName = "@MemberID"; param.Value = memberID; param.DbType = DbType.String; dbComm.Parameters.Add(param); try { BaseDB.ExecuteNonQuery(dbComm); } catch (Exception exc) { throw exc; } }
static void SetupScenario(BaseDB.ConfigContainer cfg, IEnumerable <Entity> entities) { BaseDB.PutConfigAsync(cfg).Wait(); //Simulation.Configure(new ShardID(), cfg, true); //if (DB.HasAdminAccess) InconsistencyCoverage.CommonResolution = (int)Math.Ceiling(1f / cfg.r); var clearTask = BaseDB.ClearSimulationDataAsync(); SDSFactory[,,] grid = new SDSFactory[cfg.extent.X, cfg.extent.Y, cfg.extent.Z]; cfg.extent.Cover(at => { grid[at.X, at.Y, at.Z] = new SDSFactory(at, null /*new SimulationContext(false)*/, cfg.extent); } ); var gridBox = IntBox.FromMinAndMax(Int3.Zero, cfg.extent, Bool3.False); var simulationSpace = Box.FromMinAndMax(Vec3.Zero, new Vec3(cfg.extent), Bool3.True); foreach (var e in entities) { if (!simulationSpace.Contains(e.ID.Position)) { throw new Exception("Scenario entity " + e + " is located outside simulation space"); } var cell = gridBox.Clamp(e.ID.Position.FloorInt3); grid[cell.X, cell.Y, cell.Z].Include(e); } clearTask.Wait(); Task[] tasks = new Task[cfg.extent.Product]; int idx = 0; foreach (var factory in grid) { tasks[idx++] = DB.PutAsync(factory.Finish(), true); } Task.WaitAll(tasks); }
public static void DeleteCategory(int categoryID) { DbCommand dbComm = BaseDB.CreateCommand(); dbComm.CommandText = "E_DeleteCategory"; DbParameter dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CategoryID"; dbParam.Value = categoryID; dbParam.DbType = DbType.Int32; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); try { BaseDB.ExecuteNonQuery(dbComm); } catch (Exception exc) { throw exc; } }
public int UpdateTestTimes(int tbexamsendstudentid, int TestTimes) { try { MongoCollection <tbExamSendStudent> coll = BaseDB.CreateInstance().GetCollection <tbExamSendStudent>("tbExamSendStudent"); //var update = new UpdateDocument // { // {"Number", number} // }; //coll.Update(Query.EQ("_id", tbexamsendstudentid), update,UpdateFlags.Multi);, //修改单条数据 coll.Update(Query.EQ("_id", tbexamsendstudentid), Update.Set("PaperScore", 0)); coll.Update(Query.EQ("_id", tbexamsendstudentid), Update.Set("TestTimes", TestTimes)); coll.Update(Query.EQ("_id", tbexamsendstudentid), Update.Set("StudentAnswerList", "")); //var update = new UpdateDocument // { // {"PaperScore", 0}, // {"TestTimes", TestTimes}, // {"Number",0} // }; //coll.Update(Query.EQ("_id", tbexamsendstudentid), update); return(tbexamsendstudentid); } catch { return(0); } finally { BaseDB.MongoService.Disconnect(); } }
public static int AddNewSection(string sectionName, string sectionDesc) { int sectionID = 0; DbCommand dbComm = BaseDB.CreateCommand(); dbComm.CommandText = "E_AddNewSection"; DbParameter dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CategoryName"; dbParam.Value = sectionName; dbParam.Size = 125; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CategoryDesc"; dbParam.Value = sectionDesc; dbParam.Size = 255; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); try { sectionID = int.Parse(BaseDB.ExecuteScalar(dbComm)); } catch (Exception exc) { throw exc; } //bool urlUpdated = AdminURL.UpdateID(sectionURL, sectionID); return(sectionID); }
/// <summary> /// 根据ID删除单个实体 /// </summary> /// <returns></returns> public bool DeleteExampaper(int id, bool isTrueDelete) { try { MongoCollection <tbExampaper> coll = BaseDB.CreateInstance().GetCollection <tbExampaper>("tbExampaper"); if (isTrueDelete) { coll.Remove(Query.EQ("_id", id)); } else { coll.Update(Query.EQ("_id", id), Update.Set("Status", "1")); } return(true); } catch { return(false); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 修改课程是否获得学时 0:没有获得 1:获得 获得后后面的考试就不在获得学时 标志位 /// </summary> /// <param name="tbexamsendstudentid">id</param> /// <param name="number">0:1</param> /// <returns></returns> public int UpdateNumber(int tbexamsendstudentid, int number) { try { MongoCollection <tbExamSendStudent> coll = BaseDB.CreateInstance().GetCollection <tbExamSendStudent>("tbExamSendStudent"); //var update = new UpdateDocument // { // {"Number", number} // }; //coll.Update(Query.EQ("_id", tbexamsendstudentid), update,UpdateFlags.Multi); //修改单条数据 coll.Update(Query.EQ("_id", tbexamsendstudentid), Update.Set("Number", number)); return(tbexamsendstudentid); } catch { return(0); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 根据ID批量删除单个实体 /// </summary> /// <returns></returns> public bool DeleteExampapers(string idlist) { try { MongoCollection <tbExampaper> coll = BaseDB.CreateInstance().GetCollection <tbExampaper>("tbExampaper"); //BsonArray b = new BsonArray(); string[] ids = idlist.Split(','); for (int i = 0; i < ids.Length - 1; i++) { //b.Add(ids[i].StringToInt32()); coll.Update(Query.EQ("_id", Convert.ToInt32(ids[i])), Update.Set("Status", 1)); } return(true); } catch { return(false); } finally { BaseDB.MongoService.Disconnect(); } }
public static int CountSubCategoriesInCategory(int categoryID) { DbCommand dbComm = BaseDB.CreateCommand(); dbComm.CommandText = "E_Front_Categories_CountSubCategoriesInCategory"; DbParameter dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CategoryID"; dbParam.Value = categoryID; dbParam.DbType = DbType.Int32; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); DataTable fieldData; try { fieldData = BaseDB.ExecuteSelect(dbComm); } catch (Exception exc) { throw exc; } if (fieldData.Rows.Count > 0) { int prodCount = 0; int.TryParse(fieldData.Rows[0]["Total"].ToString(), out prodCount); if (prodCount > 0) { return(prodCount); } } return(0); }
static void Main(string[] args) { try { int at = 0; var dbHost = new Address(args[at++]); BaseDB.Connect(dbHost); //,"admin","1234"); Log.Message("Updating timing..."); BaseDB.Timing = new BaseDB.TimingContainer() { startTime = (DateTime.Now + TimeSpan.FromMinutes(5)).ToString() /*, msGenerationBudget = 30000*/ }; Log.Message("Setting up scenario..."); bool success = BaseDB.TryPullGlobalConfig(3); CreateScenario(args[at++]); Log.Message("Scenario set up. Shutting down"); } catch (Exception ex) { Console.Error.WriteLine(ex); Environment.Exit(-1); } }
public bool add(OrgModel model) { SqlSugarClient db = BaseDB.GetClient(); try { //db.BeginTran();//开启事务 //特别说明:在事务中,默认情况下是使用锁的,也就是说在当前事务没有结束前,其他的任何查询都需要等待 //ReadCommitted:在正在读取数据时保持共享锁,以避免脏读,但是在事务结束之前可以更改数据,从而导致不可重复的读取或幻像数据。 //db.BeginTran(System.Data.IsolationLevel.ReadCommitted); //重载指定事务的级别 db.BeginTran(); var res = db.Insertable <Organization>(model.organization).ExecuteCommand(); var res1 = db.Insertable <OrganizationOrg>(new OrganizationOrg { orgid = model.organization.id, parentorgid = model.parentOrgId }).ExecuteCommand(); db.CommitTran();//提交事务 return(true); } catch (Exception ex) { db.RollbackTran();//回滚 return(false); } }
/// <summary> /// 通过code获取组织信息 /// </summary> /// <param name="orgCode"></param> /// <returns></returns> public OrgModel getOrgModelByCode(string orgCode) { using (SqlSugarClient db = BaseDB.GetClient()) { List <OrgModel> res = db.Queryable <Organization, OrganizationOrg>((o, oo) => new object[] { JoinType.Left, o.id == oo.orgid }) .Where((o, oo) => o.orgCode == orgCode) .Select((o, oo) => new OrgModel { organization = o, parentOrgId = oo.parentorgid }).ToList(); if (res.Count > 0) { return(res[0]); } else { return(null); } } }
static void Main(string[] args) { if (args.Length < 2) { throw new ArgumentException("Missing arguments. Usage: Executable <DBHost> <ShardID>"); } int at = 0; var dbHost = new Address(args[at++]); BaseDB.Connect(dbHost); //,"admin","1234"); ShardID addr = ShardID.Decode(args[at++]); BaseDB.BeginPullConfig(addr.XYZ); iface = new Consensus.Interface(addr, -1, 0, true, Consensus.Interface.ThreadOperations.CheckConfiguration, new Notify(error => { Log.Error(error); iface.Dispose(); Log.Message("Shutting down"); }, () => iface)); iface.Notify.OnConsensusChange(Consensus.Status.NotEstablished, null); iface.AwaitClosure(); }
private static void PublishAddress(FullShardAddress address) { Log.Message("Publishing address: " + address); BaseDB.PutNow(address); }
public override Address GetAddress(int replicaIndex) { return(BaseDB.TryGetAddress(new ShardID(MyID.XYZ, replicaIndex)).ConsensusAddress); }
public async static void SendThreadMessage(List <DataRow> dt, IList <Attachment> items) { string uzytkownik = ""; Int64 uzytkownikId = 0; try { List <DataRow> drDrugaProba = new List <DataRow>(); List <DataRow> drtrzeciaProba = new List <DataRow>(); if (items.Count > 0) { MicrosoftAppCredentials.TrustServiceUrl(@"https://facebook.botframework.com", DateTime.MaxValue); IMessageActivity message = Activity.CreateMessageActivity(); message.ChannelData = JObject.FromObject(new { notification_type = "REGULAR", quick_replies = new dynamic[] { new { content_type = "text", title = "Piłka nożna", payload = "DEVELOPER_DEFINED_PAYLOAD_Pilka_Nozna", // image_url = "https://cdn3.iconfinder.com/data/icons/developperss/PNG/Green%20Ball.png" // image_url = "http://archiwum.koluszki.pl/zdjecia/naglowki_nowe/listopad%202013/pi%C5%82ka[1].png" }, new { content_type = "text", title = "Siatkówka", payload = "DEVELOPER_DEFINED_PAYLOAD_Siatkowka", // image_url = "https://gim7bytom.edupage.org/global/pics/iconspro/sport/volleyball.png" }, new { content_type = "text", title = "Hokej", payload = "DEVELOPER_DEFINED_PAYLOAD_Hokej", // image_url = "https://cdn3.iconfinder.com/data/icons/developperss/PNG/Green%20Ball.png" }, } }); message.AttachmentLayout = AttachmentLayoutTypes.Carousel; message.Attachments = items; foreach (DataRow dr in dt) { try { var userAccount = new ChannelAccount(name: dr["UserName"].ToString(), id: dr["UserId"].ToString()); uzytkownik = userAccount.Name; uzytkownikId = Convert.ToInt64(userAccount.Id); var botAccount = new ChannelAccount(name: dr["BotName"].ToString(), id: dr["BotId"].ToString()); var connector = new ConnectorClient(new Uri(dr["Url"].ToString()), "73267226-823f-46b0-8303-2e866165a3b2", "k6XBDCgzL5452YDhS3PPLsL"); var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount); message.From = botAccount; message.Recipient = userAccount; message.Conversation = new ConversationAccount(id: conversationId.Id, isGroup: false); await connector.Conversations.SendToConversationAsync((Activity)message).ConfigureAwait(false); } catch (Exception ex) { // BaseDB.AddToLog("Błąd wysyłania wiadomości do: " + uzytkownik + " " + ex.ToString()); drDrugaProba.Add(dr); } } foreach (DataRow dr in drDrugaProba) { try { var userAccount = new ChannelAccount(name: dr["UserName"].ToString(), id: dr["UserId"].ToString()); uzytkownik = userAccount.Name; uzytkownikId = Convert.ToInt64(userAccount.Id); var botAccount = new ChannelAccount(name: dr["BotName"].ToString(), id: dr["BotId"].ToString()); var connector = new ConnectorClient(new Uri(dr["Url"].ToString()), "73267226-823f-46b0-8303-2e866165a3b2", "k6XBDCgzL5452YDhS3PPLsL"); var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount); message.From = botAccount; message.Recipient = userAccount; message.Conversation = new ConversationAccount(id: conversationId.Id, isGroup: false); await connector.Conversations.SendToConversationAsync((Activity)message).ConfigureAwait(true); } catch (Exception ex) { //BaseDB.AddToLog("Błąd wysyłania wiadomości do: " + uzytkownik + " " + ex.ToString()); drtrzeciaProba.Add(dr); } } foreach (DataRow dr in drtrzeciaProba) { try { var userAccount = new ChannelAccount(name: dr["UserName"].ToString(), id: dr["UserId"].ToString()); uzytkownik = userAccount.Name; uzytkownikId = Convert.ToInt64(userAccount.Id); var botAccount = new ChannelAccount(name: dr["BotName"].ToString(), id: dr["BotId"].ToString()); var connector = new ConnectorClient(new Uri(dr["Url"].ToString()), "73267226-823f-46b0-8303-2e866165a3b2", "k6XBDCgzL5452YDhS3PPLsL"); var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount); message.From = botAccount; message.Recipient = userAccount; message.Conversation = new ConversationAccount(id: conversationId.Id, isGroup: false); await connector.Conversations.SendToConversationAsync((Activity)message).ConfigureAwait(true); } catch (Exception ex) { // BaseDB.AddToLog("Błąd wysyłania wiadomości (próba trzecia) do: " + uzytkownik + " " + ex.Message.ToString()); BaseDB.ChangeNotification(uzytkownikId.ToString(), 5); } } // BaseDB.AddToLog("Zakończenie wątku "); } } catch (Exception ex) { BaseDB.AddToLog("Błąd wysłania wiadomosci do " + uzytkownik + " " + ex.Message.ToString()); } }
public static int UpdateNews(int newsID, string newsTitle, string source, string author, string newsSmallDesc, string newsDesc, bool hidden, DateTime modified) { DbCommand dbComm = BaseDB.CreateCommand(); DbParameter dbParam; if (newsID == 0) { dbComm.CommandText = "E_AddNewNews"; } else { dbComm.CommandText = "E_UpdateNews"; dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@NewsID"; dbParam.Value = newsID; dbParam.DbType = DbType.Int32; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); } dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Modified"; dbParam.Value = modified; dbParam.DbType = DbType.DateTime; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@NewsTitle"; dbParam.Value = newsTitle; dbParam.Size = 125; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@NewsSmallDesc"; dbParam.Value = newsSmallDesc; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@NewsDesc"; dbParam.Value = newsDesc; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Hidden"; dbParam.Value = hidden; dbParam.DbType = DbType.Boolean; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Source"; dbParam.Value = source; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Author"; dbParam.Value = author; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); try { newsID = int.Parse(BaseDB.ExecuteScalar(dbComm)); } catch (Exception exc) { throw exc; } return(newsID); }
public async static void SendThreadMessage(DataRow dr, DataTable dtWiadomosci, IList <Attachment> items) { try { // BaseDB.AddToLog("Wywołanie metody SendThreadMessage"); string uzytkownik = ""; if (items.Count > 0) { try { MicrosoftAppCredentials.TrustServiceUrl(@"https://facebook.botframework.com", DateTime.MaxValue); IMessageActivity message = Activity.CreateMessageActivity(); message.ChannelData = JObject.FromObject(new { notification_type = "REGULAR", quick_replies = new dynamic[] { new { content_type = "text", title = "Aktualności", payload = "DEVELOPER_DEFINED_PAYLOAD_Aktualnosci", // image_url = "https://cdn3.iconfinder.com/data/icons/developperss/PNG/Green%20Ball.png" // image_url = "http://archiwum.koluszki.pl/zdjecia/naglowki_nowe/listopad%202013/pi%C5%82ka[1].png" }, // new // { // content_type = "text", // title = "Galeria", // payload = "DEVELOPER_DEFINED_PAYLOAD_Galeria", //// image_url = "https://gim7bytom.edupage.org/global/pics/iconspro/sport/volleyball.png" // }, new { content_type = "text", title = "Sklep", payload = "DEVELOPER_DEFINED_PAYLOAD_Sklep", // image_url = "https://gim7bytom.edupage.org/global/pics/iconspro/sport/volleyball.png" }, new { content_type = "text", title = "Video", payload = "DEVELOPER_DEFINED_PAYLOAD_Video", // image_url = "https://www.samo-lepky.sk/data/11/hokej5.png" }, } }); message.AttachmentLayout = AttachmentLayoutTypes.Carousel; message.Attachments = items; try { var userAccount = new ChannelAccount(name: dr["UserName"].ToString(), id: dr["UserId"].ToString()); uzytkownik = userAccount.Name; var botAccount = new ChannelAccount(name: dr["BotName"].ToString(), id: dr["BotId"].ToString()); var connector = new ConnectorClient(new Uri(dr["Url"].ToString()), "8fa14720-e758-4cc7-82fd-fd6ad145ec90", "oExpuWnvj4oDAQnYHSpVrCJ"); var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount); message.From = botAccount; message.Recipient = userAccount; message.Conversation = new ConversationAccount(id: conversationId.Id, isGroup: false); await connector.Conversations.SendToConversationAsync((Activity)message).ConfigureAwait(false); } catch (Exception ex) { BaseDB.AddToLog("Błąd wysyłania wiadomości do: " + uzytkownik + " " + ex.ToString()); } } catch (Exception ex) { BaseDB.AddToLog("Błąd wysyłania wiadomości do: " + uzytkownik + " " + ex.ToString()); } } } catch (Exception ex) { BaseDB.AddToLog("Błąd wysłania wiadomosci: " + ex.ToString()); } }
public static int AddNewEmailCounseling(string korName, string engFName, string engLName, string birthday, string korZip, string korAddress, string korAddress2, string address, string address2, string city, string state, string zip, string phone1, string phone2, string email, string sitePath, string counselingType, string counselingDesc) { DbCommand dbComm = BaseDB.CreateCommand(); DbParameter dbParam; dbComm.CommandText = "E_AddNewEmailCounseling"; dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@KorName"; dbParam.Value = korName; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@EngFName"; dbParam.Value = engFName; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@EngLName"; dbParam.Value = engLName; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Birthday"; dbParam.Value = birthday; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@KorZip"; dbParam.Value = korZip; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@KorAddress"; dbParam.Value = korAddress; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@KorAddress2"; dbParam.Value = korAddress2; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Address"; dbParam.Value = address; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Address2"; dbParam.Value = address2; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@City"; dbParam.Value = city; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@State"; dbParam.Value = state; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Zip"; dbParam.Value = zip; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Phone1"; dbParam.Value = phone1; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Phone2"; dbParam.Value = phone2; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Email"; dbParam.Value = email; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@SitePath"; dbParam.Value = sitePath; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CounselingType"; dbParam.Value = counselingType; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CounselingDesc"; dbParam.Value = counselingDesc; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); int contentID; try { contentID = int.Parse(BaseDB.ExecuteScalar(dbComm)); } catch (Exception exc) { throw exc; } return(contentID); }
private void ThreadMain() { if (lastHost.IsEmpty) { return; } Debug.Log("Sector: Thread active"); try { while (!stop) { try { Debug.Log("Attempting to connect to " + lastHost); client = new TcpClient(lastHost.Host, lastHost.Port); var stream = new LZ4.LZ4Stream(client.GetStream(), LZ4.LZ4StreamMode.Decompress); var f = new BinaryFormatter(); CSLogicProvider.AsyncFactory = ResolveProvider; Debug.Log("Sector: Connected to " + lastHost); while (client.Connected) { Debug.Log("Sector: Deserializing next object"); var obj = f.UnsafeDeserialize(stream, null); Debug.Log("Sector: Deserialized object " + obj); if (obj is ShardID) { privateID = (ShardID)obj; Debug.Log("Sector: ID updated to " + privateID); OnNewNeighbor(privateID, lastHost); } else if (obj is ObserverTimingInfo) { secondsPerTLG = (float)((ObserverTimingInfo)obj).msPerTLG / 1000f; } else if (obj is CSLogicProvider) { var prov = (CSLogicProvider)obj; TaskCompletionSource <CSLogicProvider> entry; while (!providerMap.TryGetValue(prov.AssemblyName, out entry)) { providerMap.TryAdd(prov.AssemblyName, new TaskCompletionSource <CSLogicProvider>()); } if (!entry.Task.IsCompleted) { entry.SetResult(prov); } Debug.Log("Sector: Added new provider " + prov.AssemblyName); } else if (obj is FullShardAddress) { var h = (FullShardAddress)obj; newNeighbors.Add(h); } else if (obj is SDS) { SDS sds = (SDS)obj; //Debug.Log("Sector: Got new SDS. Deserializing entities..."); foreach (var e in sds.FinalEntities) { var logic = e.MyLogic as DynamicCSLogic; if (logic != null) { try { logic.FinishLoading(e.ID, TimeSpan.FromSeconds(1)); } catch (ExecutionException ex) { Debug.LogException(ex); } } } //Debug.Log("Sector: SDS processed. Signalling change"); SDS = sds; sdsChanged = true; } } } catch (SocketException ex) { Debug.LogException(ex); } catch (IOException ex) { Debug.LogException(ex); } catch (Exception ex) { Debug.LogException(ex); Debug.Log("Weird type: " + ex.GetType()); } try { client.Close(); } catch { }; { var naddr = BaseDB.TryGetAddress(ExpectedID); if (!naddr.IsEmpty) { lastHost = naddr.ObserverAddress; } } Debug.Log("Waiting, then retrying"); Thread.Sleep(2000); } } catch (Exception ex) { Debug.LogError("Encountered terminal exception"); Debug.LogException(ex); } }
public static int UpdateCase(int caseID, string caseTitle, string caseFileName, string caseSmallDesc, bool hidden, DateTime modified) { DbCommand dbComm = BaseDB.CreateCommand(); DbParameter dbParam; if (caseID == 0) { dbComm.CommandText = "E_AddNewCase"; } else { dbComm.CommandText = "E_UpdateCase"; dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CaseID"; dbParam.Value = caseID; dbParam.DbType = DbType.Int32; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Modified"; dbParam.Value = modified; dbParam.DbType = DbType.DateTime; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); } dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CaseTitle"; dbParam.Value = caseTitle; dbParam.Size = 125; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CaseFileName"; dbParam.Value = caseFileName; dbParam.Size = 125; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@CaseSmallDesc"; dbParam.Value = caseSmallDesc; dbParam.DbType = DbType.String; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); dbParam = dbComm.CreateParameter(); dbParam.ParameterName = "@Hidden"; dbParam.Value = hidden; dbParam.DbType = DbType.Boolean; dbParam.Direction = ParameterDirection.Input; dbComm.Parameters.Add(dbParam); try { caseID = int.Parse(BaseDB.ExecuteScalar(dbComm)); } catch (Exception exc) { throw exc; } return(caseID); }
public SecureTrie(BaseDB database, byte[] rootHash) : base(database, rootHash) { }
public static int UpdateMemberInfo(string memberID, string password, string email, string fname, string lname, string korName, string phone, string address, string address2, string city, string state, string zip, string progressStatus, bool activeStatus, DateTime joined) { DbCommand dbComm = BaseDB.CreateCommand(); dbComm.CommandText = "E_Admin_Members_UpdateMemberInfo"; DbParameter param = dbComm.CreateParameter(); param.ParameterName = "@MemberID"; param.Value = memberID; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@Password"; param.Value = password; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@Email"; param.Value = email; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@FName"; param.Value = fname; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@LName"; param.Value = lname; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@KorName"; param.Value = korName; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@Phone"; param.Value = phone; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@Address"; param.Value = address; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@Address2"; param.Value = address2; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@City"; param.Value = city; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@State"; param.Value = state; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@Zip"; param.Value = zip; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@ProgressStatus"; param.Value = progressStatus; param.DbType = DbType.String; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@ActiveStatus"; param.Value = activeStatus; param.DbType = DbType.Boolean; dbComm.Parameters.Add(param); param = dbComm.CreateParameter(); param.ParameterName = "@Joined"; param.Value = joined; param.DbType = DbType.DateTime; dbComm.Parameters.Add(param); int id; try { id = int.Parse(BaseDB.ExecuteScalar(dbComm)); } catch (Exception exc) { throw exc; } return(id); }
public SecureTrie(BaseDB database = null) : base(database) { }
public ContactoController(BaseDB dbBase) { _dbBase = dbBase; }
/// <summary> /// 每个实例都需要实现初始化表 /// </summary> public void initTable() { BaseDB.GetClient().CodeFirst.InitTables(typeof(T)); }