public void GetDailyXmlFile(int xslIId)
        {
            WebClient webCli = new WebClient();
            string xmlData = "";
            if (!Directory.Exists(Server.MapPath("~/Services/PrayerTimes/" + DateTime.Now.Day + DateTime.Now.Month + ".xml")))
            {
                xmlData = webCli.DownloadString("http://www.islamicfinder.org/prayer_service.php?country=jordan&city=amman&state=11&zipcode=&latitude=31.9500&longitude=35.9333&timezone=2&HanfiShafi=1&pmethod=4&fajrTwilight1=10&fajrTwilight2=10&ishaTwilight=10&ishaInterval=30&dhuhrInterval=1&maghribInterval=1&dayLight=1&simpleFormat=xml");
                xmlData = xmlData.Substring(3, xmlData.Length - 3);

                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(xmlData);
                xDoc.Save(Server.MapPath("~/Services/PrayerTimes/" + DateTime.Now.Day + DateTime.Now.Month + ".xml"));
            }
            else
            {
                StreamReader reader = new StreamReader(Server.MapPath("~/Services/PrayerTimes/" + DateTime.Now.Day + DateTime.Now.Month + ".xml"));
                xmlData = reader.ReadToEnd();
            }
            XslTemplate _xslTemplate = new XslTemplate();

            _xslTemplate = XslTemplateManager.GetByID(xslIId);
            if (null == _xslTemplate)
                return;
            string html = TransformXMLWithXSLText(xmlData, _xslTemplate.Details);
            dvdate.InnerHtml = html;
        }
        public int Add(XslTemplate obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = INSERTXslTemplate;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = obj.ID;
            parameterID.Direction = ParameterDirection.Output;
            _command.Parameters.Add(parameterID);
            SqlParameter parameterName = new SqlParameter(PN_NAME, SqlDbType.NVarChar);
            parameterName.Value = obj.Name;
            parameterName.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterName);
            SqlParameter parameterDetails = new SqlParameter(PN_DETAILS, SqlDbType.NVarChar);
            parameterDetails.Value = obj.Details;
            parameterDetails.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterDetails);
            SqlParameter parameterIsDeleted = new SqlParameter(PN_ISDELETED, SqlDbType.Int);
            parameterIsDeleted.Value = obj.IsDeleted;
            parameterIsDeleted.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterIsDeleted);
            SqlParameter parameterHash = new SqlParameter(PN_HASH, SqlDbType.NVarChar);
            parameterHash.Value = obj.Hash;
            parameterHash.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterHash);
            SqlParameter parameterCategoryID = new SqlParameter(PN_CATEGORYID, SqlDbType.Int);
            parameterCategoryID.Value = obj.CategoryID;
            parameterCategoryID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCategoryID);
            #endregion;

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
            obj.ID = Convert.ToInt32(parameterID.Value);
            return obj.ID;
        }
Beispiel #3
0
 public void PopulateXslTemplate(SqlDataReader _dtr, XslTemplate obj)
 {
     int columnIndex = 0;
     columnIndex = _dtr.GetOrdinal(XslTemplateDataMapper.CN_ID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.ID = _dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(XslTemplateDataMapper.CN_NAME);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Name = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(XslTemplateDataMapper.CN_DETAILS);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Details = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(XslTemplateDataMapper.CN_ISDELETED);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.IsDeleted = _dtr.GetBoolean((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(XslTemplateDataMapper.CN_HASH);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Hash = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(XslTemplateDataMapper.CN_CATEGORYID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.CategoryID = _dtr.GetInt32((columnIndex));
     }
 }
 public XslTemplate GetXslTemplate(SqlDataReader _dtr, IList<XslTemplate> colobj)
 {
     XslTemplate obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new XslTemplate();
         colobj.Add(obj);
     }
     return obj;
 }
        public IList<XslTemplate> GetByCategoryID(int CatID)
        {

            XslTemplate obj = null;

            IList<XslTemplate> colobj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTALLXslTemplateByCatID;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_CATEGORYID, SqlDbType.Int);
            parameterID.Value = CatID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            #endregion;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new XslTemplate();
                        colobj = new List<XslTemplate>();
                        while (_dtreader.Read())
                        {
                            obj = GetXslTemplate(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return colobj;
        }
        public IList<XslTemplate> GetAll()
        {

            XslTemplate obj = null;

            IList<XslTemplate> colobj = new List<XslTemplate>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTALLXslTemplate;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new XslTemplate();
                        colobj = new List<XslTemplate>();
                        while (_dtreader.Read())
                        {
                            obj = GetXslTemplate(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return colobj;
        }
 private void GetEntityFromReader(SqlDataReader _dtr, XslTemplate obj)
 {
     PopulateXslTemplate(_dtr, obj);
 }
        public XslTemplate GetByID(int ID)
        {

            XslTemplate obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTXslTemplate;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = ID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            #endregion;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new XslTemplate();
                        if (_dtreader.Read())
                            GetEntityFromReader(_dtreader, obj);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return obj;
        }
Beispiel #9
0
        public static void Update(XslTemplate obj)
        {
            XslTemplateDataMapper objCaller = new XslTemplateDataMapper();

            objCaller.Update(obj);
        }
Beispiel #10
0
        public static int Add(XslTemplate obj)
        {
            XslTemplateDataMapper objCaller = new XslTemplateDataMapper();

            return objCaller.Add(obj);
        }
        private void EditMode()
        {
            if (ObjectID > 0)
            {
                XslTemplate cat = new XslTemplate();
                cat = XslTemplateManager.GetByID(ObjectID);
                if (null == cat)
                    return;

                txtName.Text = cat.Name;
                txtHash.Text = cat.Hash;
                txtDetails.Content = cat.Details;
                plcControls.Visible = true;

            }
        }
        void btnSaveUpdate_Click(object sender, EventArgs e)
        {

            XslTemplate Xsl = new XslTemplate();
            if (ObjectID <= 0)
            {
                try
                {
                    Xsl.IsDeleted = false;
                    Xsl.Name = txtName.Text;
                    using (StringReader xslStringReader = new StringReader(txtDetails.Content))
                    {
                        //pass xsl text into xmltextreader
                        using (XmlReader styleSheet = new XmlTextReader(xslStringReader))
                        {
                            //create the transformation class
                            XslCompiledTransform xslTrans = new XslCompiledTransform();
                            //load the xsl into the transformer
                            xslTrans.Load(styleSheet);
                            //create a stringwriter for outputting html to



                        }
                    }
                    Xsl.Details = (txtDetails.Content);
                    Xsl.Hash = txtHash.Text;
                    Xsl.CategoryID = -1;
                    XslTemplateManager.Add(Xsl);
                    AddMode();
                }
                catch (Exception ex)
                {
                    dvProblems.Style.Clear();
                    dvProblems.InnerText = ex.ToString();
                }

            }
            else
            {
                try
                {
                    Xsl = XslTemplateManager.GetByID(ObjectID);
                    if (null == Xsl)
                    {
                        dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures);
                        return;
                    }
                    Xsl.IsDeleted = false;
                    Xsl.Name = txtName.Text;
                    using (StringReader xslStringReader = new StringReader(txtDetails.Content))
                    {
                        //pass xsl text into xmltextreader
                        using (XmlReader styleSheet = new XmlTextReader(xslStringReader))
                        {
                            //create the transformation class
                            XslCompiledTransform xslTrans = new XslCompiledTransform();
                            //load the xsl into the transformer
                            xslTrans.Load(styleSheet);
                        }
                    }
                    Xsl.Details = (txtDetails.Content);
                    Xsl.Hash = txtHash.Text;
                    Xsl.CategoryID = -1;
                    XslTemplateManager.Update(Xsl);
                    EditMode();
                }
                catch (Exception ex)
                {
                    dvProblems.Style.Clear();
                    dvProblems.InnerText = ex.ToString();
                }
            }
            BindGrid();
        }