Beispiel #1
0
        public ActionResult Login(LoginModel model)
        {
            if (!ModelState.IsValid || model.userName != "admin")
            {
                return(View());
            }
            using (LoginLogic login = new LoginLogic())
            {
                if (login.IsExist(model.userName, FormsAuthentication.HashPasswordForStoringInConfigFile(model.password, "sha1")))
                {
                    //if mailconfirm ok

                    FormsAuthentication.RedirectFromLoginPage(model.userName, model.RememberMe);
                    Session["mailRegistration"] = model.userName;
                    // Login c =login.getLogin(model.userName, FormsAuthentication.HashPasswordForStoringInConfigFile(model.password, "sha1"));

                    //   int? familyId = LoginLogic.getFamilyId(model.userName, FormsAuthentication.HashPasswordForStoringInConfigFile(model.password, "sha1")).familyId;
                    //if (familyId.HasValue)
                    // { //redirect to action family}
                    //     Session["familyId"] = familyId;
                    //     return RedirectToAction("index", "Family");
                    // }
                    // else
                    //     return RedirectToAction("create", "Family");
                }
                else
                {
                    ViewBag.message = DictExpressionBuilderSystem.Translate("message.IncorectuserNameorPassword");
                }
                //ViewBag.message = "Incorect userName or Password";
            }
            return(View());
        }
        public async Task <string> sendConfirmationEmail(string email, string emailHolder, string familyId)
        {
            FormsAuthenticationTicket formsTicket = new FormsAuthenticationTicket(
                1,
                familyId,
                DateTime.Now,
                DateTime.Now.AddMinutes(60 * 5),
                true,
                emailHolder
                );
            string encryptedTicket = FormsAuthentication.Encrypt(formsTicket);

            MailMessage m = new MailMessage(
                new MailAddress("*****@*****.**", "Web Registration"),
                new MailAddress(email));

            m.Subject    = "Email confirmation";
            m.Body       = string.Format("Dear {0}<BR/>" + DictExpressionBuilderSystem.Translate("message.pleaseclickontheLinkbelow") + ": <a href=\"{1}\" title=\"" + DictExpressionBuilderSystem.Translate("message.UserEmailConfirm") + "\">Click here</a>", email, Url.Action("ConfirmEmail", "System", new { Token = encryptedTicket, Email = email }, Request.Url.Scheme));
            m.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient("smtp.gmail.com");

            smtp.Credentials = new NetworkCredential("*****@*****.**", "zaqzaq8*");
            smtp.EnableSsl   = true;
            //  await smtp.SendMailAsync(m);
            Task <string> t = new Task <string>(() =>
            {
                smtp.SendMailAsync(m);
                return("ok");
            });

            t.Start();
            string result = await t;

            return("ok");
        }
Beispiel #3
0
 public ActionResult Confirm(string Email)
 {
     System.Threading.Thread.Sleep(3000);
     ViewBag.Title   = DictExpressionBuilderSystem.Translate("message.ConfirmEmailAddressSent");
     ViewBag.message = DictExpressionBuilderSystem.Translate("message.PleasecheckyourEmailInbox");
     ViewBag.Email   = Email;
     return(View());
 }
Beispiel #4
0
        public HttpResponseMessage GetExcel(bool _search, string nd, int rows, int page, string sidx, string sord, string filters = "")
        {
            var events       = new EventModel[] {};
            var totalRecords = 0;

            using (var logic = new tblCalendarLogic())
            {
                totalRecords = logic.Events.Count();
                events       = logic.GetPaged(_search, totalRecords, 1, sidx, sord, filters)
                               .Select(z => new EventModel(z)).ToArray();
            }

            string Name      = "Calendar";
            var    workbook  = new XLWorkbook();
            var    worksheet = workbook.Worksheets.Add(Name + " Sheet");

            worksheet.Outline.SummaryVLocation = XLOutlineSummaryVLocation.Top;

            worksheet.Cell(1, 1).Value = DictExpressionBuilderSystem.Translate("Event.date");
            worksheet.Cell(1, 2).Value = DictExpressionBuilderSystem.Translate("Event.month");
            worksheet.Cell(1, 3).Value = DictExpressionBuilderSystem.Translate("Event.HebMonth");
            worksheet.Cell(1, 4).Value = DictExpressionBuilderSystem.Translate("Event.day");
            worksheet.Cell(1, 5).Value = DictExpressionBuilderSystem.Translate("Event.active");
            worksheet.Cell(1, 6).Value = DictExpressionBuilderSystem.Translate("Event.event");

            for (int i = 0; i < events.Length; i++)
            {
                var row = 2 + i;
                worksheet.Cell(row, 1).SetValue <string>(events[i].date);
                worksheet.Cell(row, 2).SetValue <string>(events[i].month);
                worksheet.Cell(row, 3).SetValue <string>(events[i].HebMonth);
                worksheet.Cell(row, 4).SetValue <string>(events[i].day);
                worksheet.Cell(row, 5).SetValue <bool?>(events[i].active);
                worksheet.Cell(row, 6).SetValue <string>(events[i].calendarEvent);
            }

            worksheet.RangeUsed().Style.Border.InsideBorder = XLBorderStyleValues.Thin;
            worksheet.RangeUsed().Style.Border.OutsideBorder = XLBorderStyleValues.None;
            worksheet.Columns().AdjustToContents();

            var result = new HttpResponseMessage(HttpStatusCode.OK);

            using (var memoryStream = new MemoryStream())
            {
                workbook.SaveAs(memoryStream);
                memoryStream.Position = 0;
                result.Content        = new ByteArrayContent(memoryStream.ToArray());
                result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
                {
                    FileName = Name + ".xlsx"
                };
                result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            }
            return(result);
        }
Beispiel #5
0
        public ActionResult create(studentViewModel c)
        {
            if (HttpRuntime.Cache["currentYear"] == null)
            {
                using (tblSystemLogic system = new tblSystemLogic())
                {
                    string x = tblSystemLogic.getSystemValueByKey("currentRegistrationYear").ToString();
                    HttpRuntime.Cache.Insert("currentYear", x, null, Cache.NoAbsoluteExpiration, TimeSpan.FromHours(50), CacheItemPriority.High, null);
                }
            }
            int yearRegistration = int.Parse(HttpRuntime.Cache["currentYear"].ToString());

            if (tblStudentLogic.checkIfIdExist(c.EditableTblStudents.studentId, yearRegistration))
            {
                ;
                ViewBag.message = DictExpressionBuilderSystem.Translate("message.studentIsAllredyRegister");
                //ViewBag.message = "התלמיד כבר רשום במערכת לשנה זו - לא ניתן לבצע רישום ";
                return(View(c));
            }

            if (c != null)
            {
                if (!checkstreet(c.EditableTblStudents.street))
                {
                    //ViewBag.message = "יש לבחור שם רחוב מהרשימה";
                    ViewBag.message = DictExpressionBuilderSystem.Translate("message.selectStreetFromList");
                    return(View(c));
                }

                tblStudent v = new tblStudent();
                v = c.EditableTblStudents;
                Task <tblStudent> x = geoCoding(v);
                //v.Lng = x.Result.Lng;//do not nedded since lng lat will get at the admin atachment to station
                //v.Lat = x.Result.Lat;
                int familyId = (int)Session["familyId"];


                v.familyId           = familyId;
                v.yearRegistration   = yearRegistration;
                v.registrationStatus = false;
                v.Active             = true;
                v.Color = "";
                tblStudentLogic.create(v);

                return(RedirectToAction("index", "Family"));
            }
            else
            {
                return(Redirect("~/account/unAutorise"));//real check is by Js in client side- if we here there is asecurity problem!
            }
        }
Beispiel #6
0
 public ActionResult update(studentViewModel c)
 {
     if (c != null)
     {
         using (tblStudentLogic student = new tblStudentLogic())
         {
             int        familyId = (int)Session["familyId"];
             tblStudent v        = student.getStudentByPk(c.EditableTblStudents.pk);
             if (v.familyId == familyId && v.pk == c.EditableTblStudents.pk)//familiy from session + check if its the same student
             {
                 if (v.street != c.EditableTblStudents.street || v.houseNumber != c.EditableTblStudents.houseNumber)
                 {
                     v.registrationStatus = false;//Must Have administration confirm for changing the buss station for student
                 }
                 v.street = c.EditableTblStudents.street;
                 if (!checkstreet(c.EditableTblStudents.street))
                 {
                     ViewBag.message = DictExpressionBuilderSystem.Translate("message.selectStreetFromList");
                     return(View(c));
                 }
                 v.houseNumber = c.EditableTblStudents.houseNumber;
                 v.Shicva      = c.EditableTblStudents.Shicva;
                 v.@class      = c.EditableTblStudents.@class;
                 v.subsidy     = c.EditableTblStudents.subsidy;
                 if (v.Email != c.EditableTblStudents.Email)
                 {
                     v.Email           = c.EditableTblStudents.Email;
                     v.GetAlertByEmail = c.EditableTblStudents.GetAlertByEmail;
                     v.EmailConfirm    = false;
                 }
                 if (v.CellPhone != c.EditableTblStudents.CellPhone)
                 {
                     v.CellPhone      = c.EditableTblStudents.CellPhone;
                     v.GetAlertByCell = c.EditableTblStudents.GetAlertByCell;
                     v.CellConfirm    = false;
                 }
                 //Task<tblStudent> x = geoCoding(v);
                 //v.Lng = x.Result.Lng;
                 //v.Lat = x.Result.Lat;
                 v.lastUpdate = DateTime.Today;
                 tblStudentLogic.update(v);
             }
         }
         return(RedirectToAction("index", "Family"));
     }
     else
     {
         return(Redirect("~/account/unAutorise"));//real check is by Js in client side- if we here there is asecurity problem!
     }
 }
Beispiel #7
0
        public ActionResult create()
        {
            int       familyId = (int)Session["familyId"];//todo  take from session
            tblSystem v;

            if (HttpRuntime.Cache["currentYear"] == null)
            {
                v = tblSystemLogic.getSystemValueByKey("currentRegistrationYear");
                HttpRuntime.Cache["currentYear"] = v.strValue;
            }
            int yearRegistration = int.Parse(HttpRuntime.Cache["currentYear"].ToString());

            using (tblStudentLogic student = new tblStudentLogic())
            {
                tblStudent c = new tblStudent();
                c.CellConfirm      = false;
                c.EmailConfirm     = false;
                c.familyId         = familyId;
                c.yearRegistration = yearRegistration;
                c.GetAlertByCell   = false;
                c.GetAlertByEmail  = false;
                c.siblingAtSchool  = false;
                c.specialRequest   = false;
                c.city             = DictExpressionBuilderSystem.Translate("city.TelAviv");



                tblStudent n = student.getStudentByFamilyId(familyId);
                if (n != null)
                {
                    //c.cityCode = n.cityCode;
                    c.street      = n.street;
                    c.lastName    = n.lastName;
                    c.houseNumber = n.houseNumber;
                }


                tblStreet r = new Business_Logic.tblStreet();

                List <tblStreet> s = new List <tblStreet>();//TODO get tblStreet from cache

                studentViewModel vm = new studentViewModel()
                {
                    EditableTblStudents = c,
                    clas = student.clas()
                };
                return(View(vm));
            }
        }
        public JsonResult GetCompaniesFilter()
        {
            var companies = new List <SelectItemModel>();

            companies.Add(new SelectItemModel {
                Value = "", Text = DictExpressionBuilderSystem.Translate("Search.All")
            });
            using (var logic = new LineLogic()) {
                var getCompanies = logic.GetCompaniesFilter();
                companies.AddRange(getCompanies
                                   .Where(w => w != null)
                                   .Select(z => new SelectItemModel {
                    Value = z.pk.ToString(),
                    Text  = z.companyName
                }).ToList());
            }

            return(new JsonResult {
                Data = companies
            });
        }
        public JsonResult GetScheduleLines()
        {
            var lines = new List <SelectItemModel>();

            lines.Add(new SelectItemModel {
                Value = "0", Text = string.Empty, Title = string.Empty
            });
            using (var logic = new LineLogic())
            {
                lines.AddRange(logic.GetList()
                               .Select(z => new SelectItemModel
                {
                    Value = z.Id.ToString(),
                    Text  = string.Format("{0} - {1}", z.LineName, z.LineNumber),
                    Title = string.Format("{0} ({1} - {2})", z.LineName, z.LineNumber, DictExpressionBuilderSystem.Translate("General." + (LineDirection)z.Direction))
                }).ToList());
            }

            return(new JsonResult {
                Data = lines
            });
        }
Beispiel #10
0
        public HttpResponseMessage GetExcel(bool _search, string nd, int rows, int page, string sidx, string sord, string filters = "")
        {
            var lines        = new GridLineBusModel[] {};
            var totalRecords = 0;

            using (var logic = new LineLogic())
            {
                totalRecords = logic.Lines.Count();
                lines        = logic.GetPaged(_search, totalRecords, 1, sidx, sord, filters)
                               .Select(z => new GridLineBusModel(z)).ToArray();
            }

            string Name      = "BusesToLines";
            var    workbook  = new XLWorkbook();
            var    worksheet = workbook.Worksheets.Add(Name + " Sheet");

            worksheet.Outline.SummaryVLocation = XLOutlineSummaryVLocation.Top;

            worksheet.Cell(1, 1).Value  = DictExpressionBuilderSystem.Translate("Line.LineName");
            worksheet.Cell(1, 2).Value  = DictExpressionBuilderSystem.Translate("Line.LineNumber");
            worksheet.Cell(1, 3).Value  = DictExpressionBuilderSystem.Translate("Line.Direction");
            worksheet.Cell(1, 4).Value  = DictExpressionBuilderSystem.Translate("Line.IsActive");
            worksheet.Cell(1, 5).Value  = DictExpressionBuilderSystem.Translate("Line.totalStudents");
            worksheet.Cell(1, 6).Value  = DictExpressionBuilderSystem.Translate("Line.Duration");
            worksheet.Cell(1, 7).Value  = DictExpressionBuilderSystem.Translate("Bus.Id");
            worksheet.Cell(1, 7).Value  = DictExpressionBuilderSystem.Translate("Bus.BusId");
            worksheet.Cell(1, 8).Value  = DictExpressionBuilderSystem.Translate("Bus.PlateNumber");
            worksheet.Cell(1, 9).Value  = DictExpressionBuilderSystem.Translate("BusCompany.Name");
            worksheet.Cell(1, 10).Value = DictExpressionBuilderSystem.Translate("Bus.seats");
            worksheet.Cell(1, 11).Value = DictExpressionBuilderSystem.Translate("Bus.price");

            for (int i = 0; i < lines.Length; i++)
            {
                var row = 2 + i;
                worksheet.Cell(row, 1).SetValue <string>(lines[i].LineName);
                worksheet.Cell(row, 2).SetValue <string>(lines[i].LineNumber);
                worksheet.Cell(row, 3).SetValue <string>(DictExpressionBuilderSystem.Translate("General." + lines[i].Direction));
                worksheet.Cell(row, 4).SetValue <bool>(lines[i].IsActive);
                worksheet.Cell(row, 5).SetValue <int>(lines[i].totalStudents);
                worksheet.Cell(row, 6).SetValue <string>(Convert.ToString(lines[i].Duration));
                worksheet.Cell(row, 7).SetValue <int>(lines[i].Bus);
                worksheet.Cell(row, 7).SetValue <string>(lines[i].BusId);
                worksheet.Cell(row, 8).SetValue <string>(lines[i].PlateNumber);
                worksheet.Cell(row, 9).SetValue <string>(lines[i].BusCompanyName);
                worksheet.Cell(row, 10).SetValue <int?>(lines[i].seats);
                worksheet.Cell(row, 11).SetValue <double?>(lines[i].price);
            }

            var totalRowIndex = lines.Length + 2;

            worksheet.Cell(totalRowIndex, 1).Value = DictExpressionBuilderSystem.Translate("grid.Total");
            worksheet.Cell(totalRowIndex, 5).SetFormulaA1(string.Format("=SUM(E2:E{0})", totalRowIndex - 1));
            worksheet.Cell(totalRowIndex, 10).SetFormulaA1(string.Format("=SUM(J2:J{0})", totalRowIndex - 1));
            worksheet.Cell(totalRowIndex, 11).SetFormulaA1(string.Format("=SUM(K2:K{0})", totalRowIndex - 1));

            worksheet.RangeUsed().Style.Border.InsideBorder = XLBorderStyleValues.Thin;
            worksheet.RangeUsed().Style.Border.OutsideBorder = XLBorderStyleValues.None;
            worksheet.Columns().AdjustToContents();

            var result = new HttpResponseMessage(HttpStatusCode.OK);

            using (var memoryStream = new MemoryStream())
            {
                workbook.SaveAs(memoryStream);
                memoryStream.Position = 0;
                result.Content        = new ByteArrayContent(memoryStream.ToArray());
                result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
                {
                    FileName = Name + ".xlsx"
                };
                result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            }
            return(result);
        }
        public HttpResponseMessage GetExcel(bool _search, string nd, int rows, int page, string sidx, string sord, string filters = "")
        {
            var buses        = new BusModel[] {};
            var totalRecords = 0;

            using (var logic = new tblBusLogic())
            {
                totalRecords = logic.Buses.Count();
                buses        = logic.GetPaged(_search, totalRecords, 1, sidx, sord, filters)
                               .Select(z => new BusModel(z)).ToArray();
            }

            string Name      = "Buses";
            var    workbook  = new XLWorkbook();
            var    worksheet = workbook.Worksheets.Add(Name + " Sheet");

            worksheet.Outline.SummaryVLocation = XLOutlineSummaryVLocation.Top;

            worksheet.Cell(1, 1).Value  = DictExpressionBuilderSystem.Translate("Bus.BusId");
            worksheet.Cell(1, 2).Value  = DictExpressionBuilderSystem.Translate("Bus.PlateNumber");
            worksheet.Cell(1, 3).Value  = DictExpressionBuilderSystem.Translate("BusCompany.Name");
            worksheet.Cell(1, 4).Value  = DictExpressionBuilderSystem.Translate("Bus.seats");
            worksheet.Cell(1, 5).Value  = DictExpressionBuilderSystem.Translate("Bus.price");
            worksheet.Cell(1, 6).Value  = DictExpressionBuilderSystem.Translate("Bus.munifacturedate");
            worksheet.Cell(1, 7).Value  = DictExpressionBuilderSystem.Translate("Bus.LicensingDueDate");
            worksheet.Cell(1, 8).Value  = DictExpressionBuilderSystem.Translate("Bus.insuranceDueDate");
            worksheet.Cell(1, 9).Value  = DictExpressionBuilderSystem.Translate("Bus.winterLicenseDueDate");
            worksheet.Cell(1, 10).Value = DictExpressionBuilderSystem.Translate("Bus.brakeTesDueDate");

            for (int i = 0; i < buses.Length; i++)
            {
                var row = 2 + i;
                worksheet.Cell(row, 1).SetValue <string>(buses[i].BusId);
                worksheet.Cell(row, 2).SetValue <string>(buses[i].PlateNumber);
                worksheet.Cell(row, 3).SetValue <string>(buses[i].OwnerDescription);
                worksheet.Cell(row, 4).SetValue <int?>(buses[i].seats);
                worksheet.Cell(row, 5).SetValue <double?>(buses[i].price);
                worksheet.Cell(row, 6).SetValue <string>(buses[i].munifacturedate);
                worksheet.Cell(row, 7).SetValue <string>(buses[i].LicensingDueDate);
                worksheet.Cell(row, 8).SetValue <string>(buses[i].insuranceDueDate);
                worksheet.Cell(row, 9).SetValue <string>(buses[i].winterLicenseDueDate);
                worksheet.Cell(row, 10).SetValue <string>(buses[i].brakeTesDueDate);
            }

            worksheet.RangeUsed().Style.Border.InsideBorder = XLBorderStyleValues.Thin;
            worksheet.RangeUsed().Style.Border.OutsideBorder = XLBorderStyleValues.None;
            worksheet.Columns().AdjustToContents();

            var result = new HttpResponseMessage(HttpStatusCode.OK);

            using (var memoryStream = new MemoryStream())
            {
                workbook.SaveAs(memoryStream);
                memoryStream.Position = 0;
                result.Content        = new ByteArrayContent(memoryStream.ToArray());
                result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = Name + ".xlsx"
                };
                result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            }
            return(result);
        }