public void InsertErrorLog(ErrorLog model) { try { context.ErrorLog.Add(model); context.SaveChanges(); } catch (Exception ex) { } }
public bool DeleteAffidavitAttachment(long attachmentId) { bool result = false; try { var existingItem = context.AffidavitAttachment.Where(x => x.AttachmentId == attachmentId).FirstOrDefault(); if (existingItem != null) { context.AffidavitAttachment.Remove(existingItem); } context.SaveChanges(); result = true; } catch (Exception ex) { result = false; } return(result); }
public bool SaveTrackItDetails(AffidavitModel aff) { context = new SWPostEntities(); FormsAndFinalInspections form = new FormsAndFinalInspections(); try { form.AffidavitId = aff.AffidavitId; form.Comments = aff.Comments; form.RequestedDate = DateTime.Now; context.FormsAndFinalInspections.Add(form); context.SaveChanges(); } catch (Exception ex) { throw ex; } return(true); }
public bool AddAffidavitFormInspection(AffidavitFormInspection model, int type) { bool result = false; try { var existingRecord = context.AffidavitFormInspection.Where(x => x.AffidavitId.Equals(model.AffidavitId)).FirstOrDefault(); if (existingRecord == null) { model.InspectionDate = DateTime.Now; AffidavitHistory history = new AffidavitHistory(); var affidavit = context.Affidavit.Where(x => x.AffidavitID.Equals(model.AffidavitId)).FirstOrDefault(); var status = context.AffidavitStatus.Where(x => x.AffidavitStatusId == type).FirstOrDefault(); history.StatusValue = status.Status; affidavit.Status = status.AffidavitStatusId; history.AffidavitId = model.AffidavitId; history.AffidavitStatusId = type; history.CreatedDate = DateTime.Now; if (type == 5) { history.Comments = model.OtherDoNotPour; history.InspectorId = model.FormFailInspectorId; model.FormFailDate = DateTime.Now; } else if (type == 6) { history.Comments = model.OtherGrantedToPour; history.InspectorId = model.FormPassInspectorId; model.PermissionGranted = true; model.CompletionDate = DateTime.Now; } //model.AffidavitHistory.Add(history); context.AffidavitFormInspection.Add(model); context.AffidavitHistory.Add(history); context.SaveChanges(); } else { //var existingRecordHistory = existingRecord.AffidavitHistory.Where(x => x.AffidavitStatusId == type).FirstOrDefault(); var existingRecordHistory = context.AffidavitHistory.Where(x => x.AffidavitStatusId == type && x.AffidavitId == existingRecord.AffidavitId).FirstOrDefault(); if (existingRecordHistory != null) { var history = context.AffidavitHistory.Where(x => x.AffidavitId.Equals(model.AffidavitId) && x.AffidavitStatusId.Equals(type)).FirstOrDefault(); if (type == 5) { history.Comments = model.OtherDoNotPour; history.InspectorId = model.FormFailInspectorId; model.FormFailDate = DateTime.Now; } else if (type == 6) { history.Comments = model.OtherGrantedToPour; history.InspectorId = model.FormPassInspectorId; existingRecord.PermissionGranted = true; existingRecord.CompletionDate = DateTime.Now; } history.CreatedDate = DateTime.Now; } else { AffidavitHistory history = new AffidavitHistory(); var affidavit = context.Affidavit.Where(x => x.AffidavitID.Equals(model.AffidavitId)).FirstOrDefault(); var status = context.AffidavitStatus.Where(x => x.AffidavitStatusId == type).FirstOrDefault(); history.StatusValue = status.Status; affidavit.Status = status.AffidavitStatusId; history.AffidavitId = model.AffidavitId; history.AffidavitStatusId = type; history.CreatedDate = DateTime.Now; if (type == 5) { history.Comments = model.OtherDoNotPour; history.InspectorId = model.FormFailInspectorId; model.FormFailDate = DateTime.Now; } else if (type == 6) { history.Comments = model.OtherGrantedToPour; history.InspectorId = model.FormPassInspectorId; existingRecord.PermissionGranted = true; existingRecord.CompletionDate = DateTime.Now; } context.AffidavitHistory.Add(history); } existingRecord.Sidewalk = model.Sidewalk; existingRecord.Driveway = model.Driveway; existingRecord.Curb = model.Curb; existingRecord.NotReady = model.NotReady; existingRecord.InsufficientBarricades = model.InsufficientBarricades; existingRecord.RemoveDebris = model.RemoveDebris; existingRecord.NotDeep = model.NotDeep; existingRecord.CurbHeight = model.CurbHeight; existingRecord.SawCutEdges = model.SawCutEdges; existingRecord.NoPermit = model.NoPermit; existingRecord.OtherDoNotPour = model.OtherDoNotPour; existingRecord.OtherGrantedToPour = model.OtherGrantedToPour; existingRecord.Partial = model.Partial; existingRecord.PartialDescription = model.PartialDescription; existingRecord.MatchJointPattern = model.MatchJointPattern; existingRecord.ToolDeepJoints = model.ToolDeepJoints; existingRecord.PlaceJoints = model.PlaceJoints; //existingRecord.PermissionGranted = model.PermissionGranted; context.SaveChanges(); } result = true; } catch (Exception ex) { result = false;; } return(result); }
/// <summary> /// this method will create permit /// </summary> /// <param name="model"></param> /// <returns></returns> public Permit InsertPermit(Permit model) { try { string AffidavitID = model.AffidavitID.ToString(); model.NEW_AFF = affidavitLogic.GetAffidavitDetails(AffidavitID).NEW_AFF.ToString(); context.Permit.Add(model); context.SaveChanges(); if (model.PermitID > 0) { context.SP_AfterInsertPermit(model.PermitID); } } catch (Exception ex) { model = null; } return(model); }
public async Task <bool> SyncOracleSqlCCB() { bool finalResult = false; List <CCB_DAILY_LICENSES> contractorList = new List <CCB_DAILY_LICENSES>(); string oracleConnection = ConfigurationManager.ConnectionStrings["OracleConnection"].ToString(); OracleConnection conn = new OracleConnection(oracleConnection); try { ErrorLog log = new ErrorLog(); log.LogId = Guid.NewGuid(); //log.CreatedDate = DateTime.UtcNow; log.CreatedDate = DateTime.Now; log.Message = "Sync(CCB Licenses Table from Oracle DB) Started"; log.StackTrace = "Success"; context.ErrorLog.Add(log); context.SaveChanges(); using (conn = new OracleConnection(oracleConnection)) { using (OracleCommand command = conn.CreateCommand()) { string sql = "SELECT S_1, S_4, S_5, S_6, S_7, S_8, S_9, S_27, S_28 FROM AMANDA.CCB_DAILY_LICENSES order by S_1"; command.CommandText = sql; conn.Open(); OracleDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { CCB_DAILY_LICENSES result = new CCB_DAILY_LICENSES(); result.license_number = (!string.IsNullOrEmpty(dataReader["S_1"].ToString())) ? long.Parse(dataReader["S_1"].ToString()) : 0; //result.business_name = dataReader["S_4"].ToString(); result.business_name = dataReader["S_4"].ToString().Replace("&", "AND"); result.address = dataReader["S_5"].ToString(); result.city = dataReader["S_6"].ToString(); result.state = dataReader["S_7"].ToString(); result.zip = dataReader["S_8"].ToString(); result.business_telephone = (!string.IsNullOrEmpty(dataReader["S_9"].ToString())) ? long.Parse(dataReader["S_9"].ToString()) : 0; result.rmi_name = dataReader["S_27"].ToString(); result.lic_exp_date = (!string.IsNullOrEmpty(dataReader["S_28"].ToString())) ? DateTime.Parse(dataReader["S_28"].ToString()) : DateTime.MinValue; result.CCB_Id = Guid.NewGuid(); var alias = context.Contractor_Alias.Where(x => x.CCB_No.Equals(result.license_number)).FirstOrDefault(); if (alias != null && !string.IsNullOrEmpty(alias.Alias)) { result.alias_name = alias.Alias; } contractorList.Add(result); } } // Close and Dispose OracleConnection object conn.Close(); conn.Dispose(); } var existingCCB = context.CCB_DAILY_LICENSES.ToList(); context.CCB_DAILY_LICENSES.RemoveRange(existingCCB); context.CCB_DAILY_LICENSES.AddRange(contractorList); context.SaveChanges(); finalResult = true; } catch (Exception ex) { finalResult = false; ErrorLog log = new ErrorLog(); log.LogId = Guid.NewGuid(); //log.CreatedDate = DateTime.UtcNow; log.CreatedDate = DateTime.Now; log.Message = ex.Message; log.StackTrace = ex.StackTrace; context.ErrorLog.Add(log); context.SaveChanges(); } finally { conn.Close(); conn.Dispose(); ErrorLog log = new ErrorLog(); if (finalResult) { log.LogId = Guid.NewGuid(); //log.CreatedDate = DateTime.UtcNow; log.CreatedDate = DateTime.Now; log.Message = "Sync(CCB Licenses Table from Oracle DB) Finished"; log.StackTrace = "Success"; context.ErrorLog.Add(log); context.SaveChanges(); } else { log.LogId = Guid.NewGuid(); //log.CreatedDate = DateTime.UtcNow; log.CreatedDate = DateTime.Now; log.Message = "CCB Licenses Table from Oracle DB is Not-Synced"; log.StackTrace = "Failed"; context.ErrorLog.Add(log); context.SaveChanges(); } } return(finalResult); }