Example #1
0
 public SearchFilesRequest(SearchFileType type, bool isPageModel, string order, string direction)
 {
     this.SearchType        = type;
     this.IsPageModel       = isPageModel;
     this.OrderByDirection  = direction;
     this.OrderByExpression = order;
 }
Example #2
0
    SearchFile(SearchFileType type, string szInputPath)
    {
        List <string>
        aryReturn = new List <string>();

        SearchFileType[] aryMask = new SearchFileType[] {
            SearchFileType.png,
            SearchFileType.prefab,
            SearchFileType.unity,
            SearchFileType.fbx,
            SearchFileType.mat,
            SearchFileType.jpg,
            SearchFileType.tag,
            SearchFileType.xml,
            SearchFileType.bytes,
            SearchFileType.pass,
            SearchFileType.unity3d,
            SearchFileType.zip,
            SearchFileType.cs,
            SearchFileType.dds,
            SearchFileType.DDS,
            SearchFileType.asset,
            SearchFileType.controller,
            SearchFileType.preview,
        };

        foreach (SearchFileType mask in aryMask)
        {
            if ((type & mask) != 0)
            {
                // Priority search prefab file
                string pattern = string.Format(
                    "{0}.{1}", "*", mask.ToString().ToLower()
                    );

                string[] aryFile = System.IO.Directory.GetFiles(szInputPath, pattern, SearchOption.AllDirectories);
                foreach (string path in aryFile)
                {
                    string szPath = path.Substring(Application.dataPath.Length - 6);
                    aryReturn.Add(
                        szPath.Replace("\\", "/")
                        );
                }
            }
        }

        return(aryReturn);
    }
Example #3
0
		SearchFile(SearchFileType type, string szInputPath)
	{
		List<string> 
			aryReturn = new List<string>();

		SearchFileType[] aryMask = new SearchFileType[]{
			SearchFileType.png,
			SearchFileType.prefab,
			SearchFileType.unity,
			SearchFileType.fbx,
			SearchFileType.mat,
			SearchFileType.jpg,
			SearchFileType.tag,
			SearchFileType.xml,
			SearchFileType.bytes,
			SearchFileType.pass,
			SearchFileType.unity3d,
			SearchFileType.zip,
			SearchFileType.cs,
			SearchFileType.dds,
			SearchFileType.DDS,
			SearchFileType.asset,
			SearchFileType.controller,
			SearchFileType.preview,
		};

		foreach(SearchFileType mask in aryMask)
		{
			if ((type & mask) != 0)
			{
				// Priority search prefab file
				string pattern = string.Format(
					"{0}.{1}", "*", mask.ToString().ToLower()
					);

				string[] aryFile = System.IO.Directory.GetFiles(szInputPath, pattern, SearchOption.AllDirectories);
				foreach(string path in aryFile)
				{
					string szPath = path.Substring(Application.dataPath.Length - 6);
					aryReturn.Add(
						szPath.Replace("\\", "/")
						);
				}
			}
		}

		return aryReturn;
	}
Example #4
0
    /// <summary>
    /// Builds the asset bundles.
    /// </summary>
    /// <param name="szPackageName">Size package name.</param>
    /// <param name="outZipFile">If set to <c>true</c> out zip file.</param>
    /// <param name="cleaup">If set to <c>true</c> cleaup.</param>
    /// <param name="szDirectory">Size directory.</param>
    /// <param name="szPattern">Size pattern.</param>
    public static bool      BuildAssetBundles(string szInputPath, SearchFileType type)
    {
        if (string.IsNullOrEmpty(szInputPath))
        {
            throw new System.NullReferenceException();
        }

        // create mid path
        if (!Directory.Exists(MidPath))
        {
            Directory.CreateDirectory(MidPath);
        }

        // Search all files
        List <string> aryFile = SearchFile(type, szInputPath);

        if (aryFile.Count <= 0)
        {
            return(false);
        }

        // get directory name
        string[] arySplit = szInputPath.Split('/');
        if (arySplit.Length <= 0)
        {
            return(false);
        }

        AssetBundleBuild ab = new AssetBundleBuild();

        ab.assetNames         = aryFile.ToArray();
        ab.assetBundleVariant = SearchFileType.unity3d.ToString();
        ab.assetBundleName    = arySplit[arySplit.Length - 1];

        // get the assetbundl file path
        string szOutPath = MidPath.Substring(
            Application.dataPath.Length - 6, MidPath.Length - Application.dataPath.Length + 6
            );

        BuildPipeline.BuildAssetBundles(szOutPath, new AssetBundleBuild[] { ab },
                                        BuildAssetBundleOptions.UncompressedAssetBundle, EditorUserBuildSettings.activeBuildTarget);

        return(true);
    }
Example #5
0
        private async void PerformSearch()
        {
            SetStatus("Searching...");

            Program.Log.InfoFormat(
                "Searching with the following filters: Name: {0}, Sort: {1}, Type: {2}, Size : {3}, Last Modified : {4} to {5}",
                TextboxSearchName.Text,
                SearchSortBy.ToString(),
                SearchFileType.ToArray(),
                NumericSearchGreaterThan.Value,
                DateTimeMinMTime.Value,
                DateTimeMaxMTime.Value);

            EnableSearchControls(false);
            DataGridFiles.Rows.Clear();
            var timer = new Stopwatch();

            timer.Start();

            foreach (FileItem file in
                     from DataItem bookmark in
                     await DataCache.SearchRecords(
                         TextboxSearchName.Text,
                         SearchFileType,
                         StringExtensions.ParseFileSize($"{NumericSearchGreaterThan.Value} {SearchSizePrefix}"),
                         DateTimeMinMTime.Value,
                         DateTimeMaxMTime.Value)
                     let file = FileExtensions.DataItemToFile(bookmark)
                                select file)
            {
                _ = DataGridFiles.Rows.Add(file.Name,
                                           StringExtensions.BytesToPrefix(file.Size),
                                           file.Mtime.ToLocalTime(),
                                           file.Url);
            }

            timer.Stop();
            SetStatus(message: $"{StringExtensions.FormatNumber(DataGridFiles.Rows.Count)} Results ({timer.Elapsed.TotalSeconds:0.000} seconds)");
            timer.Reset();
            EnableSearchControls(true);
        }
Example #6
0
	/// <summary>
	/// Creates the zip file.
	/// </summary>
	/// <returns><c>true</c>, if zip file was created, <c>false</c> otherwise.</returns>
	/// <param name="szInputPath">Size input path.</param>
	/// <param name="szOutPath">Size out path.</param>
	public static void	CreateZipFile(string szInputDirectory, string szOutPath, string pat, SearchFileType type)
	{
		if (File.Exists(szOutPath))
			File.Delete(szOutPath);
		
		szInputDirectory 	= szInputDirectory.Replace('\\', '/');
		int iStart 			= szInputDirectory.LastIndexOf('/');
		
		FileStream zipFileStream = File.Open(szOutPath, FileMode.OpenOrCreate);
		if (zipFileStream.CanWrite)
		{
			using(ZipOutputStream stream = new ZipOutputStream(zipFileStream))
			{
				// 0 - store only to 9 - means best compression
				stream.SetLevel(9);
				
				string[] aryFilePath = Directory.GetFiles(szInputDirectory,
				                                          string.Format("{0}.{1}", pat, type.ToString()), SearchOption.AllDirectories);
				for(int i=0; i<aryFilePath.Length; i++)
				{
					if (!Filter(aryFilePath[i]))
					{
						string path 			= aryFilePath[i].Replace('\\', '/');
						string zipEntryName 	= path.Substring(iStart + 1, path.Length - iStart - 1);
						
						ZipEntry entry = new ZipEntry(zipEntryName);
						stream.PutNextEntry(entry);
						
						EditorUtility.DisplayCancelableProgressBar(zipEntryName, zipEntryName,
						                                          (float) i / (float)(aryFilePath.Length - 1));
						
						using(FileStream fs = File.OpenRead(path))
						{
							byte[] byData = new byte[fs.Length];
							
							int nReadLength = fs.Read(byData, 0, byData.Length);
							if (nReadLength == fs.Length)
							{
								stream.Write(byData, 0, byData.Length);
							}
							
							fs.Close();
						}
						

					}
				}
				stream.Close();
			}
			
			zipFileStream.Close();
		}

		EditorUtility.ClearProgressBar();
	}
Example #7
0
	/// <summary>
	/// Builds the asset bundles.
	/// </summary>
	/// <param name="szPackageName">Size package name.</param>
	/// <param name="outZipFile">If set to <c>true</c> out zip file.</param>
	/// <param name="cleaup">If set to <c>true</c> cleaup.</param>
	/// <param name="szDirectory">Size directory.</param>
	/// <param name="szPattern">Size pattern.</param>
	public static bool 	BuildAssetBundles(string szInputPath, SearchFileType type)
	{
		if (string.IsNullOrEmpty(szInputPath))
			throw new System.NullReferenceException();

		// create mid path
		if (!Directory.Exists(MidPath))
			Directory.CreateDirectory(MidPath);

		// Search all files 
		List<string> aryFile = SearchFile(type, szInputPath);
		if (aryFile.Count <= 0)
			return false;

		// get directory name 
		string[] arySplit = szInputPath.Split('/');
		if (arySplit.Length <= 0)
			return false;

		AssetBundleBuild ab 	= new AssetBundleBuild();
		ab.assetNames			= aryFile.ToArray();
		ab.assetBundleVariant	= SearchFileType.unity3d.ToString();
		ab.assetBundleName		= arySplit[arySplit.Length - 1];
	
		// get the assetbundl file path
		string szOutPath = MidPath.Substring(
			Application.dataPath.Length - 6, MidPath.Length - Application.dataPath.Length + 6
			);

		BuildPipeline.BuildAssetBundles(szOutPath, new AssetBundleBuild[]{ab}, 
			BuildAssetBundleOptions.UncompressedAssetBundle, EditorUserBuildSettings.activeBuildTarget);

		return true;
	}
Example #8
0
        private void BeginSearch()
        {
            SetStatus("Searching...");
            Program.Log.InfoFormat("Searching. Filters: Name: {0}, Sort: {1}, Type: {2}, Size : {3}, Last Modified : {4} to {5}", TextboxSearchName.Text, SearchSortBy.ToString(), SearchFileType.ToArray(), NumericSearchGreaterThan.Value, DatetimeSearchLastModifiedMin.Value, DatetimeSearchLastModifiedMax.Value);
            EnableSearchControls(false);
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            WorkerExtensions.RunWorkAsync(() => _dataCache.Search(SearchSortBy, TextboxSearchName.Text, SearchFileType, StringExtensions.ParseFileSize(NumericSearchGreaterThan.Value + " " + SearchSizePrefix), DatetimeSearchLastModifiedMin.Value, DatetimeSearchLastModifiedMax.Value), (data) =>
            {
                if (InvokeRequired)
                {
                    Invoke(new BeginSearchCallBack(BeginSearch), new object[] { });
                }
                else
                {
                    DataGridFiles.Rows.Clear();
                    foreach (var file in data)
                    {
                        DataGridFiles.Rows.Add(file.Name, StringExtensions.BytesToPrefix(file.Size), file.LastModified.ToLocalTime(), file.Url);
                    }
                    stopWatch.Stop();
                    SetStatus($"{StringExtensions.FormatNumber(DataGridFiles.Rows.Count)} Results ({stopWatch.Elapsed.TotalSeconds:0.000} seconds)");
                    stopWatch.Reset();
                    EnableSearchControls(true);
                }
            });
        }
Example #9
0
 private void MenuSearchSearx_Click(object sender, EventArgs e)
 {
     Process.Start(
         $"{Engines.Searx}{TextboxSearchName.Text} %2B({string.Join("|", SearchFileType.ToArray()).ToLower()}) %2Dinurl:(jsp|pl|php|html|aspx|htm|cf|shtml) intitle:index.of %2Dinurl:(listen77|mp3raid|mp3toss|mp3drug|index_of|index-of|wallywashis|downloadmana)");
 }
Example #10
0
 /// <summary>
 /// SearchParameters Constructor
 /// </summary>
 /// <param name="search_string">the term to search for</param>
 /// <param name="size_restricted">TRUE if the search is restricted to a specific size range</param>
 /// <param name="is_max_size">TRUE if the search is resricted to a max size</param>
 /// <param name="size">the size of the size restriction,only used if size_restricted is set to TRUE</param>
 /// <param name="file_type">the specific filetype to search for ,default will be ANY</param>
 /// <param name="tth">the tth to search for</param>
 /// <param name="username">the search user</param>
 public SearchParameters(string search_string, bool size_restricted, bool is_max_size, int size, SearchFileType file_type, string tth,string username)
 {
     this.mode = ConnectionMode.Passive;
     this.search_string = search_string;
     this.size_restricted = size_restricted;
     this.is_max_size = is_max_size;
     this.size = size;
     this.file_type = file_type;
     this.ip = "";
     this.port = 0;
     this.tth = tth;
     this.username = username;
 }
Example #11
0
 /// <summary>
 /// SearchParameters Constructor
 /// </summary>
 /// <param name="mode">the connection mode of the search</param>
 /// <param name="search_string">the term to search for</param>
 /// <param name="size_restricted">TRUE if the search is restricted to a specific size range</param>
 /// <param name="is_max_size">TRUE if the search is restricted to a max size</param>
 /// <param name="size">the size of the size restriction,only used if size_restricted is set to TRUE</param>
 /// <param name="file_type">the specific filetype to search for ,default will be ANY</param>
 /// <param name="tth">the tth to search for</param>
 /// <param name="ip"></param>
 /// <param name="port"></param>
 public SearchParameters(ConnectionMode mode, string search_string, bool size_restricted, bool is_max_size, int size, SearchFileType file_type,string tth, string ip, int port)
 {
     this.mode = ConnectionMode.Active;
     this.search_string = search_string;
     this.size_restricted = size_restricted;
     this.is_max_size = is_max_size;
     this.size = size;
     this.file_type = file_type;
     this.ip = ip;
     this.port = port;
     this.username = "";
     this.tth = tth;
 }
Example #12
0
        /// <summary>
        /// Search for something on this hub
        /// </summary>
        /// <param name="search_string">the term you want to search for</param>
        /// <param name="size_restricted">TRUE if you want to restrict your search to a specific size range</param>
        /// <param name="is_max_size">TRUE if you want to size restrict your search to a max size</param>
        /// <param name="size">the size you want to use in your size resstriction,only used if size_restricted is set to TRUE</param>
        /// <param name="file_type">the specific filetype to search for ,default will be ANY</param>
        public void Search(string search_string, bool size_restricted, bool is_max_size, long size, SearchFileType file_type)
        {
            //"Search Hub:[DE]Test F?F?0?1?extras"
            //string send_string = "<" + nick + "> " + message + "|";
            string parameter = "";
            if (my_connection_mode == ConnectionMode.Active)
            {
                parameter = my_ip + ":" + my_udp_port.ToString() + " ";
            }
            else if (my_connection_mode == ConnectionMode.Passive)
                {
                    parameter = "Hub:" + nick + " ";
                }
                if (size_restricted)
                    parameter += "T?";
                else parameter += "F?";
                if (is_max_size)
                    parameter += "T?";
                else parameter += "F?";

            parameter += size.ToString()+"?";
            parameter += ((int)file_type).ToString()+"?";
            parameter += search_string.Replace(' ','$');
            SendCommand("Search",parameter);
        }