public JsonResult Edit(SocietateAsigurare societate) { response r = new response(); string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString; int _CURENT_USER_ID = Convert.ToInt32(Session["CURENT_USER_ID"]); SocietatiAsigurareRepository ur = new SocietatiAsigurareRepository(_CURENT_USER_ID, conStr); SocietateAsigurare s = new SocietateAsigurare(_CURENT_USER_ID, conStr); PropertyInfo[] pis = societate.GetType().GetProperties(); foreach (PropertyInfo pi in pis) { pi.SetValue(s, pi.GetValue(societate)); } if (societate.ID == null) // insert { r = s.Insert(); } else // update { r = s.Update(); } return(Json(r, JsonRequestBehavior.AllowGet)); }
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); } }