public virtual List <Lookup1Table> _SelectListInternal(DbManagerProxy manager , on_action loading, on_action loaded ) { Lookup1Table _obj = null; try { MapResultSet[] sets = new MapResultSet[1]; List <Lookup1Table> objs = new List <Lookup1Table>(); sets[0] = new MapResultSet(typeof(Lookup1Table), objs); manager .SetSpCommand("spLookupTable1_SelectLookup" , 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); } }
public virtual List <SmphMandatoryFieldsLookup> _SelectListInternal(DbManagerProxy manager , Int64?idfCustomizationPackage , on_action loading, on_action loaded ) { SmphMandatoryFieldsLookup _obj = null; try { MapResultSet[] sets = new MapResultSet[1]; List <SmphMandatoryFieldsLookup> objs = new List <SmphMandatoryFieldsLookup>(); sets[0] = new MapResultSet(typeof(SmphMandatoryFieldsLookup), objs); manager .SetSpCommand("spSmphMandatoryFields_SelectLookup" , manager.Parameter("@idfCustomizationPackage", idfCustomizationPackage) ) .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); } }
public virtual List <PostalCodeLookup> _SelectListInternal(DbManagerProxy manager , Int64?SettlementID , on_action loading, on_action loaded ) { PostalCodeLookup _obj = null; try { MapResultSet[] sets = new MapResultSet[1]; List <PostalCodeLookup> objs = new List <PostalCodeLookup>(); sets[0] = new MapResultSet(typeof(PostalCodeLookup), objs); manager .SetSpCommand("spPostalCode_SelectLookup" , manager.Parameter("@SettlementID", SettlementID) ) .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); } }
public virtual List <SmphOrganizationTranslationLookup> _SelectListInternal(DbManagerProxy manager , String lang , on_action loading, on_action loaded ) { SmphOrganizationTranslationLookup _obj = null; try { MapResultSet[] sets = new MapResultSet[1]; List <SmphOrganizationTranslationLookup> objs = new List <SmphOrganizationTranslationLookup>(); sets[0] = new MapResultSet(typeof(SmphOrganizationTranslationLookup), objs); manager .SetSpCommand("spSmphOrganizationTranslation_SelectLookup" , 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); } }
public virtual List <RuleAction> _SelectListInternal(DbManagerProxy manager , Int64?idfsRule , on_action loading, on_action loaded ) { RuleAction _obj = null; try { MapResultSet[] sets = new MapResultSet[1]; List <RuleAction> objs = new List <RuleAction>(); sets[0] = new MapResultSet(typeof(RuleAction), objs); manager .SetSpCommand("spFFGetRuleParameterForAction" , manager.Parameter("@idfsRule", idfsRule) ) .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); } }
private List <EidssSiteOptions> GetSiteOptions(string spName) { Utils.CheckNotNullOrEmpty(spName, "spName"); using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { try { List <EidssSiteOptions> eidssSiteOptionses = manager.SetSpCommand(spName).ExecuteList <EidssSiteOptions>(); return(eidssSiteOptionses); } catch (Exception e) { if (e is DataException) { throw DbModelException.Create(null, e as DataException); } throw; } } }
public virtual List<FFTemplateLookup> _SelectListInternal(DbManagerProxy manager , Int64? idfsFormTemplate , Int64? idfsFormType , on_action loading, on_action loaded ) { FFTemplateLookup _obj = null; try { MapResultSet[] sets = new MapResultSet[1]; List<FFTemplateLookup> objs = new List<FFTemplateLookup>(); sets[0] = new MapResultSet(typeof(FFTemplateLookup), objs); manager .SetSpCommand("spFFGetTemplates" , manager.Parameter("@idfsFormTemplate", idfsFormTemplate) , manager.Parameter("@idfsFormType", idfsFormType) , 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); } }
public int ChangePassword(string organization, string userName, string currentPassword, string newPassword) { int res = CheckVersion(); if (res != 0) { return(res); } object hash = null; res = EvaluateHash(currentPassword, ref hash); if (res != 0) { return(res); } using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { try { DataTable dt = manager.SetSpCommand("dbo.spChangePassword", manager.Parameter("@Organization", organization), manager.Parameter("@UserName", userName), manager.Parameter("@CurrentPassword", hash), manager.Parameter("@NewPassword", PasswordHash(newPassword)), manager.Parameter(ParameterDirection.Output, "@Result", 0) ).ExecuteDataTable(); res = Convert.ToInt32(manager.Parameter("@Result").Value); if (res == 0) { SetEidssUser(dt); } return(res); } catch (DataException e) { throw DbModelException.Create(null, e); } } }
private List <long> GetDenyPermissionOnDiagnosis(object userId) { using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { try { DataTable table = manager.SetCommand( "select idfsDiagnosis from dbo.fnGetPermissionOnDiagnosis(@ObjectOperation, @Employee) where intPermission = 1", manager.Parameter("@ObjectOperation", Convert.ToInt64(ObjectOperation.Read)), manager.Parameter("@Employee", userId) ).ExecuteDataTable(); return((from DataRow row in table.Rows select(long) row["idfsDiagnosis"]).ToList()); } catch (DataException e) { throw DbModelException.Create(null, e); } } }
private void CreateEvent(DbManagerProxy manager, int isProcessed, EventType eventType, long?objectIdent, string info) { try { Type cacheManager = Type.GetType("bv.common.db.Core.LookupCache, bvdb_common"); if (cacheManager != null) { MethodInfo method = cacheManager.GetMethod("Refresh", BindingFlags.Static | BindingFlags.Public, null, new[] { typeof(string), typeof(bool), typeof(IDbTransaction), typeof(object) }, null); if (method != null) { method.Invoke(null, new object[] { info, false, manager.Transaction, null }); } } var lEventID = manager.SetSpCommand("dbo.spEventLog_CreateNewEvent", eventType, objectIdent, info, DBNull.Value, ClientID, DBNull.Value, isProcessed, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value ).ExecuteScalar <long>(ScalarSourceType.OutputParameter, "EventID"); m_EventIdents.Add(lEventID); } catch (Exception e) { if (e is DataException) { throw DbModelException.Create(null, e as DataException); } throw; } }
public virtual List <OutbreakLookup> _SelectListInternal(DbManagerProxy manager , on_action loading, on_action loaded ) { OutbreakLookup _obj = null; try { MapResultSet[] sets = new MapResultSet[1]; List <OutbreakLookup> objs = new List <OutbreakLookup>(); sets[0] = new MapResultSet(typeof(OutbreakLookup), objs); manager .SetSpCommand("spOutbreak_SelectLookup" ) .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); } }
public int LogIn(string ticketId, bool repeatAfterDeadlock = true) { using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { try { DataTable dt = manager.SetSpCommand("dbo.spLoginByTicket", manager.Parameter("@strTicket", ticketId), manager.Parameter("@intExpirationInterval", BaseSettings.TicketExpiration), manager.Parameter(ParameterDirection.Output, "@Result", 0) ).ExecuteDataTable(); int res = Convert.ToInt32(manager.Parameter("@Result").Value); if (res == 0) { PerformLogin(dt); } m_LoginTry = 0; return(res); } catch (Exception e) { Dbg.Debug("login by ticket failed, error: {0}", e); Dbg.Trace(); m_LoginTry++; if (DbModelException.IsDeadlockException(e) && m_LoginTry < DedalockRepeatCount) { Debug.WriteLine("user login deadlock found"); return(LogIn(ticketId, m_LoginTry < DedalockRepeatCount - 1)); } var dataException = e as DataException; if (dataException != null) { m_LoginTry = 0; throw DbModelException.Create(null, dataException); } m_LoginTry = 0; throw; } } }
private FFTemplateLookup _CreateNew(DbManagerProxy manager, IObject Parent, int? HACode, on_action creating, on_action created, bool isFake = false) { FFTemplateLookup obj = null; try { obj = FFTemplateLookup.CreateInstance(); obj.m_CS = m_CS; obj.m_IsNew = true; obj.Parent = Parent; if (creating != null) creating(obj); // creating extenters - begin // creating extenters - end _LoadLookups(manager, obj); _SetupHandlers(obj); _SetupChildHandlers(obj, null); obj._SetupMainHandler(); obj._setParent(); // created extenters - begin // created extenters - end if (created != null) created(obj); obj.Created(manager); _SetPermitions(obj._permissions, obj); _SetupRequired(obj); _SetupPersonalDataRestrictions(obj); return obj; } catch(DataException e) { throw DbModelException.Create(obj, e); } }
public string CreateTicket(long userId) { var dbType = DatabaseType.Main; var connectionCredentials = new ConnectionCredentials(null, "Avr"); if (connectionCredentials.IsCorrect) { DbManagerFactory.SetSqlFactory(connectionCredentials.ConnectionString, DatabaseType.AvrTicket); using (var avrManager = DbManagerFactory.Factory[DatabaseType.AvrTicket].Create()) { if (avrManager.TestConnection()) { dbType = DatabaseType.AvrTicket; } } } using (DbManagerProxy manager = DbManagerFactory.Factory[dbType].Create(ModelUserContext.Instance)) { try { manager.SetSpCommand("dbo.spLoginCreateTicket", manager.Parameter("@idfUserID", userId), manager.Parameter(ParameterDirection.Output, "@strTicket", ""), manager.Parameter(ParameterDirection.Output, "@Result", 0) ).ExecuteNonQuery(); int res = Convert.ToInt32(manager.Parameter("@Result").Value); if (res == 0) { return(Utils.Str(manager.Parameter("@strTicket").Value)); } return(null); } catch (DataException e) { throw DbModelException.Create(null, e); } } }
public List <PersonalDataGroup> GetPersonalDataGroups(long?idfUser = null, long?idfCustomizationPackage = null) { using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { var result = new List <PersonalDataGroup>(); try { Dictionary <string, bool> permissions; if (EidssUserContext.User == null) { //check if user has restrictions permissions = ParsePermissions( manager.SetSpCommand("dbo.spEvaluatePermissions", manager.Parameter("@idfEmployee", idfUser) ).ExecuteDataTable()); } else { permissions = (Dictionary <string, bool>)EidssUserContext.User.Permissions; } List <PersonalDataGroup> personalGroups = ParsePersonalDataGroups( manager.SetSpCommand("[dbo].[spContext_GetPersonalDataGroups]", manager.Parameter("@idfCustomizationPackage", idfCustomizationPackage) ).ExecuteDataTable()); if (personalGroups.Count == 0) { return(result); } var splitter = new[] { '.' }; foreach (KeyValuePair <string, bool> permission in permissions) { string[] parser = permission.Key.Split(splitter); if (parser[1].Equals(AccessToPersonalDataString, StringComparison.InvariantCultureIgnoreCase) && !permission.Value) { bool human = parser[0] == EIDSSPermissionObject.HumanCase.ToString(); bool vet = parser[0] == EIDSSPermissionObject.VetCase.ToString(); foreach (PersonalDataGroup pg in personalGroups) { if (pg.ToString().StartsWith("Human") && human) { result.Add(pg); continue; } if (pg.ToString().StartsWith("Vet") && vet) { result.Add(pg); } } } if (personalGroups.Count == result.Count) { break; } } return(result); } catch (DataException e) { throw DbModelException.Create(null, e); } } }