Exemplo n.º 1
0
        public ActionResult SelectSocietate(FormCollection model)
        {
            string     conStr = Session["conStr"].ToString(); // ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            Utilizator u      = (Utilizator)Session["CURENT_USER"];
            SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(Convert.ToInt32(u.ID), conStr);

            SocietateAsigurare[] sas = (SocietateAsigurare[])sar.GetAll().Result;
            if (!ModelState.IsValid)
            {
                return(View(sas));
            }

            /* -- modelul cu lista --
             * if(model["item.ID"] != null)
             * {
             *  Session["ID_SOCIETATE"] = model["item.ID"];
             *  SocietateAsigurare sa = (SocietateAsigurare)sar.Find(Convert.ToInt32(model["item.ID"])).Result;
             *  Session["SOCIETATE_ASIGURARE"] = sa;
             *  return RedirectToAction("Index", "Home");
             * }
             */
            if (model["Societate"] != null && model["Societate"] != "")
            {
                Session["ID_SOCIETATE"] = model["Societate"];
                SocietateAsigurare sa = (SocietateAsigurare)sar.Find(Convert.ToInt32(model["Societate"])).Result;
                Session["SOCIETATE_ASIGURARE"] = sa;
                //return RedirectToAction("Index", "Home");
                return(RedirectToAction("IndexMain", "Dashboard"));
            }
            else
            {
                ModelState.AddModelError("", "Selectati societatea!");
                return(View(sas));
            }
        }
Exemplo n.º 2
0
        private ActionResult InternalTokenLogin(string _token, string _url, Utilizator u)
        {
            string conStr = HttpContext.Server.MapPath("~").ToLower().IndexOf("test") > 0 ? CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySQLConnectionString_test"].ConnectionString, CommonFunctions.StringCipher.RetrieveKey()) : CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString, CommonFunctions.StringCipher.RetrieveKey()); // separam socisa de socisa_test

            HttpContext.Session["TOKEN"] = _token;
            TempData.Clear();

            string[] separator = { "|" };
            string[] token     = _token.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            int      id        = Convert.ToInt32(token[1]);
            Dosar    d         = new Dosar(Convert.ToInt32(u.ID), conStr, id);

            HttpContext.Session["conStr"]         = conStr;
            HttpContext.Session["CURENT_USER_ID"] = u.ID;
            HttpContext.Session["CURENT_USER"]    = u;
            FormsAuthentication.SetAuthCookie(u.USER_NAME, true);
            //System.Web.Security.FormsAuthentication.SetAuthCookie("", false);
            NomenclatoareRepository nr = new NomenclatoareRepository(Convert.ToInt32(u.ID), conStr);
            Nomenclator             n  = (Nomenclator)nr.Find("TIP_UTILIZATORI", Convert.ToInt32(u.ID_TIP_UTILIZATOR)).Result;

            HttpContext.Session["CURENT_USER_TYPE"]     = n;
            HttpContext.Session["CURENT_USER_RIGHTS"]   = (Drept[])u.GetDrepturi().Result;
            HttpContext.Session["CURENT_USER_ACTIONS"]  = (SOCISA.Models.Action[])u.GetActions().Result;
            HttpContext.Session["CURENT_USER_SETTINGS"] = (Setare[])u.GetSetari().Result;
            HttpContext.Session["CURENT_USER_SOCIETATI_ADMINISTRATE"] = (SocietateAsigurare[])u.GetSocietatiAdministrate().Result;

            HttpContext.Session["ID_SOCIETATE"] = d.ID_SOCIETATE_CASCO;
            SocietateAsigurare sa = new SocietateAsigurare(Convert.ToInt32(u.ID_SOCIETATE), conStr, Convert.ToInt32(d.ID_SOCIETATE_CASCO));

            HttpContext.Session["SOCIETATE_ASIGURARE"] = sa;
            //return Redirect(String.Format("/Dashboard/IndexMain/{0}", Token));
            return(Redirect(String.Format("{0}{1}", HttpUtility.UrlDecode(_url), _token)));
        }
        //[AuthorizeUser(ActionName = "Nomenclatoare", Recursive = false)]
        public ActionResult Details(string id)
        {
            string             conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int                uid    = Convert.ToInt32(Session["CURENT_USER_ID"]);
            SocietateAsigurare sa     = !String.IsNullOrWhiteSpace(id) ? new SocietateAsigurare(uid, conStr, Convert.ToInt32(id)) : new SocietateAsigurare();

            return(PartialView("_PartialSocietateAsigurare", sa));
        }
Exemplo n.º 4
0
 public SocietateAsigurareExtended(SocietateAsigurare baza)
 {
     PropertyInfo[] pis = baza.GetType().GetProperties();
     foreach (PropertyInfo pi in pis)
     {
         pi.SetValue(this, pi.GetValue(baza));
     }
 }
Exemplo n.º 5
0
        public ProcesView(int _CURENT_USER_ID, string conStr, string predefinedFilter)
        {
            NomenclatoareRepository tpr = new NomenclatoareRepository(_CURENT_USER_ID, conStr);

            this.TipuriProcese = (Nomenclator[])tpr.GetAll("tip_procese").Result;
            this.Instante      = (Nomenclator[])tpr.GetAll("instante").Result;
            this.Complete      = (Nomenclator[])tpr.GetAll("complete").Result;
            //ContracteRepository cr = new ContracteRepository(_CURENT_USER_ID, conStr);
            //this.Contracte = (Contract[])cr.GetAll().Result;
            ProceseRepository pr = new ProceseRepository(_CURENT_USER_ID, conStr);

            this.TipDocumenteScanateProcese = (string[])pr.GetTipDocumenteScanatePocese().Result;
            //PartiRepository par = new PartiRepository(_CURENT_USER_ID, conStr);
            //this.Parti = (Parte[])par.GetAll().Result;
            this.Calitati = (Nomenclator[])tpr.GetAll("calitati").Result;
            //Utilizator u = new Utilizator(_CURENT_USER_ID, conStr, _CURENT_USER_ID);
            //this.Societate = (SocietateAsigurare)u.GetSocietatiAsigurare().Result;
            this.Societate = new SocietateAsigurare(_CURENT_USER_ID, conStr, Convert.ToInt32(HttpContext.Current.Session["ID_SOCIETATE"]));
            //this.CurProces = new ProcesExtended(new Proces());
            //this.procesJson = new ProcesJson();
            StadiiRepository sr = new StadiiRepository(_CURENT_USER_ID, conStr);

            this.Stadii = (StadiuCombo[])sr.GetCombo().Result;

            this.Procese           = null;
            this.CurProces         = new ProcesExtended(new Proces());
            this.FilteredRowsCount = 0;
            this.procesJson        = new ProcesJson();

            if (predefinedFilter != "empty")
            {
                try
                {
                    //daca vrem sa aducem din start inregistrari !!!
                    string initFilter = String.Format(" ((PROCESE.ID_DOSAR IS NULL AND (PROCESE.ID_RECLAMANT={0} OR PROCESE.ID_PARAT={0} OR PROCESE.ID_TERT={0})) OR (PROCESE.ID_DOSAR IS NOT NULL AND (DOSARE.ID_SOCIETATE_CASCO={0} OR DOSARE.ID_SOCIETATE_RCA={0}))) ", Convert.ToInt32(HttpContext.Current.Session["ID_SOCIETATE"]));

                    ProceseRepository prep   = new ProceseRepository(_CURENT_USER_ID, conStr);
                    string            filter = String.IsNullOrWhiteSpace(predefinedFilter) ? initFilter : predefinedFilter;
                    string            limit  = String.Format(" LIMIT 0, {0} ", (CommonFunctions.ROWS_BLOCK_SIZE).ToString());

                    /*
                     * this.Procese = (ProcesExtended[])prep.GetFilteredExtended(null, null, filter, limit).Result;
                     * this.CurProces = this.Procese[0];
                     */
                    this.Procese           = (Proces[])prep.GetFiltered(null, null, filter, limit).Result;
                    this.CurProces         = new ProcesExtended(this.Procese[0]);
                    this.FilteredRowsCount = Convert.ToInt32(prep.CountFiltered(null, null, filter, null).Result);
                    this.procesJson        = new ProcesJson();
                }
                catch
                {
                    this.Procese           = null;
                    this.CurProces         = new ProcesExtended(new Proces());
                    this.FilteredRowsCount = 0;
                    this.procesJson        = new ProcesJson();
                }
            }
        }
Exemplo n.º 6
0
        public ProcesView(int _CURENT_USER_ID, string conStr, int?_ID_DOSAR, int?_ID_PROCES)
        {
            NomenclatoareRepository tpr = new NomenclatoareRepository(_CURENT_USER_ID, conStr);

            this.TipuriProcese = (Nomenclator[])tpr.GetAll("tip_procese").Result;
            this.Instante      = (Nomenclator[])tpr.GetAll("instante").Result;
            this.Complete      = (Nomenclator[])tpr.GetAll("complete").Result;
            //ContracteRepository cr = new ContracteRepository(_CURENT_USER_ID, conStr);
            //this.Contracte = (Contract[])cr.GetAll().Result;
            ProceseRepository pr = new ProceseRepository(_CURENT_USER_ID, conStr);

            this.TipDocumenteScanateProcese = (string[])pr.GetTipDocumenteScanatePocese().Result;
            //PartiRepository par = new PartiRepository(_CURENT_USER_ID, conStr);
            //this.Parti = (Parte[])par.GetAll().Result;
            this.Calitati = (Nomenclator[])tpr.GetAll("calitati").Result;
            ////Utilizator u = new Utilizator(_CURENT_USER_ID, conStr, _CURENT_USER_ID);
            ////this.Societate = (SocietateAsigurare)u.GetSocietatiAsigurare().Result;
            this.Societate = new SocietateAsigurare(_CURENT_USER_ID, conStr, Convert.ToInt32(HttpContext.Current.Session["ID_SOCIETATE"]));
            StadiiRepository sr = new StadiiRepository(_CURENT_USER_ID, conStr);

            this.Stadii = (StadiuCombo[])sr.GetCombo().Result;

            this.CurProces  = new ProcesExtended(new Proces());
            this.procesJson = new ProcesJson();
            if (_ID_DOSAR != null && _ID_PROCES == null)
            {
                this.ID_DOSAR  = Convert.ToInt32(_ID_DOSAR);
                this.ID_PROCES = null;
                Dosar d = new Dosar(_CURENT_USER_ID, conStr, Convert.ToInt32(_ID_DOSAR));
                //this.Dosar = d;
                this.Procese = (Proces[])d.GetProcese().Result;

                /*
                 * Proces[] ps = (Proces[])d.GetProcese().Result;
                 * this.Procese = new ProcesExtended[ps.Length];
                 * for (int i = 0; i < ps.Length; i++)
                 * {
                 *  this.Procese[i] = new ProcesExtended(ps[i]);
                 * }
                 */
                this.procesJson          = new ProcesJson();
                this.procesJson.Calitate = d.ID_SOCIETATE_CASCO == Societate.ID ? "RECLAMANT" : "PARAT";
                SocietateAsigurare cealaltaSocietate = new SocietateAsigurare(_CURENT_USER_ID, conStr, Convert.ToInt32(d.ID_SOCIETATE_CASCO == Societate.ID ? d.ID_SOCIETATE_RCA : d.ID_SOCIETATE_CASCO));
                this.procesJson.Reclamant = d.ID_SOCIETATE_CASCO == Societate.ID ? Societate.DENUMIRE : cealaltaSocietate.DENUMIRE;
                this.procesJson.Parat     = d.ID_SOCIETATE_CASCO == Societate.ID ? cealaltaSocietate.DENUMIRE : Societate.DENUMIRE;
                this.procesJson.Tert      = "";
            }
            if (_ID_DOSAR == null && _ID_PROCES != null)
            {
                this.ID_PROCES = Convert.ToInt32(_ID_PROCES);
                this.ID_DOSAR  = null;

                this.procesJson.Reclamant = "";
                this.procesJson.Parat     = "";
                this.procesJson.Tert      = "";
            }
        }
Exemplo n.º 7
0
 public ProcesView()
 {
     this.TipuriProcese = this.Instante = this.Complete = this.Calitati = (new List <Nomenclator>()).ToArray();
     this.Stadii        = (new List <StadiuCombo>()).ToArray();
     //this.Contracte = (new List<Contract>()).ToArray();
     this.TipDocumenteScanateProcese = (new List <string>()).ToArray();
     //this.Parti = (new List<Parte>()).ToArray();
     this.Societate         = new SocietateAsigurare();
     this.Procese           = null;
     this.CurProces         = new ProcesExtended(new Proces());
     this.FilteredRowsCount = 0;
     this.procesJson        = new ProcesJson();
 }
Exemplo n.º 8
0
        private ActionResult LoginInternal(string returnUrl)
        {
            Utilizator u = (Utilizator)TempData["tempLogin"];

            TempData.Clear();
            u.IS_ONLINE = true;
            //Session["LAST_LOGIN"] = DateTime.Now;
            Session["LAST_LOGIN"] = u.CURRENT_LOGIN = DateTime.Now;
            //string s = "{'IS_ONLINE':true}";
            u.Update();
            Session["CURENT_USER"]    = u;
            Session["CURENT_USER_ID"] = u.ID;
            FormsAuthentication.SetAuthCookie(u.USER_NAME, true);
            //NomenclatoareRepository nr = new NomenclatoareRepository(Convert.ToInt32(u.ID), conStr);
            NomenclatoareRepository nr = new NomenclatoareRepository(Convert.ToInt32(u.ID), Session["conStr"].ToString());
            Nomenclator             n  = (Nomenclator)nr.Find("TIP_UTILIZATORI", Convert.ToInt32(u.ID_TIP_UTILIZATOR)).Result;

            Session["CURENT_USER_TYPE"]     = n;
            Session["CURENT_USER_RIGHTS"]   = (Drept[])u.GetDrepturi().Result;
            Session["CURENT_USER_ACTIONS"]  = (SOCISA.Models.Action[])u.GetActions().Result;
            Session["CURENT_USER_SETTINGS"] = (Setare[])u.GetSetari().Result;
            Session["CURENT_USER_SOCIETATI_ADMINISTRATE"] = (SocietateAsigurare[])u.GetSocietatiAdministrate().Result;

            if (u.ID_SOCIETATE == null && (n != null && n.DENUMIRE.ToUpper() == "ADMINISTRATOR"))
            {
                //return Redirect(returnUrl ?? Url.Action("SelectSocietate", "UtilizatoriController"));
                return(RedirectToAction("SelectSocietate"));
            }
            else
            {
                Session["ID_SOCIETATE"] = u.ID_SOCIETATE;
                //SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(Convert.ToInt32(u.ID), conStr);
                SocietatiAsigurareRepository sar = new SocietatiAsigurareRepository(Convert.ToInt32(u.ID), Session["conStr"].ToString());
                SocietateAsigurare           sa  = (SocietateAsigurare)sar.Find(Convert.ToInt32(u.ID_SOCIETATE)).Result;
                Session["SOCIETATE_ASIGURARE"] = sa;

                //return RedirectToAction("Index", "Home");
                //return Redirect(returnUrl ?? Url.Action("Index", "Home"));
                //return Redirect(returnUrl ?? Url.Action("IndexMain", "Dashboard"));
                if (returnUrl != null && returnUrl != "/")
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("IndexMain", "Dashboard"));
                }
            }
        }
        public JsonResult ConfirmEmailAddress(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, Convert.ToInt32(societate.ID));

            if (s.EMAIL_CONFIRMAT != societate.EMAIL_CONFIRMAT)
            {
                r = ur.ConfirmEmailAddress(Convert.ToInt32(societate.ID), societate.EMAIL_CONFIRMAT, "EMAIL");
            }
            if (s.EMAIL_NOTIFICARI_CONFIRMAT != societate.EMAIL_NOTIFICARI_CONFIRMAT)
            {
                r = ur.ConfirmEmailAddress(Convert.ToInt32(societate.ID), societate.EMAIL_NOTIFICARI_CONFIRMAT, "EMAIL_NOTIFICARI");
            }
            return(Json(r, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        public ActionResult TokenLogin(string _url, string _token)
        {
            //string Token = HttpContext.Request.Params["URL"].ToString().Substring(HttpContext.Request.Params["URL"].ToString().LastIndexOf('/') + 1);

            if (!String.IsNullOrWhiteSpace(_token) && _token.IndexOf('|') > -1)
            {
                if (Session["CURENT_USER_ID"] != null && Session["ID_SOCIETATE"] != null) // s-a mai accesat odata linkul (de exemplu pt. email si pt. printare documente
                {
                    HttpContext.Session["TOKEN"] = _token;
                    return(Redirect(String.Format("{0}{1}", HttpUtility.UrlDecode(_url), _token)));
                }
                else // aici trebuie sa trimitem cod pe email
                {
                    if (TempData["TOKEN"] == null || String.IsNullOrWhiteSpace(TempData["TOKEN"].ToString()))
                    {
                        string     conStr = HttpContext.Server.MapPath("~").ToLower().IndexOf("test") > 0 ? CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySQLConnectionString_test"].ConnectionString, CommonFunctions.StringCipher.RetrieveKey()) : CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString, CommonFunctions.StringCipher.RetrieveKey()); // separam socisa de socisa_test
                        Utilizator u      = null;
                        MySql.Data.MySqlClient.MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection(conStr);
                        MySql.Data.MySqlClient.MySqlCommand    cmd = new MySql.Data.MySqlClient.MySqlCommand();
                        cmd.Connection  = con;
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        cmd.CommandText = "UTILIZATORIsp_GetByUserName";
                        cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("_USER_NAME", "email"));
                        con.Open();
                        MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                        while (r.Read())
                        {
                            int authenticatedUserId = Convert.ToInt32(r["ID"]);
                            u = new Utilizator(Convert.ToInt32(authenticatedUserId), conStr, r);
                            break;
                        }
                        r.Close(); r.Dispose();
                        if (con != null && con.State == System.Data.ConnectionState.Open)
                        {
                            con.Close();
                            con.Dispose();
                        }

                        if (u == null)
                        {
                            TempData.Clear();
                            return(Redirect("~"));
                        }
                        else
                        {
                            TempData["TOKEN"] = _token;
                            TempData["URL"]   = _url;
                            string[] separator = { "|" };
                            string[] token     = _token.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                            string   md5p      = token[0];
                            int      id        = Convert.ToInt32(token[1]);
                            Dosar    d         = new Dosar(Convert.ToInt32(u.ID), conStr, id);
                            MD5      md5h      = MD5.Create();
                            if (!CommonFunctions.VerifyMd5Hash(md5h, d.NR_DOSAR_CASCO, md5p))
                            {
                                TempData.Clear();
                                return(Redirect("~"));
                            }
                            else
                            {
                                if (Convert.ToBoolean(ConfigurationManager.AppSettings["UseDoubleAutentificationForEmail"]))
                                {
                                    SocietateAsigurare sa = (SocietateAsigurare)d.GetSocietateRca().Result;
                                    TempData["tempLogin"] = u;

                                    //string rnd = "1234"; // pt. test

                                    Random generator = new Random();
                                    string rnd       = generator.Next(0, 1000000).ToString("D6");
                                    SendVerificationCode(EmailProfiles.AwsCereriSES, sa.EMAIL_NOTIFICARI, rnd);

                                    TempData["verificationCode"]          = rnd;
                                    TempData["verificationCodeIssueTime"] = DateTime.Now;
                                    return(View("TokenLogin", new LoginJson()));
                                    //return RedirectToAction("TokenLogin", "Utilizatori");
                                }
                                else
                                {
                                    return(InternalTokenLogin(_token, _url, u));
                                }
                            }
                        }
                    }
                    else
                    {
                        TempData.Clear();
                        return(Redirect("~"));
                    }
                }
            }
            else
            {
                return(Redirect("~"));
            }
        }
Exemplo n.º 13
0
        public ActionResult TokenLogin(LoginJson model, string submitCode)
        {
            if (submitCode == "Retrimite codul")
            {
                model.Code = null;
                //string rnd = "1234"; // pt. test

                Utilizator         u         = (Utilizator)TempData["tempLogin"];
                string             _token    = TempData["TOKEN"].ToString();
                string             _url      = TempData["URL"].ToString();
                string[]           separator = { "|" };
                string[]           token     = _token.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                int                id        = Convert.ToInt32(token[1]);
                string             conStr    = HttpContext.Server.MapPath("~").ToLower().IndexOf("test") > 0 ? CommonFunctions.StringCipher.Decrypt(System.Configuration.ConfigurationManager.ConnectionStrings["MySQLConnectionString_test"].ConnectionString, CommonFunctions.StringCipher.RetrieveKey()) : CommonFunctions.StringCipher.Decrypt(System.Configuration.ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString, CommonFunctions.StringCipher.RetrieveKey()); // separam socisa de socisa_test
                Dosar              d         = new Dosar(Convert.ToInt32(u.ID), conStr, id);
                SocietateAsigurare sa        = (SocietateAsigurare)d.GetSocietateRca().Result;

                Random generator = new Random();
                string rnd       = generator.Next(0, 1000000).ToString("D6");
                SendVerificationCode(EmailProfiles.AwsCereriSES, sa.EMAIL_NOTIFICARI, rnd);
                TempData.Clear();
                TempData["TOKEN"]                     = _token;
                TempData["URL"]                       = _url;
                TempData["tempLogin"]                 = u;
                TempData["verificationCode"]          = rnd;
                TempData["verificationCodeIssueTime"] = DateTime.Now;
                return(View("TokenLogin", new LoginJson()));
            }

            if (TempData["TOKEN"] != null && TempData["URL"] != null && TempData["tempLogin"] != null)
            {
                if (TempData["verificationCode"] == null || String.IsNullOrWhiteSpace(TempData["verificationCode"].ToString()))
                {
                    ModelState.AddModelError("", socisaV2.Resources.ErrorMessagesResx.VERIFICATION_CODE_EXPIRED);
                    //TempData.Clear();
                    TempData.Keep();
                    return(View("TokenLogin", model));
                }
                else
                {
                    //model.Code = TempData["verificationCode"].ToString();
                    var passedSeconds = (DateTime.Now - (DateTime)TempData["verificationCodeIssueTime"]).TotalSeconds;
                    if (Math.Abs((int)passedSeconds) > Convert.ToInt32(ConfigurationManager.AppSettings["VerificationCodeExpiration"]))
                    {
                        ModelState.AddModelError("", socisaV2.Resources.ErrorMessagesResx.VERIFICATION_CODE_EXPIRED);
                        //TempData.Clear();
                        TempData.Keep();
                        return(View("TokenLogin", model));
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(model.Code))
                        {
                            ModelState.AddModelError("", socisaV2.Resources.ErrorMessagesResx.EMPTY_CODE);
                            return(View("TokenLogin", model));
                        }
                        else
                        {
                            if (model.Code != TempData["verificationCode"].ToString())
                            {
                                ModelState.AddModelError("", socisaV2.Resources.ErrorMessagesResx.VERIFICATION_CODE_DONT_MATCH);
                                return(View("TokenLogin", model));
                            }
                            else
                            {
                                return(InternalTokenLogin(TempData["TOKEN"].ToString(), TempData["URL"].ToString(), (Utilizator)TempData["tempLogin"]));
                            }
                        }
                    }
                }
            }
            else
            {
                TempData.Clear();
                return(Redirect("~"));
            }
        }
Exemplo n.º 14
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());
            }
        }