public ProgressSummary GetTotal(EServiceType serviceType) { lock (lockObject) { return(serviceTypePrgressInfo.GetTotal(serviceType)); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("ServiceType"); _serviceType = EServiceTypeUtils.GetEnumType(Body.GetQueryString("ServiceType")); if (Body.IsQueryExists("Delete")) { var taskId = Body.GetQueryInt("TaskID"); try { DataProvider.TaskDao.Delete(taskId); SuccessDeleteMessage(); } catch (Exception ex) { FailDeleteMessage(ex); } } if (Body.IsQueryExists("Enabled")) { var taskId = Body.GetQueryInt("TaskID"); var isEnabled = Body.GetQueryBool("IsEnabled"); var func = isEnabled ? "启用" : "禁用"; try { DataProvider.TaskDao.UpdateState(taskId, isEnabled); SuccessMessage($"{func}定时任务成功。"); } catch (Exception ex) { FailMessage(ex, $"{func}定时任务失败。"); } } if (!IsPostBack) { var taskName = EServiceTypeUtils.GetText(_serviceType); if (PublishmentSystemId > 0) { BreadCrumb(AppManager.Cms.LeftMenu.IdConfigration, AppManager.Cms.LeftMenu.Configuration.IdConfigurationTask, taskName + "任务", AppManager.Cms.Permission.WebSite.Configration); } else { BreadCrumbService(AppManager.Service.LeftMenu.Task, taskName + "任务", AppManager.Service.Permission.ServiceTask); } AddTask.Text = $"添加{taskName}任务"; AddTask.Attributes.Add("onclick", ModalTaskAdd.GetOpenWindowStringToAdd(_serviceType, PublishmentSystemId)); BindGrid(); } }
/// <summary> /// Get log infos. /// </summary> /// <param name="serviceType">The given servicetype.</param> /// <param name="date">The date.</param> /// <param name="user">The user</param> /// <param name="logLevel">The loglevel</param> public void GetLogInfos(EServiceType serviceType, string date, string user, string logLevel) { var name = user + Defaults.BusinessLogFileSplitChar + logLevel + Defaults.BusinessLogFileSplitChar + date; var directoryInfo = new DirectoryInfo(Defaults.RootDirectory + serviceType.ToString()); var file = directoryInfo.GetFiles().FirstOrDefault(zw => zw.Name.StartsWith(name)); //for files. if (file != null) { File.Copy(file.FullName, file.FullName + "copy"); var lines = File.ReadAllLines(file.FullName + "copy", Encoding.Default); File.Delete(file.FullName + "copy"); var thisCallback = OperationContext.Current.GetCallbackChannel <IMessageCallback>(); Task t = new Task(() => { Thread.Sleep(1000); StringBuilder sb = new StringBuilder(""); foreach (var line in lines) { if (Regex.Match(line, "^\\d{4}-\\d{2}-\\d{2}").Success) { if (sb.ToString() != string.Empty) { thisCallback.NotifyLogInfo(sb.ToString()); sb.Clear(); } } sb.Append(line); sb.AppendLine(); } }); t.Start(); } }
public RequestParameterList GetRequestParameter(EServiceType serviceType) { if (serviceType.ServiceType == "ImcTFSample") { return(new RequestParameterList() { RequestParameters = new List <RequestParameter>() { new RequestParameter() { Name = "Site", CommaValue = "MY,ID,SG" }, new RequestParameter() { Name = "SellerAccount", CommaValue = "4,5,6" } } }); } return(new RequestParameterList() { RequestParameters = new List <RequestParameter>() { new RequestParameter() { Name = "SellerAccount", CommaValue = "1,2,3" } } }); }
public void Clear(EServiceType serviceType) { lock (lockObject) { serviceTypePrgressInfo.Remove(serviceType); } }
public void SetItemValue(EServiceType serviceType, string user, int value, bool accumulate = true) { lock (lockObject) { serviceTypePrgressInfo.SetItemValue(serviceType, user, value, accumulate); } }
public void SetItemValueFinish(EServiceType serviceType, string user) { lock (lockObject) { serviceTypePrgressInfo[serviceType].SetItemValueFinish(user); } }
public void SetItemTotal(EServiceType serviceType, string user, int total) { lock (lockObject) { serviceTypePrgressInfo[serviceType].SetProgressItem(user, total, 0); } }
public void SetTotal(EServiceType serviceType, int total, TotalType totalType) { lock (lockObject) { serviceTypePrgressInfo.SetTotal(serviceType, total, totalType); } }
public ProgressItem GetUserProgressInfo(EServiceType serviceType, string user) { lock (lockObject) { return(serviceTypePrgressInfo.GetUserProgressInfo(serviceType, user)); } }
public static string GetRedirectUrl(int publishmentSystemId, EServiceType serviceType) { return(PageUtils.GetCmsUrl(nameof(PageTask), new NameValueCollection { { "PublishmentSystemID", publishmentSystemId.ToString() }, { "ServiceType", EServiceTypeUtils.GetValue(serviceType) } })); }
public static string GetOpenWindowStringToAdd(EServiceType serviceType, int publishmentSystemId) { return(PageUtils.GetOpenWindowString("添加任务", PageUtils.GetCmsUrl(nameof(ModalTaskAdd), new NameValueCollection { { "ServiceType", EServiceTypeUtils.GetValue(serviceType) }, { "PublishmentSystemID", publishmentSystemId.ToString() } }))); }
public ucServiceConfig(EServiceType serviceType) { InitializeComponent(); this.serviceType = serviceType; this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.DoubleBuffer, true); flowLayoutParameter = new DefaultFlowLayoutParameter(); }
/// <summary> /// UnRegister a servicetype. /// </summary> /// <param name="serviceType">The given servicetype.</param> public void UnRegister(EServiceType serviceType) { callback = OperationContext.Current.GetCallbackChannel <IMessageCallback>(); loggerPool.Log(serviceType.ServiceType, new LogContentEntity("Unregister!")); callback.Notify(MessageEntity.NormalInfo(serviceType, " Unregister")); Observers.Remove(serviceType, callback); }
public static ListItem GetListItem(EServiceType type, bool selected) { var item = new ListItem(GetText(type), GetValue(type)); if (selected) { item.Selected = true; } return(item); }
/// <summary> /// Remove a servicetype & callback. /// </summary> /// <param name="serviceType">The given servicetype.</param> /// <param name="callback">The callback instance.</param> public static void Remove(EServiceType serviceType, IMessageCallback callback) { if (Exist(serviceType, callback)) { lock (lockObject) { var tmp = clientList.Find(zw => zw.ServiceType.Equals(serviceType)); tmp.Callbacks.Remove(callback); } } }
public static MessageEntity ErrorInfo(EServiceType serviceType, string msgContent = "") { return new MessageEntity() { MessageType = EMessageType.Error, Timestamp = DateTime.Now, ServiceType = serviceType, MsgContent = msgContent, LogLevel = "Error" }; }
public static MessageEntity ErrorInfo(EServiceType serviceType, string msgContent = "") { return(new MessageEntity() { MessageType = EMessageType.Error, Timestamp = DateTime.Now, ServiceType = serviceType, MsgContent = msgContent, LogLevel = "Error" }); }
public static bool Equals(EServiceType type, string typeStr) { if (string.IsNullOrEmpty(typeStr)) { return(false); } if (string.Equals(GetValue(type).ToLower(), typeStr.ToLower())) { return(true); } return(false); }
/// <summary> /// Check the given servicetype and callback exists whether or not. /// </summary> /// <param name="serviceType">The given servicetype.</param> /// <param name="callback">The callback instance.</param> /// <returns>return true if exists,otherwise return false.</returns> public static bool Exist(EServiceType serviceType, IMessageCallback callback) { lock (lockObject) { var client = clientList.Find(zw => zw.ServiceType.Equals(serviceType)); if (client != null) { return(client.Callbacks.Contains(callback)); } return(false); } }
public void DeleteSystemTask(int publishmentSystemId, EServiceType serviceType) { const string sqlString = "DELETE FROM siteserver_Task WHERE PublishmentSystemID = @PublishmentSystemID AND IsSystemTask = @IsSystemTask AND ServiceType = @ServiceType"; var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmIsSystemTask, EDataType.VarChar, 18, true.ToString()), GetParameter(ParmServiceType, EDataType.VarChar, 50, EServiceTypeUtils.GetValue(serviceType)) }; ExecuteNonQuery(sqlString, parms); ServiceManager.ClearTaskCache(); }
public TaskInfo(int taskID, string taskName, bool isSystemTask, int publishmentSystemID, EServiceType serviceType, string serviceParameters, EFrequencyType frequencyType, int periodIntervalMinute, int startDay, int startWeekday, int startHour, bool isEnabled, DateTime addDate, DateTime lastExecuteDate, string description) { this.taskID = taskID; this.taskName = taskName; this.isSystemTask = isSystemTask; this.publishmentSystemID = publishmentSystemID; this.serviceType = serviceType; this.serviceParameters = serviceParameters; this.frequencyType = frequencyType; this.periodIntervalMinute = periodIntervalMinute; this.startDay = startDay; this.startWeekday = startWeekday; this.startHour = startHour; this.isEnabled = isEnabled; this.addDate = addDate; this.lastExecuteDate = lastExecuteDate; this.description = description; }
public TaskInfo() { taskID = 0; taskName = string.Empty; isSystemTask = false; publishmentSystemID = 0; serviceType = EServiceType.Backup; serviceParameters = string.Empty; frequencyType = EFrequencyType.Week; periodIntervalMinute = 0; startDay = 0; startWeekday = 0; startHour = 0; isEnabled = false; addDate = DateTime.Now; lastExecuteDate = DateTime.Now; description = string.Empty; }
public static string GetValue(EServiceType type) { if (type == EServiceType.Create) { return("Create"); } else if (type == EServiceType.Gather) { return("Gather"); } else if (type == EServiceType.Backup) { return("Backup"); } else { throw new Exception(); } }
public static string GetText(EServiceType type) { if (type == EServiceType.Create) { return("定时生成"); } else if (type == EServiceType.Gather) { return("定时采集"); } else if (type == EServiceType.Backup) { return("定时备份"); } else { throw new Exception(); } }
/// <summary> /// Get loginfo dates. /// </summary> /// <param name="serviceType">The given servicetype.</param> /// <returns>return the loginfo list.</returns> public IEnumerable <LogInfo> GetLogInfoDates(EServiceType serviceType) { var list = new List <LogInfo>(); string logPath = Path.Combine(Defaults.RootDirectory, serviceType.ToString()); if (!Directory.Exists(logPath)) { return(list); } foreach (var item in new DirectoryInfo(logPath).GetFiles("*.txt")) { var fileNameSpliteItems = item.Name.Split(new string[] { Defaults.BusinessLogFileSplitChar, ".txt" }, StringSplitOptions.RemoveEmptyEntries); if (fileNameSpliteItems != null && fileNameSpliteItems.Length == 3) { var sellerAccountLogLevel = new UserLogLevel() { User = fileNameSpliteItems[0], LogLevel = fileNameSpliteItems[1] }; var date = list.FirstOrDefault(zw => zw.DateString == fileNameSpliteItems[2]); if (date == null) //日期 { list.Add(new LogInfo() { DateString = fileNameSpliteItems[2], UserLogLevels = new List <UserLogLevel>() { sellerAccountLogLevel } }); } else { date.UserLogLevels.Add(sellerAccountLogLevel); } } } return(list.OrderByDescending(zw => zw.DateString).ToList()); }
/// <summary> /// Add a servicetype & callback. /// </summary> /// <param name="serviceType">The given servicetype.</param> /// <param name="callback">The callback instance.</param> public static void Add(EServiceType serviceType, IMessageCallback callback) { lock (lockObject) { var tmp = clientList.Find(zw => zw.ServiceType.Equals(serviceType)); if (tmp != null) { tmp.Callbacks.Add(callback); } else { clientList.Add(new Client() { ServiceType = serviceType, Callbacks = new List <IMessageCallback>() { callback } }); } } }
public List <int> GetTaskIdList(EServiceType serviceType) { var list = new List <int>(); const string sqlString = "SELECT TaskID FROM siteserver_Task WHERE ServiceType = @ServiceType"; var parms = new IDataParameter[] { GetParameter(ParmServiceType, EDataType.VarChar, 50, EServiceTypeUtils.GetValue(serviceType)) }; using (var rdr = ExecuteReader(sqlString, parms)) { while (rdr.Read()) { list.Add(GetInt(rdr, 0)); } rdr.Close(); } return(list); }
/// <summary> /// Get servicetype info /// </summary> /// <param name="serviceType">The given servicetype.</param> /// <returns>return the serviceinfo of the job.</returns> public ServiceInfo GetServiceInfo(EServiceType serviceType) { try { var obj = commandInvoker.Invoke <GetServiceInfoOutput>(new FunctionSwitch() { Command = ECommand.GetServiceInfo, ServiceType = serviceType }); if (obj != null) { return(obj.ServiceInfo); } return(null); } catch (Exception ex) { var fex = new FaultException(new FaultReason(ex.Message), new FaultCode("003"), "GetServiceInfo"); loggerPool.Log(serviceType.ServiceType, new LogContentEntity(fex.Message + fex.StackTrace)); throw fex; } }
public List <TaskInfo> GetTaskInfoList(EServiceType serviceType) { var list = new List <TaskInfo>(); const string sqlString = "SELECT TaskID, TaskName, IsSystemTask, PublishmentSystemID, ServiceType, ServiceParameters, FrequencyType, PeriodIntervalMinute, StartDay, StartWeekday, StartHour, IsEnabled, AddDate, LastExecuteDate, Description, OnlyOnceDate FROM siteserver_Task WHERE ServiceType = @ServiceType"; var parms = new IDataParameter[] { GetParameter(ParmServiceType, EDataType.VarChar, 50, EServiceTypeUtils.GetValue(serviceType)) }; using (var rdr = ExecuteReader(sqlString, parms)) { while (rdr.Read()) { var i = 0; var info = new TaskInfo(GetInt(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetInt(rdr, i++), EServiceTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), EFrequencyTypeUtils.GetEnumType(GetString(rdr, i++)), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetDateTime(rdr, i++), GetDateTime(rdr, i++), GetString(rdr, i++), GetDateTime(rdr, i)); list.Add(info); } rdr.Close(); } return(list); }
public bool IsSystemTaskExists(int publishmentSystemId, EServiceType serviceType) { var exists = false; const string sqlString = "SELECT TaskID FROM siteserver_Task WHERE PublishmentSystemID = @PublishmentSystemID AND IsSystemTask = @IsSystemTask AND ServiceType = @ServiceType"; var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmIsSystemTask, EDataType.VarChar, 18, true.ToString()), GetParameter(ParmServiceType, EDataType.VarChar, 50, EServiceTypeUtils.GetValue(serviceType)) }; using (var rdr = ExecuteReader(sqlString, parms)) { if (rdr.Read() && !rdr.IsDBNull(0)) { exists = true; } rdr.Close(); } return(exists); }