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);
            }
        }
 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);
 }
 private void addToCommunityToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
 {
     apiUsers api = new apiUsers();
     api.GetCommunitiesCompleted += new GetCommunitiesCompletedEventHandler(api_GetCommunitiesCompleted);
     api.GetCommunitiesAsync(GetTokenFromId(), false, true);
 }
        public static string CallUploader(byte[] file, string name, string contentType, bool isImage)
        {
            apiUsers uploadApi = new apiUsers();
            MD5CryptoServiceProvider md5Service = new MD5CryptoServiceProvider();
            string md5 = BitConverter.ToString(md5Service.ComputeHash(file)).Replace("-", "");
            string url = new apiUsers().getRealFileUrl(GetTokenFromId(), md5, contentType);
            if (!string.IsNullOrEmpty(url))
            {
                return url;
            }

            return uploadApi.UploadFile(GetTokenFromId(), file, name, "image/jpeg", !isImage);
        }
        public static string CallUploader(string filename, string name, string contentType, bool isImage)
        {
            byte[] fileBytes = File.ReadAllBytes(filename);
            MD5CryptoServiceProvider md5Service = new MD5CryptoServiceProvider();
            string md5 = BitConverter.ToString(md5Service.ComputeHash(fileBytes)).Replace("-", "");
            string url = new apiUsers().getRealFileUrl(GetTokenFromId(), md5, contentType);
            if (!string.IsNullOrEmpty(url))
            {
                return url;
            }

            CloudUploader uploader = new CloudUploader(filename, contentType);
            uploader.ShowDialog();
            return uploader.resultUrl;
        }