private void MyListView_ItemClick(object sender, ItemClickEventArgs e) { ListView lv = sender as ListView; Contentlist cl = e.ClickedItem as Contentlist; Uri uri = new Uri(cl.video_uri); Grid gr1 = lv.Parent as Grid; Grid gr2 = gr1.Parent as Grid; Home home = gr2.Parent as Home; Frame fr = home.Parent as Frame; if (Grid.GetColumnSpan(fr) == 2) { if (this.Frame != null) { fr.Navigate(typeof(SecondFrame)); SecondFrame sf2 = fr.Content as SecondFrame; Grid gr6 = sf2.Content as Grid; Grid gr7 = gr6.Children[1] as Grid; MediaElement player2 = gr7.Children[0] as MediaElement; player2.Source = uri; } return; } Grid gr3 = fr.Parent as Grid; Frame fr2 = gr3.Children[0] as Frame; SecondFrame sf = fr2.Content as SecondFrame; Grid gr4 = sf.Content as Grid; Grid gr5 = gr4.Children[1] as Grid; MediaElement player = gr5.Children[0] as MediaElement; player.Source = uri; sqliteHelper1.CreateDB(); List <Model.History> His = sqliteHelper1.CheckData(cl.name); Model.History AddHistory = new Model.History(); AddHistory.name = cl.name; AddHistory.love = cl.love; AddHistory.hate = cl.hate; AddHistory.profile_image = cl.profile_image; AddHistory.text = cl.text; AddHistory.video_uri = cl.video_uri; AddHistory.create_time = cl.create_time; AddHistory.time = DateTime.Now.ToString(); sqliteHelper1.AddData(AddHistory); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.History GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 PART_ID,SAPCODE,BATCH_NO,DESCRIPTION,DEPARTMENT,START_WEIGHT,CURRENT_WEIGHT,CAPACITY,STATUS,EQUIP_ID,LOCID,THAWING_DATETIME,READY_DATETIME,EXPIRY_DATETIME,MF_EXPIRY_DATE,LOT_ID,DEVICE,EMPTY_SYRINGE_WEIGHT,USER_ID,USER_NAME,ACTION,REMARKS,UPDATED_TIME,WEEK,MONTH,YEAR from History "); strSql.Append(" where "); SqlParameter[] parameters = { }; Model.History model=new Model.History(); DataTable dt =Common.DB.SqlDB.Query(strSql.ToString(),parameters); if (dt == null || dt.Rows.Count == 0) { return null; }else { return DataRowToModel(dt.Rows[0]); } }
public Model.History CopyTrackModel(Model.Tracking trackModel) { if (trackModel == null) { return(null); } Model.History model = new Model.History(); model.PART_ID = trackModel.PART_ID; model.SAPCODE = trackModel.SAPCODE; model.BATCH_NO = trackModel.BATCH_NO; model.DESCRIPTION = trackModel.DESCRIPTION; model.DEPARTMENT = trackModel.DEPARTMENT; model.START_WEIGHT = trackModel.START_WEIGHT; model.CURRENT_WEIGHT = trackModel.CURRENT_WEIGHT; model.CAPACITY = trackModel.CAPACITY; model.STATUS = trackModel.STATUS; model.EQUIP_ID = trackModel.EQUIP_ID; model.THAWING_DATETIME = trackModel.THAWING_DATETIME; model.READY_DATETIME = trackModel.READY_DATETIME; model.EXPIRY_DATETIME = trackModel.EXPIRY_DATETIME; model.MF_EXPIRY_DATE = trackModel.MF_EXPIRY_DATE; model.LOT_ID = trackModel.LOT_ID; model.DEVICE = trackModel.DEVICE; model.EMPTY_SYRINGE_WEIGHT = trackModel.EMPTY_SYRINGE_WEIGHT; model.USER_ID = trackModel.USER_ID; model.USER_NAME = trackModel.USER_NAME; model.ACTION = trackModel.ACTION; model.REMARKS = trackModel.REMARKS; model.UPDATED_TIME = trackModel.UPDATED_TIME; model.WEEK = trackModel.WEEK; model.MONTH = trackModel.MONTH; model.YEAR = trackModel.YEAR; model.LOCID = trackModel.LOCID; return(model); }
private bool Update(Model.Tracking trackModel, Model.History hisModel, Model.MixHistory mixModel) { BLL.MixHistory mixBLL = new BLL.MixHistory(); BLL.Tracking trackBLL = new BLL.Tracking(); BLL.History hisBLL = new BLL.History(); List <SqlCommand> cmdList = new List <SqlCommand>(); if (trackModel != null) { cmdList.Add(trackBLL.UpdateCommand(trackModel)); } if (hisModel != null) { cmdList.Add(hisBLL.AddCommand(hisModel)); } cmdList.Add(mixBLL.AddCommand(mixModel)); return(Common.DB.SqlDB.SetData_Rollback(cmdList, Common.DB.Connection.SqlServer.EMS)); }
/// <summary> /// Get history long polling request /// </summary> /// <param name="eventId">Start event from</param> public Model.HistoryExecutionResult GetFrom(long eventId) { UpdateSessionCulture(); using (var logSession = Helpers.Log.Session($"{GetType()}.{System.Reflection.MethodBase.GetCurrentMethod().Name}()", VerboseLog, RaiseLog)) try { var res = new Model.History(); while (true) using (var rep = GetNewRepository(logSession)) { SRVCCheckCredentials(logSession, rep, Repository.Model.RightType.Login, Repository.Model.RightType.ViewChanges); var historyData = rep.Get<Repository.Model.History>(h => h.HistoryId > eventId, asNoTracking: true) .OrderBy(h => h.HistoryId) .Take(MaxHistoryItemsPerRequest) .ToArray(); if (historyData.Length > 0) { res.EventId = historyData.Last().HistoryId; var itemsToProcess = historyData .Distinct(); var getData = new Func<Repository.Model.HistoryChangeType, object>((t) => { bool hasChanged = false; object resD = t == Repository.Model.HistoryChangeType.Remove ? new Model.HistoryRemoveInfo() as object : new Model.HistoryUpdateInfo() as object; resD.GetType() .GetProperties() .Select(p => new { Property = p, Attr = p.GetCustomAttributes(typeof(Model.RepositoryResolvingAttribute), true).Cast<Model.RepositoryResolvingAttribute>().FirstOrDefault() }) .Where(p => p.Attr != null) .Select(p => new { p.Property, p.Attr.EntityType, p.Attr.ReturnArrayElementType }) .ToList() .ForEach(p => { var sourceIds = itemsToProcess.Where(h => h.ChangeType == t && string.Compare(h.Source, p.EntityType.Name, true) == 0).OrderBy(h => h.Date).Select(h => h.SourceId).ToArray(); if (sourceIds.Length > 0) { var val = GetFromRepository(p.Property.PropertyType.IsArray ? p.Property.PropertyType.GetElementType() : p.Property.PropertyType, p.EntityType, p.ReturnArrayElementType, t, sourceIds, rep); if (val != null) { p.Property.SetValue(resD, val); hasChanged = true; } } }); return hasChanged ? resD : null; }); res.Add = getData(Repository.Model.HistoryChangeType.Add) as Model.HistoryUpdateInfo; res.Change = getData(Repository.Model.HistoryChangeType.Change) as Model.HistoryUpdateInfo; res.Remove = getData(Repository.Model.HistoryChangeType.Remove) as Model.HistoryRemoveInfo; break; } Thread.Sleep(300); } return new Model.HistoryExecutionResult(res); } catch (Exception ex) { ex.Data.Add(nameof(eventId), eventId); logSession.Enabled = true; logSession.Add(ex); return new Model.HistoryExecutionResult(ex); } throw new NotImplementedException(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.History model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.History model) { return(dal.Add(model)); }
public SqlCommand UpdateCommand(Model.History model) { return(dal.UpdateCommand(model)); }
public SqlCommand AddCommand(Model.History model) { return(dal.AddCommand(model)); }
private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { //检测 是否把epoxy拿了出来. //bool isMaterialIn = Hardware.IO_LIST.Input.X207_Mix_Material_In(); //while (isMaterialIn) //{ // MessageBox.Show("Mixing complete, please open door and take out epoxy!"); // //重新检下测感应器状态. // isMaterialIn = Hardware.IO_LIST.Input.X207_Mix_Material_In(); //} //更新数据库 Model.MixHistory mixModel = new Model.MixHistory(); mixModel.PART_ID = this.txt_partID_input.Text; mixModel.MIX_TIME = decimal.Parse(mixTime.ToString()); mixModel.MIX_DATETIME = DateTime.Now; mixModel.MIX_BY = this.txt_userID.Text; mixModel.REMARK = ""; BLL.Tracking trackBLL = new BLL.Tracking(); Model.Tracking trackModel = trackBLL.GetModel(this.txt_partID.Text); if (trackModel != null) { trackModel.STATUS = StaticRes.Global.Status.Unload; trackModel.UPDATED_TIME = DateTime.Now; trackModel.ACTION = "Mix"; } BLL.History hisBLL = new BLL.History(); Model.History hisModel = hisBLL.CopyTrackModel(trackModel); if (!Update(trackModel, hisModel, mixModel)) { MessageBox.Show("Update database fail!"); Common.Reports.LogFile.Log("[Mix] [BackgroundWorker_RunWorkerCompleted] - Update database fail partID:" + this.txt_partID.Text); } //init 变量 onGoing = false; runningTime = 0; this.pb.Value = 0; //init ui InitMaterialInfo(); this.txt_partID_input.Text = ""; this.txt_partID_input.IsEnabled = true; this.txt_partID_input.Focus(); this.txt_partID_input.Background = StaticRes.ColorBrushes.Linear_Green; ShowWindow(); this.txt_Msg.Text = "搅拌完成, 请取出后关闭或继续搅拌."; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.History model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update History set "); strSql.Append("PART_ID=@PART_ID,"); strSql.Append("SAPCODE=@SAPCODE,"); strSql.Append("BATCH_NO=@BATCH_NO,"); strSql.Append("DESCRIPTION=@DESCRIPTION,"); strSql.Append("DEPARTMENT=@DEPARTMENT,"); strSql.Append("START_WEIGHT=@START_WEIGHT,"); strSql.Append("CURRENT_WEIGHT=@CURRENT_WEIGHT,"); strSql.Append("CAPACITY=@CAPACITY,"); strSql.Append("STATUS=@STATUS,"); strSql.Append("EQUIP_ID=@EQUIP_ID,"); strSql.Append("LOCID=@LOCID,"); strSql.Append("THAWING_DATETIME=@THAWING_DATETIME,"); strSql.Append("READY_DATETIME=@READY_DATETIME,"); strSql.Append("EXPIRY_DATETIME=@EXPIRY_DATETIME,"); strSql.Append("MF_EXPIRY_DATE=@MF_EXPIRY_DATE,"); strSql.Append("LOT_ID=@LOT_ID,"); strSql.Append("DEVICE=@DEVICE,"); strSql.Append("EMPTY_SYRINGE_WEIGHT=@EMPTY_SYRINGE_WEIGHT,"); strSql.Append("USER_ID=@USER_ID,"); strSql.Append("USER_NAME=@USER_NAME,"); strSql.Append("ACTION=@ACTION,"); strSql.Append("REMARKS=@REMARKS,"); strSql.Append("UPDATED_TIME=@UPDATED_TIME,"); strSql.Append("WEEK=@WEEK,"); strSql.Append("MONTH=@MONTH,"); strSql.Append("YEAR=@YEAR"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@PART_ID", SqlDbType.VarChar,50), new SqlParameter("@SAPCODE", SqlDbType.VarChar,50), new SqlParameter("@BATCH_NO", SqlDbType.VarChar,50), new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,100), new SqlParameter("@DEPARTMENT", SqlDbType.VarChar,50), new SqlParameter("@START_WEIGHT", SqlDbType.Decimal,5), new SqlParameter("@CURRENT_WEIGHT", SqlDbType.Decimal,5), new SqlParameter("@CAPACITY", SqlDbType.Int,4), new SqlParameter("@STATUS", SqlDbType.VarChar,20), new SqlParameter("@EQUIP_ID", SqlDbType.VarChar,20), new SqlParameter("@LOCID", SqlDbType.VarChar,50), new SqlParameter("@THAWING_DATETIME", SqlDbType.DateTime), new SqlParameter("@READY_DATETIME", SqlDbType.DateTime), new SqlParameter("@EXPIRY_DATETIME", SqlDbType.DateTime), new SqlParameter("@MF_EXPIRY_DATE", SqlDbType.DateTime), new SqlParameter("@LOT_ID", SqlDbType.VarChar,50), new SqlParameter("@DEVICE", SqlDbType.VarChar,100), new SqlParameter("@EMPTY_SYRINGE_WEIGHT", SqlDbType.Decimal,5), new SqlParameter("@USER_ID", SqlDbType.VarChar,50), new SqlParameter("@USER_NAME", SqlDbType.VarChar,50), new SqlParameter("@ACTION", SqlDbType.VarChar,50), new SqlParameter("@REMARKS", SqlDbType.VarChar,100), new SqlParameter("@UPDATED_TIME", SqlDbType.DateTime), new SqlParameter("@WEEK", SqlDbType.Int,4), new SqlParameter("@MONTH", SqlDbType.Int,4), new SqlParameter("@YEAR", SqlDbType.Int,4)}; parameters[0].Value = model.PART_ID; parameters[1].Value = model.SAPCODE; parameters[2].Value = model.BATCH_NO; parameters[3].Value = model.DESCRIPTION; parameters[4].Value = model.DEPARTMENT; parameters[5].Value = model.START_WEIGHT; parameters[6].Value = model.CURRENT_WEIGHT; parameters[7].Value = model.CAPACITY; parameters[8].Value = model.STATUS; parameters[9].Value = model.EQUIP_ID; parameters[10].Value = model.LOCID; parameters[11].Value = model.THAWING_DATETIME; parameters[12].Value = model.READY_DATETIME; parameters[13].Value = model.EXPIRY_DATETIME; parameters[14].Value = model.MF_EXPIRY_DATE; parameters[15].Value = model.LOT_ID; parameters[16].Value = model.DEVICE; parameters[17].Value = model.EMPTY_SYRINGE_WEIGHT; parameters[18].Value = model.USER_ID; parameters[19].Value = model.USER_NAME; parameters[20].Value = model.ACTION; parameters[21].Value = model.REMARKS; parameters[22].Value = model.UPDATED_TIME; parameters[23].Value = model.WEEK; parameters[24].Value = model.MONTH; parameters[25].Value = model.YEAR; int rows=Common.DB.SqlDB.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } }
public SqlCommand AddCommand(Model.History model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into History("); strSql.Append("PART_ID,SAPCODE,BATCH_NO,DESCRIPTION,DEPARTMENT,START_WEIGHT,CURRENT_WEIGHT,CAPACITY,STATUS,EQUIP_ID,LOCID,THAWING_DATETIME,READY_DATETIME,EXPIRY_DATETIME,MF_EXPIRY_DATE,LOT_ID,DEVICE,EMPTY_SYRINGE_WEIGHT,USER_ID,USER_NAME,ACTION,REMARKS,UPDATED_TIME,WEEK,MONTH,YEAR)"); strSql.Append(" values ("); strSql.Append("@PART_ID,@SAPCODE,@BATCH_NO,@DESCRIPTION,@DEPARTMENT,@START_WEIGHT,@CURRENT_WEIGHT,@CAPACITY,@STATUS,@EQUIP_ID,@LOCID,@THAWING_DATETIME,@READY_DATETIME,@EXPIRY_DATETIME,@MF_EXPIRY_DATE,@LOT_ID,@DEVICE,@EMPTY_SYRINGE_WEIGHT,@USER_ID,@USER_NAME,@ACTION,@REMARKS,@UPDATED_TIME,@WEEK,@MONTH,@YEAR)"); SqlParameter[] parameters = { new SqlParameter("@PART_ID", SqlDbType.VarChar,50), new SqlParameter("@SAPCODE", SqlDbType.VarChar,50), new SqlParameter("@BATCH_NO", SqlDbType.VarChar,50), new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,100), new SqlParameter("@DEPARTMENT", SqlDbType.VarChar,50), new SqlParameter("@START_WEIGHT", SqlDbType.Decimal,5), new SqlParameter("@CURRENT_WEIGHT", SqlDbType.Decimal,5), new SqlParameter("@CAPACITY", SqlDbType.Int,4), new SqlParameter("@STATUS", SqlDbType.VarChar,20), new SqlParameter("@EQUIP_ID", SqlDbType.VarChar,20), new SqlParameter("@LOCID", SqlDbType.VarChar,50), new SqlParameter("@THAWING_DATETIME", SqlDbType.DateTime), new SqlParameter("@READY_DATETIME", SqlDbType.DateTime), new SqlParameter("@EXPIRY_DATETIME", SqlDbType.DateTime), new SqlParameter("@MF_EXPIRY_DATE", SqlDbType.DateTime), new SqlParameter("@LOT_ID", SqlDbType.VarChar,50), new SqlParameter("@DEVICE", SqlDbType.VarChar,100), new SqlParameter("@EMPTY_SYRINGE_WEIGHT", SqlDbType.Decimal,5), new SqlParameter("@USER_ID", SqlDbType.VarChar,50), new SqlParameter("@USER_NAME", SqlDbType.VarChar,50), new SqlParameter("@ACTION", SqlDbType.VarChar,50), new SqlParameter("@REMARKS", SqlDbType.VarChar,100), new SqlParameter("@UPDATED_TIME", SqlDbType.DateTime), new SqlParameter("@WEEK", SqlDbType.Int,4), new SqlParameter("@MONTH", SqlDbType.Int,4), new SqlParameter("@YEAR", SqlDbType.Int,4)}; parameters[0].Value = model.PART_ID; parameters[1].Value = model.SAPCODE; parameters[2].Value = model.BATCH_NO; parameters[3].Value = model.DESCRIPTION; parameters[4].Value = model.DEPARTMENT; parameters[5].Value = model.START_WEIGHT; parameters[6].Value = model.CURRENT_WEIGHT; parameters[7].Value = model.CAPACITY; parameters[8].Value = model.STATUS; parameters[9].Value = model.EQUIP_ID; parameters[10].Value = model.LOCID; parameters[11].Value = model.THAWING_DATETIME; parameters[12].Value = model.READY_DATETIME; parameters[13].Value = model.EXPIRY_DATETIME; parameters[14].Value = model.MF_EXPIRY_DATE; parameters[15].Value = model.LOT_ID; parameters[16].Value = model.DEVICE; parameters[17].Value = model.EMPTY_SYRINGE_WEIGHT; parameters[18].Value = model.USER_ID; parameters[19].Value = model.USER_NAME; parameters[20].Value = model.ACTION; parameters[21].Value = model.REMARKS; parameters[22].Value = model.UPDATED_TIME; parameters[23].Value = model.WEEK; parameters[24].Value = model.MONTH; parameters[25].Value = model.YEAR; return Common.DB.SqlDB.GenerateCommand(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.History DataRowToModel(DataRow row) { Model.History model=new Model.History(); if (row != null) { if(row["PART_ID"]!=null) { model.PART_ID=row["PART_ID"].ToString(); } if(row["SAPCODE"]!=null) { model.SAPCODE=row["SAPCODE"].ToString(); } if(row["BATCH_NO"]!=null) { model.BATCH_NO=row["BATCH_NO"].ToString(); } if(row["DESCRIPTION"]!=null) { model.DESCRIPTION=row["DESCRIPTION"].ToString(); } if(row["DEPARTMENT"]!=null) { model.DEPARTMENT=row["DEPARTMENT"].ToString(); } if(row["START_WEIGHT"]!=null && row["START_WEIGHT"].ToString()!="") { model.START_WEIGHT=decimal.Parse(row["START_WEIGHT"].ToString()); } if(row["CURRENT_WEIGHT"]!=null && row["CURRENT_WEIGHT"].ToString()!="") { model.CURRENT_WEIGHT=decimal.Parse(row["CURRENT_WEIGHT"].ToString()); } if(row["CAPACITY"]!=null && row["CAPACITY"].ToString()!="") { model.CAPACITY=int.Parse(row["CAPACITY"].ToString()); } if(row["STATUS"]!=null) { model.STATUS=row["STATUS"].ToString(); } if(row["EQUIP_ID"]!=null) { model.EQUIP_ID=row["EQUIP_ID"].ToString(); } if(row["LOCID"]!=null) { model.LOCID=row["LOCID"].ToString(); } if(row["THAWING_DATETIME"]!=null && row["THAWING_DATETIME"].ToString()!="") { model.THAWING_DATETIME=DateTime.Parse(row["THAWING_DATETIME"].ToString()); } if(row["READY_DATETIME"]!=null && row["READY_DATETIME"].ToString()!="") { model.READY_DATETIME=DateTime.Parse(row["READY_DATETIME"].ToString()); } if(row["EXPIRY_DATETIME"]!=null && row["EXPIRY_DATETIME"].ToString()!="") { model.EXPIRY_DATETIME=DateTime.Parse(row["EXPIRY_DATETIME"].ToString()); } if(row["MF_EXPIRY_DATE"]!=null && row["MF_EXPIRY_DATE"].ToString()!="") { model.MF_EXPIRY_DATE=DateTime.Parse(row["MF_EXPIRY_DATE"].ToString()); } if(row["LOT_ID"]!=null) { model.LOT_ID=row["LOT_ID"].ToString(); } if(row["DEVICE"]!=null) { model.DEVICE=row["DEVICE"].ToString(); } if(row["EMPTY_SYRINGE_WEIGHT"]!=null && row["EMPTY_SYRINGE_WEIGHT"].ToString()!="") { model.EMPTY_SYRINGE_WEIGHT=decimal.Parse(row["EMPTY_SYRINGE_WEIGHT"].ToString()); } if(row["USER_ID"]!=null) { model.USER_ID=row["USER_ID"].ToString(); } if(row["USER_NAME"]!=null) { model.USER_NAME=row["USER_NAME"].ToString(); } if(row["ACTION"]!=null) { model.ACTION=row["ACTION"].ToString(); } if(row["REMARKS"]!=null) { model.REMARKS=row["REMARKS"].ToString(); } if(row["UPDATED_TIME"]!=null && row["UPDATED_TIME"].ToString()!="") { model.UPDATED_TIME=DateTime.Parse(row["UPDATED_TIME"].ToString()); } if(row["WEEK"]!=null && row["WEEK"].ToString()!="") { model.WEEK=int.Parse(row["WEEK"].ToString()); } if(row["MONTH"]!=null && row["MONTH"].ToString()!="") { model.MONTH=int.Parse(row["MONTH"].ToString()); } if(row["YEAR"]!=null && row["YEAR"].ToString()!="") { model.YEAR=int.Parse(row["YEAR"].ToString()); } } return model; }