Пример #1
0
        public ActionResult ApplicationUpdates()
        {
            if (SessionCheck())
            {
                var OptionModelList   = new List <OptionModel>();
                var combinedModelList = new List <CombinedOptionModel>();
                OptionModelList = retrieveOptionData("ApplicationUpdates");

                CombinedOptionModel combinedOptionModel = new CombinedOptionModel()
                {
                    CombinedFile        = OptionModelList[0].OptionValueString,
                    CombinedVersion     = OptionModelList[1].OptionValueString,
                    CombinedDescription = OptionModelList[2].OptionValueString,
                    CombinedSize        = OptionModelList[3].OptionValueString,
                    CombinedPublishedOn = OptionModelList[4].OptionValueDate
                };


                combinedModelList = retrieveChangeLog("ApplicationUpdates");
                combinedModelList.Insert(0, combinedOptionModel);
                return(View(combinedModelList));
            }
            else
            {
                return(RedirectToAction("Index", "Main"));
            }
        }
Пример #2
0
        public List <CombinedOptionModel> retrieveChangeLog(string pageName)
        {
            List <CombinedOptionModel> combinedOptionModelsList = new List <CombinedOptionModel>();

            string connectionString = @"Data Source = localhost; Initial Catalog = LoginDatabase; Integrated Security = True;";

            using (SqlConnection sqlCon = new SqlConnection(connectionString))
            {
                sqlCon.Open();
                SqlCommand   StrQuer   = new SqlCommand("SELECT * FROM [ChangeLog] WHERE Page = @Pagename", sqlCon);
                SqlParameter pPagename = new SqlParameter("@Pagename", pageName);
                StrQuer.Parameters.Add(pPagename);
                SqlDataReader dr = StrQuer.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        String ChangeLog = dr.GetString(2);
                        //  Get Array of strings, split by ;
                        String[] arrayString = ChangeLog.Split(';');

                        //temp.AnnouncementBy = temp.AnnouncementBy.Replace("\0", "");

                        CombinedOptionModel combinedOptionModel = new CombinedOptionModel()
                        {
                            CombinedFile        = arrayString[0].Replace("ID0:", ""),
                            CombinedVersion     = arrayString[1].Replace("ID1:", ""),
                            CombinedDescription = arrayString[2].Replace("ID2:", ""),
                            CombinedSize        = arrayString[3].Replace("ID3:", ""),
                            CombinedPublishedOn = arrayString[4].Replace("ID4:", ""),
                        };

                        combinedOptionModelsList.Add(combinedOptionModel);
                    }
                }
                dr.Close();
            }

            return(combinedOptionModelsList);
        }