コード例 #1
0
        public void GetListTest()
        {
            var sql = new Sql("SELECT * FROM CategoryApplicationMTR ");

            sql.Where(" Name = @0", "A1");
            sql.Where(" Name  = @0 ", "A2");
            sql.Where(" Name  = @0 ", "A3");
            sql.WhereIfIn(" Name ", new[] { "A4", "A5", "A6" });
            sql.OrderBy(" Name desc ");
            var repository = NewDB.GetRepository <CategoryApplicationMtr>();
            var result     = repository.GetList <CategoryApplicationMtr>(sql);

            Assert.IsTrue(!result.Any());
        }
コード例 #2
0
        public bool NewDatabase(string DBpath, bool CopyBins = false,
                                bool CopySensors             = false, bool CopyTemps = false, bool OpenNewDatabase = false)
        {
            bool Result = false;

            try
            {
                string DBname = Path.GetFileNameWithoutExtension(DBpath);
                if (LegalFileName(DBname))
                {
                    string NewPath = Path.GetDirectoryName(DBpath) + "\\" + DBname + ".mdb";
                    if (!File.Exists(NewPath))
                    {
                        File.WriteAllBytes(NewPath, Properties.Resources.Base);

                        // check if previous database connected
                        if (cConnected)
                        {
                            // copy data
                            string        SQL = "";
                            DAO.Recordset OldRS;
                            DAO.Recordset NewRS;
                            DAO.Database  NewDB;
                            NewDB = cDBE.OpenDatabase(NewPath, DAO.DriverPromptEnum.dbDriverNoPrompt, false, "");

                            // database properties
                            SQL   = "select * from tblProps";
                            NewRS = NewDB.OpenRecordset(SQL);
                            if (NewRS.EOF)
                            {
                                NewRS.AddNew();
                            }
                            else
                            {
                                NewRS.Edit();
                            }
                            OldRS = cDB.OpenRecordset(SQL);
                            NewRS.Fields["dbType"].Value = OldRS.Fields["dbType"].Value;
                            foreach (DAO.Field Fld in OldRS.Fields)
                            {
                                if (!IsAutoIncrField(Fld))
                                {
                                    NewRS.Fields[Fld.Name].Value = OldRS.Fields[Fld.Name].Value;
                                }
                            }
                            NewRS.Update();
                            NewRS.Close();

                            // bins
                            if (CopyBins)
                            {
                                SQL   = "select * from tblStorage";
                                OldRS = cDB.OpenRecordset(SQL);
                                NewRS = NewDB.OpenRecordset(SQL);
                                while (!OldRS.EOF)
                                {
                                    NewRS.AddNew();
                                    foreach (DAO.Field Fld in OldRS.Fields)
                                    {
                                        if (!IsAutoIncrField(Fld))
                                        {
                                            NewRS.Fields[Fld.Name].Value = OldRS.Fields[Fld.Name].Value;
                                        }
                                    }
                                    NewRS.Update();
                                    OldRS.MoveNext();
                                }
                                NewRS.Close();
                                OldRS.Close();
                            }

                            // sensors
                            if (CopySensors)
                            {
                                SQL   = "select * from tblSensors";
                                OldRS = cDB.OpenRecordset(SQL);
                                NewRS = NewDB.OpenRecordset(SQL);
                                while (!OldRS.EOF)
                                {
                                    NewRS.AddNew();
                                    foreach (DAO.Field Fld in OldRS.Fields)
                                    {
                                        if (!IsAutoIncrField(Fld))
                                        {
                                            NewRS.Fields[Fld.Name].Value = OldRS.Fields[Fld.Name].Value;
                                        }
                                    }
                                    NewRS.Update();
                                    OldRS.MoveNext();
                                }
                                NewRS.Close();
                                OldRS.Close();
                            }

                            // temperature records
                            if (CopyTemps)
                            {
                                SQL   = "select * from tblSensors";
                                OldRS = cDB.OpenRecordset(SQL);
                                NewRS = NewDB.OpenRecordset(SQL);
                                while (!OldRS.EOF)
                                {
                                    NewRS.AddNew();
                                    foreach (DAO.Field Fld in OldRS.Fields)
                                    {
                                        if (!IsAutoIncrField(Fld))
                                        {
                                            NewRS.Fields[Fld.Name].Value = OldRS.Fields[Fld.Name].Value;
                                        }
                                    }
                                    NewRS.Update();
                                    OldRS.MoveNext();
                                }
                                NewRS.Close();
                                OldRS.Close();
                            }

                            NewDB.Close();
                        }
                        Result = true;
                        if (OpenNewDatabase)
                        {
                            OpenDatabase(NewPath);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                mf.Tls.WriteErrorLog("clsDatabase:NewDatabase " + ex.Message);
                Result = false;
            }
            return(Result);
        }
コード例 #3
0
        /// <summary>
        /// Создает отчет по юзерам вк (которые содержат экстремистский материал)
        /// </summary>
        private static void FromDoykovWordUsersExtremist()
        {
            using (NewDB db = new NewDB())
            {
                var api = new VkApi();

                api.Authorize(new ApiAuthParams
                {
                    ApplicationId = 123456,
                    Login         = "******",
                    Password      = "******",
                    Settings      = Settings.All
                });



                List <User> users = new List <User>();

                foreach (var item in db.ZigHailVkUsers)
                {
                    var vkuser = api.Users.Get(new long[]
                    {
                        (int)item.VkIdUser
                    }, VkNet.Enums.Filters.ProfileFields.All).FirstOrDefault();


                    if (vkuser != null)
                    {
                        string word = $"{vkuser.FirstName} {vkuser.LastName}";


                        // Если есть дата рождения то добавить
                        if (vkuser.BirthDate != null)
                        {
                            word += $", {vkuser.BirthDate}";
                        }


                        // Если есть город, то добавить
                        if (vkuser.City != null)
                        {
                            word += $", г. {vkuser.City.Title}.";
                        }
                        else
                        {
                            word += ".";
                        }



                        if (vkuser.Education != null)
                        {
                            switch (vkuser.Sex)
                            {
                            case (VkNet.Enums.Sex.Female):
                                word += " Окончила ";
                                break;

                            case (VkNet.Enums.Sex.Male):
                                word += " Окончил ";
                                break;

                            default:
                                break;
                            }

                            word += $"{vkuser.Education.UniversityName}.";
                        }


                        switch (vkuser.Sex)
                        {
                        case (VkNet.Enums.Sex.Female):
                            word += " Зарегистрирована";
                            break;

                        case (VkNet.Enums.Sex.Male):
                            word += " Зарегистрирован";
                            break;

                        default:
                            break;
                        }

                        word += $" в социальной сети «Вконтакте», адрес: vk.com/id{vkuser.Id};";

                        Console.WriteLine($"{word}");
                        //users.Add(vkuser);
                    }
                }
            }
        }