Beispiel #1
0
 public static bool DeleteCommunityObject(long CommunityId, long ComponentId)
 {
     try
     {
         if (CommunityId > 0)
         {
             if (ComponentId > 0)
             {
                 CloudCommunityComponentsAPI.apiCommunityComponents api = new CloudCommunityComponentsAPI.apiCommunityComponents();
                 long?ownerId = api.Get(CloudCommunities.GetTokenFromId(), CommunityId, ComponentId, false, false).OwnerComponentId;
                 api.Delete(CloudCommunities.GetTokenFromId(), CommunityId, ComponentId);
                 SetAvoidCache(CommunityId, ownerId.HasValue ? ownerId.Value : 0);
                 return(true);
             }
             else
             {
                 CloudCommunitiesAPI.apiCommunities api = new CloudCommunitiesAPI.apiCommunities();
                 api.Delete(CloudCommunities.GetTokenFromId(), CommunityId);
                 SetAvoidCache(CommunityId, 0);
                 return(true);
             }
         }
     }
     catch (SoapException ex)
     {
         CloudCommunities.ProcessSoapException(ex);
         return(true); // failed but still tried
     }
     return(false);
 }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                byte[] imageArray = null;
                try
                {
                    imageArray = getImageByteArray();
                }
                catch (Exception)
                {
                    MessageBox.Show(Language.GetLocalizedText(-1, "Error with selected image"));
                    return;
                }
                CloudCommunitiesUsersAPI.apiUsers uApi = new CloudCommunitiesUsersAPI.apiUsers();
                string logoUrl = uApi.UploadFile(CloudCommunities.GetTokenFromId(), imageArray, txtImage.Text, "image/jpeg", false);

                apiCommunities api            = new apiCommunities();
                long           newCommunityId = api.Create(CloudCommunities.GetTokenFromId(), txtName.Text, logoUrl,
                                                           (OrderContentMethods)cmbOrder.SelectedItem, (PublicPermission)cmbAccess.SelectedItem, txtDescription.Text);
                createdCommunityId = newCommunityId;
                this.Close();
            }
            catch (SoapException ex)
            {
                CloudCommunities.ProcessSoapException(ex);
            }
        }
Beispiel #3
0
 public static void UpdateCommunityObject(object obj)
 {
     try
     {
         if (obj is Folder)
         {
             Folder folder = (Folder)obj;
             if (folder.MSRCommunityId > 0)
             {
                 if (folder.MSRComponentId > 0)
                 {
                     CloudCommunityComponentsAPI.apiCommunityComponents api = new CloudCommunityComponentsAPI.apiCommunityComponents();
                     api.Update(CloudCommunities.GetTokenFromId(), folder.MSRCommunityId, folder.MSRComponentId, folder.Name,
                                null, null, false, null, null);
                     SetAvoidCache(folder.MSRCommunityId, folder.MSRComponentId);
                 }
                 else
                 {
                     CloudCommunitiesAPI.apiCommunities api = new CloudCommunitiesAPI.apiCommunities();
                     api.Update(CloudCommunities.GetTokenFromId(), folder.MSRCommunityId, folder.Name, null, null, null);
                     SetAvoidCache(folder.MSRCommunityId, 0);
                 }
             }
         }
         else
         {
             if (obj is Place)
             {
                 Place place = (Place)obj;
                 if (place.MSRCommunityId > 0 && place.MSRComponentId > 0)
                 {
                     AddUpdObjectToCommunity(place.MSRCommunityId, place.MSRComponentId, obj, true);
                 }
             }
             else
             {
                 if (obj is Tour)
                 {
                     Tour tour = (Tour)obj;
                     if (tour.MSRCommunityId > 0 && tour.MSRComponentId > 0)
                     {
                         AddUpdObjectToCommunity(tour.MSRCommunityId, tour.MSRComponentId, obj, true);
                     }
                 }
             }
         }
     }
     catch (SoapException ex)
     {
         CloudCommunities.ProcessSoapException(ex);
     }
 }
Beispiel #4
0
        private void CloudUploader_Load(object sender, EventArgs e)
        {
            progress.Value = 0;
            bool      isImage  = contentType.IndexOf("image") == 0;
            WebClient uploader = new WebClient();
            string    param    = "ContentType=" + Uri.EscapeUriString(contentType);

            param += "&isAttachment=" + Uri.EscapeUriString((!isImage).ToString());
            param += "&LiveToken=" + CloudCommunities.GetTokenFromId(true);
            uploader.UploadProgressChanged += new UploadProgressChangedEventHandler(uploader_UploadProgressChanged);
            uploader.UploadFileCompleted   += new UploadFileCompletedEventHandler(uploader_UploadFileCompleted);
            uploader.UploadFileAsync(new Uri(Properties.Settings.Default.WWTCommunityServer + "FileUploader.aspx?" + param),
                                     filename);
        }
Beispiel #5
0
 private void AddObjectToCommunity(long _CommunityId, long?_ComponentId, object _target, int maxProgress)
 {
     try
     {
         apiUsers uploadApi = new apiUsers();
         if (_target is Folder)
         {
             Folder folder    = (Folder)_target;
             string thumbnail = string.IsNullOrEmpty(folder.Thumbnail) ?
                                CloudCommunities.CallUploader(CloudCommunities.ImageToByteArray(folder.ThumbNail), folder.Name, "image/jpeg", true) :
                                folder.Thumbnail;
             CloudCommunityComponentsAPI.apiCommunityComponents api =
                 new CloudCommunityComponentsAPI.apiCommunityComponents();
             CloudCommunityComponentsAPI.WWTCommunityComponentSt f =
                 api.Create(CloudCommunities.GetTokenFromId(), _CommunityId,
                            CloudCommunityComponentsAPI.WWTComponentTypes.WWTCollection,
                            _ComponentId, folder.Name, thumbnail, "", null);
             int childNumber = 0, progActual = progress.Value,
                 progDiff = maxProgress - progress.Value;
             foreach (object obj in folder.Children)
             {
                 int maxProgChild = (++childNumber) * progDiff / folder.Children.Length;
                 AddObjectToCommunity(f.CommunityId, f.ComponentId, obj, progActual + maxProgChild);
             }
             CloudCommunities.SetAvoidCache(_CommunityId, _ComponentId);
         }
         else
         {
             CloudCommunities.AddUpdObjectToCommunity(_CommunityId, _ComponentId, _target, false);
         }
     }
     catch (Exception e)
     {
         errorList.Add(_target.GetType().ToString() + ": " + getTargetName(_target) + " - Error: " + e.Message);
     }
     backgroundUpdater.ReportProgress(maxProgress);
 }