Пример #1
0
        public void Enqueue(bool apply = false)
        {
            this._apply = apply;
            SEARCH search = (SEARCH)StringEnum.Parse(typeof(SEARCH), Action.search);

            switch (search)
            {
            case SEARCH.deep:
                break;

            case SEARCH.file:
                Search_File();
                break;

            case SEARCH.glob:
                Search_Glob(Action.regex);
                break;

            case SEARCH.walk_all:
                Search_Walk(true, Action.regex);
                break;

            case SEARCH.walk_files:
                Search_Walk(regex: Action.regex);
                break;
            }
        }
Пример #2
0
        public void Enqueue(bool apply = false)
        {
            SEARCH search = (SEARCH)StringEnum.Parse(typeof(SEARCH), Action.search);

            string reg_path   = Action.path;
            string reg_root   = reg_path.Substring(0, reg_path.IndexOf('\\'));
            string reg_subkey = reg_path.Substring(reg_path.IndexOf('\\') + 1, reg_path.Length - reg_root.Length - 1);
            string reg_entry  = Action.name;

            if (RegistryHelper.I.IsSubkeyExists(reg_root, reg_subkey))
            {
                // enqueue action for cleaning
                Worker.I.EnqueTTD(new Model_ThingsToDelete()
                {
                    reg_root   = reg_root,
                    reg_name   = reg_entry,
                    reg_subkey = reg_subkey,

                    FullPathName = reg_entry == null ?
                                   reg_root + "\\" + reg_subkey :
                                   reg_root + "\\" + reg_subkey + "\\" + reg_entry,

                    IsWhitelisted = false,
                    OverWrite     = false,
                    WhatKind      = THINGS_TO_DELETE.littlregistrycleaner,
                    command       = COMMANDS.littleregistry,
                    search        = search,
                });
            }
        }
Пример #3
0
        public static void AddDecryptCount(string type, Counter counter)
        {
            if (counter == null)
            {
                return;
            }

            if (PHONE.Equals(type))
            {
                Interlocked.Increment(ref counter.DecryptPhoneNum);
            }
            else if (NICK.Equals(type))
            {
                Interlocked.Increment(ref counter.DecryptNickNum);
            }
            else if (RECEIVER_NAME.Equals(type))
            {
                Interlocked.Increment(ref counter.DecryptReceiverNameNum);
            }
            else if (SIMPLE.Equals(type))
            {
                Interlocked.Increment(ref counter.DecryptSimpleNum);
            }
            else if (SEARCH.Equals(type))
            {
                Interlocked.Increment(ref counter.DecryptSearchNum);
            }
        }
Пример #4
0
        public void Enqueue(bool apply = false)
        {
            SEARCH search = (SEARCH)StringEnum.Parse(typeof(SEARCH), Action.search);

            switch (search)
            {
            case SEARCH.file:
                ProcessJSONFile(Action.regex);
                break;
            }
        }
        public void Enqueue(bool apply = false)
        {
            SEARCH search = (SEARCH)StringEnum.Parse(typeof(SEARCH), Action.search);

            switch (search)
            {
            case SEARCH.dupchecker_all:
                EnqueueCustomPath(Action.path);
                break;
            }
        }
Пример #6
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SEARCH Search = new SEARCH();
            int    p      = System.Convert.ToInt32(dataGridView1[0, e.RowIndex].Value.ToString());

            Search.ID = p;
            Search.StringConnection = StringConnection;
            this.Visible            = false;
            Search.ShowDialog();
            this.Visible = true;
        }
Пример #7
0
        public void Enqueue(bool apply = false)
        {
            SEARCH search = (SEARCH)StringEnum.Parse(typeof(SEARCH), Action.search);

            switch (search)
            {
            case SEARCH.file:
                ReadIni();
                break;
            }
        }
        public void Enqueue(bool apply = false)
        {
            this._apply = apply;

            SEARCH search = (SEARCH)StringEnum.Parse(typeof(SEARCH), Action.search);

            switch (search)
            {
            case SEARCH.file:
                EnqueueFile(Action.path);
                break;

            case SEARCH.glob:
                EnqueueFiles(Action.regex);
                break;
            }
        }
Пример #9
0
        public void Enqueue(bool apply = false)
        {
            this._apply = apply;

            if (Action.search != null)
            {
                SEARCH search = (SEARCH)StringEnum.Parse(typeof(SEARCH), Action.search);

                switch (search)
                {
                case SEARCH.winreg_delete_entries:
                    DeleteEntry(true, Action.regex);
                    break;
                }
            }
            else
            {
                DeleteEntry();
            }
        }
        public void Enqueue(bool apply = false)
        {
            this._apply = apply;

            SEARCH search = (SEARCH)StringEnum.Parse(typeof(SEARCH), Action.search);

            switch (search)
            {
            case SEARCH.clipboard_clear:
                // enqueue file for deletion
                Worker.I.EnqueTTD(new Model_ThingsToDelete()
                {
                    WhatKind     = THINGS_TO_DELETE.system,
                    command      = COMMANDS.clipboard,
                    search       = SEARCH.clipboard_clear,
                    level        = Action.parent_option.level,
                    cleaner_name = Action.parent_option.label
                });

                break;
            }
        }
Пример #11
0
        public void Enqueue(bool apply = false)
        {
            SEARCH search = (SEARCH)StringEnum.Parse(typeof(SEARCH), Action.search);

            switch (search)
            {
            case SEARCH.clamscan_file:
                EnqueueFile();
                break;

            case SEARCH.clamscan_folder:
                EnqueueFilesInFolder(false);
                break;

            case SEARCH.clamscan_folder_recurse:
                EnqueueFilesInFolder(true);
                break;

            case SEARCH.clamscan_memory:
                break;
            }
        }
Пример #12
0
        // Compile-time function for looking up a member.
        public ClassMember GetMember(string name, SEARCH searchType)
        {
            // Can use null here because we aren't doing anything with the member's type.
            MemberRef memRef = GetMemberRef(null, name, searchType);

            if (memRef.isInvalid)
            {
                return(null);
            }

            switch (memRef.memberType)
            {
            case MemberType.NORMAL:
                return(_fields.Get(memRef.ix));

            case MemberType.FUNCTION:
                return(_memberFuncs.Get(memRef.ix));

            case MemberType.STATIC:
                return(memRef.classDef._statics.Get(memRef.ix));
            }
            return(null);
        }
Пример #13
0
        public void LocationInfoCustomAttribute()
        {
            const string WEATHER_KEY  = "1368ef2d6f8a41d19a4171602191205";
            const string WEATHER_HOST = "http://api.worldweatheronline.com/premium/v1/";
            const string SEARCH       = WEATHER_HOST + "search.ashx?query={0}&format=tab&key=" + WEATHER_KEY;

            req = new HttpRequest();

            string path = SEARCH.Replace("{0}", "oporto");

            string body = req.GetBody(path);

            CsvParser <LocationInfo> location = new CsvParser <LocationInfo>('\t');

            CsvCorrespondenceAttr <LocationInfo> .MakeAttributeCorrespondence(location, typeof(LocationInfo)); // this makes the correspondence between ctorArgs, fieldArgs and paramArgs

            IEnumerable <LocationInfo> locationInfo = location
                                                      .Load(body)
                                                      .Remove(4)
                                                      .RemoveEmpties()
                                                      .Parse();

            Assert.AreEqual(6, locationInfo.Count());
        }
Пример #14
0
        private void button2_ClickAsync(object sender, EventArgs e)
        {
            //Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Влад\source\repos\WindowsFormsApp2\WindowsFormsApp2\Database2.mdf;
            try
            {
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                                   database + ";" +
                                   "port=" + port + ";" + "UID=" + uid + ";" + "PASSWORD="******";charset=utf8;";
                connection1 = new MySqlConnection(connectionString);

                try
                {
                    connection1.Open();
                    string       charsetQuerySEr = "character_set_server = utf8";
                    MySqlCommand commandSESER    = new MySqlCommand(charsetQuerySEr, connection1);

                    string       charsetQuery = "SET NAMES utf8";
                    MySqlCommand commandSET   = new MySqlCommand(charsetQuery, connection1);

                    MessageBox.Show("Соединено");
                    if (!string.IsNullOrEmpty(textBox3.Text) && !string.IsNullOrWhiteSpace(textBox3.Text) &&
                        !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrWhiteSpace(textBox2.Text))
                    {
                        string          ComandSQL = "SELECT COUNT(Qualification_ID) AS COUNT_ID  FROM Qualification WHERE Qualification.Qualification_UA ='" + textBox1.Text + "' OR Qualification.Qualification_EN='" + textBox1.Text + "'";
                        MySqlCommand    command1  = new MySqlCommand(ComandSQL, connection1);
                        MySqlDataReader reader1   = command1.ExecuteReader();
                        reader1.Read();
                        int CUoNT1 = reader1.GetInt32(0);
                        if (reader1 != null)
                        {
                            reader1.Close();
                        }
                        if (CUoNT1 == 0)
                        {
                            if (radioButton1.Checked || radioButton2.Checked)
                            {
                                MySqlCommand command = new MySqlCommand("INSERT INTO Qualification (Qualification_EN, Qualification_UA, Main_field_study_UA, Main_field_study_EN, Degree,Date)" +
                                                                        " VALUES (@Qualification_EN, @Qualification_UA,@Main_field_study_UA, @Main_field_study_EN, @Degree,@Date)", connection1);
                                command.Parameters.AddWithValue("Qualification_EN", textBox3.Text);
                                command.Parameters.AddWithValue("Qualification_UA", textBox2.Text);
                                command.Parameters.AddWithValue("Main_field_study_UA", textBox4.Text);
                                command.Parameters.AddWithValue("Main_field_study_EN", textBox5.Text);

                                if (radioButton1.Checked)
                                {
                                    command.Parameters.AddWithValue("Degree", radioButton1.Text);
                                }
                                else
                                {
                                    command.Parameters.AddWithValue("Degree", radioButton2.Text);
                                }
                                command.Parameters.AddWithValue("Date", DateTime.Now);
                                command.ExecuteNonQuery();
                                textBox2.Text        = "";
                                textBox3.Text        = "";
                                textBox4.Text        = "";
                                textBox5.Text        = "";
                                radioButton1.Checked = false;
                                radioButton2.Checked = false;


                                string          StringComand2Id = "select max(Qualification.Qualification_ID) from Qualification";
                                MySqlCommand    command2Id      = new MySqlCommand(StringComand2Id, connection1);
                                MySqlDataReader reader          = command2Id.ExecuteReader();
                                reader.Read();
                                int CUoNT = reader.GetInt32(0);
                                reader.Close();

                                if (connection1 != null && connection1.State != ConnectionState.Closed)
                                {
                                    connection1.Close();
                                }
                                SEARCH Search = new SEARCH();
                                Search.ID = CUoNT;
                                Search.StringConnection = connectionString;
                                Search.NewOrOld         = true;
                                this.Visible            = false;
                                Search.ShowDialog();
                                this.Visible = true;
                            }
                            else
                            {
                                MessageBox.Show("Оберіть ступінь!");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Спеціальність з такою назвою вже існує");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Для створення необхідно ввести назву спеціальності англійською та українською");
                    }
                }
                catch (Exception help)
                {
                    MessageBox.Show(help.Message);
                    //this.Close();
                }

                if (connection1 != null && connection1.State != ConnectionState.Closed)
                {
                    connection1.Close();
                }
            }
            catch (Exception help)
            {
                MessageBox.Show(help.Message);
            }
        }
Пример #15
0
        /// <summary>
        /// 加密之后格式。 手机号码格式:$手机号码前3位明文$base64(encrypt(phone后8位))$111$
        /// simple格式:~base64(encrypt(nick))~111~
        /// </summary>
        /// <param name="data">明文数据</param>
        /// <param name="type">加密字段类型(例如:simple\phone)</param>
        /// <param name="session">用户身份,用户级加密必填</param>
        /// <param name="version">秘钥历史版本</param>
        /// <returns></returns>
        private string Encrypt(string data, string type, string session, Nullable <Int64> version)
        {
            if (string.IsNullOrEmpty(data))
            {
                return(data);
            }
            SecretContext secretContext = secretCore.GetSecret(session, version);

            if (secretContext == null)
            {
                throw new SecretException("secretKey is null");
            }
            if (secretContext.Secret == null)
            {
                return(data);
            }

            string separator = null;

            SecurityBiz.GetSeparatorMap().TryGetValue(type, out separator);
            if (separator == null)
            {
                throw new SecretException("type error");
            }

            // 公共秘钥版本号用负数区分
            if (session == null)
            {
                SecretContext publicSecretContext = new SecretContext();
                publicSecretContext.Secret        = secretContext.Secret;
                publicSecretContext.SecretVersion = -secretContext.SecretVersion;
                secretContext = publicSecretContext;
            }

            securityCounter.AddEncryptCount(type, session);// 计数器
            bool isEncryptIndex = secretCore.IsIndexEncrypt(type, version);

            // 支持密文检索
            if (isEncryptIndex || SEARCH.Equals(type))
            {
                if (PHONE.Equals(type))
                {
                    return(SecurityBiz.EncryptPhoneIndex(data, separator, secretContext));
                }
                else
                {
                    int compressLen = secretCore.GetCompressLen();
                    int slideSize   = secretCore.GetSlideSize();
                    return(SecurityBiz.EncryptNormalIndex(data, compressLen, slideSize, separator, secretContext));
                }
            }
            else
            {
                if (PHONE.Equals(type))
                {
                    return(SecurityBiz.EncryptPhone(data, separator, secretContext));
                }
                else
                {
                    return(SecurityBiz.EncryptNormal(data, separator, secretContext));
                }
            }
        }
Пример #16
0
        // Compile-time lookup of MemberRef.
        public MemberRef GetMemberRef(ExecContext context, string name, SEARCH searchType, ref ITypeDef typeDef)
        {
            // If there is an error during compliation then we can have an uninitialized
            // class on the stack. This check prevents us from throwing an exception
            // when that happens.
            // Kind of a kludge but handling errors during compilation is pretty chaotic
            // and I don't know what I could do other than to just abort on the first error.
            if (null == _fields)
            {
                return(MemberRef.invalid);
            }

            if (SEARCH.NORMAL == searchType || SEARCH.EITHER == searchType)
            {
                if (_fields.Exists(name))
                {
                    var member = _fields.Get(name);
                    typeDef = member.typeDef;

                    // If this member is getonly and we are not in this class's context, the type becomes const.
                    if (null != context && member.isGetonly)
                    {
                        ClassDef current = context.stack.GetCurrentClassDef();
                        if (null == current || (current != this && !current.IsChildOf(this)))
                        {
                            typeDef = TypeFactory.GetConstVersion(typeDef);
                        }
                    }

                    return(new MemberRef(member.index));
                }

                if (_memberFuncs.Exists(name))
                {
                    var member = _memberFuncs.Get(name);
                    typeDef = member.typeDef;
                    return(new MemberRef(this, MemberType.FUNCTION, member.index));
                }
            }

            if (SEARCH.STATIC == searchType || SEARCH.EITHER == searchType)
            {
                ClassDef def = this;
                while (null != def)
                {
                    if (def._statics.Exists(name))
                    {
                        ClassMember member = def._statics.Get(name);
                        typeDef = member.typeDef;

                        // If this member is getonly and we are not in this class's context, the type becomes const.
                        if (null != context && member.isGetonly)
                        {
                            ClassDef current = context.stack.GetCurrentClassDef();
                            if (null == current || (current != this && !current.IsChildOf(this)))
                            {
                                typeDef = TypeFactory.GetConstVersion(typeDef);
                            }
                        }

                        return(new MemberRef(def, MemberType.STATIC, member.index));
                    }
                    def = def.parent;
                }
            }

            return(MemberRef.invalid);
        }
Пример #17
0
        public MemberRef GetMemberRef(ExecContext context, string name, SEARCH searchType)
        {
            ITypeDef typeDef = null;

            return(GetMemberRef(context, name, searchType, ref typeDef));
        }
Пример #18
0
        public void LaunchScanner(SEARCH search, string path, bool launchinbackground = false, string regex = null, bool remove = false, Action callback = null)
        {
            this.Clam.InfectedFilesCount   = 0;
            this.Clam.WindowTitle          = "Scan custom locations for viruses";
            this.Clam.EnableCleanNowButton = false;
            this.Clam.EnableCancelButton   = true;
            this.Clam.EnableCloseButton    = true;

            this.WriteConfig();

            List <string> param = new List <string>()
            {
                //"--tempdir \"{0}\"",
                //"--keep-mbox",
                //"--stdout",
                "--database=\"{1}\"",
                "--log=\"{2}\"",
                "--infected",
                "--recursive=yes"
            };

            if (IsRemove)
            {
                param.Add("--remove=yes");
            }

            // if max files are declared
            StringCollection max = Settings.Default.ClamWin_Max;

            string[] limits =
            {
                "--max-files=" + max[0],
                "--max-scansize=" + max[1],
                "--max-recursion=" + max[2],
                "--max-filesize=" + max[3]
            };

            // exclusions
            string        exclude      = string.Empty;
            List <string> list_exclude = new List <string>();

            foreach (string e in Settings.Default.ClamWin_Exclude)
            {
                list_exclude.Add(string.Format("--exclude=\"{0}\"", e));
            }
            exclude = string.Join(" ", list_exclude.ToArray());

            // add additional parameters
            if (regex != null)
            {
                param.Add("--include=\"" + regex + "\"");
            }
            param.Add(string.Join(" ", limits));

            switch (search)
            {
            case SEARCH.clamscan_file:
                param.Add("\"" + path + "\"");
                break;

            case SEARCH.clamscan_folder:
                param.Add(exclude);
                param.Add("\"" + path + "\"");
                break;

            case SEARCH.clamscan_folder_recurse:
                param.Add("--recursive");
                param.Add(exclude);
                param.Add("\"" + path + "\"");
                break;

            case SEARCH.clamscan_memory:
                this.Clam.WindowTitle = "Scan memory for viruses";
                param.Add("--memory");
                break;

            case SEARCH.clamscan_folderfile:
                string[] locs = path.Split('|');
                foreach (string loc in locs)
                {
                    param.Add("\"" + loc + "\"");
                }
                break;
            }

            string full_param = string.Join(" ", param.ToArray());

            full_param = string.Format(full_param,
                                       Environment.GetEnvironmentVariable("TEMP"),
                                       this._exec_clam_db_path,
                                       Path.Combine(Environment.GetEnvironmentVariable("TEMP"), "clamscan_temp_" + Guid.NewGuid().ToString())
                                       );

            this.log.Clear();
            UpdateProgressLog("╔═══════════════════════════════════════════════╗");
            UpdateProgressLog("║ Starting to scan files and folders for virus. ║");
            UpdateProgressLog("╚═══════════════════════════════════════════════╝");
            UpdateProgressLog("Scanning please wait..");


            if (!launchinbackground)
            {
                ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(this._exec_clam, "clamscan.exe"), full_param)
                {
                    WindowStyle            = ProcessWindowStyle.Hidden,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                };

                update_process = new Process()
                {
                    StartInfo = startInfo
                };
                update_process.OutputDataReceived += process_OutputDataReceived;
                update_process.Start();
                update_process.BeginOutputReadLine();
                update_process.WaitForExit();

                this.Clam.ShowClamWinVirusUpdateWindow = false;
            }
            else
            {
                if (!bgWorker.IsBusy)
                {
                    bgWorker.RunWorkerAsync(Path.Combine(this._exec_clam, "clamscan.exe") + "|" + full_param);
                }
                else
                {
                    MessageBox.Show("ClamAV is currently busy", "mCleaner", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }

            //bgWorker.RunWorkerAsync(full_param);
        }
Пример #19
0
        public bool DoesFieldExist(string name, SEARCH search)
        {
            var mr = GetMemberRef(null, name, search);

            return(!mr.isInvalid);
        }
Пример #20
0
        /*
         * //Excell
         * private HSSFWorkbook hssfwb;
         * private OpenFileDialog ofd;
         * private ISheet sheet0 = null;
         * private ISheet sheet1 = null;
         * private ISheet sheet2 = null;
         * private ISheet sheet3 = null;
         * private ISheet sheet4 = null;
         * private ISheet sheet5 = null*/

        private void button1_ClickAsync(object sender, EventArgs e)
        {
            try
            {
                if (!String.IsNullOrEmpty(textBox1.Text))
                {
                    string connectionString;
                    connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                                       database + ";" +
                                       "port=" + port + ";" + "UID=" + uid + ";" + "PASSWORD="******";charset=utf8;";
                    connection1 = new MySqlConnection(connectionString);
                    connection1.Open();

                    string       charsetQuerySEr = "character_set_server = utf8";
                    MySqlCommand commandSESER    = new MySqlCommand(charsetQuerySEr, connection1);

                    string       charsetQuery = "SET NAMES utf8";
                    MySqlCommand commandSET   = new MySqlCommand(charsetQuery, connection1);



                    string          ComandSQL = "SELECT COUNT(Qualification.Qualification_ID) AS COUNT_ID  FROM Qualification WHERE Qualification.Qualification_UA =CONVERT('%" + textBox1.Text + "%'USING utf8) OR Qualification.Qualification_EN =CONVERT('%" + textBox1.Text + "%'USING utf8)";
                    MySqlCommand    command   = new MySqlCommand(ComandSQL, connection1);
                    MySqlDataReader reader    = command.ExecuteReader();
                    reader.Read();
                    int CUoNT = reader.GetInt32(0);
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    if (CUoNT > 1)
                    {
                        IFnotOnes SearchIFnotOnes = new IFnotOnes();
                        //SearchIFnotOnes.ForSEARCH = textBox1.Text;
                        SearchIFnotOnes.StringConnection = connectionString;
                        SearchIFnotOnes.ShowDialog();
                    }
                    else if (CUoNT == 1)
                    {
                        string ComandSQL2 = "SELECT Qualification.Qualification_ID FROM Qualification WHERE Qualification.Qualification_UA ='" + textBox1.Text + "' OR Qualification.Qualification_EN ='" + textBox1.Text + "'";
                        command = new MySqlCommand(ComandSQL, connection1);
                        MySqlDataReader reader2 = command.ExecuteReader();

                        reader2.Read();
                        int p = reader2.GetInt32(0);

                        MessageBox.Show(reader2.GetString(0));

                        if (reader2 != null)
                        {
                            reader2.Close();
                        }
                        if (connection1 != null && connection1.State != ConnectionState.Closed)
                        {
                            connection1.Close();
                        }
                        SEARCH Search = new SEARCH();
                        Search.ID = p;
                        Search.StringConnection = connectionString;
                        Search.NewOrOld         = false;
                        this.Visible            = false;
                        Search.ShowDialog();
                        this.Visible = true;
                    }
                    else
                    {
                        string            message = "Нажаль спеціальності з назвою " + textBox1.Text + ". Бажаете переглянути всі спеціальності?";
                        string            caption = "Пошук";
                        MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                        DialogResult      result;
                        result = MessageBox.Show(message, caption, buttons);

                        if (result == System.Windows.Forms.DialogResult.Yes)
                        {
                            if (connection1 != null && connection1.State != ConnectionState.Closed)
                            {
                                connection1.Close();
                            }
                            IFnotOnes SearchIFnotOnes = new IFnotOnes();
                            SearchIFnotOnes.StringConnection = connectionString;
                            this.Visible = false;
                            SearchIFnotOnes.ShowDialog();
                            this.Visible = true;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Введіть назву");
                }
            } catch (Exception exs) { MessageBox.Show(exs.Message); this.Close(); }
        }
Пример #21
0
        private void button3_Click(object sender, EventArgs e)
        {
            //Excell
            HSSFWorkbook   hssfwb;
            OpenFileDialog ofd;
            ISheet         sheet0 = null;
            ISheet         sheet1 = null;
            ISheet         sheet2 = null;
            ISheet         sheet3 = null;
            ISheet         sheet4 = null;
            ISheet         sheet5 = null;

            System.Collections.Generic.Dictionary <int, string> filesPath = new System.Collections.Generic.Dictionary <int, string>();

            ofd        = new OpenFileDialog();
            ofd.Filter = "Excell table Microsoft Office 1998-2003 (*.xls)|*.xls";
            Stream myStream = null;

            processPb.Value = 0;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                int IdQ = 0;
                try
                {
                    DateTime localDate = DateTime.Now;

                    filesPath.Add(0, ofd.FileName); // Добавление файлового пути
                    using (FileStream file = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
                    {
                        hssfwb = new HSSFWorkbook(file);
                    }
                    bool EROR = true;
                    // Получение листов из Excell
                    sheet0            = hssfwb.GetSheetAt(0);
                    sheet1            = hssfwb.GetSheetAt(1);
                    sheet2            = hssfwb.GetSheetAt(2);
                    sheet3            = hssfwb.GetSheetAt(3);
                    sheet4            = hssfwb.GetSheetAt(4);
                    sheet5            = hssfwb.GetSheetAt(5);
                    processPb.Maximum = sheet0.LastRowNum + 5;

                    string connectionString;
                    connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                                       database + ";" +
                                       "port=" + port + ";" + "UID=" + uid + ";" + "PASSWORD="******";charset=utf8;";
                    connection1 = new MySqlConnection(connectionString);
                    connection1.Open();
                    MySqlCommand command = new MySqlCommand("INSERT INTO Qualification (Qualification_EN, Qualification_UA, Degree,Date," +
                                                            " FieldStudy_UA, FieldStudy_EN, FirstSpecialty_UA, FirstSpecialty_EN, SecondSpecialty_UA, SecondSpecialty_EN, Specialization_UA, Specialization_EN)" +
                                                            " VALUES (@Qualification_EN, @Qualification_UA,@Degree,@Date,@FieldStudy_UA, @FieldStudy_EN, @FirstSpecialty_UA, @FirstSpecialty_EN," +
                                                            " @SecondSpecialty_UA, @SecondSpecialty_EN, @Specialization_UA, @Specialization_EN)", connection1);
                    command.Parameters.AddWithValue("Qualification_EN", sheet1.GetRow(1).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Qualification_UA", sheet1.GetRow(0).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("FieldStudy_UA", sheet1.GetRow(2).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("FieldStudy_EN", sheet1.GetRow(3).GetCell(1).StringCellValue);
                    try { command.Parameters.AddWithValue("FirstSpecialty_UA", sheet1.GetRow(4).GetCell(1).StringCellValue); }
                    catch { command.Parameters.AddWithValue("FirstSpecialty_UA", ""); }
                    try { command.Parameters.AddWithValue("FirstSpecialty_EN", sheet1.GetRow(5).GetCell(1).StringCellValue); }
                    catch { command.Parameters.AddWithValue("FirstSpecialty_EN", ""); }
                    try { command.Parameters.AddWithValue("SecondSpecialty_UA", sheet1.GetRow(6).GetCell(1).StringCellValue); }
                    catch { command.Parameters.AddWithValue("SecondSpecialty_UA", ""); }
                    try { command.Parameters.AddWithValue("SecondSpecialty_EN", sheet1.GetRow(7).GetCell(1).StringCellValue); }
                    catch { command.Parameters.AddWithValue("SecondSpecialty_EN", ""); }
                    try { command.Parameters.AddWithValue("Specialization_UA", sheet1.GetRow(8).GetCell(1).StringCellValue); }
                    catch { command.Parameters.AddWithValue("Specialization_UA", ""); }
                    try { command.Parameters.AddWithValue("Specialization_EN", sheet1.GetRow(9).GetCell(1).StringCellValue); }
                    catch { command.Parameters.AddWithValue("Specialization_EN", ""); }
                    command.Parameters.AddWithValue("Degree", sheet1.GetRow(10).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Date", DateTime.Now);
                    command.ExecuteNonQuery();

                    string ComandSQL2 = "SELECT qualification.Qualification_ID FROM qualification ORDER BY" +
                                        " qualification.Qualification_ID DESC LIMIT 1";
                    command = new MySqlCommand(ComandSQL2, connection1);
                    MySqlDataReader reader2 = command.ExecuteReader();
                    reader2.Read();
                    IdQ              = reader2.GetInt32(0);
                    processPb.Value += 1;
                    reader2.Close();

                    string upDate = "UPDATE `National_framework` SET Level_qualification_UA=@Level_qualification_UA," +
                                    "`Level_qualification_EN`=@Level_qualification_EN," +
                                    "`Official_duration_programme_UA`=@Official_duration_programme_UA," +
                                    "`Official_duration_programme_EN`=@Official_duration_programme_EN," +
                                    "`Access_requirements_UA`=@Access_requirements_UA" +
                                    ",`Access_requirements_EN`=@Access_requirements_EN " +
                                    ",`Access_further_study_UA`=@Access_further_study_UA," +
                                    "`Access_further_study_EN`=@Access_further_study_EN," +
                                    "`Professional_status_UA`=@Professional_status_UA," +
                                    "`Professional_status_EN`=@Professional_status_EN" +
                                    "  WHERE National_framework.Qualification_ID=@Qualification_ID";
                    command = new MySqlCommand(upDate, connection1);

                    command.Parameters.AddWithValue("Qualification_ID", IdQ.ToString());
                    command.Parameters.AddWithValue("Level_qualification_UA", sheet2.GetRow(0).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Level_qualification_EN", sheet2.GetRow(1).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Official_duration_programme_UA", sheet2.GetRow(2).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Official_duration_programme_EN", sheet2.GetRow(3).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Access_requirements_UA", sheet2.GetRow(4).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Access_requirements_EN", sheet2.GetRow(5).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Access_further_study_UA", sheet2.GetRow(6).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Access_further_study_EN", sheet2.GetRow(7).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Professional_status_UA", sheet2.GetRow(8).GetCell(1).StringCellValue);
                    command.Parameters.AddWithValue("Professional_status_EN", sheet2.GetRow(9).GetCell(1).StringCellValue);

                    command.ExecuteNonQuery();
                    processPb.Value += 1;

                    StringMultiLanguage programSpecification   = new StringMultiLanguage();
                    StringMultiLanguage knowledgeUnderstanding = new StringMultiLanguage();
                    StringMultiLanguage applyingKnowledge      = new StringMultiLanguage();
                    StringMultiLanguage MakingJudgments        = new StringMultiLanguage();
                    for (int row = 1; row < sheet3.LastRowNum; row++)
                    {
                        if (sheet3.GetRow(row).GetCell(1) != null)
                        {
                            if (!string.IsNullOrEmpty(sheet3.GetRow(row).GetCell(1).StringCellValue))
                            {
                                programSpecification.UA = programSpecification.UA + (sheet3.GetRow(row).GetCell(1).StringCellValue + ";_");
                                programSpecification.EN = programSpecification.EN + (sheet3.GetRow(row).GetCell(2).StringCellValue + ";_");
                            }
                        }


                        if (sheet3.GetRow(row).GetCell(3) != null)
                        {
                            if (!string.IsNullOrEmpty(sheet3.GetRow(row).GetCell(3).StringCellValue))
                            {
                                knowledgeUnderstanding.UA = knowledgeUnderstanding.UA + (sheet3.GetRow(row).GetCell(3).StringCellValue + ";_");
                                knowledgeUnderstanding.EN = knowledgeUnderstanding.EN + (sheet3.GetRow(row).GetCell(4).StringCellValue + ";_");
                            }
                        }
                        if (sheet3.GetRow(row).GetCell(5) != null)
                        {
                            if (!string.IsNullOrEmpty(sheet3.GetRow(row).GetCell(5).StringCellValue))
                            {
                                applyingKnowledge.UA = applyingKnowledge.UA + (sheet3.GetRow(row).GetCell(5).StringCellValue + ";_");
                                applyingKnowledge.EN = applyingKnowledge.EN + (sheet3.GetRow(row).GetCell(6).StringCellValue + ";_");
                            }
                        }

                        if (sheet3.GetRow(row).GetCell(7) != null)
                        {
                            if (!string.IsNullOrEmpty(sheet3.GetRow(row).GetCell(7).StringCellValue))
                            {
                                MakingJudgments.UA = MakingJudgments.UA + (sheet3.GetRow(row).GetCell(7).StringCellValue + ";_");
                                MakingJudgments.EN = MakingJudgments.EN + (sheet3.GetRow(row).GetCell(8).StringCellValue + ";_");
                            }
                        }
                    }
                    processPb.Value += 1;

                    upDate = "UPDATE `contents_and_results` SET Form_study_UA=@Form_study_UA," +
                             "`Form_study_EN`=@Form_study_EN," +
                             "`Program_Specification_UA`=@Program_Specification_UA," +
                             "`Program_Specification_EN`=@Program_Specification_EN," +
                             "`Knowledge_undestanding_UA`=@Knowledge_undestanding_UA" +
                             ",`Knowledge_undestanding_EN`=@Knowledge_undestanding_EN " +
                             ",`Application_knowledge_understanding_UA`=@Application_knowledge_understanding_UA," +
                             "`Application_knowledge_understanding_EN`=@Application_knowledge_understanding_EN," +
                             "`Making_judgments_UA`=@Making_judgments_UA," +
                             "`Making_judgments_EN`=@Making_judgments_EN" +
                             "  WHERE contents_and_results.Qualification_ID=@Qualification_ID";
                    command = new MySqlCommand(upDate, connection1);

                    string Form_study = sheet3.GetRow(1).GetCell(0).StringCellValue;



                    // int last = Form_study. ;

                    command.Parameters.AddWithValue("Qualification_ID", IdQ.ToString());
                    command.Parameters.AddWithValue("Form_study_UA", Form_study.Substring(0, Form_study.IndexOf('/')));
                    command.Parameters.AddWithValue("Form_study_EN", Form_study.Substring((Form_study.IndexOf('/') + 1), (Form_study.Length - Form_study.IndexOf('/') - 1)));
                    command.Parameters.AddWithValue("Program_Specification_EN", programSpecification.EN.Replace(";_", "; "));
                    command.Parameters.AddWithValue("Program_Specification_UA", programSpecification.UA.Replace(";_", "; "));
                    command.Parameters.AddWithValue("Knowledge_undestanding_UA", knowledgeUnderstanding.UA.Replace(";_", "; "));
                    command.Parameters.AddWithValue("Knowledge_undestanding_EN", knowledgeUnderstanding.EN.Replace(";_", "; "));
                    command.Parameters.AddWithValue("Application_knowledge_understanding_UA", applyingKnowledge.UA.Replace(";_", "; "));
                    command.Parameters.AddWithValue("Application_knowledge_understanding_EN", applyingKnowledge.EN.Replace(";_", "; "));
                    command.Parameters.AddWithValue("Making_judgments_UA", MakingJudgments.UA.Replace(";_", "; "));
                    command.Parameters.AddWithValue("Making_judgments_EN", MakingJudgments.EN.Replace(";_", "; "));

                    command.ExecuteNonQuery();
                    processPb.Value += 1;
                    /////////////////////////

                    Dictionary <int, int> countries = new Dictionary <int, int>();
                    string ComandSQ = "SELECT MAX(discipline.Discipline_ID) AS expr1 FROM discipline " +
                                      "WHERE discipline.Qualification_ID =" + IdQ.ToString();
                    upDate = "INSERT INTO Discipline (Qualification_ID, Course_title_UA, Course_title_EN, Loans, Hours, Teaching, Differential)" +
                             " VALUES (@Qualification_ID, @Course_title_UA, @Course_title_EN, @Loans, @Hours, @Teaching, @Differential)";

                    for (int row = 1; row <= sheet5.LastRowNum; row++)
                    {
                        try
                        {
                            if (sheet5.GetRow(row) != null) //null is when the row only contains empty cells
                            {
                                command = new MySqlCommand(upDate, connection1);
                                // Создание обьекта студент
                                command.Parameters.AddWithValue("Qualification_ID", IdQ.ToString());
                                command.Parameters.AddWithValue("Course_title_UA", sheet5.GetRow(row).GetCell(0).StringCellValue);
                                command.Parameters.AddWithValue("Course_title_EN", sheet5.GetRow(row).GetCell(1).StringCellValue);
                                command.Parameters.AddWithValue("Loans", (sheet5.GetRow(row).GetCell(2).NumericCellValue));
                                command.Parameters.AddWithValue("Hours", (sheet5.GetRow(row).GetCell(3).NumericCellValue));
                                command.Parameters.AddWithValue("Teaching", sheet5.GetRow(row).GetCell(4).NumericCellValue);
                                command.Parameters.AddWithValue("Differential", (sheet5.GetRow(row).GetCell(5).NumericCellValue == 0) ? "Оцінка" : "Зарах");

                                command.ExecuteNonQuery();


                                command = new MySqlCommand(ComandSQ, connection1);
                                MySqlDataReader reader3 = command.ExecuteReader();
                                reader3.Read();
                                countries.Add(row, reader3.GetInt32(0));
                                reader3.Close();
                                //rbStatus.Text += sheet5.GetRow(row).GetCell(0).StringCellValue + '\n';
                            }
                        }
                        catch {}
                    }

                    processPb.Value += 1;
                    studentFunc(hssfwb, countries, connection1, IdQ);

                    connection1.Close();
                    //processPb.Value += 1;
                    SEARCH Search = new SEARCH();
                    Search.ID = IdQ;
                    Search.StringConnection = connectionString;
                    Search.NewOrOld         = false;
                    this.Visible            = false;
                    Search.ShowDialog();
                    this.Visible = true;
                }
                catch (Exception exc)
                {
                    try
                    {
                        MessageBox.Show(exc.ToString());
                        SEARCH Search = new SEARCH();
                        Search.ID = IdQ;
                        Search.StringConnection = connectionString;
                        Search.NewOrOld         = true;
                        this.Visible            = false;
                        Search.ShowDialog();
                    }
                    catch (Exception exce) { MessageBox.Show(exce.ToString()); }
                }
            }
        }
Пример #22
0
        public void LaunchScanner(SEARCH search, string path, bool launchinbackground = false, string regex = null)
        {
            List<string> param = new List<string>() {
                "--tempdir \"{0}\"",
                "--keep-mbox",
                "--stdout",
                "--database=\"{1}\"",
                "--log=\"{2}\"",
                "--infected",
                "--show-progress",
                "--kill"
            };

            // if max files are declared
            StringCollection max = Settings.Default.ClamWin_Max;
            string[] limits = {
                                  "--max-files=" + max[0],
                                  "--max-scansize=" + max[1],
                                  "--max-recursion=" + max[2],
                                  "--max-filesize=" + max[3]
                              };

            // exclusions
            string exclude = string.Empty;
            List<string> list_exclude = new List<string>();
            foreach (string e in Settings.Default.ClamWin_Exclude)
            {
                list_exclude.Add(string.Format("--exclude=\"{0}\"", e));
            }
            exclude = string.Join(" ", list_exclude.ToArray());

            // add additional parameters
            if (regex != null)
            {
                param.Add("--include=\"" + regex + "\"");
            }
            param.Add(string.Join(" ", limits));

            switch (search)
            {
                case SEARCH.clamscan_file:
                    param.Add("\"" + path + "\"");
                    break;
                case SEARCH.clamscan_folder:
                    param.Add(exclude);
                    param.Add("\"" + path + "\"");
                    break;
                case SEARCH.clamscan_folder_recurse:
                    param.Add("--recursive");
                    param.Add(exclude);
                    param.Add("\"" + path + "\"");
                    break;
                case SEARCH.clamscan_memory:
                    param.Add("--memory");
                    break;
            }

            string full_param = string.Join(" ", param.ToArray());
            full_param = string.Format(full_param,
                Environment.GetEnvironmentVariable("TEMP"),
                this._exec_clam_db_path,
                Path.Combine(Environment.GetEnvironmentVariable("TEMP"), "clamscan_temp_" + Guid.NewGuid().ToString())
            );

            this.log.Clear();
            this.Clam.WindowTitle = "Scan for virus";
            this.Clam.ShowClamWinVirusUpdateWindow = true;
            UpdateProgressLog("╔═══════════════════════════════════════════════╗");
            UpdateProgressLog("║ Starting to scan files and folders for virus. ║");
            UpdateProgressLog("╚═══════════════════════════════════════════════╝");

            if (!launchinbackground)
            {
                ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(this._exec_clam, "clamscan.exe"), full_param)
                {
                    WindowStyle = ProcessWindowStyle.Hidden,
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow = true,
                };

                update_process = new Process()
                {
                    StartInfo = startInfo
                };
                update_process.OutputDataReceived += process_OutputDataReceived;
                update_process.Start();
                update_process.BeginOutputReadLine();
                update_process.WaitForExit();
            }
            else
            {
                bgWorker.RunWorkerAsync(Path.Combine(this._exec_clam, "clamscan.exe") + "|" + full_param);
            }

            //bgWorker.RunWorkerAsync(full_param);
        }
Пример #23
0
        public void LaunchScanner(SEARCH search, string path, bool launchinbackground = false, string regex = null, bool remove = false, Action callback = null)
        {
            this.Clam.InfectedFilesCount = 0;
            this.Clam.WindowTitle = "Scan custom locations for viruses";
            this.Clam.EnableCleanNowButton = false;
            this.Clam.EnableCancelButton = true;
            this.Clam.EnableCloseButton = true;

            this.WriteConfig();

            List<string> param = new List<string>() {
                //"--tempdir \"{0}\"",
                //"--keep-mbox",
                //"--stdout",
                "--database=\"{1}\"",
                "--log=\"{2}\"",
                "--infected",
                "--recursive=yes"
            };

            if(IsRemove)
                param.Add("--remove=yes");

            // if max files are declared
            StringCollection max = Settings.Default.ClamWin_Max;
            string[] limits  = {
                                  "--max-files=" + max[0],
                                  "--max-scansize=" + max[1],
                                  "--max-recursion=" + max[2],
                                  "--max-filesize=" + max[3]
                              };

            // exclusions
            string exclude = string.Empty;
            List<string> list_exclude = new List<string>();
            foreach (string e in Settings.Default.ClamWin_Exclude)
            {
                list_exclude.Add(string.Format("--exclude=\"{0}\"", e));
            }
            exclude = string.Join(" ", list_exclude.ToArray());

            // add additional parameters
            if (regex != null)
            {
                param.Add("--include=\"" + regex + "\"");
            }
            param.Add(string.Join(" ", limits));

            switch (search)
            {
                case SEARCH.clamscan_file:
                    param.Add("\"" + path + "\"");
                    break;
                case SEARCH.clamscan_folder:
                    param.Add(exclude);
                    param.Add("\"" + path + "\"");
                    break;
                case SEARCH.clamscan_folder_recurse:
                    param.Add("--recursive");
                    param.Add(exclude);
                    param.Add("\"" + path + "\"");
                    break;
                case SEARCH.clamscan_memory:
                    this.Clam.WindowTitle = "Scan memory for viruses";
                    param.Add("--memory");
                    break;
                case SEARCH.clamscan_folderfile:
                    string[] locs = path.Split('|');
                    foreach (string loc in locs)
                    {
                        param.Add("\"" + loc + "\"");
                    }
                    break;
            }

            string full_param = string.Join(" ", param.ToArray());
            full_param = string.Format(full_param,
                Environment.GetEnvironmentVariable("TEMP"),
                this._exec_clam_db_path,
                Path.Combine(Environment.GetEnvironmentVariable("TEMP"), "clamscan_temp_" + Guid.NewGuid().ToString())
            );

            this.log.Clear();
            UpdateProgressLog("╔═══════════════════════════════════════════════╗");
            UpdateProgressLog("║ Starting to scan files and folders for virus. ║");
            UpdateProgressLog("╚═══════════════════════════════════════════════╝");
            UpdateProgressLog("Scanning please wait..");

            if (!launchinbackground)
            {
                ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(this._exec_clam, "clamscan.exe"), full_param)
                {
                    WindowStyle = ProcessWindowStyle.Hidden,
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow = true,
                };

                update_process = new Process()
                {
                    StartInfo = startInfo
                };
                update_process.OutputDataReceived += process_OutputDataReceived;
                update_process.Start();
                update_process.BeginOutputReadLine();
                update_process.WaitForExit();

                this.Clam.ShowClamWinVirusUpdateWindow = false;
            }
            else
            {
                if (!bgWorker.IsBusy)
                {
                    bgWorker.RunWorkerAsync(Path.Combine(this._exec_clam, "clamscan.exe") + "|" + full_param);
                }
                else
                {
                    MessageBox.Show("ClamAV is currently busy", "mCleaner", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }

            //bgWorker.RunWorkerAsync(full_param);
        }