Example #1
0
 static void Main(string[] args)
 {
     Console.WriteLine(args.Length.ToString());
     if (args.Length == 1)
     {
         CheckFiles GoCheckFiles = new CheckFiles();
         GoCheckFiles.Begin(args[0].ToString());
     }
 }
 public CheckUpdate()
 {
     InitializeComponent();
     checkFiles = new CheckFiles();
     checkFiles.UpdateFaildNotify += CheckFiles_UpdateFaildNotify;
     checkScripts = new CheckScripts();
     checkScripts.UpdateFaildNotify          += CheckFiles_UpdateFaildNotify;
     checkFilesStepByStep                     = new CheckFilesStepByStep();
     checkFilesStepByStep.BackToCheckFile    += CheckFilesStepByStep_BackToCheckFile;
     checkScriptStepByStep                    = new CheckScriptStepByStep();
     checkScriptStepByStep.BackToCheckScript += CheckScriptStepByStep_BackToCheckScript;
     ContentControl.Content                   = checkFiles;
 }
Example #3
0
        private CheckFiles GetCheckFilesWihtoutOriginal(AblageInfos settings)
        {
            try
            {
                var checkfiles = new CheckFiles();

                var dir   = new DirectoryInfo(settings.PathToFile);
                var files = dir.GetFiles(settings.FileFilter);

                if (files.Length == 0)
                {
                    return(null);
                }

                var ext = new List <string> {
                    "tif", "tiff", "jpg", "jpeg"
                };

                var filesWithoutUnderline = files.Where(f => f.Name.Contains("_") == false).ToList();

                foreach (var file in filesWithoutUnderline)
                {
                    var endString = file.FullName.Substring(file.FullName.LastIndexOf('.') + 1).ToLower();
                    if (!ext.Contains(endString))
                    {
                        continue;
                    }

                    checkfiles.Original.Add(file.Name);

                    checkfiles.Images.Add(file.Name);
                }



                return(checkfiles);
            }
            catch (Exception ex)
            {
                FileLogger.FileLogger.Instance.WriteExeption(ex);

                return(null);
            }
        }
Example #4
0
        private CheckFiles GetCheckFiles(AblageInfos settings)
        {
            try
            {
                var checkfiles = new CheckFiles();

                var dir   = new DirectoryInfo(settings.PathToFile);
                var files = dir.GetFiles(settings.FileFilter);

                if (files.Length == 0)
                {
                    return(null);
                }

                var ext = new List <string> {
                    "pdf", "doc", "docx", "safe"
                };

                foreach (var file in files)
                {
                    var endString = file.FullName.Substring(file.FullName.LastIndexOf('.') + 1).ToLower();
                    if (ext.Contains(endString))
                    {
                        continue;
                    }

                    checkfiles.Images.Add(file.Name);
                }



                return(checkfiles);
            }
            catch (Exception ex)
            {
                FileLogger.FileLogger.Instance.WriteExeption(ex);

                return(null);
            }
        }
        public MainWindow()
        {
            #region TVCM Update
#if !DEBUG
            ///Run TVC to Update Express FW Loader software
            try
            {
                CheckFiles myCf = new CheckFiles();
                myCf.installFromTVCHelper("FirmwareLoad", "ExpressGangLoader", @"C:\TestFiles\FirmwareLoad\ExpressGangLoader\ExpressGangLoader.exe", 2, 1);
            }
            catch (Exception e)
            {
                string InnerErrorMessage = "";
                string ErrorMessage      = string.Concat(e.Message.ToString(), e.StackTrace.ToString());
                if (e.InnerException != null)
                {
                    InnerErrorMessage = string.Concat(e.InnerException.Message.ToString(), e.InnerException.StackTrace.ToString());
                }

                ExpressFWLoaderError.ExpressFWLoaderErrorMessenger("TVCM Update", ErrorMessage, InnerErrorMessage, "");
            }
#endif
            #endregion

            #region Admin Right
#if !DEBUG
            // Verify if ExpressGangLoader is running as admin
            //if YES -> Do nothing
            //else -> Restart
            Tools mt = new Tools();
            if (!mt.IsRunAsAdmin())
            {
                ProcessStartInfo proc = new ProcessStartInfo();
                proc.UseShellExecute  = true;
                proc.WorkingDirectory = Environment.CurrentDirectory;
                proc.FileName         = Assembly.GetEntryAssembly().CodeBase;

                proc.Verb = "runas";

                try
                {
                    Process.Start(proc);
                    Application.Current.Shutdown();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("This program must be run as an administrator! \n\n" + ex.ToString());
                }
            }
#endif
            #endregion

            InitializeComponent();

            ///Everything running Express FW loader
            ///Begin with checking all PCS, RS232, LAN commuinication
            ///Display # of available port and self-test software and hardware
            //SystemVerifyView verify = new SystemVerifyView();

            ///MainViewModel with command
            MainVM mvm = new MainVM();
            DataContext = mvm;
        }
Example #6
0
 public void CheckStreamFileExists()
 {
     var checkFiles = new CheckFiles();
 }
Example #7
0
        private static void Main(string[] args)
        {
            var uhwid = new UhwidEngine();

            //0033C6A8BFEBFBFF0004065178D78DEB08D2A6E3859728686F310C5D

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var f = new Form1();

            Logger.Hook();

            if (args.Length > 0 && args[0] != null)
            {
                if (args[0].Contains("-m") || args[0].Contains("-M") || args[0].Contains("/m") || args[0].Contains("/M"))
                {
                    f.WindowState = FormWindowState.Minimized;
                }
            }
            if (args.Length > 0 && args[1] != null)
            {
                if (args[1].Contains("-gr") || args[1].Contains("-GR") ||
                    args[1].Contains("/GR") || args[1].Contains("/GR"))
                {
                    var sr = new StreamWriter(Application.StartupPath + "\\id.txt");
                    sr.WriteLine(uhwid.AdvancedUid);
                    sr.WriteLine(AesCryp.Encrypt(uhwid.AdvancedUid));
                    sr.Flush();
                    sr.Close();
                    Process.Start("id.txt");
                }
            }

            if (AesCryp.Decrypt(File.ReadAllText(Application.StartupPath + "\\Bell.txt").Trim()) == uhwid.AdvancedUid)
            {
                //MessageBox.Show(uhwid.AdvancedUid.Length.ToString());
                try
                {
                    if (CheckFiles.Checkfolder())
                    {
                        if (CheckFiles.CheckAudioFolder())
                        {
                            if (CheckFiles.CheckMp3Folder())
                            {
                                if (CheckFiles.Checkfiles())
                                {
                                    Application.Run(f);
                                    Logger.UnHook();
                                }
                                else
                                {
                                    MessageBox.Show(@"Files not found", @"Error");
                                }
                            }
                        }
                    }
                }
                catch (IOException e)
                {
                    MessageBox.Show(e.Message, @"IOException");
                }
            }
            else
            {
                MessageBox.Show(@"invalic hwid");
                Logger.UnHook();
            }
        }
Example #8
0
        private CheckFiles GetCheckFiles(AblageInfos settings)
        {
            try
            {
                var checkfiles = new CheckFiles();

                var dir   = new DirectoryInfo(settings.PathToFile);
                var files = dir.GetFiles(settings.FileFilter);

                if (files.Length == 0)
                {
                    return(null);
                }

                var withoutSafe = files.Where(f => f.Name.ToLower().Contains(".safe") == false).ToList();


                var ext = new List <string> {
                    "pdf", "doc", "docx"
                };

                foreach (var file in withoutSafe)
                {
                    var endString = file.FullName.Substring(file.FullName.LastIndexOf('.') + 1).ToLower();
                    if (!ext.Contains(endString))
                    {
                        continue;
                    }

                    checkfiles.Original.Add(file.Name);


                    var fileBeginnWith = Path.GetFileNameWithoutExtension(file.Name);
                    var expre1         = $@"{fileBeginnWith}[_][0-9]{{4,}}.tif";
                    var expre2         = $@"{fileBeginnWith}[_][0-9]{{4,}}.jpg";

                    var rx1 = new Regex(expre1, RegexOptions.IgnoreCase);
                    var rx2 = new Regex(expre2, RegexOptions.IgnoreCase);
                    foreach (var info in withoutSafe)
                    {
                        if (rx1.IsMatch(info.Name))
                        {
                            checkfiles.Images.Add(info.Name);
                        }
                        else if (rx2.IsMatch(info.Name))
                        {
                            checkfiles.Images.Add(info.Name);
                        }
                    }
                }



                return(checkfiles);
            }
            catch (Exception ex)
            {
                FileLogger.FileLogger.Instance.WriteExeption(ex);

                return(null);
            }
        }
        public List <String> uploadFile()
        {
            HttpFileCollection files    = HttpContext.Current.Request.Files;
            List <String>      filelist = new List <string>();

            foreach (string key in files.AllKeys)
            {
                HttpPostedFile file = files[key];
                if (string.IsNullOrEmpty(file.FileName) == false)
                {
                    // check file name here
                    byte[]     info  = new byte[1024];
                    CheckFiles check = new CheckFiles();

                    if (check.checkName(file.FileName) != "OK")
                    {
                        filelist.Add("File \'" + file.FileName + "\' name is not valid");
                        continue;
                    }
                    //  get the file parameter here
                    var    request = HttpContext.Current.Request;
                    string type    = "";
                    try
                    {
                        type = request.Params["type"];
                    }
                    catch (Exception e)
                    {
                        type = check.getFileType(file.FileName).ToString();
                    }


                    var      permission = request.Params["permission"];
                    DateTime time       = DateTime.Now;
                    // change the file to the byte array
                    byte[] data = null;
                    using (var binaryReader = new BinaryReader(file.InputStream))
                    {
                        data = binaryReader.ReadBytes((int)file.InputStream.Length);
                    }

                    //read the user id from the session
                    var userId = HttpContext.Current.Session["id"];
                    // add a filter to block the unlogin user
                    // here is for test
                    //if (userId == null)
                    //{
                    //    userId = 2;
                    //}
                    String fileName      = file.FileName;
                    String storeFilename = fileName;

                    fileName = userId.ToString() + "_" + fileName;
                    // check whether the file name already exist, if yes, replace a name automatically
                    if (isFileNameExisted(fileName))
                    {
                        // TODO: call a function and get a new name here
                        fileName      = fileName + "_" + 1.ToString();
                        storeFilename = storeFilename + "_" + 1.ToString();
                    }

                    // call the upload function here and get the return url
                    UploadFile fileManager = new UploadFile();
                    String     url         = fileManager.uploadByteFile(data, fileName);
                    if (url == "upload failed")
                    {
                        filelist.Add("File \'" + file.FileName + "\' upload fail");
                        continue;
                    }


                    file newFile = new file()
                    {
                        name           = storeFilename,
                        user_id        = (int)userId,
                        url            = url,
                        time           = time,
                        download_times = 0,
                        cost           = 0,
                        permission     = Convert.ToInt32(permission),
                        status         = 1,
                        type           = Convert.ToInt32(type),
                        size           = data.Length / 1024
                    };

                    // TODOļ¼š call the function to finished
                    Task task = StoreFileToDB(newFile);
                    task.Wait();
                    addUpFileNumbs((int)userId);
                    filelist.Add("File \'" + file.FileName + "\' upload success");
                }
            }
            var len = filelist.Count;

            if (len < 1)
            {
                filelist.Add(" ");
            }
            return(filelist);
        }