Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="userGroupFun"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool Create(IDal dal, CUserGroupFun userGroupFun, string user)
        {
            int i;

            dal.Execute("INSERT INTO tUserGroupFun( GroupCode ,FunCode ,Queriable ,Creatable ,Changable ,Deletable ,Checkable , BuildUser,EditUser) VALUES  ( @GroupCode , @FunCode ,@Queriable ,@Creatable ,@Changable ,@Deletable ,@Checkable,@BuildUser,@EditUser )", out i,
                        dal.CreateParameter("@GroupCode", userGroupFun.GroupCode.Trim()),
                        dal.CreateParameter("@FunCode", userGroupFun.FunCode.Trim()),
                        dal.CreateParameter("@Queriable", userGroupFun.Queriable),
                        dal.CreateParameter("@Creatable", userGroupFun.Creatable),
                        dal.CreateParameter("@Changable", userGroupFun.Changable),
                        dal.CreateParameter("@Deletable", userGroupFun.Deletable),
                        dal.CreateParameter("@Checkable", userGroupFun.Checkable),
                        dal.CreateParameter("@BuildUser", user),
                        dal.CreateParameter("@EditUser", user));
            if (i == 0)
            {
                return(false);
            }
            var dt = dal.Select("SELECT Id FROM tUserGroupFun WHERE GroupCode=@GroupCode AND FunCode=@FunCode", out i,
                                dal.CreateParameter("@GroupCode", userGroupFun.GroupCode),
                                dal.CreateParameter("@FunCode", userGroupFun.FunCode));

            if (i == 0)
            {
                return(false);
            }
            userGroupFun.Id = Convert.ToInt16(dt.Rows[0]["Id"]);
            return(true);
        }
Пример #2
0
        public ActionResult NouveauCollabo()
        {
            dal             = new Dal();
            ViewBag.Service = new SelectList(dal.ObtenirTousLesServices(), "Id", "Nom");
            IEnumerable <SelectListItem> servicesList =
                from category in dal.ObtenirTousLesServices()
                select new SelectListItem
            {
                Text  = category.Nom,
                Value = category.Id.ToString()
            };

            ViewData["services"] = servicesList;

            if (HttpContext.User.Identity.IsAuthenticated)
            {
                NouveauCollaborateurViewModel vm = new NouveauCollaborateurViewModel
                {
                    _Collaborateur = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name)
                };

                return(View(vm));
            }
            return(View());
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="groupCode"></param>
        /// <returns></returns>
        public static CUserGroupFun[] List(IDal dal, string groupCode)
        {
            int       i;
            DataTable dt;

            if (groupCode.Equals("*"))
            {
                dt = dal.Select("select 0 as Id ,'' as GroupCode,FunCode,FunName,GroupType,0 as Queriable,0 as Creatable,0 as Changable,0 as Deletable,0 as Checkable from tFunction Order By FunCode", out i);
            }
            else
            {
                dt =
                    dal.Select(
                        "select ISNULL(b.Id,0) as Id,ISNULL( b.GroupCode,@GroupCode) as GroupCode,a.FunCode,a.FunName,ISNULL( b.Queriable,0) as Queriable,ISNULL( b.Creatable,0) as Creatable,ISNULL( b.Changable,0) as Changable,ISNULL( b.Deletable,0) as Deletable,ISNULL( b.Checkable,0) as Checkable, a.GroupType from tFunction a left join tUserGroupFun b on a.FunCode=b.FunCode WHERE GroupCode=@GroupCode or GroupCode is null Order By a.FunCode",
                        out i,
                        dal.CreateParameter("@GroupCode", groupCode));
            }

            return((from DataRow row in dt.Rows
                    select new CUserGroupFun
            {
                Id = Convert.ToInt16(row["Id"]),
                GroupCode = Convert.ToString(row["GroupCode"]),
                FunCode = Convert.ToString(row["FunCode"]),
                FunName = Convert.ToString(row["FunName"]),
                GroupType = (GroupType)Convert.ToInt16(row["GroupType"]),
                Queriable = Convert.ToBoolean(row["Queriable"]),
                Changable = Convert.ToBoolean(row["Changable"]),
                Deletable = Convert.ToBoolean(row["Deletable"]),
                Checkable = Convert.ToBoolean(row["Checkable"]),
                Creatable = Convert.ToBoolean(row["Creatable"])
            }).ToArray());
        }
Пример #4
0
        public void ParametersPassProperlyToTarget()
        {
            IInstanceInterceptor interceptor = new InterfaceInterceptor();
            MyDal target = new MyDal();

            IInterceptingProxy proxy           = interceptor.CreateProxy(typeof(IDal), target);
            CallCountHandler   depositHandler  = new CallCountHandler();
            CallCountHandler   withdrawHandler = new CallCountHandler();

            proxy.SetPipeline(typeof(IDal).GetMethod("Deposit"),
                              new HandlerPipeline(new ICallHandler[] { depositHandler }));
            proxy.SetPipeline(typeof(IDal).GetMethod("Withdraw"),
                              new HandlerPipeline(new ICallHandler[] { withdrawHandler }));

            IDal intercepted = (IDal)proxy;

            intercepted.Deposit(100.0);
            intercepted.Deposit(25.95);
            intercepted.Deposit(19.95);

            intercepted.Withdraw(15.00);
            intercepted.Withdraw(6.25);

            Assert.AreEqual(3, depositHandler.CallCount);
            Assert.AreEqual(2, withdrawHandler.CallCount);

            Assert.AreEqual(100.0 + 25.95 + 19.95 - 15.00 - 6.25, target.Balance);
        }
Пример #5
0
 public Supervisor(IPoller <TaskToBeWorked> poller, IDal dal, IMessagePublisher <TaskToBeWorked> publisher, ILogger <Supervisor> logger)
 {
     _poller    = poller;
     _dal       = dal;
     _publisher = publisher;
     _logger    = logger;
 }
Пример #6
0
 /**
  * @brief assign all Model to local variables in controller
  *
  */
 public EditController(ApplicationDbContext db)
 {
     _widgetsSettings = new Dal(db);
     _ytModel         = new YoutubeModel();
     _sModel          = new SteamModel();
     _wModel          = new WeatherModel();
 }
Пример #7
0
        void ImportAttributes(IDal dal, IDbConnection connection, IDbTransaction transaction, Manager manager)
        {
            //delete all existing association
            string sqlStatement = "delete from [IdpeAttributeDataSource] where [DataSourceId] = " + this.DataSource.Id;

            CoreDatabaseObjects.Instance.ExecuteStatement(sqlStatement, dal, connection, transaction);

            int position = 1;

            foreach (IdpeAttribute attribute in this.Attributes)
            {
                int attributeId = manager.AttributeExists(attribute.Name);
                if (attributeId == 0)
                {
                    attributeId = manager.Save(attribute, dal, connection, transaction);
                }

                sqlStatement  = "insert into [IdpeAttributeDataSource]([DataSourceId],[AttributeId],[Position],[IsAcceptable],[AttributePrintValueType],[AttributePrintValueCustom],[CreatedTS],[CreatedBy],[Source]) ";
                sqlStatement += "values ({0},{1},{2},{3},{4},'{5}','{6}','{7}' ,'Imported')";

                sqlStatement = string.Format(sqlStatement,
                                             this.DataSource.Id, attributeId, position, attribute.IsAcceptable == true ? 1 : 0, attribute.AttributePrintValueType,
                                             attribute.AttributePrintValueCustom, DateTime.Now,
                                             Information.LoggedInUser.UserName.Replace("'", ""));
                CoreDatabaseObjects.Instance.ExecuteStatement(sqlStatement, dal, connection, transaction);
                position++;
            }
        }
        public void SetOfferAsProcessed(IDal dal, Offer offer)
        {
            _logger.Info($"UPDATE Offers set Processed = {(int)EOfferProcessed.Processed} WHERE Id = {offer.Id}");

            dal.ExecuteNonQuery(
                $"UPDATE Offers set Processed = {(int)EOfferProcessed.Processed} WHERE Id = {offer.Id}");
        }
        public PartialViewResult Commander()
        {
            try {
                dal = new Dal();
                if (HttpContext.User.Identity.IsAuthenticated)
                {
                    Client client = dal.ObtenirUtilisateur(HttpContext.User.Identity.Name);


                    Panier panier = (Panier)Session["cart"];
                    db.Paniers.Add(panier);
                    db.SaveChanges();
                    Commande cmd = new Commande
                    {
                        dateCommande = DateTime.Now,
                        etat         = "Non validé",
                        PanierID     = panier.PanierID,
                        Panier       = panier,
                        Client       = client,
                        ClientID     = client.ClientID
                    };
                    db.Commandes.Add(cmd);
                    db.SaveChanges();
                    Session["cart"] = null;
                }
                ViewBag.result = "success commande";
                return(PartialView("Myorder", null));
            }
            catch (Exception ex)
            {
                ViewBag.result = "faillure commande";
                return(PartialView("Myorder", null));
            }
        }
 public void SetOffersAsInProcess(IDal dal, IEnumerable <Offer> offers)
 {
     _logger.Info(
         $"UPDATE Offers set Processed = {(int)EOfferProcessed.InProcess} WHERE Id in {string.Join(",", offers)}");
     dal.ExecuteNonQuery(
         $"UPDATE Offers set Processed = {(int)EOfferProcessed.InProcess} WHERE Id in {string.Join(",", offers)}");
 }
Пример #11
0
        public OpcUaImporter(
            IDal <ProfileTypeDefinition, ProfileTypeDefinitionModel> dal,
            IDal <LookupDataType, LookupDataTypeModel> dtDal,
            IDal <Profile, ProfileModel> nsDal,
            IDal <NodeSetFile, NodeSetFileModel> nsFileDal,
            IDal <EngineeringUnit, EngineeringUnitModel> euDal,
            ProfileMapperUtil profileUtils,
            ILogger <OpcUaImporter> logger
            #if NODESETDBTEST
            , NodeSetModelContext nsDBContext
#endif
            )
        {
            _dal        = dal;
            _dtDal      = dtDal;
            _euDal      = euDal;
            this.Logger = new LoggerCapture(logger);
#if NODESETDBTEST
            this.nsDBContext = nsDBContext;
#endif
            _nsDal        = nsDal;
            _nsFileDal    = nsFileDal;
            _profileUtils = profileUtils;
            var operationContext = new SystemContext();
            var namespaceTable   = new NamespaceTable();
            namespaceTable.GetIndexOrAppend(strOpcNamespaceUri);
            var typeTable = new TypeTable(namespaceTable);
            _systemContext = new SystemContext(operationContext)
            {
                NamespaceUris = namespaceTable,
                TypeTable     = typeTable,
            };
        }
Пример #12
0
        public void SelectAndMoveOffersFromBufforToOffers(IDal db)
        {
            try
            {
                int ret = db.ExecuteNonQuery(@"
                WITH OFFERS_BUFF(Id,WebsiteId,UriHash,WebApiUserId,CreatedDate,WebsiteCategoryId) as
                (
                    SELECT max(Id),WebsiteId,UriHash,WebApiUserId,MAX(CreatedDate),max(WebsiteCategoryId) FROM offersBuffor WITH(NOLOCK)
                    GROUP BY WebsiteId,UriHash,WebApiUserId
                ) 
                INSERT INTO offers (WebsiteId,Uri,UriHash,WebApiUserId,CreatedDate,WebsiteCategoryId,Processed)
                SELECT 
	                OFFERS_BUFF.WebsiteId,
	                offersBuffor.Uri,
	                OFFERS_BUFF.UriHash,
                    OFFERS_BUFF.WebApiUserId,
	                OFFERS_BUFF.CreatedDate,
	                OFFERS_BUFF.WebsiteCategoryId,
	                0 AS Processed 
                FROM OFFERS_BUFF WITH (NOLOCK)
                INNER JOIN offersBuffor WITH(NOLOCK) ON offersBuffor.Id = OFFERS_BUFF.Id
                where OFFERS_BUFF.UriHash NOT IN (SELECT UriHash FROM Offers WITH (NOLOCK) where WebApiUserId = OFFERS_BUFF.WebApiUserId)
                ");

                _logger.Info("Moved " + ret + " offers");
                PopOffersFromBuffer(db);
                _logger.Info("Cleared buffor");
            }
            catch (Exception ex)
            {
                _logger.Info(ex.Message);
                throw;
            }
        }
Пример #13
0
 public CustomerController(IDal _dal
                           , IDal _dal1)
 {
     dal = _dal;
     // DI of MVC core
     // inversion of control
 }
Пример #14
0
        /// <summary>
        /// 读取菜单
        /// </summary>
        /// <returns></returns>
        public static CMenuCategory[] LoadMenu(IDal dal, string groupCode)
        {
            int i;
            var dt =
                dal.Select(
                    "select a.Id,a.FunCode,a.FunName,a.FunCmd,a.ParentCode,a.FunType,a.SerialNo from tFunction a,tUserGroupFun b where a.FunCode=b.FunCode and b.Queriable=1 and a.Enabled=1 and GroupCode=@GroupCode",
                    out i,
                    dal.CreateParameter("@GroupCode", groupCode));

            return((from DataRow category in dt.Rows
                    where category["FunType"].ToString() == "0"
                    select new CMenuCategory
            {
                Id = Convert.ToInt16(category["Id"]),
                CategoryCode = Convert.ToString(category["FunCode"]),
                CategoryName = Convert.ToString(category["FunName"]),
                SerialNo = Convert.ToInt16(category["SerialNo"]),
                Menus = (from DataRow menu in dt.Rows
                         where
                         menu["FunType"].ToString() == "1" &&
                         Convert.ToString(menu["ParentCode"]) == Convert.ToString(category["FunCode"])
                         select new CMenu
                {
                    Id = Convert.ToInt16(menu["Id"]),
                    MenuCode = Convert.ToString(menu["FunCode"]),
                    MenuName = Convert.ToString(menu["FunName"]),
                    MenuCmd = Convert.ToString(menu["FunCmd"]),
                    ParentCode = Convert.ToString(menu["ParentCode"]),
                    SerialNo = Convert.ToInt16(menu["SerialNo"])
                }).ToArray()
            }).ToArray());
        }
Пример #15
0
        /// <summary>
        /// 取消Token
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="userCode"></param>
        public static void DropToken(IDal dal, string userCode)
        {
            int i;

            dal.Execute(" update tUser set Token=null where UserCode=@UserCode ", out i,
                        dal.CreateParameter("@UserCode", userCode));
        }
Пример #16
0
        public static CUser Get(IDal dal, int id)
        {
            int i;
            var dt =
                dal.Select(
                    "SELECT a.*,b.DeptName,c.GroupName FROM tUser a Left JOIN tDept b ON a.DeptCode=b.DeptCode Left JOIN tUserGroup c ON a.GroupCode=c.GroupCode where a.Id=@Id",
                    out i,
                    dal.CreateParameter("@Id", id));

            if (i == 0)
            {
                return(null);
            }
            return((from DataRow row in dt.Rows
                    select new CUser
            {
                Id = Convert.ToInt16(row["Id"]),
                UserCode = Convert.ToString(row["UserCode"]),
                UserName = Convert.ToString(row["UserName"]),
                BuildDate = Convert.ToDateTime(row["BuildDate"]).ToString(ConfigurationManager.AppSettings["DateFormate"]),
                BuildUser = Convert.ToString(row["BuildUser"]),
                EditDate = Convert.ToDateTime(row["EditDate"]).ToString(ConfigurationManager.AppSettings["DateFormate"]),
                EditUser = Convert.ToString(row["EditUser"]),
                DeptCode = Convert.ToString(row["DeptCode"]),
                DeptName = Convert.ToString(row["DeptName"]),
                Enabled = Convert.ToBoolean(row["Enabled"]),
                GroupCode = Convert.ToString(row["GroupCode"]),
                GroupName = Convert.ToString(row["GroupName"])
            }).First());
        }
        public bool CategoryIdExistInDb(IDal db, int websiteCategoryId)
        {
            int count = (int)db.ExecuteScalar(
                $"SELECT COUNT(*) from websiteCategories with(nolock) where websiteId={(int) EOfferWebsite.Allegro} AND websiteCategoryId={websiteCategoryId}");

            return(count > 0);
        }
Пример #18
0
        public bool AddTester(Tester tester)
        {
            //if tester is to young
            if (DateTime.Now.Year - tester.DateOfBirth.Year < Configuration.minTesterAge)
            {
                throw new Exception("A tester cannot be under " + Configuration.minTesterAge + " years old /n");
            }
            //if tester is to old
            if (DateTime.Now.Year - tester.DateOfBirth.Year > Configuration.MaxTesterAge)
            {
                throw new Exception("A tester cannot be over " + Configuration.minTesterAge + " years old /n");
            }
            try
            {
                IDal _dal = FactorySingletonDal.GetDal();
                if (_dal.AddTester(tester))
                {
                    return(true);
                }
                return(false);
            }

            catch (Exception e)
            {
                throw e;
            }
        }
Пример #19
0
 /// <summary>
 /// 读取菜单
 /// </summary>
 /// <returns></returns>
 public static CMenuCategory[] LoadMenu(IDal dal, string groupCode)
 {
     int i;
     var dt =
         dal.Select(
             "select a.Id,a.FunCode,a.FunName,a.FunCmd,a.ParentCode,a.FunType,a.SerialNo from tFunction a,tUserGroupFun b where a.FunCode=b.FunCode and b.Queriable=1 and a.Enabled=1 and GroupCode=@GroupCode",
             out i,
             dal.CreateParameter("@GroupCode", groupCode));
     return (from DataRow category in dt.Rows
         where category["FunType"].ToString() == "0"
         select new CMenuCategory
         {
             Id = Convert.ToInt16(category["Id"]),
             CategoryCode = Convert.ToString(category["FunCode"]),
             CategoryName = Convert.ToString(category["FunName"]),
             SerialNo = Convert.ToInt16(category["SerialNo"]),
             Menus = (from DataRow menu in dt.Rows
                 where
                     menu["FunType"].ToString() == "1" &&
                     Convert.ToString(menu["ParentCode"]) == Convert.ToString(category["FunCode"])
                 select new CMenu
                 {
                     Id = Convert.ToInt16(menu["Id"]),
                     MenuCode = Convert.ToString(menu["FunCode"]),
                     MenuName = Convert.ToString(menu["FunName"]),
                     MenuCmd =Convert.ToString(menu["FunCmd"]),
                     ParentCode =Convert.ToString(menu["ParentCode"]),
                     SerialNo = Convert.ToInt16(menu["SerialNo"])
                 }).ToArray()
         }).ToArray();
 }
        public ActionResult IndexPost()
        {
            dal = new Dal();
            int idSondage = dal.CreerUnSondage();

            return(RedirectToAction("Index", "Sondage", new { id = idSondage }));
        }
Пример #21
0
        static void Main(string[] args)
        {
            //1
            //ручной вариант
            //IDal mssqldal = new MSSQLDal();
            //IDal oracldal = new OracleDal();
            //Customer obj = new Customer(mssqldal);

            //2
            //framwork Unity
            //IUnityContainer objContainer = new UnityContainer();
            //objContainer.RegisterType<Customer>();
            //objContainer.RegisterType<IDal, MSSQLDal>();
            //objContainer.RegisterType<IDal, OracleDal>();
            //Customer obj = objContainer.Resolve<Customer>();

            //3 myself
            ImyDIRepository objContainer = new DIContainer();

            //objContainer.RegisterType<IDal, MSSQLDal>();
            objContainer.RegisterType <IDal, OracleDal>();
            IDal obj = objContainer.Resolver <IDal>();

            //
            obj.Add("test1");
        }
Пример #22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="groupCode"></param>
        /// <returns></returns>
        public static CUserGroupFun[] List(IDal dal, string groupCode)
        {
            int i;
            DataTable dt;
            if (groupCode.Equals("*"))
            {
                dt = dal.Select("select 0 as Id ,'' as GroupCode,FunCode,FunName,GroupType,0 as Queriable,0 as Creatable,0 as Changable,0 as Deletable,0 as Checkable from tFunction Order By FunCode", out i);
            }
            else
            {
                dt =
                    dal.Select(
                        "select ISNULL(b.Id,0) as Id,ISNULL( b.GroupCode,@GroupCode) as GroupCode,a.FunCode,a.FunName,ISNULL( b.Queriable,0) as Queriable,ISNULL( b.Creatable,0) as Creatable,ISNULL( b.Changable,0) as Changable,ISNULL( b.Deletable,0) as Deletable,ISNULL( b.Checkable,0) as Checkable, a.GroupType from tFunction a left join tUserGroupFun b on a.FunCode=b.FunCode WHERE GroupCode=@GroupCode or GroupCode is null Order By a.FunCode",
                        out i,
                        dal.CreateParameter("@GroupCode", groupCode));
            }

            return (from DataRow row in dt.Rows
                    select new CUserGroupFun
                    {
                        Id = Convert.ToInt16(row["Id"]),
                        GroupCode = Convert.ToString(row["GroupCode"]),
                        FunCode = Convert.ToString(row["FunCode"]),
                        FunName = Convert.ToString(row["FunName"]),
                        GroupType = (GroupType)Convert.ToInt16(row["GroupType"]),
                        Queriable = Convert.ToBoolean(row["Queriable"]),
                        Changable = Convert.ToBoolean(row["Changable"]),
                        Deletable = Convert.ToBoolean(row["Deletable"]),
                        Checkable = Convert.ToBoolean(row["Checkable"]),
                        Creatable = Convert.ToBoolean(row["Creatable"])
                    }).ToArray();
        }
Пример #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="custContact"></param>
        /// <param name="editUser"></param>
        /// <returns></returns>
        public static bool Update(IDal dal, CCustContact custContact, string editUser)
        {
            int i;

            dal.Execute("UPDATE tCustContact SET ContactName=@ContactName,CustomerCode=@CustomerCode,Phone1=@Phone,Phone2=@Phone,Email=@Email,Remark=@Remark,EditUser=@EditUser,EditDate=GETDATE(),Enabled=@Enabled Where Id=@Id", out i,
                        dal.CreateParameter("@ContactName", custContact.ContactName.Trim()),
                        dal.CreateParameter("@CustomerCode", custContact.CustomerCode.Trim()),
                        dal.CreateParameter("@Phone1", custContact.Phone1.Trim()),
                        dal.CreateParameter("@Phone2", custContact.Phone2.Trim()),
                        dal.CreateParameter("@Email", custContact.Email.Trim()),
                        dal.CreateParameter("@Remark", custContact.Remark.Trim()),
                        dal.CreateParameter("@EditUser", editUser),
                        dal.CreateParameter("@Enabled", custContact.Enabled),
                        dal.CreateParameter("@Id", custContact.Id));
            if (i == 0)
            {
                return(false);
            }
            var dt = dal.Select("Select EditUser,EditDate From tCustContact Where Id=@Id", out i,
                                dal.CreateParameter("@Id", custContact.Id));

            if (i == 0)
            {
                return(false);
            }
            custContact.EditUser = Convert.ToString(dt.Rows[0]["EditUser"]);
            custContact.EditDate = Convert.ToDateTime(dt.Rows[0]["EditDate"]).ToString(ConfigurationManager.AppSettings["DateFormate"]);
            return(true);
        }
Пример #24
0
        public void CanInterceptInstancesViaTheContainer()
        {
            IUnityContainer container = new UnityContainer()
                                        .AddNewExtension <Interception>()
                                        .RegisterType <IDal, MockDal>()
                                        .Configure <Interception>()
                                        .SetInterceptorFor <IDal>(new InterfaceInterceptor())
                                        .AddPolicy("AlwaysMatches")
                                        .AddMatchingRule <AlwaysMatchingRule>()
                                        .AddCallHandler <CallCountHandler>("callCount", new ContainerControlledLifetimeManager())
                                        .Interception
                                        .Container;

            IDal dal = container.Resolve <IDal>();

            Assert.IsTrue(dal is IInterceptingProxy);

            dal.Deposit(50.0);
            dal.Deposit(65.0);
            dal.Withdraw(15.0);

            CallCountHandler handler = (CallCountHandler)(container.Resolve <ICallHandler>("callCount"));

            Assert.AreEqual(3, handler.CallCount);
        }
Пример #25
0
        /// <summary>
        /// 新建用户组
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="userGroup"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool Create(IDal dal, CUserGroup userGroup,string user)
        {
            int i;
            dal.BeginTran();
            dal.Execute(
                "INSERT INTO tUserGroup( GroupCode ,GroupName ,BuildUser ,EditUser,GroupType) VALUES  ( @GroupCode , @GroupName,@BuildUser,@EditUser,@GroupType)",
                out i,
                dal.CreateParameter("@GroupCode", userGroup.GroupCode.Trim()),
                dal.CreateParameter("@GroupName", userGroup.GroupName.Trim()),
                dal.CreateParameter("@GroupType", (short) (userGroup.GroupType)),
                dal.CreateParameter("@BuildUser", user),
                dal.CreateParameter("@EditUser", user)
                );

            if (i == 0)return false;
            var dt = dal.Select("SELECT Id FROM tUserGroup WHERE GroupCode =@GroupCode", out i,
                dal.CreateParameter("@GroupCode", userGroup.GroupCode));
            if (i == 0) return false;
            userGroup.Id = Convert.ToInt16(dt.Rows[0]["Id"]);

            foreach (var fun in userGroup.GroupFun)
            {
                fun.GroupCode = userGroup.GroupCode;
                UserGroupFunBll.Create(dal, fun, user);
            }
            dal.CommitTran();
            userGroup.Fun = UserGroupFunBll.CountGroupFun(dal, userGroup.GroupCode);
            userGroup.People = UserBll.CountPeople(dal, userGroup.GroupCode);
            return true;
        }
Пример #26
0
        public int GetSreKeyId(IDal myDal, IDbConnection conn, IDbTransaction transaction, int dataSourceId, string keyName)
        {
            int    keyId       = 0;
            string commandText = "select k.keyId, [Name], [Value] from idpekey k ";

            commandText += "inner join IdpeKeyDataSource ka on k.keyId = ka.keyId ";
            commandText += "where ka.dataSourceId = @DataSourceId and Name = @Name";

            IDbCommand command = myDal.CreateCommand(commandText, conn);

            command.Transaction = transaction;
            command.AddParameterWithValue("DataSourceId", dataSourceId);
            command.AddParameterWithValue("Name", keyName);
            IDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                keyId = int.Parse(reader[0].ToString());
            }

            reader.Close();
            reader.Dispose();
            command.Dispose();
            return(keyId);
        }
Пример #27
0
 public Worker(IMessageListener <TaskToBeWorked> listener, Func <string, IStep> stepAccessor, IDal dal, ILogger <Worker> logger)
 {
     _listener     = listener;
     _stepAccessor = stepAccessor;
     _dal          = dal;
     _logger       = logger;
 }
Пример #28
0
 /// <summary>
 /// 计算用户组中功能数量
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="groupCode"></param>
 /// <returns></returns>
 public static int CountGroupFun(IDal dal, string groupCode)
 {
     int i;
     var dt = dal.Select("select count(1) as Fun from tFunction a left join tUserGroupFun b on a.FunCode =b.FunCode where a.Enabled=1 and b.Queriable=1 and b.GroupCode=@GroupCode", out i,
         dal.CreateParameter("@GroupCode", groupCode));
     return Convert.ToInt16(dt.Rows[0]["Fun"]);
 }
Пример #29
0
        public object ExecuteScalar(string commandText, IDal dal = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            object returnObject = null;

            if (dal == null)
            {
                dal        = new DataAccessLayer(EyediaCoreConfigurationSection.CurrentConfig.Database.DatabaseType).Instance;
                connection = dal.CreateConnection(_ConnectionString);
                connection.Open();
                IDbCommand command = dal.CreateCommand(commandText, connection);
                returnObject = command.ExecuteScalar();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }
            else
            {
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }
                IDbCommand command = dal.CreateCommand(commandText, connection);
                returnObject = command.ExecuteScalar();
                command.Dispose();
            }
            return(returnObject);
        }
Пример #30
0
        /// <summary>
        /// The function creates Dal tier implementation object according to Dal type
        /// as appears in "dal" element in the configuration file config.xml.<br/>
        /// The configuration file also includes element "dal-packages" with list
        /// of available packages (.dll files) per Dal type.<br/>
        /// Each Dal package must use "Dal" namespace and it must include internal access
        /// singleton class with the same name as package's name.<br/>
        /// The singleton class must include public static property called "Instance"
        /// which must contain the single instance of the class.
        /// </summary>
        /// <returns>Dal tier implementation object</returns>
        public static IDal GetDal()
        {
            string dalType    = DalConfig.DalName;
            string dalPackage = DalConfig.DalPackages[dalType];

            if (dalPackage == null)
            {
                throw new DalConfigException($"Wrong DL type: {dalType}");
            }
            try // Load concrete Dal implementation assembly
            {
                Assembly asm = Assembly.Load(dalPackage);
            }
            catch (Exception ex)
            {
                throw new DalConfigException($"Failed loading {dalPackage}.dll", ex);
            }
            // Get concrete Dal implementation's class metadata object
            Type type = Type.GetType($"Dal.{dalPackage}, {dalPackage}");

            if (type == null)
            {
                throw new DalConfigException($"Class name is not the same as Assembly Name: {dalPackage}");
            }
            // Get concrete Dal implementation's Instance
            IDal dal = (IDal)type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static)
                       .GetValue(null); // since it's a static property - no need for an object

            if (dal == null)
            {
                throw new DalConfigException($"Class {dalPackage} is not a singleton");
            }
            return(dal);
        }
Пример #31
0
        public DataTable ExecuteCommand(string commandText, IDal dal = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            DataTable table = new DataTable();

            if (dal == null)
            {
                dal        = new DataAccessLayer(EyediaCoreConfigurationSection.CurrentConfig.Database.DatabaseType).Instance;
                connection = dal.CreateConnection(_ConnectionString);
                connection.Open();
                IDbCommand  command = dal.CreateCommand(commandText, connection);
                IDataReader reader  = command.ExecuteReader();
                table.Load(reader);
                reader.Close();
                reader.Dispose();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }
            else
            {
                IDbCommand  command = dal.CreateCommand(commandText, connection, transaction);
                IDataReader reader  = command.ExecuteReader();
                table.Load(reader);
                reader.Close();
                reader.Dispose();
                command.Dispose();
            }
            return(table);
        }
Пример #32
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static CCustomer Get(IDal dal, int id)
        {
            int i;
            var dt = dal.Select("SELECT * FROM tCustomer WHERE Id=@Id", out i,
                                dal.CreateParameter("@Id", id));

            if (i == 0)
            {
                return(null);
            }
            return((from DataRow row in dt.Rows
                    select new CCustomer
            {
                Id = Convert.ToInt16(row["Id"]),
                CustomerCode = Convert.ToString(row["CustomerCode"]),
                CustomerName = Convert.ToString(row["CustomerName"]),
                Status = (CustomerStatus)Convert.ToInt16(row["Status"]),
                Remark = Convert.ToString(row["Remark"]),
                BuildDate = Convert.ToDateTime(row["BuildDate"]).ToString(ConfigurationManager.AppSettings["DateFormate"]),
                BuildUser = Convert.ToString(row["BuildUser"]),
                EditDate = Convert.ToDateTime(row["EditDate"]).ToString(ConfigurationManager.AppSettings["DateFormate"]),
                EditUser = Convert.ToString(row["EditUser"]),
                Enabled = Convert.ToBoolean(row["Enabled"]),
                Owner = Convert.ToString(row["Owner"])
            }).First());
        }
Пример #33
0
        /// <summary>
        /// 按照条件查询指定联系人
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="customerCode"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public static CCustContact[] List(IDal dal, string customerCode, int page)
        {
            int i;
            var dt =
                dal.Select(
                    "SELECT * FROM tCustContact Where CustomerCode=@CustomerCode",
                    (page - 1) * PageLength + 1, PageLength, out i,
                    dal.CreateParameter("@CustomerCode", customerCode)
                    );

            if (i == 0)
            {
                return(null);
            }
            return((from DataRow row in dt.Rows
                    select new CCustContact
            {
                Id = Convert.ToInt16(row["Id"]),
                CustomerCode = Convert.ToString(row["CustomerCode"]),
                ContactCode = Convert.ToString(row["ContactCode"]),
                ContactName = Convert.ToString(row["ContactName"]),
                Phone1 = Convert.ToString(row["Phone1"]),
                Phone2 = Convert.ToString(row["Phone2"]),
                Email = Convert.ToString(row["Email"]),
                Remark = Convert.ToString(row["Remark"]),
                BuildDate = Convert.ToDateTime(row["BuildDate"]).ToString(ConfigurationManager.AppSettings["DateFormate"]),
                BuildUser = Convert.ToString(row["BuildUser"]),
                EditDate = Convert.ToDateTime(row["EditDate"]).ToString(ConfigurationManager.AppSettings["DateFormate"]),
                EditUser = Convert.ToString(row["EditUser"]),
                Enabled = Convert.ToBoolean(row["Enabled"])
            }).ToArray());
        }
        /// <summary>
        /// Creates a workbook <see cref="ISession"/> where the cache of the associated <see cref="Assembler"/>
        /// is populated with data sourced from the workbook
        /// </summary>
        /// <param name="dal">
        /// The <see cref="IDal"/> instance used to communicate with the data-source.
        /// </param>
        /// <param name="credentials">
        /// The <see cref="Credentials"/> used to communicate with the data-source.
        /// </param>
        /// <returns>
        /// An instance of <see cref="ISession"/> that is specific to the <see cref="Workbook"/>
        /// </returns>
        private async Task <ISession> CreateWorkbookSession(IDal dal, Credentials credentials)
        {
            var workbookDataDal = new WorkbookDataDal(this.workbook);
            var workbookData    = workbookDataDal.Read();

            var workbookSession = dal.CreateSession(credentials);

            if (workbookData != null)
            {
                if (workbookData.SiteDirectoryThings != null && workbookData.SiteDirectoryThings.Any())
                {
                    await workbookSession.Assembler.Synchronize(workbookData.SiteDirectoryThings, false);
                }

                if (workbookData.IterationThings != null && workbookData.IterationThings.Any())
                {
                    var iterationThings = workbookData.IterationThings.ToList();

                    this.SetIterationContainer(ref iterationThings);

                    await workbookSession.Assembler.Synchronize(iterationThings, false);
                }
            }

            return(workbookSession);
        }
Пример #35
0
 /// <summary>
 /// 更新Token
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="token"></param>
 /// <param name="userCode"></param>
 public static void UpdateToken(IDal dal, string token, string userCode)
 {
     var vlu = MD5.Create().ComputeHash(Encoding.Default.GetBytes(token));
     int i;
     dal.Execute(" update tUser set Token=@Token where UserCode=@UserCode ", out i,
         dal.CreateParameter("@Token",vlu),
         dal.CreateParameter("@UserCode",userCode));
 }
Пример #36
0
 /// <summary>
 /// Default constructor
 /// </summary>
 private DALManager( DALProvider provider )
 {
     switch (provider)
     {
         case DALProvider.ORACLE:
             break;
         case DALProvider.SQLSERVER:
             _dal = new DalSQLServer(_connexionString);
             break;
     }
 }
Пример #37
0
 public static bool Delete(IDal dal, int id,out CDept hisDept)
 {
     int i;
     hisDept = Get(dal, id);
     if (hisDept == null) return false;
     dal.BeginTran();
     dal.Execute("UPDATE tUser SET DeptCode=null WHERE DeptCode=@DeptCode", out i,
         dal.CreateParameter("@DeptCode",hisDept.DeptCode));
     dal.Execute("DELETE FROM tDept WHERE Id=@Id",out i,
         dal.CreateParameter("@Id",id));
     dal.CommitTran();
     return true;
 }
Пример #38
0
 /// <summary>
 /// 筛选的部门
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="condition">条件,Code或者Name</param>
 /// <returns></returns>
 public static CDept[] Filter(IDal dal, string condition)
 {
     int i;
     var dt = dal.Select(" SELECT * FROM tDept WHERE DeptCode LIKE @Condition+'%' OR DeptName LIKE '%'+@Condition +'%' ", out i,
         dal.CreateParameter("@Condition", condition));
     if (i == 0) return null;
     return (from DataRow row in dt.Rows
         select new CDept
         {
             Id = Convert.ToInt16(row["Id"]),
             DeptCode = Convert.ToString(row["DeptCode"]),
             DeptName = Convert.ToString(row["DeptName"]),
             ParentCode = Convert.ToString(row["ParentCode"])
         }).ToArray();
 }
Пример #39
0
 /// <summary>
 /// 读取指定Dept
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static CDept Get(IDal dal, int id)
 {
     int i;
     var dt = dal.Select("SELECT * FROM tDept WHERE Id=@Id", out i,
         dal.CreateParameter("@Id", id));
     if (i == 0) return null;
     return (from DataRow row in dt.Rows
         select new CDept
         {
             Id = Convert.ToInt16(row["Id"]),
             DeptCode = Convert.ToString(row["DeptCode"]),
             DeptName = Convert.ToString(row["DeptName"]),
             ParentCode = Convert.ToString(row["ParentCode"])
         }).First();
 }
Пример #40
0
        /// <summary>
        /// 删除用户组
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="id"></param>
        /// <param name="hisUserGroup"></param>
        /// <returns></returns>
        public static bool Delete(IDal dal, int id ,out CUserGroup hisUserGroup)
        {
            int i;
            hisUserGroup = Get(dal, id);
            if (hisUserGroup == null) return false;

            dal.BeginTran();
            dal.Execute("UPDATE tUser SET GroupCode=null WHERE GroupCode=@GroupCode",out i,
                dal.CreateParameter("@GroupCode",hisUserGroup.GroupCode));
            dal.Execute("DELETE FROM tUserGroupFun WHERE GroupCode=@GroupCode",out i,
                dal.CreateParameter("@GroupCode",hisUserGroup.GroupCode));
            dal.Execute("DELETE FROM tUserGroup WHERE Id=@Id",out i,
                dal.CreateParameter("@Id",id));
            dal.CommitTran();
            return true;
        }
Пример #41
0
 /// <summary>
 /// 新建部门
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="dept"></param>
 /// <param name="editUser"></param>
 /// <returns></returns>
 public static bool Create(IDal dal, CDept dept,string editUser)
 {
     int i;
     dal.Execute("INSERT INTO tDept( DeptCode ,DeptName ,ParentCode ,BuildUser ,EditUser) VALUES  ( @DeptCode ,@DeptName ,@ParentCode ,@BuildUser ,@EditUser )",out i,
         dal.CreateParameter("@DeptCode",dept.DeptCode.Trim()),
         dal.CreateParameter("@DeptName",dept.DeptName.Trim()),
         dal.CreateParameter("@ParentCode",dept.ParentCode.Trim()),
         dal.CreateParameter("@BuildUser", editUser),
         dal.CreateParameter("@EditUser", editUser));
     if (i == 0) return false;
     var dt = dal.Select("SELECT Id FROM dbo.tDept WHERE DeptCode=@DeptCode",out i,
         dal.CreateParameter("@DeptCode",dept.DeptCode));
     if (i == 0) return false;
     dept.Id = Convert.ToInt16(dt.Rows[0]["Id"]);
     return true;
 }
Пример #42
0
 /// <summary>
 /// 通过用户名密码登录
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="authorityModel"></param>
 /// <returns></returns>
 public static bool Signin(IDal dal,CAuthorityModel authorityModel)
 {
     int i;
     var pwd = MD5.Create().ComputeHash(Encoding.Default.GetBytes(authorityModel.UserCode + authorityModel.UPwd));
     var dt = dal.Select("select * from tUser where UPassword=@UPassword", out i,
         dal.CreateParameter("@UPassword", pwd));
     if (i == 0)
     {
         return false;
     }
     authorityModel.Id = Convert.ToInt16(dt.Rows[0]["Id"]);
     authorityModel.UserName = Convert.ToString(dt.Rows[0]["UserName"]);
     authorityModel.GroupCode = Convert.ToString(dt.Rows[0]["GroupCode"]);
     authorityModel.DeptCode = Convert.ToString(dt.Rows[0]["DeptCode"]);
     return true;
 }
Пример #43
0
 /// <summary>
 /// 筛选用户组
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="condition"></param>
 /// <returns></returns>
 public static CUserGroup[] Filter(IDal dal, string condition)
 {
     int i;
     var dt = dal.Select(" SELECT * FROM tUserGroup WHERE GroupCode LIKE @Condition+'%' OR GroupName LIKE '%'+@Condition +'%' ", out i,
         dal.CreateParameter("@Condition", condition));
     if (i == 0) return null;
     return (from DataRow row in dt.Rows
         select new CUserGroup
         {
             Id = Convert.ToInt16(row["Id"]),
             GroupCode = Convert.ToString(row["GroupCode"]),
             GroupName = Convert.ToString(row["GroupName"]),
             GroupType = (GroupType) Convert.ToInt16(row["GroupType"]),
             People = UserBll.CountPeople(dal, Convert.ToString(row["GroupCode"])),
             Fun = UserGroupFunBll.CountGroupFun(dal, Convert.ToString(row["GroupCode"]))
         }).ToArray();
 }
Пример #44
0
 /// <summary>
 /// 显示日志
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="page"></param>
 /// <returns></returns>
 public static CLog[] List(IDal dal, int page)
 {
     int i;
     const int length = 50;
     var startIndex = (page-1)*length + 1;
     var dt = dal.Select("SELECT * FROM tXtLog ORDER BY SerialNo", startIndex, length, out i);
     if (i == 0) return null;
     return (from DataRow row in dt.Rows
         select new CLog
         {
             Id = Convert.ToInt32(row["Id"]),
             LogContent = Convert.ToString(row["LogContent"]),
             LogDate = Convert.ToDateTime(row["LogDate"]).ToString(ConfigurationManager.AppSettings["DateFormate"]),
             LogType = (LogType)Convert.ToInt16(row["LogType"]),
             LogUser = Convert.ToString(row["LogUser"])
         }).ToArray();
 }
Пример #45
0
 /// <summary>
 /// 通过token登录
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="token"></param>
 /// <param name="user"></param>
 /// <param name="authorityModel"></param>
 /// <returns></returns>
 public static bool Signin(IDal dal, string user, string token, CSign authorityModel)
 {
     int i;
     var tk = MD5.Create().ComputeHash(Encoding.Default.GetBytes(token));
     var dt = dal.Select(" select * from tUser where UserCode=@UserCode And Token=@Token ", out i,
         dal.CreateParameter("@UserCode",user),
         dal.CreateParameter("@Token", tk));
     if (i == 0)
     {
         return false;
     }
     authorityModel.Id = Convert.ToInt16(dt.Rows[0]["Id"]);
     authorityModel.UserName = Convert.ToString(dt.Rows[0]["UserName"]);
     authorityModel.UserCode = Convert.ToString(dt.Rows[0]["UserCode"]);
     authorityModel.GroupCode =Convert.ToString(dt.Rows[0]["GroupCode"]);
     authorityModel.DeptCode =  Convert.ToString(dt.Rows[0]["DeptCode"]);
     return true;
 }
Пример #46
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="userGroupFun"></param>
 /// <param name="user"></param>
 /// <returns></returns>
 public static bool Create(IDal dal, CUserGroupFun userGroupFun,string user)
 {
     int i;
     dal.Execute("INSERT INTO tUserGroupFun( GroupCode ,FunCode ,Queriable ,Creatable ,Changable ,Deletable ,Checkable , BuildUser,EditUser) VALUES  ( @GroupCode , @FunCode ,@Queriable ,@Creatable ,@Changable ,@Deletable ,@Checkable,@BuildUser,@EditUser )", out i,
         dal.CreateParameter("@GroupCode",userGroupFun.GroupCode.Trim()),
         dal.CreateParameter("@FunCode",userGroupFun.FunCode.Trim()),
         dal.CreateParameter("@Queriable",userGroupFun.Queriable),
         dal.CreateParameter("@Creatable",userGroupFun.Creatable),
         dal.CreateParameter("@Changable",userGroupFun.Changable),
         dal.CreateParameter("@Deletable",userGroupFun.Deletable),
         dal.CreateParameter("@Checkable",userGroupFun.Checkable),
         dal.CreateParameter("@BuildUser",user),
         dal.CreateParameter("@EditUser",user));
     if (i == 0) return false;
     var dt = dal.Select("SELECT Id FROM tUserGroupFun WHERE GroupCode=@GroupCode AND FunCode=@FunCode", out i,
         dal.CreateParameter("@GroupCode", userGroupFun.GroupCode),
         dal.CreateParameter("@FunCode", userGroupFun.FunCode));
     if (i == 0) return false;
     userGroupFun.Id = Convert.ToInt16(dt.Rows[0]["Id"]);
     return true;
 }
Пример #47
0
 public static void Write(IDal dal, CLog log)
 {
     try
     {
         if (dal.IsOpen)
         {
             int i;
             dal.Execute(
                 "INSERT INTO dbo.tXtLog( LogDate, LogContent, LogType,LogUser )VALUES  ( GETDATE(),@LogContent,@LogType,@LogUser)",
                 out i,
                 dal.CreateParameter("@LogContent", log.LogContent.Trim()),
                 dal.CreateParameter("@LogType", log.LogType),
                 dal.CreateParameter("@LogUser", log.LogUser.Trim()));
         }
         else
         {
             Write(log);
         }
     }
     catch
     {
         Write(log);
     }
 }
Пример #48
0
 public RechercherController()
 {
     dal = DalEnDur.Instance;
 }
Пример #49
0
 private FridgeController(IDal dalIoc)
 {
     dal = dalIoc;
 }
Пример #50
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="dept"></param>
 /// <param name="editUser"></param>
 /// <returns></returns>
 public static bool Update(IDal dal, CDept dept, string editUser)
 {
     int i;
     dal.Execute("UPDATE tDept SET DeptName=@DeptName ,EditDate=GETDATE(),EditUser=@EditUser WHERE Id=@Id", out i,
         dal.CreateParameter("@DeptName",dept.DeptName.Trim()),
         dal.CreateParameter("@EditUser", editUser),
         dal.CreateParameter("@Id",dept.Id));
     return i == 1;
 }
Пример #51
0
 /// <summary>
 /// 获取部门列表
 /// </summary>
 /// <returns></returns>
 public static CDept[] List(IDal dal)
 {
     int i;
     var dt = dal.Select("SELECT * FROM tDept ORDER BY DeptCode", out i);
     if (i == 0)
     {
         return null;
     }
     var people = CountPeople(dal);
     return (from DataRow row in dt.Rows
         where Convert.ToString(row["DeptCode"]) == "root"
         select new CDept
         {
             Id = Convert.ToInt16(row["Id"]),
             DeptCode =Convert.ToString(row["DeptCode"]),
             DeptName = Convert.ToString(row["DeptName"]),
             ParentCode =Convert.ToString(row["ParentCode"]),
             Childs = GetChilds(Convert.ToString(row["DeptCode"]), dt,people),
             People = people.Any(p => p.Id == Convert.ToInt16(row["Id"]))?people.First(p=>p.Id==Convert.ToInt16(row["Id"])).People:0
         }).ToArray();
 }
Пример #52
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="dal"></param>
 /// <param name="userGroupFun"></param>
 /// <param name="user"></param>
 /// <returns></returns>
 public static bool Update(IDal dal, CUserGroupFun userGroupFun,string user)
 {
     int i;
     dal.Execute("UPDATE tUserGroupFun SET Changable=@Changable,Checkable=@Checkable,Deletable=@Deletable,Queriable=@Queriable,Creatable=@Creatable WHERE Id=@Id",out i,
         dal.CreateParameter("@Changable",userGroupFun.Changable),
         dal.CreateParameter("@Checkable",userGroupFun.Checkable),
         dal.CreateParameter("@Deletable",userGroupFun.Deletable),
         dal.CreateParameter("@Queriable",userGroupFun.Queriable),
         dal.CreateParameter("@Creatable",userGroupFun.Creatable),
         dal.CreateParameter("@Id",userGroupFun.Id)
         );
     return i != 0 || Create(dal, userGroupFun, user);
 }
Пример #53
0
        /// <summary>
        /// 修改用户组
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="userGroup"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool Update(IDal dal, CUserGroup userGroup,string user)
        {
            int i;
            dal.BeginTran();
            dal.Execute("UPDATE tUserGroup SET GroupName=@GroupName,EditUser=@EditUser,EditDate=GETDATE(),GroupType=@GroupType WHERE Id=@Id", out i,
                dal.CreateParameter("@GroupName",userGroup.GroupName.Trim()),
                dal.CreateParameter("@EditUser",user),
                dal.CreateParameter("@Id",userGroup.Id),
                dal.CreateParameter("@GroupType",userGroup.GroupType));
            if (i == 0) return false;

            foreach (var fun in userGroup.GroupFun)
            {
                UserGroupFunBll.Update(dal, fun, user);
            }
            dal.CommitTran();
            userGroup.Fun = UserGroupFunBll.CountGroupFun(dal, userGroup.GroupCode);
            userGroup.People = UserBll.CountPeople(dal, userGroup.GroupCode);
            return true;
        }
Пример #54
0
        public void Init_BeforeEachTest()
        {
            // On créer et supprimer la base de donnée a chaque lancement des tests.
            IDatabaseInitializer<BddContext> init = new DropCreateDatabaseAlways<BddContext>();
            Database.SetInitializer(init);
            init.InitializeDatabase(new BddContext());

            _dal = new Dal();
        }
Пример #55
0
 public ProtoPetMap(IDal dal)
 {
     Dal = dal;
 }
Пример #56
0
 private static CDept[] CountPeople(IDal dal)
 {
     int i;
     var dt = dal.Select("select a.Id,count(1) as People from tDept a , tUser b where a.DeptCode=b.DeptCode group by a.Id order by a.Id", out i);
     return (from DataRow row in dt.Rows
         select new CDept
         {
             Id = Convert.ToInt16(row["Id"]),
             People = Convert.ToInt16(row["People"])
         }).ToArray();
 }
Пример #57
0
        public void Init_AvantChaqueTest()
        {
            IDatabaseInitializer<BddContext> init = new DropCreateDatabaseAlways<BddContext>();
            Database.SetInitializer(init);
            init.InitializeDatabase(new BddContext());

            dal = new Dal();
        }
Пример #58
0
 public CompteController(IDal dal)
 {
     this.dal = dal;
 }
Пример #59
0
 public AfficherController()
 {
     dal = DalEnDur.Instance;
 }
Пример #60
0
 private LoginController(IDal dalIoc)
 {
     dal = dalIoc;
 }