public static void RegenerateResourceFile(out string message)
        {
            List <Resource> listWithAllResources;
            ResourcePresentationInSearch resourcePresentationInSearch;
            string        commaSeparatedListWithKeyWords, serializedResourcePresentationInSearch, errorMessage;
            DateTime      created;
            StringBuilder sb;
            int           i;

            message = null;

            try
            {
                listWithAllResources = ResourceUtility.ReturnListWithResources(ResourcesType.All, out errorMessage);

                if (errorMessage != null)
                {
                    message = errorMessage;
                    return;
                }

                sb = new StringBuilder();

                for (i = 0; i < listWithAllResources.Count; i++)
                {
                    created = Utility.ReturnDateTimeFromString(listWithAllResources[i].Created);
                    commaSeparatedListWithKeyWords         = KeyWordUtility.ReturnCommaSeparatedListWithKeyWords(listWithAllResources[i].KeyWords);
                    resourcePresentationInSearch           = new ResourcePresentationInSearch(listWithAllResources[i].Id, listWithAllResources[i].ResourcesType, created, listWithAllResources[i].Title, commaSeparatedListWithKeyWords);
                    serializedResourcePresentationInSearch = SerializeResourcePresentationInSearch(resourcePresentationInSearch);

                    if (i > 0)
                    {
                        sb.Append(string.Format("{0}{1}", "\r\n\r\n---------- New resource ----------\r\n\r\n", serializedResourcePresentationInSearch));
                    }
                    else
                    {
                        sb.Append(serializedResourcePresentationInSearch);
                    }
                }

                Utility.CreateNewFile(_fileNameFullPathToResources, sb.ToString());

                message = string.Format("Resources.txt was successfully regenerated with {0} resources.", listWithAllResources.Count.ToString());
            }
            catch (Exception e)
            {
                message = string.Format("ERROR!! An Exception occured in method RegenerateResourceFile! e.Message:\r\n{0}", e.Message);
                return;
            }
        }
        public static void AddResource(Resource resource)
        {
            string commaSeparatedListWithKeyWords, serializedResourcePresentationInSearch;
            ResourcePresentationInSearch resourcePresentationInSearch;
            DateTime created;

            created = Utility.ReturnDateTimeFromString(resource.Created);
            commaSeparatedListWithKeyWords = KeyWordUtility.ReturnCommaSeparatedListWithKeyWords(resource.KeyWords);

            resourcePresentationInSearch           = new ResourcePresentationInSearch(resource.Id, resource.ResourcesType, created, resource.Title, commaSeparatedListWithKeyWords);
            serializedResourcePresentationInSearch = SerializeResourcePresentationInSearch(resourcePresentationInSearch);

            if (resource.Id > 1)
            {
                Utility.AppendToFile(_fileNameFullPathToResources, string.Format("{0}{1}", "\r\n\r\n---------- New resource ----------\r\n\r\n", serializedResourcePresentationInSearch));
            }
            else
            {
                Utility.AppendToFile(_fileNameFullPathToResources, serializedResourcePresentationInSearch);
            }
        }
 private static string SerializeResourcePresentationInSearch(ResourcePresentationInSearch resource)
 {
     return(string.Format("{0}\r\n\r\n----- New property -----\r\n\r\n{1}\r\n\r\n----- New property -----\r\n\r\n{2}\r\n\r\n----- New property -----\r\n\r\n{3}\r\n\r\n----- New property -----\r\n\r\n{4}", resource.Id.ToString(), resource.ResourcesType.ToString(), resource.Created.ToString("yyyy-MM-dd HH:mm:ss"), resource.Title, resource.KeyWords));
 }