public DosarView(int _CURENT_USER_ID, int _ID_SOCIETATE, Dosar dosar, string conStr) { if (HttpContext.Current.Session["TOKEN"] == null) // nu e request din link email notificare { this.Dosar = dosar; this.dosarJson = new DosarJson(_CURENT_USER_ID, _ID_SOCIETATE, conStr); SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(_CURENT_USER_ID, conStr); //this.SocietatiCASCO = this.SocietatiRCA = (SocietateAsigurare[])sar.GetAll().Result; this.SocietatiAsigurare = (SocietateAsigurare[])sar.GetAll().Result; NomenclatoareRepository nr = new NomenclatoareRepository(_CURENT_USER_ID, conStr); this.TipuriCaz = (Nomenclator[])nr.GetAll("tip_caz").Result; this.TipuriDosar = (Nomenclator[])nr.GetAll("tip_dosare").Result; this.StatusDosare = SOCISA.CommonFunctions.STATUS_DOSARE; //daca vrem sa aducem din start inregistrari !!! DosareRepository dr = new DosareRepository(_CURENT_USER_ID, conStr); string filter = String.Format(" DOSARE.ID_SOCIETATE_CASCO = {0} ", HttpContext.Current.Session["ID_SOCIETATE"]); string limit = String.Format(" LIMIT 0, {0} ", (SOCISA.CommonFunctions.ROWS_BLOCK_SIZE).ToString()); this.DosareResult = (Dosar[])dr.GetFiltered(null, null, filter, limit).Result; this.FilteredRowsCount = Convert.ToInt32(dr.CountFiltered(null, null, filter, null).Result); } else // request din link email notificare - doar un dosar { SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(_CURENT_USER_ID, conStr); //this.SocietatiCASCO = this.SocietatiRCA = (SocietateAsigurare[])sar.GetAll().Result; this.SocietatiAsigurare = (SocietateAsigurare[])sar.GetAll().Result; NomenclatoareRepository nr = new NomenclatoareRepository(_CURENT_USER_ID, conStr); this.TipuriCaz = (Nomenclator[])nr.GetAll("tip_caz").Result; this.TipuriDosar = (Nomenclator[])nr.GetAll("tip_dosare").Result; this.StatusDosare = SOCISA.CommonFunctions.STATUS_DOSARE; this.Dosar = dosar; DosareResult = new Dosar[] { dosar }; this.dosarJson = new DosarJson(_CURENT_USER_ID, _ID_SOCIETATE, conStr); this.FilteredRowsCount = 1; } }
public DosarView(int _CURENT_USER_ID, int _ID_SOCIETATE, string conStr, string predefinedFilter) { if (HttpContext.Current.Session["TOKEN"] == null) // nu e request din link email notificare { SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(_CURENT_USER_ID, conStr); //this.SocietatiCASCO = this.SocietatiRCA = (SocietateAsigurare[])sar.GetAll().Result; this.SocietatiAsigurare = (SocietateAsigurare[])sar.GetAll().Result; NomenclatoareRepository nr = new NomenclatoareRepository(_CURENT_USER_ID, conStr); this.TipuriCaz = (Nomenclator[])nr.GetAll("tip_caz").Result; this.TipuriDosar = (Nomenclator[])nr.GetAll("tip_dosare").Result; this.StatusDosare = SOCISA.CommonFunctions.STATUS_DOSARE; try { //daca vrem sa aducem din start inregistrari !!! DosareRepository dr = new DosareRepository(_CURENT_USER_ID, conStr); //string filter = String.Format(" DOSARE.ID_SOCIETATE_CASCO = {0} ", HttpContext.Current.Session["ID_SOCIETATE"]); string filter = String.IsNullOrWhiteSpace(predefinedFilter) ? String.Format(" DOSARE.ID_SOCIETATE_CASCO = {0} ", HttpContext.Current.Session["ID_SOCIETATE"]) : predefinedFilter; string limit = String.Format(" LIMIT 0, {0} ", (SOCISA.CommonFunctions.ROWS_BLOCK_SIZE).ToString()); this.DosareResult = (Dosar[])dr.GetFiltered(null, null, filter, limit).Result; this.Dosar = DosareResult[0]; this.dosarJson = new DosarJson(_CURENT_USER_ID, _ID_SOCIETATE, conStr); this.FilteredRowsCount = Convert.ToInt32(dr.CountFiltered(null, null, filter, null).Result); } catch { this.DosareResult = null; this.Dosar = new Dosar(); Dosar.ID_SOCIETATE_CASCO = Convert.ToInt32(HttpContext.Current.Session["ID_SOCIETATE"]); this.dosarJson = new DosarJson(); this.FilteredRowsCount = 0; } } else // request din link email notificare - doar un dosar { SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(_CURENT_USER_ID, conStr); //this.SocietatiCASCO = this.SocietatiRCA = (SocietateAsigurare[])sar.GetAll().Result; this.SocietatiAsigurare = (SocietateAsigurare[])sar.GetAll().Result; NomenclatoareRepository nr = new NomenclatoareRepository(_CURENT_USER_ID, conStr); this.TipuriCaz = (Nomenclator[])nr.GetAll("tip_caz").Result; this.TipuriDosar = (Nomenclator[])nr.GetAll("tip_dosare").Result; this.StatusDosare = SOCISA.CommonFunctions.STATUS_DOSARE; try { string token = HttpContext.Current.Session["TOKEN"].ToString(); int id_dosar = Convert.ToInt32(token.Substring(token.LastIndexOf('|') + 1)); Dosar d = new Dosar(_CURENT_USER_ID, conStr, id_dosar); DosareResult = new Dosar[] { d }; Dosar = d; this.dosarJson = new DosarJson(_CURENT_USER_ID, _ID_SOCIETATE, conStr); this.FilteredRowsCount = 1; } catch { DosareResult = null; Dosar = new Dosar(); Dosar.ID_SOCIETATE_CASCO = Convert.ToInt32(HttpContext.Current.Session["ID_SOCIETATE"]); dosarJson = new DosarJson(); FilteredRowsCount = 0; } } }
public void ExportDosareToExcel(string _sort, string _order, string _filter, string _limit) { try { JObject jObj = (JObject)JsonConvert.DeserializeObject(_filter); string filterName = jObj["filterName"].ToString(); string filterKey = jObj["filterKey"].ToString(); object[] args = JsonConvert.DeserializeObject <object[]>(jObj["args"].ToString()); _filter = PredefinedFilters.CreateFilter(filterName, filterKey, args); } catch { } string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString; int _CURENT_USER_ID = Convert.ToInt32(Session["CURENT_USER_ID"]); DosareRepository dr = new DosareRepository(_CURENT_USER_ID, conStr); //Dosar[] dosare = (Dosar[])dr.GetFiltered(null, null, String.Format(" DOSARE.DATA_SCA = '{0}' AND DOSARE.ID_SOCIETATE_CASCO = '{1}' AND DOSARE.ID_SOCIETATE_RCA = '{2}' ", CommonFunctions.ToMySqlFormatDate(d), Convert.ToInt32(Session["ID_SOCIETATE"]), Convert.ToInt32(id_soc_rca)), null).Result; Dosar[] dosare = (Dosar[])dr.GetFiltered(_sort, _order, _filter, _limit).Result; DataTable table = (DataTable)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(dosare, Formatting.None, new Newtonsoft.Json.Converters.IsoDateTimeConverter() { DateTimeFormat = SOCISA.CommonFunctions.DATE_FORMAT }), (typeof(DataTable))); List <string> columns_to_remove = new List <string>(); foreach (DataColumn dc in table.Columns) { if ( !dc.ColumnName.ToLower().Equals("id") && !dc.ColumnName.ToLower().Contains("nr_dosar_casco") && !dc.ColumnName.ToLower().Contains("nr_sca") && !dc.ColumnName.ToLower().Contains("data_sca") && !dc.ColumnName.ToLower().Contains("nr_polita_casco") && !dc.ColumnName.ToLower().Contains("nr_auto_casco") && !dc.ColumnName.ToLower().Contains("nr_polita_rca") && !dc.ColumnName.ToLower().Contains("nr_auto_rca") && !dc.ColumnName.ToLower().Contains("data_eveniment") && !dc.ColumnName.ToLower().Contains("valoare_regres") && !dc.ColumnName.ToLower().Contains("data_avizare") ) { columns_to_remove.Add(dc.ColumnName); } } foreach (string col_name in columns_to_remove) { table.Columns.Remove(col_name); } DataColumn newdc = new DataColumn("ASIGURAT_CASCO", Type.GetType("System.String")); table.Columns.Add(newdc); newdc = new DataColumn("ASIGURATOR_RCA", Type.GetType("System.String")); table.Columns.Add(newdc); table.AcceptChanges(); foreach (DataRow drow in table.Rows) { try { Dosar dosar = new Dosar(_CURENT_USER_ID, conStr, Convert.ToInt32(drow["ID"])); Asigurat aCasco = (Asigurat)dosar.GetAsiguratCasco().Result; drow["ASIGURAT_CASCO"] = aCasco.DENUMIRE; SocietateAsigurare sRca = (SocietateAsigurare)dosar.GetSocietateRca().Result; drow["ASIGURATOR_RCA"] = sRca.DENUMIRE; } catch (Exception exp) { LogWriter.Log(exp); } } table.AcceptChanges(); using (ExcelPackage pack = new ExcelPackage()) { ExcelWorksheet ws = pack.Workbook.Worksheets.Add("Dosare"); ws.Cells["A1"].LoadFromDataTable(table, true); var ms = new System.IO.MemoryStream(); pack.SaveAs(ms); Response.BinaryWrite(ms.GetBuffer()); } }