示例#1
0
        public static void AddDirectory(CredentialsLib c, MachineModel m, DirModel d)
        {
            GetDirList(m);
            int NoSuchNameYet = (from o in m.Directories where o.Name == d.Name select o).Count();

            if (NoSuchNameYet != 0)
            {
                // throw new Exception("directory with given name already exists");
                //no action needed
            }
            else
            {
                d.Owner = UserManipulator.LoginToId(c.Login);
                AddDir(d);
                m.Id = MachManipulator.MachineNameToId(m.Name);
                AddMachDir(m, d);
            }
        }
示例#2
0
        public static void GetDirList(MachineModel m)
        {
            int             mach_id = MachManipulator.MachineNameToId(m.Name);
            List <DirModel> dirlist = new List <DirModel>();

            using (filesyncEntities context = new filesyncEntities())
            {
                foreach (var x in (from md in context.MachineDirs
                                   join d in context.Dirs on md.dir_id equals d.dir_id
                                   where md.machine_id == mach_id
                                   select new { md.dir_realpath, d }))
                {
                    DirModel dir = new DirModel(x.d.dir_name, x.d.dir_description, x.dir_realpath);
                    dir.Id    = x.d.dir_id;
                    dir.Owner = x.d.user_ownerid;
                    dirlist.Add(dir);
                }

                m.Directories = dirlist;
            }
        }