コード例 #1
0
        public override void CreateContextData()
        {
            if (DbManagerFactory.Factory == null)
            {
                return;
            }
            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(this))
            {
                try
                {
                    manager.SetSpCommand("dbo.spSetContextData",
                                         manager.Parameter("@idfEventID", DBNull.Value),
                                         manager.Parameter("@idfDataAuditEvent", DBNull.Value)
                                         ).ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    Dbg.Debug("error during context creating: {0}", e.ToString());

                    //Exception throwing is commented because this method  can be called before creating valid DbManagerFactory with correct connection.
                    //if (e is DataException)
                    //{
                    //    throw DbModelException.Create(e as DataException);
                    //}
                    //throw;
                }
            }
        }
コード例 #2
0
        public static BaseReferenceRaw[] GetList(long[] types)
        {
            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                var list = new List<BaseReferenceRaw>();
                foreach (long type in types)
                {
                    if (type == 19000019) // Diagnosis
                    {
                        list.AddRange(
                            manager.SetCommand(@"
select idfsBaseReference, idfsReferenceType, intHACode, strDefault 
from trtBaseReference 
inner join trtDiagnosis
	on trtDiagnosis.idfsDiagnosis = trtBaseReference.idfsBaseReference
where trtBaseReference.intRowStatus = 0 and idfsReferenceType = @idfsReferenceType
and trtDiagnosis.idfsUsingType = 10020001"
                                , manager.Parameter("@idfsReferenceType", type))
                                .ExecuteList<BaseReferenceRaw>());
                    }
                    else
                    {
                        list.AddRange(
                            manager.SetCommand(@"
select idfsBaseReference, idfsReferenceType, intHACode, strDefault 
from trtBaseReference 
where intRowStatus = 0 and idfsReferenceType = @idfsReferenceType"
                                , manager.Parameter("@idfsReferenceType", type))
                                .ExecuteList<BaseReferenceRaw>());
                    }
                }
                return list.ToArray();
            }
        }
コード例 #3
0
        public static QueryTableHeaderDTO GetQueryCacheHeader(long queryCacheId, bool isSchedulerCall, bool isArchive)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;
                DbManager      command = manager.SetSpCommand("spAsQueryCacheGetHeader",
                                                              manager.Parameter("idfQueryCache", queryCacheId),
                                                              manager.Parameter("blnSchedulerCall", isSchedulerCall),
                                                              manager.Parameter("blnUseArchivedData", isArchive));

                QueryTablePacketDTO headerPacket = new QueryTablePacketDTO {
                    IsArchive = isArchive
                };
                int packetCount = 0;
                lock (m_DbSyncLock)
                {
                    using (IDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            packetCount           = (int)reader["intPacketCount"];
                            headerPacket.RowCount = (int)reader["intQueryColumnCount"];
                            var binaryBody = (byte[])reader["blbQuerySchema"];
                            headerPacket.BinaryBody = new ChunkByteArray(binaryBody);
                        }
                    }

                    avrTran.CommitTransaction();
                }
                return(new QueryTableHeaderDTO(headerPacket, queryCacheId, packetCount));
            }
        }
コード例 #4
0
        public static LayoutDTO GetLayoutDTO(long layoutId)
        {
            LayoutDTO dto = new LayoutDTO(layoutId);

            try
            {
                using (DbManagerProxy manager = DbManagerFactory.Factory.Create())
                {
                    DbManager command = manager.SetSpCommand("spAsLayoutSelectLookup",
                                                             manager.Parameter("LangID", Localizer.lngEn),
                                                             manager.Parameter("LayoutID", layoutId));
                    using (IDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            dto.DefaultLayoutName = reader["strDefaultLayoutName"].ToString();
                            dto.QueryId           = (long)reader["idflQuery"];
                            dto.UseArchivedData   = (bool)reader["blnUseArchivedData"];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dto.DefaultLayoutName = ex.ToString();
            }
            return(dto);
        }
コード例 #5
0
        public static ViewDTO GetViewCache(long viewCacheId, bool isSchedulerCall)
        {
            ViewDTO view;

            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager   = avrTran.Manager;
                DbManager      headerCmd = manager.SetSpCommand("spAsViewCacheGetHeader",
                                                                manager.Parameter("idfViewCache", viewCacheId),
                                                                manager.Parameter("blnSchedulerCall", isSchedulerCall));

                lock (m_DbSyncLock)
                {
                    int packetCount;
                    using (IDataReader reader = headerCmd.ExecuteReader())
                    {
                        if (!reader.Read())
                        {
                            return(null);
                        }

                        BaseTableDTO viewTableDTO = new BaseTableDTO
                        {
                            Header =
                            {
                                RowCount   = (int)reader["intViewColumnCount"],
                                BinaryBody = new ChunkByteArray((byte[])reader["blbViewSchema"])
                            }
                        };

                        var binaryHeader = (byte[])reader["blbViewHeader"];
                        view = new ViewDTO(viewTableDTO, binaryHeader);

                        packetCount = (int)reader["intPacketCount"];
                    }
                    for (int packetNumber = 0; packetNumber < packetCount; packetNumber++)
                    {
                        DbManager packetCmd = manager.SetSpCommand("spAsViewCacheGetPacket",
                                                                   manager.Parameter("idfViewCache", viewCacheId),
                                                                   manager.Parameter("intViewCachePacketNumber", packetNumber));

                        var packetDTO = new BaseTablePacketDTO();
                        using (IDataReader packetReader = packetCmd.ExecuteReader())
                        {
                            if (!packetReader.Read())
                            {
                                return(null);
                            }

                            packetDTO.RowCount   = (int)packetReader["intTableRowCount"];
                            packetDTO.BinaryBody = new ChunkByteArray((byte[])packetReader["blbViewCachePacket"]);
                        }
                        view.BodyPackets.Add(packetDTO);
                    }

                    avrTran.CommitTransaction();
                }
            }
            return(view);
        }
コード例 #6
0
        public static long SaveQueryCacheWithoutTransaction(QueryTableModel zippedTable)
        {
            lock (m_DbSyncLock)
            {
                using (DbManagerProxy manager = DbManagerFactory.Factory[DatabaseType.Avr].Create())
                {
                    DbManager headerCommand = manager.SetSpCommand("spAsQueryCachePostHeader",
                                                                   manager.Parameter("idfQuery", zippedTable.QueryId),
                                                                   manager.Parameter("strLanguage", zippedTable.Language),
                                                                   manager.Parameter("intQueryColumnCount", zippedTable.Header.RowCount),
                                                                   manager.Parameter("blbQuerySchema", zippedTable.Header.BinaryBody.ToArray()),
                                                                   manager.Parameter("blnUseArchivedData", zippedTable.UseArchivedData)
                                                                   );

                    var queryCasheId = (long)headerCommand.ExecuteScalar();
                    for (int i = 0; i < zippedTable.BodyPackets.Count; i++)
                    {
                        DbManager command = manager.SetSpCommand("spAsQueryCachePostPacket",
                                                                 manager.Parameter("idfQueryCache", queryCasheId),
                                                                 manager.Parameter("intQueryCachePacketNumber", i),
                                                                 manager.Parameter("intPacketRowCount", zippedTable.BodyPackets[i].RowCount),
                                                                 manager.Parameter("blbQueryCachePacket", zippedTable.BodyPackets[i].BinaryBody.ToArray()),
                                                                 manager.Parameter("blnArchivedData", zippedTable.BodyPackets[i].IsArchive)
                                                                 );

                        command.ExecuteNonQuery();
                    }

                    return(queryCasheId);
                }
            }
        }
コード例 #7
0
            public LoginResult LogInOrgOutput(string organization, string userName, string password,
                                              Action onBeforeLogin = null, Action onSuccess = null)
            {
                var resultOrg  = organization;
                int resultCode = CheckVersion();

                if (resultCode != 0)
                {
                    return(new LoginResult(resultCode, resultOrg));
                }

                if (onBeforeLogin != null)
                {
                    onBeforeLogin();
                }

                object hash = null;

                resultCode = EvaluateHash(password, ref hash);
                if (resultCode != 0)
                {
                    return(new LoginResult(resultCode, resultOrg));
                }
                using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                {
                    try
                    {
                        DataTable dt = manager.SetSpCommand("dbo.spLoginUser",
                                                            manager.Parameter("@UserName", userName),
                                                            manager.Parameter("@Password", hash, DbType.Binary),
                                                            manager.Parameter(ParameterDirection.Output, "@Result", 0)
                                                            ).ExecuteDataTable();
                        resultCode = Convert.ToInt32(manager.Parameter("@Result").Value);
                        if (resultCode == 0)
                        {
                            resultOrg = Utils.Str(dt.Rows[0]["strLoginOrganization"]);
                            if (BaseSettings.UseOrganizationInLogin &&
                                Utils.Str(organization).ToLowerInvariant() != resultOrg.ToLowerInvariant())
                            {
                                return(new LoginResult(2, resultOrg));
                            }

                            if (onSuccess != null)
                            {
                                onSuccess();
                            }

                            PerformLogin(dt);
                        }
                        return(new LoginResult(resultCode, resultOrg));
                    }
                    catch (DataException e)
                    {
                        throw DbModelException.Create(null, e);
                    }
                }
            }
コード例 #8
0
        public static long SaveViewCacheWithoutTransaction(long queryCacheId, long layoutId, ViewDTO zippedTable)
        {
            lock (m_DbSyncLock)
            {
                using (DbManagerProxy manager = DbManagerFactory.Factory[DatabaseType.Avr].Create())
                {
                    DbManager headerCommand = manager.SetSpCommand("spAsViewCachePostHeader",
                                                                   manager.Parameter("idfQueryCache", queryCacheId),
                                                                   manager.Parameter("idfLayout", layoutId),
                                                                   manager.Parameter("blbViewSchema", zippedTable.Header.BinaryBody.ToArray()),
                                                                   manager.Parameter("blbViewHeader", zippedTable.BinaryViewHeader),
                                                                   manager.Parameter("intViewColumnCount", zippedTable.Header.RowCount)
                                                                   );

                    var viewCasheId = (long)headerCommand.ExecuteScalar();
                    for (int i = 0; i < zippedTable.BodyPackets.Count; i++)
                    {
                        DbManager command = manager.SetSpCommand("spAsViewCachePostPacket",
                                                                 manager.Parameter("idfViewCache", viewCasheId),
                                                                 manager.Parameter("intViewCachePacketNumber", i),
                                                                 manager.Parameter("intPacketRowCount", zippedTable.BodyPackets[i].RowCount),
                                                                 manager.Parameter("blbViewCachePacket", zippedTable.BodyPackets[i].BinaryBody.ToArray())
                                                                 );

                        command.ExecuteNonQuery();
                    }

                    return(viewCasheId);
                }
            }
        }
コード例 #9
0
        public static GisBaseReferenceTranslationRaw[] GetAll(string[] langs)
        {
            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                var list = new List<GisBaseReferenceTranslationRaw>();
                foreach (string lang in langs)
                {
                    list.AddRange(manager.SetCommand(@"
select b.idfsGISBaseReference as idfsBaseReference, o.strTextString as strTranslation, @lang as strLanguage
from gisBaseReference b
inner join gisCountry c on c.idfsCountry = b.idfsGISBaseReference
left join	dbo.gisStringNameTranslation as o
    on b.idfsGISBaseReference = o.idfsGISBaseReference and o.idfsLanguage = dbo.fnGetLanguageCode(@lang)
where b.intRowStatus = 0 and c.idfsCountry = @idfsCountry"
                        , manager.Parameter("@idfsCountry", EidssSiteContext.Instance.CountryID), manager.Parameter("@lang", lang))
                                      .ExecuteList<GisBaseReferenceTranslationRaw>());

                    list.AddRange(manager.SetCommand(@"
select b.idfsGISBaseReference as idfsBaseReference, o.strTextString as strTranslation, @lang as strLanguage
from gisBaseReference b
inner join gisRegion c on c.idfsRegion = b.idfsGISBaseReference
left join	dbo.gisStringNameTranslation as o
    on b.idfsGISBaseReference = o.idfsGISBaseReference and o.idfsLanguage = dbo.fnGetLanguageCode(@lang)
where b.intRowStatus = 0 and c.idfsCountry = @idfsCountry"
                        , manager.Parameter("@idfsCountry", EidssSiteContext.Instance.CountryID), manager.Parameter("@lang", lang))
                                      .ExecuteList<GisBaseReferenceTranslationRaw>());

                    list.AddRange(manager.SetCommand(@"
select b.idfsGISBaseReference as idfsBaseReference, o.strTextString as strTranslation, @lang as strLanguage
from gisBaseReference b
inner join gisRayon d on d.idfsRayon = b.idfsGISBaseReference
inner join gisRegion c on c.idfsRegion = d.idfsRegion
left join	dbo.gisStringNameTranslation as o
    on b.idfsGISBaseReference = o.idfsGISBaseReference and o.idfsLanguage = dbo.fnGetLanguageCode(@lang)
where b.intRowStatus = 0 and c.idfsCountry = @idfsCountry"
                        , manager.Parameter("@idfsCountry", EidssSiteContext.Instance.CountryID), manager.Parameter("@lang", lang))
                                      .ExecuteList<GisBaseReferenceTranslationRaw>());

                    list.AddRange(manager.SetCommand(@"
select b.idfsGISBaseReference as idfsBaseReference, o.strTextString as strTranslation, @lang as strLanguage
from gisBaseReference b
inner join gisSettlement e on e.idfsSettlement = b.idfsGISBaseReference
inner join gisRayon d on d.idfsRayon = e.idfsRayon
inner join gisRegion c on c.idfsRegion = d.idfsRegion
left join	dbo.gisStringNameTranslation as o
    on b.idfsGISBaseReference = o.idfsGISBaseReference and o.idfsLanguage = dbo.fnGetLanguageCode(@lang)
where b.intRowStatus = 0 and c.idfsCountry = @idfsCountry"
                        , manager.Parameter("@idfsCountry", EidssSiteContext.Instance.CountryID), manager.Parameter("@lang", lang))
                                      .ExecuteList<GisBaseReferenceTranslationRaw>());

                }
                return list.ToArray();
            }
        }
コード例 #10
0
        public static DataTable GetQueryFieldTranslationLookup(DbManagerProxy manager, long queryId, string lang)
        {
            Utils.CheckNotNull(manager, "manager");
            Utils.CheckNotNullOrEmpty(lang, "lang");

            DbManager command = manager.SetSpCommand("spAsQuerySearchFieldSelectLookup",
                                                     manager.Parameter("LangID", lang),
                                                     manager.Parameter("QueryID", queryId));

            return(command.ExecuteDataTable());
        }
コード例 #11
0
 protected internal static DataView GetDeniedReportsLookup()
 {
     using (DbManagerProxy manager = DbManagerFactory.Factory.Create())
     {
         DbManager command = manager.SetSpCommand("spRepDeniedReportsLookup",
                                                  manager.Parameter("SiteID", EidssSiteContext.Instance.SiteID),
                                                  manager.Parameter("UserID", Convert.ToInt64(EidssUserContext.User.ID))
                                                  );
         DataTable dataTable = command.ExecuteDataTable();
         return(new DataView(dataTable));
     }
 }
コード例 #12
0
        public static FarmPanel LivestockFarmRefreshFromRoot(long idfRootFarm, long idfFarm)
        {
            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
            {
                //refresh normal farm's data from root
                manager.SetSpCommand("spFarm_CopyRootToNormal",
                                     manager.Parameter("idfRootFarm", idfRootFarm),
                                     manager.Parameter("idfTargetFarm", idfFarm),
                                     manager.Parameter("idfMonitoringSession", DBNull.Value)).ExecuteNonQuery();

                return(FarmPanel.Accessor.Instance(null).SelectByKey(manager, idfFarm, (int)HACode.Livestock));
            }
        }
コード例 #13
0
            protected virtual LinkObject _SelectByKeyInternal(DbManagerProxy manager
                                                              , Int64?ID
                                                              , on_action loading, on_action loaded
                                                              )
            {
                MapResultSet[]    sets = new MapResultSet[1];
                List <LinkObject> objs = new List <LinkObject>();

                sets[0] = new MapResultSet(typeof(LinkObject), objs);
                LinkObject obj = null;

                try
                {
                    manager
                    .SetSpCommand("spLinkObject_SelectDetail"
                                  , manager.Parameter("@ID", ID)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);

                    if (objs.Count == 0)
                    {
                        return(null);
                    }

                    obj      = objs[0];
                    obj.m_CS = m_CS;


                    if (loading != null)
                    {
                        loading(obj);
                    }
                    _SetupLoad(manager, obj);


                    //obj._setParent();
                    if (loaded != null)
                    {
                        loaded(obj);
                    }
                    obj.Loaded(manager);
                    return(obj);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(obj, e);
                }
            }
コード例 #14
0
            protected void CheckDuplicates(DbManagerProxy manager, AggregateCaseHeader h)
            {
                int ret = manager.SetSpCommand("dbo.spAggregateCaseExists",
                                               manager.Parameter("@StartDate", h.datStartDateCalc),
                                               manager.Parameter("@FinishDate", h.datFinishDateCalc),
                                               manager.Parameter("@AdminUnit", h.idfsAdministrativeUnitCalc),
                                               manager.Parameter("@AggrCaseType", h.idfsAggrCaseType),
                                               manager.Parameter("@CaseID", h.idfAggrCase)
                                               ).ExecuteScalar <int>(ScalarSourceType.ReturnValue);

                if (ret == 1)
                {
                    throw new ValidationModelException("Agg_Case_already_exists", "", "", null, null, ValidationEventType.Error, h);
                }
            }
コード例 #15
0
        public static GisBaseReferenceRaw[] GetAll()
        {
            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                var list = new List<GisBaseReferenceRaw>();

                list.AddRange(manager.SetCommand(@"
select b.idfsGISBaseReference as idfsBaseReference, b.idfsGISReferenceType as idfsReferenceType, 
c.idfsCountry as idfsCountry, 0 as idfsRegion, 0 as idfsRayon, b.strDefault as strDefault
from gisBaseReference b
inner join gisCountry c on c.idfsCountry = b.idfsGISBaseReference
where b.intRowStatus = 0 and c.idfsCountry = @idfsCountry"
                    , manager.Parameter("@idfsCountry", EidssSiteContext.Instance.CountryID))
                                  .ExecuteList<GisBaseReferenceRaw>());

                list.AddRange(manager.SetCommand(@"
select b.idfsGISBaseReference as idfsBaseReference, b.idfsGISReferenceType as idfsReferenceType, 
c.idfsCountry as idfsCountry, c.idfsRegion as idfsRegion, 0 as idfsRayon, b.strDefault as strDefault
from gisBaseReference b
inner join gisRegion c on c.idfsRegion = b.idfsGISBaseReference
where b.intRowStatus = 0 and c.idfsCountry = @idfsCountry"
                    , manager.Parameter("@idfsCountry", EidssSiteContext.Instance.CountryID))
                                  .ExecuteList<GisBaseReferenceRaw>());

                list.AddRange(manager.SetCommand(@"
select b.idfsGISBaseReference as idfsBaseReference, b.idfsGISReferenceType as idfsReferenceType, 
c.idfsCountry as idfsCountry, d.idfsRegion as idfsRegion, d.idfsRayon as idfsRayon, b.strDefault as strDefault
from gisBaseReference b
inner join gisRayon d on d.idfsRayon = b.idfsGISBaseReference
inner join gisRegion c on c.idfsRegion = d.idfsRegion
where b.intRowStatus = 0 and c.idfsCountry = @idfsCountry"
                    , manager.Parameter("@idfsCountry", EidssSiteContext.Instance.CountryID))
                                  .ExecuteList<GisBaseReferenceRaw>());

                list.AddRange(manager.SetCommand(@"
select b.idfsGISBaseReference as idfsBaseReference, b.idfsGISReferenceType as idfsReferenceType, 
c.idfsCountry as idfsCountry, c.idfsRegion as idfsRegion, d.idfsRayon as idfsRayon, b.strDefault as strDefault
from gisBaseReference b
inner join gisSettlement e on e.idfsSettlement = b.idfsGISBaseReference
inner join gisRayon d on d.idfsRayon = e.idfsRayon
inner join gisRegion c on c.idfsRegion = d.idfsRegion
where b.intRowStatus = 0 and c.idfsCountry = @idfsCountry"
                    , manager.Parameter("@idfsCountry", EidssSiteContext.Instance.CountryID))
                                  .ExecuteList<GisBaseReferenceRaw>());

                return list.ToArray();
            }
        }
コード例 #16
0
            public virtual List <TestDiagnosisLookup> _SelectListInternal(DbManagerProxy manager
                                                                          , Int64?idfMaterial
                                                                          , Int64?idfCase
                                                                          , Int64?idfCaseType
                                                                          , on_action loading, on_action loaded
                                                                          )
            {
                TestDiagnosisLookup _obj = null;

                try
                {
                    MapResultSet[]             sets = new MapResultSet[1];
                    List <TestDiagnosisLookup> objs = new List <TestDiagnosisLookup>();
                    sets[0] = new MapResultSet(typeof(TestDiagnosisLookup), objs);

                    manager
                    .SetSpCommand("spLabTestEditable_GetSampleDiagnosis"
                                  , manager.Parameter("@idfMaterial", idfMaterial)
                                  , manager.Parameter("@idfCase", idfCase)
                                  , manager.Parameter("@idfCaseType", idfCaseType)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
コード例 #17
0
ファイル: DataHelper.cs プロジェクト: EIDSS/EIDSS6.1.0.45
        public static int GetQueryFieldsCount(long queryId)
        {
            using (DbManagerProxy manager = DbManagerFactory.Factory.Create())
            {
                DbManager command = manager.SetCommand(
                    @"   select sum(t.fieldCount) from
                               (
                                     select 
	                                    case 
		                                    when sf.idfsGISReferenceType is not null then 2 else 1
	                                    end as fieldCount
                                     from tasQuerySearchField qsf
                                     inner join tasQuerySearchObject qso
                                     on qsf.idfQuerySearchObject = qso.idfQuerySearchObject
                                     inner join tasSearchField sf
                                     on sf.idfsSearchField = qsf.idfsSearchField
                                     where qso.idflQuery = @idflQuery
                                ) as t",
                    manager.Parameter("idflQuery", queryId)
                    );

                var count = (int)command.ExecuteScalar();
                return(count);
            }
        }
コード例 #18
0
        public static T GetInnerQueryResult <T>(DbManagerProxy manager, string queryString, string lang, Func <DbManager, T> commandExecutor)
        {
            Utils.CheckNotNull(manager, "manager");
            Utils.CheckNotNull(lang, "lang");
            Utils.CheckNotNullOrEmpty(queryString, "queryString");
            Utils.CheckNotNull(commandExecutor, "commandExecutor");

            int oldTimeout = manager.CommandTimeout;

            try
            {
                manager.CommandTimeout = m_CommandTimeout;
                manager.BeginTransaction(IsolationLevel.ReadUncommitted);
                DbManager command = manager.SetCommand(queryString,
                                                       manager.Parameter("LangID", lang));
                T result = commandExecutor(command);

                manager.CommitTransaction();
                return(result);
            }
            catch (Exception)
            {
                manager.RollbackTransaction();
                throw;
            }
            finally
            {
                manager.CommandTimeout = oldTimeout;
            }
        }
コード例 #19
0
 public bool ValidatePassword(string password)
 {
     using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
     {
         try
         {
             DataSet ds = manager.SetSpCommand("dbo.spSecurityPolicy_List",
                                               manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)
                                               ).ExecuteDataSet();
             if (ds == null || ds.Tables.Count < 2 || ds.Tables[0].Rows.Count == 0)
             {
                 return(false);
             }
             DataTable dt = ds.Tables[0];
             if ((int)dt.Rows[0]["intForcePasswordComplexity"] == 0)
             {
                 return(true);
             }
             dt = ds.Tables[1];
             if (dt.Rows.Count == 0)
             {
                 return(true);
             }
             string          passwordExpression = Utils.Str(dt.Rows[0]["strAlphabet"], "");
             MatchCollection matches            = Regex.Matches(password, passwordExpression);
             return(matches.Count > 0);
         }
         catch (Exception e)
         {
             Dbg.Debug("error during password validation: {0}", e.ToString());
             return(false);
         }
     }
 }
コード例 #20
0
 public int GetIntPolicyValue(string name, int defaultValue)
 {
     using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
     {
         try
         {
             DataTable dt = manager.SetSpCommand("dbo.spSecurityPolicy_List",
                                                 manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)
                                                 ).ExecuteDataTable();
             if (dt == null || dt.Rows.Count == 0)
             {
                 return(defaultValue);
             }
             return((int)dt.Rows[0][name]);
         }
         catch (Exception e)
         {
             Dbg.Debug(
                 "error during retrieving security policy value {0}, default value {1} is returned. \r\n{2}",
                 name,
                 defaultValue, e.ToString());
             return(defaultValue);
         }
     }
 }
コード例 #21
0
 private Dictionary <long, List <EIDSSPermissionObject> > GetAvrQueryPermissions()
 {
     using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
     {
         try
         {
             var       avrPermissions = new Dictionary <long, List <EIDSSPermissionObject> >();
             DataTable table          = manager.SetSpCommand("dbo.spAsSearchObjectToSystemFunctionSelectLookup",
                                                             manager.Parameter("@LangID", Localizer.lngEn)
                                                             ).ExecuteDataTable();
             foreach (DataRow row in table.Rows)
             {
                 var key = (long)row["idfsSearchObject"];
                 if (!avrPermissions.ContainsKey(key))
                 {
                     avrPermissions.Add(key, new List <EIDSSPermissionObject>());
                 }
                 avrPermissions[key].Add((EIDSSPermissionObject)row["idfsSystemFunction"]);
             }
             return(avrPermissions);
         }
         catch (DataException e)
         {
             throw DbModelException.Create(null, e);
         }
     }
 }
コード例 #22
0
        public static List <string> GetSubQueryFunctionName(DbManagerProxy manager, long queryId)
        {
            Utils.CheckNotNull(manager, "manager");

            //  return  new List<string>();
            DbManager command = manager.SetSpCommand("spAsSubQuerySelectLookup",
                                                     manager.Parameter("LangID", Localizer.DefaultLanguage),
                                                     manager.Parameter("ID", queryId));
            DataTable table  = command.ExecuteDataTable();
            var       result = new List <string>();

            foreach (DataRow row in table.Rows)
            {
                result.Add(Utils.Str(row["strSubQueryFunctionName"]));
            }
            return(result);
        }
コード例 #23
0
        private static void UpdateQueryRefreshDate(long?id, int days)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;
                DbManager      command = manager.SetCommand(
                    @"      update QueryCache
                            set datQueryRefresh = DATEADD(day, @intDays, GETDATE())
                            where [idfQueryCache] = @idflQueryCache",
                    manager.Parameter("idflQueryCache", id),
                    manager.Parameter("intDays", days)
                    );

                command.ExecuteNonQuery();
                avrTran.CommitTransaction();
            }
        }
コード例 #24
0
            public virtual List <RegionForAzReportLookup> _SelectListInternal(DbManagerProxy manager
                                                                              , Int64?CountryID
                                                                              , Int64?ID
                                                                              , on_action loading, on_action loaded
                                                                              )
            {
                RegionForAzReportLookup _obj = null;

                try
                {
                    MapResultSet[] sets = new MapResultSet[1];
                    List <RegionForAzReportLookup> objs = new List <RegionForAzReportLookup>();
                    sets[0] = new MapResultSet(typeof(RegionForAzReportLookup), objs);

                    manager
                    .SetSpCommand("spRegionAz_SelectLookup"
                                  , manager.Parameter("@CountryID", CountryID)
                                  , manager.Parameter("@ID", ID)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
コード例 #25
0
        public void Save()
        {
            string data = Serialize();

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
            {
                try
                {
                    manager.SetSpCommand("dbo.spUserOptionsSave",
                                         manager.Parameter("@UserID", EidssUserContext.User.ID),
                                         manager.Parameter("@strOptions", data)
                                         ).ExecuteNonQuery();
                }
                catch (Exception)
                {
                }
            }
        }
コード例 #26
0
            public virtual List <Lookup2ParamTable> _SelectListInternal(DbManagerProxy manager
                                                                        , Int32?ParentID
                                                                        , on_action loading, on_action loaded
                                                                        )
            {
                Lookup2ParamTable _obj = null;

                try
                {
                    MapResultSet[]           sets = new MapResultSet[1];
                    List <Lookup2ParamTable> objs = new List <Lookup2ParamTable>();
                    sets[0] = new MapResultSet(typeof(Lookup2ParamTable), objs);

                    manager
                    .SetSpCommand("spLookupTable2Param_SelectLookup"
                                  , manager.Parameter("@ParentID", ParentID)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
コード例 #27
0
            public virtual List <AnimalAgeLookup> _SelectListInternal(DbManagerProxy manager
                                                                      , String idfsSpecies
                                                                      , on_action loading, on_action loaded
                                                                      )
            {
                AnimalAgeLookup _obj = null;

                try
                {
                    MapResultSet[]         sets = new MapResultSet[1];
                    List <AnimalAgeLookup> objs = new List <AnimalAgeLookup>();
                    sets[0] = new MapResultSet(typeof(AnimalAgeLookup), objs);

                    manager
                    .SetSpCommand("spAnimalAgeList_SelectLookup"
                                  , manager.Parameter("@idfsSpecies", idfsSpecies)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
コード例 #28
0
            public virtual List <HACodeLookup> _SelectListInternal(DbManagerProxy manager
                                                                   , Int32?intHACodeMask
                                                                   , on_action loading, on_action loaded
                                                                   )
            {
                HACodeLookup _obj = null;

                try
                {
                    MapResultSet[]      sets = new MapResultSet[1];
                    List <HACodeLookup> objs = new List <HACodeLookup>();
                    sets[0] = new MapResultSet(typeof(HACodeLookup), objs);

                    manager
                    .SetSpCommand("spHACode_SelectCheckList"
                                  , manager.Parameter("@intHACodeMask", intHACodeMask)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
コード例 #29
0
            public virtual List <SmphBaseReferenceTranslationLookup> _SelectListInternal(DbManagerProxy manager
                                                                                         , Int64?idfsReferenceType
                                                                                         , String lang
                                                                                         , on_action loading, on_action loaded
                                                                                         )
            {
                SmphBaseReferenceTranslationLookup _obj = null;

                try
                {
                    MapResultSet[] sets = new MapResultSet[1];
                    List <SmphBaseReferenceTranslationLookup> objs = new List <SmphBaseReferenceTranslationLookup>();
                    sets[0] = new MapResultSet(typeof(SmphBaseReferenceTranslationLookup), objs);

                    manager
                    .SetSpCommand("spSmphBaseReferenceTranslation_SelectLookup"
                                  , manager.Parameter("@idfsReferenceType", idfsReferenceType)
                                  , manager.Parameter("@lang", lang)
                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
コード例 #30
0
        public static string GetQueryFunctionText(DbManagerProxy manager, string spName)
        {
            Utils.CheckNotNull(manager, "manager");
            Utils.CheckNotNullOrEmpty(spName, "spName");

            DbManager command      = manager.SetSpCommand("spAsGetFunctionText", manager.Parameter("name", spName));
            var       functionText = command.ExecuteScalar <string>();

            return(functionText);
        }