예제 #1
0
        public void Save(DataObject loadedDataObject)
        {
            ObjectStatus objectStatus;
            bool         managed          = false;
            string       selectedRoles    = null;
            FriendType   friendVisibility = 0;

            if (objectViewHandler != null)
            {
                friendVisibility = objectViewHandler.GetFriendType();
                objectStatus     = objectViewHandler.GetObjectStatus();
                selectedRoles    = objectViewHandler.GetRoles();
                managed          = objectViewHandler.IsManaged();
            }
            else
            {
                objectStatus     = loadedDataObject.Status;
                friendVisibility = loadedDataObject.FriendVisibility;
            }

            ObjectShowState objectShowState = ObjectShowState.Published;

            if (loadedDataObject == null || (loadedDataObject.ObjectType != Helper.GetObjectTypeNumericID("ProfileCommunity") && loadedDataObject.ObjectType != Helper.GetObjectTypeNumericID("Page") && loadedDataObject.ObjectType != Helper.GetObjectTypeNumericID("Community")))
            {
                objectShowState = managed ? ObjectShowState.Draft : ObjectShowState.Published;
            }

            string tagWords;

            if (objectTagHandler != null)
            {
                tagWords = objectTagHandler.GetTags();
            }
            else
            {
                tagWords = loadedDataObject.TagList;
            }

            loadedDataObject.TagList          = tagWords;
            loadedDataObject.Status           = objectStatus;
            loadedDataObject.ShowState        = objectShowState;
            loadedDataObject.FriendVisibility = friendVisibility;
            loadedDataObject.Copyright        = int.Parse(this.Copyright.SelectedValue);
            if (!string.IsNullOrEmpty(selectedRoles))
            {
                var roles = loadedDataObject.RoleRight.Keys.ToArray <string>();
                foreach (string role in roles)
                {
                    loadedDataObject.RoleRight[role] = false;
                }
                string[] selRoles = selectedRoles.Split(Constants.TAG_DELIMITER);
                for (int i = 0; i < selRoles.Length; i++)
                {
                    loadedDataObject.RoleRight[selRoles[i]] = true;
                }
            }
            double geoLat;

            if (double.TryParse(this.TxtGeoLat.Text, out geoLat))
            {
                loadedDataObject.Geo_Lat = geoLat;
            }
            double geoLong;

            if (double.TryParse(this.TxtGeoLong.Text, out geoLong))
            {
                loadedDataObject.Geo_Long = geoLong;
            }
            loadedDataObject.Zip         = this.HFZip.Value.StripForScript();
            loadedDataObject.City        = this.HFCity.Value.StripForScript();
            loadedDataObject.Street      = this.HFStreet.Value.StripForScript();
            loadedDataObject.CountryCode = this.HFCountry.Value.StripForScript();
        }