public override void OnException(HttpActionExecutedContext actionExecutedContext) { var actionContext = actionExecutedContext.ActionContext; var logItem = new ExceptionLog(true) { ActionName = actionContext.ActionDescriptor.ActionName, ControllerName = actionContext.ControllerContext.ControllerDescriptor.ControllerName, //TODO: Browser = tespit edilecek, ErrorCode = actionExecutedContext.Exception.HResult, InnerException = actionExecutedContext.Exception.InnerException == null ? null : actionExecutedContext.Exception.InnerException.Message, Exception = actionExecutedContext.Exception.Message, //TODO: Ip = tespit edilecek, //TODO: Url = tespit edilecek }; UnitOfWorkData.ExceptionLogRepository.Insert(logItem); UnitOfWorkData.ExceptionLogRepository.Save(); //var res = actionExecutedContext.Exception.Message; //HttpResponseMessage response = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError) //{ // Content = new StringContent(res), // ReasonPhrase = res //}; //actionExecutedContext.Response = response; }
public WBSPGHelper(System.Web.SessionState.HttpSessionState session, System.Web.UI.Page page, FileLog eventLog, ExceptionLog exceptionEventLog, bool isProduction) { Session = session; Page = page; objEventLog = eventLog; objExceptionEventLog = exceptionEventLog; bIsProduction = isProduction; return; }
public DeviceAtlasData(FileLog objEventLog, ExceptionLog objExceptionEventLog) { Tree = null; try { Tree = Api.GetTreeFromFile((string)ConfigurationManager.AppSettings["DeviceAtlasDataPath"]); } catch (Exception e) { objExceptionEventLog.Write("Exception while reading DA hash tree from file: ", e); } return; }
public static DeviceAtlasData GetDeviceAtlasData(Cache objCache, FileLog objEventLog, ExceptionLog objExceptionEventLog) { DeviceAtlasData objDeviceAtlasData = null; lock (DeviceAtlasData.CacheLock) { if (objCache["DeviceAtlasData"] != null) { objDeviceAtlasData = (DeviceAtlasData)objCache["DeviceAtlasData"]; } else { objDeviceAtlasData = new DeviceAtlasData(objEventLog, objExceptionEventLog); objCache.Add("DeviceAtlasData", objDeviceAtlasData, null, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.NotRemovable, null); } } return objDeviceAtlasData; }
/// <summary> /// Gets the related exception logs /// </summary> /// <param name="baseException">The base exception.</param> /// <returns>List of Exception Detail Summary objects</returns> private List<ExceptionLog> GetExceptionLogs( ExceptionLog baseException ) { List<ExceptionLog> exceptionList = new List<ExceptionLog>(); ExceptionLogService svc = new ExceptionLogService( new RockContext() ); //load the base exception exceptionList.Add( baseException ); //get the parentID int? parentId = baseException.ParentId; //loop through exception hierarchy (parent, grandparent, etc) while ( parentId != null && parentId > 0 ) { var exception = svc.Get( (int)parentId ); if ( exception != null ) { exceptionList.Add( exception ); } parentId = exception.ParentId; } //get inner exceptions if ( baseException.HasInnerException != null && (bool)baseException.HasInnerException ) { exceptionList.AddRange( svc.GetByParentId( baseException.Id ) ); } return exceptionList; }
protected virtual void Page_Init(object sender, EventArgs e) { dtPageStartTime = DateTime.Now; if (Context.Session != null) { bool bIsNewSessionOverride = false; if (Context.Items["IsNewSessionOverride"] != null) bIsNewSessionOverride = (bool)Context.Items["IsNewSessionOverride"]; if (Session.IsNewSession && !bIsNewSessionOverride) { Response.Redirect("~/Default.aspx"); return; } } bIsProduction = XnGR_WBS_Page.IsProductionMode(); if (ConfigurationManager.AppSettings["WBSBookingMode"] == "Production") bIsBookThrough = true; else bIsBookThrough = false; if (ConfigurationManager.AppSettings["GuestDetailsTestPrefill"] == "1") bIsGuestDetailsTestPrefill = true; else bIsGuestDetailsTestPrefill = false; bIsParentPreRender = false; bIsDeepLinkNav = false; objEventLog = (FileLog)Application["EventLog"]; objExceptionEventLog = (ExceptionLog)Application["ExceptionEventLog"]; wbsAPIRouter = WBSAPIRouter.GetWbsApiRouter(Context.Cache, objEventLog, objExceptionEventLog, bIsProduction, (int)Application["WBSAPIRouter.RequestExpirationSeconds"], (int)Application["WBSAPIRouter.WindowUnitSeconds"], (int)Application["WBSAPIRouter.WindowUnits"]); wbsAPIRouterData = null; wbsIISAsyncResult = null; wbsAPI = new WBSAPIRouterHelper(Session, Page, objEventLog, objExceptionEventLog, bIsProduction); wbsPG = new WBSPGHelper(Session, Page, objEventLog, objExceptionEventLog, bIsProduction); wbsUI = new WBSUIHelper(Session, Page); wbsPerfCounters = WBSPerfCounters.GetWbsPerfCounters(Context.Cache, objEventLog, objExceptionEventLog, (string)Application["WBSPerfCounters.PerformanceMonitorGroupName"]); wbsServiceTimesUpdater = WBSServiceTimesUpdater.GetWbsServiceTimesUpdater(Context.Cache, objEventLog, objExceptionEventLog, bIsProduction, (int)Application["WBSAPIRouter.RequestExpirationSeconds"], (int)Application["WBSAPIRouter.WindowUnitSeconds"], (int)Application["WBSAPIRouter.WindowUnits"], (string)Application["WBSPerfCounters.PerformanceMonitorGroupName"]); // retrieved only as a "keep-alive" mechanism wbsMonitor = WBSMonitor.GetWbsMonitor(Context.Cache, objEventLog, objExceptionEventLog, bIsProduction, (int)Application["WBSMonitor.ExpirationSeconds"]); // Used for pending prepay bookings logging this.InitPageErrors(); if (!IsPostBack) { if (Request.QueryString.Get("CrossPageErrors") == "1") this.RestoreCrossPageErrors(); if (Request.QueryString.Get("DeepLinkNav") == "1") // used wtih Response.Redirect bIsDeepLinkNav = true; if ((string)Context.Items["DeepLinkNav"] == "1") // used with Server.Transfer bIsDeepLinkNav = true; } return; }
public ActionResult AddApplyLeave(string EmployeeID, string FromDate, string ToDate, string LeaveTypeId, string LeaveReasonId, string Description) { string Message = string.Empty; ExceptionLog.WriteDebugLog("methodname:SaveDocuments", "FromDate=" + FromDate + "ToDate=" + ToDate + "EmployeeID=" + EmployeeID + "LeaveTypeId=" + LeaveTypeId + "LeaveReasonId=" + LeaveReasonId + "Description=" + Description); try { HttpPostedFileBase file1 = null; string fname1 = ""; LMS _LMS = new LMS(); _LMS.BusinessId = BusinessId; _LMS.UserId = UserId; _LMS.UserEmployeeId = Convert.ToInt32(EmployeeID); _LMS.FromDate = DateTime.ParseExact(FromDate, "MM/dd/yyyy", null); _LMS.ToDate = DateTime.ParseExact(ToDate, "MM/dd/yyyy", null); _LMS.LeaveTypeId = Convert.ToInt32(LeaveTypeId); _LMS.LeaveReasonId = Convert.ToInt32(LeaveReasonId); _LMS.CurrentLeaveBalance = 0; _LMS.EffectiveLeave = 0; _LMS.Description = Description; if (Request.Files.Count > 0) { HttpFileCollectionBase files1 = Request.Files; for (int i = 0; i < files1.Count; i++) { file1 = files1[i]; if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file1.FileName.Split(new char[] { '\\' }); fname1 = testfiles[testfiles.Length - 1]; } else { fname1 = file1.FileName; } } } //_DocumentCabinet.FilePath =Path.Combine(ConfigurationManager.AppSettings["FilepathPdf"].ToString()); _LMS.FilePath = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["LeavesFilePath"].ToString()), fname1); CommonMessages MessagesObj = new CommonMessages(); MessagesObj = BAL.LMSBAL.SaveEmployeeLeave(_LMS); if (MessagesObj.Result > 0) { string extension = Path.GetExtension(fname1); fname1 = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["LeavesFilePath"].ToString()), MessagesObj.Result + extension); if (System.IO.File.Exists(fname1)) { System.IO.FileInfo fileinfo = new System.IO.FileInfo(fname1); fileinfo.Delete(); file1.SaveAs(fname1); } else { //file1.SaveAs(fname1); } Message = EMSResources.SavedSuccessfully; } else { Message = MessagesObj.Message; } return(Json(Message, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ExceptionLog.WriteLog(ex, "Method:AddApplyLeave,Parameters: EmployeeID=" + EmployeeID + ",FromDate=" + FromDate + ",ToDate=" + ToDate + ",LeaveTypeId=" + LeaveTypeId + ",LeaveReasonId=" + LeaveReasonId + ",Description=" + Description); ErrorSignal.FromCurrentContext().Raise(ex); return(null); } }
/// <summary> /// Populates the <see cref="Rock.Model.ExceptionLog" /> entity with the exception data. /// </summary> /// <param name="ex">The <see cref="System.Exception" /> to log.</param> /// <param name="context">The <see cref="System.Web.HttpContext" />.</param> /// <param name="pageId">An <see cref="System.Int32" /> containing the Id of the <see cref="Rock.Model.Page" /> where the exception occurred. /// This value is nullable.</param> /// <param name="siteId">An <see cref="System.Int32" /> containing the Id the <see cref="Rock.Model.Site" /> where the exception occurred. /// This value is nullable.</param> /// <param name="personAlias">The person alias.</param> /// <returns></returns> private static ExceptionLog PopulateExceptionLog( Exception ex, HttpContext context, int? pageId, int? siteId, PersonAlias personAlias ) { int? personAliasId = null; if (personAlias != null) { personAliasId = personAlias.Id; } var exceptionLog = new ExceptionLog { SiteId = siteId, PageId = pageId, HasInnerException = ex.InnerException != null, ExceptionType = ex.GetType().ToString(), Description = ex.Message, Source = ex.Source, StackTrace = ex.StackTrace, Guid = Guid.NewGuid(), CreatedByPersonAliasId = personAliasId, ModifiedByPersonAliasId = personAliasId, CreatedDateTime = RockDateTime.Now, ModifiedDateTime = RockDateTime.Now }; try { // If current HttpContext is null, return early. if ( context == null ) { return exceptionLog; } // If current HttpContext is available, populate its information as well. var request = context.Request; StringBuilder cookies = new StringBuilder(); var cookieList = request.Cookies; if ( cookieList.Count > 0 ) { cookies.Append( "<table class=\"cookies exception-table\">" ); foreach ( string cookie in cookieList ) { var httpCookie = cookieList[cookie]; if ( httpCookie != null ) cookies.Append( "<tr><td><b>" + cookie + "</b></td><td>" + httpCookie.Value + "</td></tr>" ); } cookies.Append( "</table>" ); } StringBuilder formItems = new StringBuilder(); var formList = request.Form; if ( formList.Count > 0 ) { formItems.Append( "<table class=\"form-items exception-table\">" ); foreach ( string formItem in formList ) formItems.Append( "<tr><td><b>" + formItem + "</b></td><td>" + formList[formItem] + "</td></tr>" ); formItems.Append( "</table>" ); } StringBuilder serverVars = new StringBuilder(); var serverVarList = request.ServerVariables; if ( serverVarList.Count > 0 ) { serverVars.Append( "<table class=\"server-variables exception-table\">" ); foreach ( string serverVar in serverVarList ) serverVars.Append( "<tr><td><b>" + serverVar + "</b></td><td>" + serverVarList[serverVar] + "</td></tr>" ); serverVars.Append( "</table>" ); } exceptionLog.Cookies = cookies.ToString(); exceptionLog.StatusCode = context.Response.StatusCode.ToString(); exceptionLog.PageUrl = request.Url.ToString(); exceptionLog.ServerVariables = serverVars.ToString(); exceptionLog.QueryString = request.Url.Query; exceptionLog.Form = formItems.ToString(); } catch { // Intentionally do nothing } return exceptionLog; }
/// <summary> /// 疾病模型评估 /// </summary> /// <returns></returns> internal EntityRptModelAcess GetRptModelParam(decimal modelId, EntitymModelAccessRecord vo, out List <EntityModelParamCalc> lstMdParamCalc) { EntityRptModelAcess modelAcess = new EntityRptModelAcess(); lstMdParamCalc = new List <EntityModelParamCalc>(); modelAcess.lstModelParam = new List <EntityRptModelParam>(); Dictionary <string, string> dicData = new Dictionary <string, string>(); EntityRptModelParam param = null; try { modelAcess.modelId = modelId; List <EntityModelGroupItem> lstModelGroup = lstModelGroupItem.FindAll(r => r.modelId == modelId && r.isMain == 1); if (!string.IsNullOrEmpty(vo.qnData)) { XmlDocument document = new XmlDocument(); document.LoadXml(vo.qnData); XmlNodeList list = document["FormData"].ChildNodes; dicData = Function.ReadXML(vo.qnData); } #region 主要评估参数 if (lstModelGroup != null) { bool rFlag = false; foreach (var model in lstModelGroup) { rFlag = false; param = new EntityRptModelParam(); param.itemCode = model.paramNo; param.itemName = model.paramName; param.pointId = model.pointId; //问卷 if (model.paramType == 3 || model.paramType == 4) { List <EntityModelParam> lstModelParamTmp = lstModelParam.FindAll(r => r.parentFieldId == model.paramNo && r.modelId == modelId); if (lstModelParamTmp != null) { foreach (var gxyModel in lstModelParamTmp) { rFlag = false; if (gxyModel.isNormal == "1") { param.range = gxyModel.judgeRange; } if (dicData.ContainsKey(gxyModel.paramNo)) { if (gxyModel.judgeType == 2) { if (Function.Dec(dicData[gxyModel.paramNo]) == gxyModel.judgeValue) { param.result = gxyModel.judgeRange; } if (string.IsNullOrEmpty(param.result)) { param.result = "无"; } } else { param.result = dicData[model.paramNo]; } rFlag = true; } } } } //体检项目 else if (model.paramType == 2) { if (lstTjResult == null) { continue; } if (!lstTjResult.Any(r => r.itemCode == param.itemCode)) { continue; } EntityTjResult tjR = lstTjResult.Find(r => r.itemCode == param.itemCode); param.itemName = tjR.itemName; param.result = tjR.itemResult; param.range = tjR.range; param.unit = tjR.unit; if (!string.IsNullOrEmpty(tjR.hint)) { param.pic = ReadImageFile("picHint.png"); } rFlag = true; } if (rFlag) { modelAcess.lstModelParam.Add(param); } } } #endregion #region 预防要点 //预防要点 List <int> lstPoint = new List <int>(); modelAcess.lstPoint = new List <string>(); if (modelAcess.lstModelParam != null) { foreach (var pVo in modelAcess.lstModelParam) { if (!lstPoint.Contains(pVo.pointId)) { lstPoint.Add(pVo.pointId); } } for (int i = 0; i < lstPoint.Count; i++) { EntityModelAnalysisPoint pointVo = lstModelPoint.Find(r => r.id == lstPoint[i]); if (pointVo != null) { modelAcess.lstPoint.Add(pointVo.pintAdvice); } } } #endregion #region 风险评估 decimal bestDf = 0; decimal df = 0; lstMdParamCalc = CalcModelResult(modelId, vo, out df, out bestDf); modelAcess.df = df; modelAcess.bestDf = bestDf; modelAcess.reduceDf = modelAcess.df - modelAcess.bestDf; if (modelAcess.df <= 5) { modelAcess.imgFx01 = ReadImageFile("picFx.png"); modelAcess.resultStr = "低危"; } else if (modelAcess.df > 5 && modelAcess.df < 20) { modelAcess.imgFx02 = ReadImageFile("picFx.png"); modelAcess.resultStr = "中危"; } else if (modelAcess.df > 20 && modelAcess.df < 50) { modelAcess.imgFx03 = ReadImageFile("picFx.png"); modelAcess.resultStr = "高危"; } else if (modelAcess.df >= 50) { modelAcess.imgFx04 = ReadImageFile("picFx.png"); modelAcess.resultStr = "很高危"; } modelAcess.lstEvaluate = new List <EntityEvaluateResult>(); EntityEvaluateResult voEr = new EntityEvaluateResult(); voEr.result = Function.Double(modelAcess.df.ToString("0.00")); voEr.evaluationName = "本次结果"; modelAcess.lstEvaluate.Add(voEr); EntityEvaluateResult voEb = new EntityEvaluateResult(); voEb.result = Function.Double(modelAcess.bestDf.ToString("0.00")); voEb.evaluationName = "最佳状态"; modelAcess.lstEvaluate.Add(voEb); EntityEvaluateResult voEa = new EntityEvaluateResult(); voEa.result = 18; voEa.evaluationName = "平均水平"; modelAcess.lstEvaluate.Add(voEa); #endregion } catch (Exception ex) { ExceptionLog.OutPutException(ex); } return(modelAcess); }
/// <summary> /// AddQuestCtrl /// </summary> void AddQuestCtrl(EntityQnRecord qnRecord) { try { if (qnRecord != null) { if (!string.IsNullOrEmpty(qnRecord.xmlData)) { XmlDocument document = new XmlDocument(); document.LoadXml(qnRecord.xmlData); XmlNodeList list = document["FormData"].ChildNodes; xmlData = list[1].OuterXml; dicData = Function.ReadXML(xmlData); } } using (Biz202 biz = new Biz202()) { lstCtrlLocation = biz.GetQnCtrlLocation(lstQuest[1]); } using (Biz209 biz = new Biz209()) { lstTopic = new List <EntityDicQnSetting>(); lstItems = new List <EntityDicQnSetting>(); biz.GetQnCustom(1, out lstTopic, out lstItems); } int locationX = 0; int locationY = 0; int F35Count = 0; int F35Row = (lstTopic.FindAll(r => r.fieldId.Contains("F035")).Count) / 6; int F35Y = 0; List <EntityDicQnSetting> lstChildSettings = new List <EntityDicQnSetting>(); if (lstTopic != null && lstTopic.Count > 0) { for (int i = 0; i < lstTopic.Count; i++) { EntityDicQnSetting item = lstTopic[i]; if (item.questName == lstQuest[1]) { if (item.fieldId.Contains("F035")) { DevExpress.XtraReports.UI.XRCheckBox chkAns = new DevExpress.XtraReports.UI.XRCheckBox(); chkAns.Text = item.fieldName; chkAns.Font = new System.Drawing.Font("宋体", 9.5F); chkAns.Name = item.fieldId; EntityCtrlLocation ctrLocat = lstCtrlLocation.FindAll(r => r.name.Contains("F035"))[F35Count]; locationX = ctrLocat.locationX; locationY = ctrLocat.locationY; F35Y += locationY; chkAns.Width = ctrLocat.width; chkAns.Height = ctrLocat.height; chkAns.Location = new System.Drawing.Point(locationX, locationY); if (dicData.ContainsKey(item.fieldId)) { string value = dicData[item.fieldId]; chkAns.Checked = value == "0" ? false : true; } this.Detail.Controls.Add(chkAns); F35Count++; } } } F35Y -= 80; for (int i2 = 0; i2 < lstTopic.Count; i2++) { EntityDicQnSetting itemVo = lstTopic[i2]; if (itemVo.questName == lstQuest[1]) { if (string.IsNullOrEmpty(itemVo.parentFieldId) && !itemVo.fieldId.Contains("F035")) { DevExpress.XtraReports.UI.XRLabel lblTopic = new DevExpress.XtraReports.UI.XRLabel(); lblTopic.Name = itemVo.fieldId; lblTopic.Text = itemVo.fieldName; lblTopic.Font = new System.Drawing.Font("宋体", 9.5F); EntityCtrlLocation ctrLocat = lstCtrlLocation.Find(r => r.name == itemVo.fieldId); locationX = ctrLocat.locationX; locationY = ctrLocat.locationY - F35Y; lblTopic.Location = new System.Drawing.Point(locationX, locationY); this.Detail.Controls.Add(lblTopic); lstChildSettings = lstTopic.FindAll(r => r.parentFieldId == itemVo.fieldId); if (lstChildSettings.Count > 0) { foreach (var childVo in lstChildSettings) { DevExpress.XtraReports.UI.XRCheckBox chkAns = new DevExpress.XtraReports.UI.XRCheckBox(); string strEndWith = childVo.fieldId.Substring(4, 2); chkAns.Text = childVo.fieldName; chkAns.Font = new System.Drawing.Font("宋体", 9.5F); chkAns.Name = childVo.fieldId; EntityCtrlLocation ctrLocatChild = lstCtrlLocation.Find(r => r.name == childVo.fieldId); locationX = ctrLocatChild.locationX; locationY = ctrLocatChild.locationY - F35Y; chkAns.Width = ctrLocatChild.width; chkAns.Height = ctrLocatChild.height; chkAns.Location = new System.Drawing.Point(locationX, locationY); if (dicData.ContainsKey(childVo.fieldId)) { string value = dicData[childVo.fieldId]; chkAns.Checked = value == "0" ? false : true; } this.Detail.Controls.Add(chkAns); } } } } } } if (lstCtrlLocation != null && lstCtrlLocation.Count > 0) { foreach (var clVo in lstCtrlLocation) { DevExpress.XtraReports.UI.XRLabel lblTopic = new DevExpress.XtraReports.UI.XRLabel(); lblTopic.Name = clVo.name; lblTopic.Text = clVo.text; lblTopic.Font = new System.Drawing.Font("宋体", 9.75F, System.Drawing.FontStyle.Bold); locationX = clVo.locationX; if (clVo.name == "FM0201") { locationY = clVo.locationY; } else if (clVo.name.Contains("FM")) { locationY = clVo.locationY - F35Y; } else { continue; } lblTopic.Location = new System.Drawing.Point(locationX, locationY); this.Detail.Controls.Add(lblTopic); } } } catch (Exception ex) { ExceptionLog.OutPutException(ex); } finally { } }
public void LogException(ExceptionLog exceptionLog) { _elmahErrorLogManager.LogException(exceptionLog); }
/// <summary> /// 保存.电子申请单 /// </summary> /// <param name="formVo"></param> /// <param name="formId"></param> /// <returns></returns> public int SaveForm(EntityFormDesign formVo, out int formId) { int affectRows = 0; string Sql = string.Empty; SqlHelper svc = null; formId = 0; try { svc = new SqlHelper(EnumBiz.onlineDB); List <DacParm> lstPara = new List <DacParm>(); bool isExsit = true; if (formVo.Formid <= 0) { isExsit = false; formVo.Formid = svc.GetNextID(EntityTools.GetTableName(formVo), EntityTools.GetFieldName(formVo, EntityFormDesign.Columns.Formid)); } lstPara.Add(svc.GetInsertParm(formVo)); if (isExsit == false) { string tbName = "emrFormRtf" + formVo.Formid.ToString(); // 自动生成 EntityEmrBasicInfo vo = new EntityEmrBasicInfo(); vo.typeId = 1; vo.formId = formVo.Formid; vo.formName = formVo.Formname; vo.caseCode = formVo.Formid.ToString(); vo.pyCode = SpellCodeHelper.GetPyCode(formVo.Formname); vo.wbCode = SpellCodeHelper.GetWbCode(formVo.Formname); vo.tableName = tbName; vo.attribute = 0; vo.showType = 0; vo.caseStyle = 0; vo.catalogId = 23; // 其他类 vo.fieldXml = EmrTool.GetBasicFieldXml(formVo.Layout); vo.status = 1; lstPara.Add(svc.GetInsertParm(vo)); Sql = @"if exists (select 1 from sysobjects where id = object_id('{0}') and type = 'U') drop table {1}"; lstPara.Add(svc.GetDacParm(EnumExecType.ExecSql, string.Format(Sql, tbName, tbName))); Sql = @"create table {0} ( registerid varchar(20) not null, recorddate datetime not null, fieldname varchar(50) not null, rowindex numeric(10,0) not null, tablecode varchar(100) null, contentrtf image null, printrtf image null, isprint numeric(1,0) not null, constraint pk_{0} primary key (registerid, recorddate, fieldname, rowindex) )"; lstPara.Add(svc.GetDacParm(EnumExecType.ExecSql, string.Format(Sql, tbName, tbName))); } else { EntityEmrBasicInfo vo = new EntityEmrBasicInfo(); vo.formId = formVo.Formid; vo.formName = formVo.Formname; vo.pyCode = SpellCodeHelper.GetPyCode(formVo.Formname); vo.wbCode = SpellCodeHelper.GetWbCode(formVo.Formname); vo.fieldXml = EmrTool.GetBasicFieldXml(formVo.Layout); DataTable dt = svc.Select(vo, new List <string>() { EntityEmrBasicInfo.Columns.formId }); if (dt != null && dt.Rows.Count > 0) { lstPara.Add(svc.GetUpdateParm(vo, new List <string>() { EntityEmrBasicInfo.Columns.formName, EntityEmrBasicInfo.Columns.pyCode, EntityEmrBasicInfo.Columns.wbCode, EntityEmrBasicInfo.Columns.fieldXml }, new List <string>() { EntityEmrBasicInfo.Columns.formId })); } } if (formVo.Formid > 0) { using (TransactionScope scope = svc.TransactionScope) { if (DelForm((int)formVo.Formid, (int)formVo.Version) < 0) { return(-1); } affectRows = svc.Commit(lstPara); scope.Complete(); } } else { affectRows = svc.Commit(lstPara); } formId = (int)formVo.Formid; if (formId > 0 && affectRows <= 0) { affectRows = 1; } } catch (Exception e) { ExceptionLog.OutPutException(e); affectRows = -1; } finally { svc = null; } return(affectRows); }
public long Add(ExceptionLog exceptionLog) { return(_repository.Add(exceptionLog)); }
// PUT: api/ReceiveSupplierOrder/5 public string Put(int id, HttpRequestMessage value) { try { string message = HttpContext.Current.Server.UrlDecode(value.Content.ReadAsStringAsync().Result).Substring(5); JObject json = JObject.Parse(message); JArray cs = (JArray)json["cs"]; JArray ps = (JArray)json["ps"]; JArray rms = (JArray)json["rms"]; var so = (from p in db.Supplier_Order where p.Supplier_Order_ID == id select p).First(); bool rawAll = true; bool partAll = true; bool compAll = true; foreach (JObject comp in cs) { int component_id = (int)comp["Component_ID"]; Supplier_Order_Component soc = new Supplier_Order_Component(); soc = (from p in db.Supplier_Order_Component where p.Supplier_Order_ID == id && p.Component_ID == component_id select p).First(); int quantity = soc.Quantity_Received; int newquantity = (int)comp["Quantity_Received"] - quantity; soc.Quantity_Received = (int)comp["Quantity_Received"]; soc.Supplier_Order = so; Component c = new Component(); c = (from p in db.Components where p.Component_ID == component_id select p).First(); c.Quantity += newquantity; if (soc.Quantity_Requested != soc.Quantity_Received) { compAll = false; } } foreach (JObject part in ps) { int component_id = (int)part["Part_Type_ID"]; Supplier_Order_Detail_Part soc = new Supplier_Order_Detail_Part(); soc = (from p in db.Supplier_Order_Detail_Part where p.Supplier_Order_ID == id && p.Part_Type_ID == component_id select p).First(); int quantity = soc.Quantity_Received; int newquantity = (int)part["Quantity_Received"] - quantity; soc.Quantity_Received = (int)part["Quantity_Received"]; int key = db.Parts.Count() == 0 ? 1 : (from t in db.Parts orderby t.Part_ID descending select t.Part_ID).First() + 1; if (soc.Quantity != soc.Quantity_Received) { partAll = false; } for (int x = 0; x < newquantity; x++) { string abbreviation = soc.Part_Type.Abbreviation; //(Armand) Generate the new number; Random rand = new Random(); int num = 0; string serial = ""; while (true) { num = rand.Next(1, 999999999); serial = abbreviation + "-" + Convert.ToString(num); if ((from d in db.Parts where d.Part_Serial == serial select d).Count() == 0) { break; } } Part p = new Part(); p.Parent_ID = 0; p.Part_Serial = serial; p.Part_Status_ID = 1; p.Part_Type_ID = component_id; p.Part_ID = key; key++; p.Part_Stage = 0; p.Date_Added = DateTime.Now; p.Cost_Price = (decimal)part["Price"]; p.Supplier_Order.Add(so); db.Parts.Add(p); } } foreach (JObject raw in rms) { int component_id = (int)raw["Raw_Material_ID"]; Supplier_Order_Detail_Raw_Material soc = new Supplier_Order_Detail_Raw_Material(); soc = (from p in db.Supplier_Order_Detail_Raw_Material where p.Supplier_Order_ID == id && p.Raw_Material_ID == component_id select p).First(); int quantity = soc.Quantity_Received; int newquantity = (int)raw["Quantity_Received"] - quantity; soc.Quantity_Received = (int)raw["Quantity_Received"]; int key = db.Unique_Raw_Material.Count() == 0 ? 1 : (from t in db.Unique_Raw_Material orderby t.Unique_Raw_Material_ID descending select t.Unique_Raw_Material_ID).First() + 1; if (soc.Quantity != soc.Quantity_Received) { rawAll = false; } for (int x = 0; x < newquantity; x++) { Unique_Raw_Material p = new Unique_Raw_Material(); p.Unique_Raw_Material_ID = key; key++; p.Cost_Price = (decimal)raw["Price"]; p.Date_Added = DateTime.Now; p.Raw_Material_ID = component_id; p.Dimension = (string)raw["Dimensions"]; p.Quality = ""; p.Supplier_Order_ID = id; db.Unique_Raw_Material.Add(p); } } if (rawAll && partAll && compAll) { so.Supplier_Order_Status_ID = 5; } else { so.Supplier_Order_Status_ID = 2; string to = so.Supplier.Email; string subject = "WME Supplier Order #" + so.Supplier_Order_ID + " Back Order"; String orderDate = DateTime.Now.ToShortDateString(); string body = "Walter Meano Engineering Supplier Order #" + so.Supplier_Order_ID + "\nThe order was partially received on " + orderDate + "\n\nThe following items still need to be delivered:\n"; foreach (JObject comp in cs) { int component_id = (int)comp["Component_ID"]; Supplier_Order_Component soc = new Supplier_Order_Component(); soc = (from p in db.Supplier_Order_Component where p.Supplier_Order_ID == id && p.Component_ID == component_id select p).First(); int quantity = soc.Quantity_Received; int quantityLeft = soc.Quantity_Requested - quantity; if (quantityLeft != 0) { Component c = new Component(); c = (from p in db.Components where p.Component_ID == component_id select p).First(); body += c.Name + "\t\tx" + quantityLeft + "\n"; } } foreach (JObject part in ps) { int component_id = (int)part["Part_Type_ID"]; Supplier_Order_Detail_Part soc = new Supplier_Order_Detail_Part(); soc = (from p in db.Supplier_Order_Detail_Part where p.Supplier_Order_ID == id && p.Part_Type_ID == component_id select p).First(); int quantity = soc.Quantity_Received; int quantityLeft = soc.Quantity - quantity; if (quantityLeft != 0) { Part_Type c = new Part_Type(); c = (from p in db.Part_Type where p.Part_Type_ID == component_id select p).First(); body += c.Name + "\t\tx" + quantityLeft + "\n"; } } foreach (JObject raw in rms) { int component_id = (int)raw["Raw_Material_ID"]; Supplier_Order_Detail_Raw_Material soc = new Supplier_Order_Detail_Raw_Material(); soc = (from p in db.Supplier_Order_Detail_Raw_Material where p.Supplier_Order_ID == id && p.Raw_Material_ID == component_id select p).First(); int quantity = soc.Quantity_Received; int quantityLeft = soc.Quantity - quantity; if (quantityLeft != 0) { Raw_Material c = new Raw_Material(); c = (from p in db.Raw_Material where p.Raw_Material_ID == component_id select p).First(); body += c.Name + "\t\tx" + quantityLeft + "\n"; } } Email.SendEmail(to, subject, body); } db.SaveChanges(); return("true|Supplier Purchase Order successfully received."); } catch (Exception e) { ExceptionLog.LogException(e, "ReceiveSupplierOrderController"); return("false|An error has occured receiving the Supplier Purchase Order on the system."); } }
private void BindData() { m_bDataBound = true; Pager.PageSize = BoardSettings.PostsPerPage; if (topic == null) { Forum.Redirect(Pages.topics, "f={0}", PageForumID); } PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.PageSize = Pager.PageSize; using (DataTable dt0 = DB.post_list(PageTopicID, IsPostBack ? 0 : 1)) { if (dt0 == null) { ExceptionLog.log("dt0 é null", "NULL"); } DataView dt = dt0.DefaultView; if (dt == null) { ExceptionLog.log("dt é null", "NULL"); } if (IsThreaded) { dt.Sort = "Position"; } else { dt.Sort = "Posted"; } Pager.Count = dt.Count; pds.DataSource = dt; int nFindMessage = 0; try { if (m_bIgnoreQueryString) { } else if (Request.QueryString["p"] != null) { // show specific page (p is 1 based) int tPage = Convert.ToInt32(Request.QueryString["p"]); if (pds.PageCount >= tPage) { pds.CurrentPageIndex = tPage - 1; Pager.CurrentPageIndex = pds.CurrentPageIndex; } } else if (Request.QueryString["m"] != null) { // Show this message nFindMessage = int.Parse(Request.QueryString["m"]); } else if (Request.QueryString["find"] != null && Request.QueryString["find"].ToLower() == "unread") { // Find next unread using (DataTable dtUnread = DB.message_findunread(PageTopicID, Mession.LastVisit)) { foreach (DataRow row in dtUnread.Rows) { nFindMessage = (int)row["MessageID"]; break; } } } } catch (Exception) { } if (nFindMessage > 0) { CurrentMessage = nFindMessage; // Find correct page for message for (int foundRow = 0; foundRow < dt.Count; foundRow++) { if ((int)dt[foundRow]["MessageID"] == nFindMessage) { pds.CurrentPageIndex = foundRow / pds.PageSize; Pager.CurrentPageIndex = pds.CurrentPageIndex; break; } } } else { foreach (DataRow row in dt0.Rows) { CurrentMessage = (int)row["MessageID"]; break; } } } pds.CurrentPageIndex = Pager.CurrentPageIndex; if (pds.CurrentPageIndex >= pds.PageCount) { pds.CurrentPageIndex = pds.PageCount - 1; } MessageList.DataSource = pds; if (topic["PollID"] != DBNull.Value) { Poll.Visible = true; dtPoll = DB.poll_stats(topic["PollID"]); Poll.DataSource = dtPoll; } DataBind(); }
public ActionResult Index(int id, int?actionType) { try { if (!AppSession.HasValidSession) { SessionExpired(); } HelperClasses.SetReportOrScheduleID(id, (int)ReportsListEnum.TracerByEP); SearchInputService reportservice = new SearchInputService(); SearchList list = new SearchList(); string savedChapters = string.Empty; string savedStandards = string.Empty; if (AppSession.ReportScheduleID > 0) { //Load the saved parameters var oSaveAndScheduleService = new SaveAndScheduleService(); var savedParameters = oSaveAndScheduleService.LoadUserSchedule(AppSession.ReportScheduleID); TempData["SavedParameters"] = savedParameters; //This tempdata will be used by the Ajax call to avoid loading the saved parameters again from DB TempData["ActionType"] = actionType; //Show/Hide Save to my reports button ViewBag.HideSaveReport = HelperClasses.HideSaveToMyReports(AppSession.RoleID, savedParameters.UserID, AppSession.UserID, actionType); //Get the saved Chapters and Standards savedChapters = savedParameters.ReportParameters.FirstOrDefault(param => param.ReportParameterName == WebConstants.TRACERS_CHAPTER).ParameterValue; savedStandards = savedParameters.ReportParameters.FirstOrDefault(param => param.ReportParameterName == WebConstants.TRACERS_STANDARD).ParameterValue; list = reportservice.GetSearchListsForSavedParameters(AppSession.ReportScheduleID, savedParameters, WebConstants.TRACER_REPORT_TITLE_TRACE_BY_EP_REPORT); } else { list = reportservice.GetSearchLists(WebConstants.TRACER_REPORT_TITLE_TRACE_BY_EP_REPORT); } list.TracersChapters = reportservice.GetTracersChapters().TracersChapters; List <TracersStandards> standardList = new List <TracersStandards>(); if (!String.IsNullOrWhiteSpace(savedChapters) && savedChapters != "-1") //Load standards only for the selected Chapters { standardList = reportservice.GetTracersStandards(savedChapters).TracersStandards.ToList(); } else { standardList.Add(new TracersStandards { TracerStandardID = Convert.ToInt32(-1), Code = "All" }); } list.TracersStandards = standardList; List <TracersEP> epList = new List <TracersEP>(); if (!String.IsNullOrWhiteSpace(savedStandards) && savedStandards != "-1") //Load EPs only for the selected Standards and Chapters { epList = reportservice.GetTracersEPs(savedChapters, savedStandards).TracersEPs.ToList(); } else { epList.Add(new TracersEP { EPTextID = Convert.ToInt32(-1), StandardLabelAndEPLabel = "All", }); } list.TracersEPs = epList; return(View(list)); } catch (Exception ex) { ExceptionLog exceptionLog = new ExceptionLog { ExceptionText = "Reports: " + ex.Message, PageName = "TracerByEP", MethodName = "Index", UserID = Convert.ToInt32(AppSession.UserID), SiteId = Convert.ToInt32(AppSession.SelectedSiteId), TransSQL = "", HttpReferrer = null }; exceptionService.LogException(exceptionLog); return(RedirectToAction("Error", "Transfer")); } }
public async Task <IActionResult> GetExceptionLog(string logId) { ExceptionLog log = await _logBll.GetExceptionLogAsync(logId); return(new JsonResult(new { success = true, data = log })); }
/// <summary> /// Recursively logs exception and any children. /// </summary> /// <param name="ex">The <see cref="System.Exception"/> to log.</param> /// <param name="log">The parent <see cref="Rock.Model.ExceptionLog"/> of the exception being logged. This value is nullable.</param> /// <param name="isParent">A <see cref="System.Boolean"/> flag indicating if this Exception is a parent exception. This value is /// <c>true</c> if the exception that is being logged is a parent exception, otherwise <c>false</c>. /// </param> private static void LogExceptions( Exception ex, ExceptionLog log, bool isParent ) { // First, attempt to log exception to the database. try { ExceptionLog exceptionLog; // If this is a recursive call and not the originating exception being logged, // attempt to clone the initial one, and populate it with Exception Type and Message // from the inner exception, while retaining the contextual information from where // the exception originated. if ( !isParent ) { exceptionLog = log.Clone( false ); if ( exceptionLog != null ) { // Populate with inner exception type, message and update whether or not there is another inner exception. exceptionLog.ExceptionType = ex.GetType().ToString(); exceptionLog.Description = ex.Message; exceptionLog.Source = ex.Source; exceptionLog.StackTrace = ex.StackTrace; exceptionLog.HasInnerException = ex.InnerException != null; // Ensure EF properly recognizes this as a new record. exceptionLog.Id = 0; exceptionLog.Guid = Guid.NewGuid(); exceptionLog.ParentId = log.Id; } } else { exceptionLog = log; } // The only reason this should happen is if the `log.Clone()` operation failed. Compiler sugar. if ( exceptionLog == null ) { return; } // Write ExceptionLog record to database. var rockContext = new Rock.Data.RockContext(); var exceptionLogService = new ExceptionLogService( rockContext ); exceptionLogService.Add( exceptionLog ); rockContext.SaveChanges(); // Recurse if inner exception is found if ( exceptionLog.HasInnerException.GetValueOrDefault( false ) ) { LogExceptions( ex.InnerException, exceptionLog, false ); } if (ex is AggregateException) { // if an AggregateException occurs, log the exceptions individually var aggregateException = ( ex as AggregateException ); foreach ( var innerException in aggregateException.InnerExceptions ) { LogExceptions( innerException, exceptionLog, false ); } } } catch ( Exception ) { // If logging the exception fails, write the exceptions to a file try { string directory = AppDomain.CurrentDomain.BaseDirectory; directory = Path.Combine( directory, "App_Data", "Logs" ); if ( !Directory.Exists( directory ) ) { Directory.CreateDirectory( directory ); } string filePath = Path.Combine( directory, "RockExceptions.csv" ); string when = RockDateTime.Now.ToString(); while ( ex != null ) { File.AppendAllText( filePath, string.Format( "{0},{1},\"{2}\"\r\n", when, ex.GetType(), ex.Message ) ); ex = ex.InnerException; } } catch { // failed to write to database and also failed to write to log file, so there is nowhere to log this error } } }
public ReportViewer _departmentcomparativeanalysisRDLC(Search search, Email emailInput) { SearchFormat searchoutput = new SearchFormat(); searchoutput.CheckInputs(search); if (AppSession.ReportScheduleID > 0) { search.ReportTitle = String.Concat(search.ReportTitle, " - Report ID: ", AppSession.ReportScheduleID); } if (search.StartDate != null && search.EndDate != null) { search.ReportDateTitle = "Tracer updates for " + search.StartDate.Value.ToShortDateString() + " - " + search.EndDate.Value.ToShortDateString(); } else if (search.StartDate != null && search.EndDate == null) { search.ReportDateTitle = "Tracer updates since " + search.StartDate.Value.ToShortDateString(); } else if (search.StartDate == null && search.EndDate != null) { search.ReportDateTitle = "Tracers updates through " + search.EndDate.Value.ToShortDateString(); } else { search.ReportDateTitle = "All Tracer Dates"; } ReportViewer reportViewer = new ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; try { reportViewer.LocalReport.DisplayName = search.ReportTitle; reportViewer.LocalReport.ReportPath = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath) + @"Areas\Tracer\Reports\rptReportDepartmentComparativeAnalysis.rdlc"; reportViewer.LocalReport.DataSources.Add(new ReportDataSource("dsReport_DepartmentComparativeAnalysisData", ReportDepartmentComparativeAnalysisData(search).Tables[0])); if (search.IncludeNonCompliantOpportunities) { // We wish to get Opportunities her eso read the data set. reportViewer.LocalReport.DataSources.Add(new ReportDataSource("dsReport_DepartmentComparativeAnalysisOpportunities", ReportDepartmentComparativeAnalysisOpportunities(search, false).Tables[0])); } else { // We pass a blank dataset if NonCompliant Opportunities are not required for this report DataSet ds = new DataSet(); ds.ReadXml(HttpContext.Current.Server.MapPath("~/App_Data/dsReport_DepartmentComparativeAnalysisOpportunities.xsd")); reportViewer.LocalReport.DataSources.Add(new ReportDataSource("dsReport_DepartmentComparativeAnalysisOpportunities", ds.Tables[0])); } ReportParameter p1 = new ReportParameter("ReportDisplayType", ((int)Enum.Parse(typeof(ReportType), search.ReportType)).ToString()); ReportParameter p2 = new ReportParameter("ProgramName", AppSession.SelectedProgramName); ReportParameter p3 = new ReportParameter("SiteName", AppSession.SelectedSiteName); ReportParameter p4 = new ReportParameter("OrgType1Header", AppSession.OrgRanking1Name.ToString()); // Provide OrgType Rank 1 Name header (e.g., Department) ReportParameter p5 = new ReportParameter("OrgType2Header", AppSession.OrgRanking2Name.ToString()); // Provide OrgType Rank 2 Name column header or blank if none ReportParameter p6 = new ReportParameter("OrgType3Header", AppSession.OrgRanking3Name.ToString()); // Provide OrgType Rank 2 Name column header or blank if none ReportParameter p7 = new ReportParameter("OrgRank1Names", search.OrgTypeLevel1Names.ToString()); // Filtered Rank 1 Org Names or blank string for all ReportParameter p8 = new ReportParameter("OrgRank2Names", search.OrgTypeLevel2Names.ToString()); // Filtered Rank 2 Org Names or blank string for all ReportParameter p9 = new ReportParameter("OrgRank3Names", search.OrgTypeLevel3Names.ToString()); // Filtered Rank 3 Org Names or blank string for all ReportParameter p10 = new ReportParameter("TracerCategories", search.TracerCategoryNames.ToString()); // Filterd Tracercategories or blank for all ReportParameter p11 = new ReportParameter("TracerName", search.TracerListNames.ToString()); // Filtered Tracer Names or blank for all ReportParameter p12 = new ReportParameter("ReportTitle", search.ReportTitle); // Report title from DB ReportParameter p13 = new ReportParameter("ReportDateTitle", search.ReportDateTitle.ToString()); // Computed start/end date string for date range title ReportParameter p14 = new ReportParameter("Copyright", "© " + DateTime.Now.Year.ToString() + WebConstants.Tracer_Copyright.ToString()); ReportParameter p15 = new ReportParameter("IncludeCompliancePercent", search.IncludeNonCompliantOpportunities ? "1" : "0"); ReportParameter p16 = new ReportParameter("CompliancePercent", search.OpportunitiesValue.ToString()); ReportParameter p17 = new ReportParameter("IncludeDeptNoCompObs", search.IncludeDeptNoCompObs ? "1" : "0"); ReportParameter p18 = new ReportParameter("TracerTypeID", search.TracerTypeID < 1 ? "1" : search.TracerTypeID.ToString()); ReportParameter p19 = new ReportParameter("IsCMSEnabled", AppSession.IsCMSProgram ? "1" : "0"); ReportParameterCollection reportParameterCollection = new ReportParameterCollection { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19 }; reportViewer.LocalReport.SetParameters(reportParameterCollection); if (emailInput.To != null) { CommonService emailService = new CommonService(); int actionTypeId = (int)ActionTypeEnum.DepartmentComparativeAnalysisReport; if (emailService.SendReportEmail(emailInput, actionTypeId, emailService.SetRdlcEmail(reportViewer))) { // do nothing // left place holder for any other actions. } else { throw (new Exception("Email")); } } } catch (Exception ex) { if (ex.Message.ToString() != "No Data" && ex.Message.ToString() != "Limit") { ExceptionLog exceptionLog = new ExceptionLog { ExceptionText = "Reports: " + ex.Message, PageName = "DepartmentComparativeAnalysis", MethodName = "_departmentcomparativeanalysisRDLC", UserID = Convert.ToInt32(AppSession.UserID), SiteId = Convert.ToInt32(AppSession.SelectedSiteId), TransSQL = "", HttpReferrer = null }; _exceptionService.LogException(exceptionLog); } throw; } return(reportViewer); }
/// <summary> /// GetForm /// </summary> /// <param name="formId"></param> /// <returns></returns> public List <EntityFormDesign> GetForm(int formId) { string SQL = string.Empty; List <EntityFormDesign> lstForm = new List <EntityFormDesign>(); EntityFormDesign vo = new EntityFormDesign(); DataTable dt = null; SqlHelper svc = new SqlHelper(EnumBiz.onlineDB); IDataParameter[] paramArr = null; try { SQL = @"select t.formid, t.formcode, t.formname, t.version, t.pycode, t.wbcode, t.panelsize, t.layout, t.printtemplateid, t.recorderid, t.recorddate, t.status, b.oper_name as empname from emrFormDesign t left join code_operator b on t.recorderid = b.oper_code "; if (formId <= 0) { SQL += @"order by t.version asc"; dt = svc.GetDataTable(SQL); } else { SQL += @" where t.formid = ? order by t.version asc"; paramArr = svc.CreateParm(1); paramArr[0].Value = formId; dt = svc.GetDataTable(SQL, paramArr); } if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { vo = new EntityFormDesign(); vo.Formid = Function.Int(dr["formid"]); vo.Formcode = dr["formcode"].ToString(); vo.Formname = dr["formname"].ToString(); vo.Version = Function.Int(dr["version"]); vo.Pycode = dr["pycode"].ToString().ToUpper(); vo.Wbcode = dr["wbcode"].ToString().ToUpper(); vo.Panelsize = dr["panelsize"].ToString(); vo.Layout = dr["layout"].ToString(); vo.Recorderid = Function.Int(dr["recorderid"]); vo.RecorderName = dr["empname"].ToString(); vo.Recorddate = Convert.ToDateTime(dr["recorddate"].ToString()); vo.Status = Function.Int(dr["status"]); vo.StatusName = (vo.Status == 1 ? "启用" : "停用"); lstForm.Add(vo); } } } catch (Exception e) { ExceptionLog.OutPutException(e); } finally { svc = null; paramArr = null; } return(lstForm); }
public void Post(ExceptionLog exceptionLog) { this.centralizeLogContext.Add(exceptionLog); this.centralizeLogContext.SaveChanges(); Dispose(); }
// GET: api/Supplier/5 public string Get(int id) { try { JObject result = JObject.FromObject(new { suppliers = from p in db.Suppliers orderby p.Name where p.Supplier_ID == id select new { Supplier_ID = p.Supplier_ID, Name = p.Name, Address = p.Address, City = p.City, Zip = p.Zip, Bank_Account_Number = p.Bank_Account_Number, Bank_Branch = p.Bank_Branch, Bank_Name = p.Bank_Name, Email = p.Email, Contact_Number = p.Contact_Number, Status = p.Status, Province_ID = p.Province_ID, Bank_Reference = p.Bank_Reference, Contact_Name = p.Contact_Name, Foreign_Bank = p.Foreign_Bank, rms = from d in db.Raw_Material_Supplier where d.Supplier_ID == p.Supplier_ID select new { Raw_Material_ID = d.Raw_Material_ID, Raw_Material_Name = d.Raw_Material.Name, Is_Prefered = d.Is_Prefered, unit_price = d.unit_price }, cs = from d in db.Component_Supplier where d.Supplier_ID == p.Supplier_ID select new { Component_ID = d.Component_ID, Component_Name = d.Component.Name, is_preferred = d.is_preferred, unit_price = d.unit_price }, ps = from d in db.Part_Supplier where d.Supplier_ID == p.Supplier_ID select new { Part_Type_Name = d.Part_Type.Name, Part_Type_ID = d.Part_Type_ID, Is_Prefered = d.Is_Prefered, unit_price = d.unit_price } } }); return("true|" + result.ToString()); } catch (Exception e) { ExceptionLog.LogException(e, "SupplierController GET ID"); return("false|Failed to retrieve Supplier."); } }
private void FillInnerException(Exception ex, ExceptionLog innerExceptionLog, ExceptionLog pExceptionLog, ref int i) { innerExceptionLog.ExceptionType = ex.GetType().Name; innerExceptionLog.Message = ex.Message; innerExceptionLog.StackTrace = ex.StackTrace; innerExceptionLog.Source = ex.Source; if (pExceptionLog != null) { pExceptionLog.InnerException = innerExceptionLog; i = ++i; } if (ex.InnerException != null) { innerExceptionLog.InnerException = new ExceptionLog(); FillInnerException(ex.InnerException, innerExceptionLog.InnerException, innerExceptionLog, ref i); } }
// POST: api/SearchUniqueRawMaterial public string Post(HttpRequestMessage value) { try { string message = HttpContext.Current.Server.UrlDecode(value.Content.ReadAsStringAsync().Result).Substring(5); JObject json = JObject.Parse(message); string method = (string)json["method"]; //Exact, Contains, Similar string criteria = (string)json["criteria"]; //Typed in search value string category = (string)json["category"]; //Name, Description, Access Level JObject result = null; if (category == "ID") { try { int id = Convert.ToInt32(criteria); result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where p.Unique_Raw_Material_ID == id select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } catch { return("false|The entered search criteria value is not a number."); } } else if (method == "Exact") { if (category == "All") { try { int id = Convert.ToInt32(criteria); result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where p.Unique_Raw_Material_ID == id || rm.Name == criteria || rm.Description == criteria || p.Dimension == criteria select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } catch { result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where rm.Name == criteria || rm.Description == criteria || p.Dimension == criteria select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } } else if (category == "Name") { result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where rm.Name == criteria select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } else if (category == "Description") { result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where rm.Description == criteria select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } else if (category == "Dimension") { result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where p.Dimension == criteria select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } } else if (method == "Contains") { if (category == "All") { try { int id = Convert.ToInt32(criteria); result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where p.Unique_Raw_Material_ID == id || rm.Name.Contains(criteria) || rm.Description.Contains(criteria) || p.Dimension.Contains(criteria) select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } catch { result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where rm.Name.Contains(criteria) || rm.Description.Contains(criteria) || p.Dimension.Contains(criteria) select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } } else if (category == "Name") { result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where rm.Name.Contains(criteria) select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } else if (category == "Description") { result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where rm.Description.Contains(criteria) select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } else if (category == "Dimension") { result = JObject.FromObject(new { unique_raw_materials = from p in db.Unique_Raw_Material join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID orderby rm.Name where p.Dimension.Contains(criteria) select new { Raw_Material_ID = p.Raw_Material_ID, Raw_Material_Name = rm.Name, Raw_Material_Description = rm.Description, Unique_Raw_Material_ID = p.Unique_Raw_Material_ID, Dimension = p.Dimension, Quality = p.Quality, Date_Added = p.Date_Added, Date_Used = p.Date_Used, Cost_Price = p.Cost_Price, Supplier_Order_ID = p.Supplier_Order_ID } }); } } return("true|" + result.ToString()); } catch (Exception e) { ExceptionLog.LogException(e, "SearchUniqueRawMaterialController"); return("false|An error has occured searching for Unique Raw Materials on the system."); } }
public ActionResult SaferReport_Data(SearchCorporateER search, int LevelIdentifier, int LevelTypeIdentifier) { try { //Mock Survey Status Parameter. Corporate Reports displays data after Mock Survey Recommendations are approved. search.MockSurveyStatusID = (int)MockSurveyStatus.Publish_CCA_Recommendation; JsonResult jr = new JsonResult(); if (search.ProgramIDs == "-1") { search.ProgramIDs = "2"; } if (search.SelectedChapterIDs == "-1") { search.SelectedChapterIDs = null; } if (search.SelectedStandardIDs == "-1") { search.SelectedStandardIDs = null; } if (search.SelectedEPIDs == "-1") { search.SelectedEPIDs = null; } if (search.MatrixID < 1000) { search.MatrixID = 0; } search.EndDate = (search.EndDate != null && search.EndDate.ToString() != "") ? search.EndDate.Value.Date.AddHours(23).AddMinutes(29).AddSeconds(59) : search.EndDate; string encryptionKey = ConfigurationManager.AppSettings.Get("EncryptionKey"); switch (LevelIdentifier) { case (int)WebConstants.SaferMatrixLevels.Level1_Program: { switch (LevelTypeIdentifier) { case (int)WebConstants.LevelTypeIdentifier.Graph: var levelGraph = SaferMatrix.GetSaferMatrix(search); if (levelGraph == null) { Response.StatusCode = (int)HttpStatusCode.BadRequest; } jr = Json(levelGraph, JsonRequestBehavior.AllowGet); break; case (int)WebConstants.LevelTypeIdentifier.Summary: var levelSummary = SaferMatrix.GetSaferMatrixSummary(search); jr = Json(levelSummary, JsonRequestBehavior.AllowGet); break; case (int)WebConstants.LevelTypeIdentifier.Detail: var levelDetail = SaferMatrix.GetSaferMatrixData(search); jr = Json(levelDetail, JsonRequestBehavior.AllowGet); break; } break; } case (int)WebConstants.SaferMatrixLevels.Level2_Site: { switch (LevelTypeIdentifier) { case (int)WebConstants.LevelTypeIdentifier.Graph: case (int)WebConstants.LevelTypeIdentifier.Summary: var levelChartSummary = SaferMatrix.GetSaferMatrixSummaryBySite(search); jr = Json(levelChartSummary, JsonRequestBehavior.AllowGet); break; case (int)WebConstants.LevelTypeIdentifier.Detail: var levelData = SaferMatrix.GetSaferMatrixData(search); jr = Json(levelData, JsonRequestBehavior.AllowGet); break; } break; } case (int)WebConstants.SaferMatrixLevels.Level3_Chapter: { switch (LevelTypeIdentifier) { case (int)WebConstants.LevelTypeIdentifier.Graph: case (int)WebConstants.LevelTypeIdentifier.Summary: var levelGraphSummary = SaferMatrix.GetSaferMatrixSummaryByChapter(search); jr = Json(levelGraphSummary, JsonRequestBehavior.AllowGet); break; case (int)WebConstants.LevelTypeIdentifier.Detail: var levelData = SaferMatrix.GetSaferMatrixData(search); jr = Json(levelData, JsonRequestBehavior.AllowGet); break; } break; } case (int)WebConstants.SaferMatrixLevels.Level4_EP: { var levelData = new List <SaferMatrixData>(); levelData = SaferMatrix.GetSaferMatrixData(search); jr = Json(levelData, JsonRequestBehavior.AllowGet); break; } } jr.MaxJsonLength = Int32.MaxValue; jr.RecursionLimit = 100; return(jr); } catch (Exception ex) { ExceptionLog exceptionLog = new ExceptionLog { ExceptionText = "Reports: " + ex.Message, PageName = "SaferMatrix", MethodName = "AMPCorporateSummarySaferMatrix_Data", UserID = Convert.ToInt32(AppSession.UserID), SiteId = Convert.ToInt32(AppSession.SelectedSiteId), TransSQL = "", HttpReferrer = null }; exceptionService.LogException(exceptionLog); return(RedirectToAction("Error", "Transfer")); } }
public byte[] RFIReportRDLC(SearchCorporateER search, int reportType, string SortBy = "", string SortOrder = "") { byte[] fileContents = null; string reportDateTitle = ""; string rdlcName = String.Empty; string dsName = String.Empty; string reportSubTitle = String.Empty; string stdDetail = string.Empty; string findingDetails = string.Empty; DataView dv = null; ReportParameterCollection reportParameterCollection = null; try { if (AppSession.ReportScheduleID > 0 && search.ReportTitle != null) { search.ReportTitle = String.Concat(search.ReportTitle, " - Report ID: ", AppSession.ReportScheduleID); } else { search.ReportTitle = "Priority Findings RFI Report"; } reportDateTitle = CommonService.InitializeReportDateTitle("Observation", search.StartDate, search.EndDate); search.EndDate = (search.EndDate != null && search.EndDate.ToString() != "") ? search.EndDate.Value.Date.AddHours(23).AddMinutes(29).AddSeconds(59) : search.EndDate; // Setup ReportViewer ReportViewer reportViewer = new ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; reportViewer.LocalReport.DisplayName = search.ReportTitle; int maxRowCount = 0; // LevelIdentifier references the specific RDLC report requested switch (search.LevelIdentifier) { case (int)WebConstants.CorporateSummaryLevels.Level1_Program: default: { rdlcName = "rptReportRFIFindingsByProgram.rdlc"; dsName = "dsReport_RFIFindingsbyProgram"; var result = TJCRFIFinding.GetRFIFindingByProgram(search); maxRowCount = (from l in result group l by new { l.ProgramID } into g select new { totalCount = g.Sum(a => a.PSCount + a.RFICount + a.FSCount) }).Max(a => a.totalCount); dv = new DataView(result.ToDataTable()); reportSubTitle = "Findings by Program"; //stdDetail = "*This graph represents 100% of the total findings for selected sites and criteria."; stdDetail = " "; break; } case (int)WebConstants.CorporateSummaryLevels.Level2_Chapter: { rdlcName = "rptReportRFIFindingsPareto.rdlc"; dsName = "dsReport_RFIFindingsPareto"; var result = TJCRFIFinding.GetRFIFindingByChapter(search); maxRowCount = (from l in result group l by new { l.ChapterID } into g select new { totalCount = g.Sum(a => a.PSCount + a.RFICount + a.FSCount) }).Max(a => a.totalCount); dv = new DataView(result.ToDataTable()); reportSubTitle = "Findings by Chapter"; // stdDetail = "*This graph represents 100% of the total findings for selected sites and criteria."; stdDetail = " "; break; } case (int)WebConstants.CorporateSummaryLevels.Level3_Standard: { rdlcName = "rptReportRFIFindingsPareto.rdlc"; dsName = "dsReport_RFIFindingsPareto"; var result = TJCRFIFinding.GetRFIFindingByStandard(search); maxRowCount = (from l in result group l by new { l.StandardID } into g select new { totalCount = g.Sum(a => a.PSCount + a.RFICount + a.FSCount) }).Max(a => a.totalCount); dv = new DataView(result.ToDataTable()); reportSubTitle = "Findings by Standard"; stdDetail = "*This graph represents " + HttpContext.Current.Session["MaxStandardCount"] + "% of the total findings for selected sites and criteria."; break; } } // Setup Report Parmaeters common to all reports ReportParameter p1 = new ReportParameter("ReportTitle", search.ReportTitle.ToString()); ReportParameter p2 = new ReportParameter("Programs", search.ProgramNames.ToString()); ReportParameter p3 = new ReportParameter("Chapters", search.SelectedChapterNames.ToString()); ReportParameter p4 = new ReportParameter("Standards", search.SelectedStandardNames.ToString()); ReportParameter p5 = new ReportParameter("ReportDateTitle", reportDateTitle.ToString()); ReportParameter p6 = new ReportParameter("HCOID", search.SelectedSiteHCOIDs.ToString()); ReportParameter p7 = new ReportParameter("Copyright", "© " + DateTime.Now.Year.ToString() + WebConstants.Copyright.ToString()); ReportParameter p8 = new ReportParameter("ReportType", search.ReportType.ToString()); ReportParameter p9 = new ReportParameter("ReportSubTitle", reportSubTitle.ToString()); ReportParameter p10 = new ReportParameter("FSA", search.IncludeFsa ? "1" : "0"); ReportParameter p11 = new ReportParameter("RFI", search.IncludeRFI ? "1" : "0"); ReportParameter p12 = new ReportParameter("PreScore", search.IncludePre ? "1" : "0"); ReportParameter p13 = new ReportParameter("FinScore", search.IncludeFin ? "1" : "0"); if (search.LevelIdentifier != (int)WebConstants.CorporateSummaryLevels.Level1_Program) { ReportParameter p14 = new ReportParameter("StandardDetail", stdDetail); // reportParameterCollection = new ReportParameterCollection { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15 }; reportParameterCollection = new ReportParameterCollection { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14 }; } else { //reportParameterCollection = new ReportParameterCollection { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14 }; reportParameterCollection = new ReportParameterCollection { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 } }; reportParameterCollection.Add(new ReportParameter("MaxRowCount", maxRowCount.ToString())); if (SortBy != "") { dv.Sort = SortBy + " " + SortOrder; } // Setup Data sources for report reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.ReportPath = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath) + @"Areas\Corporate\Reports\" + rdlcName.ToString(); reportViewer.LocalReport.DataSources.Add(new ReportDataSource(dsName, dv)); reportViewer.LocalReport.SetParameters(reportParameterCollection); Warning[] warnings; string[] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; string format = WebConstants.REPORT_FORMAT_PDF; // PDF is default if (reportType == (int)WebConstants.ReportFormat.EXCEL) { format = WebConstants.REPORT_FORMAT_EXCEL; // If Excel option chosen } fileContents = reportViewer.LocalReport.Render(format, null, out mimeType, out encoding, out extension, out streamIds, out warnings); } catch (Exception ex) { ExceptionLog exceptionLog = new ExceptionLog { ExceptionText = "Reports: " + ex.Message, PageName = "RFIReportRDLC", MethodName = "RFIReportRDLC", UserID = Convert.ToInt32(AppSession.UserID), SiteId = Convert.ToInt32(AppSession.SelectedSiteId), TransSQL = "", HttpReferrer = null }; _exceptionService.LogException(exceptionLog); } return(fileContents); }
public DataSourceResult _departmentcomparativeanalysisOppExcel([DataSourceRequest] DataSourceRequest request, Search search) { DataSourceResult result = new DataSourceResult(); try { SearchFormat searchoutput = new SearchFormat(); searchoutput.CheckInputs(search); List <DepartmentComparativeAnalysisOPP> DepartmentComparativeAnalysis = new List <DepartmentComparativeAnalysisOPP>(); DataTable dt = new DataTable(); dt = ReportDepartmentComparativeAnalysisOpportunities(search).Tables[0]; //convert datatable to list DepartmentComparativeAnalysis = dt.ToList <DepartmentComparativeAnalysisOPP>(); result = DepartmentComparativeAnalysis.ToDataSourceResult(request, dca => new DepartmentComparativeAnalysisOPP { OrgName_Rank3 = dca.OrgName_Rank3, OrgName_Rank2 = dca.OrgName_Rank2, OrgName_Rank1_Dept = dca.OrgName_Rank1_Dept, QuestionText = dca.QuestionText.ReplaceNewline(), StandardEPs = dca.StandardEPs.ReplaceNewline(), TracerCustomName = dca.TracerCustomName, TracerResponseTitle = dca.TracerResponseTitle, ObservationDate = dca.ObservationDate, Numerator = dca.Numerator, Denominator = dca.Denominator, CompliancePercent = dca.CompliancePercent, TracerQuestionNote = dca.TracerQuestionNote.ReplaceNewline(), }); } catch (Exception ex) { if (ex.Message.ToString() == "No Data") { result.Errors = WebConstants.NO_DATA_FOUND_EXCEL_VIEW; } else if (ex.Message.ToString() == "Limit") { result.Errors = "Maximum limit of " + ConfigurationManager.AppSettings["ReportOutputLimit"].ToString() + " records reached. Refine your criteria to narrow the result."; } if (ex.Message.ToString() != "No Data" && ex.Message.ToString() != "Limit") { ExceptionLog exceptionLog = new ExceptionLog { ExceptionText = "Reports: " + ex.Message, PageName = "DepartmentComparativeAnalysis", MethodName = "_departmentcomparativeanalysisOppExcel", UserID = Convert.ToInt32(AppSession.UserID), SiteId = Convert.ToInt32(AppSession.SelectedSiteId), TransSQL = "", HttpReferrer = null }; _exceptionService.LogException(exceptionLog); } } return(result); }
/// <summary> /// LoadForm /// </summary> /// <param name="vo"></param> internal void LoadForm(EntityAccount vo) { try { if (vo == null || string.IsNullOrEmpty(vo.FuncCode)) { return; } this.IsLoadform = true; string strPath = Application.StartupPath + "\\" + vo.FuncFile.Trim(); string className = vo.FuncCode.Trim(); if (className.IndexOf("|") > 0) { className = className.Substring(0, className.IndexOf("|")); } Assembly objAsm = Assembly.LoadFrom(strPath); object obj = objAsm.CreateInstance(className, true); Type objType = obj.GetType(); MethodInfo objMth; int n = 0; foreach (Form frm in Viewer.MdiChildren) { if (frm is frmBaseMdi) { n++; } } if (n >= 10) { DialogBox.Msg("界面设定为最多打开10个,请关闭暂时不需要的界面。", MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(vo.OperName)) { vo.OperName = "Show"; } string strMethod = vo.OperName; object[] objParams = null; int intIndex = strMethod.IndexOf("("); if (intIndex != -1) //带参 { string strParam = strMethod.Substring(intIndex + 1, strMethod.Length - intIndex - 2); objParams = strParam.Split(','); strMethod = strMethod.Substring(0, intIndex); objMth = objType.GetMethod(strMethod); } else { objMth = objType.GetMethod(vo.OperName, new Type[0]); } if (objMth == null) { DialogBox.Msg("自动创建模块失败。", MessageBoxIcon.Exclamation, Viewer); } if (obj is Form) { if (!FormExisted(obj.GetType(), vo.OperName)) { //if (vo.OperName.ToLower().Equals("show")) uiHelper.BeginLoading(Viewer); if (vo.OperName.ToLower().Contains("show")) { uiHelper.BeginLoading(Viewer); } GetFormFuncButton(vo.FuncCode); ((Form)obj).AccessibleName = vo.FuncCode; ((Form)obj).AccessibleDescription = vo.FuncName; MakeMdiForm(obj, vo.OperName); objMth.Invoke(obj, objParams); } } } catch (Exception e) { ExceptionLog.OutPutException(e); DialogBox.Msg(e.Message, MessageBoxIcon.Exclamation, Viewer); } finally { uiHelper.CloseLoading(Viewer); this.IsLoadform = false; } }
/// <summary> /// AddQuestCtrl /// </summary> void AddQuestCtrl(EntityQnRecord qnRecord) { try { if (qnRecord != null) { if (!string.IsNullOrEmpty(qnRecord.xmlData)) { XmlDocument document = new XmlDocument(); document.LoadXml(qnRecord.xmlData); XmlNodeList list = document["FormData"].ChildNodes; xmlData = list[5].OuterXml; dicData = Function.ReadXML(xmlData); } } using (ProxyHms proxy = new ProxyHms()) { lstCtrlLocation = proxy.Service.GetQnCtrlLocation(lstQuest[4], qnRecord.qnId); lstTopic = new List <EntityDicQnSetting>(); lstItems = new List <EntityDicQnSetting>(); proxy.Service.GetQnCustom(1, out lstTopic, out lstItems); } int locationX = 0; int locationY = 0; if (lstCtrlLocation != null && lstCtrlLocation.Count > 0) { foreach (var clVo in lstCtrlLocation) { if (clVo.name.Contains("FM")) { DevExpress.XtraReports.UI.XRLabel lblTopic = new DevExpress.XtraReports.UI.XRLabel(); lblTopic.Name = clVo.name; lblTopic.Text = clVo.text; if (clVo.name == "FM0902" || clVo.name == "FM0903") { lblTopic.Font = new System.Drawing.Font("宋体", 9.5F); lblTopic.ForeColor = System.Drawing.Color.Red; } else { lblTopic.Font = new System.Drawing.Font("宋体", 9.75F, System.Drawing.FontStyle.Bold); } locationX = clVo.locationX; locationY = clVo.locationY; lblTopic.WidthF = clVo.width; //lblTopic.HeightF = clVo.height; lblTopic.Location = new System.Drawing.Point(locationX, locationY); this.Detail.Controls.Add(lblTopic); } } } List <EntityDicQnSetting> lstChildSettings = new List <EntityDicQnSetting>(); if (lstTopic != null && lstTopic.Count > 0) { for (int i = 0; i < lstTopic.Count; i++) { EntityDicQnSetting item = lstTopic[i]; if (item.questName == lstQuest[4]) { if (string.IsNullOrEmpty(item.parentFieldId)) { DevExpress.XtraReports.UI.XRLabel lblTopic = new DevExpress.XtraReports.UI.XRLabel(); lblTopic.Name = item.fieldId; lblTopic.Text = item.fieldName; lblTopic.Font = new System.Drawing.Font("宋体", 9.5F); EntityCtrlLocation ctrLocat = lstCtrlLocation.Find(r => r.name == item.fieldId); locationX = ctrLocat.locationX; locationY = ctrLocat.locationY; lblTopic.WidthF = ctrLocat.width; //lblTopic.HeightF = ctrLocat.height; lblTopic.Location = new System.Drawing.Point(locationX, locationY); this.Detail.Controls.Add(lblTopic); lstChildSettings = lstTopic.FindAll(r => r.parentFieldId == item.fieldId); if (lstChildSettings.Count > 0) { foreach (var childVo in lstChildSettings) { if (childVo.typeId != "3") { DevExpress.XtraReports.UI.XRCheckBox chkAns = new DevExpress.XtraReports.UI.XRCheckBox(); string strEndWith = childVo.fieldId.Substring(4, 2); chkAns.Text = childVo.fieldName; chkAns.Font = new System.Drawing.Font("宋体", 9.5F); chkAns.Name = childVo.fieldId; EntityCtrlLocation ctrLocatChild = lstCtrlLocation.Find(r => r.name == childVo.fieldId); locationX = ctrLocatChild.locationX; locationY = ctrLocatChild.locationY; chkAns.Width = ctrLocatChild.width; //chkAns.Height = ctrLocatChild.height; chkAns.Location = new System.Drawing.Point(locationX, locationY); if (dicData.ContainsKey(childVo.fieldId)) { string value = dicData[childVo.fieldId]; chkAns.Checked = value == "0" ? false : true; } this.Detail.Controls.Add(chkAns); } else { DevExpress.XtraReports.UI.XRLabel txtAns = new DevExpress.XtraReports.UI.XRLabel(); string strEndWith = childVo.fieldId.Substring(4, 2); txtAns.Text = childVo.fieldName; txtAns.Font = new System.Drawing.Font("宋体", 9.5F); txtAns.Name = childVo.fieldId; EntityCtrlLocation ctrLocatChild = lstCtrlLocation.Find(r => r.name == childVo.fieldId); locationX = ctrLocatChild.locationX; locationY = ctrLocatChild.locationY; txtAns.Width = ctrLocatChild.width; //txtAns.Height = ctrLocatChild.height; txtAns.Location = new System.Drawing.Point(locationX, locationY); if (dicData.ContainsKey(childVo.fieldId)) { string value = dicData[childVo.fieldId]; txtAns.Text = value; } this.Detail.Controls.Add(txtAns); } } } } } } } } catch (Exception ex) { ExceptionLog.OutPutException(ex); } finally { } }
public ActionResult CreateERSessionCriteria(SearchCorporateER ERsearch) { try { //Mock Survey Status Parameter. Corporate Reports displays data after Mock Survey Recommendations are approved. ERsearch.MockSurveyStatusID = (int)MockSurveyStatus.Publish_CCA_Recommendation; //if (ERsearch.ProgramIDs == "-1") ERsearch.ProgramIDs = null; if (ERsearch.ProgramNames == "-1" || ERsearch.ProgramNames == null) { ERsearch.ProgramNames = "All"; } if (ERsearch.SelectedChapterIDs == "-1") { ERsearch.SelectedChapterIDs = null; } if (ERsearch.SelectedChapterNames == "-1" || ERsearch.SelectedChapterNames == null) { ERsearch.SelectedChapterNames = "All"; } if (ERsearch.SelectedStandardIDs == "-1") { ERsearch.SelectedStandardIDs = null; } if (ERsearch.SelectedStandardNames == "-1" || ERsearch.SelectedStandardNames == null) { ERsearch.SelectedStandardNames = "All"; } if (ERsearch.SelectedEPIDs == "-1") { ERsearch.SelectedEPIDs = null; } if (ERsearch.SelectedEPLabels == "-1" || ERsearch.SelectedEPLabels == null) { ERsearch.SelectedEPLabels = "All"; } if (ERsearch.MatrixID < 1000) { ERsearch.MatrixID = 0; } Session["ERsearchcriteria"] = ERsearch; return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ExceptionLog exceptionLog = new ExceptionLog { ExceptionText = "Reports: " + ex.Message, PageName = "SaferMatrix", MethodName = "CreateERSessionCriteria", UserID = Convert.ToInt32(AppSession.UserID), SiteId = Convert.ToInt32(AppSession.SelectedSiteId), TransSQL = "", HttpReferrer = null }; exceptionService.LogException(exceptionLog); return(RedirectToAction("Error", "Transfer")); } }
public ActionResult CreateERSessionCriteria(SearchCorporateER ERsearch) { try { if (ERsearch.ProgramIDs == "-1") { ERsearch.ProgramIDs = null; } if (ERsearch.ProgramNames == "-1") { ERsearch.ProgramIDs = "All"; } if (ERsearch.ProgramNames == "-1") { ERsearch.ProgramIDs = "All"; } if (ERsearch.SelectedChapterIDs == "-1") { ERsearch.SelectedChapterIDs = null; } if (ERsearch.SelectedChapterNames == "-1") { ERsearch.SelectedChapterIDs = "All"; } if (ERsearch.SelectedStandardIDs == "-1") { ERsearch.SelectedStandardIDs = null; } if (ERsearch.SelectedStandardNames == "-1") { ERsearch.SelectedStandardNames = "All"; } if (ERsearch.SelectedMockSurveyIDs == "-1") { ERsearch.SelectedMockSurveyIDs = null; } if (ERsearch.SelectedMockSurveyNames == "-1") { ERsearch.SelectedMockSurveyNames = "All"; } if (ERsearch.SelectedMockSurveyLeadIDs == "-1") { ERsearch.SelectedMockSurveyLeadIDs = null; } if (ERsearch.SelectedMockSurveyLeadNames == "-1") { ERsearch.SelectedMockSurveyLeadIDs = "All"; } if (ERsearch.SelectedMockSurveyMemberIDs == "-1") { ERsearch.SelectedMockSurveyMemberIDs = null; } if (ERsearch.SelectedMockSurveyMemberNames == "-1") { ERsearch.SelectedMockSurveyMemberNames = "All"; } Session["ERsearchcriteria"] = ERsearch; return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ExceptionLog exceptionLog = new ExceptionLog { ExceptionText = "Reports: " + ex.Message, PageName = "CorporatePriorityFinding", MethodName = "AMPCorporateSummaryCreateERSessionCriteria", UserID = Convert.ToInt32(AppSession.UserID), SiteId = Convert.ToInt32(AppSession.SelectedSiteId), TransSQL = "", HttpReferrer = null }; exceptionService.LogException(exceptionLog); return(RedirectToAction("Error", "Transfer")); } }
public void m_mthLoadDWReport(DataStore p_dsReport, string dwObject, string p_strParmValue) { DataTable dataTable = new DataTable(); DataTable table = new DataTable(); dataTable = this.m_objPrintInfo.m_dtbBaseInfo; table = this.m_objPrintInfo.m_dtbResult; this.dsReport.LibraryList = Application.StartupPath + "\\pb_lis.pbl"; this.dsReport.DataWindowObject = dwObject; this.dsReport.InsertRow(0); string text = dataTable.Rows[0]["patient_type_chr"].ToString().Trim(); string text2 = text; if (text2 != null) { if (text2 == "2") { this.dsReport.Modify("t_4_2.visible=true"); this.dsReport.Modify("t_4_1.visible=false"); this.dsReport.Modify("t_4_3.visible=false"); this.dsReport.Modify("st_bihno.text = '" + dataTable.Rows[0]["patientcardid_chr"].ToString().Trim() + "'"); } if (text2 == "3") { this.dsReport.Modify("t_4_3.visible=true"); this.dsReport.Modify("t_4_2.visible=false"); this.dsReport.Modify("t_4_1.visible=false"); this.dsReport.Modify("st_bihno.text = '" + dataTable.Rows[0]["patient_inhospitalno_chr"].ToString().Trim() + "'"); } } else { this.dsReport.Modify("t_4_1.visible=true"); this.dsReport.Modify("t_4_2.visible=false"); this.dsReport.Modify("t_4_3.visible=false"); this.dsReport.Modify("st_bihno.text = '" + dataTable.Rows[0]["patient_inhospitalno_chr"].ToString().Trim() + "'"); } this.dsReport.Modify("p_1.filename = '" + Application.StartupPath + "\\Picture\\东莞茶山医院图标.jpg'"); this.dsReport.Modify("st_name.text = '" + dataTable.Rows[0]["patient_name_vchr"].ToString().Trim() + "'"); this.dsReport.Modify("st_sex.text = '" + dataTable.Rows[0]["sex_chr"].ToString().Trim() + "'"); this.dsReport.Modify("st_age.text = '" + dataTable.Rows[0]["age_chr"].ToString().Trim() + "'"); this.dsReport.Modify("st_checkno.text = '" + dataTable.Rows[0]["check_no_chr"].ToString().Trim() + "'"); this.dsReport.Modify("st_dept.text = '" + dataTable.Rows[0]["deptname_vchr"].ToString().Trim() + "'"); this.dsReport.Modify("st_bedno.text = '" + dataTable.Rows[0]["bedno_chr"].ToString().Trim() + "'"); this.dsReport.Modify("st_sample.text = '" + dataTable.Rows[0]["sample_type_desc_vchr"].ToString().Trim() + "'"); DataView dataView = new DataView(table); dataView.RowFilter = "is_graph_result_num = 0"; dataView.Sort = "sample_print_seq_int asc"; int num = 21; int num2 = 0; while (num2 < dataView.Count && num < 221) { DataRowView dataRowView = dataView[num2]; this.dsReport.Modify("t_" + Convert.ToString(num++) + ".text = '" + dataRowView["device_check_item_name_vchr"].ToString().Trim() + "'"); this.dsReport.Modify("t_" + Convert.ToString(num++) + ".text = '" + dataRowView["rptno_chr"].ToString().Trim() + "'"); string text3 = dataRowView["result_vchr"].ToString().Trim(); string text4 = dataRowView["min_val_dec"].ToString().Trim(); string text5 = dataRowView["max_val_dec"].ToString().Trim(); if (!string.IsNullOrEmpty(text4) && !string.IsNullOrEmpty(text5)) { if (decimal.Parse(text3) > decimal.Parse(text5)) { text3 = text3.PadRight(6, ' ') + "↑"; } else { if (decimal.Parse(text3) < decimal.Parse(text4)) { if (text3.Contains(">") || text3.Contains("<")) { text3 = text3.PadRight(6, ' ') + "↑"; } else { text3 = text3.PadRight(6, ' ') + "↓"; } } } } this.dsReport.Modify("t_" + Convert.ToString(num++) + ".text = '" + text3 + "'"); this.dsReport.Modify("t_" + Convert.ToString(num++) + ".text = '" + dataRowView["refrange_vchr"].ToString().Trim() + "'"); this.dsReport.Modify("t_" + Convert.ToString(num++) + ".text = '" + dataRowView["unit_vchr"].ToString().Trim() + "'"); num2++; } dataView.RowFilter = "is_graph_result_num = 1"; dataView.Sort = "sample_print_seq_int asc"; MemoryStream memoryStream = null; for (int i = 0; i < dataView.Count; i++) { DataRowView dataRowView = dataView[i]; if (!(dataRowView["graph_img"] is DBNull)) { try { memoryStream = new MemoryStream(dataRowView["graph_img"] as byte[]); Image image = Image.FromStream(memoryStream, true); image.Save("D:\\\\code\\\\0001.jpg", ImageFormat.Jpeg); image.Dispose(); this.dsReport.Modify("p_img.filename = 'D:\\code\\0001.jpg'"); break; } catch (Exception ex) { //MessageBox.Show(ex.ToString()); ExceptionLog.OutPutException("m_mthLoadDWReport-->" + ex); } finally { if (memoryStream != null) { memoryStream.Close(); } } } } this.dsReport.Modify("t_confirmdate.text = '" + DateTime.Parse(dataTable.Rows[0]["confirm_dat"].ToString().Trim()).ToString("yyyy-MM-dd") + "'"); this.dsReport.Modify("t_reportor.text = '" + dataTable.Rows[0]["reportor"].ToString().Trim() + "'"); this.dsReport.Modify("t_confirmer.text = '" + dataTable.Rows[0]["confirmer"].ToString().Trim() + "'"); }
public ActionResult CorporateReport_Data(SearchCorporateER search, int LevelIdentifier) { try { //Mock Survey Status Parameter. Corporate Reports displays data after Mock Survey Recommendations are approved. search.MockSurveyStatusID = (int)MockSurveyStatus.Publish_CCA_Recommendation; JsonResult jr = new JsonResult(); if (search.ProgramIDs == "-1") { search.ProgramIDs = null; } if (search.SelectedChapterIDs == "-1") { search.SelectedChapterIDs = null; } if (search.SelectedStandardIDs == "-1") { search.SelectedStandardIDs = null; } if (search.SelectedMockSurveyIDs == "-1") { search.SelectedMockSurveyIDs = null; } if (search.SelectedMockSurveyLeadIDs == "-1") { search.SelectedMockSurveyLeadIDs = null; } if (search.SelectedMockSurveyMemberIDs == "-1") { search.SelectedMockSurveyMemberIDs = null; } string JCREmailDomain = "@JCRINC.COM"; string JCREmailDomain2 = "@JCAHO.COM"; string encryptionKey = ConfigurationManager.AppSettings.Get("EncryptionKey"); switch (LevelIdentifier) { case (int)WebConstants.CorporateSummaryLevels.Level1_Program: { List <CorpProgramFinding> Level1Data = new List <CorpProgramFinding>(); Level1Data = CorporateFinding.GetCorpFindingByProgram(search); jr = Json(Level1Data, JsonRequestBehavior.AllowGet); break; } case (int)WebConstants.CorporateSummaryLevels.Level2_Chapter: { if (search.IsDuplicateLoadCall) { jr = TempData["ACS_Level2Data"] as JsonResult; } else { List <CorpChapterFinding> Level2Data = new List <CorpChapterFinding>(); Level2Data = CorporateFinding.GetCorpFindingByChapter(search); jr = Json(Level2Data, JsonRequestBehavior.AllowGet); TempData["ACS_Level2Data"] = jr; } break; } case (int)WebConstants.CorporateSummaryLevels.Level3_Standard: { if (search.IsDuplicateLoadCall) { jr = TempData["ACS_Level3Data"] as JsonResult; } else { List <CorpStandardFinding> Level3Data = new List <CorpStandardFinding>(); Level3Data = CorporateFinding.GetCorpFindingByStandard(search); var max = Convert.ToInt32(Level3Data.Max(r => r.CumulativePercentage)); Session["MaxStandardCount"] = max >= 100 ? 100 : max; jr = Json(Level3Data, JsonRequestBehavior.AllowGet); TempData["ACS_Level3Data"] = jr; } break; } case (int)WebConstants.CorporateSummaryLevels.Level4_EP: { string tjcFinding = string.Empty; List <CorpEPFinding> Level4Data = new List <CorpEPFinding>(); Level4Data = CorporateFinding.GetCorpFindingByEP(search); if (!AppSession.EmailAddress.ToUpper().Contains(JCREmailDomain) && !AppSession.EmailAddress.ToUpper().Contains(JCREmailDomain2)) { Level4Data.ToList().ForEach(data => { data.TJCFinding = CryptHelpers.RFIDecrypt(data.TJCFinding, encryptionKey); }); } else { Level4Data.ToList().ForEach(data => data.TJCFinding = string.Empty); } jr = Json(Level4Data, JsonRequestBehavior.AllowGet); break; } case (int)WebConstants.CorporateSummaryLevels.Level5_EPDetails: { List <CorpStandardFinding> Level5Data = new List <CorpStandardFinding>(); Level5Data = CorporateFinding.GetCorpFindingByStandard(search); jr = Json(Level5Data, JsonRequestBehavior.AllowGet); break; } } jr.MaxJsonLength = Int32.MaxValue; jr.RecursionLimit = 100; return(jr); } catch (Exception ex) { ExceptionLog exceptionLog = new ExceptionLog { ExceptionText = "Reports: " + ex.Message, PageName = "CorporatePriorityFinding", MethodName = "AMPCorporateSummaryCorporateReport_Data", UserID = Convert.ToInt32(AppSession.UserID), SiteId = Convert.ToInt32(AppSession.SelectedSiteId), TransSQL = "", HttpReferrer = null }; exceptionService.LogException(exceptionLog); return(RedirectToAction("Error", "Transfer")); } }
/// <summary> /// Binds the exception occurrence grid. /// </summary> /// <param name="baseException">Exception to base the occurrence grid off of.</param> private void BindExceptionOccurrenceGrid( ExceptionLog baseException ) { ExceptionLogService exceptionService = new ExceptionLogService( new RockContext() ); string url = String.Format( "{0}?ExceptionId=", LinkedPageUrl( "DetailPage" ) ); var query = exceptionService.Queryable() .Where( e => e.HasInnerException == null || e.HasInnerException == false ) .Where( e => e.Description.Substring( 0, 28 ) == baseException.Description.Substring( 0, 28 ) ) .Select( e => new { Id = e.Id, CreatedDateTime = e.CreatedDateTime, PageName = e.Page.InternalName ?? e.PageUrl, FullName = ( e.CreatedByPersonAlias != null && e.CreatedByPersonAlias.Person != null ) ? e.CreatedByPersonAlias.Person.LastName + ", " + e.CreatedByPersonAlias.Person.NickName : "", Description = "<a href='" + url + e.Id + "'>" + e.Description + "</a>" } ).OrderBy( e => e.CreatedDateTime ); if ( gExceptionOccurrences.SortProperty == null ) { query = query.OrderByDescending( e => e.CreatedDateTime ); } else { query = query.Sort( gExceptionOccurrences.SortProperty ); } gExceptionOccurrences.EntityTypeId = EntityTypeCache.Read<ExceptionLog>().Id; gExceptionOccurrences.SetLinqDataSource( query ); gExceptionOccurrences.DataBind(); }
public void LogExceptionDataToDb(ExceptionLog additionalExData) { _dalFactory.LogExceptionToDb(additionalExData); }
public bool Add(ExceptionLog entity) { return(_ctx.ExceptionLogs.Add(entity) != null); }
public void Edit(ExceptionLog entity) { _ctx.Entry(entity).State = System.Data.Entity.EntityState.Modified; }
/// <summary> /// Populates the <see cref="Rock.Model.ExceptionLog" /> entity with the exception data. /// </summary> /// <param name="ex">The <see cref="System.Exception" /> to log.</param> /// <param name="context">The <see cref="System.Web.HttpContext" />.</param> /// <param name="pageId">An <see cref="System.Int32" /> containing the Id of the <see cref="Rock.Model.Page" /> where the exception occurred. /// This value is nullable.</param> /// <param name="siteId">An <see cref="System.Int32" /> containing the Id the <see cref="Rock.Model.Site" /> where the exception occurred. /// This value is nullable.</param> /// <param name="personAlias">The person alias.</param> /// <returns></returns> private static ExceptionLog PopulateExceptionLog( Exception ex, HttpContext context, int? pageId, int? siteId, PersonAlias personAlias ) { int? personAliasId = null; if (personAlias != null) { personAliasId = personAlias.Id; } string exceptionMessage = ex.Message; if ( ex is System.Data.SqlClient.SqlException ) { var sqlEx = ex as System.Data.SqlClient.SqlException; var sqlErrorList = sqlEx.Errors.OfType<System.Data.SqlClient.SqlError>().ToList().Select(a => string.Format("{0}: Line {1}", a.Procedure, a.LineNumber)); if ( sqlErrorList.Any() ) { exceptionMessage += string.Format( "[{0}]", sqlErrorList.ToList().AsDelimited(", ") ); } } var exceptionLog = new ExceptionLog { SiteId = siteId, PageId = pageId, HasInnerException = ex.InnerException != null, ExceptionType = ex.GetType().ToString(), Description = exceptionMessage, Source = ex.Source, StackTrace = ex.StackTrace, Guid = Guid.NewGuid(), CreatedByPersonAliasId = personAliasId, ModifiedByPersonAliasId = personAliasId, CreatedDateTime = RockDateTime.Now, ModifiedDateTime = RockDateTime.Now, ModifiedAuditValuesAlreadyUpdated = true }; if ( exceptionLog.StackTrace == null ) { try { // if the Exception didn't include a StackTrace, manually grab it var stackTrace = new System.Diagnostics.StackTrace( 2 ); exceptionLog.StackTrace = stackTrace.ToString(); } catch { // ignore } } try { ex.Data.Add( "ExceptionLogGuid", exceptionLog.Guid ); } catch { // ignore } try { // If current HttpContext is null, return early. if ( context == null ) { return exceptionLog; } // If current HttpContext is available, populate its information as well. var request = context.Request; StringBuilder cookies = new StringBuilder(); var cookieList = request.Cookies; if ( cookieList.Count > 0 ) { cookies.Append( "<table class=\"cookies exception-table\">" ); foreach ( string cookie in cookieList ) { var httpCookie = cookieList[cookie]; if ( httpCookie != null ) cookies.Append( "<tr><td><b>" + cookie + "</b></td><td>" + httpCookie.Value.EncodeHtml() + "</td></tr>" ); } cookies.Append( "</table>" ); } StringBuilder formItems = new StringBuilder(); var formList = request.Form; if ( formList.Count > 0 ) { formItems.Append( "<table class=\"form-items exception-table\">" ); foreach ( string formItem in formList ) { formItems.Append( "<tr><td><b>" + formItem + "</b></td><td>" + formList[formItem].EncodeHtml() + "</td></tr>" ); } formItems.Append( "</table>" ); } StringBuilder serverVars = new StringBuilder(); var serverVarList = request.ServerVariables; if ( serverVarList.Count > 0 ) { serverVars.Append( "<table class=\"server-variables exception-table\">" ); foreach ( string serverVar in serverVarList ) serverVars.Append( "<tr><td><b>" + serverVar + "</b></td><td>" + serverVarList[serverVar].EncodeHtml() + "</td></tr>" ); serverVars.Append( "</table>" ); } exceptionLog.Cookies = cookies.ToString(); exceptionLog.StatusCode = context.Response.StatusCode.ToString(); exceptionLog.PageUrl = request.Url.ToString(); exceptionLog.ServerVariables = serverVars.ToString(); exceptionLog.QueryString = request.Url.Query; exceptionLog.Form = formItems.ToString(); } catch { // Intentionally do nothing } return exceptionLog; }
public ExceptionLog Remove(ExceptionLog entity) { return(_ctx.ExceptionLogs.Remove(entity)); }
private void LogError( Exception ex, int parentException, string status, System.Web.HttpContext context ) { try { // get the current user Rock.CMS.User user = Rock.CMS.UserService.GetCurrentUser(); // save the exception info to the db ExceptionLogService service = new ExceptionLogService(); ExceptionLog exceptionLog = new ExceptionLog(); ; exceptionLog.ParentId = parentException; exceptionLog.ExceptionDate = DateTime.Now; if ( ex.InnerException != null ) exceptionLog.HasInnerException = true; exceptionLog.Description = ex.Message; exceptionLog.StackTrace = ex.StackTrace; exceptionLog.Source = ex.Source; exceptionLog.StatusCode = status; if ( context.Items["Rock:SiteId"] != null ) exceptionLog.SiteId = Int32.Parse( context.Items["Rock:SiteId"].ToString() ); if ( context.Items["Rock:PageId"] != null ) exceptionLog.PageId = Int32.Parse( context.Items["Rock:PageId"].ToString() ); exceptionLog.ExceptionType = ex.GetType().Name; exceptionLog.PageUrl = context.Request.RawUrl; exceptionLog.QueryString = context.Request.QueryString.ToString(); // write cookies StringBuilder cookies = new StringBuilder(); cookies.Append("<table class=\"cookies\">"); foreach ( string cookie in context.Request.Cookies ) cookies.Append( "<tr><td><b>" + cookie + "</b></td><td>" + context.Request.Cookies[cookie].Value + "</td></tr>" ); cookies.Append( "</table>" ); exceptionLog.Cookies = cookies.ToString(); // write form items StringBuilder formItems = new StringBuilder(); cookies.Append( "<table class=\"formItems\">" ); foreach ( string formItem in context.Request.Form ) cookies.Append( "<tr><td><b>" + formItem + "</b></td><td>" + context.Request.Form[formItem].ToString() + "</td></tr>" ); cookies.Append( "</table>" ); exceptionLog.Form = formItems.ToString(); // write server vars StringBuilder serverVars = new StringBuilder(); cookies.Append( "<table class=\"server-variables\">" ); foreach ( string serverVar in context.Request.ServerVariables ) serverVars.Append( "<tr><td><b>" + serverVar + "</b></td><td>" + context.Request.ServerVariables[serverVar].ToString() + "</td></tr>" ); cookies.Append( "</table>" ); exceptionLog.ServerVariables = serverVars.ToString(); if (user != null) exceptionLog.PersonId = user.PersonId; service.Add( exceptionLog, null ); service.Save( exceptionLog, null ); // log inner exceptions if ( ex.InnerException != null ) LogError( ex.InnerException, exceptionLog.Id, status, context ); } catch ( Exception exception ) { // if you get an exception while logging an exception I guess you're hosed... } }
// PUT: api/Supplier/5 public string Put(int id, HttpRequestMessage value) { try { Model.Supplier supplier = new Model.Supplier(); supplier = (from p in db.Suppliers where p.Supplier_ID == id select p).First(); string message = HttpContext.Current.Server.UrlDecode(value.Content.ReadAsStringAsync().Result).Substring(5); JObject json = JObject.Parse(message); JObject supplierDetails = (JObject)json["supplier"]; JArray componentDetails = (JArray)json["components"]; JArray partTypeDetails = (JArray)json["parts"]; JArray RawMaterialDetails = (JArray)json["raw"]; supplier.Name = (string)supplierDetails["Name"]; supplier.Address = (string)supplierDetails["Address"]; supplier.City = (string)supplierDetails["City"]; supplier.Zip = (string)supplierDetails["Zip"]; supplier.Bank_Account_Number = (string)supplierDetails["Bank_Account_Number"]; supplier.Bank_Branch = (string)supplierDetails["Bank_Branch"]; supplier.Bank_Name = (string)supplierDetails["Bank_Name"]; supplier.Email = (string)supplierDetails["Email"]; supplier.Contact_Number = (string)supplierDetails["Contact_Number"]; supplier.Status = Convert.ToBoolean(supplierDetails["Status"]); supplier.Province_ID = (int)supplierDetails["Province_ID"]; supplier.Bank_Reference = (string)supplierDetails["Bank_Reference"]; supplier.Contact_Name = (string)supplierDetails["Contact_Name"]; supplier.Foreign_Bank = Convert.ToBoolean(supplierDetails["Foreign_Bank"]); string errorString = "false|"; bool error = false; if ((from t in db.Suppliers where t.Name == supplier.Name && t.Supplier_ID != id select t).Count() != 0) { error = true; errorString += "The Supplier name entered already exists on the system. "; } if ((from t in db.Suppliers where t.Contact_Name == supplier.Contact_Name && t.Supplier_ID != id select t).Count() != 0) { error = true; errorString += "The Contact Name entered already exists on the system. "; } if ((from t in db.Suppliers where t.Email == supplier.Email && t.Supplier_ID != id select t).Count() != 0) { error = true; errorString += "The Contact Email entered already exists on the system. "; } if ((from t in db.Suppliers where t.Contact_Number == supplier.Contact_Number && t.Supplier_ID != id select t).Count() != 0) { error = true; errorString += "The Contact Number entered already exists on the system. "; } if ((from t in db.Suppliers where (t.Address == supplier.Address && t.City == supplier.City && t.Zip == supplier.Zip) && t.Supplier_ID != id select t).Count() != 0) { error = true; errorString += "The Supplier Address entered already exists on the system. "; } if ((from t in db.Suppliers where (t.Bank_Account_Number == supplier.Bank_Account_Number && t.Bank_Branch == supplier.Bank_Branch) && t.Supplier_ID != id select t).Count() != 0) { error = true; errorString += "The Supplier Banking details entered already exists on the system. "; } if (error) { return(errorString); } db.Component_Supplier.RemoveRange(db.Component_Supplier.Where(x => x.Supplier_ID == id)); if (componentDetails != null) { foreach (JObject comp in componentDetails) { Component_Supplier cs = new Component_Supplier(); cs.Component_ID = (int)comp["Component_ID"]; cs.Supplier_ID = id; cs.is_preferred = Convert.ToBoolean(Convert.ToInt32(comp["Is_Prefered"])); cs.unit_price = (decimal)comp["unit_price"]; db.Component_Supplier.Add(cs); } } db.Part_Supplier.RemoveRange(db.Part_Supplier.Where(x => x.Supplier_ID == id)); if (partTypeDetails != null) { foreach (JObject part in partTypeDetails) { Part_Supplier ps = new Part_Supplier(); ps.Part_Type_ID = (int)part["Part_Type_ID"]; ps.Supplier_ID = id; ps.Is_Prefered = Convert.ToBoolean(Convert.ToInt32(part["Is_Prefered"])); ps.unit_price = (decimal)part["unit_price"]; db.Part_Supplier.Add(ps); } } db.Raw_Material_Supplier.RemoveRange(db.Raw_Material_Supplier.Where(x => x.Supplier_ID == id)); if (RawMaterialDetails != null) { foreach (JObject raw in RawMaterialDetails) { Raw_Material_Supplier rms = new Raw_Material_Supplier(); rms.Raw_Material_ID = (int)raw["Raw_Material_ID"]; rms.Supplier_ID = id; rms.Is_Prefered = Convert.ToBoolean(Convert.ToInt32(raw["Is_Prefered"])); rms.unit_price = (decimal)raw["unit_price"]; db.Raw_Material_Supplier.Add(rms); } } db.SaveChanges(); return("true|Supplier successfully updated."); } catch (Exception e) { ExceptionLog.LogException(e, "SupplierController PUT"); return("false|An error has occured updating the Suplier on the system."); } }
/// <summary> /// Binds the exception occurrence grid. /// </summary> /// <param name="baseException">Exception to base the occurrence grid off of.</param> private void BindExceptionOccurrenceGrid( ExceptionLog baseException ) { ExceptionLogService exceptionService = new ExceptionLogService( new RockContext() ); var query = exceptionService.Queryable() .Where( e => e.HasInnerException == null || e.HasInnerException == false ) .Where( e => e.SiteId == baseException.SiteId ) .Where( e => e.PageId == baseException.PageId ) .Where( e => e.Description == baseException.Description ) .Select( e => new { Id = e.Id, CreatedDateTime = e.CreatedDateTime, FullName = ( e.CreatedByPersonAlias != null && e.CreatedByPersonAlias.Person != null ) ? e.CreatedByPersonAlias.Person.LastName + ", " + e.CreatedByPersonAlias.Person.NickName : "", Description = e.Description } ).OrderBy(e => e.CreatedDateTime); if ( gExceptionOccurrences.SortProperty == null ) { gExceptionOccurrences.DataSource = query.OrderByDescending( e => e.CreatedDateTime ).ToList(); } else { gExceptionOccurrences.DataSource = query.Sort( gExceptionOccurrences.SortProperty ).ToList(); } gExceptionOccurrences.DataBind(); }
public override void context() { IExceptionLogParser parser = new ExceptionLogParser(); _logs = parser.Parse(LOG.ToStream()); _log = _logs.FirstOrDefault(); }