From b9cde075d6c7134bd628e371e0171aadd8aaf15a Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Fri, 17 May 2013 16:06:02 +0300 Subject: [PATCH] fixed bug with "Running Tasks" --- WebsitePanel/Database/update_db.sql | 44 + .../Data/DataProvider.cs | 808 +++++++++--------- .../Scheduling/SchedulerController.cs | 6 + .../Tasks/TaskManager.cs | 76 +- .../DesktopModules/WebsitePanel/Tasks.ascx | 10 +- .../DesktopModules/WebsitePanel/Tasks.ascx.cs | 30 +- .../WebsitePanel/Tasks.ascx.designer.cs | 44 +- 7 files changed, 584 insertions(+), 434 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 82413010..524433cf 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -813,4 +813,48 @@ GO UPDATE ScheduleTasks SET TaskType = RTRIM(TaskType) + '.Code' WHERE SUBSTRING(RTRIM(TaskType), LEN(RTRIM(TaskType)) - 3, 4) <> 'Code' +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetRunningSchedules') +DROP PROCEDURE GetRunningSchedules +GO + +CREATE PROCEDURE [dbo].[GetRunningSchedules] +( + @ActorID int +) +AS + +SELECT + S.ScheduleID, + S.TaskID, + ST.TaskType, + ST.RoleID, + S.PackageID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.LastFinish, + S.NextRun, + S.Enabled, + 1 AS StatusID, + S.PriorityID, + S.MaxExecutionTime, + S.WeekMonthDay, + ISNULL(0, (SELECT TOP 1 SeverityID FROM AuditLog WHERE ItemID = S.ScheduleID AND SourceName = 'SCHEDULER' ORDER BY StartDate DESC)) AS LastResult, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM Schedule AS S +INNER JOIN Packages AS P ON S.PackageID = P.PackageID +INNER JOIN ScheduleTasks AS ST ON S.TaskID = ST.TaskID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +WHERE (U.UserID = @ActorID OR U.OwnerID = @ActorID) AND S.LastRun > S.LastFinish GO \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs index 08efc8c9..bd948d2e 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs @@ -43,9 +43,9 @@ namespace WebsitePanel.EnterpriseServer /// public static class DataProvider { - + static string EnterpriseServerRegistryPath = "SOFTWARE\\WebsitePanel\\EnterpriseServer"; - + private static string ConnectionString { get @@ -77,35 +77,35 @@ namespace WebsitePanel.EnterpriseServer { return ""; } - } + } - #region System Settings + #region System Settings - public static IDataReader GetSystemSettings(string settingsName) - { - return SqlHelper.ExecuteReader( - ConnectionString, - CommandType.StoredProcedure, - "GetSystemSettings", - new SqlParameter("@SettingsName", settingsName) - ); - } + public static IDataReader GetSystemSettings(string settingsName) + { + return SqlHelper.ExecuteReader( + ConnectionString, + CommandType.StoredProcedure, + "GetSystemSettings", + new SqlParameter("@SettingsName", settingsName) + ); + } - public static void SetSystemSettings(string settingsName, string xml) - { - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "SetSystemSettings", - new SqlParameter("@SettingsName", settingsName), - new SqlParameter("@Xml", xml) - ); - } + public static void SetSystemSettings(string settingsName, string xml) + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "SetSystemSettings", + new SqlParameter("@SettingsName", settingsName), + new SqlParameter("@Xml", xml) + ); + } - #endregion + #endregion - #region Users - public static bool CheckUserExists(string username) + #region Users + public static bool CheckUserExists(string username) { SqlParameter prmExists = new SqlParameter("@Exists", SqlDbType.Bit); prmExists.Direction = ParameterDirection.Output; @@ -1296,11 +1296,11 @@ namespace WebsitePanel.EnterpriseServer public static IDataReader GetServiceItemTypes() { - return SqlHelper.ExecuteReader ( - ConnectionString, - CommandType.StoredProcedure, - "GetServiceItemTypes" - ); + return SqlHelper.ExecuteReader( + ConnectionString, + CommandType.StoredProcedure, + "GetServiceItemTypes" + ); } #endregion @@ -1851,6 +1851,13 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@taskId", taskId)); } + public static IDataReader GetRunningSchedules(int actorId) + { + return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "GetRunningSchedules", + new SqlParameter("@actorId", actorId)); + } + public static DataSet GetSchedules(int actorId, int packageId) { return SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, @@ -1901,17 +1908,17 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@scheduleId", scheduleId)); } - /// - /// Loads view configuration for the task with specified id. - /// - /// Task id which points to task for which view configuration will be loaded. - /// View configuration for the task with supplied id. - public static IDataReader GetScheduleTaskViewConfigurations(string taskId) - { - return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "GetScheduleTaskViewConfigurations", - new SqlParameter("@taskId", taskId)); - } + /// + /// Loads view configuration for the task with specified id. + /// + /// Task id which points to task for which view configuration will be loaded. + /// View configuration for the task with supplied id. + public static IDataReader GetScheduleTaskViewConfigurations(string taskId) + { + return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "GetScheduleTaskViewConfigurations", + new SqlParameter("@taskId", taskId)); + } public static int AddSchedule(int actorId, string taskId, int packageId, string scheduleName, string scheduleTypeId, int interval, @@ -1945,7 +1952,7 @@ namespace WebsitePanel.EnterpriseServer // read identity return Convert.ToInt32(prmId.Value); } - + public static void UpdateSchedule(int actorId, int scheduleId, string taskId, string scheduleName, string scheduleTypeId, int interval, DateTime fromTime, DateTime toTime, DateTime startTime, @@ -2149,7 +2156,7 @@ namespace WebsitePanel.EnterpriseServer } #endregion - #region Exchange Server + #region Exchange Server public static int AddExchangeAccount(int itemId, int accountType, string accountName, @@ -2181,42 +2188,42 @@ namespace WebsitePanel.EnterpriseServer } - public static void AddExchangeAccountEmailAddress(int accountId, string emailAddress) - { - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "AddExchangeAccountEmailAddress", - new SqlParameter("@AccountID", accountId), - new SqlParameter("@EmailAddress", emailAddress) - ); - } + public static void AddExchangeAccountEmailAddress(int accountId, string emailAddress) + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "AddExchangeAccountEmailAddress", + new SqlParameter("@AccountID", accountId), + new SqlParameter("@EmailAddress", emailAddress) + ); + } - public static void AddExchangeOrganization(int itemId, string organizationId) - { - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "AddExchangeOrganization", - new SqlParameter("@ItemID", itemId), - new SqlParameter("@OrganizationID", organizationId) - ); - } + public static void AddExchangeOrganization(int itemId, string organizationId) + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "AddExchangeOrganization", + new SqlParameter("@ItemID", itemId), + new SqlParameter("@OrganizationID", organizationId) + ); + } - public static void AddExchangeOrganizationDomain(int itemId, int domainId, bool isHost) - { - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "AddExchangeOrganizationDomain", - new SqlParameter("@ItemID", itemId), - new SqlParameter("@DomainID", domainId), - new SqlParameter("@IsHost", isHost) - ); - } + public static void AddExchangeOrganizationDomain(int itemId, int domainId, bool isHost) + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "AddExchangeOrganizationDomain", + new SqlParameter("@ItemID", itemId), + new SqlParameter("@DomainID", domainId), + new SqlParameter("@IsHost", isHost) + ); + } public static void ChangeExchangeAcceptedDomainType(int itemId, int domainId, int domainTypeId) - { + { SqlHelper.ExecuteNonQuery( ConnectionString, CommandType.StoredProcedure, @@ -2227,134 +2234,134 @@ namespace WebsitePanel.EnterpriseServer ); } - public static IDataReader GetExchangeOrganizationStatistics(int itemId) - { - return SqlHelper.ExecuteReader( - ConnectionString, - CommandType.StoredProcedure, - "GetExchangeOrganizationStatistics", - new SqlParameter("@ItemID", itemId) - ); - } + public static IDataReader GetExchangeOrganizationStatistics(int itemId) + { + return SqlHelper.ExecuteReader( + ConnectionString, + CommandType.StoredProcedure, + "GetExchangeOrganizationStatistics", + new SqlParameter("@ItemID", itemId) + ); + } public static void DeleteUserEmailAddresses(int accountId, string primaryAddress) { SqlHelper.ExecuteNonQuery( ConnectionString, CommandType.StoredProcedure, - "DeleteUserEmailAddresses", + "DeleteUserEmailAddresses", new SqlParameter("@AccountID", accountId), new SqlParameter("@PrimaryEmailAddress", primaryAddress) ); } - + public static void DeleteExchangeAccount(int itemId, int accountId) - { - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "DeleteExchangeAccount", - new SqlParameter("@ItemID", itemId), - new SqlParameter("@AccountID", accountId) - ); - } + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "DeleteExchangeAccount", + new SqlParameter("@ItemID", itemId), + new SqlParameter("@AccountID", accountId) + ); + } - public static void DeleteExchangeAccountEmailAddress(int accountId, string emailAddress) - { - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "DeleteExchangeAccountEmailAddress", - new SqlParameter("@AccountID", accountId), - new SqlParameter("@EmailAddress", emailAddress) - ); - } + public static void DeleteExchangeAccountEmailAddress(int accountId, string emailAddress) + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "DeleteExchangeAccountEmailAddress", + new SqlParameter("@AccountID", accountId), + new SqlParameter("@EmailAddress", emailAddress) + ); + } - public static void DeleteExchangeOrganization(int itemId) - { - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "DeleteExchangeOrganization", - new SqlParameter("@ItemID", itemId) - ); - } + public static void DeleteExchangeOrganization(int itemId) + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "DeleteExchangeOrganization", + new SqlParameter("@ItemID", itemId) + ); + } - public static void DeleteExchangeOrganizationDomain(int itemId, int domainId) - { - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "DeleteExchangeOrganizationDomain", - new SqlParameter("@ItemId", itemId), - new SqlParameter("@DomainID", domainId) - ); - } + public static void DeleteExchangeOrganizationDomain(int itemId, int domainId) + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "DeleteExchangeOrganizationDomain", + new SqlParameter("@ItemId", itemId), + new SqlParameter("@DomainID", domainId) + ); + } - public static bool ExchangeAccountEmailAddressExists(string emailAddress) - { - SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit); - outParam.Direction = ParameterDirection.Output; + public static bool ExchangeAccountEmailAddressExists(string emailAddress) + { + SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit); + outParam.Direction = ParameterDirection.Output; - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "ExchangeAccountEmailAddressExists", - new SqlParameter("@EmailAddress", emailAddress), - outParam - ); + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "ExchangeAccountEmailAddressExists", + new SqlParameter("@EmailAddress", emailAddress), + outParam + ); - return Convert.ToBoolean(outParam.Value); - } + return Convert.ToBoolean(outParam.Value); + } public static bool ExchangeOrganizationDomainExists(int domainId) - { - SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit); - outParam.Direction = ParameterDirection.Output; + { + SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit); + outParam.Direction = ParameterDirection.Output; - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "ExchangeOrganizationDomainExists", - new SqlParameter("@DomainID", domainId), - outParam - ); + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "ExchangeOrganizationDomainExists", + new SqlParameter("@DomainID", domainId), + outParam + ); - return Convert.ToBoolean(outParam.Value); - } + return Convert.ToBoolean(outParam.Value); + } - public static bool ExchangeOrganizationExists(string organizationId) - { - SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit); - outParam.Direction = ParameterDirection.Output; + public static bool ExchangeOrganizationExists(string organizationId) + { + SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit); + outParam.Direction = ParameterDirection.Output; - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "ExchangeOrganizationExists", - new SqlParameter("@OrganizationID", organizationId), - outParam - ); + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "ExchangeOrganizationExists", + new SqlParameter("@OrganizationID", organizationId), + outParam + ); - return Convert.ToBoolean(outParam.Value); - } + return Convert.ToBoolean(outParam.Value); + } - public static bool ExchangeAccountExists(string accountName) - { - SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit); - outParam.Direction = ParameterDirection.Output; + public static bool ExchangeAccountExists(string accountName) + { + SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit); + outParam.Direction = ParameterDirection.Output; - SqlHelper.ExecuteNonQuery( - ConnectionString, - CommandType.StoredProcedure, - "ExchangeAccountExists", - new SqlParameter("@AccountName", accountName), - outParam - ); + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "ExchangeAccountExists", + new SqlParameter("@AccountName", accountName), + outParam + ); - return Convert.ToBoolean(outParam.Value); - } + return Convert.ToBoolean(outParam.Value); + } public static void UpdateExchangeAccount(int accountId, string accountName, ExchangeAccountType accountType, string displayName, string primaryEmailAddress, bool mailEnabledPublicFolder, @@ -2388,16 +2395,16 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@UserPrincipalName", userPrincipalName)); } - public static IDataReader GetExchangeAccount(int itemId, int accountId) - { - return SqlHelper.ExecuteReader( - ConnectionString, - CommandType.StoredProcedure, - "GetExchangeAccount", - new SqlParameter("@ItemID", itemId), - new SqlParameter("@AccountID", accountId) - ); - } + public static IDataReader GetExchangeAccount(int itemId, int accountId) + { + return SqlHelper.ExecuteReader( + ConnectionString, + CommandType.StoredProcedure, + "GetExchangeAccount", + new SqlParameter("@ItemID", itemId), + new SqlParameter("@AccountID", accountId) + ); + } public static IDataReader GetExchangeAccountByAccountName(int itemId, string accountName) { @@ -2422,37 +2429,37 @@ namespace WebsitePanel.EnterpriseServer } - public static IDataReader GetExchangeAccountEmailAddresses(int accountId) - { - return SqlHelper.ExecuteReader( - ConnectionString, - CommandType.StoredProcedure, - "GetExchangeAccountEmailAddresses", - new SqlParameter("@AccountID", accountId) - ); - } + public static IDataReader GetExchangeAccountEmailAddresses(int accountId) + { + return SqlHelper.ExecuteReader( + ConnectionString, + CommandType.StoredProcedure, + "GetExchangeAccountEmailAddresses", + new SqlParameter("@AccountID", accountId) + ); + } + + public static IDataReader GetExchangeOrganizationDomains(int itemId) + { + return SqlHelper.ExecuteReader( + ConnectionString, + CommandType.StoredProcedure, + "GetExchangeOrganizationDomains", + new SqlParameter("@ItemID", itemId) + ); + } - public static IDataReader GetExchangeOrganizationDomains(int itemId) - { - return SqlHelper.ExecuteReader( - ConnectionString, - CommandType.StoredProcedure, - "GetExchangeOrganizationDomains", - new SqlParameter("@ItemID", itemId) - ); - } - public static IDataReader GetExchangeAccounts(int itemId, int accountType) - { - return SqlHelper.ExecuteReader( - ConnectionString, - CommandType.StoredProcedure, - "GetExchangeAccounts", - new SqlParameter("@ItemID", itemId), - new SqlParameter("@AccountType", accountType) - ); - } + { + return SqlHelper.ExecuteReader( + ConnectionString, + CommandType.StoredProcedure, + "GetExchangeAccounts", + new SqlParameter("@ItemID", itemId), + new SqlParameter("@AccountType", accountType) + ); + } public static IDataReader GetExchangeMailboxes(int itemId) { @@ -2464,9 +2471,9 @@ namespace WebsitePanel.EnterpriseServer ); } - public static DataSet GetExchangeAccountsPaged(int actorId, int itemId, string accountTypes, + public static DataSet GetExchangeAccountsPaged(int actorId, int itemId, string accountTypes, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) - { + { // check input parameters string[] types = accountTypes.Split(','); for (int i = 0; i < types.Length; i++) @@ -2483,41 +2490,41 @@ namespace WebsitePanel.EnterpriseServer string searchTypes = String.Join(",", types); - return SqlHelper.ExecuteDataset( - ConnectionString, - CommandType.StoredProcedure, - "GetExchangeAccountsPaged", - new SqlParameter("@ActorID", actorId), - new SqlParameter("@ItemID", itemId), + return SqlHelper.ExecuteDataset( + ConnectionString, + CommandType.StoredProcedure, + "GetExchangeAccountsPaged", + new SqlParameter("@ActorID", actorId), + new SqlParameter("@ItemID", itemId), new SqlParameter("@AccountTypes", searchTypes), - new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)), - new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)), - new SqlParameter("@SortColumn", VerifyColumnName(sortColumn)), - new SqlParameter("@StartRow", startRow), - new SqlParameter("@MaximumRows", maximumRows) - ); - } + new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)), + new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)), + new SqlParameter("@SortColumn", VerifyColumnName(sortColumn)), + new SqlParameter("@StartRow", startRow), + new SqlParameter("@MaximumRows", maximumRows) + ); + } - public static IDataReader SearchExchangeAccounts(int actorId, int itemId, bool includeMailboxes, + public static IDataReader SearchExchangeAccounts(int actorId, int itemId, bool includeMailboxes, bool includeContacts, bool includeDistributionLists, bool includeRooms, bool includeEquipment, string filterColumn, string filterValue, string sortColumn) - { - return SqlHelper.ExecuteReader( - ConnectionString, - CommandType.StoredProcedure, - "SearchExchangeAccounts", - new SqlParameter("@ActorID", actorId), - new SqlParameter("@ItemID", itemId), - new SqlParameter("@IncludeMailboxes", includeMailboxes), - new SqlParameter("@IncludeContacts", includeContacts), - new SqlParameter("@IncludeDistributionLists", includeDistributionLists), + { + return SqlHelper.ExecuteReader( + ConnectionString, + CommandType.StoredProcedure, + "SearchExchangeAccounts", + new SqlParameter("@ActorID", actorId), + new SqlParameter("@ItemID", itemId), + new SqlParameter("@IncludeMailboxes", includeMailboxes), + new SqlParameter("@IncludeContacts", includeContacts), + new SqlParameter("@IncludeDistributionLists", includeDistributionLists), new SqlParameter("@IncludeRooms", includeRooms), new SqlParameter("@IncludeEquipment", includeEquipment), - new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)), - new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)), - new SqlParameter("@SortColumn", VerifyColumnName(sortColumn)) - ); - } + new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)), + new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)), + new SqlParameter("@SortColumn", VerifyColumnName(sortColumn)) + ); + } public static IDataReader SearchExchangeAccount(int actorId, int accountType, string primaryEmailAddress) { @@ -2531,7 +2538,7 @@ namespace WebsitePanel.EnterpriseServer ); } - #endregion + #endregion #region Exchange Mailbox Plans public static int AddExchangeMailboxPlan(int itemID, string mailboxPlan, bool enableActiveSync, bool enableIMAP, bool enableMAPI, bool enableOWA, bool enablePOP, @@ -2565,11 +2572,11 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@ProhibitSendReceivePct", prohibitSendReceivePct), new SqlParameter("@HideFromAddressBook", hideFromAddressBook), new SqlParameter("@MailboxPlanType", mailboxPlanType), - new SqlParameter("@AllowLitigationHold",enabledLitigationHold), + new SqlParameter("@AllowLitigationHold", enabledLitigationHold), new SqlParameter("@RecoverableItemsWarningPct", recoverabelItemsWarning), - new SqlParameter("@RecoverableItemsSpace",recoverabelItemsSpace), - new SqlParameter("@LitigationHoldUrl",litigationHoldUrl), - new SqlParameter("@LitigationHoldMsg",litigationHoldMsg) + new SqlParameter("@RecoverableItemsSpace", recoverabelItemsSpace), + new SqlParameter("@LitigationHoldUrl", litigationHoldUrl), + new SqlParameter("@LitigationHoldMsg", litigationHoldMsg) ); return Convert.ToInt32(outParam.Value); @@ -2607,8 +2614,8 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@AllowLitigationHold", enabledLitigationHold), new SqlParameter("@RecoverableItemsWarningPct", recoverabelItemsWarning), new SqlParameter("@RecoverableItemsSpace", recoverabelItemsSpace), - new SqlParameter("@LitigationHoldUrl",litigationHoldUrl), - new SqlParameter("@LitigationHoldMsg",litigationHoldMsg) + new SqlParameter("@LitigationHoldUrl", litigationHoldUrl), + new SqlParameter("@LitigationHoldMsg", litigationHoldMsg) ); } @@ -2688,16 +2695,16 @@ namespace WebsitePanel.EnterpriseServer { SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, "DeleteOrganizationUsers", new SqlParameter("@ItemID", itemId)); } - + public static int GetItemIdByOrganizationId(string id) - { - object obj =SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "GetItemIdByOrganizationId", + { + object obj = SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "GetItemIdByOrganizationId", new SqlParameter("@OrganizationId", id)); return (obj == null || DBNull.Value == obj) ? 0 : (int)obj; - + } - + public static IDataReader GetOrganizationStatistics(int itemId) { return SqlHelper.ExecuteReader( @@ -2706,7 +2713,7 @@ namespace WebsitePanel.EnterpriseServer "GetOrganizationStatistics", new SqlParameter("@ItemID", itemId) ); - } + } public static IDataReader SearchOrganizationAccounts(int actorId, int itemId, string filterColumn, string filterValue, string sortColumn, bool includeMailboxes) @@ -2727,7 +2734,7 @@ namespace WebsitePanel.EnterpriseServer #endregion #region CRM - + public static int GetCRMUsersCount(int itemId, string name, string email) { SqlParameter[] sqlParams = new SqlParameter[] @@ -2737,19 +2744,19 @@ namespace WebsitePanel.EnterpriseServer GetFilterSqlParam("@Email", email), }; - return (int) SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "GetCRMUsersCount", sqlParams); + return (int)SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "GetCRMUsersCount", sqlParams); } - + private static SqlParameter GetFilterSqlParam(string paramName, string value) { if (string.IsNullOrEmpty(value)) return new SqlParameter(paramName, DBNull.Value); - return new SqlParameter(paramName, value); + return new SqlParameter(paramName, value); } - public static IDataReader GetCrmUsers(int itemId, string sortColumn, string sortDirection, string name, string email, int startRow, int count ) + public static IDataReader GetCrmUsers(int itemId, string sortColumn, string sortDirection, string name, string email, int startRow, int count) { SqlParameter[] sqlParams = new SqlParameter[] { @@ -2762,7 +2769,7 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("Count", count) }; - + return SqlHelper.ExecuteReader( ConnectionString, CommandType.StoredProcedure, @@ -2772,7 +2779,7 @@ namespace WebsitePanel.EnterpriseServer public static IDataReader GetCRMOrganizationUsers(int itemId) { return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, "GetCRMOrganizationUsers", - new SqlParameter[] {new SqlParameter("@ItemID", itemId)}); + new SqlParameter[] { new SqlParameter("@ItemID", itemId) }); } public static void CreateCRMUser(int itemId, Guid crmId, Guid businessUnitId) @@ -2784,7 +2791,7 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@CrmUserID", crmId), new SqlParameter("@BusinessUnitId", businessUnitId) }); - + } @@ -2796,14 +2803,13 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@AccountID", itemId) }); return reader; - + } public static int GetCrmUserCount(int itemId) { - return (int)SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "GetOrganizationCRMUserCount", - new SqlParameter[] - { new SqlParameter("@ItemID",itemId)}); + return (int)SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "GetOrganizationCRMUserCount", + new SqlParameter[] { new SqlParameter("@ItemID", itemId) }); } public static void DeleteCrmOrganization(int organizationId) @@ -2811,8 +2817,8 @@ namespace WebsitePanel.EnterpriseServer SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "DeleteCRMOrganization", new SqlParameter[] { new SqlParameter("@ItemID", organizationId) }); } - - #endregion + + #endregion #region VPS - Virtual Private Servers @@ -2833,8 +2839,8 @@ namespace WebsitePanel.EnterpriseServer } #endregion - public static IDataReader GetVirtualMachinesForPCPaged(int actorId, int packageId, string filterColumn, string filterValue, - string sortColumn, int startRow, int maximumRows, bool recursive) + public static IDataReader GetVirtualMachinesForPCPaged(int actorId, int packageId, string filterColumn, string filterValue, + string sortColumn, int startRow, int maximumRows, bool recursive) { IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, "GetVirtualMachinesPagedForPC", @@ -3030,7 +3036,7 @@ namespace WebsitePanel.EnterpriseServer #endregion #region BlackBerry - + public static void AddBlackBerryUser(int accountId) { SqlHelper.ExecuteNonQuery(ConnectionString, @@ -3041,8 +3047,8 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@AccountID", accountId) }); } - - + + public static bool CheckBlackBerryUserExists(int accountId) { int res = (int)SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "CheckBlackBerryUserExists", @@ -3094,7 +3100,7 @@ namespace WebsitePanel.EnterpriseServer { new SqlParameter("@AccountID", accountId) }); - + } #endregion @@ -3181,142 +3187,142 @@ namespace WebsitePanel.EnterpriseServer #endregion - #region SSL - public static int AddSSLRequest(int actorId, int packageId, int siteID, int userID, string friendlyname, string hostname, string csr, int csrLength, string distinguishedName, bool isRenewal, int previousID) - { - SqlParameter prmId = new SqlParameter("@SSLID", SqlDbType.Int); - prmId.Direction = ParameterDirection.Output; - SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "AddSSLRequest", prmId, - new SqlParameter("@ActorId", actorId), - new SqlParameter("@PackageId", packageId), - new SqlParameter("@UserID", userID), - new SqlParameter("@WebSiteID", siteID), - new SqlParameter("@FriendlyName", friendlyname), - new SqlParameter("@HostName", hostname), - new SqlParameter("@CSR", csr), - new SqlParameter("@CSRLength", csrLength), - new SqlParameter("@DistinguishedName", distinguishedName), - new SqlParameter("@IsRenewal", isRenewal), - new SqlParameter("@PreviousId", previousID) - ); - return Convert.ToInt32(prmId.Value); + #region SSL + public static int AddSSLRequest(int actorId, int packageId, int siteID, int userID, string friendlyname, string hostname, string csr, int csrLength, string distinguishedName, bool isRenewal, int previousID) + { + SqlParameter prmId = new SqlParameter("@SSLID", SqlDbType.Int); + prmId.Direction = ParameterDirection.Output; + SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "AddSSLRequest", prmId, + new SqlParameter("@ActorId", actorId), + new SqlParameter("@PackageId", packageId), + new SqlParameter("@UserID", userID), + new SqlParameter("@WebSiteID", siteID), + new SqlParameter("@FriendlyName", friendlyname), + new SqlParameter("@HostName", hostname), + new SqlParameter("@CSR", csr), + new SqlParameter("@CSRLength", csrLength), + new SqlParameter("@DistinguishedName", distinguishedName), + new SqlParameter("@IsRenewal", isRenewal), + new SqlParameter("@PreviousId", previousID) + ); + return Convert.ToInt32(prmId.Value); - } + } - public static void CompleteSSLRequest(int actorId, int packageId, int id, string certificate, string distinguishedName, string serialNumber, byte[] hash, DateTime validFrom, DateTime expiryDate) - { - SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "CompleteSSLRequest", - new SqlParameter("@ActorID", actorId), - new SqlParameter("@PackageID", packageId), - new SqlParameter("@ID", id), - new SqlParameter("@DistinguishedName", distinguishedName), - new SqlParameter("@Certificate", certificate), - new SqlParameter("@SerialNumber", serialNumber), - new SqlParameter("@Hash", Convert.ToBase64String(hash)), - new SqlParameter("@ValidFrom", validFrom), - new SqlParameter("@ExpiryDate", expiryDate)); + public static void CompleteSSLRequest(int actorId, int packageId, int id, string certificate, string distinguishedName, string serialNumber, byte[] hash, DateTime validFrom, DateTime expiryDate) + { + SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "CompleteSSLRequest", + new SqlParameter("@ActorID", actorId), + new SqlParameter("@PackageID", packageId), + new SqlParameter("@ID", id), + new SqlParameter("@DistinguishedName", distinguishedName), + new SqlParameter("@Certificate", certificate), + new SqlParameter("@SerialNumber", serialNumber), + new SqlParameter("@Hash", Convert.ToBase64String(hash)), + new SqlParameter("@ValidFrom", validFrom), + new SqlParameter("@ExpiryDate", expiryDate)); - } + } - public static void AddPFX(int actorId, int packageId, int siteID, int userID, string hostname, string friendlyName, string distinguishedName, int csrLength, string serialNumber, DateTime validFrom, DateTime expiryDate) - { - SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "AddPFX", - new SqlParameter("@ActorId", actorId), - new SqlParameter("@PackageId", packageId), - new SqlParameter("@UserID", userID), - new SqlParameter("@WebSiteID", siteID), - new SqlParameter("@FriendlyName", friendlyName), - new SqlParameter("@HostName", hostname), - new SqlParameter("@CSRLength", csrLength), - new SqlParameter("@DistinguishedName", distinguishedName), - new SqlParameter("@SerialNumber", serialNumber), - new SqlParameter("@ValidFrom", validFrom), - new SqlParameter("@ExpiryDate", expiryDate)); + public static void AddPFX(int actorId, int packageId, int siteID, int userID, string hostname, string friendlyName, string distinguishedName, int csrLength, string serialNumber, DateTime validFrom, DateTime expiryDate) + { + SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "AddPFX", + new SqlParameter("@ActorId", actorId), + new SqlParameter("@PackageId", packageId), + new SqlParameter("@UserID", userID), + new SqlParameter("@WebSiteID", siteID), + new SqlParameter("@FriendlyName", friendlyName), + new SqlParameter("@HostName", hostname), + new SqlParameter("@CSRLength", csrLength), + new SqlParameter("@DistinguishedName", distinguishedName), + new SqlParameter("@SerialNumber", serialNumber), + new SqlParameter("@ValidFrom", validFrom), + new SqlParameter("@ExpiryDate", expiryDate)); - } + } - public static DataSet GetSSL(int actorId, int packageId, int id) - { - return SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "GetSSL", - new SqlParameter("@SSLID", id)); + public static DataSet GetSSL(int actorId, int packageId, int id) + { + return SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "GetSSL", + new SqlParameter("@SSLID", id)); - } + } - public static DataSet GetCertificatesForSite(int actorId, int packageId, int siteId) - { - return SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "GetCertificatesForSite", - new SqlParameter("@ActorId", actorId), - new SqlParameter("@PackageId", packageId), - new SqlParameter("@websiteid", siteId)); + public static DataSet GetCertificatesForSite(int actorId, int packageId, int siteId) + { + return SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "GetCertificatesForSite", + new SqlParameter("@ActorId", actorId), + new SqlParameter("@PackageId", packageId), + new SqlParameter("@websiteid", siteId)); - } + } - public static DataSet GetPendingCertificates(int actorId, int packageId, int id, bool recursive) - { - return SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "GetPendingSSLForWebsite", - new SqlParameter("@ActorId", actorId), - new SqlParameter("@PackageId", packageId), - new SqlParameter("@websiteid", id), - new SqlParameter("@Recursive", recursive)); + public static DataSet GetPendingCertificates(int actorId, int packageId, int id, bool recursive) + { + return SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "GetPendingSSLForWebsite", + new SqlParameter("@ActorId", actorId), + new SqlParameter("@PackageId", packageId), + new SqlParameter("@websiteid", id), + new SqlParameter("@Recursive", recursive)); - } + } - public static IDataReader GetSSLCertificateByID(int actorId, int id) - { - return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "GetSSLCertificateByID", - new SqlParameter("@ActorId", actorId), - new SqlParameter("@ID", id)); - } + public static IDataReader GetSSLCertificateByID(int actorId, int id) + { + return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "GetSSLCertificateByID", + new SqlParameter("@ActorId", actorId), + new SqlParameter("@ID", id)); + } - public static int CheckSSL(int siteID, bool renewal) - { - SqlParameter prmId = new SqlParameter("@Result", SqlDbType.Int); - prmId.Direction = ParameterDirection.Output; + public static int CheckSSL(int siteID, bool renewal) + { + SqlParameter prmId = new SqlParameter("@Result", SqlDbType.Int); + prmId.Direction = ParameterDirection.Output; - SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "CheckSSL", - prmId, - new SqlParameter("@siteID", siteID), - new SqlParameter("@Renewal", renewal)); + SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "CheckSSL", + prmId, + new SqlParameter("@siteID", siteID), + new SqlParameter("@Renewal", renewal)); - return Convert.ToInt32(prmId.Value); - } + return Convert.ToInt32(prmId.Value); + } - public static IDataReader GetSiteCert(int actorId, int siteID) - { - return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "GetSSLCertificateByID", - new SqlParameter("@ActorId", actorId), - new SqlParameter("@ID", siteID)); - } + public static IDataReader GetSiteCert(int actorId, int siteID) + { + return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "GetSSLCertificateByID", + new SqlParameter("@ActorId", actorId), + new SqlParameter("@ID", siteID)); + } - public static void DeleteCertificate(int actorId, int packageId, int id) - { - SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "DeleteCertificate", - new SqlParameter("@ActorID", actorId), - new SqlParameter("@PackageID", packageId), - new SqlParameter("@id", id)); - } + public static void DeleteCertificate(int actorId, int packageId, int id) + { + SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "DeleteCertificate", + new SqlParameter("@ActorID", actorId), + new SqlParameter("@PackageID", packageId), + new SqlParameter("@id", id)); + } - public static bool CheckSSLExistsForWebsite(int siteId) - { - SqlParameter prmId = new SqlParameter("@Result", SqlDbType.Bit); - prmId.Direction = ParameterDirection.Output; - SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "CheckSSLExistsForWebsite", prmId, - new SqlParameter("@siteID", siteId), - new SqlParameter("@SerialNumber", "")); - return Convert.ToBoolean(prmId.Value); - } - #endregion + public static bool CheckSSLExistsForWebsite(int siteId) + { + SqlParameter prmId = new SqlParameter("@Result", SqlDbType.Bit); + prmId.Direction = ParameterDirection.Output; + SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "CheckSSLExistsForWebsite", prmId, + new SqlParameter("@siteID", siteId), + new SqlParameter("@SerialNumber", "")); + return Convert.ToBoolean(prmId.Value); + } + #endregion #region Lync @@ -3473,7 +3479,7 @@ namespace WebsitePanel.EnterpriseServer new SqlParameter("@IsDefault", lyncUserPlan.IsDefault) ); } - + public static void DeleteLyncUserPlan(int lyncUserPlanId) { SqlHelper.ExecuteNonQuery( @@ -3591,11 +3597,11 @@ namespace WebsitePanel.EnterpriseServer FROM Providers WHERE ProviderName = @ProviderName", new SqlParameter("@ProviderName", providerName)); - + reader.Read(); - providerId = (int) reader["ProviderID"]; - groupId = (int) reader["GroupID"]; + providerId = (int)reader["ProviderID"]; + groupId = (int)reader["GroupID"]; } @@ -3666,7 +3672,7 @@ namespace WebsitePanel.EnterpriseServer GetHeliconZooProviderAndGroup("HeliconZoo", out providerId, out groupId); - IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, + IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, @"SELECT HostingPlanQuotas.QuotaID, Quotas.QuotaName, Quotas.QuotaDescription FROM HostingPlanQuotas INNER JOIN Packages ON HostingPlanQuotas.PlanID = Packages.PlanID diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Scheduling/SchedulerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Scheduling/SchedulerController.cs index 65d8b175..58bab08f 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Scheduling/SchedulerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Scheduling/SchedulerController.cs @@ -54,6 +54,12 @@ namespace WebsitePanel.EnterpriseServer DataProvider.GetScheduleTask(SecurityContext.User.UserId, taskId)); } + public static List GetRunningSchedules() + { + return ObjectUtils.CreateListFromDataReader( + DataProvider.GetRunningSchedules(SecurityContext.User.UserId)); + } + public static DataSet GetSchedules(int packageId) { DataSet ds = DataProvider.GetSchedules(SecurityContext.User.UserId, packageId); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Tasks/TaskManager.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Tasks/TaskManager.cs index 5bdfa7c7..9772aad5 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Tasks/TaskManager.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Tasks/TaskManager.cs @@ -134,13 +134,13 @@ namespace WebsitePanel.EnterpriseServer WriteLogRecord(0, parameterName + ": " + val, null, null); } - public static void Write(string text, params string[] textParameters) + public static void Write(string text, params string[] textParameters) { // INFO WriteLogRecord(0, text, null, textParameters); } - public static void WriteWarning(string text, params string[] textParameters) + public static void WriteWarning(string text, params string[] textParameters) { // WARNING WriteLogRecord(1, text, null, textParameters); @@ -168,7 +168,7 @@ namespace WebsitePanel.EnterpriseServer WriteLogRecord(2, text, ex.Message + "\n" + ex.StackTrace, prms); } - public static void WriteError(string text, params string[] textParameters) + public static void WriteError(string text, params string[] textParameters) { // ERROR WriteLogRecord(2, text, null, textParameters); @@ -195,8 +195,8 @@ namespace WebsitePanel.EnterpriseServer public static void CompleteTask() { - if (TasksStack.Count == 0) - return; + if (TasksStack.Count == 0) + return; // call event handler CallTaskEventHandler(TopTask, true); @@ -241,7 +241,7 @@ namespace WebsitePanel.EnterpriseServer XmlWriter writer = new XmlTextWriter(sw); writer.WriteStartElement("log"); - + // parameters writer.WriteStartElement("parameters"); foreach (string name in task.Parameters.Keys) @@ -320,7 +320,21 @@ namespace WebsitePanel.EnterpriseServer // remove tasks foreach (string taskId in completedTasks) + { + BackgroundTask task = GetTask(taskId); + if (task != null) + { + // update last finish time + SchedulerJob schedule = SchedulerController.GetScheduleComplete(task.ItemId); + if (schedule != null) + { + schedule.ScheduleInfo.LastFinish = DateTime.Now; + SchedulerController.UpdateSchedule(schedule.ScheduleInfo); + } + } + tasks.Remove(taskId); + } } public static int PackageId @@ -449,6 +463,14 @@ namespace WebsitePanel.EnterpriseServer // nope } + // update last finish time + SchedulerJob schedule = SchedulerController.GetScheduleComplete(task.ItemId); + if (schedule != null) + { + schedule.ScheduleInfo.LastFinish = DateTime.Now; + SchedulerController.UpdateSchedule(schedule.ScheduleInfo); + } + // remove it from stack tasks.Remove(taskId); } @@ -467,17 +489,37 @@ namespace WebsitePanel.EnterpriseServer { List list = new List(); - // try to get user first - UserInfo user = UserController.GetUser(userId); - if (user == null) - return list; // prohibited user + int effectiveUserId = SecurityContext.User.IsPeer ? SecurityContext.User.OwnerId : SecurityContext.User.UserId; + Dictionary scheduledTasks = GetScheduledTasks(); - // get user tasks - foreach (BackgroundTask task in tasks.Values) + List scheduleList = SchedulerController.GetRunningSchedules(); + + foreach (var scheduleInfo in scheduleList) { - if(task.EffectiveUserId == userId && !task.Completed) - list.Add(task); + if (effectiveUserId == userId && scheduleInfo.LastRun > scheduleInfo.LastFinish) + { + if (scheduledTasks.ContainsKey(scheduleInfo.ScheduleId) && !scheduledTasks[scheduleInfo.ScheduleId].Completed) + { + list.Add(scheduledTasks[scheduleInfo.ScheduleId]); + } + else + { + list.Add(new BackgroundTask + { + TaskId = "", + ItemId = scheduleInfo.ScheduleId, + StartDate = scheduleInfo.LastRun, + TaskName = scheduleInfo.ScheduleName, + UserId = SecurityContext.User.UserId, + Source = "RUN_SCHEDULE", + Severity = 0, + ItemName = scheduleInfo.ScheduleName, + Completed = false + }); + } + } } + return list; } @@ -508,7 +550,7 @@ namespace WebsitePanel.EnterpriseServer string[] taskHandlers = GetTaskEventHandlers(task.Source, task.TaskName); if (taskHandlers != null) { - foreach(string taskHandler in taskHandlers) + foreach (string taskHandler in taskHandlers) { try { @@ -650,8 +692,8 @@ namespace WebsitePanel.EnterpriseServer res.IsSuccess = true; return res; } - - #endregion + + #endregion } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx index 30b3a522..8acbbbc0 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx @@ -13,8 +13,9 @@ - + + @@ -26,15 +27,16 @@ -
+ -
+ + In Progress
+ CausesValidation="false" Text="Stop" OnClientClick="return confirm('Do you really want to terminate this task?');" Visible="false"> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx.cs index a1933493..c8465f60 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx.cs @@ -66,13 +66,34 @@ namespace WebsitePanel.Portal // find controls HyperLink lnkTaskName = (HyperLink)e.Row.FindControl("lnkTaskName"); + Literal litTaskName = (Literal)e.Row.FindControl("litTaskName"); Literal litTaskDuration = (Literal)e.Row.FindControl("litTaskDuration"); + Panel pnlProgressBarContainer = (Panel)e.Row.FindControl("pnlProgressBarContainer"); Panel pnlProgressIndicator = (Panel)e.Row.FindControl("pnlProgressIndicator"); + Literal litProgressIndicator = (Literal)e.Row.FindControl("litProgressIndicator"); LinkButton cmdStop = (LinkButton)e.Row.FindControl("cmdStop"); - // bind controls - lnkTaskName.Text = GetAuditLogTaskName(task.Source, task.TaskName); - lnkTaskName.NavigateUrl = EditUrl("TaskID", task.TaskId, "view_details"); + if (String.IsNullOrEmpty(task.TaskId)) + { + litTaskName.Visible = true; + litProgressIndicator.Visible = true; + + // bind controls + litTaskName.Text = GetAuditLogTaskName(task.Source, task.TaskName); + } + else + { + lnkTaskName.Visible = true; + pnlProgressBarContainer.Visible = true; + cmdStop.Visible = true; + + // bind controls + lnkTaskName.NavigateUrl = EditUrl("TaskID", task.TaskId, "view_details"); + lnkTaskName.Text = GetAuditLogTaskName(task.Source, task.TaskName); + + // stop button + cmdStop.CommandArgument = task.TaskId; + } // duration TimeSpan duration = (TimeSpan)(DateTime.Now - task.StartDate); @@ -86,9 +107,6 @@ namespace WebsitePanel.Portal if (task.IndicatorMaximum > 0) percent = task.IndicatorCurrent * 100 / task.IndicatorMaximum; pnlProgressIndicator.Width = Unit.Percentage(percent); - - // stop button - cmdStop.CommandArgument = task.TaskId; } protected void gvTasks_RowCommand(object sender, GridViewCommandEventArgs e) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx.designer.cs index 4bc94460..b4454382 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Tasks.ascx.designer.cs @@ -1,19 +1,51 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.42 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------ namespace WebsitePanel.Portal { + public partial class Tasks { - protected System.Web.UI.Timer tasksTimer; - protected System.Web.UI.UpdatePanel tasksUpdatePanel; - protected System.Web.UI.WebControls.GridView gvTasks; - protected System.Web.UI.WebControls.ObjectDataSource odsTasks; + + /// + /// tasksTimer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.Timer tasksTimer; + + /// + /// tasksUpdatePanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.UpdatePanel tasksUpdatePanel; + + /// + /// gvTasks control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.GridView gvTasks; + + /// + /// odsTasks control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ObjectDataSource odsTasks; } }