private void RecoverCompanies(int orgID, LoginUser loginUser) { Organizations badCompanies = new Organizations(GetCorrupteLoginUser()); badCompanies.LoadByParentID(orgID, false); Organizations goodCompanies = new Organizations(loginUser); goodCompanies.LoadByParentID(orgID, false); foreach (Organization badCompany in badCompanies) { try { Organization goodCompany = goodCompanies.FindByName(badCompany.Name); if (goodCompany == null) { goodCompany = (new Organizations(loginUser)).AddNewOrganization(); goodCompany.CopyRowData(badCompany); goodCompany.DateCreated = badCompany.DateCreatedUtc; goodCompany.DateModified = badCompany.DateModifiedUtc; goodCompany.ImportID = _importID; goodCompany.ParentID = orgID; goodCompany.Collection.Save(); } } catch (Exception ex) { _exceptionOcurred = true; ExceptionLogs.LogException(GetCorrupteLoginUser(), ex, "recover"); } } }
private DataTable GetReportTableAllForExports(string sortField, bool isDesc, bool useUserFilter, bool includeHiddenFields) { SqlCommand command = GetExportsSqlCommand(ref sortField, ref isDesc, useUserFilter, includeHiddenFields); _report.LastSqlExecuted = DataUtils.GetCommandTextSql(command); _report.Collection.Save(); BaseCollection.FixCommandParameters(command); DataTable table = new DataTable(); using (SqlConnection connection = new SqlConnection(_loginUser.ConnectionString)) { connection.Open(); command.Connection = connection; using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { try { adapter.Fill(table); } catch (Exception ex) { ExceptionLogs.LogException(_loginUser, ex, "Report Data"); throw; } } connection.Close(); } return(table); }
private static void SyncOrg(HttpContext context) { /* * payload.OrganizationID = orgID; * payload.Company = company; * payload.PodName = SystemSettings.GetPodName(); * payload.Key = "81f4060c-2166-48c3-a126-b12c94f1fd9d"; */ try { dynamic data = JObject.Parse(ReadJsonData(context)); if (data.Key != "81f4060c-2166-48c3-a126-b12c94f1fd9d") { return; } LoginUser loginUser = LoginUser.Anonymous; Organizations orgs = new Organizations(loginUser); orgs.LoadByImportID(data.PodName.ToString() + "-" + data.OrganizationID.ToString(), 1078); Organization tsOrg = orgs[0]; tsOrg.Name = data.Company; tsOrg.Collection.Save(); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "SyncOrg"); throw; } }
public override void Run() { try { if (DateTime.Now.Subtract(_lastDLSAdjustment).TotalMinutes > 60 && DateTime.Now.Minute > 2 && DateTime.Now.Minute < 30) { Logs.WriteEvent("Update business hours for DSL"); _lastDLSAdjustment = DateTime.Now; UpdateBusinessHoursForDLSFix(); } } catch (Exception) { } try { foreach (TicketSlaInfo ticket in GetAllUnnotifiedAndExpiredSla(LoginUser)) { if (IsStopped) { break; } Logs.WriteEventFormat("Attempting to process: {0}", ticket.TicketId); ProcessTicket(ticket); System.Threading.Thread.Sleep(0); } } catch (Exception ex) { ExceptionLogs.LogException(LoginUser, ex, "SLA Processor", "Sync"); } }
private static void SyncUser(HttpContext context) { /* * payload.UserID = userID; * payload.OrganizationID = orgID; * payload.FirstName = firstName; * payload.LastName = lastName; * payload.Email = email; * payload.Title = title; * payload.PodName = SystemSettings.GetPodName(); * payload.Key = "81f4060c-2166-48c3-a126-b12c94f1fd9d"; */ try { dynamic data = JObject.Parse(ReadJsonData(context)); if (data.Key != "81f4060c-2166-48c3-a126-b12c94f1fd9d") { return; } LoginUser loginUser = LoginUser.Anonymous; User tsUser = null; Organizations organizations = new Organizations(loginUser); organizations.LoadByImportID(data.PodName.ToString() + "-" + data.OrganizationID.ToString(), 1078); if (organizations.IsEmpty) { return; } Organization tsOrg = organizations[0]; Users users = new Users(loginUser); users.LoadByImportID(data.UserID.ToString(), tsOrg.OrganizationID); if (users.IsEmpty) { users.LoadByEmail(data.Email.ToString().Trim(), tsOrg.OrganizationID); } if (users.IsEmpty) { tsUser = (new Users(loginUser)).AddNewUser(); tsUser.OrganizationID = tsOrg.OrganizationID; tsUser.IsActive = true; tsUser.IsPortalUser = true; } else { tsUser = users[0]; } tsUser.ImportID = data.UserID.ToString(); tsUser.FirstName = data.FirstName.ToString().Trim(); tsUser.LastName = data.LastName.ToString().Trim(); tsUser.Email = data.Email.ToString().Trim(); tsUser.Title = data.Title.ToString(); tsUser.Collection.Save(); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "SyncUser"); throw; } }
public static string GetOrganizations(RestCommand command, bool orderByDateCreated = false, int?limitNumber = null) { OrganizationsView organizations = new OrganizationsView(command.LoginUser); bool hasBeenFiltered = false; if (orderByDateCreated) { //This seems to be Zapier only organizations.LoadByParentID(command.Organization.OrganizationID, true, "DateCreated DESC", limitNumber); hasBeenFiltered = true; } else { try { organizations.LoadByParentID(command.Organization.OrganizationID, true, command.Filters, command.PageNumber, command.PageSize); hasBeenFiltered = true; } catch (Exception e) { organizations = new OrganizationsView(command.LoginUser); organizations.LoadByParentID(command.Organization.OrganizationID, true); ExceptionLogs.LogException(command.LoginUser, e, "API", "RestOrganizations. RestGetOrganization(). SQL filtering generation failed, fell into old method (no filters?)."); } } return(organizations.GetXml("Customers", "Customer", true, !hasBeenFiltered ? command.Filters : new System.Collections.Specialized.NameValueCollection(), command.IsPaging)); }
public override void Run() { try { ProcessWebHook(WebHook); Thread.Sleep(0); _isStopped = true; } catch (Exception ex) { Logs.WriteEvent("Error processing the webhook"); Logs.WriteEventFormat("Id: {0}, Is Inbound: {1}, RefId: {2}", WebHook.Id, WebHook.Inbound, WebHook.RefId); Logs.WriteEventFormat("WebHook Data: {0}", WebHook.BodyData); Logs.WriteException(ex); ExceptionLogs.LogException(LoginUser, ex, "Webhooks", "Error processing the webhook."); //ToDo should we re-insert for later process a webhook that threw an in-process unhandled-exception while processing? /* * WebHooksPending reInserted = new WebHooksPending(LoginUser); * WebHooksPendingItem reInsertedItem = reInserted.AddNewWebHooksPendingItem(); * reInsertedItem.RefId = WebHook.RefId; * reInsertedItem.RefType = WebHook.RefType; * reInsertedItem.Type = WebHook.Type; * reInsertedItem.BodyData = WebHook.BodyData; * reInsertedItem.Inbound = WebHook.Inbound; * reInsertedItem.IsProcessing = false; * reInserted.Save(); */ } }
private static DataTable GetSummaryData(LoginUser loginUser, SummaryReport summaryReport, bool useDefaultOrderBy, Report report = null) { SqlCommand command = new SqlCommand(); SummaryReportSql.GetSummaryCommand(loginUser, command, summaryReport, false, false, useDefaultOrderBy); BaseCollection.FixCommandParameters(command); if (report != null) { report.LastSqlExecuted = DataUtils.GetCommandTextSql(command); report.Collection.Save(); } DataTable table = new DataTable(); using (SqlConnection connection = new SqlConnection(loginUser.ConnectionString)) { connection.Open(); command.Connection = connection; using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { try { adapter.Fill(table); } catch (Exception ex) { ExceptionLogs.LogException(loginUser, ex, "GetSummaryData"); throw; } } connection.Close(); } return(table); }
private void RecoverTicketCustomValues(int orgID, int badTicketID, int goodTicketID) { CustomValues badCustomValues = new CustomValues(GetCorrupteLoginUser()); badCustomValues.LoadByReferenceTypeModifiedAfterRecovery(orgID, ReferenceType.Tickets, badTicketID); foreach (CustomValue badCustomValue in badCustomValues) { try { if (badCustomValue == null) { continue; } CustomValue goodCustomValue = CustomValues.GetValue(GetReviewLoginUser(), goodTicketID, badCustomValue.ApiFieldName); if (goodCustomValue != null) { goodCustomValue.Value = badCustomValue.Value; goodCustomValue.Collection.Save(); } } catch (Exception ex) { _exceptionOcurred = true; ExceptionLogs.LogException(GetCorrupteLoginUser(), ex, "recover"); } } }
public void IndexTicket(int ticketID) { Ticket Ticket = Tickets.GetTicket(TSAuthentication.GetLoginUser(), ticketID); Tags Tags = new Tags(TSAuthentication.GetLoginUser()); Tags.LoadByReference(ReferenceType.Tickets, ticketID); DeflectorService Deflection = new DeflectorService(); List <DeflectorIndex> deflectorIndexList = new List <DeflectorIndex>(); foreach (var Tag in Tags) { deflectorIndexList.Add(new DeflectorIndex { TicketID = Ticket.TicketID, Name = Ticket.Name, OrganizationID = Ticket.OrganizationID, TagID = Tag.TagID, Value = Tag.Value, ProductID = Ticket.ProductID }); } try { DeflectorAPI deflectorAPI = new DeflectorAPI(); deflectorAPI.BulkIndexDeflectorAsync(Newtonsoft.Json.JsonConvert.SerializeObject(deflectorIndexList)); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "Deflector"); } }
public static string GetTicketsByCustomerID(RestCommand command, int customerID, bool orderByDateCreated = false) { TicketsView tickets = new TicketsView(command.LoginUser); string orderBy = orderByDateCreated ? "ot.DateCreated DESC" : "TicketNumber"; string xml = ""; if (command.IsPaging) { try { //remove Paging parameters NameValueCollection filters = new NameValueCollection(); foreach (string key in command.Filters.AllKeys) { if (key.ToLower() != "pagenumber" && key.ToLower() != "pagesize") { filters.Add(key, command.Filters[key]); } } tickets.LoadByCustomerID(customerID, filters, (int)command.PageNumber, (int)command.PageSize, orderBy); XmlTextWriter writer = Tickets.BeginXmlWrite("Tickets"); foreach (DataRow row in tickets.Table.Rows) { int ticketId = (int)row["TicketID"]; Tags tags = new Tags(command.LoginUser); tags.LoadByReference(ReferenceType.Tickets, ticketId); tags = tags ?? new Tags(command.LoginUser); tickets.WriteXml(writer, row, "Ticket", true, new NameValueCollection(), tags); } int totalRecords = 0; if (tickets.Count > 0) { totalRecords = tickets[0].TotalRecords; } writer.WriteElementString("TotalRecords", totalRecords.ToString()); xml = Tickets.EndXmlWrite(writer); } catch (Exception ex) { ExceptionLogs.LogException(command.LoginUser, ex, "API", "RestTickets. GetTicketsByCustomerID(). Paging. SQL filtering generation failed."); throw new RestException(HttpStatusCode.InternalServerError, "There was an error processing your request. Please contact TeamSupport.com", ex); } } else { tickets.LoadByCustomerID(customerID, orderBy); xml = tickets.GetXml("Tickets", "Ticket", true, command.Filters, command.IsPaging); xml = AddTagsToTickets(xml, command); } return(xml); }
/// <summary> /// Add the Tag tags to the final xml of the deleted tickets /// </summary> /// <param name="deletedTicketsXml">Deleted Tickets xml string.</param> /// <returns>An xml string with the Deleted Tickets data and its tags.</returns> private static string AddTagsToDeletedTickets(string deletedTicketsXml, RestCommand command, bool isCustomerToken = false) { string xml = string.Empty; //Add the tag nodes to each deleted ticket object XmlDocument xmlDoc = new XmlDocument(); xmlDoc.XmlResolver = null; xmlDoc.LoadXml(deletedTicketsXml); //Do we have paging? XmlNode totalRecordsElement = xmlDoc.SelectSingleNode("/DeletedTickets/TotalRecords"); XmlNodeList nodeList = xmlDoc.SelectNodes("/DeletedTickets/DeletedTicket"); string xmlResultString = string.Empty; using (var xmlTextWriter = Tickets.BeginXmlWrite("DeletedTickets")) { if (totalRecordsElement != null) { totalRecordsElement.WriteTo(xmlTextWriter); totalRecordsElement = null; } foreach (XmlNode node in nodeList) { //get the tags for the deleted ticket using the Id try { string recordIdString = node["ID"].InnerText; Tags tags = new Tags(command.LoginUser); tags.LoadByReference(ReferenceType.DeletedTickets, int.Parse(recordIdString), isCustomerToken ? command.Organization.ParentID : null); XmlTextWriter writer = Tags.BeginXmlWrite("Tags"); foreach (DataRow row in tags.Table.Rows) { tags.WriteXml(writer, row, "Tag", false, null); } string tagXmlString = string.Empty; tagXmlString = Tags.EndXmlWrite(writer); XmlDocument xmlTag = new XmlDocument(); xmlDoc.XmlResolver = null; xmlTag.LoadXml(tagXmlString); node.AppendChild(node.OwnerDocument.ImportNode(xmlTag.FirstChild.NextSibling, true)); } catch (Exception ex) { ExceptionLogs.LogException(command.LoginUser, ex, "API", string.Format("OrgID: {0}{1}Verb: {2}{1}Url: {3}{1}Body: {4}", command.Organization.OrganizationID, Environment.NewLine, command.Method, command.Method, command.Data)); } node.WriteTo(xmlTextWriter); } xml = DeletedTickets.EndXmlWrite(xmlTextWriter); } return(xml); }
public TsChatUpdate GetChatUpdate(int lastChatMessageID, int lastChatRequestID) { TsChatUpdate update = new TsChatUpdate(); try { User user = Users.GetUser(LoginUser.Anonymous, TSAuthentication.UserID); user.UpdatePing(); LoginUser loginUser = new LoginUser(user.UserID, user.OrganizationID, null); List <GrowlMessage> chatMessageGrowl = new List <GrowlMessage>(); List <GrowlMessage> chatRequestGrowl = new List <GrowlMessage>(); update.LastChatRequestID = lastChatRequestID; update.LastChatMessageID = lastChatMessageID; update.ChatMessageCount = 0; update.ChatRequestCount = 0; if (user.IsChatUser && ChatUserSettings.GetSetting(loginUser, user.UserID).IsAvailable) { ChatMessages chatMessages = new ChatMessages(loginUser); update.ChatMessageCount = chatMessages.GetUnreadMessageCount(loginUser.UserID, ChatParticipantType.User); update.ChatRequestCount = user.IsChatUser ? ChatRequests.GetWaitingRequestCount(loginUser, loginUser.UserID, loginUser.OrganizationID) : 0; if (lastChatMessageID < 0) { update.LastChatMessageID = ChatMessages.GetLastMessageID(loginUser); } chatMessages.LoadUnpreviewedMessages(loginUser.UserID, update.LastChatMessageID); foreach (ChatMessage chatMessage in chatMessages) { chatMessageGrowl.Add(new GrowlMessage(chatMessage.Message, chatMessage.PosterName, "ui-state-active")); update.LastChatMessageID = chatMessage.ChatMessageID; } ChatRequests requests = new ChatRequests(loginUser); requests.LoadNewWaitingRequests(loginUser.UserID, loginUser.OrganizationID, lastChatRequestID); foreach (ChatRequest chatRequest in requests) { chatRequestGrowl.Add(new GrowlMessage(string.Format("{0} {1} is requesting a chat!", chatRequest.Row["FirstName"].ToString(), chatRequest.Row["LastName"].ToString()), "Chat Request", "ui-state-error")); update.LastChatRequestID = chatRequest.ChatRequestID; } } update.NewChatMessages = chatMessageGrowl.ToArray(); update.NewChatRequests = chatRequestGrowl.ToArray(); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "Main Chat Upate"); } return(update); }
public void DeleteTicket(int ticketID) { try { DeflectorAPI deflectorAPI = new DeflectorAPI(); deflectorAPI.DeleteTicketAsync(ticketID); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "Deflector"); } }
public void CreateNewException() { try { throw new Exception("This is a test exception."); } catch (Exception ex) { ExceptionLogs.LogException(TSAuthentication.GetLoginUser(), ex, "TSSystem", "Extra Info"); } }
public override bool Save() { try { string path = TeamSupport.Data.Quarantine.WebAppQ.GetAttachmentPath8(UserSession.LoginUser); RemoveCachedImages(UserSession.LoginUser.OrganizationID, _userID); if (img1.Value != "") { img1.Value = img1.Value.Replace(".ashx", ""); string source = TeamSupport.Data.Quarantine.WebAppQ.GetAttachmentPath9(UserSession.LoginUser, Session["WorkingImage"].ToString()); string dest = path + '\\' + _userID + "avatar.jpg"; try { ImageBuilder.Current.Build(source, dest, new ResizeSettings(img1.Value)); } catch (Exception ex2) { ExceptionLogs.LogException(UserSession.LoginUser, ex2, "ImageBuilder", string.Format("source:{0}, dest:{1}", source, dest)); throw; } File.Delete(source); AttachmentProxy proxy = TeamSupport.ModelAPI.Model_API.ReadRefTypeProxyByRefID <UserPhotoAttachmentProxy>(_userID); if (proxy != null) { proxy.FileName = _userID + "avatar.jpg"; proxy.Path = path + '\\' + _userID + "avatar.jpg"; proxy.FilePathID = 3; TeamSupport.ModelAPI.Model_API.Update(proxy); } else { proxy = AttachmentProxy.ClassFactory(AttachmentProxy.References.UserPhoto); proxy.RefID = _userID; proxy.OrganizationID = _organizationID; proxy.FileName = _userID + "avatar.jpg"; proxy.Path = path + '\\' + _userID + "avatar.jpg"; proxy.FilePathID = 3; proxy.FileType = "image/jpeg"; proxy.FileSize = -1; TeamSupport.ModelAPI.Model_API.Create(proxy); } } } catch (Exception ex) { ExceptionLogs.LogException(UserSession.LoginUser, ex, "Save Avatar"); throw; } return(true); }
public void RemoveTag(int organizationID, int ticketID, string value) { try { DeflectorAPI deflectorAPI = new DeflectorAPI(); deflectorAPI.RemoveTagAsync(organizationID, ticketID, value); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "Deflector"); } }
public void IndexDeflector(string deflectorIndex) { try { DeflectorAPI deflectorAPI = new DeflectorAPI(); deflectorAPI.IndexDeflectorAsync(deflectorIndex); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "Deflector"); } }
public override bool Save() { if (IsValid()) { if (_isCloning) { //Clone SLA here LoginUser loginUser = TSAuthentication.GetLoginUser(); int clonedSlaLevelId = 0; try { SlaLevel originalSlaLevel = SlaLevels.GetSlaLevel(loginUser, _slaLevelID); SlaLevel clonedSlaLevel = originalSlaLevel.Clone(textName.Text.Trim()); clonedSlaLevelId = clonedSlaLevel.SlaLevelID; } catch (Exception ex) { ExceptionLogs.LogException(loginUser, ex, "Cloning Sla", "SlaLevel.aspx.cs.Save"); } } else { SlaLevel level; SlaLevels levels = new SlaLevels(UserSession.LoginUser); if (_slaLevelID < 0) { level = levels.AddNewSlaLevel(); level.OrganizationID = UserSession.LoginUser.OrganizationID; } else { level = SlaLevels.GetSlaLevel(UserSession.LoginUser, _slaLevelID); if (level == null) { return(false); } } level.Name = textName.Text; level.Collection.Save(); DialogResult = level.SlaLevelID.ToString(); } } else { return(false); } return(true); }
private static DataTable GetReportTableAll(LoginUser scheduledReportCreator, Report report, string sortField, bool isDesc, bool useUserFilter, bool includeHiddenFields) { SqlCommand command = new SqlCommand(); report.GetCommand(command, includeHiddenFields, false, useUserFilter); if (string.IsNullOrWhiteSpace(sortField)) { sortField = GetReportColumnNames(scheduledReportCreator, report.ReportID)[0]; isDesc = false; } //need to append the extra stuff for custom and summary reports here. See Reports.cs line 2115 if (report.ReportDefType == ReportType.Custom) { string query = @"WITH {0}, r AS (SELECT q.*, ROW_NUMBER() OVER (ORDER BY [{1}] {2}) AS 'RowNum' FROM q) SELECT *{3} FROM r "; command.CommandText = string.Format(query, command.CommandText, sortField, isDesc ? "DESC" : "ASC", ""); } if (command.CommandText.ToLower().IndexOf(" order by ") < 0) { command.CommandText = command.CommandText + " ORDER BY [" + sortField + (isDesc ? "] DESC" : "] ASC"); } report.LastSqlExecuted = DataUtils.GetCommandTextSql(command); report.Collection.Save(); DataTable table = new DataTable(); using (SqlConnection connection = new SqlConnection(scheduledReportCreator.ConnectionString)) { connection.Open(); command.Connection = connection; using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { try { adapter.Fill(table); } catch (Exception ex) { ExceptionLogs.LogException(scheduledReportCreator, ex, "Report Data"); throw; } } connection.Close(); } return(table); }
public void HydrateOrganization(int organizationID) { string response = TeamSupport.Data.Deflector.GetOrganizationIndeces(TSAuthentication.GetLoginUser(), organizationID); try { DeflectorAPI deflectorAPI = new DeflectorAPI(); deflectorAPI.BulkIndexDeflectorAsync(response); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "Deflector"); } }
public async Task <string> TestDeflectorAPI(string tag) { try { DeflectorAPI deflectorAPI = new DeflectorAPI(); return(await deflectorAPI.TestDeflectorAPIAsync(tag)); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "Deflector"); return(null); } }
public TsMainPageUpdate GetUserStatusUpdate(string sessionID) { TsMainPageUpdate update = new TsMainPageUpdate(); try { update.IsDebug = TSAuthentication.OrganizationID == 1078 || TSAuthentication.IsBackdoor; update.IsExpired = false; using (SqlConnection connection = new SqlConnection(LoginUser.Anonymous.ConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SELECT EnforceSingleSession, SessionID, IsActive, MarkDeleted FROM Users WHERE UserID = @UserID"; command.Parameters.AddWithValue("UserID", TSAuthentication.UserID); SqlDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { if (!(bool)reader[2] || (bool)reader[3]) { update.IsExpired = true; } else if ((bool)reader[0] && reader[1] != DBNull.Value) { if (sessionID != null && sessionID.ToLower() != reader[1].ToString().ToLower() && !TSAuthentication.IsBackdoor) { update.IsExpired = true; } } } else { } reader.Close(); } update.RefreshID = int.Parse(SystemSettings.ReadString(LoginUser.Anonymous, "RefreshID", "-1")); update.ExpireTime = TSAuthentication.Ticket.Expiration.ToShortTimeString(); update.Version = GetVersion() + "." + GetRevision(); //update.IsIdle = user.DateToUtc(user.LastActivity).AddMinutes(20) < DateTime.UtcNow; update.MyUnreadTicketCount = Tickets.GetMyOpenUnreadTicketCount(TSAuthentication.GetLoginUser(), TSAuthentication.UserID); } catch (Exception ex) { ex.Data["SessionID"] = sessionID; ExceptionLogs.LogException(LoginUser.Anonymous, ex, "GetUserStatusUpdate"); } return(update); }
public override void Run() { bool isRebuilder = GetIsRebuilderMode(); int daysSinceLastRebuild = Settings.ReadInt("DaysSinceLastRebuild", 14); int minutesSinceLastActive = Settings.ReadInt("MinutesSinceLastActive", 30); while (!IsStopped) { try { UpdateHealth(); Organization organization = GetNextOrganization(LoginUser.ConnectionString, (int)_threadPosition, isRebuilder, daysSinceLastRebuild, minutesSinceLastActive); if (organization == null) { System.Threading.Thread.Sleep(10000); continue; } try { _isVerbose = Settings.ReadBool("VerboseLogging", false); int idToLog = Settings.ReadInt("VerboseLoggingOrg", 0); if (_isVerbose && idToLog > 0) { _isVerbose = organization.OrganizationID == idToLog; } ProcessOrganization(organization, isRebuilder); } finally { if (isRebuilder) { UnmarkIndexRebuild(organization.OrganizationID); } else { UnlockIndex(organization.OrganizationID); } } } catch (Exception ex) { Logs.WriteEvent("Error processing organization"); Logs.WriteException(ex); ExceptionLogs.LogException(LoginUser, ex, "Indexer", "Error processing organization"); } } }
public override void Run() { TaskEmailPosts.UnlockThread(LoginUser, (int)_threadPosition); while (!IsStopped) { TaskEmailPost taskEmailPost = GetNextTaskEmailPost(LoginUser.ConnectionString, (int)_threadPosition, _isDebug); if (taskEmailPost == null) { System.Threading.Thread.Sleep(10000); continue; } try { try { if (taskEmailPost.CreatorID != -5) { _isDebug = Settings.ReadBool("Debug", false); _logEnabled = Settings.ReadInt("LoggingEnabled", 0) == 1; Logs.WriteLine(); Logs.WriteEvent("***********************************************************************************"); Logs.WriteEvent("Processing Task Email Post TaskEmailPostID: " + taskEmailPost.TaskEmailPostID.ToString()); Logs.WriteData(taskEmailPost.Row); Logs.WriteEvent("***********************************************************************************"); SetTimeZone(taskEmailPost); ProcessEmail(taskEmailPost); } } catch (Exception ex) { ExceptionLogs.LogException(LoginUser, ex, "Email", taskEmailPost.Row); } finally { Logs.WriteEvent("Deleting from DB"); taskEmailPost.Collection.DeleteFromDB(taskEmailPost.TaskEmailPostID); } Logs.WriteEvent("Updating Health"); UpdateHealth(); } catch (Exception ex) { ExceptionLogs.LogException(LoginUser, ex, "Email", taskEmailPost.Row); } } }
private void RecoverProducts(int orgID, LoginUser loginUser) { // check corrupt db for different products,if so craete the new products, but do not use ID's Products badProducts = new Products(GetCorrupteLoginUser()); badProducts.LoadByOrganizationID(orgID); Products goodProducts = new Products(loginUser); goodProducts.LoadByOrganizationID(orgID); foreach (Product badProduct in badProducts) { try { Product goodProduct = goodProducts.FindByName(badProduct.Name); if (goodProduct == null) { goodProduct = (new Products(loginUser)).AddNewProduct(); goodProduct.Name = badProduct.Name; goodProduct.DateCreated = badProduct.DateCreatedUtc; if (badProduct.CreatorID > 0) { User creator = _usersAndContacts.FindByUserID(badProduct.CreatorID); if (creator != null) { goodProduct.CreatorID = creator.UserID; } else { goodProduct.CreatorID = -5; } } else { goodProduct.CreatorID = badProduct.CreatorID; } goodProduct.OrganizationID = orgID; goodProduct.ImportID = _importID; goodProduct.Collection.Save(); } } catch (Exception ex) { _exceptionOcurred = true; ExceptionLogs.LogException(GetCorrupteLoginUser(), ex, "recover"); } } }
public void AddLike(WatercoolerLikProxy[] likes, int messageID, int messageParentID, string orgID) { LoginUser loginUser = new LoginUser(connString, -1, -1, null); try { loginUser = new LoginUser(connString, TSAuthentication.GetLoginUser().UserID, TSAuthentication.GetLoginUser().OrganizationID, null); var result = pusher.Trigger("ticket-dispatch-" + TSAuthentication.GetLoginUser().OrganizationID, "updateLikes", new { like = likes, message = messageID, messageParent = messageParentID }); //Clients.Group(orgID).updateLikes(likes, messageID, messageParentID); } catch (Exception ex) { ExceptionLogs.LogException(loginUser, ex, "Socket.AddLike"); } }
public ScheduledReportProxy GetScheduledReport(int id) { ScheduledReportProxy proxy = new ScheduledReportProxy(); try { ScheduledReport scheduledReport = ScheduledReports.GetScheduledReport(TSAuthentication.GetLoginUser(), id); proxy = scheduledReport.GetProxy(); } catch (Exception ex) { ExceptionLogs.LogException(TSAuthentication.GetLoginUser(), ex, "ReportService.GetScheduledReport"); } return(proxy); }
//For Exports private DataTable GetReportTablePageForExports(string sortField, bool isDesc, bool useUserFilter, bool includeHiddenFields) { SqlCommand command = GetExportsSqlCommand(ref sortField, ref isDesc, useUserFilter, includeHiddenFields); _report.LastSqlExecuted = DataUtils.GetCommandTextSql(command); _report.Collection.Save(); BaseCollection.FixCommandParameters(command); DataTable table = new DataTable(); using (SqlConnection connection = new SqlConnection(_loginUser.ConnectionString)) { connection.Open(); SqlTransaction transaction = connection.BeginTransaction(IsolationLevel.ReadUncommitted); command.Connection = connection; command.Transaction = transaction; try { using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(table); } transaction.Commit(); table = DataUtils.DecodeDataTable(table); table = DataUtils.StripHtmlDataTable(table); } catch (Exception ex) { transaction.Rollback(); ExceptionLogs.LogException(_loginUser, ex, "Report Data", DataUtils.GetCommandTextSql(command)); throw; } connection.Close(); } //On exports it is always false //if (!includeHiddenFields) if (table.Columns.Contains("RowNum")) { table.Columns.Remove("RowNum"); } AddReportTicketsViewTempTable(command); return(table); }
public static string GetAssetsView(RestCommand command) { AssetsView assetsView = new AssetsView(command.LoginUser); try { assetsView.LoadByOrganizationID(command.Organization.OrganizationID, command.Filters); } catch (Exception ex) { //if something fails use the old method assetsView.LoadByOrganizationID(command.Organization.OrganizationID); ExceptionLogs.LogException(command.LoginUser, ex, "API", "RestAssetsView. GetAssetsView(). SQL filtering generation failed, fell into old method."); } return(assetsView.GetXml("Assets", "Asset", true, command.Filters)); }