Beispiel #1
0
        /// <summary>
        /// 获取用户使用痕迹
        /// </summary>
        /// <param name="path"></param>
        public static Stack <string> getUserTrack(string path)
        {
            Stack <string> userIDStack = new Stack <string>();

            try {
                StreamReader trackReader = new StreamReader(path, Encoding.Default);
                string       line;
                string       userName;
                while ((line = trackReader.ReadLine()) != null)
                {
                    userName = CodeAnalysis.getValueString(line)[0];
                    if (!userIDStack.Contains(userName))
                    {
                        userIDStack.Push(userName);
                    }
                }
                trackReader.Close();
            }
            catch (Exception e)
            {
                Reporter.reportBug(e.ToString());
            }
            return(userIDStack);
        }
Beispiel #2
0
        /// <summary>
        /// 不解密导出项目
        /// </summary>
        /// <param name="itemNames"></param>
        /// <param name="keyNames"></param>
        /// <param name="destination"></param>
        public static void exportItemsWithoutDiscryption(Queue <string> itemNames, Queue <string> keyNames, string destination, Label labelFileStatus)
        {
            if (itemNames.Count != keyNames.Count)
            {
                return;
            }
            string itemName;
            string keyName;
            string fileName;

            while (itemNames.Count > 0)
            {
                itemName = itemNames.Dequeue();
                keyName  = keyNames.Dequeue();
                //调试用
                Reporter.writeLog("./log/export.log", "exportWithoutDiscryption " + itemName);
                if (keyName.Contains(FileTree.FILE_IDENTIFY_NAME))
                {
                    fileName = itemName + MyConfig.EXTEND_NAME_ENCRYP_FILE;
                    labelFileStatus.Invoke(new MethodInvoker(delegate
                    {
                        labelFileStatus.Text = "正在处理: " + Path.GetFileName(fileName);
                        labelFileStatus.SetBounds(142 - (labelFileStatus.Width / 2), labelFileStatus.Location.Y, labelFileStatus.Width, labelFileStatus.Height);
                    }
                                                             ));
                    /* 直接复制 */
                    if (File.Exists(fileName))
                    {
                        //CMDComand.discryptFile(fileName, destination + "/" + Path.GetFileNameWithoutExtension(fileName));
                        copyFile(fileName, destination + "/" + Path.GetFileName(fileName));
                    }
                    //CMDComand.discryptFile(fileName, destination + "/" + Path.GetFileName(fileName));
                }
                else if (keyName.Contains(FileTree.FOLDER_IDENTIFY_NAME))
                {
                    if (Directory.Exists(itemName))
                    {
                        /* 防止重名 */
                        string destName = destination + "/" + Path.GetFileName(itemName);
                        if (!Directory.Exists(destName))
                        {
                            Directory.CreateDirectory(destName);
                        }
                        DirectoryInfo   directoryInfo  = new DirectoryInfo(itemName);
                        DirectoryInfo[] directory_info = directoryInfo.GetDirectories();
                        FileInfo[]      fileInfo       = directoryInfo.GetFiles();
                        Queue <string>  names          = new Queue <string>();
                        Queue <string>  keys           = new Queue <string>();
                        for (int i = 0; i < fileInfo.Length; i++)
                        {
                            names.Enqueue(fileInfo[i].DirectoryName + "/" + Path.GetFileNameWithoutExtension(fileInfo[i].FullName));
                            keys.Enqueue(FileTree.FILE_IDENTIFY_NAME);
                        }
                        for (int i = 0; i < directory_info.Length; i++)
                        {
                            names.Enqueue(directory_info[i].FullName);
                            keys.Enqueue(FileTree.FOLDER_IDENTIFY_NAME);
                        }
                        /* 递归 */
                        exportItemsWithoutDiscryption(names, keys, destination + "/" + Path.GetFileName(itemName), labelFileStatus);
                    }
                }
            }
        }