Ejemplo n.º 1
0
            public static void AddParameterToGlobal(string key, string value)
            {
                SetCustomFile();
                var type         = Helper.ServiceData.SupposeDataType(value);
                var booleanVerbs = Helper.ServiceData.SupposeBooleanVerbs(value);
                var line         = new LineModel {
                    FilePath     = $"{MntDir}/{AntdSambaFile}",
                    Key          = key,
                    Value        = value,
                    Type         = type,
                    BooleanVerbs = booleanVerbs
                };
                var shares = MapFile.Get().Share;
                var data   = MapFile.Get().Data;

                data.Add(line);
                var samba = new SambaModel {
                    _Id       = ServiceGuid,
                    Guid      = ServiceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

                DeNSo.Session.New.Set(samba);
            }
Ejemplo n.º 2
0
            public static void Render()
            {
                var shares = new List <ShareModel>();
                var data   = new List <LineModel>();

                foreach (var file in SimpleStructure)
                {
                    if (file.Contains("/share/"))
                    {
                        shares.Add(ReadFileShare(file));
                    }
                    else
                    {
                        var lines = ReadFile(file);
                        data.AddRange(lines);
                    }
                }
                var samba = new SambaModel {
                    _Id       = ServiceGuid,
                    Guid      = ServiceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

                DeNSo.Session.New.Set(samba);
            }
Ejemplo n.º 3
0
            public static void SaveShareConfig(string fileName, string name, string queryName, List <ServiceSamba> newParameters)
            {
                var data     = MapFile.Get().Data;
                var shares   = MapFile.Get().Share;
                var oldShare = shares.FirstOrDefault(o => o.Name == queryName);

                shares.Remove(oldShare);
                var shareData = newParameters.Select(ConvertData).ToList();
                var newShare  = new ShareModel {
                    FilePath = fileName,
                    Name     = name,
                    Data     = shareData
                };

                shares.Add(newShare);
                var samba = new SambaModel {
                    _Id       = ServiceGuid,
                    Guid      = ServiceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

                DeNSo.Session.New.Set(samba);
            }
Ejemplo n.º 4
0
 public static void SaveGlobalConfig(List <ServiceSamba> newParameters)
 {
     var shares = MapFile.Get().Share;
     var data   = newParameters.Select(ConvertData).ToList();
     var samba  = new SambaModel {
         _Id       = ServiceGuid,
         Guid      = ServiceGuid,
         Timestamp = Timestamp.Now,
         Share     = shares,
         Data      = data
     };
     //DeNSo.Session.New.Set(samba);
 }
Ejemplo n.º 5
0
            public static void AddShare(string name, string directory)
            {
                SetShareFile(name);
                var shareData          = new List <LineModel>();
                var defaultParameter00 = new LineModel {
                    FilePath     = $"{MntDir}/share/{name.Replace("", "_")}.conf",
                    Key          = "path",
                    Value        = directory,
                    Type         = ServiceDataType.String,
                    BooleanVerbs = new KeyValuePair <string, string>("", "")
                };

                shareData.Add(defaultParameter00);
                var defaultParameter01 = new LineModel {
                    FilePath     = $"{MntDir}/share/{name.Replace("", "_")}.conf",
                    Key          = "browseable",
                    Value        = "yes",
                    Type         = ServiceDataType.Boolean,
                    BooleanVerbs = new KeyValuePair <string, string>("yes", "no")
                };

                shareData.Add(defaultParameter01);
                var sh = new ShareModel {
                    FilePath = $"{MntDir}/share/{name.Replace("", "_")}.conf",
                    Name     = name,
                    Data     = shareData
                };
                var shares = MapFile.Get().Share;
                var data   = MapFile.Get().Data;

                shares.Add(sh);
                var samba = new SambaModel {
                    _Id       = ServiceGuid,
                    Guid      = ServiceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

                DeNSo.Session.New.Set(samba);
            }