示例#1
0
 // GET: Repairs
 public ActionResult Index()
 {
     using (dbModel model = new dbModel())
     {
         return(View(model.Repairs.ToList()));
     }
 }
示例#2
0
 // GET: Table_1/Delete/5
 public ActionResult Delete(int ID)
 {
     using (dbModel Dbmodel = new dbModel())
     {
         return(View(Dbmodel.Table_1.Where(x => x.id == ID).FirstOrDefault()));
     }
 }
示例#3
0
        //public IEnumerable<ANG_EMPLOYEE> GetANG_EMPLOYEEs() {
        //    return db.ANG_EMPLOYEE;
        //}

        public JsonResult GetANG_EMPLOYEEsList()
        {
            using (var dbm = new dbModel()) {
                var emp = dbm.ANG_EMPLOYEE.ToList();
                return(Json(dbm.ANG_EMPLOYEE, JsonRequestBehavior.AllowGet));
            }
        }
示例#4
0
        /// <summary>
        /// Обнуляем значения свойств перед новым импортом
        /// </summary>
        private static void Preparing()
        {
            try
            {
                using (var db = new dbModel(CONNECTION))
                {
                    CleaningTempTables(db);
                }

                distinctProducts = null;
                emailHelper      = new EmailParamsHelper();
                EmailBody        = String.Empty;
                CountSuccess     = CountFalse = 0;
                Total            = "0 час. 0 мин. 0 сек. 0 мс.";
                Log        = new List <string>();
                Steps      = new List <string>();
                dictionary = new Dictionary <string, string>
                {
                    { "catalogs", "категории" },
                    { "products", "товары" },
                    { "catalogproductlinks", "связи категорий и товаров" },
                    { "images", "изображения" },
                    { "certificates", "сертификаты" },
                };
                if (!IsCompleted)
                {
                    Percent = Step = CountProducts = 0;
                }
            }
            catch (Exception e)
            {
                SrvcLogger.Error("{error}", e.ToString());
            }
        }
        public string includeDB(dbModel m)
        {
            if (conexion.OpenConnection().Equals("Connected"))
            {
                string Query = "insert into metadatadb.servidores(database_type,user,pass,server,protocol,port,alias) values('"
                               + m.dbType + "','" + m.username + "','" + m.pass + "','" + m.server + "','" + m.protocol + "','" +
                               m.port + "','" + m.alias + "');";

                MySqlCommand cmd = new MySqlCommand(Query, conexion.connection);

                try
                {
                    cmd.ExecuteNonQuery();

                    conexion.CloseConnection();
                    return("Insertado correctamente");
                }
                catch (Exception e)
                {
                    return("Error insertando" + e);
                }
            }

            else

            {
                conexion.CloseConnection();
                return("No hay conexion con la base de datos : metadata");
            }
        }
示例#6
0
 // GET: Table_1/index
 public ActionResult Index()
 {
     using (dbModel DbModel = new dbModel())
     {
         return(View(DbModel.Table_1.ToList()));
     }
 }
示例#7
0
 public void UpdateDb(dbModel dbModel)
 {
     using (StreamWriter file = File.CreateText("db.json"))
     {
         JsonSerializer serializer = new JsonSerializer();
         serializer.Serialize(file, dbModel);
     }
 }
示例#8
0
        /// <summary>
        /// Запускает импорт
        /// </summary>
        /// <returns></returns>
        public int Start(string path)
        {
            using (var reader = new StreamReader(path, Encoding.UTF8, true))
            {
                var serializer = new XmlSerializer(typeof(FLInfoList));
                try
                {
                    var arrayOfInfo = (FLInfoList)serializer.Deserialize(reader);

                    List <SS_FlInfo> list = new List <SS_FlInfo>();
                    ServiceLogger.Info("{info}", "начало мапинга");
                    foreach (var item in arrayOfInfo.FLInfos)
                    {
                        list.Add(CustomMapper(item));
                    }
                    ServiceLogger.Info("{info}", "конец мапинга");
                    using (var db = new dbModel(connection))
                    {
                        db.CommandTimeout = 1200000;
                        using (var tr = db.BeginTransaction())
                        {
                            try
                            {
                                ServiceLogger.Info("{info}", "таблица SS_FlInfo_Dupl перезапись начало");
                                db.AbonentInfoDelete();
                                ServiceLogger.Info("{info}", "таблица SS_FlInfo_Dupl перезапись конец");
                                ServiceLogger.Info("{info}", "таблица SS_FlInfo очищена");

                                ServiceLogger.Info("{info}", "таблица SS_FlInfo запись начало");
                                InsertBulk(list, db);
                                ServiceLogger.Info("{info}", "таблица SS_FlInfo запись окончание");

                                ServiceLogger.Info("{info}", "таблица SS_FlInfo обновление начало");
                                db.AbonentInfoUpdate();
                                ServiceLogger.Info("{info}", "таблица SS_FlInfo обновление конец");

                                tr.Commit();
                                ServiceLogger.Info("{info}", "импорт завершён");

                                return(list.Count);
                            }
                            catch (Exception e)
                            {
                                ServiceLogger.Error("{error}", e.ToString());
                                return(0);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    ServiceLogger.Error("{error}", e.ToString());
                    //string sd = @"�";
                    return(0);
                }
            }
        }
示例#9
0
        /// <summary>
        /// Gets all donors from the db.
        /// </summary>
        /// <returns>Observable collection of all donors</returns>
        public ObservableCollection <Donor> GetDonors()
        {
            ObservableCollection <Donor> Donors = new ObservableCollection <Donor>();

            context.Dispose();
            context = new dbModel();
            context.Donors.Load();
            Donors = context.Donors.Local;
            return(Donors);
        }
示例#10
0
 /// <summary>
 /// Возвращает список товаров
 /// </summary>
 /// <returns></returns>
 public string[] GetProducts(DateTime createDate)
 {
     using (var db = new dbModel(connection))
     {
         return(db.content_productss
                .Where(w => w.d_create_date >= createDate)
                .Select(s => s.c_barcode)
                .ToArray());
     }
 }
示例#11
0
        /// <summary>
        /// Gets all users from the db.
        /// </summary>
        /// <returns>Observable collection of all users</returns>
        public ObservableCollection <User> GetUsers()
        {
            ObservableCollection <User> Users = new ObservableCollection <User>();

            context.Dispose();
            context = new dbModel();
            context.Users.Load();
            Users = context.Users.Local;
            return(Users);
        }
        /// <summary>
        /// Gets all acceptors from the db.
        /// </summary>
        /// <returns>Observable collection of all acceptors</returns>
        public ObservableCollection <Acceptor> GetAcceptors()
        {
            ObservableCollection <Acceptor> Acceptors = new ObservableCollection <Acceptor>();

            context.Dispose();
            context = new dbModel();
            context.Acceptors.Load();
            Acceptors = context.Acceptors.Local;
            return(Acceptors);
        }
示例#13
0
        /// <summary>
        /// Gets all orders from the db.
        /// </summary>
        /// <returns>Observable collection of all orders</returns>
        public ObservableCollection <Order> GetOrders()
        {
            ObservableCollection <Order> Orders = new ObservableCollection <Order>();

            context.Dispose();
            context = new dbModel();
            context.Orders.Load();
            Orders = context.Orders.Local;
            return(Orders);
        }
示例#14
0
        /// <summary>
        /// Работа с файлами импорта
        /// </summary>
        /// <param name="file"></param>
        private static bool FileProcessing(FileInfo file, dbModel db, ReceiverParamsHelper receiverParams)
        {
            try
            {
                SrvcLogger.Info("{preparing}", $"импорт данных из: '{file.Name}'");
                Log.Insert(0, $"Чтение данных: {file.Name}");

                using (FileStream fileStream = new FileStream(file.FullName, FileMode.Open))
                {
                    SrvcLogger.Info("{preparing}", $"данные прочитаны из файла: {file.Name}");
                    Log.Insert(0, "Данные прочитаны");

                    var helper = new InsertHelper
                    {
                        FileStream = fileStream,
                        Db         = db,
                        Entity     = Entity.Catalogs
                    };

                    if (file.Name.StartsWith("cat"))
                    {
                        InsertWithLogging(helper);
                    }
                    else if (file.Name.StartsWith("prod"))
                    {
                        foreach (Entity entity in Enum.GetValues(typeof(Entity)))
                        {
                            if (!entity.Equals(Entity.Catalogs))
                            {
                                helper.Entity = entity;
                                InsertWithLogging(helper);
                            }
                        }
                        Step++;

                        SrvcLogger.Info("{work}", "перенос данных из буферных таблиц");
                        Log.Insert(0, "Перенос данных из буферных таблиц");
                        Finalizer(db);
                        Step++;
                    }
                    else if (file.Name.Contains(".zip"))
                    {
                        ImageService imageService = new ImageService(receiverParams);
                        imageService.Execute(file);
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                SrvcLogger.Error("{error}", e.ToString());
                return(false);
            }
        }
示例#15
0
 /// <summary>
 /// Вставляет список записей в таблицу
 /// </summary>
 /// <returns></returns>
 private void InsertBulk(IEnumerable <SS_FlInfo> list, dbModel db)
 {
     try
     {
         db.BulkCopy(list);
     }
     catch (Exception e)
     {
         ServiceLogger.Error("{error}", e.ToString());
     }
 }
示例#16
0
        public dbModel getConnection(int cID)
        {
            if (conexion.OpenConnection().Equals("Connected"))
            {
                // mariaDB.Insert(db);
                string Query = "select * from  metadatadb.servidores";

                MySqlCommand cmd = new MySqlCommand(Query, conexion.connection);

                ArrayList objs = new ArrayList();
                //cmd.ExecuteNonQuery();
                try
                {
                    MySqlDataReader rdr   = cmd.ExecuteReader();
                    dbModel         model = null;
                    while (rdr.Read())
                    {
                        int z = rdr.GetInt32(7);
                        if (z == cID)
                        {
                            string db_type  = rdr.GetString(0);
                            string usr      = rdr.GetString(1);
                            string pass     = rdr.GetString(2);
                            string server   = rdr.GetString(3);
                            string protocol = rdr.GetString(4);
                            int    port     = rdr.GetInt32(5);
                            string allias   = rdr.GetString(6);
                            string id       = rdr.GetString(7);
                            model = new dbModel(
                                db_type, usr, pass, server, protocol, port, allias);
                            return(model);
                        }
                    }
                    rdr.Close();
                    conexion.CloseConnection();
                    return(model);
                    //  citationstexter = citationstexter + "]";



                    // return citationstexter;
                }
                catch (Exception e)
                {
                    return(null);
                }
            }

            else
            {
                return(null);
            }
        }
示例#17
0
 /// <summary>
 /// Возвращает список продуктов, записанных в бд
 /// </summary>
 /// <returns></returns>
 private static ProductExport[] GetProducts()
 {
     using (var db = new dbModel(CONNECTION))
     {
         return(db.content_productss
                .Where(w => w.n_count > 0)
                .Select(s => new ProductExport
         {
             Code = s.c_code
         }).ToArray());
     }
 }
示例#18
0
 /// <summary>
 /// Gets statistics value for <paramref name="BloodType"/> from db.
 /// </summary>
 /// <param name="BloodType">Type of the blood.</param>
 /// <returns>Percent of reserve for <paramref name="BloodType"/>
 /// or throws an NullReferenceException if there is no such blood type in Statistics table.</returns>
 /// <exception cref="System.NullReferenceException"></exception>
 public long GetStatistic(BloodTypeMarker BloodType)
 {
     try
     {
         context.Dispose();
         context = new dbModel();
         return((context.Statistics.Find(BloodType)).TotalAmount / 5000);
     }
     catch (NullReferenceException)
     {
         throw new NullReferenceException();
     }
 }
示例#19
0
        //Chequear que existe una conexion posible de mariaDB con el modelo del parámetro.
        public string check(dbModel model)
        {
            MariaDBConnect cc = new MariaDBConnect(model.username, model.pass, model.server, model.port, model.alias);

            if (cc.OpenConnection().Equals("Connected"))
            {
                return("Connected");
            }
            else
            {
                return("Cant connect");
            }
        }
示例#20
0
        internal string check(dbModel model)
        {
            try
            {
                var connectionString = "mongodb://" + model.username + ":" + model.pass + "@" + model.server + "/" + model.alias;

                MongoClient mongoClient = new MongoClient(connectionString);

                return("Connected");
            }
            catch (Exception e) {
                return("Cant Connect");
            }
        }
示例#21
0
        public string includeDB(dbModel m)
        {
            if (conexion.OpenConnection().Equals("Connected"))
            {
                return("Connected");
            }

            else

            {
                conexion.CloseConnection();
                return("No hay conexion con la base de datos : metadata");
            }
        }
示例#22
0
        public string includeDB(string jsonIDB)
        {
            //string type, string user, string pass, string server,int port,string database
            //string db_type, string user, string pass, string server, int port, string allias
            //Creamos un nuevo modelo de una base de datos a incluir.
            // dbModel model = new dbModel(type, user, pass, server,"tcp/ip", port, database);
            dbModel model = JsonConvert.DeserializeObject <dbModel>(jsonIDB);

            switch (model.dbType)
            {
            case "MariaDB":
                string cMa = controlMaria.check(model);
                if (cMa.Equals("Connected"))
                {
                    return(controlMaria.includeDB(model));
                }
                else
                {
                    return("No hay conexion con esta instancia de MariaDB ");
                }

            case "MongoDB":
                string cMo = controlMongo.check(model);
                if (cMo.Equals("Connected"))
                {
                    return(controlMaria.includeDB(model));
                }
                else
                {
                    return("No hay conexion con esta instancia de MongoDB ");
                }


            case "SQLDB":
                string cS = controlSQL.check(model);
                if (cS.Equals("Connected"))
                {
                    return(controlMaria.includeDB(model));
                }
                else
                {
                    return("No hay conexion con esta instancia de SQLDB ");
                }


            default: return("Cant Check");
            }
        }
示例#23
0
 /// <summary>
 /// Logs the in.
 /// </summary>
 /// <param name="username">The username.</param>
 /// <param name="password">The password.</param>
 /// <returns>Logged user or null if nothing matched. Throws an EntityException on connection error.</returns>
 public bbFiles.Entities.User LogIn(string username, string password)
 {
     try
     {
         using (var context = new dbModel())
         {
             return(context.Users
                    .Where(x => x.Login.ToLower() == username.ToLower() && x.Password == password)
                    .Select(x => x)
                    .SingleOrDefault());
         }
     }
     catch (EntityException ex)
     {
         throw ex.InnerException;
     }
 }
示例#24
0
        /// <summary>
        /// Возвращает список email для получения информации по импорту
        /// </summary>
        /// <param name="db"></param>
        /// <returns></returns>
        private static List <string> GetAdminEmails(dbModel db)
        {
            try
            {
                string email = db.cms_sitess
                               .Select(s => s.c_tech_email).FirstOrDefault();

                return(email.Split(';')
                       .Select(s => s.Trim())
                       .Where(w => !String.IsNullOrWhiteSpace(w))
                       .ToList());
            }
            catch (Exception e)
            {
                SrvcLogger.Error("{error}", e.ToString());
                return(null);
            }
        }
示例#25
0
 public ActionResult Delete(int ID, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         using (dbModel Dbmodel = new dbModel())
         {
             Table_1 table_1 = Dbmodel.Table_1.Where(x => x.id == ID).FirstOrDefault();
             Dbmodel.Table_1.Remove(table_1);
             Dbmodel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#26
0
        public ActionResult Edit(int id, Table_1 table_1)
        {
            try
            {
                using (dbModel Dbmodel = new dbModel())
                {
                    Dbmodel.Entry(table_1).State = EntityState.Modified;
                    Dbmodel.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#27
0
        public ActionResult Create(Table_1 table_1)
        {
            try
            {
                using (dbModel DbModel = new dbModel())
                {
                    DbModel.Table_1.Add(table_1);
                    DbModel.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#28
0
 /// <summary>
 /// Очищает буферные таблицы
 /// </summary>
 private static void CleaningTempTables(dbModel db)
 {
     try
     {
         using (var tr = db.BeginTransaction())
         {
             db.import_productss.Delete();
             db.import_catalogss.Delete();
             db.import_product_categoriess.Delete();
             db.import_product_certificatess.Delete();
             db.import_product_imagess.Delete();
             tr.Commit();
         }
     }
     catch (Exception e)
     {
         SrvcLogger.Error("{error}", e.ToString());
     }
 }
示例#29
0
        public static List <CumpleaniosView> cumpleanosOT()
        {
            List <CumpleaniosView> cumpleanieros = new List <CumpleaniosView>();

            using (dbModel db = new dbModel())
            {
                var clientes = (from n in db.tblOtorgante
                                select n).ToList();

                foreach (var item in clientes)
                {
                    int diaCumple = item.fechanacimiento.Day;
                    int mesCumple = item.fechanacimiento.Month;
                    //int anioCumple = 1994;

                    DateTime proximoCumple;

                    if (DateTime.Now.Month > mesCumple && DateTime.Now.Day > diaCumple)
                    {
                        proximoCumple = new DateTime(DateTime.Now.AddYears(1).Year, mesCumple, diaCumple);
                    }
                    else
                    {
                        proximoCumple = new DateTime(DateTime.Now.Year, mesCumple, diaCumple);
                    }

                    TimeSpan faltan = proximoCumple.Subtract(DateTime.Now);

                    if (faltan.Days >= 0 && faltan.Days <= 3)
                    {
                        var clienteOT = new CumpleaniosView
                        {
                            nombreCliente = item.nombres + " " + item.apellidos,
                            //dias = faltan.Days
                            //dias = faltan.Days == 0 ? faltan.Days + 1 : faltan.Days
                            dias = DateTime.Now.Day == diaCumple ? 0 : faltan.Days + 1
                        };
                        cumpleanieros.Add(clienteOT);
                    }
                }
                return(cumpleanieros);
            }
        }
示例#30
0
        public static List <AudienciasView> Audiencias()
        {
            List <AudienciasView> NotiAudiencias = new List <AudienciasView>();

            using (dbModel db = new dbModel())
            {
                var clientesAudiencia = (from n in db.tblCasos
                                         select n).ToList();

                foreach (var item in clientesAudiencia)
                {
                    int diaAudi = item.Fecha_Audiencia.Day;
                    int mesAUdi = item.Fecha_Audiencia.Month;

                    DateTime proximaAudi;

                    if (DateTime.Now.Month > mesAUdi && DateTime.Now.Day > diaAudi)
                    {
                        proximaAudi = new DateTime(DateTime.Now.AddYears(1).Year, mesAUdi, diaAudi);
                    }
                    else
                    {
                        proximaAudi = new DateTime(DateTime.Now.Year, mesAUdi, diaAudi);
                    }

                    TimeSpan faltan = proximaAudi.Subtract(DateTime.Now);

                    if (faltan.Days >= 0 && faltan.Days <= 7)
                    {
                        var clienteAB = new AudienciasView
                        {
                            nombreCLiente = item.tblClientes.Nombres + " " + item.tblClientes.Apellidos,
                            juzgado       = item.tblJuzgados.Juzgado,
                            dias          = DateTime.Now.Day == diaAudi ? 0 : faltan.Days + 1
                        };

                        NotiAudiencias.Add(clienteAB);
                    }
                }

                return(NotiAudiencias);
            }
        }