Example #1
0
 public bool Create(List <SYS_Logger_Layer> models)
 {
     try
     {
         using (var context = new SystemEntities())
         {
             if (models != null && models.Count > 0)
             {
                 var addModel = context.SYS_Logger_Layer.AddRange(models);
                 var result   = context.SaveChanges();
                 return(result > 0);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #2
0
 public bool Delete(long id)
 {
     try
     {
         using (var context = new SystemEntities())
         {
             var model = context.SYS_Logger_Capability.FirstOrDefault(f => f.ID.Equals(id));
             if (model != null)
             {
                 context.SYS_Logger_Capability.Remove(model);
                 return(context.SaveChanges() > 0);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #3
0
 public bool Delete(string id)
 {
     try
     {
         using (var context = new SystemEntities())
         {
             var model = context.SYS_Version.FirstOrDefault(f => f.VersionCode.Equals(id));
             if (model != null)
             {
                 context.SYS_Version.Remove(model);
                 return(context.SaveChanges() > 0);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #4
0
 public SYS_Version Create(SYS_Version model)
 {
     using (var context = new SystemEntities())
     {
         if (model != null)
         {
             var addModel = context.SYS_Version.Add(model);
             var result   = context.SaveChanges();
             if (result > 0)
             {
                 return(addModel);
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
 }
Example #5
0
 public bool Update(string id, SYS_Version model)
 {
     if (model == null)
     {
         throw new ArgumentNullException();
     }
     using (var context = new SystemEntities())
     {
         var baseModel = context.SYS_Version.FirstOrDefault(f => f.VersionCode.Equals(id));
         if (baseModel == null)
         {
             throw new NullReferenceException("Không tìm thấy đối tượng trong cơ sở dữ liệu");
         }
         else
         {
             model.VersionCode = id;
             context.Entry(baseModel).CurrentValues.SetValues(model);
             //context.Entry(model).State = System.Data.Entity.EntityState.Modified;
             //context.SYS_Layer.Attach(model);
             return(context.SaveChanges() > 0);
         }
     }
 }
Example #6
0
 public SYS_Version CheckUpdate(string applicationId, string version)
 {
     using (var context = new SystemEntities())
     {
         var currentModel = this.Get(version);
         if (currentModel == null)
         {
             return(null);
         }
         if (currentModel == null)
         {
             return(null);
         }
         var lastVersion = context.SYS_Version
                           .Where(w => w.ApplicationId.Equals(applicationId))
                           .OrderByDescending(o => o.Date)
                           .Take(1)
                           .FirstOrDefault();
         if (lastVersion != null)
         {
             // nếu là version mới
             if (currentModel.Date < lastVersion.Date)
             {
                 return(lastVersion);
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
 }
Example #7
0
        public LoginInfo GetDataAggTraceInfo(string dataSourceId, ref string retsLoginURL)
        {
            //RdcCode is data source id.

            LoginInfo loginInfo = null;

            using (SystemEntities se = new SystemEntities())
            {
                try
                {
                    var loginTraceInfo = se.spDA_RETSConnectionInfo_sel(dataSourceId.ToString(CultureInfo.InvariantCulture),
                                                                        false).FirstOrDefault();
                    //var dataSourceResult =
                    //    se.spDA_TCSDatasource_sel(moduleId.ToString(CultureInfo.InvariantCulture), false).ToList();

                    //if (dataSourceResult.Count == 0)
                    //{
                    //    return null;
                    //}
                    //string traceName = string.Empty;
                    //foreach (var item in dataSourceResult)
                    //{
                    //    if (!item.OriginalDataSourceID.Equals(dataSourceId)) continue;
                    //    traceName = item.datasourcename.Trim();
                    //    break;
                    //}
                    //if (string.IsNullOrEmpty(traceName) || traceName.EndsWith("Test", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    return null;
                    //}

                    if (loginTraceInfo != null)
                    {
                        loginInfo = new LoginInfo
                        {
                            UserName             = loginTraceInfo.RETSUserName,
                            Password             = loginTraceInfo.RETSPassword,
                            UserAgent            = loginTraceInfo.RETSUserAgent,
                            UaPassword           = loginTraceInfo.RETSUserAgentPassword,
                            ByPassAuthentication = "1"
                        };
                        retsLoginURL = loginTraceInfo.RETSLoginURL;
                    }

                    //se.Connection.Open();
                    //ObjectResult<spDA_RETSConnectionInfo_sel_Result> loginTrace =
                    //    se.spDA_TCSDatasource_sel(dataSourceId, false);
                    //foreach (var connInfo in loginTrace)
                    //{
                    //    ModuleLoginContainer connection = new ModuleLoginContainer();
                    //    connection.LoginURL = connInfo.RETSLoginURL;
                    //    connection.LoginUserName = connInfo.RETSUserName;
                    //    connection.LoginPassword = connInfo.RETSPassword;
                    //    connection.UserAgent = connInfo.RETSUserAgent;
                    //    connection.UserAgentPW = connInfo.RETSUserAgentPassword;
                    //    connections.Add(connection);
                    //}
                }
                catch (Exception ex)
                {
                }
            }
            return(loginInfo);
        }
        /// <summary>
        /// Overridden to ensure that a connection to the database can be established.
        /// Waits as long as a connection becomes available so that further flow can execute as intended.
        /// </summary>
        protected override void InitializeOverride()
        {
            base.InitializeOverride();

            SystemEntities.EnsureDatabaseReachable();
        }