Пример #1
0
        protected void Application_Error(object sender, EventArgs e)
        {
            try
            {
                Exception ex = Server.GetLastError().GetBaseException();
                //Exception ex = Server.GetLastError();

                if (ex != null)
                {
                    HttpContext.Current.Session["LastError"] = ex;

                    Guid errorIndex = Guid.NewGuid();

                    SQMLogger.LogException(ex, errorIndex);

                    if (HttpContext.Current.Session != null)
                    {
                        HttpContext.Current.Session["ErrorIndex"] = errorIndex.ToString();
                        //BDW: comment out redirect to error page for now, because we don't
                        //     want to mask exceptions while in development mode.
                        //Response.Redirect("Error.aspx", false);
                    }
                }
            }
            catch { }
            //Server.ClearError();
        }
Пример #2
0
        public static List <NONCONFORMANCE> SelectNonconfList(string problemArea, bool activeOnly)
        {
            List <NONCONFORMANCE> nonconfList = null;

            try
            {
                using (PSsqmEntities ctx = new PSsqmEntities())
                {
                    if (string.IsNullOrEmpty(problemArea))
                    {
                        nonconfList = (from m in ctx.NONCONFORMANCE
                                       where (m.NONCONF_CATEGORY != null)
                                       select m).OrderBy(l => l.PROBLEM_AREA).ThenBy(l => l.NONCONF_CD).ToList();
                    }
                    else
                    {
                        nonconfList = (from m in ctx.NONCONFORMANCE
                                       where (m.NONCONF_CATEGORY != null && m.PROBLEM_AREA == problemArea)
                                       select m).OrderBy(l => l.NONCONF_CD).ToList();
                    }

                    if (activeOnly)
                    {
                        nonconfList = nonconfList.ToList().FindAll(l => l.STATUS == "A");
                    }
                }
            }
            catch (Exception e)
            {
                SQMLogger.LogException(e);
            }

            return(nonconfList);
        }
Пример #3
0
        //public static VIDEO_FILE SelectVideoFileById(decimal videoId)
        //{
        //	var entities = new PSsqmEntities();
        //	return (from i in entities.VIDEO_FILE where i.VIDEO_ID == videoId select i).FirstOrDefault();
        //}

        /// <summary>
        /// Delete all information for a specific video.
        /// </summary>
        /// <param name="videoId"></param>
        /// <param name="fileName"></param> Filename specified on the video record. Must be provided for file extension info.
        /// <returns></returns>
        public static int DeleteVideo(decimal videoId, string fileName)
        {
            int    status = 0;
            string delCmd = " IN (" + videoId + ") ";

            using (PSsqmEntities ctx = new PSsqmEntities())
            {
                try
                {
                    // delete all attachments
                    List <decimal> attachmentIds = (from a in ctx.VIDEO_ATTACHMENT
                                                    where a.VIDEO_ID == videoId
                                                    select a.VIDEO_ATTACH_ID).ToList();

                    if (attachmentIds != null && attachmentIds.Count > 0)
                    {
                        status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO_ATTACHMENT_FILE WHERE VIDEO_ATTACH_ID IN (" + String.Join(",", attachmentIds) + ")");
                        status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO_ATTACHMENT WHERE VIDEO_ATTACH_ID IN (" + String.Join(",", attachmentIds) + ")");
                    }

                    // delete the video from the Azure blob
                    // Retrieve storage account from connection string.
                    List <SETTINGS> sets               = SQMSettings.SelectSettingsGroup("MEDIA_UPLOAD", "");
                    string          storageContainer   = sets.Find(x => x.SETTING_CD == "STORAGE_CONTAINER").VALUE.ToString();
                    string          storageURL         = sets.Find(x => x.SETTING_CD == "STORAGE_URL").VALUE.ToString();
                    string          storageQueryString = sets.Find(x => x.SETTING_CD == "STORAGE_QUERY").VALUE.ToString();
                    string          fileType           = Path.GetExtension(fileName);
                    try
                    {
                        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                            CloudConfigurationManager.GetSetting("StorageConnectionString"));

                        // Create the blob client.
                        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                        // Retrieve reference to a previously created container.
                        CloudBlobContainer container = blobClient.GetContainerReference(storageContainer);

                        // Retrieve reference to a blob named "myblob.txt".
                        CloudBlockBlob blockBlob = container.GetBlockBlobReference(videoId.ToString() + fileType);

                        // Delete the blob.
                        blockBlob.Delete();
                    }
                    catch (Exception videoEx)
                    {
                        // what to do if there is an exception? Just log the exception for now
                        SQMLogger.LogException(videoEx);
                    }
                    // delete the video header
                    status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO WHERE VIDEO_ID" + delCmd);
                }
                catch (Exception ex)
                {
                    SQMLogger.LogException(ex);
                }
            }

            return(status);
        }
Пример #4
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     try
     {
         RegisterAppPage(WebSiteCommon.CleanPageName(Request.Path));
     }
     catch (Exception exp)
     {
         SQMLogger.LogException(exp);
     }
 }
Пример #5
0
        public static int DeleteAuditScheduler(decimal auditScheduleId)
        {
            int    status = 0;
            string delCmd = " IN (" + auditScheduleId + ") ";

            using (PSsqmEntities ctx = new PSsqmEntities())
            {
                try
                {
                    status = ctx.ExecuteStoreCommand("DELETE FROM AUDIT_SCHEDULER WHERE AUDIT_SCHEDULER_ID" + delCmd);
                }
                catch (Exception ex)
                {
                    SQMLogger.LogException(ex);
                }
            }

            return(status);
        }
Пример #6
0
        public static int DeleteIncident(decimal incidentId)
        {
            int    status = 0;
            string delCmd = " IN (" + incidentId + ") ";

            using (PSsqmEntities ctx = new PSsqmEntities())
            {
                try
                {
                    decimal probCaseId = (from po in ctx.PROB_OCCUR where po.INCIDENT_ID == incidentId select po.PROBCASE_ID).FirstOrDefault();

                    if (probCaseId > 0)
                    {
                        status = ProblemCase.DeleteProblemCase(probCaseId);
                    }

                    List <decimal> attachmentIds = (from a in ctx.ATTACHMENT where a.RECORD_TYPE == 40 && a.RECORD_ID == incidentId
                                                    select a.ATTACHMENT_ID).ToList();

                    if (attachmentIds != null && attachmentIds.Count > 0)
                    {
                        status = ctx.ExecuteStoreCommand("DELETE FROM ATTACHMENT_FILE WHERE ATTACHMENT_ID IN (" + String.Join(",", attachmentIds) + ")");
                        status = ctx.ExecuteStoreCommand("DELETE FROM ATTACHMENT WHERE ATTACHMENT_ID IN (" + String.Join(",", attachmentIds) + ")");
                    }

                    status = ctx.ExecuteStoreCommand("DELETE FROM PROB_OCCUR WHERE INCIDENT_ID" + delCmd);
                    status = ctx.ExecuteStoreCommand("DELETE FROM INCIDENT_ANSWER WHERE INCIDENT_ID" + delCmd);
                    status = ctx.ExecuteStoreCommand("DELETE FROM INCIDENT WHERE INCIDENT_ID" + delCmd);
                }
                catch (Exception ex)
                {
                    SQMLogger.LogException(ex);
                }
            }

            return(status);
        }
Пример #7
0
        /// <summary>
        ///  Delete a ALL Video and attachment records for a specific source (Incident/Audit)
        /// </summary>
        /// <param name="sourceId"></param>
        /// <param name="sourceType"></param>
        /// <param name="sourceStep"></param> This is the question Id for Audit videos. If left blank, all videos for a specific audit will be deleted
        /// <returns></returns>
        public static int DeleteAllSourceVideos(decimal sourceId, int sourceType, string sourceStep)
        {
            int status = 0;
            var videos = new List <VIDEO>();

            using (PSsqmEntities ctx = new PSsqmEntities())
            {
                try
                {
                    // select all videos for a source Id & source type
                    if (sourceStep.Trim().Length > 0)
                    {
                        videos = (from i in ctx.VIDEO
                                  where (i.SOURCE_ID == sourceId && i.SOURCE_TYPE == sourceType && i.SOURCE_STEP == sourceStep.Trim())
                                  orderby i.VIDEO_ID descending
                                  select i).ToList();
                    }
                    else
                    {
                        videos = (from i in ctx.VIDEO
                                  where (i.SOURCE_ID == sourceId && i.SOURCE_TYPE == sourceType)
                                  orderby i.VIDEO_ID descending
                                  select i).ToList();
                    }
                    decimal[] ids = videos.Select(v => v.VIDEO_ID).Distinct().ToArray();

                    // delete all attachments for all the videos
                    List <decimal> attachmentIds = (from a in ctx.VIDEO_ATTACHMENT
                                                    where ids.Contains(a.VIDEO_ID)
                                                    select a.VIDEO_ATTACH_ID).ToList();

                    if (attachmentIds != null && attachmentIds.Count > 0)
                    {
                        status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO_ATTACHMENT_FILE WHERE VIDEO_ATTACH_ID IN (" + String.Join(",", attachmentIds) + ")");
                        status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO_ATTACHMENT WHERE VIDEO_ATTACH_ID IN (" + String.Join(",", attachmentIds) + ")");
                    }


                    // delete the videos from the Azure blob
                    // Retrieve storage account from connection string.
                    List <SETTINGS> sets               = SQMSettings.SelectSettingsGroup("MEDIA_UPLOAD", "");
                    string          storageContainer   = sets.Find(x => x.SETTING_CD == "STORAGE_CONTAINER").VALUE.ToString();
                    string          storageURL         = sets.Find(x => x.SETTING_CD == "STORAGE_URL").VALUE.ToString();
                    string          storageQueryString = sets.Find(x => x.SETTING_CD == "STORAGE_QUERY").VALUE.ToString();
                    foreach (VIDEO video in videos)
                    {
                        string fileType = Path.GetExtension(video.FILE_NAME);
                        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                            CloudConfigurationManager.GetSetting("StorageConnectionString"));

                        // Create the blob client.
                        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                        // Retrieve reference to a previously created container.
                        CloudBlobContainer container = blobClient.GetContainerReference(storageContainer);

                        // Retrieve reference to a blob named "myblob.txt".
                        CloudBlockBlob blockBlob = container.GetBlockBlobReference(video.VIDEO_ID.ToString() + fileType);

                        // Delete the blob.
                        blockBlob.Delete();
                    }

                    // delete the video headers
                    if (sourceStep.Trim().Length > 0)
                    {
                        status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO WHERE SOURCE_ID = " + sourceId + " AND SOURCE_TYPE = " + sourceType + " AND SOURCE_STEP = '" + sourceStep.Trim() + "'");
                    }
                    else
                    {
                        status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO WHERE SOURCE_ID = " + sourceId + " AND SOURCE_TYPE = " + sourceType);
                    }
                }
                catch (Exception ex)
                {
                    SQMLogger.LogException(ex);
                }
            }

            return(status);
        }