private string GetBasePath(FolderType folderType)
        {
            var basePath = "";

            if (HttpContext.Current != null && HttpContext.Current.Server != null)
            {
                basePath = HttpContext.Current.Server.MapPath("~\\" + folderType.ToString());
            }
            else
            {
                basePath = "C:\\bbhpro\\" + folderType.ToString();
            }

            return(basePath);
        }
        public int AddFolderIcon(FolderType type)
        {
            string text = "folder_" + type.ToString();
            int    result;

            if (this._extensionList.ContainsKey(text))
            {
                result = (int)this._extensionList[text];
            }
            else
            {
                int count = ((ImageList)this._imageLists[0]).Images.Count;
                if (this._manageBothSizes)
                {
                    ((ImageList)this._imageLists[0]).Images.Add(IconReader.GetFolderIcon(IconSize.Small, type));
                    ((ImageList)this._imageLists[1]).Images.Add(IconReader.GetFolderIcon(IconSize.Large, type));
                }
                else
                {
                    ((ImageList)this._imageLists[0]).Images.Add(IconReader.GetFolderIcon(this._iconSize, type));
                }
                this.AddExtension(text, count);
                result = count;
            }
            return(result);
        }
Exemple #3
0
 private static void AssertModel(string name, FolderType folderType, int candidates, JsonFolderModel model)
 {
     AssertJsonSuccess(model);
     Assert.AreEqual(name, model.Folder.Name);
     Assert.AreEqual(folderType.ToString(), model.Folder.Type);
     Assert.AreEqual(candidates, model.Folder.Count);
 }
 public int AddFolderIcon(FolderType type)
 {
     string text = "folder_" + type.ToString();
     int result;
     if (this._extensionList.ContainsKey(text))
     {
         result = (int)this._extensionList[text];
     }
     else
     {
         int count = ((ImageList)this._imageLists[0]).Images.Count;
         if (this._manageBothSizes)
         {
             ((ImageList)this._imageLists[0]).Images.Add(IconReader.GetFolderIcon(IconSize.Small, type));
             ((ImageList)this._imageLists[1]).Images.Add(IconReader.GetFolderIcon(IconSize.Large, type));
         }
         else
         {
             ((ImageList)this._imageLists[0]).Images.Add(IconReader.GetFolderIcon(this._iconSize, type));
         }
         this.AddExtension(text, count);
         result = count;
     }
     return result;
 }
Exemple #5
0
 private static String BaseParameters(RepositoryType type, Int32 idCommunity, long idItem = long.MinValue, long idFolder = long.MinValue, FolderType folderType = FolderType.none, OrderBy orderBy = OrderBy.none, Boolean?ascending = null, Boolean withPlaceHolders = false)
 {
     return("type=" + type.ToString() + ((idCommunity > -1) ? "&idCommunity=" + idCommunity.ToString() : "")
            + BaseParameters(false, idItem, idFolder)
            + ((folderType != FolderType.none) ? "&ftype=" + folderType.ToString() : "")
            + BaseDisplayParameters(withPlaceHolders, orderBy, ascending));
 }
        public void SaveAsType(FolderType emailFolder, int[] ids, string folderPath, string type)
        {
            var             emailFolderStr = emailFolder.ToString("f").ToUpper();
            IList <Message> messages       = ApiClient.GetListOfSomeMessages(service, emailFolderStr, ids[ids.Length - 1] + 1);

            if (messages != null && messages.Count > 0)
            {
                int j = 0;
                for (int i = 0; i < messages.Count; ++i)
                {
                    if (i == ids[j])
                    {
                        ++j;
                        var message = ApiClient.GetMessage(service, "me", messages[i].Id);
                        var email   = new ApiEmail(message);
                        var attac   = ApiClient.GetAttachments(service, message, "me", messages[i].Id, false);
                        switch (type)
                        {
                        case ".eml":
                            ApiClient.ConverteToEml(email, attac, folderPath);
                            break;

                        case ".msg":
                            ApiClient.ConverteToMsg(email, attac, folderPath);
                            break;
                        }
                    }
                }
            }
        }
        public void SaveAsType(FolderType emailFolder, int amount, string folderPath, string type)
        {
            var            emailFolderStr = emailFolder.ToString("f").ToUpper();
            List <Message> messages;

            if (amount == 0)
            {
                messages = ApiClient.GetListOfAllMessages(service, emailFolderStr);
            }
            else
            {
                var list = ApiClient.GetListOfSomeMessages(service, emailFolderStr, amount);
                messages = list.OfType <Message>().ToList();
            }
            if (messages != null && messages.Count > 0)
            {
                Parallel.ForEach(messages, (sms) =>
                {
                    var message = ApiClient.GetMessage(service, "me", sms.Id);
                    var email   = new ApiEmail(message);
                    var attac   = ApiClient.GetAttachments(service, message, "me", sms.Id, false);
                    switch (type)
                    {
                    case ".eml":
                        ApiClient.ConverteToEml(email, attac, folderPath);
                        break;

                    case ".msg":
                        ApiClient.ConverteToMsg(email, attac, folderPath);
                        break;
                    }
                });
            }
        }
        /// <summary>
        /// Adds a folder iconto the imagelist.
        /// </summary>
        /// <param name="type">The type of folder (opened/closed).</param>
        /// <returns>Index in the imagelist pointing to the icon.</returns>
        public int AddFolderIcon(FolderType type)
        {
            string key = "folder_" + type.ToString();

            if (_extensionList.ContainsKey(key))
            {
                return((int)_extensionList[key]);
            }
            else
            {
                // It's not already been added, so add it and record its position.

                int pos = ((ImageList)_imageLists[0]).Images.Count;             //store current count -- new item's index

                if (_manageBothSizes == true)
                {
                    //managing two lists, so add it to small first, then large
                    ((ImageList)_imageLists[0]).Images.Add(IconReader.GetFolderIcon(IconSize.Small, type));
                    ((ImageList)_imageLists[1]).Images.Add(IconReader.GetFolderIcon(IconSize.Large, type));
                }
                else
                {
                    //only doing one size, so use IconSize as specified in _iconSize.
                    ((ImageList)_imageLists[0]).Images.Add(IconReader.GetFolderIcon(_iconSize, type));  //add to image list
                }

                AddExtension(key, pos); // add to hash table
                return(pos);
            }
        }
Exemple #9
0
        public static string GetFolder(FolderType folderType)
        {
            switch (folderType)
            {
            case FolderType.RootFolder:
                //return folder from settings
                var settings   = new Core.ApplicationSettings().GetOrCreateApplicationSettings();
                var rootFolder = settings.ClientSettings.RootFolder;
                return(rootFolder);

            case FolderType.SettingsFolder:
                //return app data taskt folder
                return(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\taskt\\");

            case FolderType.ScriptsFolder:
                //return scripts folder
                return(System.IO.Path.Combine(GetFolder(FolderType.RootFolder), "My Scripts\\"));

            case FolderType.LogFolder:
                //return logs folder
                return(System.IO.Path.Combine(GetFolder(FolderType.RootFolder), "Logs\\"));

            case FolderType.TempFolder:
                //return temp folder
                return(System.IO.Path.GetTempPath() + "\\taskt\\");

            default:
                //enum is not implemented
                throw new NotImplementedException("FolderType " + folderType.ToString() + " Not Supported");
            }
        }
        public static string GetFolder(FolderType folderType)
        {
            switch (folderType)
            {
            case FolderType.RootFolder:
                //return root folder from settings
                var rootSettings = new ApplicationSettings().GetOrCreateApplicationSettings();
                var rootFolder   = rootSettings.ClientSettings.RootFolder;
                return(rootFolder);

            case FolderType.AttendedTasksFolder:
                //return attended tasks folder from settings
                var attendedSettings    = new ApplicationSettings().GetOrCreateApplicationSettings();
                var attentedTasksFolder = attendedSettings.ClientSettings.AttendedTasksFolder;
                return(attentedTasksFolder);

            case FolderType.SettingsFolder:
                //return app data OpenBots folder
                return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenBots Inc"));

            case FolderType.ScriptsFolder:
                //return scripts folder
                return(Path.Combine(GetFolder(FolderType.RootFolder), "My Scripts"));

            case FolderType.PublishedFolder:
                //return scripts folder
                return(Path.Combine(GetFolder(FolderType.RootFolder), "Published"));

            case FolderType.LogFolder:
                //return logs folder
                return(Path.Combine(GetFolder(FolderType.RootFolder), "Logs"));

            case FolderType.TempFolder:
                //return temp folder
                return(Path.Combine(Path.GetTempPath(), "OpenBotsStudio"));

            case FolderType.LocalAppDataPackagesFolder:
                //return local app data packages folder
                return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenBots Inc", "packages"));

            case FolderType.ProgramFilesPackagesFolder:
                //return program files packages folder
                return(Path.Combine(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent.FullName, "packages", Application.ProductVersion));

            default:
                //enum is not implemented
                throw new NotImplementedException("FolderType " + folderType.ToString() + " Not Supported");
            }
        }
        public static string GetFolder(FolderType folderType)
        {
            switch (folderType)
            {
            case FolderType.RootFolder:
                //return root folder from settings
                var rootSettings = new ApplicationSettings().GetOrCreateApplicationSettings();
                var rootFolder   = rootSettings.ClientSettings.RootFolder;
                return(rootFolder);

            case FolderType.AttendedTasksFolder:
                //return attended tasks folder from settings
                var attendedSettings    = new ApplicationSettings().GetOrCreateApplicationSettings();
                var attentedTasksFolder = attendedSettings.ClientSettings.AttendedTasksFolder;
                return(attentedTasksFolder);

            case FolderType.SettingsFolder:
                //return app data OpenBots folder
                return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "OpenBotsStudio"));

            case FolderType.ScriptsFolder:
                //return scripts folder
                return(Path.Combine(GetFolder(FolderType.RootFolder), "My Scripts"));

            case FolderType.PublishedFolder:
                //return scripts folder
                return(Path.Combine(GetFolder(FolderType.RootFolder), "Published"));

            case FolderType.LogFolder:
                //return logs folder
                return(Path.Combine(GetFolder(FolderType.RootFolder), "Logs"));

            case FolderType.TempFolder:
                //return temp folder
                return(Path.Combine(Path.GetTempPath(), "OpenBotsStudio"));

            default:
                //enum is not implemented
                throw new NotImplementedException("FolderType " + folderType.ToString() + " Not Supported");
            }
        }
        /// <summary>
        /// Gets the first folder of the specific type with the specified amount of free space
        /// </summary>
        /// <param name="folderType">The type of folder to get.</param>
        /// <param name="fileSizeMb">The size of the file to be stored, defaults to 0 Mb</param>
        /// <returns></returns>
        public FolderLibrary GetFolder(FolderType folderType, int fileSizeMb = 0)
        {
            string key = AllFoldersKey + ":" + folderType.ToString();
            List <FolderLibrary> folders;

            if (!memoryCache.TryGetValue(key, out folders))
            {
                folders = GetAll().FindAll(ii => ii.FileType == folderType);
                MemoryCacheEntryOptions cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(2)).SetAbsoluteExpiration(TimeSpan.FromMinutes(5));
                memoryCache.Set(key, folders, cacheEntryOptions);
            }
            if (folders == null || folders.Count == 0)
            {
                throw new Exception($"No folders of type {folderType} configured.");
            }
            for (int i = 0; i < folders.Count; i++)
            {
                if (folders[i].IsReady() && folders[i].GetAvailableSpace > fileSizeMb)
                {
                    return(folders[i]);
                }
            }
            throw new Exception($"No {folderType} folder with free space available.");
        }
Exemple #13
0
 public String ToString()
 {
     return("Id-" + Id + "-" + DisplayName + "-" + Type.ToString() + "-" + Path + FolderType.ToString() + "-" + Deleted.ToString());
 }
Exemple #14
0
 protected virtual string GetSubfolderPath(FolderType folderType)
 {
     return(folderType.ToString());
 }
Exemple #15
0
        public static string GetFolder(FolderType folderType, bool createFolder = true)
        {
            string folderPath;

            switch (folderType)
            {
            case FolderType.RootFolder:
                //return root folder from settings
                var rootSettings = new ApplicationSettings().GetOrCreateApplicationSettings();
                folderPath = rootSettings.ClientSettings.RootFolder2;
                break;

            case FolderType.SettingsFolder:
                //return app data OpenBots folder
                folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenBots Inc");
                break;

            case FolderType.StudioFolder:
                //return app data OpenBots.Studio folder
                folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenBots Inc", "OpenBots Studio");
                break;

            case FolderType.ScriptsFolder:
                //return scripts folder
                var scriptSettings = new ApplicationSettings().GetOrCreateApplicationSettings();
                folderPath = scriptSettings.ClientSettings.ScriptsFolder;
                break;

            case FolderType.PublishedFolder:
                //return scripts folder
                folderPath = Path.Combine(GetFolder(FolderType.RootFolder), "Published");
                break;

            case FolderType.LogFolder:
                //return logs folder
                folderPath = Path.Combine(GetFolder(FolderType.RootFolder), "Logs");
                break;

            case FolderType.TempFolder:
                //return temp folder
                folderPath = Path.Combine(Path.GetTempPath(), "OpenBots Studio");
                break;

            case FolderType.LocalAppDataPackagesFolder:
                //return local app data packages folder
                folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenBots Inc", "Packages");
                break;

            case FolderType.ProgramFilesPackagesFolder:
                //return program files packages folder
                folderPath = Path.Combine(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent.FullName, "Packages", Application.ProductVersion);
                break;

            case FolderType.ProgramFilesExtensionsFolder:
                //return program files extensions folder
                folderPath = Path.Combine(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent.FullName, "Extensions");
                break;

            case FolderType.LocalAppDataExtensionsFolder:
                //return program files packages folder
                folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenBots Inc", "OpenBots Studio", "Extensions");
                break;

            default:
                //enum is not implemented
                throw new NotImplementedException("FolderType " + folderType.ToString() + " Not Supported");
            }

            if (!Directory.Exists(folderPath) && createFolder)
            {
                Directory.CreateDirectory(folderPath);
            }

            return(folderPath);
        }
 public List <Email> GetEmails(FolderType emailFolder, int amount)
 {
     return(ShowUserMessage(service, emailFolder.ToString().ToUpper(), request, amount));
 }
 public void CalculateHash()
 {
     Loger.Log($"{FolderType.ToString()} {Folder}");
     FilesHash = FileChecker.GenerateHashFiles(Folder, OnChangeFolderAction);
 }
 public String ToString()
 {
     return("Id " + Id + " " + DisplayName + " " + Type.ToString() + "[" + Path + "] " + (Type == ItemType.Folder ? "-Ftype=" + FolderType.ToString() : ""));
 }