Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataObjectDocument document = (DataObjectDocument)dataObject;
            GuiLanguage        language = GuiLanguage.GetGuiLanguage("UserControls.Templates.WebUI.Base");

            // Disable tooltip managers by default -> tooltip managers without targets don't work
            this.RTTM.Visible = false;
            if (document != null)
            {
                foreach (string tooltipId in _4screen.CSB.DataAccess.Business.AdWordHelper.GetCampaignObjectIds(document.ObjectID.Value))
                {
                    this.RTTM.TargetControls.Add(tooltipId, true);
                    this.RTTM.Visible = true;
                }
            }
            string strSize = document.SizeByte < 1000 ? string.Format("{0} Bytes", document.SizeByte) : string.Format("{0:f1} KB", document.SizeByte / 1024.00);

            this.LitDownload.Text = string.Format("<a href='{0}{1}' alt={2} target='_blank'>{5} {3} ({4}) </a>", SiteConfig.MediaDomainName, document.URLDocument, document.Title, document.Title.CropString(25), strSize, language.GetString("LabelDocumentDownload"));
            this.DESCLIT.Text     = document.DescriptionLinked;
            if (!string.IsNullOrEmpty(document.Author))
            {
                this.DESCLIT.Text += string.Format("<br/>{0}: {1} ", language.GetString("LabelDocumentAuthor"), document.Author);
            }
            if (!string.IsNullOrEmpty(document.Version))
            {
                this.DESCLIT.Text += string.Format("<br/>{0}: {1} ", language.GetString("LabelDocumentVersion"), document.Version);
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid?           uploadSession   = null;
            string          tagWords        = null;
            ObjectStatus?   objectStatus    = null;
            ObjectShowState?objectShowState = null;
            FriendType?     friendType      = null;
            int?            copyright       = null;
            double          geoLat          = double.MinValue;
            double          geoLong         = double.MinValue;
            string          geoZip          = null;
            string          geoCity         = null;
            string          geoStreet       = null;
            string          geoCountry      = null;

            if (!string.IsNullOrEmpty(Request.QueryString["UploadSession"]))
            {
                uploadSession = Request.QueryString["UploadSession"].ToGuid();
            }
            if (!string.IsNullOrEmpty(Request.QueryString["TG"]))
            {
                tagWords = Server.UrlDecode(Request.QueryString["TG"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["OS"]))
            {
                objectStatus = (ObjectStatus)int.Parse(Request.QueryString["OS"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["SS"]))
            {
                objectShowState = (ObjectShowState)int.Parse(Request.QueryString["SS"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["FT"]))
            {
                friendType = (FriendType)int.Parse(Request.QueryString["FT"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["CR"]))
            {
                copyright = int.Parse(Request.QueryString["CR"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["GC"]))
            {
                string[] geoLatLong = Request.QueryString["GC"].Split(',');
                if (geoLatLong.Length == 2)
                {
                    double.TryParse(geoLatLong[0], out geoLat);
                    double.TryParse(geoLatLong[1], out geoLong);
                }
            }
            if (!string.IsNullOrEmpty(Request.QueryString["ZP"]))
            {
                geoZip = Server.UrlDecode(Request.QueryString["ZP"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["CI"]))
            {
                geoCity = Server.UrlDecode(Request.QueryString["CI"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["RE"]))
            {
                geoStreet = Server.UrlDecode(Request.QueryString["RE"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["CO"]))
            {
                geoCountry = Server.UrlDecode(Request.QueryString["CO"]);
            }

            document = DataObject.Load <DataObjectDocument>(ObjectID, null, true);

            if (document.State != ObjectState.Added) // Changing an existing object
            {
                if (tagWords != null)
                {
                    document.TagList = tagWords;
                }
                if (objectStatus.HasValue)
                {
                    document.Status = objectStatus.Value;
                }
                if (objectShowState.HasValue)
                {
                    document.ShowState = objectShowState.Value;
                }
                if (friendType.HasValue)
                {
                    document.FriendVisibility = friendType.Value;
                }
                if (copyright.HasValue)
                {
                    document.Copyright = copyright.Value;
                }
                if (uploadSession != null)
                {
                    document.GroupID = uploadSession;
                }
                if (geoLat != double.MinValue)
                {
                    document.Geo_Lat = geoLat;
                }
                if (geoLong != double.MinValue)
                {
                    document.Geo_Long = geoLong;
                }
                if (geoZip != null)
                {
                    document.Zip = geoZip;
                }
                if (geoCity != null)
                {
                    document.City = geoCity;
                }
                if (geoStreet != null)
                {
                    document.Street = geoStreet;
                }
                if (geoCountry != null)
                {
                    document.CountryCode = geoCountry;
                }

                // Don't save yet - save on SaveStep()

                FillEditForm();
            }
            else if (uploadSession.HasValue) // Creating an new object
            {
                try
                {
                    string cutFileName = FileInfo.Name.Substring(32);
                    document.Title       = cutFileName.Substring(0, cutFileName.LastIndexOf(".")).Replace("_", " ").CropString(100);
                    document.CommunityID = CommunityID;
                    if (tagWords != null)
                    {
                        document.TagList = tagWords;
                    }
                    if (objectStatus.HasValue)
                    {
                        document.Status = objectStatus.Value;
                    }
                    if (objectShowState.HasValue)
                    {
                        document.ShowState = objectShowState.Value;
                    }
                    if (friendType.HasValue)
                    {
                        document.FriendVisibility = friendType.Value;
                    }
                    if (copyright.HasValue)
                    {
                        document.Copyright = copyright.Value;
                    }
                    if (uploadSession != null)
                    {
                        document.GroupID = uploadSession;
                    }
                    if (geoLat != double.MinValue)
                    {
                        document.Geo_Lat = geoLat;
                    }
                    if (geoLong != double.MinValue)
                    {
                        document.Geo_Long = geoLong;
                    }
                    if (geoZip != null)
                    {
                        document.Zip = geoZip;
                    }
                    if (geoCity != null)
                    {
                        document.City = geoCity;
                    }
                    if (geoStreet != null)
                    {
                        document.Street = geoStreet;
                    }
                    if (geoCountry != null)
                    {
                        document.CountryCode = geoCountry;
                    }

                    string mediaFolder = string.Format(@"{0}\{1}\{2}", System.Configuration.ConfigurationManager.AppSettings["ConverterRootPathMedia"], UserProfile.Current.UserId.ToString(), Helper.GetMediaFolder(ObjectType));
                    if (!Directory.Exists(mediaFolder))
                    {
                        Directory.CreateDirectory(mediaFolder);
                    }
                    string documentFile = string.Format(@"{0}\{1}", mediaFolder, FileInfo.Name);
                    FileInfo.CopyTo(documentFile);
                    string documentUrl = documentFile.Substring(ConfigurationManager.AppSettings["ConverterRootPathMedia"].Length).Replace("\\", "/");
                    document.URLDocument = documentUrl;
                    document.SizeByte    = FileInfo.Length;

                    document.Insert(UserDataContext.GetUserDataContext());

                    FillEditForm();
                }
                catch (Exception ex)
                {
                    this.LitMsg.Text = string.Format("{0}: ", language.GetString("MessageSaveError")) + ex.Message;
                }
            }
        }