示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            int iCount = args.Count();

            ConvertCategory    category     = ConvertCategory.ALL;
            CustomizedCategory itercategory = CustomizedCategory.CustomizedByFile;
            CommandPara        curtpara     = CommandPara.Null;

            for (int i = 0; i < iCount; i++)
            {
                switch (args[i].ToUpper().Trim())
                {
                case "--SERVICE":
                case "-S":
                    curtpara = CommandPara.Servcie;
                    break;

                case "--CUSTOMIZE":
                case "-C":
                    curtpara = CommandPara.Customize;
                    break;

                case "--HELP":
                case "-H":
                    ShowUseageTip();
                    return;

                default:
                    switch (curtpara)
                    {
                    case CommandPara.Servcie:
                        switch (args[i].ToUpper().Trim())
                        {
                        case "S":
                            itercategory = CustomizedCategory.CustomizedByService;
                            break;

                        case "F":
                            itercategory = CustomizedCategory.CustomizedByFile;
                            break;

                        default:
                            curtpara = CommandPara.VerifyFail;
                            break;
                        }
                        break;

                    case CommandPara.Customize:
                        switch (args[i].ToUpper().Trim())
                        {
                        case "A":
                            category = ConvertCategory.AuthorReplacement;
                            break;

                        case "U":
                            category = ConvertCategory.URLReplacement;
                            break;

                        case "C":
                            category = ConvertCategory.URLCorrection;
                            break;

                        case "F":
                            category = ConvertCategory.FindArticle;
                            break;

                        case "I":
                            category = ConvertCategory.IncludeParentFile;
                            break;

                        case "T":
                            category = ConvertCategory.ToolReplacement;
                            break;

                        default:
                            curtpara = CommandPara.VerifyFail;
                            break;
                        }
                        break;

                    case CommandPara.Null:
                        curtpara = CommandPara.VerifyFail;
                        break;

                    case CommandPara.VerifyFail:
                        ShowUseageTip();
                        return;
                    }
                    break;
                }
            }



            string error      = "";
            string configfile = CommonFun.GetConfigurationValue("customerfilepath", ref error);

            if (error.Length > 0)
            {
                return;
            }

            StreamReader sr = null;



            string filename      = "";
            string directory     = "";
            string customizedate = "";

            List <FileCustomize> fileList = new List <FileCustomize>();

            ArrayList arrFile = new ArrayList();

            int threadCount = 0;

            switch (itercategory)
            {
            case  CustomizedCategory.CustomizedByService:
                customizedate = DateTime.Now.ToString("MM/dd/yyyy");
                arrFile       = GetFileListByService(customizedate);
                break;

            case CustomizedCategory.CustomizedByFile:
                arrFile = GetFileListByArticles();
                break;
            }



            //Get the thread count



            ThreadPool.SetMinThreads(1000, 1000);

            threadCount = arrFile.Count;
            Thread[] newThreads = new Thread[threadCount];

            // Declare the application thread.


            string[] para = new string[] { };

            for (int i = 0; i < threadCount; i++)
            {
                para          = (string[])arrFile[i];
                filename      = para[0];
                directory     = para[1];
                customizedate = para[2];
                FileCustomize curtFile = new FileCustomize(i, filename, directory, customizedate, category);
                fileList.Add(curtFile);
                newThreads[i]      = new Thread(new ThreadStart(curtFile.ProcessFileCustomize));
                newThreads[i].Name = string.Format("{0}/{1}", directory, filename);
                newThreads[i].Start();
                Console.WriteLine(string.Format("Start the Thread[{0}] in application...", i));


                // Console.WriteLine(string.Format("Join the {0} thread in application", threadIdx));
#if DEBUG
                newThreads[i].Join();
#endif
            }

            bool allThreadOver = false;
            while (allThreadOver == false)
            {
                Thread.Sleep(20000);
                allThreadOver = true;
                for (int i = 0; i < threadCount; i++)
                {
                    if (newThreads[i].ThreadState != ThreadState.Stopped)
                    {
                        allThreadOver = false;
                        Console.WriteLine(string.Format("Checking status of the Thread[{0}] \t : \t {1} -> \t {2}", i, newThreads[i].ThreadState.ToString(), newThreads[i].Name.ToString()));
                        break;
                    }
                }
            }


            if (category == ConvertCategory.ALL || category == ConvertCategory.IncludeParentFile)
            {
                //Display the Parent of Include file in Console.
                string sPath       = string.Empty;
                string sFileName   = string.Empty;
                int    idxLastDash = 0;

                foreach (FileCustomize curtFile in fileList)
                {
                    if (curtFile.ArticleCategory == FileCategory.Includes)
                    {
                        idxLastDash = curtFile.ParentFile.LastIndexOf(@"\");
                        if (idxLastDash >= 0)
                        {
                            sPath     = curtFile.ParentFile.Substring(0, idxLastDash);
                            sFileName = curtFile.ParentFile.Substring(idxLastDash + 1);
                        }
                        else
                        {
                            sPath     = "";
                            sFileName = "";
                        }

                        Console.WriteLine(string.Format("The parent file of\t{0}\tis\t{1}\t{2}\t.", curtFile.File, sPath, sFileName));
                    }
                }


                //Save the download file for the parent of Include file in text file.
                StringBuilder sbText = new StringBuilder();

                Console.WriteLine();
                sbText.AppendLine(String.Format("**********************Check Process Result({0})**********************", ConvertCategory.IncludeParentFile.ToString()));
                //Console.WriteLine(String.Format("**********************Check Process Result({0})**********************", category.ToString()));

                foreach (FileCustomize curtFile in fileList)
                {
                    if (curtFile.ArticleCategory == FileCategory.Includes)
                    {
                        //if (!string.IsNullOrEmpty(curtFile.ParentFile))
                        //{
                        idxLastDash = curtFile.ParentFile.LastIndexOf(@"\");
                        if (idxLastDash >= 0)
                        {
                            sPath     = curtFile.ParentFile.Substring(0, idxLastDash);
                            sFileName = curtFile.ParentFile.Substring(idxLastDash + 1);
                        }
                        else
                        {
                            sPath     = "";
                            sFileName = "";
                        }
                        sbText.AppendLine(string.Format("The parent file of\t{0}\tis\t{1}\t{2}\t.", curtFile.File, sPath, sFileName));
                        //}
                    }
                }

                CommonFun.GenerateDownloadFile(category, ref sbText);
            }

            //Thread.Sleep(5000);
            Console.WriteLine("Program run finished, Press <Enter> to exit....");

            ExitWithUserConfirm();
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            int                iCount       = args.Count();
            ConvertCategory    category     = ConvertCategory.SXSUpdate;
            CustomizedCategory itercategory = CustomizedCategory.CustomizedByFile;
            CommandPara        curtpara     = CommandPara.Null;

            for (int i = 0; i < iCount; i++)
            {
                switch (args[i].ToUpper().Trim())
                {
                case "--SERVICE":
                case "-S":
                    curtpara = CommandPara.Servcie;
                    break;

                case "--CUSTOMIZE":
                case "-C":
                    curtpara = CommandPara.Customize;
                    break;

                case "--HELP":
                case "-H":
                    ShowUseageTip();
                    return;

                default:
                    switch (curtpara)
                    {
                    case CommandPara.Servcie:
                        switch (args[i].ToUpper().Trim())
                        {
                        case "S":
                            itercategory = CustomizedCategory.CustomizedByService;
                            break;

                        case "F":
                            itercategory = CustomizedCategory.CustomizedByFile;
                            break;

                        default:
                            curtpara = CommandPara.VerifyFail;
                            break;
                        }
                        break;

                    case CommandPara.Customize:
                        switch (args[i].ToUpper().Trim())
                        {
                        case "X":
                            category = ConvertCategory.SXSUpdate;
                            break;

                        default:
                            curtpara = CommandPara.VerifyFail;
                            break;
                        }
                        break;

                    case CommandPara.Null:
                        curtpara = CommandPara.VerifyFail;
                        break;

                    case CommandPara.VerifyFail:
                        ShowUseageTip();
                        return;
                    }
                    break;
                }
            }


            string error = "";

            string fileprefix = CommonFun.GetConfigurationValue("GlobalTaregetRepository", ref error);

            if (error.Length > 0)
            {
                return;
            }

            string customizedate = CommonFun.GetConfigurationValue("CustomizeDate", ref error);

            if (error.Length > 0)
            {
                return;
            }

            string filename     = "";
            string directory    = "";
            string curtFullName = "";

            ArrayList arrFile = new ArrayList();

            List <FileCustomize> fileList = new List <FileCustomize>();

            int threadCount = 0;

            switch (itercategory)
            {
            case CustomizedCategory.CustomizedByService:
                customizedate = DateTime.Now.ToString("MM/dd/yyyy");
                arrFile       = GetFileListByService(customizedate);
                break;

            case CustomizedCategory.CustomizedByFile:
                arrFile = GetFileListByArticles();
                break;
            }

            ThreadPool.SetMinThreads(1000, 1000);

            threadCount = arrFile.Count;
            Thread[] newThreads = new Thread[threadCount];

            string[] para = new string[] { };

            int iRemoveFileCount = 0;

            for (int i = 0; i < threadCount; i++)
            {
                para          = (string[])arrFile[i];
                filename      = para[0];
                directory     = para[1];
                customizedate = para[2];


                FileCustomize curtFile = new FileCustomize(i, filename, directory, customizedate, category);

                if (System.IO.File.Exists(curtFile.FullMasterPath) == true)
                {
                    fileList.Add(curtFile);
                    newThreads[i - iRemoveFileCount] = new Thread(new ThreadStart(curtFile.ProcessFileCustomize));
                    newThreads[i - iRemoveFileCount].Start();
#if DEBUG
                    newThreads[i].Join();
#endif
                }
                else
                {
                    iRemoveFileCount += 1;
                }
            }


            bool allThreadOver = false;
            while (allThreadOver == false)
            {
                Thread.Sleep(10000);
                allThreadOver = true;
                for (int i = 0; i < threadCount - iRemoveFileCount; i++)
                {
                    if (newThreads[i].ThreadState != ThreadState.Stopped)
                    {
                        allThreadOver = false;
                        Console.WriteLine(string.Format("Checking status of the Thread[{0}] : {1} ", i, newThreads[i].ThreadState.ToString()));
                        break;
                    }
                }
            }

            if (category == ConvertCategory.ALL || category == ConvertCategory.IncludeParentFile)
            {
                Console.WriteLine();
                Console.WriteLine(String.Format("**********************Check Process Result({0})**********************", ConvertCategory.IncludeParentFile.ToString()));

                foreach (FileCustomize curtFile in fileList)
                {
                    if (curtFile.ArticleCategory == FileCategory.Includes)
                    {
                        Console.WriteLine("The parent file of \t{0} \tis \t{1}", curtFile.File, curtFile.ParentFile);
                    }
                }
            }

            if (category == ConvertCategory.ALL || category == ConvertCategory.SXSUpdate)
            {
                Console.WriteLine();
                Console.WriteLine(String.Format("**********************Check Process Result({0})**********************", ConvertCategory.SXSUpdate.ToString()));

                foreach (FileCustomize curtFile in fileList)
                {
                    if (!string.IsNullOrEmpty(curtFile.WarningMessage))
                    {
                        Console.WriteLine(curtFile.Fullpath);
                        Console.WriteLine("File: \t{0} \tMessage: \t{1}", curtFile.Fullpath, curtFile.WarningMessage);
                    }
                }
            }

            Console.WriteLine("Program run finished, Press <Enter> to exit....");

            ExitWithUserConfirm();
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Check the Redirect URL Category
            int             iCount   = args.Count();
            ConvertCategory category = ConvertCategory.CheckRedirectByFile;
            ConvertProcess  process  = ConvertProcess.ShowResult;

            CommandPara curtpara = CommandPara.Null;

            for (int i = 0; i < iCount; i++)
            {
                switch (args[i].ToUpper().Trim())
                {
                case "--SERVICE":
                case "-S":
                    curtpara = CommandPara.Servcie;
                    break;

                case "--CUSTOMIZE":
                case "-C":
                    curtpara = CommandPara.Customize;
                    break;

                case "--HELP":
                case "-H":
                    ShowUseageTip();
                    return;

                default:
                    switch (curtpara)
                    {
                    case CommandPara.Servcie:
                        switch (args[i].ToUpper().Trim())
                        {
                        case "S":
                            category = ConvertCategory.CheckRedirectByService;
                            break;

                        case "F":
                            category = ConvertCategory.CheckRedirectByFile;
                            break;

                        default:
                            curtpara = CommandPara.VerifyFail;
                            break;
                        }
                        break;

                    case CommandPara.Customize:
                        switch (args[i].ToUpper().Trim())
                        {
                        case "R":
                            process = ConvertProcess.ShowResult;
                            break;

                        case "H":
                            process = ConvertProcess.ShowHistory;
                            break;

                        default:
                            curtpara = CommandPara.VerifyFail;
                            break;
                        }
                        break;

                    case CommandPara.Null:
                        curtpara = CommandPara.VerifyFail;
                        break;

                    case CommandPara.VerifyFail:
                        ShowUseageTip();
                        return;
                    }

                    if (curtpara == CommandPara.VerifyFail)
                    {
                        ShowUseageTip();
                        return;
                    }
                    break;
                }
            }



            //Get the following config file , redirect file(both global and mooncake repository)
            bool   errFlag    = false;
            string error      = "";
            string configfile = CommonFun.GetConfigurationValue("CustomerFilePath", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }

            string fileGlobal = CommonFun.GetConfigurationValue("GlobalRedirectFile", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }

            string fileMooncakeDir = CommonFun.GetConfigurationValue("MooncakeRedirectDir", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }

            string fileGlobalDir = CommonFun.GetConfigurationValue("GlobalRedirectDir", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }

            string fileMooncake = CommonFun.GetConfigurationValue("MooncakeRedirectFile", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }


            string mooncakeSite = CommonFun.GetConfigurationValue("MooncakeSite", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }


            ////Get the redirect file content(both global and mooncake repository)
            string fileGlobalContent   = string.Empty;
            string fileMooncakeContent = string.Empty;

            errFlag = CommonFun.GetFileContent(fileGlobal, ref fileGlobalContent) && CommonFun.GetFileContent(fileMooncake, ref fileMooncakeContent);
            if (errFlag == false)
            {
                return;
            }

            List <CollectRedirectFileByArticle> fileList = new List <CollectRedirectFileByArticle>();
            ArrayList arrFile = new ArrayList();

            //Get the thread count
            int threadCount = 0;


            errFlag = CommonFun.GetConfigFileRowCount(configfile, ref threadCount);

            if (errFlag == false)
            {
                return;
            }

            string customizedate = string.Empty;

            switch (category)
            {
            case ConvertCategory.CheckRedirectByService:
                customizedate = DateTime.Now.ToString("MM/dd/yyyy");
                arrFile       = GetFileListByService(customizedate);
                break;

            case ConvertCategory.CheckRedirectByFile:
                arrFile = GetFileListByArticles();
                break;
            }

            threadCount = arrFile.Count;

            Thread[] newThreads = new Thread[threadCount];



            string filename  = "";
            string directory = "";

            string[] para = new string[] { };

            for (int i = 0; i < threadCount; i++)
            {
                para = (string[])arrFile[i];

                filename      = para[0];
                directory     = para[1];
                customizedate = para[2];
                CollectRedirectFileByArticle curtFile = new CollectRedirectFileByArticle(i, filename, directory, customizedate, category, mooncakeSite, fileGlobalContent, fileMooncakeContent);
                fileList.Add(curtFile);
                newThreads[i]      = new Thread(new ThreadStart(curtFile.ProcessFileCustomize));
                newThreads[i].Name = string.Format("{0}/{1}", directory, filename);
                newThreads[i].Start();
                Console.WriteLine(string.Format("Start the Thread[{0}] in application...", i));
#if DEBUG
                newThreads[i].Join();
#endif
                // Console.WriteLine(string.Format("Join the {0} thread in application", threadIdx));
            }



            bool allThreadOver = false;
            while (allThreadOver == false)
            {
                Thread.Sleep(10000);
                allThreadOver = true;
                for (int i = 0; i < threadCount; i++)
                {
                    if (newThreads[i].ThreadState != ThreadState.Stopped)
                    {
                        allThreadOver = false;
                        Console.WriteLine(string.Format("Checking status of the Thread[{0}] : {1} ", i, newThreads[i].ThreadState.ToString()));
                        break;
                    }
                }
            }

            if (category == ConvertCategory.CheckRedirectByService || category == ConvertCategory.CheckRedirectByFile)
            {
                foreach (CollectRedirectFileByArticle curtFile in fileList)
                {
                    Console.WriteLine("------------------------");
                    Console.WriteLine(curtFile.RelativeFile);
                    Console.WriteLine("Global Redirections");
                    Console.Write(curtFile.RedirectGContent);
                    Console.WriteLine("Mooncake Redirections");
                    Console.Write(curtFile.RedirectMContent);
                }

                Console.WriteLine("************Result Start for Json**************");
                foreach (CollectRedirectFileByArticle curtFile in fileList)
                {
                    if (curtFile.RedirectGContent.Length > 0 && curtFile.RedirectMContent.Length == 0)
                    {
                        Console.Write(curtFile.RedirectGContent);
                    }
                }
                Console.WriteLine("************Result End for Json**************");

                Console.WriteLine("************Result Start for Excel**************");
                foreach (CollectRedirectFileByArticle curtFile in fileList)
                {
                    if (curtFile.RedirectGContent.Length > 0 && curtFile.RedirectMContent.Length == 0)
                    {
                        Console.Write(curtFile.RedirectExcelContent);
                    }
                }
                Console.WriteLine("************Result End for Excel**************");

                Console.WriteLine("************Delete File List Start for Excel**************");
                foreach (CollectRedirectFileByArticle curtFile in fileList)
                {
                    if (curtFile.RedirectGContent.Length == 0 && curtFile.RedirectMContent.Length == 0)
                    {
                        Console.WriteLine(curtFile.RelativeFile);
                    }
                }
                Console.WriteLine("************Delete File List End for Excel**************");
            }

            Console.WriteLine("Program run finished, Press <Enter> to exit....");

            ExitWithUserConfirm();
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Check the Redirect URL Category
            int             iCount   = args.Count();
            ConvertCategory category = ConvertCategory.CollectNewFileByService;
            ConvertProcess  process  = ConvertProcess.ShowResult;

            CommandPara curtpara = CommandPara.Null;

            for (int i = 0; i < iCount; i++)
            {
                switch (args[i].ToUpper().Trim())
                {
                case "--SERVICE":
                case "-S":
                    curtpara = CommandPara.Servcie;
                    break;

                case "--CUSTOMIZE":
                case "-C":
                    curtpara = CommandPara.Customize;
                    break;

                case "--HELP":
                case "-H":
                    ShowUseageTip();
                    return;

                default:
                    switch (curtpara)
                    {
                    case CommandPara.Servcie:
                        switch (args[i].ToUpper().Trim())
                        {
                        case "S":
                            category = ConvertCategory.CollectNewFileByService;
                            break;

                        default:
                            curtpara = CommandPara.VerifyFail;
                            break;
                        }
                        break;

                    case CommandPara.Customize:
                        switch (args[i].ToUpper().Trim())
                        {
                        case "R":
                            process = ConvertProcess.ShowResult;
                            break;

                        default:
                            curtpara = CommandPara.VerifyFail;
                            break;
                        }
                        break;

                    case CommandPara.Null:
                        curtpara = CommandPara.VerifyFail;
                        break;

                    case CommandPara.VerifyFail:
                        ShowUseageTip();
                        return;
                    }

                    if (curtpara == CommandPara.VerifyFail)
                    {
                        ShowUseageTip();
                        return;
                    }
                    break;
                }
            }



            //Get the following config file , redirect file(both global and mooncake repository)
            bool   errFlag    = false;
            string error      = "";
            string configfile = CommonFun.GetConfigurationValue("CustomerFilePath", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }

            string fileGlobal = CommonFun.GetConfigurationValue("GlobalRedirectFile", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }

            string fileMooncakeDir = CommonFun.GetConfigurationValue("MooncakeRedirectDir", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }

            string fileGlobalDir = CommonFun.GetConfigurationValue("GlobalRedirectDir", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }

            string fileMooncake = CommonFun.GetConfigurationValue("MooncakeRedirectFile", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }


            string mooncakeSite = CommonFun.GetConfigurationValue("MooncakeSite", ref error);

            if (error.Length > 0)
            {
                Console.WriteLine(error);
                ExitWithUserConfirm();
                return;
            }


            ////Get the redirect file content(both global and mooncake repository)
            string fileGlobalContent   = string.Empty;
            string fileMooncakeContent = string.Empty;


            ArrayList arrFile = new ArrayList();

            //Get the thread count
            int threadCount = 0;


            errFlag = CommonFun.GetConfigFileRowCount(configfile, ref threadCount);

            if (errFlag == false)
            {
                return;
            }

            string customizedate = string.Empty;

            switch (category)
            {
            case ConvertCategory.CollectNewFileByService:
                customizedate = DateTime.Now.ToString("MM/dd/yyyy");
                arrFile       = GetFileListByService(customizedate);
                break;
            }

            threadCount = arrFile.Count;


            string filename  = "";
            string directory = "";

            string[] para = new string[] { };

            if (category == ConvertCategory.CollectNewFileByService)
            {
                for (int i = 0; i < threadCount; i++)
                {
                    para = (string[])arrFile[i];

                    filename      = para[0];
                    directory     = para[1];
                    customizedate = para[2];

                    Console.WriteLine(directory + "/" + filename);
                }
            }

            Console.WriteLine("Program run finished, Press <Enter> to exit....");

            ExitWithUserConfirm();
        }