示例#1
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);
        }
示例#2
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);
                }
            }
        }
示例#3
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);
                }
            }
        }
示例#4
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);
         }
     }
 }
示例#5
0
            public Dictionary <long, string> GetNumberingObjectPrefixes()
            {
                var nop = new Dictionary <long, string>();

                using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                {
                    try
                    {
                        DataTable dt = manager.SetSpCommand("dbo.spGetNextNumberPrefixes").ExecuteDataTable();
                        //ToDictionary(kv => Convert.ToInt64(kv.Key), kv => Utils.Str(kv.Value))

                        if ((dt != null) && (dt.Rows.Count > 0))
                        {
                            nop = dt.AsEnumerable().ToDictionary <DataRow, long, string>(row => Convert.ToInt64(row["idfsNumberName"]),
                                                                                         row => Utils.Str(row["strPrefix"]));
                        }

                        foreach (var num in NumberingObjectEnum.GetValues(typeof(NumberingObjectEnum)))
                        {
                            if (!nop.ContainsKey((long)num))
                            {
                                nop.Add((long)num, string.Empty);
                            }
                        }

                        return(nop);
                    }
                    catch (DataException e)
                    {
                        throw DbModelException.Create(null, e);
                    }
                }
            }
示例#6
0
        public static long getNewId(DbManagerProxy manager)
        {
            Exception lastEx = null;
            int       iDeadlockAttemptsCount = BaseSettings.DeadlockAttemptsCount;

            for (int iAttemptNumber = 0; iAttemptNumber < iDeadlockAttemptsCount; iAttemptNumber++)
            {
                try
                {
                    return(manager.SetSpCommand("dbo.spsysGetNewID", DBNull.Value).ExecuteScalar <long>(ScalarSourceType.OutputParameter));
                }
                catch (Exception e)
                {
                    lastEx = e;
                    if (!manager.IsTransactionStarted)
                    {
                        if (DbModelException.IsDeadlockException(e))
                        {
                            Thread.Sleep(BaseSettings.DeadlockDelay);
                            continue;
                        }
                    }

                    throw;
                }
            }

            throw lastEx;
        }
示例#7
0
        private void CreateClientEvent(EventType eventType, object objectId)
        {
            Dbg.ConditionalDebug(DebugDetalizationLevel.Low,
                                 "replication client raise replication event for object at {0}", DateTime.Now);

            using (DbManagerProxy manager = GetDbManager())
            {
                try
                {
                    manager.SetSpCommand("dbo.spEventLog_CreateNewEvent",
                                         manager.Parameter("@idfsEventTypeID", Convert.ToInt64(eventType)),
                                         manager.Parameter("@idfObjectID", objectId),
                                         manager.Parameter("@strInformationString", DBNull.Value),
                                         manager.Parameter("@strNote", DBNull.Value),
                                         manager.Parameter("@ClientID", m_ClientID),
                                         manager.Parameter("@datEventDatatime", DateTime.Now),
                                         manager.Parameter("@intProcessed", 0),
                                         manager.Parameter("@idfUserID", m_UserID),
                                         manager.Parameter(ParameterDirection.InputOutput, "@EventID", DBNull.Value, DbType.Int64),
                                         manager.Parameter("@idfsSite", m_SiteID),
                                         manager.Parameter("@idfsDiagnosis", DBNull.Value)
                                         ).ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    Dbg.Debug("event creation fail: {0}", ex);
                }
            }
        }
示例#8
0
 private long CreateAuditEvent
     (DbManagerProxy manager, AuditEventType auditEventType, EIDSSAuditObject eidssAuditObject, AuditTable auditTable,
     long?objectId)
 {
     try
     {
         DataAuditEvent = manager.SetSpCommand("dbo.spAudit_CreateNewEvent",
                                               auditEventType,
                                               eidssAuditObject,
                                               auditTable,
                                               objectId,
                                               DBNull.Value,
                                               DBNull.Value
                                               ).ExecuteScalar <long>(ScalarSourceType.OutputParameter, "idfDataAuditEvent");
         return(DataAuditEvent);
     }
     catch (Exception e)
     {
         if (e is DataException)
         {
             throw DbModelException.Create(null, e as DataException);
         }
         throw;
     }
 }
示例#9
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));
            }
        }
示例#10
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;
                }
            }
        }
示例#11
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);
        }
示例#12
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);
         }
     }
 }
示例#13
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);
         }
     }
 }
示例#14
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);
                    }
                }
            }
示例#15
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);
        }
示例#16
0
        private void GetSiteInfo()
        {
            if (m_IsInitialized && m_Language == ModelUserContext.CurrentLanguage)
            {
                return;
            }
            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
            {
                try
                {
                    using (DataTable dt = manager.SetSpCommand("dbo.spGetSiteInfo",
                                                               // todo: change to LangId when new database will be deployed
                                                               manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)
                                                               ).ExecuteDataTable())
                    {
                        if (dt.Rows.Count > 0)
                        {
                            DataRow row = dt.Rows[0];
                            m_CountryID       = (long)(row["idfsCountry"] == DBNull.Value ? 0 : row["idfsCountry"]);
                            m_CountryHascCode = (row["strHASCCountry"] == DBNull.Value ? "" : row["strHASCCountry"]).ToString();

                            m_CountryName      = (row["idfsRegion"] == DBNull.Value ? "" : row["strCountryName"]).ToString();
                            m_RegionID         = (long)(row["idfsRegion"] == DBNull.Value ? 0 : row["idfsRegion"]);
                            m_RayonID          = (long)(row["idfsRayon"] == DBNull.Value ? 0 : row["idfsRayon"]);
                            m_SiteID           = (long)(row["idfsSite"] == DBNull.Value ? 0 : row["idfsSite"]);
                            m_RealSiteID       = (long)(row["idfsRealSiteID"] == DBNull.Value ? 0 : row["idfsRealSiteID"]);
                            m_RealSitePrefix   = (row["strRealSitePrefix"] == DBNull.Value ? "" : row["strRealSitePrefix"]).ToString();
                            m_PermissionSiteID = (long)(row["idfsPermissionSite"] == DBNull.Value ? 1 : row["idfsPermissionSite"]);
                            m_SiteCode         = (row["strSiteID"] == DBNull.Value ? "" : row["strSiteID"]).ToString();
                            m_SiteHascCode     = (row["strHASCsiteID"] == DBNull.Value ? "" : row["strHASCsiteID"]).ToString();
                            m_SiteType         = row["idfsSiteType"] == DBNull.Value ? SiteType.Undefined : (SiteType)row["idfsSiteType"];
                            m_RealSiteType     = row["idfsRealSiteType"] == DBNull.Value ? SiteType.Undefined : (SiteType)row["idfsRealSiteType"];
                            m_SiteName         = (row["strSiteName"] == DBNull.Value ? "" : row["strSiteName"]).ToString();
                            m_SiteTypeName     = (row["strSiteTypeName"] == DBNull.Value ? "" : row["strSiteTypeName"]).ToString();
                            m_OrganizationName = (row["strOrganizationName"] == DBNull.Value ? "" : row["strOrganizationName"]).ToString();
                            m_OrganizationID   = (long)(row["idfOffice"] == DBNull.Value ? 0 : row["idfOffice"]);
                            m_IsInitialized    = true;
                            m_Language         = ModelUserContext.CurrentLanguage;
                        }
                        else
                        {
                            Clear();
                        }
                    }
                }
                catch (Exception e)
                {
                    if (e is DataException)
                    {
                        throw DbModelException.Create(null, e as DataException);
                    }
                    throw;
                }
            }
        }
示例#17
0
        public static void InvalidateQueryCache(long queryId, string lang = null)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;

                DbManager command = string.IsNullOrEmpty(lang)
                    ? manager.SetSpCommand("spAsQueryCacheInvalidate",
                                           manager.Parameter("idfQuery", queryId))
                    : manager.SetSpCommand("spAsQueryCacheInvalidate",
                                           manager.Parameter("idfQuery", queryId),
                                           manager.Parameter("strLanguage", lang));

                lock (m_DbSyncLock)
                {
                    command.ExecuteNonQuery();
                    avrTran.CommitTransaction();
                }
            }
        }
示例#18
0
        public static void ValidateLogin(DbManagerProxy manager, LoginInfo obj)
        {
            int ret =
                manager.SetSpCommand("dbo.spLogin_Validate", obj.idfUserID, obj.strAccountName)
                .ExecuteScalar <int>(ScalarSourceType.DataReader);

            if (ret != 0)
            {
                throw new ValidationModelException("msgLoginExist", "", "", new object[] { }, null, ValidationEventType.Error, obj);
            }
        }
示例#19
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());
        }
示例#20
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));
     }
 }
示例#21
0
        private static void DoFiltration()
        {
            if (!m_bFiltration)
            {
                m_bFiltration = true;
                ThreadPool.QueueUserWorkItem(c =>
                {
                    var waitHandles = new WaitHandle[] { m_CloseEvent, m_Event };
                    while (WaitHandle.WaitAny(waitHandles) != 0)
                    {
                        long id = 0;
                        lock (m_DataAuditEvents)
                        {
                            if (m_DataAuditEvents.Count > 0)
                            {
                                id = m_DataAuditEvents.Dequeue();
                            }
                        }

                        if (id != 0)
                        {
                            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                            {
                                try
                                {
                                    manager.SetSpCommand("dbo.spFiltered_CheckEvent", id).ExecuteNonQuery();
                                }
                                catch (Exception)
                                {
                                    // TODO add error handling here
                                }
                            }
                        }

                        lock (m_DataAuditEvents)
                        {
                            if (m_DataAuditEvents.Count > 0)
                            {
                                m_Event.Set();
                            }
                            else
                            {
                                m_CloseEvent.Set();
                            }
                        }
                    }

                    m_bFiltration = false;
                    return;
                }, null);
            }
        }
示例#22
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));
            }
        }
示例#23
0
 public static void CheckSamplesForGroupAccesionInExists(DbManagerProxy manager, LaboratorySectionItem obj)
 {
     if (obj.intNewMode == LabNewModeEnum.GroupAccessionIn)
     {
         var idfMaterial = manager.SetSpCommand("dbo.spLaboratorySection_GetByFieldBarcodeCount",
                                                obj.strFieldBarcode,
                                                obj.bSendToCurrentOffice ? EidssSiteContext.Instance.OrganizationID : 0).ExecuteScalar <long>();
         if (idfMaterial == 0)
         {
             throw new ValidationModelException("msgSamplesForGroupAccesionInNotFound", "", "", new object[] { }, null, ValidationEventType.Error, obj);
         }
     }
 }
示例#24
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);
                }
            }
示例#25
0
 public LaboratorySectionItem SetupLoad(DbManagerProxy manager)
 {
     if (!m_bSetupLoaded)
     {
         m_bSetupLoaded = true;
         Accessor.Instance(null)._SetupLoad(manager, this);
         if (BaseSettings.ValidateObject)
         {
             _isValid = (manager.SetSpCommand("spLabSection_Validate", Key).ExecuteScalar <int>(ScalarSourceType.ReturnValue) == 0);
         }
         DeepAcceptChanges();
     }
     return(this);
 }
示例#26
0
 public static DateTime?GetsQueryCacheUserRequestDate(long queryId)
 {
     using (var avrTran = new AvrDbTransaction())
     {
         DbManagerProxy manager = avrTran.Manager;
         DbManager      command = manager.SetSpCommand("spAsQueryCacheUserRequestDate", manager.Parameter("idfQuery", queryId));
         object         result;
         lock (m_DbSyncLock)
         {
             result = command.ExecuteScalar();
             avrTran.CommitTransaction();
         }
         return((result == null || result == DBNull.Value) ? null : (DateTime?)result);
     }
 }
示例#27
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);
                }
            }
示例#28
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);
                }
            }
示例#29
0
            protected virtual VetAggregateActionDetailed _SelectByKeyInternal(DbManagerProxy manager
                                                                              , Int64?idfAggrCase
                                                                              , on_action loading, on_action loaded
                                                                              )
            {
                MapResultSet[] sets = new MapResultSet[1];
                List <VetAggregateActionDetailed> objs = new List <VetAggregateActionDetailed>();

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

                try
                {
                    manager
                    .SetSpCommand("spVetAggregateActionDetailed_SelectDetail"
                                  , manager.Parameter("@idfAggrCase", idfAggrCase)
                                  )
                    .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);
                }
            }
示例#30
0
 private void CheckNotificationService()
 {
     using (DbManagerProxy manager = GetDbManager())
     {
         try
         {
             var dt = manager.SetSpCommand("dbo.spEventLog_IsNtfyServiceRunning",
                                           manager.Parameter("@idfsClient", m_ClientID)
                                           ).ExecuteNonQuery();
         }
         catch (Exception ex)
         {
             Dbg.Debug("event subscription is fail: {0}", ex);
         }
     }
 }