Exemplo 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     = $"{DIR}/{antdNfsFile}",
                    Key          = key,
                    Value        = value,
                    Type         = type,
                    BooleanVerbs = booleanVerbs
                };
                var shares = MapFile.Get().Share;
                var data   = MapFile.Get().Data;

                data.Add(line);
                var nfs = new NfsModel {
                    _Id       = serviceGuid,
                    Guid      = serviceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

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

                shares.Remove(oldShare);
                var shareData = new List <LineModel>();

                foreach (var parameter in newParameters)
                {
                    shareData.Add(ConvertData(parameter));
                }
                var newShare = new ShareModel {
                    FilePath = fileName,
                    Name     = name,
                    Data     = shareData
                };

                shares.Add(newShare);
                var nfs = new NfsModel {
                    _Id       = serviceGuid,
                    Guid      = serviceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

                DeNSo.Session.New.Set(nfs);
            }
Exemplo n.º 3
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);
                        foreach (var line in lines)
                        {
                            data.Add(line);
                        }
                    }
                }
                var nfs = new NfsModel {
                    _Id       = serviceGuid,
                    Guid      = serviceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

                DeNSo.Session.New.Set(nfs);
            }
Exemplo n.º 4
0
            public static void SaveGlobalConfig(List <ServiceNfs> newParameters)
            {
                var shares = MapFile.Get().Share;
                var data   = new List <LineModel>();

                foreach (var parameter in newParameters)
                {
                    data.Add(ConvertData(parameter));
                }
                var nfs = new NfsModel {
                    _Id       = serviceGuid,
                    Guid      = serviceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

                DeNSo.Session.New.Set(nfs);
            }
Exemplo n.º 5
0
            public static void AddShare(string name, string directory)
            {
                SetShareFile(name);
                var shareData          = new List <LineModel>();
                var defaultParameter00 = new LineModel {
                    FilePath     = $"{DIR}/share/{name.Replace("", "_")}.conf",
                    Key          = "path",
                    Value        = directory,
                    Type         = ServiceDataType.String,
                    BooleanVerbs = new KeyValuePair <string, string>("", "")
                };

                shareData.Add(defaultParameter00);
                var defaultParameter01 = new LineModel {
                    FilePath     = $"{DIR}/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 = $"{DIR}/share/{name.Replace("", "_")}.conf",
                    Name     = name,
                    Data     = shareData
                };
                var shares = MapFile.Get().Share;
                var data   = MapFile.Get().Data;

                shares.Add(sh);
                var nfs = new NfsModel {
                    _Id       = serviceGuid,
                    Guid      = serviceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

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