예제 #1
0
        public override void MapFromTableRow(DataRow row)
        {
            try
            {
                this.Id               = row["Id"].ToString();
                this.Name             = row["Name"].ToString();
                this.Description      = row["Description"].ToString();
                this.StartDate        = (DateTime)row["StartDate"];
                this.EndDate          = (DateTime)row["EndDate"];
                this.Published        = (bool)row["Published"];
                this.StartPublishDate = (DateTime)row["StartPublishDate"];
                this.EndPublishDate   = (DateTime)row["EndPublishDate"];
                this.Image            = row["Image"].ToString();
                this.Finished         = (bool)row["Finished"];
                this.MaxSlots         = (int)row["MaxSlots"];
                this.CurSlots         = (int)row["CurSlots"];
                this.CreatedBy        = row["CreatedBy"].ToString();
                this.Type             = (int)row["Type"];
                this.ExternalLink     = row["ExternalLink"].ToString();

                this.Title    = row["Title"].ToString();
                this.SubTitle = row["SubTitle"].ToString();
                this.Text1    = row["Text1"].ToString();
                this.Text2    = row["Text2"].ToString();
                this.Footer   = row["Footer"].ToString();
                this.HeadImg  = row["HeadImg"].ToString();
                this.Location = row["Location"].ToString();

                this.CreateDate = (DateTime)row["CreateDate"];
                this.AlterDate  = (DateTime)row["AlterDate"];
                this.Status     = row["Status"].ToString();
            }
            catch (Exception e)
            {
                //throw;
                this.isValid = false;
                this.sMsgError.Add("Error:  Event.MapFromTableRow.");
                this.sMsgError.Add(e.Message);
                return;
            }

            this.Validate();
            ImageControl oImgCtrl = new ImageControl();

            //this.Image = this.AdjustImageFile("events", this.Image);
            //this.HeadImg = this.AdjustImageFile("events", this.HeadImg);
            this.Image   = oImgCtrl.RetrieveImage("events", this.Id + "-D");
            this.HeadImg = oImgCtrl.RetrieveImage("events", this.Id + "-H");
        }
예제 #2
0
        public override void MapFromTableRow(DataRow row)
        {
            ImageControl oImgCtrl = new ImageControl();

            try
            {
                this.Id         = row["Id"].ToString();
                this.Title      = row["Title"].ToString();
                this.Text       = row["Text"].ToString();
                this.CreatedBy  = row["CreatedBy"].ToString();
                this.Category   = row["Category"].ToString();
                this.Type       = row["Type"].ToString();
                this.Image      = row["Id"].ToString();
                this.Status     = row["Status"].ToString();
                this.CreateDate = (DateTime)row["CreateDate"];
                this.AlterDate  = (DateTime)row["AlterDate"];
            }
            catch (Exception e)
            {
                //throw;
                this.isValid = false;
                this.sMsgError.Add("Error:  Event.MapFromTableRow.");
                this.sMsgError.Add(e.Message);
                return;
            }

            this.Validate();
            this.Image = oImgCtrl.RetrieveImage("classifieds", this.Image);
        }
예제 #3
0
        public override bool Update()
        {
            DateTime  dNow = DateTime.Now;
            DataTable oClassDB;
            Dictionary <string, object> infoParameters = new Dictionary <string, object>();

            Byte[]       oImageBytes;
            int          nIndex      = 0;
            string       cRegexp     = @"\/(.*)";
            string       contentType = "image/";
            Match        oMatch;
            ImageControl oImgCtrl = new ImageControl();
            ImageFile    oImage;

            if (this.ImageData != null && this.ImageData.Length > 0)
            {
                //Image upload to BLOB Azure Storage
                nIndex = this.ImageData.IndexOf(";base64,");
                if (nIndex >= 0)
                {
                    try
                    {
                        oMatch       = Regex.Match(this.ImageData.Substring(0, nIndex), cRegexp);
                        oImageBytes  = Convert.FromBase64String(this.ImageData.Substring(nIndex + 8));
                        contentType += oMatch.Value.ToString().Replace("/", "").Replace(";", "");

                        //oImgCtrl = new ImageControl();
                        //oImgCtrl.UploadImage("classifieds",this.Id, oImageBytes, contentType);

                        infoParameters.Add("cImage", this.Id);
                    }
                    catch (Exception e)
                    {
                        return(false);
                    }
                }
                else
                {
                    infoParameters.Add("cImage", "square-image.png"); //Default Image for Classifieds
                }
            }
            else
            {
                infoParameters.Add("cImage", "square-image.png"); //Default Image for Classifieds
            }

            infoParameters.Add("cId", this.Id);
            infoParameters.Add("cTitle", this.Title);
            infoParameters.Add("cText", this.Text);
            infoParameters.Add("cCreatedBy", this.CreatedBy);
            infoParameters.Add("cCategory", this.Category);
            infoParameters.Add("cType", this.Type);
            infoParameters.Add("dAlterDate", dNow);

            try
            {
                oClassDB = DBConn.ExecuteCommand("sp_Classifieds_Update", infoParameters).Tables[0];
                if (!oClassDB.HasErrors)
                {
                    if (!oClassDB.HasErrors)
                    {
                        this.AlterDate = dNow;
                        //this.Image = this.AdjustImageFile("classifieds", this.Image);
                        this.Image = oImgCtrl.RetrieveImage("classifieds", this.Image);
                        return(true);
                    }
                    else
                    {
                        this.sMsgError.Add("Error Updating Classified.");
                    }
                }
            }
            catch (Exception e)
            {
                this.sMsgError.Add("Error Updating Classified.");
                this.sMsgError.Add(e.Message);
            }
            return(false);
        }