コード例 #1
0
        public override object Run(MBuilderModel model, string path, string parms)
        {
            MUser  currentUser = CurrentUser(model);
            string clsType     = GetParm("clsType", "");
            int    parentId    = GetParm("parentId", 0);

            if (GetParm("clstypelist", false))
            {
                List <MClsType> lt = model.MainDic.GetAll <MClsType>((object o) => (clsType == "" || clsType == ((MClsType)o).Id));
                return(lt);
            }

            MTreeList l = new MTreeList(parentId);

            model.Select(l, typeof(MCls), $"select  * from [MCls] (nolock) where ClsTypeId={model.AddParam(clsType)} and ParentId={model.AddParam(parentId)}");

            List <MCls> k = new List <MCls>();

            if (clsType != "")
            {
                model.Select(k, typeof(MCls), $"select * from [MCls] where id in ({l.IdList()}) and id in (select ParentId from MCls)");
                foreach (MCls cls in l)
                {
                    cls.webix_kids = true;
                }
            }
            return(l);
        }
コード例 #2
0
ファイル: UsrAdapter.cs プロジェクト: PANKOVAN/TEST
        public override object Run(MBuilderModel model, string path, string parms)
        {
            MUser currentUser = CurrentUser(model);

            // Чтение списка пользователей
            MPaginationList l  = new MPaginationList(parms);
            List <MArt>     la = new List <MArt>();

            string clsIdList = ClsAdapter.GetParenIdList(GetParm("clsid", ""), "USR");
            string f         = "";

            if (string.IsNullOrEmpty(clsIdList) || GetParm("isAll", false))
            {
                f = "--";
            }

            model.Select(l, typeof(MEntity),
                         $@"select  * from [MEntity] (nolock) where EntityTypeId='USR' 
                    and code like {model.AddParam("%"+GetParm("code", "")+"%")} 
                    and name like {model.AddParam("%" + GetParm("name", "") + "%")} 
                    {f} and clsId in ({clsIdList})"
                         );

            if (l.Count > 0)
            {
                model.Select(la, typeof(MArt), $"select  * from [MArt] (nolock) where EntityId in ({l.IdList()})");
                foreach (MArt art in la)
                {
                    art.Entity.Arts.Add(art);
                }
            }
            return(l);
        }
コード例 #3
0
ファイル: PinAdapter.cs プロジェクト: PANKOVAN/TEST
        public override object Run(MBuilderModel model, string path, string parms)
        {
            MUser currentUser = CurrentUser(model);

            // Прикнопить
            model.Exec($@"if exists(select 1 from [MRelation] where RelationTypeId='PIN' and OwnerId={model.AddParam(currentUser.User.Id)} and ChildId in ({GetParm("id", "")}))
                              delete [MRelation] where RelationTypeId='PIN' and OwnerId={model.AddParam(currentUser.User.Id)} and ChildId in ({GetParm("id", "")}) 
                              else insert [MRelation] (RelationTypeId, OwnerId, ChildId) select 'PIN', {model.AddParam(currentUser.User.Id)}, id from [MEntity] where Id in ({GetParm("id", "")})  
                             ");
            // Чтение списка
            MPaginationList l  = new MPaginationList(parms);
            List <MArt>     la = new List <MArt>();

            model.Select(l, typeof(MEntity), $"select  * from [MEntity] (nolock) where Id in ({GetParm("id", "")})");
            if (l.Count > 0)
            {
                foreach (MEntity e in l)
                {
                    e.IsPin = false;
                }
                List <MRelation> lr = new List <MRelation>();
                model.Select(lr, typeof(MRelation), $"select  * from [MRelation] (nolock) where RelationTypeId='PIN' and OwnerId={model.AddParam(currentUser.User.Id)} and ChildId in ({l.IdList()})");
                foreach (MRelation r in lr)
                {
                    model.MainDic.GetObj <MEntity>(r.ChildId).IsPin = true;
                }
            }
            return(l);
        }
コード例 #4
0
ファイル: LastAdapter.cs プロジェクト: PANKOVAN/TEST
        public override object Run(MBuilderModel model, string path, string parms)
        {
            MUser currentUser = CurrentUser(model);

            // Чтение списка
            MPaginationList l = new MPaginationList(parms);

            return(l);
        }
コード例 #5
0
        public IActionResult Login(MBuilderModel model, string login, string password)
        {
            try
            {
                if (login == null)
                {
                    login = "";
                }
                if (password == null)
                {
                    password = "";
                }

                if (login == "" && password == "")
                {
                    login    = "******";
                    password = "******";
                }

                MEntity   user = model.SelectFirst <MEntity>($"select * from [MEntity] (nolock) where EntityTypeId='USR' and Code={model.AddParam(login)}");
                MPassword pass = model.SelectFirst <MPassword>($"select * from [MPassword] (nolock) where Id={model.AddParam(login)} and PassCode={model.AddParam(MFunc.GetSecurityHash(password))}");
                if (user != null)
                {
                    if (pass != null)
                    {
                        model.AddUser(new MUser(user), login);
                        SetAuth(login);
                    }
                    else
                    {
                        throw new NotAuthException($@"Неправильный пароль...");
                    }
                }
                else
                {
                    throw new NotAuthException($@"Пользователь ""{login}"" не найден...");
                }

                return(Json(new MJsonResult(MJsonResultType.OK, null)));
            }
            catch (Exception e)
            {
                return(Json(new MJsonResult(MJsonResultType.Error, e.Message)));
            }
        }
コード例 #6
0
        public override object Run(MBuilderModel model, string path, string parms)
        {
            MUser currentUser = CurrentUser(model);

            MPaginationList l  = new MPaginationList(parms);
            List <MArt>     la = new List <MArt>();

            model.Select(l, typeof(MEntity), $"select  * from [MEntity] (nolock) where Id in (select ChildId from [MRelation] where RelationTypeId='PIN' and OwnerId={model.AddParam(currentUser.User.Id)})");
            if (l.Count > 0)
            {
                model.Select(la, typeof(MArt), $"select  * from [MArt] (nolock) where EntityId in ({l.IdList()})");
                foreach (MArt art in la)
                {
                    art.Entity.Arts.Add(art);
                }
                foreach (MEntity e in l)
                {
                    e.IsPin = true;
                }
            }
            return(l);
        }
コード例 #7
0
ファイル: Startup.cs プロジェクト: PANKOVAN/TEST
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDistributedMemoryCache();
            services.AddSession(options =>
            {
                options.CookieName  = ".MyApp.Session";
                options.IdleTimeout = TimeSpan.FromSeconds(3600);
            });
            services.AddMvc();

            //MEDMDefModel.MainDef.Load(Path.Combine(BaseDir, "Model", "CNTIModel.xml"));
            MBuilderModel.ConnectionPool.ConnectionString = Configuration.GetConnectionString("DefaultConnection");
            MBuilderModel.Store = new MEDMStore(Configuration.GetSection("Store").GetSection("Path").Value);

            EDMTrace.IsEnabled = true;
            MBuilderModel bm = new MBuilderModel();

            bm.BaseDir = BaseDir;
            bm.Init();

            services.AddScoped <MBuilderModel>();
            services.AddSingleton <IConfigurationRoot>(Configuration);
        }
コード例 #8
0
 public DataController(MBuilderModel model) : base(model)
 {
 }
コード例 #9
0
 public virtual object Run(MBuilderModel model, string path, string parms)
 {
     return(base.Run(model, path, parms));
 }
コード例 #10
0
 public SysController(MBuilderModel model) : base(model)
 {
 }
コード例 #11
0
        public override object Run(MBuilderModel model, string path, string parms)
        {
            MUser currentUser = CurrentUser(model);

            // Загрузка файла картинки
            if (GetParm("upload", false))
            {
                int    id       = GetParm("id", 0);
                string filename = GetParm("name", "");
                string ext      = GetParm("type", "").ToLower();
                if (id == 0)
                {
                    throw new Exception("Текуший проект не выбран...");
                }
                if (filename == "")
                {
                    throw new Exception("Файл не задан...");
                }
                if (!(ext == "png" || ext == "jpg" || ext == "bmp" || ext == "svg"))
                {
                    throw new Exception("Разрешены только следущие типы файлов png, jpg, bmp, svg");
                }
                MArt art = model.SelectFirst <MArt>($"select * from [MArt] where EntityId={model.AddParam(id)} and ArtTypeId='IMG'");
                if (art == null)
                {
                    art           = model.CreateObject(typeof(MArt)) as MArt;
                    art.EntityId  = id;
                    art.ArtTypeId = "IMG";
                }
                art.FileName = filename;
                art.Type     = ext;
                model.Save(Context.Session);

                foreach (IFormFile ff in Context.Request.Form.Files)
                {
                    MBuilderModel.Store.Save(ff, art.GID, art.Type);
                    art.Version++;
                    model.Save(Context.Session);
                    break;
                }
                return(null);
            }
            // Удаление файла картинки
            if (GetParm("deleteImage", false))
            {
                model.Exec($"delete [MArt] where EntityId in ({GetParm("id", "")}) and ArtTypeId='IMG'");
            }
            // Прикнопить проект
            if (GetParm("pin", false))
            {
                model.Exec($@"if exists(select 1 from [MRelation] where RelationTypeId='PIN' and OwnerId={model.AddParam(currentUser.User.Id)} and ChildId in ({GetParm("id", "")}))
                              delete [MRelation] where RelationTypeId='PIN' and OwnerId={model.AddParam(currentUser.User.Id)} and ChildId in ({GetParm("id", "")}) 
                              else insert [MRelation] (RelationTypeId, OwnerId, ChildId) select 'PIN', {model.AddParam(currentUser.User.Id)}, id from [MEntity] where EntityTypeId='PRJ' and Id in ({GetParm("id", "")})  
                             ");
            }
            // Чтение списка проектов
            MPaginationList l  = new MPaginationList(parms);
            List <MArt>     la = new List <MArt>();

            model.Select(l, typeof(MEntity), $"select  * from [MEntity] (nolock) where EntityTypeId='PRJ'");
            if (l.Count > 0)
            {
                model.Select(la, typeof(MArt), $"select  * from [MArt] (nolock) where EntityId in ({l.IdList()})");
                foreach (MArt art in la)
                {
                    art.Entity.Arts.Add(art);
                }
                List <MRelation> lr = new List <MRelation>();
                model.Select(lr, typeof(MRelation), $"select  * from [MRelation] (nolock) where RelationTypeId='PIN' and OwnerId={model.AddParam(currentUser.User.Id)} and ChildId in ({l.IdList()})");
                foreach (MRelation r in lr)
                {
                    model.MainDic.GetObj <MEntity>(r.ChildId).IsPin = true;
                }
            }
            return(l);
        }
コード例 #12
0
 public TemplatesController(MBuilderModel model) : base(model)
 {
 }