예제 #1
0
        //T ConvertTableT( DataTable table)
        //{
        //    return new T(table);
        //}

        /// <summary>
        /// 根据id读取指定行。该方法不受其它参数限定
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual T GetRowById(int id)
        {
            T dt = new T();

            if (string.IsNullOrEmpty(dt.IdentifyField))
            {
                throw new Exception("表[" + dt.TableName + "] 无主键数");
            }
            string sql = string.Format("select * from {0} where {1}={2}",
                                       ((IDBSQLHelper)this).safeTableName, dBase.FieldEncode(dt.IdentifyField), id);

            LastSqlExecute = sql;
            var cmd = dBase.Command();

            cmd.CommandText = sql;
            System.Data.IDataReader reader = null;
            try
            {
                reader = dBase.ExecuteReader(cmd);
                return(Reader2Item(reader));
            }
            finally
            {
                cmd.Cancel();//可快速关闭reader
                if (reader != null)
                {
                    reader.Dispose();
                }
                cmd.Dispose();
            }
        }
예제 #2
0
        /// <summary>
        /// Returns the value of the specified variable name
        /// </summary>
        /// <param name="varName">Variable name</param>
        /// <returns>variable value</returns>
        public string GetVarValue(string varName)
        {
            string Function_Name = "GetVarValue";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");

            string varValue = "null";
            string localSQL = "SELECT VAR_VALUE FROM CONFIG_VARS WHERE VAR_NAME = '" + varName + "'";

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            if (drReader != null)
            {
                try
                {
                    while (drReader.Read())
                    {
                        if (!drReader.IsDBNull(0))
                        {
                            varValue = drReader.GetString(0).ToString();
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
                }

                drReader.Close();
                drReader.Dispose();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(varValue);
        }
예제 #3
0
                public void Dispose()
                {
                    if (m_reader != null)
                    {
                        m_reader.Dispose();
                        m_reader = null;
                    }

                    if (m_command != null)
                    {
                        m_command.Dispose();
                        m_command = null;
                    }

                    if (m_tmptable != null)
                    {
                        try
                        {
                            using (var c = m_connection.CreateCommand())
                            {
                                c.CommandText = string.Format(@"DROP TABLE IF EXISTS ""{0}""", m_tmptable);
                                c.ExecuteNonQuery();
                            }
                        }
                        catch { }
                        finally { m_tmptable = null; }
                    }
                }
예제 #4
0
 public static SoftFluent.Samples.Thinktecture.IdentityServer.Login LoadById(System.Guid id)
 {
     if ((id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         return(null);
     }
     SoftFluent.Samples.Thinktecture.IdentityServer.Login login       = new SoftFluent.Samples.Thinktecture.IdentityServer.Login();
     CodeFluent.Runtime.CodeFluentPersistence             persistence = CodeFluentContext.Get(SoftFluent.Samples.Thinktecture.IdentityServer.Constants.SoftFluent_Samples_Thinktecture_IdentityServerStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Login", "LoadById");
     persistence.AddParameter("@Id", id, CodeFluentPersistence.DefaultGuidValue);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             login.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             login.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(login);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #5
0
 public static SoftFluent.Json.NET.Publication LoadById(int id)
 {
     if ((id == -1))
     {
         return(null);
     }
     SoftFluent.Json.NET.Publication          publication = new SoftFluent.Json.NET.Publication();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Json.NET.Constants.SoftFluent_Json_NETStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Publication", "LoadById");
     persistence.AddParameter("@Id", id, ((int)(-1)));
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             publication.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             publication.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(publication);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #6
0
 public static ModelCodeFluent.Identity.RoleClaim LoadById(System.Guid id)
 {
     if ((id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         return(null);
     }
     ModelCodeFluent.Identity.RoleClaim       roleClaim   = new ModelCodeFluent.Identity.RoleClaim();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(ModelCodeFluent.Constants.ModelCodeFluentStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "RoleClaim", "LoadById");
     persistence.AddParameter("@Id", id, CodeFluentPersistence.DefaultGuidValue);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             roleClaim.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             roleClaim.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(roleClaim);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #7
0
        public string GetLocationNameFromKey(double locationKey)
        {
            string Function_Name = "GetLocationNameFromKey";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            string locationName = "";
            string localSQL     = "SELECT NAME FROM LOCATION WHERE PKEY = " + locationKey.ToString();

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            try
            {
                if (drReader != null && drReader.Read())
                {
                    if (!drReader.IsDBNull(drReader.GetOrdinal("NAME")))
                    {
                        locationName = DAOHelper.convert8859P1ToGB2312(drReader["NAME"].ToString());
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
                //SimpleDatabase.GetInstance().CloseCurrentSession();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(locationName);
        }
예제 #8
0
 public static SoftFluent.Samples.AspNetIdentity2.Role Load(System.Guid id)
 {
     if ((id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         return(null);
     }
     SoftFluent.Samples.AspNetIdentity2.Role  role        = new SoftFluent.Samples.AspNetIdentity2.Role();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.AspNetIdentity2.Constants.SoftFluent_Samples_AspNetIdentity2StoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Role", "Load");
     persistence.AddParameter("@Id", id, CodeFluentPersistence.DefaultGuidValue);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             role.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             role.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(role);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
        /// <summary>
        /// Returns the total sample group records count in table
        /// </summary>
        /// <returns>No of Sample group configured</returns>
        public int GetRowCount()
        {
            string Function_Name = "GetRowCount";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            string localSQL;
            int    nRowCount = 0;

            localSQL = "SELECT COUNT(SAMPLE_GRP_NAME) AS MAXROWS FROM OPC_DT_SAMPLE_GRP";
            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            try
            {
                if (drReader != null && drReader.Read())
                {
                    if (!drReader.IsDBNull(0))
                    {
                        LogHelper.Debug(CLASS_NAME, Function_Name, "Function_Exited");
                        nRowCount = Convert.ToInt32(drReader["MAXROWS"]);
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(nRowCount);
        }
 public static ContactManager.ContactSource LoadById(int id)
 {
     if ((id == -1))
     {
         return(null);
     }
     ContactManager.ContactSource             contactSource = new ContactManager.ContactSource();
     CodeFluent.Runtime.CodeFluentPersistence persistence   = CodeFluentContext.Get(ContactManager.Constants.ContactManagerStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "ContactSource", "LoadById");
     persistence.AddParameter("@Id", id, ((int)(-1)));
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             contactSource.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             contactSource.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(contactSource);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #11
0
 public static SoftFluent.Samples.GED.Directory LoadById(System.Guid id)
 {
     if ((id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         return(null);
     }
     SoftFluent.Samples.GED.Directory         directory   = new SoftFluent.Samples.GED.Directory();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.GED.Constants.SoftFluent_Samples_GEDStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Directory", "LoadById");
     persistence.AddRawParameter("@Id", id);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             directory.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             directory.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(directory);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
        public bool GetOPCDataPointByName(string dataPoint)
        {
            string Function_Name = "GetOPCDataPointByName";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            string localSQL = "SELECT PKEY FROM DATALOG_DP_TREND WHERE DP_NAME = '" + dataPoint + "'";

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            bool bFound = false;

            try
            {
                if (drReader != null && drReader.Read())
                {
                    if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_PKEY)))
                    {
                        bFound = true;
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(bFound);
        }
예제 #13
0
 public static SoftFluent.Json.NET.Support LoadByName(string name)
 {
     if ((name == default(string)))
     {
         return(null);
     }
     SoftFluent.Json.NET.Support support = new SoftFluent.Json.NET.Support();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Json.NET.Constants.SoftFluent_Json_NETStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Support", "LoadByName");
     persistence.AddParameter("@Name", name, default(string));
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             support.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             support.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(support);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #14
0
 public static ModelCodeFluent.Vehicle LoadByVehicleId(System.Guid vehicleId)
 {
     if ((vehicleId.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         return(null);
     }
     ModelCodeFluent.Vehicle vehicle = new ModelCodeFluent.Vehicle();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(ModelCodeFluent.Constants.ModelCodeFluentStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Vehicle", "LoadByVehicleId");
     persistence.AddParameter("@VehicleId", vehicleId, CodeFluentPersistence.DefaultGuidValue);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             vehicle.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             vehicle.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(vehicle);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #15
0
 public static SoftFluent.SqlServerInMemory.Customer LoadById(System.Guid id)
 {
     if ((id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         return(null);
     }
     SoftFluent.SqlServerInMemory.Customer    customer    = new SoftFluent.SqlServerInMemory.Customer();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.SqlServerInMemory.Constants.SoftFluent_SqlServerInMemoryStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Customer", "LoadById");
     persistence.AddParameter("@Id", id, CodeFluentPersistence.DefaultGuidValue);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             customer.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             customer.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(customer);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #16
0
 public static SoftFluent.Samples.GED.Page LoadOneToProcess()
 {
     SoftFluent.Samples.GED.Page page = new SoftFluent.Samples.GED.Page();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.GED.Constants.SoftFluent_Samples_GEDStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Page", "LoadOneToProcess");
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             page.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             page.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(page);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #17
0
 public static void SaveLocalizedValues(SoftFluent.Samples.RedisCache.Category entity, int lcid, bool isDefault, string name)
 {
     if ((entity == null))
     {
         throw new System.ArgumentNullException("entity");
     }
     if ((entity.Id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         CodeFluent.Runtime.CodeFluentRuntimeException.Throw("invalidEntityKey", "Id", "entity", "SoftFluent.Samples.RedisCache.Category");
     }
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.RedisCache.Constants.SoftFluent_Samples_RedisCacheStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Category", "SaveLocalizedValues");
     persistence.AddParameter("@entityId", entity.Id, CodeFluentPersistence.DefaultGuidValue);
     persistence.AddParameter("@Lcid", lcid);
     persistence.AddRawParameter("@IsDefault", isDefault);
     persistence.AddParameter("@Name", name, default(string));
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         SoftFluent.Samples.RedisCache.Category.SaveLocalizedValuesUpdateRowVersion(reader, entity, lcid, isDefault, name);
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
 }
예제 #18
0
 public static SoftFluent.Samples.AspNetIdentity1.User LoadByProviderKey(string providerKey)
 {
     if ((providerKey == default(string)))
     {
         return(null);
     }
     SoftFluent.Samples.AspNetIdentity1.User  user        = new SoftFluent.Samples.AspNetIdentity1.User();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.AspNetIdentity1.Constants.SoftFluent_Samples_AspNetIdentity1StoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "User", "LoadByProviderKey");
     persistence.AddParameter("@providerKey", providerKey);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             user.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             user.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(user);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #19
0
 public static ContactManager.User LoadByEmail(string email)
 {
     if ((email == default(string)))
     {
         return(null);
     }
     ContactManager.User user = new ContactManager.User();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(ContactManager.Constants.ContactManagerStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "User", "LoadByEmail");
     persistence.AddParameter("@Email", email, default(string));
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             user.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             user.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(user);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #20
0
 public static ContactManager.Address LoadByContact(int contactId)
 {
     if ((contactId == -1))
     {
         return(null);
     }
     ContactManager.Address address = new ContactManager.Address();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(ContactManager.Constants.ContactManagerStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Address", "LoadByContact");
     persistence.AddParameter("@ContactId", contactId);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             address.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             address.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(address);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #21
0
 public static SoftFluent.Samples.ExtendedSearch.Customer LoadById(int id)
 {
     if ((id == -1))
     {
         return(null);
     }
     SoftFluent.Samples.ExtendedSearch.Customer customer    = new SoftFluent.Samples.ExtendedSearch.Customer();
     CodeFluent.Runtime.CodeFluentPersistence   persistence = CodeFluentContext.Get(SoftFluent.Samples.ExtendedSearch.Constants.SoftFluent_Samples_ExtendedSearchStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Customer", "LoadById");
     persistence.AddParameter("@Id", id, ((int)(-1)));
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             customer.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             customer.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(customer);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #22
0
        /// <summary>
        /// retrieve all the configuration name for real-time charting.
        /// </summary>
        /// <returns></returns>
        public List <string> GetAllDPGrpNames()
        {
            string Function_Name = "GetAllDPGrpNames";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            List <string> dpGrpNames = new List <string>();
            string        localSQL   = " SELECT DISTINCT CONFIG_NAME FROM TRENDVIEWER_CONFIG order by config_name ";

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            if (drReader != null)
            {
                try
                {
                    while (drReader.Read())
                    {
                        if (!drReader.IsDBNull(0))
                        {
                            dpGrpNames.Add(DAOHelper.convert8859P1ToGB2312(drReader["CONFIG_NAME"].ToString()));
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
                }
                drReader.Close();
                drReader.Dispose();
                //SimpleDatabase.GetInstance().CloseCurrentSession();
            }


            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(dpGrpNames);
        }
예제 #23
0
 public static DigitalPicnik.List LoadById(System.Guid id)
 {
     if ((id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         return(null);
     }
     DigitalPicnik.List list = new DigitalPicnik.List();
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(DigitalPicnik.Constants.DigitalPicnikStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "List", "LoadById");
     persistence.AddParameter("@Id", id, CodeFluentPersistence.DefaultGuidValue);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             list.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             list.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(list);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #24
0
 public static SoftFluent.Samples.Thinktecture.IdentityServer.Role LoadByName(string name)
 {
     if ((name == default(string)))
     {
         return(null);
     }
     SoftFluent.Samples.Thinktecture.IdentityServer.Role role        = new SoftFluent.Samples.Thinktecture.IdentityServer.Role();
     CodeFluent.Runtime.CodeFluentPersistence            persistence = CodeFluentContext.Get(SoftFluent.Samples.Thinktecture.IdentityServer.Constants.SoftFluent_Samples_Thinktecture_IdentityServerStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Role", "LoadByName");
     persistence.AddParameter("@Name", name, default(string));
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             role.ReadRecord(reader, CodeFluent.Runtime.CodeFluentReloadOptions.Default);
             role.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
             return(role);
         }
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     return(null);
 }
예제 #25
0
        /// <summary>
        /// Returns Sample Group details of the specified Sample group Key.
        /// </summary>
        /// <param name="opcGrpID">Sample group key</param>
        /// <returns>Sample Group entity</returns>
        public EtyOPCSampleGroup GetOPCGrpByID(string opcGrpID)
        {
            string Function_Name = "GetOPCGrpByID";

            LogHelper.Trace(CLASS_NAME, Function_Name, string.Format("Function_Entered with params - {0}", opcGrpID));
            EtyOPCSampleGroup etyOPCSampleGrp = new EtyOPCSampleGroup();

            string localSQL = " SELECT SAMPLE_GRP_NAME,SAMPLE_GRP_DESC,SAMPLE_INTERVAL,INTERVAL_TYPE,START_TIME,DELTA_VALUE,DISABLE "
                              + " FROM OPC_DT_SAMPLE_GRP WHERE SAMPLE_GRP_ID = " + opcGrpID;

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            try
            {
                while (drReader != null && drReader.Read())
                {
                    if (!drReader.IsDBNull(drReader.GetOrdinal("SAMPLE_GRP_NAME")))
                    {
                        etyOPCSampleGrp.SampleGrpName = DAOHelper.convert8859P1ToGB2312(drReader["SAMPLE_GRP_NAME"].ToString());
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("SAMPLE_GRP_DESC")))
                    {
                        etyOPCSampleGrp.SampleGrpDescription = DAOHelper.convert8859P1ToGB2312(drReader["SAMPLE_GRP_DESC"].ToString());
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("SAMPLE_INTERVAL")))
                    {
                        etyOPCSampleGrp.Interval = Convert.ToInt32(drReader["SAMPLE_INTERVAL"]);
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("INTERVAL_TYPE")))
                    {
                        etyOPCSampleGrp.IntervalType = drReader["INTERVAL_TYPE"].ToString();
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("START_TIME")))
                    {
                        etyOPCSampleGrp.StartTime = drReader["START_TIME"].ToString();
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("DELTA_VALUE")))
                    {
                        etyOPCSampleGrp.DeltaValue = Convert.ToDouble(drReader["DELTA_VALUE"]);
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("DISABLE")))
                    {
                        etyOPCSampleGrp.Disabled = DAOHelper.ChangeStrToBool(drReader["DISABLE"].ToString());
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(etyOPCSampleGrp);
        }
예제 #26
0
        // CacheManager0
        private static SoftFluent.Samples.RedisCache.CategoryCollection CachePageLoadAll(bool useCache, int pageIndex, int pageSize, CodeFluent.Runtime.PageOptions pageOptions)
        {
            if ((pageIndex < 0))
            {
                pageIndex = 0;
            }
            if ((pageSize < 0))
            {
                if ((pageOptions != null))
                {
                    pageSize = pageOptions.DefaultPageSize;
                }
                else
                {
                    pageSize = int.MaxValue;
                }
            }
            SoftFluent.Samples.RedisCache.CategoryCollection ret = null;
            string cacheKey = null;

            if ((useCache == true))
            {
                cacheKey = CodeFluent.Runtime.Caching.SimpleCacheManager.BuildCacheKey("69d80ec93c1e64a950b65ea0729f45bc", pageIndex, pageSize, pageOptions);
                ret      = SoftFluent.Samples.RedisCache.Caching.CacheManager0.Manager.Get("SoftFluent.Samples.RedisCache.Category", cacheKey) as SoftFluent.Samples.RedisCache.CategoryCollection;
                if ((ret != null))
                {
                    return(ret);
                }
            }
            ret = new SoftFluent.Samples.RedisCache.CategoryCollection();
            System.Data.IDataReader reader = null;
            try
            {
                reader = SoftFluent.Samples.RedisCache.CategoryCollection.PageDataLoadAll(pageOptions);
                if ((reader == null))
                {
                    if ((useCache == true))
                    {
                        SoftFluent.Samples.RedisCache.Caching.CacheManager0.Manager.Add("SoftFluent.Samples.RedisCache.Category", cacheKey, ret, null);
                    }
                    return(ret);
                }
                ret.LoadAll(pageIndex, pageSize, pageOptions, reader);
            }
            finally
            {
                if ((reader != null))
                {
                    reader.Dispose();
                }
                CodeFluent.Runtime.CodeFluentPersistence.CompleteCommand(SoftFluent.Samples.RedisCache.Constants.SoftFluent_Samples_RedisCacheStoreName);
            }
            if ((useCache == true))
            {
                SoftFluent.Samples.RedisCache.Caching.CacheManager0.Manager.Add("SoftFluent.Samples.RedisCache.Category", cacheKey, ret, null);
            }
            return(ret);
        }
        /// <summary>
        /// Returns the DataPoints based specified datapoint name substring.
        /// </summary>
        /// <param name="opcServerName">Datapoint server name</param>
        /// <param name="DataPointNameSubstr"> Datapoint name substring to be queried</param>
        /// <returns>Datapoints</returns>
        public List <EtyDataLogDPTrend> GetDataPointByName(string opcServerName, string DataPointNameSubstr)
        {
            const string Function_Name = "GetDataPointByName";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");


            List <EtyDataLogDPTrend> etyDPTrendList = new List <EtyDataLogDPTrend>();

            string localSQL = "SELECT et.PKEY AS ENTITY_KEY,CONCAT(et.NAME,'.Value')as DP_NAME ,DP.DP_GRP_ID AS DP_GRP_ID FROM ENTITY et LEFT JOIN DATALOG_DP_TREND DP" +
                              " ON et.PKEY = DP.ENTITY_KEY WHERE TYPEKEY = (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'DataPoint')" +
                              " AND UPPER(et.NAME) LIKE '%" + DAOHelper.convertEscapeStringAndGB2312To8859P1(DataPointNameSubstr) + "%'";

            string LocationClauseStr = DAOHelper.CheckLocationAndAddSQL(COLUMN_ENTITY_LOCATIONKEY);

            if (LocationClauseStr.Length != 0)
            {
                localSQL += " AND" + LocationClauseStr;
            }

            localSQL += " ORDER BY DP_NAME ";

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            if (drReader != null)
            {
                try
                {
                    while (drReader.Read())
                    {
                        EtyDataLogDPTrend etyDPTrend = new EtyDataLogDPTrend();
                        if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_ENTITY_KEY)))
                        {
                            etyDPTrend.EntityKey = Convert.ToDouble(drReader[COLUMN_ENTITY_KEY]);
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_NAME)))
                        {
                            etyDPTrend.OPCDataPointName = DAOHelper.convert8859P1ToGB2312(drReader[COLUMN_NAME].ToString());
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_SAMPLE_GRP_ID)))
                        {
                            etyDPTrend.OPCSampleGrpId = Convert.ToDouble(drReader[COLUMN_SAMPLE_GRP_ID]);
                        }
                        etyDPTrendList.Add(etyDPTrend);
                    }
                }
                catch (System.Exception ex)
                {
                    LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
                }
                drReader.Close();
                drReader.Dispose();
                //SimpleDatabase.GetInstance().CloseCurrentSession();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(etyDPTrendList);
        }
예제 #28
0
 protected virtual bool BaseSave(bool force)
 {
     if ((this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.ToBeDeleted))
     {
         this.Delete();
         return(false);
     }
     CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saving, true);
     this.OnEntityAction(evt);
     if ((evt.Cancel == true))
     {
         return(false);
     }
     CodeFluentPersistence.ThrowIfDeleted(this);
     this.Validate();
     if (((force == false) &&
          (this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.Unchanged)))
     {
         return(false);
     }
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Json.NET.Constants.SoftFluent_Json_NETStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Customer", "Save");
     persistence.AddParameter("@Customer_Id", this.Id, ((int)(-1)));
     persistence.AddParameter("@Customer_Name", this.Name, default(string));
     persistence.AddParameter("@Customer_Address", this.Address, default(string));
     persistence.AddParameter("@Customer_City", this.City, default(string));
     persistence.AddParameter("@Customer_ZipCode", this.ZipCode, default(string));
     persistence.AddParameter("@Customer_Country", this.Country, default(string));
     persistence.AddParameter("@Customer_Phone", this.Phone, default(string));
     persistence.AddParameter("@Customer_Fax", this.Fax, default(string));
     persistence.AddParameter("@Customer_WebSite", this.WebSite, default(string));
     persistence.AddParameterEnumInt32("@Customer_Language", this.Language, SoftFluent.Json.NET.Language.French);
     persistence.AddParameterEnumInt32("@Customer_CustomerType", this.CustomerType, SoftFluent.Json.NET.CustomerType.Client);
     persistence.AddParameter("@_trackLastWriteUser", persistence.Context.User.Name);
     persistence.AddParameter("@_rowVersion", this.RowVersion);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             this.ReadRecordOnSave(reader);
         }
         CodeFluentPersistence.NextResults(reader);
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saved, false, false));
     this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
     return(true);
 }
예제 #29
0
 protected virtual bool BaseSave(bool force)
 {
     if ((this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.ToBeDeleted))
     {
         this.Delete();
         return(false);
     }
     CodeFluent.Runtime.CodeFluentEntityActionEventArgs evt = new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saving, true);
     this.OnEntityAction(evt);
     if ((evt.Cancel == true))
     {
         return(false);
     }
     CodeFluentPersistence.ThrowIfDeleted(this);
     this.Validate();
     if (((force == false) &&
          (this.EntityState == CodeFluent.Runtime.CodeFluentEntityState.Unchanged)))
     {
         return(false);
     }
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Json.NET.Constants.SoftFluent_Json_NETStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "Campaign", "Save");
     persistence.AddParameter("@Campaign_Id", this.Id, ((int)(-1)));
     persistence.AddParameter("@Campaign_Name", this.Name, default(string));
     persistence.AddParameterEnumInt32("@Campaign_State", this.State, SoftFluent.Json.NET.CampaignStateType.Conceived);
     persistence.AddParameter("@Campaign_Customer_Id", this.CustomerId, ((int)(-1)));
     persistence.AddParameter("@Campaign_Price", this.Price, CodeFluentPersistence.DefaultDecimalValue);
     persistence.AddParameter("@Campaign_PriceAllTaxIncluded", this.PriceAllTaxIncluded, CodeFluentPersistence.DefaultDecimalValue);
     persistence.AddParameter("@Campaign_DiscountRate", this.DiscountRate, CodeFluentPersistence.DefaultDecimalValue);
     persistence.AddParameter("@Campaign_ConceptionDate", this.ConceptionDate, CodeFluentPersistence.DefaultDateTimeValue);
     persistence.AddParameter("@Campaign_AddressedDate", this.AddressedDate, CodeFluentPersistence.DefaultDateTimeValue);
     persistence.AddParameter("@Campaign_PropositionDate", this.PropositionDate, CodeFluentPersistence.DefaultDateTimeValue);
     persistence.AddParameter("@Campaign_ConfirmationDate", this.ConfirmationDate, CodeFluentPersistence.DefaultDateTimeValue);
     persistence.AddParameter("@_trackLastWriteUser", persistence.Context.User.Name);
     persistence.AddParameter("@_rowVersion", this.RowVersion);
     System.Data.IDataReader reader = null;
     try
     {
         reader = persistence.ExecuteReader();
         if ((reader.Read() == true))
         {
             this.ReadRecordOnSave(reader);
         }
         CodeFluentPersistence.NextResults(reader);
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         persistence.CompleteCommand();
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.Saved, false, false));
     this.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
     return(true);
 }
        /// <summary>
        /// Returns all the Root Data Nodes.
        /// </summary>
        /// <returns>Root Data Nodes</returns>
        public List <EtyOPCDataNode> GetAllOPCDataNode(string serverRootName, string opcServerName)
        {
            const string Function_Name = "GetAllOPCDataNode";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");


            List <EtyOPCDataNode> OPCDataNodeList = new List <EtyOPCDataNode>();

            string localSQL = " SELECT KEYID,DT_NODE_NAME,DT_NODE_DESC " +
                              " FROM OPC_DT_NODE WHERE PKEYID  IN (SELECT DISTINCT PKEY FROM ENTITY WHERE NAME = '" + serverRootName + "') AND DISABLE = 'N' AND DATA_PT_SERVER = '" + opcServerName
                              + "' ORDER BY DT_NODE_NAME";

            //sql for getting from entity table

            /*string localSQL = " SELECT PKEY,NAME,DESCRIPTION" +
             *                      " FROM ENTITY WHERE TYPEKEY = (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'DataNode')"+
             *                      " AND PARENTKEY  IN (SELECT DISTINCT PKEY FROM ENTITY WHERE TYPEKEY IN (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'SCADAROOT'))"+
             *                      " ORDER BY NAME";*/

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);

            if (drReader != null)
            {
                try
                {
                    while (drReader.Read())
                    {
                        EtyOPCDataNode etyOPCDataNode = new EtyOPCDataNode();
                        if (!drReader.IsDBNull(drReader.GetOrdinal("KEYID")))
                        {
                            etyOPCDataNode.OPCDataNodeId = Convert.ToDouble(drReader["KEYID"]);
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal("DT_NODE_NAME")))
                        {
                            etyOPCDataNode.OPCDataNodeName = DAOHelper.convert8859P1ToGB2312(drReader["DT_NODE_NAME"].ToString());
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal("DT_NODE_DESC")))
                        {
                            etyOPCDataNode.OPCDataNodeDesc = DAOHelper.convert8859P1ToGB2312(drReader["DT_NODE_DESC"].ToString());
                        }
                        OPCDataNodeList.Add(etyOPCDataNode);
                    }
                }
                catch (System.Exception ex)
                {
                    LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
                }
                drReader.Close();
                drReader.Dispose();
            }


            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(OPCDataNodeList);
        }