public response SendToInvolvedParties() { try { response toReturn = new response(true, "", null, null, new List <Error>()); Dosar d = (Dosar)this.GetDosar().Result; Utilizator[] utilizatori = (Utilizator[])d.GetInvolvedParties().Result; foreach (Utilizator utilizator in utilizatori) { MesajUtilizator mesajUtilizator = new MesajUtilizator(authenticatedUserId, connectionString) { ID_UTILIZATOR = Convert.ToInt32(utilizator.ID), ID_MESAJ = Convert.ToInt32(this.ID) }; response r = mesajUtilizator.Insert(); if (!r.Status) { toReturn.AddResponse(r); } } return(toReturn); } catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>() { new Error(exp) })); } }
public JsonResult UpdateCheckDates(string _data) { EmailNotificationExtended[] EmailNotifications = JsonConvert.DeserializeObject <EmailNotificationExtended[]>(_data, CommonFunctions.JsonDeserializerSettings); DateTime _d = DateTime.Now; string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString; int uid = Convert.ToInt32(Session["CURENT_USER_ID"]); /* * EmailNotificationsRepository enr = new EmailNotificationsRepository(uid, conStr); * response r = enr.UpdateCheckedTimes(Convert.ToDateTime(_timestamp), _d); */ response r = new response(true, null, null, null, null); foreach (EmailNotificationExtended ene in EmailNotifications) { EmailNotification en = new EmailNotification(uid, conStr, Convert.ToInt32(ene.EmailNotification.ID)); if (en.TIME_CHECKED == null) { en.TIME_CHECKED = _d; response rtmp = en.Update(); if (!rtmp.Status) { r.AddResponse(rtmp); } } } return(Json(r, JsonRequestBehavior.AllowGet)); }
public JsonResult Edit(UtilizatorDosar[] UtilizatoriDosare) { response toReturn = new response(true, "", null, null, new List <Error>()); string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString; int curent_user_id = Convert.ToInt32(Session["CURENT_USER_ID"]); foreach (UtilizatorDosar udP in UtilizatoriDosare) { Dosar d = new Dosar(curent_user_id, conStr, udP.ID_DOSAR); UtilizatorDosar ud = new UtilizatorDosar(curent_user_id, conStr); ud.ID_UTILIZATOR = udP.ID_UTILIZATOR; ud.ID_DOSAR = udP.ID_DOSAR; response r = ud.Insert(); if (!r.Status) { toReturn.AddResponse(r); } else { Mesaj m = new Mesaj(curent_user_id, conStr, ud.ID_DOSAR, DateTime.Now, String.Format("DOSAR NOU ({0})", d.NR_DOSAR_CASCO), String.Format("DOSAR NOU ({0})", d.NR_DOSAR_CASCO), "DOSAR NOU", curent_user_id, (int)Importanta.Low); response rm = m.Insert(); if (rm.Status && rm.InsertedId != null) { m.ID = rm.InsertedId; MesajUtilizator mu = new MesajUtilizator(curent_user_id, conStr); mu.ID_MESAJ = Convert.ToInt32(m.ID); mu.ID_UTILIZATOR = ud.ID_UTILIZATOR; response rmu = mu.Insert(); if (!rmu.Status) { toReturn.AddResponse(rmu); } } else { toReturn.AddResponse(rm); } } } return(Json(toReturn, JsonRequestBehavior.AllowGet)); }
public response GenerateAndSendMessage(int?IdDosar, DateTime Data, string Subiect, string Body, string TipMesaj, int IdSender, int Importanta) { Mesaj mesaj = new Mesaj(authenticatedUserId, connectionString, IdDosar, Data, Subiect, Body, TipMesaj, IdSender, Importanta); response r = mesaj.Insert(); if (r.Status && r.InsertedId != null) { mesaj.ID = r.InsertedId; r.AddResponse(mesaj.SendToInvolvedParties()); } return(r); }
public static void CallService(bool WithoutEmails, bool WithoutMarkings, bool WithPdfs, string DenumireSocietate) { response r = new response(); try { int uid = 1; List <string> conStrs = new List <string>(); conStrs.Add(CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ToString(), CommonFunctions.StringCipher.RetrieveKey())); //conStrs.Add(StringCipher.Decrypt( ConfigurationManager.ConnectionStrings["MySqlConnectionString_test"].ToString(), RetrieveKey())); // -- daca vrem insert si in baza de test !!! dubleaza documentele in "scan" /* * BasicHttpBinding binding = new BasicHttpBinding(); * binding.MaxBufferPoolSize = binding.MaxBufferSize = Int32.MaxValue; * binding.MaxReceivedMessageSize = long.MaxValue; */ SubrogationServiceClient s = new SubrogationServiceClient(); /* * (s.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxBufferPoolSize = Int32.MaxValue; * (s.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = Int32.MaxValue; * (s.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = Int32.MaxValue; */ s.ClientCredentials.UserName.UserName = CommonFunctions.StringCipher.Decrypt(ConfigurationManager.AppSettings["AllianzWSUser"].ToString(), CommonFunctions.StringCipher.RetrieveKey()); s.ClientCredentials.UserName.Password = CommonFunctions.StringCipher.Decrypt(ConfigurationManager.AppSettings["AllianzWSPassword"].ToString(), CommonFunctions.StringCipher.RetrieveKey()); s.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0); SubrogationInfo[] sis = s.BrowseUnreadSubrogations(DateTime.MinValue, DateTime.MinValue); int counter = 0; foreach (SubrogationInfo si in sis) { //if (counter > 2) return; foreach (string conStr in conStrs) // salvam in ambele baze ! { try { response validationResponse = new response(); SOCISA.Models.Dosar d = new SOCISA.Models.Dosar(uid, conStr); try { SocietateAsigurare sCasco = new SocietateAsigurare(uid, conStr, DenumireSocietate, true); d.ID_SOCIETATE_CASCO = sCasco.ID; } catch (Exception exp) { LogWriter.Log(exp); } try { //SocietateAsigurare sRca = new SocietateAsigurare(uid, conStr, si.SubrogationInsurerName, false); SocietateAsigurare sRca = null; int?id_soc = GetSocietateMapping(SocietatiMappings, si.SubrogationInsurerId); if (id_soc != null && id_soc != 0) { sRca = new SocietateAsigurare(uid, conStr, Convert.ToInt32(id_soc)); } if (sRca == null || sRca.ID == null) { sRca = new SocietateAsigurare(uid, conStr); sRca.DENUMIRE = sRca.DENUMIRE_SCURTA = si.SubrogationInsurerName; sRca.ADRESA = si.SubrogationInsurerCountry; r = sRca.Insert(); /* * if(r.InsertedId != null && id_soc == null) * { * DataRow newRow = SocietatiMappings.NewRow(); * newRow["ID_SCA"] = r.InsertedId; * newRow["ID_SOCIETATE"] = id_soc; * SocietatiMappings.Rows.Add(newRow); * SocietatiMappings.AcceptChanges(); * SaveSocietatiMappings(DenumireSocietate); * } */ } d.ID_SOCIETATE_RCA = sRca.ID; } catch (Exception exp) { LogWriter.Log(exp); } try { if (!String.IsNullOrWhiteSpace(si.InsuredFullName)) { Asigurat aCasco = new Asigurat(uid, conStr, si.InsuredFullName); if (aCasco == null || aCasco.ID == null) { aCasco = new Asigurat(uid, conStr); aCasco.DENUMIRE = si.InsuredFullName; r = aCasco.Insert(); } d.ID_ASIGURAT_CASCO = aCasco.ID; } } catch (Exception exp) { LogWriter.Log(exp); } try { if (!String.IsNullOrWhiteSpace(si.SubrogationGuiltyPartner)) { Asigurat aRca = new Asigurat(uid, conStr, si.SubrogationGuiltyPartner); if (aRca == null || aRca.ID == null) { aRca = new Asigurat(uid, conStr); aRca.DENUMIRE = si.SubrogationGuiltyPartner; r = aRca.Insert(); } d.ID_ASIGURAT_RCA = aRca.ID; } } catch (Exception exp) { LogWriter.Log(exp); } try { if (!String.IsNullOrWhiteSpace(si.InsuredCarPlateNo)) { Auto autoCasco = new Auto(uid, conStr, si.InsuredCarPlateNo); if (autoCasco == null || autoCasco.ID == null) { autoCasco = new Auto(uid, conStr); autoCasco.NR_AUTO = si.InsuredCarPlateNo; autoCasco.MARCA = si.InsuredCarBrandName; autoCasco.MODEL = si.InsuredCarModelName; autoCasco.SERIE_SASIU = si.InsuredCarChassisNo; r = autoCasco.Insert(); } d.ID_AUTO_CASCO = autoCasco.ID; } } catch (Exception exp) { LogWriter.Log(exp); } try { if (!String.IsNullOrWhiteSpace(si.SubrogationCarPlateNo)) { Auto autoRca = new Auto(uid, conStr, si.SubrogationCarPlateNo); if (autoRca == null || autoRca.ID == null) { autoRca = new Auto(uid, conStr); autoRca.NR_AUTO = si.SubrogationCarPlateNo; //autoRca.MARCA = si.SubrogationCarBrandName; //autoRca.MODEL = si.SubrogationCarModelName; autoRca.SERIE_SASIU = si.SubrogationCarChassisNo; r = autoRca.Insert(); } d.ID_AUTO_RCA = autoRca.ID; } } catch (Exception exp) { LogWriter.Log(exp); } try { d.CAZ = si.AmiableAssessmentNo; } catch { } try { d.DATA_CREARE = d.DATA_ULTIMEI_MODIFICARI = DateTime.Now; } catch { } try { if (si.LossDate == DateTime.MinValue) { d.DATA_EVENIMENT = null; } else { d.DATA_EVENIMENT = si.LossDate; } } catch { } try { d.DATA_NOTIFICARE = si.AssessmentDate; } catch { } //?? - la ei este Data Constatarii, nu cred ca e tot una cu Data Notificarii de la noi try { d.NR_DOSAR_CASCO = si.ClaimFileNo; } catch { } try { d.NR_POLITA_CASCO = si.InsuredPolicyNo; } catch { } try { d.NR_POLITA_RCA = si.SubrogationRcoPolicyNo; } catch { } try { d.SUMA_IBNR = d.VALOARE_DAUNA = d.VALOARE_REGRES = d.VMD = d.REZERVA_DAUNA = Convert.ToDouble(si.ClaimReserveValueRon); } catch { } try { d.LOC_ACCIDENT = String.Format("{0}{1}{2}{3}{4}{5}", si.LossCountry, String.IsNullOrWhiteSpace(si.LossCity) ? "" : ", " + si.LossCity, String.IsNullOrWhiteSpace(si.LossDistrictNo.ToString()) ? "" : ", sector " + si.LossDistrictNo.ToString(), String.IsNullOrWhiteSpace(si.LossStreet) ? "" : ", str. " + si.LossStreet, String.IsNullOrWhiteSpace(si.LossStreetNo) ? "" : ", nr. " + si.LossStreetNo, String.IsNullOrWhiteSpace(si.LossIntersection) ? "" : ", intersectie cu str. " + si.LossIntersection); } catch { } validationResponse = d.Validare(); if (validationResponse.Status) { r = d.Insert(); validationResponse.InsertedId = r.InsertedId; validationResponse.Status = true; if (r.Status && r.InsertedId != null) { d.Log(validationResponse, 1); // 1 = automatic import ClaimDocumentSummary[] cdss = s.BrowseClaimDocuments(si.ClaimId, DateTime.MinValue); foreach (ClaimDocumentSummary cds in cdss) { try { //TipDocument td = new TipDocument(uid, conStr, cds.CategoryName); TipDocument td = null; int? id_tip_doc = GetTipDocumentMapping(TipuriDocumentMappings, cds.CategoryId); if (id_tip_doc != null && id_tip_doc != 0) { td = new TipDocument(uid, conStr, Convert.ToInt32(id_tip_doc)); } DocumentScanat ds = new DocumentScanat(uid, conStr); ds.DENUMIRE_FISIER = String.IsNullOrWhiteSpace(cds.Name) ? cds.FileName : cds.Name; ds.EXTENSIE_FISIER = !String.IsNullOrWhiteSpace(cds.Extension) ? cds.Extension : !String.IsNullOrWhiteSpace(cds.Name) ? cds.Name.Substring(cds.Name.LastIndexOf('.')) : cds.FileName.Substring(cds.FileName.LastIndexOf('.')); ds.ID_TIP_DOCUMENT = Convert.ToInt32(td.ID); ds.ID_DOSAR = Convert.ToInt32(d.ID); BinaryContent bc = s.GetClaimDocumentDetails(cds.Id); ds.FILE_CONTENT = bc.BinaryData; ds.CALE_FISIER = FileManager.SaveBinaryContentToFile(bc.BinaryData, ds.EXTENSIE_FISIER); response rd = ds.Validare(); if (rd.Status) { rd = ds.Insert(); ds.Log(rd, 1); // 1 = automatic import } if (!rd.Status) // marcam dosarul ca citit (preluat) de la Allianz doar daca s-a reusit preluarea tuturor documentelor asociate { r.AddResponse(rd); } } catch (Exception exp) { LogWriter.Log(exp); r.AddResponse(new response(false, exp.ToString(), null, null, new List <Error>() { new Error(exp) })); } } if (r.Status) { if (!WithoutMarkings) { s.MarkAsReadByClaimId(si.ClaimId); } if (WithoutEmails && WithPdfs) { d.GenerateNotificarePdf(); } if (!WithoutEmails) { d.SendNotificare(EmailProfiles.AwsNotificariSES); } } } } else { r = d.InsertWithErrors(); validationResponse.Status = false; validationResponse.InsertedId = r.InsertedId; if (r.Status && r.InsertedId != null) { d.Log(validationResponse, 1); // 1 = automatic import ClaimDocumentSummary[] cdss = s.BrowseClaimDocuments(si.ClaimId, DateTime.MinValue); foreach (ClaimDocumentSummary cds in cdss) { try { //TipDocument td = new TipDocument(uid, conStr, cds.CategoryName); TipDocument td = null; int? id_tip_doc = GetTipDocumentMapping(TipuriDocumentMappings, cds.CategoryId); if (id_tip_doc != null && id_tip_doc != 0) { td = new TipDocument(uid, conStr, Convert.ToInt32(id_tip_doc)); } DocumentScanat ds = new DocumentScanat(uid, conStr); ds.DENUMIRE_FISIER = String.IsNullOrWhiteSpace(cds.Name) ? cds.FileName : cds.Name; ds.EXTENSIE_FISIER = !String.IsNullOrWhiteSpace(cds.Extension) ? cds.Extension : !String.IsNullOrWhiteSpace(cds.Name) ? cds.Name.Substring(cds.Name.LastIndexOf('.')) : cds.FileName.Substring(cds.FileName.LastIndexOf('.')); ds.ID_TIP_DOCUMENT = Convert.ToInt32(td.ID); ds.ID_DOSAR = Convert.ToInt32(d.ID); BinaryContent bc = s.GetClaimDocumentDetails(cds.Id); ds.FILE_CONTENT = bc.BinaryData; ds.CALE_FISIER = FileManager.SaveBinaryContentToFile(bc.BinaryData, ds.EXTENSIE_FISIER); response rd = ds.Validare(); if (rd.Status) { rd = ds.InsertWithErrors(); ds.Log(rd, 1); // 1 = automatic import } if (!rd.Status) // marcam dosarul ca citit (preluat) de la Allianz doar daca s-a reusit preluarea tuturor documentelor asociate { r.AddResponse(rd); } } catch (Exception exp) { LogWriter.Log(exp); r.AddResponse(new response(false, exp.ToString(), null, null, new List <Error>() { new Error(exp) })); } } if (r.Status) { if (!WithoutMarkings) { s.MarkAsReadByClaimId(si.ClaimId); } } } } } catch (Exception exp) { LogWriter.Log(exp); } counter++; } } } catch (Exception exp) { LogWriter.Log(exp); } }
public response GetPlatiFromExcel(string sheet, string fileName) { try { FileInfo fi = new FileInfo(File.Exists(fileName) ? fileName : Path.Combine(CommonFunctions.GetImportsFolder(), fileName)); ExcelPackage ep = new ExcelPackage(fi); ExcelWorksheet ews = ep.Workbook.Worksheets[sheet]; Dictionary <string, int> columnNames = new Dictionary <string, int>(); int colIndex = 1; foreach (var firstRowCell in ews.Cells[1, 1, 1, ews.Dimension.End.Column]) { columnNames.Add(firstRowCell.Text, colIndex); colIndex++; } List <object[]> toReturnList = new List <object[]>(); //TO DO: trebuie stabilita maparea exacta cu coloanele din Excel !!! Nomenclator TipPlata = new Nomenclator(authenticatedUserId, connectionString, "tip_plata", "DIRECTA"); Dosar dosar = null; for (var rowNumber = 2; rowNumber <= ews.Dimension.End.Row; rowNumber++) { try { response toReturn = new response(true, "", null, null, new List <Error>());; response r = new response(); List <PlataExtended> plati = new List <PlataExtended>(); try { dosar = new Dosar(authenticatedUserId, connectionString, ews.Cells[rowNumber, columnNames["DOSAR"]].Text.Trim()); if (dosar == null || dosar.ID == null) { Error err = ErrorParser.ErrorMessage("dosarInexistent"); List <Error> errs = new List <Error>(); errs.Add(err); r = new response(false, err.ERROR_MESSAGE, null, null, errs); toReturn.AddResponse(r); } else { if (!dosar.IsAvizat()) { Error err = ErrorParser.ErrorMessage("dosarNeavizat"); List <Error> errs = new List <Error>(); errs.Add(err); r = new response(false, err.ERROR_MESSAGE, null, null, errs); toReturn.AddResponse(r); } } } catch (Exception exp) { LogWriter.Log(exp); } for (int i = 1; i < 6; i++) // platile in Excel sunt pe coloane si consideram maxim 5 plati { try { if (!String.IsNullOrWhiteSpace(ews.Cells[rowNumber, columnNames["DOCUMENT_PLATA" + i.ToString()]].Text.Trim()) && Double.TryParse(ews.Cells[rowNumber, columnNames["SUMA_RECUPERATA" + i.ToString()]].Text.Trim(), out double tmpSuma) && CommonFunctions.SwitchBackFormatedDate(ews.Cells[rowNumber, columnNames["DATA_PLATA" + i.ToString()]].Text.Trim()) != null) { Plata plata = new Plata(authenticatedUserId, connectionString); try { plata.NR_DOCUMENT = ews.Cells[rowNumber, columnNames["DOCUMENT_PLATA" + i.ToString()]].Text.Trim(); } catch { } try { plata.DATA_DOCUMENT = CommonFunctions.SwitchBackFormatedDate(ews.Cells[rowNumber, columnNames["DATA_PLATA" + i.ToString()]].Text.Trim()); } catch { } try { plata.SUMA = Convert.ToDouble(ews.Cells[rowNumber, columnNames["SUMA_RECUPERATA" + i.ToString()]].Text.Trim()); } catch { } try { plata.ID_DOSAR = dosar.ID; } catch { } try { plata.ID_TIP_PLATA = TipPlata.ID; } catch { } plati.Add(new PlataExtended(plata)); } } catch { } } foreach (PlataExtended plataExtended in plati) { Plata tmpPlata = new Plata(authenticatedUserId, connectionString, plataExtended.Plata); if (tmpPlata != null && tmpPlata.ID != null) { Error err = ErrorParser.ErrorMessage("plataExistenta"); List <Error> errs = new List <Error>(); errs.Add(err); r = new response(false, err.ERROR_MESSAGE, null, null, errs); toReturn.AddResponse(r); } r = plataExtended.Plata.Validare(); if (!r.Status) { toReturn.AddResponse(r); } //pt. cazul in care avem duplicate in excel si platile nu sunt inca in baza de date ! for (int i = 0; i < toReturnList.Count; i++) { tmpPlata = ((PlataExtended)toReturnList[i][1]).Plata; if (tmpPlata.NR_DOCUMENT == plataExtended.Plata.NR_DOCUMENT && tmpPlata.DATA_DOCUMENT == plataExtended.Plata.DATA_DOCUMENT && tmpPlata.SUMA == plataExtended.Plata.SUMA && tmpPlata.ID_DOSAR == plataExtended.Plata.ID_DOSAR) { Error err = new Error(); response nr = new response(false, null, null, null, new List <Error>()); nr.Status = false; err = ErrorParser.ErrorMessage("plataExistenta"); nr.Message = string.Format("{0}{1};", nr.Message ?? "", err.ERROR_MESSAGE); nr.InsertedId = null; nr.Error.Add(err); toReturn.AddResponse(nr); break; } } toReturnList.Add(new object[] { toReturn, plataExtended }); } } catch (Exception exp) { LogWriter.Log(exp); } } return(new response(true, JsonConvert.SerializeObject(toReturnList.ToArray(), CommonFunctions.JsonSerializerSettings), toReturnList.ToArray(), null, null)); } catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.Message, null, null, new List <Error>() { new Error(exp) })); } }