예제 #1
0
 public DosarExtended(Dosar d, bool _selected)
 {
     this.Dosar          = d;
     this.AsiguratCasco  = (Asigurat)d.GetAsiguratCasco().Result;
     this.AsiguratRca    = (Asigurat)d.GetAsiguratRca().Result;
     this.AutoCasco      = (Auto)d.GetAutoCasco().Result;
     this.AutoRca        = (Auto)d.GetAutoRca().Result;
     this.Intervenient   = (Intervenient)d.GetIntervenient().Result;
     this.SocietateCasco = (SocietateAsigurare)d.GetSocietateCasco().Result;
     this.SocietateRca   = (SocietateAsigurare)d.GetSocietateRca().Result;
     this.TipDosar       = (Nomenclator)d.GetTipDosar().Result;
     this.selected       = _selected;
 }
예제 #2
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("~"));
            }
        }
예제 #3
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("~"));
            }
        }
예제 #4
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());
            }
        }