public ActionResult AddMenu()
 {
     if (User.Identity.IsAuthenticated)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         ViewData["ContentPages"] = (from c in scope.GetOqlQuery <ContentPage>().ExecuteEnumerable()
                                     select c).ToList();
         ViewData["menus"] = (from c in scope.GetOqlQuery <Menu>().ExecuteEnumerable()
                              where c.ParentId.Equals(string.Empty)
                              select c).ToList();        //
         return(View(new MenuModel()));
     }
     return(RedirectToAction("LogOn", "Account"));
 }
Пример #2
0
        public ActionResult DeleteImage(string id)
        {
            var scope  = ObjectScopeProvider1.GetNewObjectScope();
            var images = (from c in scope.GetOqlQuery <File>().ExecuteEnumerable()
                          where c.ID.Equals(id)
                          select c).ToList();

            foreach (var image in images)
            {
                scope.Transaction.Begin();
                scope.Remove(image);
                scope.Transaction.Commit();
            }
            return(RedirectToAction("Images"));
        }
Пример #3
0
        public ActionResult DeletePage(string pid)
        {
            var scope = ObjectScopeProvider1.GetNewObjectScope();
            var pages = (from c in scope.GetOqlQuery <ContentPage>().ExecuteEnumerable()
                         where c.ID != null && c.ID.Equals(pid)
                         select c).ToList();

            foreach (var contentPage in pages)
            {
                scope.Transaction.Begin();
                scope.Remove(contentPage);
                scope.Transaction.Commit();
            }
            return(RedirectToAction("Pages"));
        }
Пример #4
0
 public ActionResult Employer(EmployerModel model)
 {
     if (ModelState.IsValid)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         scope.Transaction.Begin();
         var employer = new Employer
         {
             Academic            = model.Academic,
             AdditionalBenefits  = model.AdditionalBenefits,
             AddressOftheCompany = model.AddressOftheCompany,
             AgeFrom             = model.AgeFrom,
             AgeTo                   = model.AgeTo,
             ContactPerson           = model.ContactPerson,
             Contractbaselabours     = model.Contractbaselabours,
             EmailID                 = model.EmailID,
             ExperienceFrom          = model.ExperienceFrom,
             ExperienceTo            = model.ExperienceTo,
             FaxNo                   = model.FaxNo,
             GrossSalaryFrom         = model.GrossSalaryFrom,
             GrossSalaryTo           = model.GrossSalaryTo,
             Industry                = model.Industry,
             InterviewerName         = model.InterviewerName,
             InterviewerPosition     = model.InterviewerPosition,
             InterviewLocation       = model.InterviewLocation,
             Jobdescription          = model.Jobdescription,
             MobileNo                = model.MobileNo,
             NameOftheCompany        = model.NameOftheCompany,
             NatureOfBusiness        = model.NatureOfBusiness,
             NoOfPositionsRequired   = model.NoOfPositionsRequired,
             PhoneNoOffice           = model.PhoneNoOffice,
             PhoneNoResident         = model.PhoneNoResident,
             PlaceOfWork             = model.PlaceOfWork,
             Position                = model.Position,
             Preferences             = model.Preferences,
             ProbableDate            = model.ProbableDate,
             ProbableDateOfInterview = model.ProbableDateOfInterview,
             TechnicalOrProfessional = model.TechnicalOrProfessional,
             Totalregularmanpower    = model.Totalregularmanpower,
             Totalturnover           = model.Totalturnover
         };
         scope.Add(employer);
         scope.Transaction.Commit();
         ViewData["Status"] = "Thank you for posting your requirement with us, we will get back to you soon.";
         return(View("Status"));
     }
     return(View());
 }
        public ActionResult DeleteMenu(string mid)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("LogOn", "Account"));
            }
            if (ModelState.IsValid)
            {
                DeleteMenus(mid);
            }
            var scope = ObjectScopeProvider1.GetNewObjectScope();

            ViewData["menus"] = (from c in scope.GetOqlQuery <Menu>().ExecuteEnumerable()
                                 select c).ToList();
            return(View("Menus"));
        }
 public ActionResult EditMenu(MenuModel menuModel)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(RedirectToAction("LogOn", "Account"));
     }
     if (ModelState.IsValid)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         var menus = (from c in scope.GetOqlQuery <Menu>().ExecuteEnumerable()
                      where c.Id != null && c.Id.Equals(menuModel.Id)
                      select c).ToList();
         if (menus.Count > 0)
         {
             var contentPages = (from c in scope.GetOqlQuery <ContentPage>().ExecuteEnumerable()
                                 where c.Id.Equals(Request.Form["CmbPages"])
                                 select c).ToList();
             if (contentPages.Count > 0)
             {
                 string selectedMenu = Request.Form["CmbParentMenu"];
                 string parentID     = string.Empty;
                 if (!string.IsNullOrEmpty(selectedMenu) && selectedMenu.ToLower().Trim() != "--root--")
                 {
                     var menuIds = (from c in scope.GetOqlQuery <Menu>().ExecuteEnumerable()
                                    where c.Id != null && c.Id.Equals(selectedMenu)
                                    select c.Id).ToList();
                     if (menuIds.Count > 0)
                     {
                         parentID = menuIds[0];
                     }
                 }
                 foreach (Menu menu in menus)
                 {
                     scope.Transaction.Begin();
                     menu.Name     = menuModel.MenuName;
                     menu.Page     = contentPages[0];
                     menu.ParentId = parentID;
                     scope.Add(menu);
                     scope.Transaction.Commit();
                 }
             }
         }
     }
     return(RedirectToAction("Menus"));
 }
 public static byte[] SignatureImage(string id)
 {
     try
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         List <SignatureImage> files = (from c in scope.GetOqlQuery <SignatureImage>().ExecuteEnumerable()
                                        where c.ID.ToString().Equals(id)
                                        select c).ToList();
         if (files.Count > 0)
         {
             return(files[0].Filedata);
         }
     }
     catch (Exception)
     {
     }
     return(null);
 }
 //
 // GET: /Signature/
 public FileContentResult Signature(string id)
 {
     try
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         List <SignatureImage> files = (from c in scope.GetOqlQuery <SignatureImage>().ExecuteEnumerable()
                                        where c.ID.ToString().Equals(id)
                                        select c).ToList();
         if (files.Count > 0)
         {
             return(File(files[0].Filedata, files[0].MimeType, files[0].Filename));
         }
     }
     catch (Exception)
     {
     }
     return(null);
 }
Пример #9
0
        public static string GetProjects(string groupuid, string currentuseruid)
        {
            var outputTable = new DataTable();

            outputTable.Columns.Add("uid");
            outputTable.Columns.Add("name");
            try
            {
                // open access dynamic databse configuration
                string SiteUrl = HttpContext.Current.Request.UrlReferrer.Scheme + "://" +
                                 HttpContext.Current.Request.UrlReferrer.Host + ":" +
                                 HttpContext.Current.Request.UrlReferrer.Port + "/" +
                                 HttpContext.Current.Request.UrlReferrer.Segments[1];
                if (MyUtilities.DevelopMode)
                {
                    SiteUrl = MyUtilities.ProjectServerInstanceURL(SPContext.Current);
                }

                MyUtilities.ModifyConnectionString(SiteUrl);

                using (IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope())
                {
                    List <Groups> groups = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                            from d in c.groups
                                            where c.ResourceUID.Equals(currentuseruid) && d.UID.Equals(groupuid)
                                            select d).ToList();
                    if (groups.Count > 0)
                    {
                        foreach (var project in groups[0].projects)
                        {
                            var testrow = outputTable.NewRow();
                            testrow["uid"]  = project.uid;
                            testrow["name"] = project.name;
                            outputTable.Rows.Add(testrow);
                        }
                    }
                }
            }
            catch (Exception)
            {
                // error log here
            }
            return(MyUtilities.Serialize(outputTable));
        }
 public ActionResult EditPage(PageModel pageModel)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(RedirectToAction("LogOn", "Account"));
     }
     if (ModelState.IsValid)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         var pages = (from c in scope.GetOqlQuery <ContentPage>().ExecuteEnumerable()
                      where c.Id != null && c.Id.Equals(pageModel.ID)
                      select c).ToList();
         foreach (ContentPage page in pages)
         {
             scope.Transaction.Begin();
             page.Name    = pageModel.PageTitle;
             page.Content = pageModel.Content;
             scope.Add(page);
             scope.Transaction.Commit();
             try
             {
                 using (var connection = new SqlConnection("Data Source=208.91.198.196;Initial Catalog=admin_hopestrack;Persist Security Info=True;User ID=hopestrack;Password=password@123"))
                 {
                     connection.Open();
                     string qry     = "update content_page set [<_content>k___backing_field] = '" + pageModel.Content + "' where [<_id>k___backing_field]='" + page.Id + "'";
                     var    command = new SqlCommand(qry, connection);
                     command.ExecuteNonQuery();
                     connection.Close();
                 }
             }
             catch (Exception)
             {
                 continue;
             }
             break;
         }
         LoadPages();
         return(View("Pages"));
     }
     return(View(pageModel));
 }
Пример #11
0
        public ActionResult Index()
        {
            var scope = ObjectScopeProvider1.GetNewObjectScope();
            var count = (from c in scope.GetOqlQuery <ContentPage>().ExecuteEnumerable()
                         where c.Name.ToLower().Trim().Equals("index")
                         select c).Count();

            if (count > 0)
            {
                var page = (from c in scope.GetOqlQuery <ContentPage>().ExecuteEnumerable()
                            where c.Name.ToLower().Trim().Equals("index")
                            select c).First();
                ViewData["Content"] = page.Content;
            }
            else
            {
                ViewData["Content"] = "";
            }

            return(View());
        }
 public ActionResult EditMenu(string mid)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(RedirectToAction("LogOn", "Account"));
     }
     if (!string.IsNullOrEmpty(mid))
     {
         var scope        = ObjectScopeProvider1.GetNewObjectScope();
         var contentPages = (from c in scope.GetOqlQuery <ContentPage>().ExecuteEnumerable()
                             select c).ToList();
         ViewData["ContentPages"] = contentPages;
         ViewData["menus"]        = (from c in scope.GetOqlQuery <Menu>().ExecuteEnumerable()
                                     where c.Id != null && !c.Id.Equals(mid)
                                     select c).ToList();
         ViewData["Pagename"] = string.Empty;
         var menus = (from c in scope.GetOqlQuery <Menu>().ExecuteEnumerable()
                      where c.Id != null && c.Id.Equals(mid)
                      select c).ToList();
         if (menus.Count > 0)
         {
             ViewData["ParentMenuId"] = menus[0].ParentId;
             var menuModel = new MenuModel
             {
                 MenuName = menus[0].Name,
                 Id       = menus[0].Id
             };
             foreach (ContentPage contentPage in contentPages)
             {
                 if (contentPage.Name.ToLower().Equals(menus[0].Page.Name.ToLower()))
                 {
                     ViewData["Pagename"] = contentPage.Name;
                     break;
                 }
             }
             return(View(menuModel));
         }
     }
     return(RedirectToAction("Menus"));
 }
 public ActionResult Ajaxaddimage(ImageModel file, HttpPostedFileBase image)
 {
     if (ModelState.IsValid)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         scope.Transaction.Begin();
         var productFile = new HopestrackDL.File {
             Filename = image.FileName
         };
         Stream fileStream = image.InputStream;
         int    fileLength = image.ContentLength;
         productFile.Filedata = new byte[fileLength];
         fileStream.Read(productFile.Filedata, 0, fileLength);
         productFile.MimeType = image.ContentType;
         productFile.Id       = DateTime.Now.Ticks.ToString();
         scope.Add((productFile));
         scope.Transaction.Commit();
         ViewData["Status"] = "Image added successfully.";
         return(View(new ImageModel()));
     }
     return(View(file));
 }
Пример #14
0
 public ActionResult ExporttoExcel()
 {
     if (User.Identity.IsAuthenticated)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         if (Checkauthorization(scope, User.Identity.Name))
         {
             ViewData["selectedTypeOfReceipt"] = string.Empty;
             ViewData["SeachReceipts"]         = new List <ReceiptData>();
             ViewData["typeofreceipts"]        = new List <string> {
                 "All", "Regular", "Recurrence", "Merchandise", "Service"
             };
             return
                 (View(new ExporttoExcelModel {
                 EndDate = DateTime.Now, StartDate = DateTime.Now
             }));
         }
         ViewData["Status"] = "You are not authorized to do this operation";
         return(View("PartialViewStatus"));
     }
     return(RedirectToAction("LogOn", "Account"));
 }
        private void DeleteMenus(string menuId)
        {
            var scope = ObjectScopeProvider1.GetNewObjectScope();
            var menus = (from c in scope.GetOqlQuery <Menu>().ExecuteEnumerable()
                         where c.Id != null && c.Id.Equals(menuId)
                         select c).ToList();

            foreach (Menu menu in menus)
            {
                Menu menu1       = menu;
                var  parentmenus = (from c in scope.GetOqlQuery <Menu>().ExecuteEnumerable()
                                    where c.ParentId != null && c.ParentId.Equals(menu1.Id)
                                    select c).ToList();
                foreach (var parentmenu in parentmenus)
                {
                    DeleteMenu(parentmenu.Id);
                }

                scope.Transaction.Begin();
                scope.Remove(menu);
                scope.Transaction.Commit();
            }
        }
 public ActionResult AddPage(PageModel adPageModel)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(RedirectToAction("LogOn", "Account"));
     }
     if (ModelState.IsValid)
     {
         var scope       = ObjectScopeProvider1.GetNewObjectScope();
         var contentPage = new ContentPage {
             Name = adPageModel.PageTitle, Content = adPageModel.Content, Id = DateTime.Now.Ticks.ToString()
         };
         scope.Transaction.Begin();
         scope.Add(contentPage);
         scope.Transaction.Commit();
         try
         {
             using (var connection = new SqlConnection("Data Source=208.91.198.196;Initial Catalog=admin_hopestrack;Persist Security Info=True;User ID=hopestrack;Password=password@123"))
             {
                 connection.Open();
                 string qry     = "update content_page set [<_content>k___backing_field] = '" + adPageModel.Content + "' where [<_id>k___backing_field]='" + contentPage.Id + "'";
                 var    command = new SqlCommand(qry, connection);
                 command.ExecuteNonQuery();
                 connection.Close();
             }
         }
         catch (Exception)
         {
             LoadPages();
             return(View("Pages"));
         }
         LoadPages();
         return(View("Pages"));
     }
     return(View(adPageModel));
 }
 public ActionResult EditPage(string pid)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(RedirectToAction("LogOn", "Account"));
     }
     if (pid != null)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         var pages = (from c in scope.GetOqlQuery <ContentPage>().ExecuteEnumerable()
                      where c.Id != null && c.Id.Equals(pid)
                      select c).ToList();
         var contentPage = new PageModel();
         foreach (ContentPage page in pages)
         {
             contentPage.PageTitle = page.Name;
             contentPage.Content   = page.Content;
             contentPage.ID        = page.Id;
             break;
         }
         return(View(contentPage));
     }
     return(RedirectToAction("Pages"));
 }
Пример #18
0
        public ActionResult SearchReceipts(SearchModel searchModel)
        {
            if (User.Identity.IsAuthenticated)
            {
                var scope = ObjectScopeProvider1.GetNewObjectScope();
                if (Checkauthorization(scope, User.Identity.Name))
                {
                    ViewData["selectedTypeOfReceipt"] = string.Empty;
                    ViewData["SeachReceipts"]         = new List <ReceiptData>();
                    ViewData["typeofreceipts"]        = new List <string> {
                        "All", "Regular", "Recurrence", "Merchandise", "Service"
                    };
                    if (ModelState.IsValid)
                    {
                        ViewData["selectedTypeOfReceipt"] = searchModel.TypeOfReceipt;
                        ReceiptType receiptType = ReceiptType.GeneralReceipt;
                        switch (searchModel.TypeOfReceipt)
                        {
                        case "Regular":
                        {
                            receiptType = ReceiptType.GeneralReceipt;
                            break;
                        }

                        case "Recurrence":
                        {
                            receiptType = ReceiptType.RecurringReceipt;
                            break;
                        }

                        case "Merchandise":
                        {
                            receiptType = ReceiptType.MerchandiseReceipt;
                            break;
                        }

                        case "Service":
                        {
                            receiptType = ReceiptType.ServicesReceipt;
                            break;
                        }

                        case "All":
                        {
                            break;
                        }
                        }
                        List <Receipt> receipts;
                        int            maxrecordsperpage = Convert.ToInt32(searchModel.Maxrecordsperpage);
                        if (searchModel.TypeOfReceipt != "All")
                        {
                            receipts = (from c in scope.GetOqlQuery <Receipt>().ExecuteEnumerable()
                                        where c.ReceiptType.Equals(receiptType) && c.DateReceived >= searchModel.StartDate && c.DateReceived <= searchModel.EndDate
                                        orderby c.ReceiptNumber
                                        select c).Skip(searchModel.PageIndex * maxrecordsperpage).Take(
                                maxrecordsperpage).ToList();
                        }
                        else
                        {
                            receipts = (from c in scope.GetOqlQuery <Receipt>().ExecuteEnumerable()
                                        where c.DateReceived >= searchModel.StartDate && c.DateReceived <= searchModel.EndDate
                                        orderby c.ReceiptNumber
                                        select c).Skip(searchModel.PageIndex * maxrecordsperpage).Take(
                                maxrecordsperpage).ToList();
                        }
                        var localRegularReceipts = receipts.Select(receipt => new ReceiptData
                        {
                            ReceiptNumber =
                                receipt.ReceiptNumber,
                            FirstName    = receipt.FirstName,
                            Mi           = receipt.Mi,
                            LastName     = receipt.LastName,
                            DateReceived =
                                receipt.DateReceived,
                            ReceiptType =
                                receipt.ReceiptType.ToString()
                        }).ToList();
                        ViewData["pageIndex"] = searchModel.PageIndex;
                        if (searchModel.PageIndex <= 0)
                        {
                            ViewData["HasPrevious"] = false;
                        }
                        else
                        {
                            ViewData["HasPrevious"] = true;
                        }
                        int totalrecords;
                        if (searchModel.TypeOfReceipt != "All")
                        {
                            totalrecords = (from c in scope.GetOqlQuery <Receipt>().ExecuteEnumerable()
                                            where c.ReceiptType.Equals(receiptType) && c.DateReceived >= searchModel.StartDate && c.DateReceived <= searchModel.EndDate
                                            select c).Count();
                        }
                        else
                        {
                            totalrecords = (from c in scope.GetOqlQuery <Receipt>().ExecuteEnumerable()
                                            where c.DateReceived >= searchModel.StartDate && c.DateReceived <= searchModel.EndDate
                                            select c).Count();
                        }
                        if (totalrecords > (searchModel.PageIndex + 1) * NoOfRecordsPerPage)
                        {
                            ViewData["HasNext"] = true;
                        }
                        else
                        {
                            ViewData["HasNext"] = false;
                        }

                        ViewData["SeachReceipts"] = localRegularReceipts;
                        return(View(searchModel));
                    }
                    return(View(searchModel));
                }
                ViewData["Status"] = "You are not authorized to do this operation";
                return(View("PartialViewStatus"));
            }
            return(RedirectToAction("LogOn", "Account"));
        }
Пример #19
0
        public static bool PlaceProject(string groupuid, string projectuid, string currentuseruid)
        {
            bool Output = false;

            try
            {
                // open access dynamic databse configuration
                string SiteUrl = HttpContext.Current.Request.UrlReferrer.Scheme + "://" +
                                 HttpContext.Current.Request.UrlReferrer.Host + ":" +
                                 HttpContext.Current.Request.UrlReferrer.Port + "/" +
                                 HttpContext.Current.Request.UrlReferrer.Segments[1];
                if (MyUtilities.DevelopMode)
                {
                    SiteUrl = MyUtilities.ProjectServerInstanceURL(SPContext.Current);
                }

                MyUtilities.ModifyConnectionString(SiteUrl);

                using (IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope())
                {
                    List <Projects> projects = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                                from d in c.groups
                                                from f in d.projects
                                                where c.ResourceUID.Equals(currentuseruid) && f.uid.Equals(projectuid)
                                                select f).ToList();
                    if (projects.Count > 0)
                    {
                        List <Groups> new_groups = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                                    from d in c.groups
                                                    where c.ResourceUID.Equals(currentuseruid) && d.UID.Equals(groupuid)
                                                    select d).ToList();
                        if (new_groups.Count > 0)
                        {
                            List <Groups> old_groups = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                                        from d in c.groups
                                                        from f in d.projects
                                                        where c.ResourceUID.Equals(currentuseruid) && f.uid.Equals(projectuid)
                                                        select d).ToList();
                            // remove from current group first
                            if (old_groups.Count > 0)
                            {
                                if (old_groups[0].projects.Contains(projects[0]))
                                {
                                    scope.Transaction.Begin();
                                    old_groups[0].projects.Remove(projects[0]);
                                    scope.Add(old_groups[0]);
                                    scope.Transaction.Commit();
                                }
                            }

                            scope.Transaction.Begin();
                            new_groups[0].projects.Add(projects[0]);
                            scope.Add(new_groups[0]);
                            scope.Transaction.Commit();
                            Output = true;
                        }
                    }
                }
            }
            catch (Exception)
            {
                // error log here
            }
            return(Output);
        }
Пример #20
0
        public ActionResult JobSeekers(JobSeekerModel jobSeekerModel, HttpPostedFileBase resumeAttachment)
        {
            var result = GetUgQualifications();

            result.Sort();
            ViewData["UGQualifications"] = result;
            result = GetPgQualifications();
            result.Sort();
            ViewData["PGQualifications"] = result;
            result = GetIndustries();
            result.Sort();
            ViewData["Industries"] = result;
            result = GetFunctionalAreas();
            result.Sort();
            ViewData["FunctionalArea"] = result;
            string selectedGender = string.Empty;

            if (Request.Form["Gender"] != null)
            {
                selectedGender = Request.Form["Gender"];
            }
            string selectedUgQualification = string.Empty;

            if (Request.Form["UGQualification"] != null)
            {
                selectedUgQualification = Request.Form["UGQualification"];
            }
            string selectedPgQualification = string.Empty;

            if (Request.Form["PGQualification"] != null)
            {
                selectedPgQualification = Request.Form["PGQualification"];
            }
            string selectedIndustry = string.Empty;

            if (Request.Form["Industry"] != null)
            {
                selectedIndustry = Request.Form["Industry"];
            }
            string selectedFunctionalArea = string.Empty;

            if (Request.Form["Functional"] != null)
            {
                selectedFunctionalArea = Request.Form["Functional"];
            }
            if (string.IsNullOrEmpty(selectedGender))
            {
                ModelState.AddModelError("Gender", "Please select gender.");
            }
            if (string.IsNullOrEmpty(selectedUgQualification))
            {
                ModelState.AddModelError("UgQualification", "Please select your ug qualification.");
            }
            else if (selectedUgQualification.ToLower().Trim() == "others" && string.IsNullOrEmpty(jobSeekerModel.UgOthers))
            {
                ModelState.AddModelError("UgOthers", "Please input your ug qualification - others");
            }
            if (string.IsNullOrEmpty(selectedPgQualification))
            {
                ModelState.AddModelError("PgQualification", "Please select your pg qualification.");
            }
            else if (selectedPgQualification.ToLower().Trim() == "others" && string.IsNullOrEmpty(jobSeekerModel.PgOthers))
            {
                ModelState.AddModelError("PgOthers", "Please input your pg qualification - others");
            }
            if (string.IsNullOrEmpty(selectedIndustry))
            {
                ModelState.AddModelError("Industry", "Please select industry.");
            }
            else if (selectedIndustry.ToLower().Trim() == "others" && string.IsNullOrEmpty(jobSeekerModel.IndustryOthers))
            {
                ModelState.AddModelError("IndustryOthers", "Please input your industry - others");
            }
            if (string.IsNullOrEmpty(selectedFunctionalArea))
            {
                ModelState.AddModelError("Functional", "Please select your functional area.");
            }
            else if (selectedFunctionalArea.ToLower().Trim() == "others" && string.IsNullOrEmpty(jobSeekerModel.FunctionalOthers))
            {
                ModelState.AddModelError("FunctionalOthers", "Please input your functiona area - others");
            }
            if (ModelState.IsValid)
            {
                var scope = ObjectScopeProvider1.GetNewObjectScope();
                scope.Transaction.Begin();
                var jobSeeker = new JobSeeker
                {
                    CurrentCtc         = jobSeekerModel.CurrentCtc,
                    DateOfBirth        = jobSeekerModel.DateOfBirth,
                    EmailID            = jobSeekerModel.EmailID,
                    ExpectedCtc        = jobSeekerModel.ExpectedCtc,
                    FirstName          = jobSeekerModel.FirstName,
                    Functional         = jobSeekerModel.Functional,
                    FunctionalOthers   = jobSeekerModel.FunctionalOthers,
                    Gender             = jobSeekerModel.Gender,
                    Industry           = jobSeekerModel.Industry,
                    IndustryOthers     = jobSeekerModel.IndustryOthers,
                    LastName           = jobSeekerModel.LastName,
                    MobileNo           = jobSeekerModel.MobileNo,
                    NoticePeriod       = jobSeekerModel.NoticePeriod,
                    OptionalEmailID    = jobSeekerModel.OptionalEmailID,
                    PgOthers           = jobSeekerModel.PgOthers,
                    PgQualification    = jobSeekerModel.PgQualification,
                    PhoneNo            = jobSeekerModel.PhoneNo,
                    PrimarySkillSet    = jobSeekerModel.PrimarySkillSet,
                    RelaventExperience = jobSeekerModel.RelaventExperience,
                    SecondarySkillSet  = jobSeekerModel.SecondarySkillSet,
                    TotalExperience    = jobSeekerModel.TotalExperience,
                    UgOthers           = jobSeekerModel.UgOthers,
                    UgQualification    = jobSeekerModel.UgQualification
                };
                Stream fileStream = resumeAttachment.InputStream;
                int    fileLength = resumeAttachment.ContentLength;
                var    attachment = new Attachment
                {
                    Filedata = new byte[fileLength],
                    MimeType = resumeAttachment.ContentType,
                    Id       = DateTime.Now.Ticks.ToString()
                };
                fileStream.Read(attachment.Filedata, 0, fileLength);
                jobSeeker.ResumeAttachment = attachment;
                scope.Add((jobSeeker));
                scope.Transaction.Commit();
                ViewData["Status"] = "Thank you for uploading your profile, we will get back to you soon.";
                return(View("Status"));
            }
            ViewData["Selectedgender"]          = selectedGender;
            ViewData["SelectedUgQualification"] = selectedUgQualification;
            ViewData["SelectedPgQualification"] = selectedPgQualification;
            ViewData["SelectedIndustry"]        = selectedIndustry;
            ViewData["SelectedFunctionalArea"]  = selectedFunctionalArea;
            return(View());
        }
Пример #21
0
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var         scope         = ObjectScopeProvider1.GetNewObjectScope();
                List <User> logOnFailures = (from c in scope.GetOqlQuery <User>().ExecuteEnumerable()
                                             where c.Username.ToLower().Trim().Equals(model.UserName.ToLower().Trim())
                                             select c).ToList();
                if (logOnFailures.Count > 0 && logOnFailures[0].Failcount > 2 && DateTime.Now.Subtract(logOnFailures[0].Lasttriedtime).TotalMinutes < 10)
                {
                    ModelState.AddModelError("", "The authentication is failed in three consequence times, please wait for ten minites and try again.");
                    return(View(model));
                }
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    if (logOnFailures.Count > 0)
                    {
                        var logOnFailure = logOnFailures[0];
                        scope.Transaction.Begin();
                        logOnFailure.Failcount = 0;
                        scope.Add(logOnFailure);
                        scope.Transaction.Commit();
                    }
                    FormsAuthentication.SetAuthCookie(model.UserName, true);

                    /*var ticket = new FormsAuthenticationTicket(1, model.UserName, DateTime.Now, DateTime.Now.AddDays(30), true, "");
                     * var strEncryptedTicket = FormsAuthentication.Encrypt(ticket);
                     * var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, strEncryptedTicket);
                     * Response.Cookies.Add(cookie); */

                    HttpCookie myCookie = FormsAuthentication.GetAuthCookie(model.UserName, true);
                    myCookie.Domain  = "shirdisaibabaaz.org";
                    myCookie.Path    = "/";
                    myCookie.Expires = DateTime.Now.AddDays(1);
                    Response.AppendCookie(myCookie);

                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }
                    return(RedirectToAction("home", "Controlpanel"));
                }
                if (logOnFailures.Count > 0)
                {
                    var logOnFailure = logOnFailures[0];
                    scope.Transaction.Begin();
                    if (logOnFailure.Failcount == 0)
                    {
                        logOnFailure.Lasttriedtime = DateTime.Now;
                    }
                    logOnFailure.Failcount += 1;
                    scope.Add(logOnFailure);
                    scope.Transaction.Commit();
                }
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #22
0
        public ActionResult ExporttoExcel(ExporttoExcelModel exporttoExcelModel)
        {
            if (User.Identity.IsAuthenticated)
            {
                var scope = ObjectScopeProvider1.GetNewObjectScope();
                if (Checkauthorization(scope, User.Identity.Name))
                {
                    ViewData["selectedTypeOfReceipt"] = string.Empty;
                    ViewData["SeachReceipts"]         = new List <ReceiptData>();
                    ViewData["typeofreceipts"]        = new List <string> {
                        "All", "Regular", "Recurrence", "Merchandise", "Service"
                    };
                    if (ModelState.IsValid)
                    {
                        ViewData["selectedTypeOfReceipt"] = exporttoExcelModel.TypeOfReceipt;
                        ReceiptType receiptType = ReceiptType.GeneralReceipt;
                        switch (exporttoExcelModel.TypeOfReceipt)
                        {
                        case "Regular":
                        {
                            receiptType = ReceiptType.GeneralReceipt;
                            break;
                        }

                        case "Recurrence":
                        {
                            receiptType = ReceiptType.RecurringReceipt;
                            break;
                        }

                        case "Merchandise":
                        {
                            receiptType = ReceiptType.MerchandiseReceipt;
                            break;
                        }

                        case "Service":
                        {
                            receiptType = ReceiptType.ServicesReceipt;
                            break;
                        }

                        case "All":
                        {
                            break;
                        }
                        }
                        List <Receipt> receipts;
                        if (exporttoExcelModel.TypeOfReceipt != "All")
                        {
                            receipts = (from c in scope.GetOqlQuery <Receipt>().ExecuteEnumerable()
                                        where c.ReceiptType.Equals(receiptType) && c.DateReceived >= exporttoExcelModel.StartDate && c.DateReceived <= exporttoExcelModel.EndDate
                                        orderby c.ReceiptNumber
                                        select c).ToList();
                        }
                        else
                        {
                            receipts = (from c in scope.GetOqlQuery <Receipt>().ExecuteEnumerable()
                                        where c.DateReceived >= exporttoExcelModel.StartDate && c.DateReceived <= exporttoExcelModel.EndDate
                                        orderby c.ReceiptNumber
                                        select c).ToList();
                        }

                        Response.AppendHeader("Content-Disposition", "attachment;filename=ExporttoExcel.csv");
                        Response.Charset         = "UTF-8";
                        Response.ContentEncoding = System.Text.Encoding.UTF8;
                        Response.ContentType     = "application/text/csv";
                        String csvOutput =
                            "Receipt ID, Receipt Type,First Name,MI,Last Name,Address 1,Address 2,City,State,Zip Code,Email,Contact,Date Received,Issued Date,Donation Amount,Donation Amount in words,Recurring Payment Details,Merchandise Item,Quantity,Value,Service Type,Hours Served,Rate per hour,FMV Value,Mode of Payment,Received By";
                        foreach (Receipt receipt in receipts)
                        {
                            double totalAmount;
                            if (receipt.ReceiptType == ReceiptType.RecurringReceipt)
                            {
                                totalAmount = receipt.RecurringDetails.Sum(recurringDetail => Convert.ToDouble(recurringDetail.Amount));
                            }
                            else
                            {
                                totalAmount = Convert.ToDouble(receipt.DonationAmount);
                            }
                            // adding data
                            csvOutput += Environment.NewLine;
                            csvOutput += receipt.ReceiptNumber;
                            csvOutput += "," + receipt.ReceiptType;
                            csvOutput += "," + receipt.FirstName;
                            csvOutput += "," + receipt.Mi;
                            csvOutput += "," + receipt.LastName;
                            csvOutput += "," + receipt.Address;
                            csvOutput += "," + receipt.Address2;
                            csvOutput += "," + receipt.City;
                            csvOutput += "," + receipt.State;
                            csvOutput += "," + receipt.ZipCode;
                            csvOutput += "," + receipt.Email;
                            csvOutput += "," + receipt.Contact;

                            if (receipt.ReceiptType == ReceiptType.RecurringReceipt)
                            {
                                csvOutput += ",";
                            }
                            else
                            {
                                csvOutput += "," + receipt.DateReceived.ToString("MM/dd/yyyy");
                            }

                            csvOutput += "," + receipt.IssuedDate.ToString("MM/dd/yyyy");
                            if (receipt.ReceiptType == ReceiptType.RecurringReceipt || receipt.ReceiptType == ReceiptType.GeneralReceipt)
                            {
                                csvOutput += "," + totalAmount.ToString("0.00");
                                csvOutput += "," + receipt.DonationAmountinWords;
                            }
                            else
                            {
                                csvOutput += ",";
                                csvOutput += ",";
                            }
                            string recurringDates = receipt.RecurringDetails.Aggregate(" ", (current, recurringDetail) => current + ("(" + recurringDetail.DueDate.ToString("MM/dd/yyyy") + "-" + recurringDetail.ModeOfPayment + "-" + recurringDetail.Amount + ")"));
                            csvOutput += "," + recurringDates;

                            if (receipt.ReceiptType == ReceiptType.MerchandiseReceipt)
                            {
                                csvOutput += "," + receipt.MerchandiseItem;
                                csvOutput += "," + receipt.Quantity;
                                csvOutput += "," + Convert.ToDouble(receipt.FmvValue).ToString("0.00");
                            }
                            else
                            {
                                csvOutput += ",";
                                csvOutput += ",";
                                csvOutput += ",";
                            }

                            if (receipt.ReceiptType == ReceiptType.ServicesReceipt)
                            {
                                csvOutput += "," + receipt.ServiceType;
                                csvOutput += "," + receipt.HoursServed;
                                csvOutput += "," + Convert.ToDouble(receipt.RatePerHrOrDay).ToString("0.00");
                                csvOutput += "," + Convert.ToDouble(receipt.FmvValue).ToString("0.00");
                            }
                            else
                            {
                                csvOutput += ",";
                                csvOutput += ",";
                                csvOutput += ",";
                                csvOutput += ",";
                            }

                            if (receipt.ReceiptType == ReceiptType.RecurringReceipt || receipt.ReceiptType == ReceiptType.MerchandiseReceipt || receipt.ReceiptType == ReceiptType.ServicesReceipt)
                            {
                                csvOutput += ",";
                            }
                            else
                            {
                                csvOutput += "," + receipt.ModeOfPayment;
                            }
                            csvOutput += "," + receipt.DonationReceiver.Username;
                        }

                        Response.Write(csvOutput);
                        Response.End();
                        return(View(exporttoExcelModel));
                    }
                    return(View(exporttoExcelModel));
                }
                ViewData["Status"] = "You are not authorized to do this operation";
                return(View("PartialViewStatus"));
            }
            return(RedirectToAction("LogOn", "Account"));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Browser detection and redirecting to error page
            if (Request.Browser.Browser.ToLower() == "ie" && Convert.ToDouble(Request.Browser.Version) < 7)
            {
                SPUtility.TransferToErrorPage("To view this report use later versions of IE 6.0");
            }
            else
            {
                try
                {
                    string SiteUrl = MyUtilities.ProjectServerInstanceURL(SPContext.Current);

                    var Resource_Svc = new Resource();
                    var Project_Svc  = new Project();

                    Resource_Svc.UseDefaultCredentials = true;
                    Project_Svc.UseDefaultCredentials  = true;

                    Resource_Svc.Url = SiteUrl + "/_vti_bin/psi/resource.asmx";
                    Project_Svc.Url  = SiteUrl + "/_vti_bin/psi/project.asmx";

                    Resource_Svc.AllowAutoRedirect = true;
                    Project_Svc.AllowAutoRedirect  = true;

                    if (MyUtilities.IndividualPages)
                    {
                        LnkConfigButton.PostBackUrl = SiteUrl + "/_layouts/ITXProjectGovernanceReport/ITXPGReport.aspx";
                    }
                    else
                    {
                        LnkConfigButton.Visible = false;
                    }

                    // setting current user uid
                    LblCurUserUId.Text = Resource_Svc.GetCurrentUserUid().ToString();

                    // For Group Repeater control

                    var GroupTable = new DataTable();
                    GroupTable.Columns.Add("title");
                    GroupTable.Columns.Add("grpid");

                    // impersonation here
                    try
                    {
                        var wik = WindowsIdentity.Impersonate(IntPtr.Zero);
                    }
                    catch (Exception)
                    {
                    }

                    MyUtilities.ModifyConnectionString(SiteUrl);

                    using (IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope())
                    {
                        // creating the user account into db if not exists
                        List <Users> userses = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                                where c.ResourceUID.Equals(LblCurUserUId.Text)
                                                select c).ToList();
                        if (userses.Count == 0)
                        {
                            scope.Transaction.Begin();
                            var new_user = new Users();
                            new_user.ResourceUID = LblCurUserUId.Text;
                            scope.Add(new_user);
                            scope.Transaction.Commit();

                            userses = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                       where c.ResourceUID.Equals(LblCurUserUId.Text)
                                       select c).ToList();
                        }

                        List <Groups> groups = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                                from d in c.groups
                                                where
                                                c.ResourceUID.Equals(LblCurUserUId.Text) &&
                                                !d.UID.Equals(Guid.Empty.ToString())
                                                select d).ToList();
                        foreach (var group in groups)
                        {
                            var new_row = GroupTable.NewRow();
                            new_row["title"] = group.name;
                            new_row["grpid"] = group.UID;
                            GroupTable.Rows.Add(new_row);
                        }

                        RptrGroupnames.DataSource = GroupTable;
                        RptrGroupnames.DataBind();

                        // For Project name Repeater Control
                        var ProjectTable = MyUtilities.GetProjects_DataTable(SiteUrl, new Guid(LblCurUserUId.Text));

                        groups = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                  from d in c.groups
                                  where c.ResourceUID.Equals(LblCurUserUId.Text) && d.UID.Equals(Guid.Empty.ToString())
                                  select d).ToList();

                        if (groups.Count == 0)
                        {
                            if (userses.Count > 0)
                            {
                                scope.Transaction.Begin();
                                var new_group = new Groups();
                                new_group.name = "Not Grouped.";
                                new_group.UID  = Guid.Empty.ToString();
                                userses[0].groups.Add(new_group);
                                scope.Add(userses[0]);
                                scope.Transaction.Commit();
                            }
                            groups = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                      from d in c.groups
                                      where
                                      c.ResourceUID.Equals(LblCurUserUId.Text) &&
                                      d.UID.Equals(Guid.Empty.ToString())
                                      select d).ToList();
                        }

                        // Checking and adding missed projects to the user
                        foreach (DataRow row in ProjectTable.Rows)
                        {
                            var count = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                         from d in c.groups
                                         from f in d.projects
                                         where
                                         c.ResourceUID.Equals(LblCurUserUId.Text) &&
                                         f.uid.Equals(row["ProjectUID"].ToString())
                                         select e).Count();
                            if (count == 0 && groups.Count > 0)
                            {
                                scope.Transaction.Begin();
                                var new_proj_row = new Projects();
                                new_proj_row.name = row["Title"].ToString();
                                new_proj_row.uid  = row["ProjectUID"].ToString();
                                groups[0].projects.Add(new_proj_row);
                                scope.Add(groups[0]);
                                scope.Transaction.Commit();
                            }
                        }

                        RptrProjectnames.DataSource = (from c in scope.GetOqlQuery <Users>().ExecuteEnumerable()
                                                       from d in c.groups
                                                       from f in d.projects
                                                       where
                                                       c.ResourceUID.Equals(LblCurUserUId.Text) &&
                                                       d.UID.Equals(Guid.Empty.ToString())
                                                       select f).AsEnumerable();
                        RptrProjectnames.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    MyUtilities.ErrorLog("Error at Project Group Congure load due to " + ex.Message,
                                         EventLogEntryType.Error);
                    if (MyUtilities.DevelopMode)
                    {
                        Response.Write(ex.Message);
                    }
                }
            }
        }