/// <summary> /// 发布新版本程序 /// </summary> /// <param name="programModel"></param> /// <param name="programType"></param> /// <returns></returns> public Model.Enum.HandleResult ReleaseProgram(AdvertManage.Model.ProgramUpgradeModel programModel) { try { AdvertManage.Model.ProgramUpgradeModel oldProgram = GetProgramInfoByProgramType(programModel.Application); if (oldProgram == null) { programUpgradeDal.Add(programModel); } else { if (oldProgram.Version == programModel.Version) { return(Model.Enum.HandleResult.Failed); } else { programModel.Id = oldProgram.Id; programUpgradeDal.Update(programModel); } } return(Model.Enum.HandleResult.Successed); } catch (Exception ex) { throw ex; } }
/// <summary> /// 系统Xml信息上传 /// </summary> public string SystemUpdate() { try { system.ReleaseDate = DateTime.Now; system.StartProgram = StartProgram; system.SubsystemType = (SeatManage.EnumType.SeatManageSubsystem)(int) SystemType; system.UpdateLog = string.Format("{0}{1}\r{2}\r\r", oldSystem == null ? "" : oldSystem.UpdateLog, DateTime.Now.ToShortDateString(), UpdateLog); system.Version = Version; AdvertManage.Model.ProgramUpgradeModel model = new AdvertManage.Model.ProgramUpgradeModel(); model.Application = SystemType; model.AutoUpdaterXml = system.ToString(); model.ReleaseDate = DateTime.Now; model.UpdateLog += string.Format("{0}{1}\r{2}\r\r", oldSystem == null ? "" : oldSystem.UpdateLog, DateTime.Now.ToShortDateString(), UpdateLog); model.Version = Version; if (AdvertManage.BLL.ProgramUpgradeBLL.ReleaseProgram(model) == AdvertManage.Model.Enum.HandleResult.Successed) { return("更新成功"); } else { return("更新失败"); } } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// 发布新版本程序 /// </summary> /// <param name="programModel">要发布的程序信息</param> /// <param name="programType">要发布的程序类型</param> /// <returns></returns> public static Model.Enum.HandleResult ReleaseProgram(AdvertManage.Model.ProgramUpgradeModel programModel) { IWCFService.IAdvertManageService advertService = WcfAccessProxy.AMS_ServiceProxy.CreateChannelAdvertManageService(); bool error = false; try { return(advertService.ReleaseProgram(programModel)); } catch (Exception ex) { error = true; SeatManage.SeatManageComm.WriteLog.Write(string.Format("根据类型获取对应的程序信息失败 ,异常来自:{0};信息:{1}", ex.Source, ex.Message)); throw ex; } finally { ICommunicationObject ICommObjectService = advertService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
AdvertManage.Model.ProgramUpgradeModel DataRowToProgramUpgradeModel(DataRow dr) { AdvertManage.Model.ProgramUpgradeModel model = new AdvertManage.Model.ProgramUpgradeModel(); if (dr["Id"] != null && dr["Id"].ToString() != "") { model.Id = int.Parse(dr["Id"].ToString()); } if (dr["Application"] != null && dr["Application"].ToString() != "") { model.Application = (Model.Enum.SeatManageSubsystem) int.Parse(dr["Application"].ToString()); } if (dr["AutoUpdaterXml"] != null && dr["AutoUpdaterXml"].ToString() != "") { model.AutoUpdaterXml = dr["AutoUpdaterXml"].ToString(); } if (dr["UpdateLog"] != null && dr["UpdateLog"].ToString() != "") { model.UpdateLog = dr["UpdateLog"].ToString(); } if (dr["ReleaseDate"] != null && dr["ReleaseDate"].ToString() != "") { model.ReleaseDate = DateTime.Parse(dr["ReleaseDate"].ToString()); } if (dr["Version"] != null && dr["Version"].ToString() != "") { model.Version = dr["Version"].ToString(); } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(AdvertManage.Model.ProgramUpgradeModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ProgramUpgrade("); strSql.Append("Application,AutoUpdaterXml,UpdateLog,ReleaseDate,Version)"); strSql.Append(" values ("); strSql.Append("@Application,@AutoUpdaterXml,@UpdateLog,@ReleaseDate,@Version)"); SqlParameter[] parameters = { new SqlParameter("@Application", SqlDbType.Int, 4), new SqlParameter("@AutoUpdaterXml", SqlDbType.Text), new SqlParameter("@UpdateLog", SqlDbType.NVarChar, 4000), new SqlParameter("@ReleaseDate", SqlDbType.DateTime), new SqlParameter("@Version", SqlDbType.NVarChar, 50) }; parameters[0].Value = (int)model.Application; parameters[1].Value = model.AutoUpdaterXml; parameters[2].Value = model.UpdateLog; parameters[3].Value = model.ReleaseDate; parameters[4].Value = model.Version; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (dataGrid1.SelectedIndex != -1) { AdvertManage.Model.ProgramUpgradeModel model = dataGrid1.SelectedItem as AdvertManage.Model.ProgramUpgradeModel; IssueCommand issue = new IssueCommand(); issue.Command = AdvertManage.Model.Enum.CommandType.ProgramUpgrade; issue.CommandId = model.Id; issue.Show(); } }
/// <summary> /// 得到一个对象实体 /// </summary> public AdvertManage.Model.ProgramUpgradeModel GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,Application,AutoUpdaterXml,UpdateLog,ReleaseDate,Version from ProgramUpgrade "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; AdvertManage.Model.ProgramUpgradeModel model = new AdvertManage.Model.ProgramUpgradeModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["Application"] != null && ds.Tables[0].Rows[0]["Application"].ToString() != "") { model.Application = (Model.Enum.SeatManageSubsystem) int.Parse(ds.Tables[0].Rows[0]["Application"].ToString()); } if (ds.Tables[0].Rows[0]["AutoUpdaterXml"] != null && ds.Tables[0].Rows[0]["AutoUpdaterXml"].ToString() != "") { model.AutoUpdaterXml = ds.Tables[0].Rows[0]["AutoUpdaterXml"].ToString(); } if (ds.Tables[0].Rows[0]["UpdateLog"] != null && ds.Tables[0].Rows[0]["UpdateLog"].ToString() != "") { model.UpdateLog = ds.Tables[0].Rows[0]["UpdateLog"].ToString(); } if (ds.Tables[0].Rows[0]["ReleaseDate"] != null && ds.Tables[0].Rows[0]["ReleaseDate"].ToString() != "") { model.ReleaseDate = DateTime.Parse(ds.Tables[0].Rows[0]["ReleaseDate"].ToString()); } if (ds.Tables[0].Rows[0]["Version"] != null && ds.Tables[0].Rows[0]["Version"].ToString() != "") { model.Version = ds.Tables[0].Rows[0]["Version"].ToString(); } return(model); } else { return(null); } }
/// <summary> /// 获取选中的系统类型 /// </summary> public void FindSystemMessage() { AdvertManage.Model.ProgramUpgradeModel program = AdvertManage.BLL.ProgramUpgradeBLL.GetProgramInfoByProgramType((AdvertManage.Model.Enum.SeatManageSubsystem)(int) SystemType); if (program == null) { return; } oldSystem = FileUpdateInfo.Convert(program.AutoUpdaterXml); if (oldSystem != null) { Version = oldSystem.Version; } else { } }
/// <summary> /// 构建文件路径,上传。 /// </summary> public string BuildUpdateFile() { AdvertManage.Model.ProgramUpgradeModel program = AdvertManage.BLL.ProgramUpgradeBLL.GetProgramInfoByProgramType((AdvertManage.Model.Enum.SeatManageSubsystem)(int) SystemType); if (program != null) { oldSystem = FileUpdateInfo.Convert(program.AutoUpdaterXml); if (oldSystem != null && Version == oldSystem.Version) { return("版本号重复"); } filePaths = system.BuildUpdateFilePaths(); return(""); } else { return(""); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(AdvertManage.Model.ProgramUpgradeModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ProgramUpgrade set "); strSql.Append("Application=@Application,"); strSql.Append("AutoUpdaterXml=@AutoUpdaterXml,"); strSql.Append("UpdateLog=@UpdateLog,"); strSql.Append("ReleaseDate=@ReleaseDate,"); strSql.Append("Version=@Version"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Application", SqlDbType.Int, 4), new SqlParameter("@AutoUpdaterXml", SqlDbType.Text), new SqlParameter("@UpdateLog", SqlDbType.NVarChar, 4000), new SqlParameter("@ReleaseDate", SqlDbType.DateTime), new SqlParameter("@Version", SqlDbType.NVarChar, 50), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = (int)model.Application; parameters[1].Value = model.AutoUpdaterXml; parameters[2].Value = model.UpdateLog; parameters[3].Value = model.ReleaseDate; parameters[4].Value = model.Version; parameters[5].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }