//method to fetch incidentDetails from database public DBIncident gettingIncidentDetails(int pstrComponentId) { WinMonitorEntityModelContext contextObj = new WinMonitorEntityModelContext(); DBIncident incidentObj = new DBIncident(); try{ incidentObj = contextObj.Database.SqlQuery <DBIncident>("select * from DBIncidents where DBCSId=" + pstrComponentId + ";").FirstOrDefault(); } catch (DbUpdateException exUpdateDB) { Console.Write(exUpdateDB); } catch (DbEntityValidationException exEntityValidateDB) { Console.Write(exEntityValidateDB); } catch (NotSupportedException exNotSupportedDB) { Console.Write(exNotSupportedDB); } catch (ObjectDisposedException exObjectDisposedDB) { Console.Write(exObjectDisposedDB); } catch (InvalidOperationException exInvalidOperationDB) { Console.Write(exInvalidOperationDB); } return(incidentObj); }
/// <summary> /// ItemId, ItemName, Weight, StateId, CanDelete (int) /// </summary> public static DataTable GetList(DictionaryTypes dict) { DataTable dt = null; switch (dict) { case DictionaryTypes.Categories: dt = DBCommon.GetListCategoriesForDictionaries(); break; case DictionaryTypes.IncidentSeverities: dt = DBIncident.GetListIncidentSeverityForDictionaries(); break; case DictionaryTypes.IncidentTypes: dt = DBIncident.GetListIncidentTypesForDictionaries(); break; case DictionaryTypes.ProjectTypes: dt = DBProject.GetListProjectTypesForDictionaries(); break; case DictionaryTypes.ProjectCategories: dt = DBProject.GetListProjectCategoriesForDictionaries(); break; case DictionaryTypes.IncidentCategories: dt = DBIncident.GetListIncidentCategoriesForDictionaries(); break; case DictionaryTypes.Currency: dt = DBCommon.GetListCurrencyForDictionaries(); break; case DictionaryTypes.DocumentStatus: dt = DBDocument.GetListDocumentStatusForDictionaries(Security.CurrentUser.LanguageId); break; case DictionaryTypes.ProjectPhases: dt = DBProject.GetListProjectPhasesForDictionaries(); break; case DictionaryTypes.RiskLevels: dt = DBProject.GetListRiskLevelsForDictionaries(); break; } if (dict != DictionaryTypes.ProjectPhases && dict != DictionaryTypes.RiskLevels && dt != null) { dt.Columns.Add("Weight", typeof(int)); } return(dt); }
/// <summary> /// Finds the incident by ticket. /// </summary> /// <param name="Ticket">The ticket.</param> /// <returns></returns> private static int FindIncidentByTicket(string Ticket) { int IncidentId = TicketUidUtil.GetThreadId(Ticket); using (IDataReader reader = DBIncident.GetIncident(IncidentId, 0, 1)) { if (reader.Read()) { return(IncidentId); } } return(-1); }
public static void AddItem(string ItemName, int Param, DictionaryTypes dict) { if (!Company.CheckDiskSpace()) { throw new MaxDiskSpaceException(); } switch (dict) { case DictionaryTypes.Categories: DBCommon.AddCategory(ItemName); break; case DictionaryTypes.IncidentSeverities: DBIncident.AddIncidentSeverity(ItemName); break; case DictionaryTypes.IncidentTypes: DBIncident.AddIncidentType(ItemName); break; case DictionaryTypes.ProjectTypes: AddProjectType(ItemName); break; case DictionaryTypes.ProjectCategories: DBProject.AddProjectCategory(ItemName); break; case DictionaryTypes.IncidentCategories: DBIncident.AddIncidentCategory(ItemName); break; case DictionaryTypes.Currency: DBCommon.AddCurrency(ItemName); break; case DictionaryTypes.DocumentStatus: DBDocument.AddDocumentStatus(ItemName, Param); break; case DictionaryTypes.ProjectPhases: DBProject.AddProjectPhase(ItemName, Param); break; case DictionaryTypes.RiskLevels: DBProject.AddRiskLevel(ItemName, Param); break; } }
public static void DeleteItem(int ItemId, DictionaryTypes dict) { switch (dict) { case DictionaryTypes.Categories: DBCommon.DeleteCategory(ItemId); break; case DictionaryTypes.IncidentSeverities: DBIncident.DeleteIncidentSeverity(ItemId); break; case DictionaryTypes.IncidentTypes: DBIncident.DeleteIncidentType(ItemId); break; case DictionaryTypes.ProjectTypes: DeleteProjectType(ItemId); break; // case DictionaryTypes.Clients: // DBProject.DeleteClient(ItemId); // break; case DictionaryTypes.ProjectCategories: DBProject.DeleteProjectCategory(ItemId); break; case DictionaryTypes.IncidentCategories: DBIncident.DeleteIncidentCategory(ItemId); break; case DictionaryTypes.Currency: DBCommon.DeleteCurrency(ItemId); break; case DictionaryTypes.DocumentStatus: DBDocument.DeleteDocumentStatus(ItemId); break; case DictionaryTypes.ProjectPhases: DBProject.DeleteProjectPhase(ItemId); break; case DictionaryTypes.RiskLevels: DBProject.DeleteRiskLevel(ItemId); break; } }
public static void UpdateItem(int ItemId, string ItemName, int Param, DictionaryTypes dict) { switch (dict) { case DictionaryTypes.Categories: DBCommon.UpdateCategory(ItemId, ItemName); break; case DictionaryTypes.IncidentSeverities: DBIncident.UpdateIncidentSeverity(ItemId, ItemName); break; case DictionaryTypes.IncidentTypes: DBIncident.UpdateIncidentType(ItemId, ItemName); break; case DictionaryTypes.ProjectTypes: UpdateProjectType(ItemId, ItemName); break; // case DictionaryTypes.Clients: // DBProject.UpdateClient(ItemId, ItemName); // break; case DictionaryTypes.ProjectCategories: DBProject.UpdateProjectCategory(ItemId, ItemName); break; case DictionaryTypes.IncidentCategories: DBIncident.UpdateIncidentCategory(ItemId, ItemName); break; case DictionaryTypes.Currency: DBCommon.UpdateCurrency(ItemId, ItemName); break; case DictionaryTypes.DocumentStatus: DBDocument.UpdateDocumentStatus(ItemId, ItemName, Param); break; case DictionaryTypes.ProjectPhases: DBProject.UpdateProjectPhase(ItemId, ItemName, Param); break; case DictionaryTypes.RiskLevels: DBProject.UpdateRiskLevel(ItemId, ItemName, Param); break; } }
public static void Update(IncidentBox box, IncidentBoxDocument document) { if (!CanModify()) { throw new AccessDeniedException(); } using (Database.DbTransaction tran = Database.DbTransaction.Begin()) { IncidentBox.Update(box); IncidentBoxDocument.Save(document); // O.R.[2008-12-16]: Recalculate Current Responsible DBIncident.RecalculateCurrentResponsibleByIncidentBox(box.IncidentBoxId); tran.Commit(); } }
/// <summary> /// Adds the external E mail to incident. /// </summary> /// <param name="IncidentId">The incident id.</param> /// <param name="EMailMessageId">The E mail message id.</param> /// <param name="message">The message.</param> private static int AddExternalEMail2Incident(int IncidentId, int EMailMessageId, string SenderName, string SenderEmail) { ForumThreadNodeInfo info = null; using (DbTransaction tran = DbTransaction.Begin()) { BaseIbnContainer FOcontainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", IncidentId)); ForumStorage forumStorage = (ForumStorage)FOcontainer.LoadControl("ForumStorage"); EMailMessageInfo mi = EMailMessageInfo.Load(EMailMessageId); info = forumStorage.CreateForumThreadNode(EMailMessageInfo.ExtractTextFromHtml(mi.HtmlBody), DateTime.UtcNow, Security.UserID, EMailMessageId, (int)ForumStorage.NodeContentType.EMail); // 2006-12-12 OZ: Register EMail External Recepient if (!EMailIssueExternalRecipient.Contains(IncidentId, SenderEmail)) { EMailIssueExternalRecipient.Create(IncidentId, SenderEmail); } ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(info.Id); settings.Add(ForumThreadNodeSetting.Incoming, "1"); if (HttpContext.Current != null && HttpContext.Current.Items.Contains(ForumThreadNodeSetting.AllRecipients)) { settings.Add(ForumThreadNodeSetting.AllRecipients, HttpContext.Current.Items[ForumThreadNodeSetting.AllRecipients].ToString()); } // O.R. [2008-09-19]: Recalculate Expected Dates DBIncident.RecalculateExpectedResponseDate(IncidentId); DBIncident.RecalculateExpectedAssignDate(IncidentId); tran.Commit(); } return(info.Id); }
//function to get expected end date public DummyClassToGetExpectedEndTime gettingExpectedEndTime(int componentId) { DummyClassToGetExpectedEndTime dummyObj = new DummyClassToGetExpectedEndTime(); WinMonitorEntityModelContext contextObj = new WinMonitorEntityModelContext(); DBIncident incidentObj = new DBIncident(); DBLogHistory historyObj = new DBLogHistory(); incidentObj = contextObj.Database.SqlQuery <DBIncident>("select * from DBIncidents where DBCSId='" + componentId + "';").First(); historyObj = contextObj.Database.SqlQuery <DBLogHistory>("select * from DBLogHistory where DBIncidentId='" + incidentObj.DBIncidentId + "';").Last(); if (incidentObj.DBExpectedDuration != null) { dummyObj.expectedEndpresentOrNot = true; dummyObj.expectedEndDate = contextObj.Database.SqlQuery <DateTime>("select DATEADD(hour, " + incidentObj.DBExpectedDuration + ", '" + historyObj.DBDateTimeStart + "')").First(); } else { dummyObj.expectedEndpresentOrNot = false; dummyObj.expectedEndDate = null; } return(dummyObj); }
public static int GetSharingLevel(ObjectTypes ObjectType, int ObjectId) { int UserId = Security.CurrentUser.UserID; int RetVal = -1; switch (ObjectType) { case ObjectTypes.ToDo: RetVal = DBToDo.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.Task: RetVal = DBTask.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.CalendarEntry: RetVal = DBEvent.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.Issue: RetVal = DBIncident.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.Project: RetVal = DBProject.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.Document: RetVal = DBDocument.GetSharingLevel(UserId, ObjectId); break; default: RetVal = -1; break; } return(RetVal); }
//method to delete existing incident of particular element public void deletingExistingIncidentOfComponent(int pstrComponentId, int pstrCompanyId) { WinMonitorEntityModelContext contextObj = new WinMonitorEntityModelContext(); DBIncident incidentObj = new DBIncident(); DBComponent_With_Status componentObj = new DBComponent_With_Status(); DBLogHistory historyObj = new DBLogHistory(); componentObj = (from component in contextObj.DBComponent_With_Status where component.DBCSId == pstrComponentId select component).FirstOrDefault(); incidentObj = (from incident in contextObj.DBIncidents where incident.DBCSId == pstrComponentId select incident).FirstOrDefault(); historyObj = (from log in contextObj.DBLogHistories where ((log.DBCompanyId == pstrCompanyId) && (log.DBCSId == pstrComponentId) && (log.DBDateTimeEnd == null)) select log).Last(); historyObj.DBDateTimeStart = DateTime.UtcNow;; contextObj.SaveChanges(); contextObj.DBIncidents.Remove(incidentObj); contextObj.SaveChanges(); }
private void OnNewMessage(object sender, EventArgs e) { if (e is NewPop3MessageEventArgs && sender is EMailRouterPop3BoxMessageLoader) { EMailRouterPop3Box internalPop3Box = EMailRouterPop3Box.ListInternal(); if (internalPop3Box != null && !internalPop3Box.Activity.IsActive) { internalPop3Box = null; } UserLight prevUser = Security.CurrentUser; Alerts2.SendToCurrentUser = true; try { using (DbTransaction tran = DbTransaction.Begin()) { EMailRouterPop3BoxMessageLoader loader = (EMailRouterPop3BoxMessageLoader)sender; Pop3Message msg = ((NewPop3MessageEventArgs)e).Message; string TicketUID = TicketUidUtil.LoadFromString(msg.Subject == null ? string.Empty : msg.Subject); EMailMessageAntiSpamRuleRusult result = EMailMessageAntiSpamRuleRusult.Deny; if (loader.Owner.IsInternal) { int UserId = DBUser.GetUserByEmail(EMailMessage.GetSenderEmail(msg), false); if (TicketUID != string.Empty && UserId > 0) { result = EMailMessageAntiSpamRuleRusult.Accept; } } else { if (PortalConfig.UseAntiSpamFilter) { result = EMailMessageAntiSpamRule.Check(loader.Owner, msg); } else { result = EMailMessageAntiSpamRuleRusult.Accept; } } int EMailMessageId = -1; // OZ: [2007-01-29] EMailMessageLog if (EmailLogSettings != null) { string from = string.Empty; if (msg.Headers["Reply-To"] != null) { from = msg.Headers["Reply-To"]; } //else if (msg.Headers["Sender"] != null) //{ // from = msg.Headers["Sender"]; //} else if (msg.Headers["From"] != null) { from = msg.Headers["From"]; } EMailMessageLog.Add(from, msg.Headers["To"] != null ? msg.Headers["To"] : string.Empty, msg.Headers["Subject"] != null ? msg.Headers["Subject"] : string.Empty, loader.Owner.EMailRouterPop3BoxId, result); } // switch (result) { case EMailMessageAntiSpamRuleRusult.Pending: // Register Email Message EMailMessageId = RegisterEmail(loader.Owner.EMailRouterPop3BoxId, msg); // Add to pending email table EMailMessage.MarkAsPendingMessage(EMailMessageId); break; case EMailMessageAntiSpamRuleRusult.Accept: // Register Email Message EMailMessageId = RegisterEmail(loader.Owner.EMailRouterPop3BoxId, msg); if (TicketUID == string.Empty) { int IncidentId = EMailMessage.CreateNewIncident(EMailMessageId, loader.Owner, msg); } else { // Assign By Ticket int IncidentId = FindIncidentByTicket(TicketUID); if (IncidentId != -1) { int creatorId, issueBoxId; using (IDataReader reader = DBIncident.GetIncident(IncidentId, 0, 1)) { reader.Read(); creatorId = (int)reader["CreatorId"]; issueBoxId = (int)reader["IncidentBoxId"]; } int stateId, managerId, responsibleId; bool isResposibleGroup; ArrayList users = new ArrayList(); Issue2.GetIssueBoxSettings(issueBoxId, out stateId, out managerId, out responsibleId, out isResposibleGroup, users); EMailMessage.LogOnCreator(creatorId, msg); int ThreadNodeId = EMailMessage.AddToIncidentMessage(loader.Owner.IsInternal, IncidentId, EMailMessageId, msg); if (EMailMessage.ProcessXIbnHeaders(IncidentId, ThreadNodeId, msg)) { try { ArrayList excludeUsers = EMailRouterOutputMessage.Send(IncidentId, loader.Owner, msg); SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, IncidentId, -1, excludeUsers); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); Log.WriteError(ex.ToString()); } } } else { // Add to pending email table if (!loader.Owner.IsInternal) { EMailMessage.MarkAsPendingMessage(EMailMessageId); } } } break; case EMailMessageAntiSpamRuleRusult.Deny: // Do nothing break; } tran.Commit(); } } finally { Alerts2.SendToCurrentUser = false; if (Security.CurrentUser != prevUser) { Security.SetCurrentUser(prevUser); } } } }
//method to delete selected components public void DeleteSelectedComponents(List <int> pListOfComponents, int pCompanyId) { WinMonitorEntityModelContext contextObj = new WinMonitorEntityModelContext(); foreach (int componentId in pListOfComponents) { DBIncident incidentObj = new DBIncident(); DBLogHistory historyObj = new DBLogHistory(); DBComponent_With_Status componentObj = new DBComponent_With_Status(); int incidentIdStoringVariable = -1; incidentObj = (from incident in contextObj.DBIncidents where incident.DBCSId == componentId select incident).FirstOrDefault(); componentObj = (from component in contextObj.DBComponent_With_Status where component.DBCSId == componentId select component).FirstOrDefault(); if (incidentObj != null) { incidentIdStoringVariable = incidentObj.DBIncidentId; //Adding log history historyObj.DBCompanyId = pCompanyId; historyObj.DBComponentName = componentObj.DBComponentName; historyObj.DBCSId = componentObj.DBCSId; historyObj.DBDateTimeStart = DateTime.UtcNow;; historyObj.DBIncidentId = incidentIdStoringVariable; historyObj.DBDateTimeEnd = null; historyObj.DBIncidentDetails = "Incident Deleted"; historyObj.DBIncidentName = incidentObj.DBIncidentName; historyObj.DBLogId = getseqDBLogId(); historyObj.DBStatus = "Operational"; contextObj.DBLogHistories.Add(historyObj); contextObj.SaveChanges(); contextObj.DBIncidents.Remove(incidentObj); contextObj.SaveChanges(); } else { historyObj = new DBLogHistory(); //Adding log history historyObj.DBCompanyId = pCompanyId; historyObj.DBComponentName = componentObj.DBComponentName; historyObj.DBCSId = componentObj.DBCSId; historyObj.DBDateTimeStart = DateTime.UtcNow;; historyObj.DBDateTimeEnd = null; historyObj.DBIncidentId = incidentIdStoringVariable; historyObj.DBIncidentDetails = "Component Deleted"; historyObj.DBIncidentName = "Component Deleted"; historyObj.DBLogId = getseqDBLogId(); historyObj.DBStatus = "Operational"; contextObj.DBLogHistories.Add(historyObj); contextObj.SaveChanges(); } contextObj.DBComponent_With_Status.Remove(componentObj); contextObj.SaveChanges(); } }
//Incidents Save details method public string mSaveAddIncidentDetails(string pstringIncidentName, string pstringIncidentDetails, List <int> pstringComponentIdList, int pCompanyId) { try { WinMonitorEntityModelContext mDBContext = new WinMonitorEntityModelContext(); DBIncident mDBIncidentObj = new DBIncident(); DBLogHistory historyObj = new DBLogHistory(); foreach (int componentId in pstringComponentIdList) { mDBIncidentObj.DBIncidentId = getseqDBIncidentId(); mDBIncidentObj.DBIncidentName = pstringIncidentName; mDBIncidentObj.DBDescription = pstringIncidentDetails; mDBIncidentObj.DBCSId = componentId; //adds new incident to the incidents table mDBContext.DBIncidents.Add(mDBIncidentObj); mDBContext.SaveChanges(); //code to add details to log hisory historyObj.DBLogId = getseqDBLogId(); historyObj.DBCompanyId = pCompanyId; historyObj.DBCSId = componentId; historyObj.DBIncidentId = mDBIncidentObj.DBIncidentId; historyObj.DBComponentName = mDBContext.Database.SqlQuery <string>("select DBComponentName from DBComponent_With_Status where DBCSId=" + componentId + ";").FirstOrDefault(); historyObj.DBIncidentName = mDBIncidentObj.DBIncidentName; historyObj.DBIncidentDetails = mDBIncidentObj.DBDescription; historyObj.DBDateTimeStart = DateTime.UtcNow;; historyObj.DBStatus = mDBContext.Database.SqlQuery <string>("select DBStatus from DBComponent_With_Status where DBCSId=" + componentId + ";").FirstOrDefault(); historyObj.DBDateTimeEnd = null; //adds history obj to database mDBContext.DBLogHistories.Add(historyObj); //save the specific component details to the database mDBContext.SaveChanges(); } return("Incident Successfully added !!"); } catch (DbUpdateException exUpdateDB) { Console.Write(exUpdateDB); return("DbUpdateException"); } catch (DbEntityValidationException exEntityValidateDB) { Console.Write(exEntityValidateDB); return("DbEntityValidationException"); } catch (NotSupportedException exNotSupportedDB) { Console.Write(exNotSupportedDB); return("NotSupportedException"); } catch (ObjectDisposedException exObjectDisposedDB) { Console.Write(exObjectDisposedDB); return("ObjectDisposedException"); } catch (InvalidOperationException exInvalidOperationDB) { Console.Write(exInvalidOperationDB); return("InvalidOperationException"); } catch (Exception ex) { Console.Write(ex); return("Misllaneous Exception"); } }
//update staus of selected components public string UpdatingStatusOfComponentsSelected(List <int> pselectedComponentList, string pStatusToBeChanged, int pCompanyId) { try { WinMonitorEntityModelContext contextObj = new WinMonitorEntityModelContext(); DBLogHistory historyObj = new DBLogHistory(); DBCompany companyObj = new DBCompany(); string previousStatus; companyObj = (from company in contextObj.DBCompanies where company.DBCompanyId == pCompanyId select company).FirstOrDefault(); string strResult = String.Empty; if (pStatusToBeChanged == "Operational") { foreach (int componentId in pselectedComponentList) { DBComponent_With_Status componentObj = new DBComponent_With_Status(); DBIncident incidentObj = new DBIncident(); componentObj = (from component in contextObj.DBComponent_With_Status where component.DBCSId == componentId select component).FirstOrDefault(); if (companyObj.DBSecondaryCenter != componentObj.DBCenterName) { incidentObj = (from incident in contextObj.DBIncidents where incident.DBCSId == componentId select incident).FirstOrDefault(); if (incidentObj != null) { historyObj = (from histObj in contextObj.DBLogHistories where ((histObj.DBCompanyId == pCompanyId) && (histObj.DBCSId == componentId) && (histObj.DBIncidentId == incidentObj.DBIncidentId)) orderby histObj.DBDateTimeStart descending, histObj.DBDateTimeEnd descending select histObj).First(); historyObj.DBDateTimeEnd = DateTime.UtcNow;; contextObj.SaveChanges(); contextObj.DBIncidents.Remove(incidentObj); contextObj.SaveChanges(); } componentObj.DBStatus = pStatusToBeChanged; contextObj.SaveChanges(); } List <DBSubscription> subscriptionObjList = new List <DBSubscription>(); subscriptionObjList = (from subObj in contextObj.DBSubscriptions where subObj.DBCompanyId == pCompanyId select subObj).ToList(); DBEmailPage emailPageObj = new DBEmailPage(); emailPageObj = (from emailPage in contextObj.DBEmailPages where emailPage.DBEmailPageId == 1 select emailPage).FirstOrDefault(); foreach (DBSubscription subscriptionObj in subscriptionObjList) { PerformSubscription performSubscriptionObj = new PerformSubscription(); WebClient clientObj = new WebClient(); int endIndex, startIndex; string stringToBeReplaced; string stringHtml = emailPageObj.DBEmailContent.ToString(); endIndex = stringHtml.IndexOf("<!--end of eventsUpdateDiv-->"); startIndex = stringHtml.IndexOf("<div id=\"divForEvents\">"); stringToBeReplaced = stringHtml.Substring(startIndex, endIndex - startIndex); stringHtml = stringHtml.Replace(stringToBeReplaced, ""); endIndex = stringHtml.IndexOf("<!--end of dataCenterChangeUpdate-->"); startIndex = stringHtml.IndexOf("<div id=\"divForDataCenterUpdate\">"); stringToBeReplaced = stringHtml.Substring(startIndex, endIndex - startIndex); stringHtml = stringHtml.Replace(stringToBeReplaced, ""); string link = "http://cha-en-pdp2:2108/?pUserCompanyName=CompanyNameVariable"; //change url to direct to user page stringHtml = stringHtml.Replace("linkToBeChanged", link); stringHtml = stringHtml.Replace("CompanyNameVariable", companyObj.DBCompanyName); stringHtml = stringHtml.Replace("customerNameVariable", subscriptionObj.DBName); stringHtml = stringHtml.Replace("ComponentNameForStatusUpdateVariable", componentObj.DBComponentName); stringHtml = stringHtml.Replace("ComponentStatusUpdateVariable", componentObj.DBStatus); performSubscriptionObj.sendEmail(subscriptionObj.DBEmail, null, "Component Status Updated", stringHtml); } } strResult = "Incident Successfully deleted !!"; } else { foreach (int componentId in pselectedComponentList) { DBComponent_With_Status componentObj = new DBComponent_With_Status(); componentObj = (from component in contextObj.DBComponent_With_Status where component.DBCSId == componentId select component).FirstOrDefault(); previousStatus = componentObj.DBStatus; componentObj.DBStatus = pStatusToBeChanged; contextObj.SaveChanges(); DBIncident incidentObj = new DBIncident(); incidentObj = (from incident in contextObj.DBIncidents where incident.DBCSId == componentId select incident).FirstOrDefault(); //code to add details to log hisory historyObj.DBLogId = getseqDBLogId(); historyObj.DBCompanyId = pCompanyId; historyObj.DBCSId = componentId; historyObj.DBIncidentId = incidentObj.DBIncidentId; historyObj.DBComponentName = componentObj.DBComponentName; historyObj.DBIncidentName = incidentObj.DBIncidentName; historyObj.DBIncidentDetails = incidentObj.DBDescription; historyObj.DBDateTimeStart = DateTime.UtcNow;; historyObj.DBStatus = componentObj.DBStatus; historyObj.DBDateTimeEnd = null; List <DBSubscription> subscriptionObjList = new List <DBSubscription>(); subscriptionObjList = (from subObj in contextObj.DBSubscriptions where subObj.DBCompanyId == pCompanyId select subObj).ToList(); DBEmailPage emailPageObj = new DBEmailPage(); emailPageObj = (from emailPage in contextObj.DBEmailPages where emailPage.DBEmailPageId == 1 select emailPage).FirstOrDefault(); foreach (DBSubscription subscriptionObj in subscriptionObjList) { PerformSubscription performSubscriptionObj = new PerformSubscription(); WebClient clientObj = new WebClient(); int endIndex, startIndex; string stringToBeReplaced; string stringHtml = emailPageObj.DBEmailContent.ToString(); endIndex = stringHtml.IndexOf("<!--end of eventsUpdateDiv-->"); startIndex = stringHtml.IndexOf("<div id=\"divForEvents\">"); stringToBeReplaced = stringHtml.Substring(startIndex, endIndex - startIndex); stringHtml = stringHtml.Replace(stringToBeReplaced, ""); endIndex = stringHtml.IndexOf("<!--end of dataCenterChangeUpdate-->"); startIndex = stringHtml.IndexOf("<div id=\"divForDataCenterUpdate\">"); stringToBeReplaced = stringHtml.Substring(startIndex, endIndex - startIndex); stringHtml = stringHtml.Replace(stringToBeReplaced, ""); string link = "http://cha-en-pdp2:2108/?pUserCompanyName=CompanyNameVariable"; //change url to direct to user page stringHtml = stringHtml.Replace("linkToBeChanged", link); stringHtml = stringHtml.Replace("CompanyNameVariable", companyObj.DBCompanyName); stringHtml = stringHtml.Replace("customerNameVariable", subscriptionObj.DBName); stringHtml = stringHtml.Replace("ComponentNameForStatusUpdateVariable", componentObj.DBComponentName); stringHtml = stringHtml.Replace("ComponentStatusUpdateVariable", componentObj.DBStatus); performSubscriptionObj.sendEmail(subscriptionObj.DBEmail, null, "Component Status Updated", stringHtml); } } strResult = "Incident Successfully added !!"; } return(strResult); } catch (DbUpdateException exUpdateDB) { Console.Write(exUpdateDB); return("DbUpdateException"); } catch (DbEntityValidationException exEntityValidateDB) { Console.Write(exEntityValidateDB); return("DbEntityValidationException"); } catch (NotSupportedException exNotSupportedDB) { Console.Write(exNotSupportedDB); return("NotSupportedException"); } catch (ObjectDisposedException exObjectDisposedDB) { Console.Write(exObjectDisposedDB); return("ObjectDisposedException"); } catch (InvalidOperationException exInvalidOperationDB) { Console.Write(exInvalidOperationDB); return("InvalidOperationException"); } catch (Exception ex) { Console.Write(ex); return("Misllaneous Exception"); } }