Пример #1
0
 public ProgressSummary GetTotal(EServiceType serviceType)
 {
     lock (lockObject)
     {
         return(serviceTypePrgressInfo.GetTotal(serviceType));
     }
 }
Пример #2
0
        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();
            }
        }
Пример #3
0
        /// <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();
            }
        }
Пример #4
0
        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"
                    }
                }
            });
        }
Пример #5
0
 public void Clear(EServiceType serviceType)
 {
     lock (lockObject)
     {
         serviceTypePrgressInfo.Remove(serviceType);
     }
 }
Пример #6
0
 public void SetItemValue(EServiceType serviceType, string user, int value, bool accumulate = true)
 {
     lock (lockObject)
     {
         serviceTypePrgressInfo.SetItemValue(serviceType, user, value, accumulate);
     }
 }
Пример #7
0
 public void SetItemValueFinish(EServiceType serviceType, string user)
 {
     lock (lockObject)
     {
         serviceTypePrgressInfo[serviceType].SetItemValueFinish(user);
     }
 }
Пример #8
0
 public void SetItemTotal(EServiceType serviceType, string user, int total)
 {
     lock (lockObject)
     {
         serviceTypePrgressInfo[serviceType].SetProgressItem(user, total, 0);
     }
 }
Пример #9
0
 public void SetTotal(EServiceType serviceType, int total, TotalType totalType)
 {
     lock (lockObject)
     {
         serviceTypePrgressInfo.SetTotal(serviceType, total, totalType);
     }
 }
Пример #10
0
 public ProgressItem GetUserProgressInfo(EServiceType serviceType, string user)
 {
     lock (lockObject)
     {
         return(serviceTypePrgressInfo.GetUserProgressInfo(serviceType, user));
     }
 }
Пример #11
0
 public static string GetRedirectUrl(int publishmentSystemId, EServiceType serviceType)
 {
     return(PageUtils.GetCmsUrl(nameof(PageTask), new NameValueCollection
     {
         { "PublishmentSystemID", publishmentSystemId.ToString() },
         { "ServiceType", EServiceTypeUtils.GetValue(serviceType) }
     }));
 }
Пример #12
0
 public static string GetOpenWindowStringToAdd(EServiceType serviceType, int publishmentSystemId)
 {
     return(PageUtils.GetOpenWindowString("添加任务", PageUtils.GetCmsUrl(nameof(ModalTaskAdd), new NameValueCollection
     {
         { "ServiceType", EServiceTypeUtils.GetValue(serviceType) },
         { "PublishmentSystemID", publishmentSystemId.ToString() }
     })));
 }
Пример #13
0
        public ucServiceConfig(EServiceType serviceType)
        {
            InitializeComponent();
            this.serviceType = serviceType;
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.DoubleBuffer, true);

            flowLayoutParameter = new DefaultFlowLayoutParameter();
        }
Пример #14
0
        /// <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);
        }
Пример #15
0
        public static ListItem GetListItem(EServiceType type, bool selected)
        {
            var item = new ListItem(GetText(type), GetValue(type));

            if (selected)
            {
                item.Selected = true;
            }
            return(item);
        }
Пример #16
0
 /// <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);
         }
     }
 }
Пример #17
0
 public static MessageEntity ErrorInfo(EServiceType serviceType, string msgContent = "")
 {
     return new MessageEntity()
     {
         MessageType = EMessageType.Error,
         Timestamp = DateTime.Now,
         ServiceType = serviceType,
         MsgContent = msgContent,
         LogLevel = "Error"
     };
 }
Пример #18
0
 public static MessageEntity ErrorInfo(EServiceType serviceType, string msgContent = "")
 {
     return(new MessageEntity()
     {
         MessageType = EMessageType.Error,
         Timestamp = DateTime.Now,
         ServiceType = serviceType,
         MsgContent = msgContent,
         LogLevel = "Error"
     });
 }
Пример #19
0
 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);
 }
Пример #20
0
 /// <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);
     }
 }
Пример #21
0
        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();
        }
Пример #22
0
 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;
 }
Пример #23
0
 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;
 }
Пример #24
0
 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();
     }
 }
Пример #25
0
 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();
     }
 }
Пример #26
0
        /// <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());
        }
Пример #27
0
 /// <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
                 }
             });
         }
     }
 }
Пример #28
0
        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);
        }
Пример #29
0
        /// <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;
            }
        }
Пример #30
0
        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);
        }
Пример #31
0
        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);
        }