Esempio n. 1
0
 public static bool AddVersion(ref CfgVersion model, out string strError)
 {
     strError = "";
     try
     {
         using (GLedDbEntities ent = new GLedDbEntities())
         {
             CfgVersion newinfo = new CfgVersion()
             {
                 Id       = model.Id,
                 UpdateDt = DateTime.Now,
                 Version  = model.Version
             };
             ent.CfgVersion.Add(newinfo);
             ent.SaveChanges();
             model.Id = newinfo.Id;
             return(true);
         }
     }
     catch (System.Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 查找该分公司下是否有项目组
        /// </summary>
        /// <param name="iOrgId">如果小于等于0,表示全文查找,现在添加也是要求所有企业都唯一</param>
        /// <param name="userName"></param>
        /// <param name="userPassword"></param>
        /// <returns></returns>
        public static GroupLoginedUserModel GroupLogin(int iOrgId, string userName, string userPassword)
        {
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                GroupUser userinfo = null;
                if (iOrgId <= 0)
                {
                    userinfo = (from c in ent.GroupUser
                                where c.Name == userName && c.Password == userPassword
                                select c).FirstOrDefault();
                }
                else
                {
                    userinfo = (from c in ent.GroupUser
                                where c.Name == userName && c.Password == userPassword && c.RefOrgId == iOrgId
                                select c).FirstOrDefault();
                }

                if (userinfo == null)
                {
                    return(null);
                }

                string iTockId            = LoginUserEnableMgr.Get().InsertANewLogined();
                GroupLoginedUserModel mod = new GroupLoginedUserModel()
                {
                    LoginDt         = DateTime.Now,
                    LoginIdByCenter = iTockId,
                    UserInfo        = userinfo
                };
                return(mod);
            }
        }
Esempio n. 3
0
 public static List <CmdLogs> GetAllCmds()
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         return(ent.CmdLogs.ToList());
     }
 }
Esempio n. 4
0
        public static bool UpdateProejct(ref OrgInfo model, out string strError)
        {
            strError = "";
            try
            {
                using (GLedDbEntities ent = new GLedDbEntities())
                {
                    int     id     = model.Id;
                    OrgInfo mdyMod = (from c in ent.OrgInfo where c.Id == id select c).FirstOrDefault();
                    if (mdyMod == null)
                    {
                        strError = ConstDefineBll.InfoCanNotFind;
                        return(false);
                    }

                    mdyMod.Name       = model.Name;
                    mdyMod.Address    = model.Address;
                    mdyMod.ManageName = model.ManageName;
                    mdyMod.ManageTel  = model.ManageTel;
                    mdyMod.UpdateDt   = DateTime.Now;
                    ent.SaveChanges();
                    return(true);
                }
            }
            catch (System.Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
        }
Esempio n. 5
0
 public static List <CfgVersion> GetAllCfg()
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         return(ent.CfgVersion.ToList());
     }
 }
Esempio n. 6
0
        // todo get all

        public static bool AddUser(ref ProjectUser model, out string strErrorMsg)
        {
            strErrorMsg = "";
            if (IsUserNameExist(model.Name))
            {
                strErrorMsg = ConstDefineBll.NameExist;
                return(false);
            }

            using (GLedDbEntities ent = new GLedDbEntities())
            {
                ProjectUser newinfo = new ProjectUser()
                {
                    Id           = model.Id,
                    MgrProjectId = model.MgrProjectId,
                    Name         = model.Name,
                    Password     = model.Password,
                    RefOrgId     = model.RefOrgId,
                    RefGroupId   = model.RefGroupId,
                    CreateDt     = DateTime.Now,
                    UpdateDt     = DateTime.Now
                };
                ent.ProjectUser.Add(newinfo);
                ent.SaveChanges();
                model.Id = newinfo.Id;
            }
            return(true);
        }
        public static bool UpdateDev(GasCardWithCommInfo model, out string strError)
        {
            strError = "";
            try
            {
                using (GLedDbEntities ent = new GLedDbEntities())
                {
                    var oldinfo = (from c in ent.GasCardWithCommInfo where c.Id == model.Id select c).FirstOrDefault();
                    if (oldinfo == null)
                    {
                        strError = ConstDefineBll.InfoCanNotFind;
                        return(false);
                    }
                    oldinfo.Id                = model.Id;
                    oldinfo.DefName           = model.DefName;
                    oldinfo.DefPassword       = model.DefPassword;
                    oldinfo.Name              = model.Name;
                    oldinfo.Password          = model.Password;
                    oldinfo.CityId            = model.CityId;
                    oldinfo.Address           = model.Address;
                    oldinfo.PosLongitude      = model.PosLongitude;
                    oldinfo.PosLatitude       = model.PosLatitude;
                    oldinfo.ProjectId         = model.ProjectId;
                    oldinfo.GroupId           = model.GroupId;
                    oldinfo.OrgId             = model.OrgId;
                    oldinfo.CommType          = model.CommType;
                    oldinfo.ProtocolType      = model.ProtocolType;
                    oldinfo.CommServerIp      = model.CommServerIp;
                    oldinfo.CommServerPort    = model.CommServerPort;
                    oldinfo.CommServerSn      = model.CommServerSn;
                    oldinfo.CommSerialPort    = model.CommSerialPort;
                    oldinfo.CommSerialBaud    = model.CommSerialBaud;
                    oldinfo.CommSerialDataBit = model.CommSerialDataBit;
                    oldinfo.CommSerialStopBit = model.CommSerialStopBit;
                    oldinfo.CommSerialParity  = model.CommSerialParity;
                    oldinfo.CommTimeoutMs     = model.CommTimeoutMs;
                    oldinfo.CommExtConnInfo   = model.CommExtConnInfo;
                    oldinfo.BEnable           = model.BEnable;
                    oldinfo.CardBrightness    = model.CardBrightness;
                    oldinfo.CardContext       = model.CardContext;
                    oldinfo.CardIsDouble      = model.CardIsDouble;
                    oldinfo.CardModel         = model.CardModel;
                    oldinfo.CardNumberCount   = model.CardNumberCount;
                    oldinfo.CardPointCount    = model.CardPointCount;
                    oldinfo.CardScreenCount   = model.CardScreenCount;
                    oldinfo.IsDel             = model.IsDel;

                    oldinfo.Comment  = model.Comment;
                    oldinfo.UpdateDt = DateTime.Now;
                    ent.SaveChanges();
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
        }
        public static bool UpdateDefNamePassword(int Id, string strName, string strPassword, out string strError)
        {
            strError = "";
            try
            {
                using (GLedDbEntities ent = new GLedDbEntities())
                {
                    var oldinfo = (from c in ent.GasCardWithCommInfo where c.Id == Id select c).FirstOrDefault();
                    if (oldinfo == null)
                    {
                        strError = ConstDefineBll.InfoCanNotFind;
                        return(false);
                    }
                    oldinfo.Password = strPassword;
                    oldinfo.Name     = strPassword;
                    oldinfo.UpdateDt = DateTime.Now;
                    ent.SaveChanges();
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
        }
Esempio n. 9
0
 public static CfgVersion GetFirstCfg()
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         return(ent.CfgVersion.FirstOrDefault());
     }
 }
Esempio n. 10
0
        public static bool AddUser(ref SuperUser model, out string strErrorMsg)
        {
            strErrorMsg = "";
            if (IsUserNameExist(model.Name))
            {
                strErrorMsg = ConstDefineBll.NameExist;
                return(false);
            }

            using (GLedDbEntities ent = new GLedDbEntities())
            {
                SuperUser newinfo = new SuperUser()
                {
                    Id         = model.Id,
                    EnableTime = model.EnableTime,
                    UserType   = model.UserType,
                    Name       = model.Name,
                    Password   = model.Password,
                    CreateDt   = DateTime.Now,
                    UpdateDt   = DateTime.Now
                };
                ent.SuperUser.Add(newinfo);
                ent.SaveChanges();
                model.Id = newinfo.Id;
            }
            return(true);
        }
Esempio n. 11
0
        public static bool VersionInc(ref int iNewVer)
        {
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                CfgVersion mdyMod = (from c in ent.CfgVersion select c).FirstOrDefault();
                if (mdyMod == null)
                {
                    mdyMod = new CfgVersion()
                    {
                        Id       = 0,
                        UpdateDt = DateTime.Now,
                        Version  = 1
                    };
                    ent.CfgVersion.Add(mdyMod);
                    ent.SaveChanges();
                    iNewVer = 1;
                    return(true);
                }

                mdyMod.Version  = mdyMod.Version + 1;
                iNewVer         = mdyMod.Version.Value;
                mdyMod.UpdateDt = DateTime.Now;
                ent.SaveChanges();
                return(true);
            }
        }
Esempio n. 12
0
 public static bool AddCommDevInfo(ref CmdLogs model, out string strError)
 {
     strError = "";
     try
     {
         using (GLedDbEntities ent = new GLedDbEntities())
         {
             CmdLogs newinfo = new CmdLogs()
             {
                 Id         = model.Id,
                 CardInfoId = model.CardInfoId,
                 CmdInfo    = model.CmdInfo,
                 CmdType    = model.CmdType,
                 CommDevId  = model.CommDevId,
                 CreateTime = DateTime.Now,
                 IsDetele   = 0,
                 Result     = 0,
                 ResultInfo = model.ResultInfo,
                 UpdateTime = DateTime.Now
             };
             ent.CmdLogs.Add(newinfo);
             ent.SaveChanges();
             model.Id = newinfo.Id;
             return(true);
         }
     }
     catch (System.Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
Esempio n. 13
0
 public static CmdLogs GetACmdLogsById(int id)
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         return((from c in ent.CmdLogs where c.Id == id select c).FirstOrDefault());
     }
 }
 public static bool AddDev(ref GasCardWithCommInfo model, out string strError)
 {
     strError = "";
     try
     {
         using (GLedDbEntities ent = new GLedDbEntities())
         {
             GasCardWithCommInfo newinfo = new GasCardWithCommInfo()
             {
                 Id                = model.Id,
                 DefName           = model.DefName,
                 DefPassword       = model.DefPassword,
                 Name              = model.Name,
                 Password          = model.Password,
                 CityId            = model.CityId,
                 Address           = model.Address,
                 PosLongitude      = model.PosLongitude,
                 PosLatitude       = model.PosLatitude,
                 ProjectId         = model.ProjectId,
                 GroupId           = model.GroupId,
                 OrgId             = model.OrgId,
                 CommType          = model.CommType,
                 ProtocolType      = model.ProtocolType,
                 CommServerIp      = model.CommServerIp,
                 CommServerPort    = model.CommServerPort,
                 CommServerSn      = model.CommServerSn,
                 CommSerialPort    = model.CommSerialPort,
                 CommSerialBaud    = model.CommSerialBaud,
                 CommSerialDataBit = model.CommSerialDataBit,
                 CommSerialStopBit = model.CommSerialStopBit,
                 CommSerialParity  = model.CommSerialParity,
                 CommTimeoutMs     = model.CommTimeoutMs,
                 CommExtConnInfo   = model.CommExtConnInfo,
                 BEnable           = model.BEnable,
                 CardBrightness    = model.CardBrightness,
                 CardContext       = model.CardContext,
                 CardIsDouble      = model.CardIsDouble,
                 CardModel         = model.CardModel,
                 CardNumberCount   = model.CardNumberCount,
                 CardPointCount    = model.CardPointCount,
                 CardScreenCount   = model.CardScreenCount,
                 IsDel             = 0,
                 ScreenNams        = model.ScreenNams,
                 Comment           = model.Comment,
                 UpdateDt          = DateTime.Now,
                 CreateDt          = DateTime.Now
             };
             ent.GasCardWithCommInfo.Add(newinfo);
             ent.SaveChanges();
             model.Id = newinfo.Id;
             return(true);
         }
     }
     catch (System.Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
 public static List <GasCardWithCommInfo> GetAllDevList()
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         List <GasCardWithCommInfo> lsts = (from c in ent.GasCardWithCommInfo select c).ToList();
         return(lsts);
     }
 }
Esempio n. 16
0
        public static List <CmdLogs> GetNewCmdsByMinutes(int iMinutes)
        {
            DateTime dtCheck = DateTime.Now.AddMinutes(-iMinutes);

            using (GLedDbEntities ent = new GLedDbEntities())
            {
                return((from c in ent.CmdLogs where c.Result == 0 && c.IsDetele != 1 && c.CreateTime > dtCheck select c).ToList());
            }
        }
Esempio n. 17
0
 public static List <ProjectInfo> GetProjectsByGroupId(int iGroupId)
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         List <ProjectInfo> pros = (from c in ent.ProjectInfo
                                    where c.GroupId == iGroupId
                                    select c).ToList <ProjectInfo>();
         return(pros);
     }
 }
 public static List <GasCardWithCommInfo> GetDevListByOrgId(int iOrgId)
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         List <GasCardWithCommInfo> lsts = (from c in ent.GasCardWithCommInfo
                                            where c.OrgId == iOrgId
                                            select c).ToList();
         return(lsts);
     }
 }
Esempio n. 19
0
 public static bool IsNameExist(string name)
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         if ((from c in ent.OrgInfo where c.Name == name select c).FirstOrDefault() != null)
         {
             return(true);
         }
     }
     return(false);
 }
 public static bool IsSnExise(string strSn)
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         if ((from c in ent.GasCardWithCommInfo
              where c.CommServerSn == strSn
              select c).FirstOrDefault() != null)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 21
0
 /// <summary>
 /// 检查是否有存在指定名字工程,除当前的ID外的
 /// </summary>
 /// <param name="iEcxpId">不包括这ID</param>
 /// <param name="projectName"></param>
 /// <returns></returns>
 private bool IsProjectNameExist(int iEcxpId, string projectName)
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         if ((from c in ent.ProjectInfo
              where c.ProjectName == projectName && c.Id != iEcxpId
              select c).FirstOrDefault() == null)
         {
             return(true);
         }
     }
     return(false);
 }
 public static bool IsNameExist(string strName)
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         if ((from c in ent.GasCardWithCommInfo
              where c.Name == strName || c.DefName == strName
              select c).FirstOrDefault() != null)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 23
0
 /// <summary>
 /// 检查是否有存在指定名字工程,除当前的Id外的
 /// </summary>
 /// <param name="iEcxpId">不包括这Id</param>
 /// <param name="projectName"></param>
 /// <returns></returns>
 public bool IsNameExist(int iEcxpId, string name)
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         if ((from c in ent.OrgInfo
              where c.Name == name && c.Id != iEcxpId
              select c).FirstOrDefault() == null)
         {
             return(true);
         }
     }
     return(false);
 }
        public static bool DelDev(int Id)
        {
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                var delItem = (from c in ent.GasCardWithCommInfo where c.Id == Id select c).FirstOrDefault();
                if (delItem == null)
                {
                    return(true);
                }

                ent.GasCardWithCommInfo.Remove(delItem);
                ent.SaveChanges();
                return(true);
            }
        }
Esempio n. 25
0
 public static bool IsUserNameExist(string strName)
 {
     using (GLedDbEntities ent = new GLedDbEntities())
     {
         var delItem = (from c in ent.ProjectUser where c.Name == strName select c).FirstOrDefault();
         if (delItem != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 26
0
        public static bool DelUser(int id)
        {
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                var delItem = (from c in ent.ProjectUser where c.Id == id select c).FirstOrDefault();
                if (delItem == null)
                {
                    return(true);
                }

                ent.ProjectUser.Remove(delItem);
                ent.SaveChanges();
                return(true);
            }
        }
Esempio n. 27
0
        public static bool DeleteAOrg(int id, out string strError)
        {
            strError = "";
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                var delItem = (from c in ent.OrgInfo where c.Id == id select c).FirstOrDefault();
                if (delItem == null)
                {
                    return(true);
                }

                ent.OrgInfo.Remove(delItem);
                ent.SaveChanges();
                return(true);
            }
        }
        public static bool UpdateOilLastValue(int id, string strContext)
        {
            try
            {
                using (GLedDbEntities ent = new GLedDbEntities())
                {
                    string strSql = string.Format("UPDATE GasCardWithCommInfo SET CardContext ='{0}' WHERE Id ={1}", strContext, id);
                    ent.Database.ExecuteSqlCommand(strSql);
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);
            }
        }
Esempio n. 29
0
        public static bool UpdateACmdResult(int id, int iResult, string strResultInfo)
        {
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                CmdLogs mdyMod = (from c in ent.CmdLogs where c.Id == id select c).FirstOrDefault();
                if (mdyMod == null)
                {
                    return(false);
                }

                mdyMod.Result     = iResult;
                mdyMod.ResultInfo = strResultInfo;
                mdyMod.UpdateTime = DateTime.Now;
                ent.SaveChanges();
                return(true);
            }
        }
Esempio n. 30
0
        public static List <OrgInfo> GetAllOrgInfo()
        {
            try
            {
                using (GLedDbEntities ent = new GLedDbEntities())
                {
                    List <OrgInfo> pros = (from c in ent.OrgInfo
                                           select c).ToList <OrgInfo>();

                    return(pros);
                }
            }
            catch (Exception ex)
            {
                LogMgr.WriteErrorDefSys("GetAllCardInfo error " + ex.Message);
                throw;
            }
        }