Ejemplo n.º 1
0
        private void addToCommunityToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            apiUsers api = new apiUsers();

            api.GetCommunitiesCompleted += new GetCommunitiesCompletedEventHandler(api_GetCommunitiesCompleted);
            api.GetCommunitiesAsync(GetTokenFromId(), false, true);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
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);
 }