Ejemplo n.º 1
0
 public static void FolderType(string name, string folderType)
 {
     using (ShellLibrary library = ShellLibrary.Load(ShellLibrary.CreateLibraryFullName(name), true))
     {
         if (string.IsNullOrEmpty(folderType))
         {
             Guid   folderTypeId   = library.FolderTypeId;
             string folderTypeName = folderTypeId.ToString();
             try
             {
                 folderTypeName = FolderTypes.GetFolderType(folderTypeId);
             }
             catch
             {
             }
             Console.WriteLine("Folder type: {0}", folderTypeName);
         }
         else
         {
             Guid folderTypeId;
             try
             {
                 folderTypeId = FolderTypes.GetFolderType(folderType);
             }
             catch
             {
                 folderTypeId = new Guid(folderType);
             }
             library.FolderTypeId = folderTypeId;
         }
     }
 }
Ejemplo n.º 2
0
        private static void ShowInformation(ShellLibrary library)
        {
            Console.WriteLine("\nShowing information of {0} library", library.Name);
            Console.WriteLine("\tLibrary path: {0}", library.FullName);
            Console.WriteLine("\tIs pinned to navigation pane: {0}", library.IsPinnedToNavigationPane);
            string saveFolder = library.DefaultSaveFolder;

            Console.WriteLine("\tSave folder: {0}", saveFolder);
            Console.WriteLine("\tIcon: {0}", library.Icon);
            Guid   folderTypeId   = library.FolderTypeId;
            string folderTypeName = folderTypeId.ToString();

            try
            {
                folderTypeName = FolderTypes.GetFolderType(folderTypeId);
            }
            catch
            {
            }
            Console.WriteLine("\tFolder type: {0}", folderTypeName);

            Console.WriteLine("\tFolder list:");
            foreach (string folder in library.GetFolders())
            {
                Console.WriteLine("\t\t{0} {1}", folder, saveFolder == folder ? "*" : "");
            }
        }
Ejemplo n.º 3
0
        private static void InitApp()
        {
            DependencyResolver.GetInstance <ILogger>().ConsoleAndLog("Initializing application....");
            PurgeFolder = new FolderObject(Default.PurgeFolder, true, false, false);

            // DELETE ALL SUBFOLDERS THATS NOT SUPPOSE TO BE THEIR
            PurgeFolder.Subfolders
            .Where(sf => !FolderTypes.Select(f => f.ToString()).Contains(sf.FolderNameOnly)).ToList()
            .ForEach(delegate(FolderObject o)
            {
                o.DeleteFolder();
                DependencyResolver.GetInstance <ILogger>().ConsoleAndLog($"Deleting Folder {o.FullFolderPath} because it doesn't belong in this directory");
            });


            foreach (var type in FolderTypes)
            {
                if (PurgeFolder.Subfolders.Where(subfolder => subfolder.FolderNameOnly == type.ToString()).IsNullOrEmpty())
                {
                    using (var newFolder = new FolderObject(PurgeFolder.FullFolderPath + type + Path.DirectorySeparatorChar))
                    {
                        DependencyResolver.GetInstance <ILogger>().ConsoleAndLog($"Creating Folder {newFolder.FullFolderPath}");
                        newFolder.Create();
                    }
                }
            }

            PurgeFolder.RefreshObject(true, false, false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Make the library manager state coherent with the underline shell library
        /// </summary>
        /// <param name="shellLibrary">The shell library path</param>
        private void UpdateLibraryState(ShellLibrary shellLibrary)
        {
            try
            {
                //break update loop
                _isIgnoreEvent = true;

                FolderList.Clear();
                foreach (string folder in shellLibrary.GetFolders())
                {
                    FolderList.Add(folder);
                }
                DefaultSaveFolder        = shellLibrary.DefaultSaveFolder;
                IsPinnedToNavigationPane = shellLibrary.IsPinnedToNavigationPane;

                string iconPath = shellLibrary.Icon;
                ShellIcon = string.IsNullOrEmpty(iconPath) ? null : Helper.GetIconBitmap(iconPath);

                string folderType;
                try
                {
                    folderType = FolderTypes.GetFolderType(shellLibrary.FolderTypeId);
                }
                catch
                {
                    folderType = "";
                }
                FolderType = folderType;
            }
            finally
            {
                _isIgnoreEvent = false;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns the message count for a specific folder type (inbox, sent, deleted)
        /// </summary>
        /// <param name="pFolder">
        /// Mailbox folder to fetch count for
        /// </param>
        /// <param name="pCount">
        /// Message count for the folder type
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class with details of the fetch and results from the server
        /// </returns>
        public WebCallResult GetFolderCount(FolderTypes pFolder, out int pCount)
        {
            pCount = 0;
            string strUrl = string.Format("{0}mailbox/folders/{1}?userobjectid={2}", HomeServer.BaseUrl, pFolder.ToString(), UserObjectId);

            //issue the command to the CUPI interface
            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false)
            {
                return res;
            }

            Folder oFolder= HomeServer.GetObjectFromJson<Folder>(res.ResponseText, "Folder");

            if (oFolder==null)
            {
                res.ErrorText = "Failure parsing JSON response into MailboxInfo class:" + res.ResponseText;
                res.Success = false;
                return res;
            }

            pCount = oFolder.MessageCount;
            return res;
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            RegisterDependencies();
            InitApp();

            DependencyResolver.GetInstance <ILogger>().ConsoleAndLog("Checking for any file(s) & folder(s) to purge");

            FolderTypes.Where(f => f != PurgeFolders.ManualPurge).ToList().ForEach(delegate(PurgeFolders folderType)
            {
                var folder = PurgeFolder.Subfolders.First(subfolder => subfolder.FolderNameOnly == folderType.ToString());

                // Grab all files
                folder.RefreshObject(false, true, true);
                folder.Files.ForEach(delegate(FileObject o)
                {
                    var result = ExpirationLookup.TryGetValue(folderType, out var value);
                    if (o.CreationTimeUtc < DateTimeOffset.UtcNow.Subtract(value))
                    {
                        try
                        {
                            PurgeFileCount++;
                            DiskSpaceRecovered += o.GetFileSize(FileObject.SizeUnits.Byte).GetValueOrDefault(0);
                            o.DeleteFile(true);
                        }
                        catch (Exception error)
                        {
                            DependencyResolver.GetInstance <ILogger>().LogError(error);
                            DependencyResolver.GetInstance <ILogger>().ConsoleAndLog($"Couldn't Delete File {o.FullFilePath}");
                            PurgeFileCount--;
                            DiskSpaceRecovered -= o.GetFileSize(FileObject.SizeUnits.Byte).GetValueOrDefault(0);
                            PurgeFileErrorCount++;
                        }
                    }
                    else // DO NOTHING
                    {
                    }
                });
            });


            DependencyResolver.GetInstance <ILogger>().ConsoleAndLog($"Performance Results :");
            DependencyResolver.GetInstance <ILogger>().ConsoleAndLog($"Disk Space Recovered : {DiskSpaceRecovered} Bytes");
            DependencyResolver.GetInstance <ILogger>().ConsoleAndLog($"Files Deleted : {PurgeFileCount}");
            DependencyResolver.GetInstance <ILogger>().ConsoleAndLog($"Files not deleted due to errors : {PurgeFileErrorCount}");



            // DependencyResolver.GetInstance<IEmailSender>().SendToRecipients(new List<string>() { "*****@*****.**" }, new List<string>() { }, "Test", "Joseph Testing", true);


            CloseApp();
        }
        private void FillFolderTypes(XmlDocument configDocument)
        {
            var folderTypesNode = configDocument.SelectSingleNode(ConfigNode + "/folderTypes");

            if (folderTypesNode == null)
            {
                return;
            }
            FolderTypes.Clear();
            foreach (XmlNode folderTypeNode in folderTypesNode)
            {
                FolderTypes.Add(GetFolderMappingFromConfigNode(folderTypeNode));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Set the folder type template
        /// </summary>
        /// <param name="typeName">The folder type name</param>
        private void SetFolderType(string typeName)
        {
            Guid folderType = FolderTypes.GetFolderType(typeName);

            if (_isIgnoreEvent || folderType == Guid.Empty)
            {
                return;
            }

            using (ShellLibrary shellLibrary = ShellLibrary.Load(LibraryName, true))
            {
                shellLibrary.FolderTypeId = folderType;
            }
        }
Ejemplo n.º 9
0
 /// <inheritdoc/>
 public override bool IsFlowApplicable(FolderTypes folderType, string fullPath)
 {
     return(folderType == FolderTypes.CanBeAnApplication);
 }
Ejemplo n.º 10
0
        public static MailFolder GetFolder(Core core, FolderTypes folder, MessageRecipient user)
        {
            SelectQuery query = MailFolder.GetSelectQueryStub(core, typeof(MailFolder));
            query.AddCondition("folder_type", (byte)folder);
            query.AddCondition("owner_id", user.UserId);

            System.Data.Common.DbDataReader inboxReader = core.Db.ReaderQuery(query);

            if (inboxReader.HasRows)
            {
                inboxReader.Read();

                MailFolder newFolder = new MailFolder(core, inboxReader);

                inboxReader.Close();
                inboxReader.Dispose();

                return newFolder;
            }
            else
            {
                inboxReader.Close();
                inboxReader.Dispose();

                throw new InvalidMailFolderException();
            }
        }
Ejemplo n.º 11
0
        public static MailFolder Create(Core core, User owner, FolderTypes type, string title)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            /* TODO: Fix */
            Item item = Item.Create(core, typeof(MailFolder), new FieldValuePair("owner_id", owner.Id),
                new FieldValuePair("folder_type", (byte)type),
                new FieldValuePair("folder_parent", 0),
                new FieldValuePair("folder_name", title));

            return (MailFolder)item;
        }
Ejemplo n.º 12
0
 public static MailFolder Create(Core core, FolderTypes type, string title)
 {
     return Create(core, core.Session.LoggedInMember, type, title);
 }
Ejemplo n.º 13
0
 public string ResourcesPath(FolderTypes type)
 {
     return(folders.Find((info) => info.type == type).folder.ResourcesPath);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Check path for possible of presented <see cref="UserAction"/>.
 /// </summary>
 /// <param name="folderType">Computed folder type.</param>
 /// <param name="fullPath">Full path to folder.</param>
 /// <returns>Is it flow applicable for source path.</returns>
 public abstract bool IsFlowApplicable(FolderTypes folderType, string fullPath);
Ejemplo n.º 15
0
 public override bool IsFlowApplicable(FolderTypes folderType, string fullPath)
 {
     return(folderType == FolderTypes.ClickOnceApplication ||
            Directory.GetFiles(fullPath, $"*.{Constants.DeployFileExtension}").Any());
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Constructor for  <see cref="HistoryHelp"/>.
 /// </summary>
 public HistoryHelp(string description, FolderTypes folderType)
 {
     Description = description;
     FolderType  = folderType;
 }