Exemple #1
0
        /// <summary>
        /// Get a single company by id. Only active companies will be returned.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Company GetCompanyById(int id)
        {
            string query = @"SELECT b.*, l.land_naam, GROUP_CONCAT(DISTINCT o.opl_naam) as opleidingen, 
                    IF(r.review_sterren IS NULL, 0,
                            CASE WHEN COUNT(r.review_sterren) > 0
                            THEN AVG(r.review_sterren)
                            ELSE 0 END
                       ) as average_reviews,
                    IF(r.review_sterren IS NULL, 0,
                            CASE WHEN COUNT(r.review_sterren) > 0
                            THEN COUNT(r.review_sterren)
                            ELSE 0 END
                       ) as amount_reviews
                FROM reg_bedrijven b
                LEFT JOIN reg_landen l ON b.bedrijf_vestiging_land = l.land_id
                LEFT JOIN reg_reviews r ON b.bedrijf_id = r.review_bedrijf_id
                LEFT JOIN reg_opleiding_per_bedrijf ob ON b.bedrijf_id = ob.opb_bedrijf_id
                LEFT JOIN reg_opleidingen o ON ob.opb_opleiding_id = o.opl_id
                WHERE b.bedrijf_id = @id AND b.bedrijf_actief = 1
                GROUP BY b.bedrijf_id";

            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@id", id);

            DBCompany dbCompany = this.companyRepository.GetCompany(query, parameters);

            return(this.mapper.Map <Company>(dbCompany));
        }
        //method to populate data center list on component page
        public DBCompany populatingDataCenterListOnComponentPage(int pstrCompanyId)
        {
            WinMonitorEntityModelContext contextObj = new WinMonitorEntityModelContext();
            DBCompany companyObj = new DBCompany();

            companyObj = contextObj.Database.SqlQuery <DBCompany>("select * from DBCompany where DBCompanyId=" + pstrCompanyId + ";").FirstOrDefault();
            return(companyObj);
        }
Exemple #3
0
        public Company(DBCompany comp)
        {
            Id              = comp.CompanyId;
            Name            = comp.Name;
            NeedMeasureDays = comp.NeedsDaysMeasured;

            FindLogo(comp.Logo);
        }
        //method to change data center of components list selected
        public void ChangingDataCenter(List <int> mListOfCheckBoxes, int pstrCompanyId, string pstrDataCenterSelected)
        {
            WinMonitorEntityModelContext contextObj = new WinMonitorEntityModelContext();
            DBCompany companyObj = new DBCompany();

            companyObj = (from company in contextObj.DBCompanies
                          where company.DBCompanyId == pstrCompanyId
                          select company).FirstOrDefault();
            foreach (int componentId in mListOfCheckBoxes)
            {
                DBComponent_With_Status componentObj = new DBComponent_With_Status();
                componentObj = (from component in contextObj.DBComponent_With_Status
                                where component.DBCSId == componentId
                                select component).FirstOrDefault();
                componentObj.DBCenterName = pstrDataCenterSelected;
                contextObj.SaveChanges();
                List <DBSubscription> subscriptionObjList = new List <DBSubscription>();
                subscriptionObjList = (from subObj in contextObj.DBSubscriptions
                                       where subObj.DBCompanyId == pstrCompanyId
                                       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 componentStatusChangeDiv-->");
                    startIndex         = stringHtml.IndexOf("<div id=\"divForComponentStatusUpdate\">");
                    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("ComponentNameForDataCenterUpdateVariable", componentObj.DBComponentName);
                    stringHtml = stringHtml.Replace("DataCenterVariable", componentObj.DBCenterName);

                    performSubscriptionObj.sendEmail(subscriptionObj.DBEmail, null, "Data Center Updated", stringHtml);
                }
            }
        }
Exemple #5
0
        //function to update events in Database
        public void UpdatingCalenderInDB(int pstrEventId, DateTime pstrNewEventStart, DateTime pstrNewEventEnd)
        {
            WinMonitorEntityModelContext contextObj = new WinMonitorEntityModelContext();
            DBCalendar calenderObj = new DBCalendar();

            calenderObj = (from calenderEvent in contextObj.DBCalendars
                           where calenderEvent.DBEventId == pstrEventId
                           select calenderEvent).FirstOrDefault();
            if (calenderObj.DBEventStatus == "Active")
            {
                calenderObj.DBEventStartTime = pstrNewEventStart;
                calenderObj.DBEventEndTime   = pstrNewEventEnd;
                contextObj.SaveChanges();
                DBCompany companyObj = new DBCompany();
                companyObj = (from company in contextObj.DBCompanies
                              where company.DBCompanyId == calenderObj.DBCompanyId
                              select company).FirstOrDefault();
                List <DBSubscription> subscriptionObjList = new List <DBSubscription>();
                subscriptionObjList = (from subObj in contextObj.DBSubscriptions
                                       where subObj.DBCompanyId == calenderObj.DBCompanyId
                                       select subObj).ToList();
                DBCalendar calEvent = new DBCalendar();
                calEvent = (from calObj in contextObj.DBCalendars
                            where calObj.DBEventId == pstrEventId
                            select calObj).FirstOrDefault();
                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 stringHtml = emailPageObj.DBEmailContent.ToString();

                    endIndex   = stringHtml.IndexOf("<!--end of componentUpdateDiv-->");
                    startIndex = stringHtml.IndexOf("<div id=\"divForComponentUpdates\">");
                    string 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("EventNameVariable", calEvent.DBEventTitle);
                    stringHtml = stringHtml.Replace("EventDetailsVariable", calEvent.DBEventDetails);
                    stringHtml = stringHtml.Replace("EventStartTimeVariable", calEvent.DBEventStartTime.ToString());
                    stringHtml = stringHtml.Replace("EventEndTimeVariable", calEvent.DBEventEndTime.ToString());
                    performSubscriptionObj.sendEmail(subscriptionObj.DBEmail, null, "Event Schedule Updated", stringHtml);
                }
            }
        }
        public string mSaveAddCompanyDetails(string pstringCompanyName, string pstringURL, string pstringPrimarySelect, string pstringSecondarySelect)
        {
            try
            {
                WinMonitorEntityModelContext mDBContext = new WinMonitorEntityModelContext();
                DBCompany mDBCompanyObj = new DBCompany();


                mDBCompanyObj.DBCompanyId       = getseqDBCompanyId();
                mDBCompanyObj.DBCompanyName     = pstringCompanyName;
                mDBCompanyObj.DBURL             = pstringURL;
                mDBCompanyObj.DBPrimaryCenter   = pstringPrimarySelect;
                mDBCompanyObj.DBSecondaryCenter = pstringSecondarySelect;

                //adds new to the company
                mDBContext.DBCompanies.Add(mDBCompanyObj);

                //save the company details to the database
                mDBContext.SaveChanges();
                return("Company Successfully added !!");
            }
            catch (DbUpdateException exUpdateDB)
            {
                Console.Write(exUpdateDB);
                return("DbUpdateException, Duplicate Company");
            }
            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");
            }
        }
Exemple #7
0
        public static bool CheckDiskSpace()
        {
            bool RetVal       = false;
            long MaxDiskSpace = PortalConfig.DatabaseSize;

            if (MaxDiskSpace == -1)
            {
                RetVal = true;
            }
            else
            {
                RetVal = (DBCompany.GetDatabaseSize() < (MaxDiskSpace * 1024 * 1024)) ? true : false;
            }

            return(RetVal);
        }
Exemple #8
0
 public static long GetDatabaseSize()
 {
     return(DBCompany.GetDatabaseSize());
 }
        public int GetNumCompanies(string filter, int mode)
        {
            int numCompanies = DBCompany.GetNumCompanies(filter, mode);

            return(numCompanies);
        }
        public List <Companies> Pagination(int pageNum, string filter, int mode)
        {
            List <Companies> m_Companies = DBCompany.Pagination(pageNum, filter, mode);

            return(m_Companies);
        }
        public List <GlobalDataTypes.ContactSelect> GetContacts(int id)
        {
            List <GlobalDataTypes.ContactSelect> m_Contacts = DBCompany.GetContacts(id);

            return(m_Contacts);
        }
        public List <CompanyType> GetCompanyTypes()
        {
            List <CompanyType> m_CompanyTypes = DBCompany.GetCompanyTypes();

            return(m_CompanyTypes);
        }
        public Companies RetrieveOne(int id)
        {
            Companies m_Company = DBCompany.RetrieveOne(id);

            return(m_Company);
        }
 public void UpdateCompany(Companies m_Company)
 {
     DBCompany.UpdateCompany(m_Company);
 }
 public void AddCompany(Companies m_Company)
 {
     DBCompany.AddCompany(m_Company);
 }
Exemple #16
0
        //Admin Maintenance Calendar

        //AddEVent In Calendar
        public string mSaveCalendarEvent(string pstrTitle, string pstrDetails, string pstrStartTime, string pstrEndTime, string pstrEventFor, string pstrMaintenance, int pstrCompanyId)
        {
            try
            {
                WinMonitorEntityModelContext mDBContext = new WinMonitorEntityModelContext();
                if (pstrEventFor == "all")
                {
                    List <DBCompany> companyList = new List <DBCompany>();
                    companyList = (from company in mDBContext.DBCompanies
                                   select company).ToList();
                    foreach (DBCompany companyObj in companyList)
                    {
                        DBCalendar CalObj = new DBCalendar();
                        CalObj.DBEventId      = getseqDBCalEventId();
                        CalObj.DBEventTitle   = pstrTitle;
                        CalObj.DBEventDetails = pstrDetails;

                        DateTime mdateStartTime = DateTime.Parse(pstrStartTime);
                        CalObj.DBEventStartTime = mdateStartTime;

                        DateTime mdateEndTime = DateTime.Parse(pstrEndTime);
                        CalObj.DBEventEndTime = mdateEndTime;

                        CalObj.DBEventDifferenceTime = mdateEndTime.Subtract(mdateStartTime).ToString();

                        CalObj.DBEventMaintenance = pstrMaintenance;

                        CalObj.DBCompanyId = companyObj.DBCompanyId;

                        TimeSpan mstrRecordState = mdateEndTime.Subtract(DateTime.UtcNow);
                        if (mstrRecordState.TotalMinutes > 0)
                        {
                            CalObj.DBEventStatus = "Active";
                        }
                        else
                        {
                            CalObj.DBEventStatus = "Inactive";
                        }


                        mDBContext.DBCalendars.Add(CalObj);
                        mDBContext.SaveChanges();

                        List <DBSubscription> subscriptionObjList = new List <DBSubscription>();
                        subscriptionObjList = (from subObj in mDBContext.DBSubscriptions
                                               where subObj.DBCompanyId == companyObj.DBCompanyId
                                               select subObj).ToList();
                        DBEmailPage emailPageObj = new DBEmailPage();
                        emailPageObj = (from emailPage in mDBContext.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 stringHtml = emailPageObj.DBEmailContent.ToString();

                            endIndex   = stringHtml.IndexOf("<!--end of componentUpdateDiv-->");
                            startIndex = stringHtml.IndexOf("<div id=\"divForComponentUpdates\">");
                            string 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("EventNameVariable", CalObj.DBEventTitle);
                            stringHtml = stringHtml.Replace("EventDetailsVariable", CalObj.DBEventDetails);
                            stringHtml = stringHtml.Replace("EventStartTimeVariable", CalObj.DBEventStartTime.ToString());
                            stringHtml = stringHtml.Replace("EventEndTimeVariable", CalObj.DBEventEndTime.ToString());
                            performSubscriptionObj.sendEmail(subscriptionObj.DBEmail, null, "New Event Scheduled", stringHtml);
                        }
                    }
                }
                else
                {
                    DBCalendar CalObj = new DBCalendar();
                    CalObj.DBEventId      = getseqDBCalEventId();
                    CalObj.DBEventTitle   = pstrTitle;
                    CalObj.DBEventDetails = pstrDetails;

                    DateTime mdateStartTime = DateTime.Parse(pstrStartTime);
                    CalObj.DBEventStartTime = mdateStartTime;

                    DateTime mdateEndTime = DateTime.Parse(pstrEndTime);
                    CalObj.DBEventEndTime = mdateEndTime;

                    CalObj.DBEventDifferenceTime = mdateEndTime.Subtract(mdateStartTime).ToString();

                    //CalObj.DBEventRepetition = pstrEventFor;
                    CalObj.DBEventMaintenance = pstrMaintenance;

                    CalObj.DBCompanyId = pstrCompanyId;

                    TimeSpan mstrRecordState = mdateEndTime.Subtract(DateTime.UtcNow);
                    if (mstrRecordState.TotalMinutes > 0)
                    {
                        CalObj.DBEventStatus = "Active";
                    }
                    else
                    {
                        CalObj.DBEventStatus = "Inactive";
                    }


                    mDBContext.DBCalendars.Add(CalObj);
                    mDBContext.SaveChanges();

                    DBCompany companyObj = new DBCompany();
                    companyObj = (from company in mDBContext.DBCompanies
                                  where company.DBCompanyId == pstrCompanyId
                                  select company).FirstOrDefault();
                    List <DBSubscription> subscriptionObjList = new List <DBSubscription>();
                    subscriptionObjList = (from subObj in mDBContext.DBSubscriptions
                                           where subObj.DBCompanyId == pstrCompanyId
                                           select subObj).ToList();
                    DBEmailPage emailPageObj = new DBEmailPage();
                    emailPageObj = (from emailPage in mDBContext.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 stringHtml = emailPageObj.DBEmailContent.ToString();

                        endIndex   = stringHtml.IndexOf("<!--end of componentUpdateDiv-->");
                        startIndex = stringHtml.IndexOf("<div id=\"divForComponentUpdates\">");
                        string 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("EventNameVariable", CalObj.DBEventTitle);
                        stringHtml = stringHtml.Replace("EventDetailsVariable", CalObj.DBEventDetails);
                        stringHtml = stringHtml.Replace("EventStartTimeVariable", CalObj.DBEventStartTime.ToString());
                        stringHtml = stringHtml.Replace("EventEndTimeVariable", CalObj.DBEventEndTime.ToString());
                        performSubscriptionObj.sendEmail(subscriptionObj.DBEmail, null, "New Event Scheduled", stringHtml);
                    }
                }



                return("Event Saved Sucessfully!!");
            }
            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");
            }
        }
        public List <Companies> RetrieveAll()
        {
            List <Companies> m_Companies = DBCompany.RetrieveAll();

            return(m_Companies);
        }
        //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");
            }
        }