Beispiel #1
0
        private static void CompileServices()
        {
            if (Compiled)
            {
                return;
            }

            ToConsole("Compiling Services...");

            TryCatch(
                () =>
            {
                var files = ServicesDirectory.GetFiles("*.dll", SearchOption.AllDirectories);
                var asm   = new List <Assembly>(files.Length);

                foreach (var file in files)
                {
                    TryCatch(() => asm.Update(Assembly.LoadFrom(file.FullName)), ToConsole);
                }

                ServiceAssemblies = asm.ToArray();

                asm.AddRange(ScriptCompiler.Assemblies);
                asm.Prune();

                ScriptCompiler.Assemblies = asm.FreeToArray(true);
            },
                ToConsole);
        }
Beispiel #2
0
        public ServicesDirectory MapFromReader(SqlDataReader reader)
        {
            ServicesDirectory service = new ServicesDirectory();

            service.Id   = (int)reader["ServicesDirectoryId"];
            service.Name = (string)reader["ServicesDirectoryName"];
            return(service);
        }
Beispiel #3
0
        public ServicesDirectory MapFromRow(DataRow row)
        {
            ServicesDirectory service = new ServicesDirectory();

            service.Id   = row.Field <int>("ServicesDirectoryId");
            service.Name = row.Field <string>("ServicesDirectoryName");
            return(service);
        }
Beispiel #4
0
 public ServicesDirectory GetItem(int serviceId)
 {
     using (dataBase = new FinancialInstitutionEntities())
     {
         ServicesDirectory sd = dataBase.ServicesDirectories.Find(serviceId);
         return(sd);
     }
 }
Beispiel #5
0
 public void Insert(ServicesDirectory service)
 {
     using (dataBase = new FinancialInstitutionEntities())
     {
         dataBase.ServicesDirectories.Add(service);
         dataBase.SaveChanges();
     }
 }
        public ServicesDirectory MapFromEntity(DataAccessLayerCommon.ServicesDirectory servicesDirectory)
        {
            ServicesDirectory SDModel = new ServicesDirectory {
                Name = servicesDirectory.Name, Id = servicesDirectory.Id
            };

            return(SDModel);
        }
Beispiel #7
0
        public void Insert(ServicesDirectory service)
        {
            string       expression = "INSERT ServicesDirectory (Name) VALUES (@name)";
            SqlCommand   command    = new SqlCommand(expression, sqlConnection);
            SqlParameter nameParam  = new SqlParameter("@name", service.Name);

            command.Parameters.Add(nameParam);
            ExecuteNonQueryCommand(command);
        }
Beispiel #8
0
 public void Delete(int serviceId)
 {
     using (dataBase = new FinancialInstitutionEntities())
     {
         ServicesDirectory sd = dataBase.ServicesDirectories.Find(serviceId);
         dataBase.ServicesDirectories.Remove(sd);
         dataBase.SaveChanges();
     }
 }
Beispiel #9
0
 public void Update(int serviceId, ServicesDirectory service)
 {
     using (dataBase = new FinancialInstitutionEntities())
     {
         ServicesDirectory sd = dataBase.ServicesDirectories.Find(serviceId);
         sd.Name = service.Name;
         dataBase.SaveChanges();
     }
 }
Beispiel #10
0
        public void Update(int serviceId, ServicesDirectory service)
        {
            string       expression     = "UPDATE ServicesDirectory SET Name = @name WHERE Id = @serviceid";
            SqlCommand   command        = new SqlCommand(expression, sqlConnection);
            SqlParameter nameParam      = new SqlParameter("@name", service.Name);
            SqlParameter serviceIdParam = new SqlParameter("@serviceId", serviceId);

            command.Parameters.Add(nameParam);
            command.Parameters.Add(serviceIdParam);
            ExecuteNonQueryCommand(command);
        }
Beispiel #11
0
        public List <ServicesDirectory> GetAll()
        {
            List <ServicesDirectory> services = new List <ServicesDirectory>();
            string     expression             = "SELECT * FROM ServicesDirectory";
            SqlCommand sqlCommand             = new SqlCommand(expression, sqlConnection);
            DataTable  dataTable = GetDataTable(sqlCommand);

            foreach (DataRow row in dataTable.Rows)
            {
                ServicesDirectory service = serviceMapper.MapFromRow(row);
                services.Add(service);
            }
            return(services);
        }
Beispiel #12
0
        public ServicesDirectory GetItem(int serviceId)
        {
            SqlParameter serviceIdParam = new SqlParameter("@serviceId", serviceId);
            string       expression     = "SELECT * FROM ServicesDirectory  WHERE Id = @serviceid";
            SqlCommand   command        = new SqlCommand(expression, sqlConnection);

            command.Parameters.Add(serviceIdParam);
            ServicesDirectory service = new ServicesDirectory();

            using (sqlConnection = new SqlConnection(connectionString))
            {
                sqlConnection.Open();
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    service = serviceMapper.MapFromReader(reader);
                }
            }

            return(service);
        }
        private static void CompileServices()
        {
            if (Compiled)
            {
                return;
            }

            ToConsole("Compiling Services...");

            TryCatch(
                () =>
            {
                var files = ServicesDirectory.GetFiles("*.vnc.srv.dll", SearchOption.AllDirectories);
                var asm   = new List <Assembly>(files.Length);

                foreach (FileInfo file in files)
                {
                    TryCatch(
                        () =>
                    {
                        Assembly a = Assembly.LoadFrom(file.FullName);

                        if (a != null && !asm.Contains(a))
                        {
                            asm.Add(a);
                        }
                    },
                        ToConsole);
                }

                ServiceAssemblies = asm.ToArray();
                asm.AddRange(ScriptCompiler.Assemblies);
                ScriptCompiler.Assemblies = asm.ToArray();
            },
                ToConsole);
        }
Beispiel #14
0
        private bool CheckIfServicesDirectoryExist()
        {
            if (!ServicesDirectory.Exists())
            {
                var result = MessageBox.Show(
                    $@"file : {
                            ServicesDirectory.FullName
                        } \ndoes not exist anymore. \nDo you want to removed it from recent directories list?", @"Directory Not Found",
                    System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
                _recentFiles.Remove(ServicesDirectory.FullName);
                if (result != System.Windows.Forms.DialogResult.Yes)
                {
                    return(false);
                }

                SaveRecentFilesXml();
                ReloadRecentFiles();

                ServicesDirectory = null;
                projectLoaded     = false;
                return(false);
            }
            return(true);
        }
Beispiel #15
0
        bool LoadFile(string filePath)
        {
            FileInfo file = filePath.AsFile();

            ServicesDirectory = file.Directory; //filePath.AsDirectory();

            var serviceInfos = ServicesDirectory?.GetDirectories()
                               .Where(x => File.Exists(x.FullName + @"\Website\appsettings.json"))
                               .Select(x =>
                                       new ServiceInfo
            {
                Name               = getServiceName(x.FullName + @"\Website\appSettings.json"),
                ProjectFolder      = x.FullName,
                WebsiteFolder      = Path.Combine(x.FullName, "Website"),
                LaunchSettingsPath = Path.Combine(x.FullName, @"Website\Properties", "launchSettings.json")
            });

            if (!CheckIfServicesDirectoryExist())
            {
                return(false);
            }

            servicesDirectoryLastWriteTime = ServicesDirectory.LastWriteTime;

            txtFileInfo.Text = ServicesDirectory.FullName;
            txtSolName.Text  = ServicesDirectory.Name;
            if (serviceInfos == null)
            {
                return(false);
            }

            foreach (var serviceInfo in serviceInfos)
            {
                var serviceName = serviceInfo.Name;
                var srv         = ServiceData.SingleOrDefault(srvc => srvc.Service == serviceName);
                if (srv == null)
                {
                    srv = new MicroserviceItem();
                    ServiceData.Add(srv);
                }

                var port           = "";
                var status         = MicroserviceItem.EnumStatus.NoSourcerLocally;
                var parentFullName = ServicesDirectory?.FullName ?? "";
                var projFolder     = serviceInfo.ProjectFolder;
                var websiteFolder  = serviceInfo.WebsiteFolder;
                var launchSettings = serviceInfo.LaunchSettingsPath;
                var procId         = -1;

                if (File.Exists(@launchSettings))
                {
                    status = MicroserviceItem.EnumStatus.Pending;
                    port   = GetPortNumberFromLaunchSettingsFile(launchSettings);
                }
                else
                {
                    websiteFolder = null;
                }

                srv.Status         = status;
                srv.Service        = serviceName;
                srv.Port           = port;
                srv.ProcId         = procId;
                srv.SolutionFolder = projFolder;
                srv.WebsiteFolder  = websiteFolder;
            }

            FilterListBy(txtSearch.Text);

            projectLoaded = true;

            if (watcher == null)
            {
                StartFileSystemWatcher(ServicesDirectory);
            }

            Refresh();

            return(true);
        }