예제 #1
0
        public int SaveFactoryProviders(FactoryProviders FactoryProviders)
        {
            FactoryProviders dbEntry;

            try
            {
                if (FactoryProviders.id == 0)
                {
                    dbEntry = new FactoryProviders()
                    {
                        id          = 0,
                        provider    = FactoryProviders.provider,
                        descriptipn = FactoryProviders.descriptipn
                    };
                    context.FactoryProviders.Add(dbEntry);
                }
                else
                {
                    dbEntry = context.FactoryProviders.Find(FactoryProviders.id);
                    if (dbEntry != null)
                    {
                        dbEntry.provider    = FactoryProviders.provider;
                        dbEntry.descriptipn = FactoryProviders.descriptipn;
                    }
                }

                context.SaveChanges();
            }
            catch (Exception e)
            {
                e.WriteErrorMethod(String.Format("SaveFactoryProviders(FactoryProviders={0})", FactoryProviders.GetFieldsAndValue()), eventID);
                return(-1);
            }
            return(dbEntry.id);
        }
예제 #2
0
 /// <summary>
 /// Получить DataSources по указаному dataset c определенной выборкой
 /// </summary>
 /// <param name="id_dataset"></param>
 /// <param name="sqlparams"></param>
 /// <returns></returns>
 public DataSources GetDataSources(int id_dataset, SQLParameter[] sqlparams)
 {
     try
     {
         EFDataSources efds = new EFDataSources();
         DataSets      ds   = efds.GetDataSets(id_dataset);
         if (ds == null)
         {
             return(null);
         }
         List <Parameter> list = new List <Parameter>();
         foreach (DataSetParameters dsp in ds.DataSetParameters)
         {
             foreach (SQLParameter sqlp in sqlparams)
             {
                 if (dsp.type_where.Contains(sqlp.where.ToString()))
                 {
                     // Добавим и выходим
                     list.Add(new Parameter(dsp, sqlp.value));
                     break;
                 }
             }
         }
         Connections conn = efds.GetConnections(ds.id_connection);
         if (conn == null)
         {
             return(null);
         }
         FactoryProviders provider = efds.GetFactoryProviders(conn.id_provider);
         if (provider == null)
         {
             return(null);
         }
         DataSources sources = new DataSources()
         {
             trobj      = (trObj)ds.trobj,
             provider   = provider.provider,
             connection = conn.connection,
             type       = (type_dataset)ds.type,
             linked     = ds.linked,
             dataset    = ds.dataset,
             parameters = list.ToArray()
         };
         return(sources);
     }
     catch (Exception e)
     {
         e.WriteErrorMethod(String.Format("GetConnections(id_dataset={0}, type_where={1})", id_dataset, sqlparams), eventID);
         return(null);
     }
 }
        public static IFactory GetInstance(this FactoryProviders factoryProvider)
        {
            switch (factoryProvider)
            {
            case FactoryProviders.FixedFactory:
                return(FixedFactory);

            case FactoryProviders.ProportionFactory:
                return(ProportionFactory);

            default:
                return(null);
            }
        }
예제 #4
0
        public FactoryProviders DeleteFactoryProviders(int id)
        {
            FactoryProviders dbEntry = context.FactoryProviders.Find(id);

            if (dbEntry != null)
            {
                try
                {
                    context.FactoryProviders.Remove(dbEntry);
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    e.WriteErrorMethod(String.Format("DeleteFactoryProviders(id={0})", id), eventID);
                    return(null);
                }
            }
            return(dbEntry);
        }