コード例 #1
0
        public ActionResult Create(CreateModel m)
        {
            if (ModelState.IsValid)
            {
                //var user = BenefitsAllocation.Core.Domain.User.GetByLoginId(Repository, User.Identity.Name);
                var user = Models.User.FindByLoginId(System.Web.HttpContext.Current.User.Identity.Name);

                var unit = user.Units.FirstOrDefault();
                var orgId = string.Empty;
                var transDocOriginCode = string.Empty;
                using (var context = new FISDataMartEntities())
                {
                    var schoolCodeParameter = new SqlParameter("schoolCode", unit.SchoolCode);
                    orgId = context.Database.SqlQuery<string>(
                    "SELECT dbo.udf_GetOrgIdForSchoolCode(@schoolCode)", schoolCodeParameter).FirstOrDefault();
                    var orgIdParameter = new SqlParameter("orgId", orgId);
                    transDocOriginCode = context.Database.SqlQuery<string>(
                    "SELECT dbo.udf_GetTransDocOriginCodeForOrg(@orgId)", orgIdParameter).FirstOrDefault();
                }

                //var filename = _dataExtractionService.CreateFile(m.FiscalYear, m.FiscalPeriod, m.TransDescription, m.OrgDocNumber, m.OrgRefId, m.TransDocNumberSequence);
                var useDaFIS = (m.UseDaFIS == CreateModel.YesNo.Yes);
                var filename = _dataExtractionService.CreateFile(m.FiscalYear, m.FiscalPeriod.Period, m.TransDescription, m.OrgDocNumber, m.OrgRefId, m.TransDocNumberSequence, orgId, transDocOriginCode, useDaFIS);
                //var user = BenefitsAllocation.Core.Domain.User.GetByLoginId(Repository, User.Identity.Name);
                //var unit = user.Units.FirstOrDefault();

                Message = "No file was created.  There was no benefits data available.";
                if (!string.IsNullOrWhiteSpace(filename))
                {
                    var unitFile = new UnitFile()
                    {
                        Filename = filename,
                        SchoolCode = unit.DeansOfficeSchoolCode,
                        UnitId = unit.UnitID,
                        Created = DateTime.Now,
                        CreatedBy = User.Identity.Name
                    };

                    _unitFileRepository.EnsurePersistent(unitFile);

                    Message = String.Format("File \"{0}\" has been created.", filename);
                }

                return RedirectToAction("Index");
            }
            return View(m);
        }
コード例 #2
0
        public List<FileNames> GetFiles()
        {
            var user = User.FindByLoginId(System.Web.HttpContext.Current.User.Identity.Name);
            var lstFiles = new List<FileNames>();
            var dirInfo = new DirectoryInfo(HostingEnvironment.MapPath(_storageLocation));

            int i = 0;
            foreach (var item in dirInfo.GetFiles())
            {
                lstFiles.Add(new FileNames()
                    {

                        FileId = i + 1,
                        FileName = item.Name,
                        TimeStamp = item.CreationTime,
                        FilePath = dirInfo.FullName + @"\" + item.Name
                    });
                i = i + 1;
            }
            using (var db = new FISDataMartEntities())
            {
                var unitFiles = db.UnitFiles.ToList();
                foreach (var file in lstFiles)
                {
                    var unitFileResult = unitFiles.FirstOrDefault(u => u.Filename.Equals(file.FileName));
                    if (unitFileResult != null)
                    {
                        file.CreatedBy = unitFileResult.CreatedBy;
                        file.Uploaded = unitFileResult.Uploaded;
                        file.UploadedBy = unitFileResult.UploadedBy;
                        file.SchoolCode = unitFileResult.SchoolCode;
                    }
                }
            }

            return lstFiles;
        }
コード例 #3
0
        public ActionResult Index()
        {
            var results = new List<ExpiredAccount>();
            using (var db = new FISDataMartEntities())
            {
                var user = Models.User.FindByLoginId(System.Web.HttpContext.Current.User.Identity.Name);
                var unit = user.Units.FirstOrDefault();
                var orgId = string.Empty;

                var today = DateTime.Now;
                var year = today.Year;
                var month = today.Month;

                if (month >= 8)
                    year += 1;
                var fiscalYear = year.ToString();

                var schoolCodeParameter = new SqlParameter("schoolCode", unit.SchoolCode);

                orgId = db.Database.SqlQuery<string>(
                    "SELECT dbo.udf_GetOrgIdForSchoolCode(@schoolCode)", schoolCodeParameter).FirstOrDefault();

                var command = db.Database.Connection.CreateCommand();
                command.CommandText = "dbo.usp_GetExpiredAccountsForOrg";
                command.CommandType = CommandType.StoredProcedure;

                var parameter = new SqlParameter
                    {
                        ParameterName = "@FiscalYear",
                        SqlDbType = SqlDbType.VarChar,
                        Direction = ParameterDirection.Input,
                        Value = fiscalYear
                    };
                command.Parameters.Add(parameter);

                parameter = new SqlParameter
                    {
                        ParameterName = "@OrgId",
                        SqlDbType = SqlDbType.VarChar,
                        Direction = ParameterDirection.Input,
                        Value = orgId
                    };
                command.Parameters.Add(parameter);

                parameter = new SqlParameter
                {
                    ParameterName = "@UseDaFIS",
                    SqlDbType = SqlDbType.Bit,
                    Direction = ParameterDirection.Input,
                    //Value =  (!"AAES".Equals(orgId))  // our local database has been timing out lately; therefore, use DaFIS for all Orgs.
                    Value =  1
                };
                command.Parameters.Add(parameter);

                command.Connection.Open();
                var reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        results.Add(new ExpiredAccount
                            {
                                Level3OrgCode = reader[0].ToString(),
                                ChartNum = reader[1].ToString(),
                                AccountNum = reader[2].ToString(),
                                ExpirationDate = (DateTime)reader[3],
                                Amount = (decimal)reader[4] ,
                                MgrId = reader[5].ToString(),
                                MgrName = reader[6].ToString()
                            }
                            );
                    }
                }

                reader.Close();
                command.Connection.Close();
                command.Dispose();

                ViewData.Model = results;
            }
            return View();
        }
        protected string GetOrgIdForCurrentUser()
        {
            var retval = string.Empty;

            using (var db = new FISDataMartEntities())
            {
                var user = Models.User.FindByLoginId(System.Web.HttpContext.Current.User.Identity.Name);
                var unit = user.Units.FirstOrDefault();
                var schoolCodeParameter = new SqlParameter("schoolCode", unit.SchoolCode);

                retval = db.Database.SqlQuery<string>(
                    "SELECT dbo.udf_GetOrgIdForSchoolCode(@schoolCode)", schoolCodeParameter).FirstOrDefault();
            }
            return retval;
        }