Exemplo n.º 1
0
        // dependencyProperty Name
        // configurationPart  Name
        // foreignKey ?

        /// <summary>
        /// Merges the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        public static void Merge(CandleModel model)
        {
            foreach (ModelElement elem in model.Store.ElementDirectory.AllElements)
            {
                if (elem is ShapeElement || elem is ElementLink)
                {
                    continue;
                }

                DomainClassInfo ci = elem.GetDomainClass();
                Debug.WriteLine(String.Format("Elem '{0}' id={1}", ci.Name, elem.Id));
                foreach (DomainPropertyInfo p in ci.LocalDomainProperties)
                {
                    Debug.WriteLine(String.Format("     property '{0}'={1}", p.Name, p.GetValue(elem)));
                }

                foreach (DomainRoleInfo role in ci.LocalDomainRolesPlayed)
                {
                    foreach (ElementLink link in role.GetElementLinks(elem))
                    {
                        Debug.WriteLine(String.Format("     --> '{0}' id={1}", role.Name, link.Id));

                        foreach (DomainPropertyInfo p in link.GetDomainClass().LocalDomainProperties)
                        {
                            Debug.WriteLine(String.Format("     --> property '{0}'={1}", p.Name, p.GetValue(link)));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public Task <TrendDirection> CheckTrendAsync(string tradingPair, CandleModel currentCandle)
        {
            var candleSticksValue = _candleSticksIndicator.GetIndicatorValue(currentCandle);

            if (_lastTrend == TrendDirection.Short)
            {
                if (candleSticksValue.CandleFormat == CandleFormat.BullishMarubozu)
                {
                    _lastTrend = TrendDirection.Long;
                    return(Task.FromResult(_lastTrend));
                }
            }
            if (_lastTrend == TrendDirection.Long)
            {
                if (currentCandle.ClosePrice >= _lastBuyPrice * (decimal)1.01 ||
                    candleSticksValue.CandleFormat == CandleFormat.BearishMarubozu)
                {
                    _lastTrend = TrendDirection.Short;
                }
                else
                {
                    return(Task.FromResult(TrendDirection.None));
                }
            }

            return(Task.FromResult(TrendDirection.None));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Shows the component wizard.
        /// </summary>
        /// <param name="component">The component.</param>
        /// <remarks>
        /// Ce traitement peut-être appelé soit lors de l'insertion d'un composant avec le designer soit à l'ouverture d'un modèle dont
        /// le nom du composant est un '?' (cas du template). Dans ce dernier cas, on ne passe pas par une règle car une règle déclenchée
        /// lors de l'ouverture du document ne notifie pas le designer des changements (car le designer ne s'aboone aux notifications qu'après
        /// le chargement du doc.
        /// </remarks>
        public static void ShowComponentWizard(SoftwareComponent component)
        {
            if (component.Name != "?")
            {
                return;
            }

            component.Store.TransactionManager.CurrentTransaction.Context.ContextInfo["InitializeComponentWizard"] =
                true;

            // Wizard pour demander le namespace et la version
            ApplicationNamespaceForm form = new ApplicationNamespaceForm(component);

            if (form.ShowDialog() != DialogResult.OK)
            {
                throw new CanceledByUser();
            }

            // Demande du namespace
            component.Namespace = form.Namespace;
            component.Name      = form.ApplicationName;

            // Mise à jour de la définition du système
            CandleModel def = component.Model;

            if (def != null)
            {
                def.IsLibrary = form.IsLibrary;
                def.Version   = form.Version;
                def.Comment   = form.Description;
                def.Url       = form.URL;
                def.Name      = form.ApplicationName;
                def.Path      = form.DomainPath;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Recherche d'un modèle par son nom
        /// </summary>
        /// <param name="fullName">The full name.</param>
        /// <returns></returns>
        private DataType FindModelClassByName(string fullName)
        {
            ClassNameInfo nameHelper = new ClassNameInfo(_initialNamespace, fullName);

            // On recherche d'abord dans le modèle courant
            DataType clazz = _layer.FindType(nameHelper.FullName);

            if (clazz == null)
            {
                // Puis dans les les systèmes référencés
                foreach (ExternalComponent sys in _layer.Component.Model.ExternalComponents)
                {
                    CandleModel model = sys.ReferencedModel;
                    if (model != null && model.DataLayer != null)
                    {
                        clazz = model.DataLayer.FindType(nameHelper.FullName);
                        if (clazz != null)
                        {
                            break;
                        }
                    }
                }
            }
            return(clazz);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Traverses the specified visitor.
        /// </summary>
        /// <param name="visitor">The visitor.</param>
        /// <param name="element">The element.</param>
        public void Traverse(IReferenceVisitor visitor, ModelElement element)
        {
            if (visitor == null)
            {
                throw new ArgumentNullException("visitor");
            }
            if (element == null)
            {
                return;
            }

            _visitor = visitor;

            // Il faut toujours commencer par un modèle pour initialiser le contexte
            CandleModel model = null;

            if (!(element is CandleModel))
            {
                model = CandleModel.GetInstance(element.Store);
                visitor.Accept(new ReferenceItem(null, model, false)); // Initialisation du contexte
            }

            // Parcours de l'élément choisi
            Traverse(new ReferenceItem(null, element, false));

            if (model != null)
            {
                visitor.ExitElement(new ReferenceItem(null, model, false));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Copie dans le repository local
        /// </summary>
        /// <param name="model">Le modèle à publier</param>
        /// <param name="fileName">Chemin absolu du modèle à publier</param>
        /// <param name="remoteName">Nom du fichier modèle dans le repository</param>
        /// <returns></returns>
        public string PublishModel(CandleModel model, string fileName, string remoteName)
        {
            ILogger logger = ServiceLocator.Instance.GetService <ILogger>();

            remoteName = Path.GetFileName(remoteName);
            string targetFileName = model.MetaData.ResolvePath(remoteName, PathKind.Absolute);

            // On ne copie que si c'est nécessaire
            if (targetFileName != String.Empty && File.Exists(fileName) &&
                !Utils.StringCompareEquals(targetFileName, fileName) &&
                !Utils.FileDateEquals(targetFileName, fileName))
            {
                try
                {
                    Utils.CopyFile(fileName, targetFileName);
                }
                catch (Exception ex)
                {
                    if (logger != null)
                    {
                        logger.WriteError("Repository", "Publish model", ex);
                    }
                }
            }
            else if (logger != null)
            {
                logger.Write("Repository", "Skip copy of " + fileName + " (same version)", LogType.Info);
            }

            return(targetFileName);
        }
Exemplo n.º 7
0
        public async Task SellAsync(CandleModel candle)
        {
            if (candle != null)
            {
                if (_userBalanceService.HasOpenOrder)
                {
                    await _exchangeProvider.CancelOrderAsync(_tradingPair, _userBalanceService.OpenOrderNumber);

                    return;
                }
                var sellPrice = !_userBalanceService.EnableRealtimeTrading ? candle.ClosePrice : _exchangeProvider.GetTicker(_tradingPair).Result.HighestBid;
                _userBalanceService.TradingCount++;
                long orderNumber = 0;
                if (_userBalanceService.EnableRealtimeTrading)
                {
                    orderNumber = await _exchangeProvider.CreateOrderAsync(TradeType.Sell, _tradingPair, sellPrice, _userBalanceService.Rate);

                    _userBalanceService.HasOpenOrder = true;

                    await CheckOrderInvoked(orderNumber, TradeType.Sell);
                }

                var profit = _userBalanceService.GetProfit(sellPrice, candle.StartDateTime);
                var msg    = $"Sell crypto currency. Date: {candle.StartDateTime}; Price: ${sellPrice}; Rate: {_userBalanceService.Rate}; OrderNumber: {orderNumber}\n" +
                             $"Profit: ${profit.Profit}\n" +
                             $"Trading time in hours: {Math.Round(profit.TradingTimeInMinutes / 60.0, 2)}\n" +
                             "\n" +
                             _userBalanceService.TradingSummary();

                Console.WriteLine(msg);

                _emailService.SendEmail(string.Format(_cryptoTradingOptions.EmailSubject, _tradingPair), msg);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Resolves the path.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <returns></returns>
        public static string ResolvePath(CandleModel model, string assemblyName)
        {
            if (assemblyName.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase) == false)
            {
                assemblyName += ".dll";
            }

            string version = model.DotNetFrameworkVersion.ToString();

            string folder = FindInFirstFramework(version);

            if (folder != null)
            {
                return(Path.Combine(folder, assemblyName));
            }

            // Si pas trouvé, on recherche dans le répertoire apparu depuis la version 3
            // "%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0
            string[] parts = version.Split('.');
            version = String.Join(".", parts, 0, 2);
            folder  =
                Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles%"),
                             @"Reference Assemblies\Microsoft\Framework\v" + version);
            // Bidouille pour le 3.0 car l'assembly peut exister dans le 2.0
            string fileName = Path.Combine(folder, assemblyName);

            if (version == "3.0" && File.Exists(fileName))
            {
                return(fileName);
            }
            return(Path.Combine(FindInFirstFramework("2.0.0.0"), assemblyName));
        }
Exemplo n.º 9
0
        public Task <TrendDirection> CheckTrendAsync(string tradingPair, CandleModel currentCandle)
        {
            var rsiValue = _rsiIndicator.GetIndicatorValue(currentCandle).IndicatorValue;

            Console.WriteLine($"Rsi value: {rsiValue}");

            if (rsiValue < 30 && rsiValue > 0)
            {
                if (_lastTrend == TrendDirection.Long)
                {
                    return(Task.FromResult(TrendDirection.None));
                }
                _lastTrend = TrendDirection.Long;
                return(Task.FromResult(_lastTrend));
            }

            if (rsiValue > 70)
            {
                if (_lastTrend == TrendDirection.Short)
                {
                    return(Task.FromResult(TrendDirection.None));
                }

                _lastTrend = TrendDirection.Short;
                return(Task.FromResult(_lastTrend));
            }

            return(Task.FromResult(TrendDirection.None));
        }
Exemplo n.º 10
0
 /// <summary>
 /// Appelée pour chaque modèle
 /// </summary>
 /// <param name="model"></param>
 /// <param name="isInitialModel"></param>
 protected virtual void AcceptModel(CandleModel model, bool isInitialModel)
 {
     if (!_models.Contains(model))
     {
         _models.Add(model);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Création du composant principal initialisé à partir d'une assembly
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="mainAssembly">The main assembly.</param>
        /// <returns></returns>
        private static BinaryComponent CreateComponent(CandleModel model, Assembly mainAssembly)
        {
            using (Transaction transaction = model.Store.TransactionManager.BeginTransaction("Init main component"))
            {
                // Création du composant
                BinaryComponent component = new BinaryComponent(model.Store);

                // Init avec les valeurs d'un assembly
                if (mainAssembly != null)
                {
                    if (string.IsNullOrEmpty(model.Name))
                    {
                        component.Name = component.Namespace = mainAssembly.GetName().Name;
                        int pos = component.Name.IndexOf('.');
                        if (pos > 0)
                        {
                            component.Name = component.Name.Substring(0, pos);
                        }
                        // Init du system
                        model.Name = component.Name;
                    }
                    else
                    {
                        component.Name = model.Name;
                    }

                    model.Version = new VersionInfo(mainAssembly.GetName().Version);
                }

                model.Component = component;
                transaction.Commit();
                return(component);
            }
        }
Exemplo n.º 12
0
        public Task <TrendDirection> CheckTrendAsync(string tradingPair, CandleModel currentCandle)
        {
            var mfiValue = _mfiIndicator.GetIndicatorValue(currentCandle).IndicatorValue;

            Console.WriteLine($"Mfi indicator value: {mfiValue}");

            if (mfiValue < 0)
            {
                return(Task.FromResult(TrendDirection.None));
            }
            if (mfiValue > 0 && mfiValue <= 20)
            {
                if (_lastTrend == TrendDirection.Short)
                {
                    _lastTrend = TrendDirection.Long;
                    return(Task.FromResult(_lastTrend));
                }
            }
            if (mfiValue >= 80)
            {
                if (_lastTrend == TrendDirection.Long)
                {
                    _lastTrend = TrendDirection.Short;
                    return(Task.FromResult(_lastTrend));
                }
            }

            return(Task.FromResult(TrendDirection.None));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Execute the command
        /// </summary>
        public void Exec()
        {
            CandleModel system = _shape.ModelElement as CandleModel;

            // Si la commande a été lancé sur le composant, on référence le modèle
            if (system == null)
            {
                BinaryComponent component = _shape.ModelElement as BinaryComponent;
                if (component != null)
                {
                    system = component.Model;
                }
            }

            // Peut etre à null si le composant n'est pas de type Binary
            if (system != null)
            {
                // Affiche la fenetre de dialogue permettant de choisir les assemblies
                IAssemblySelectorDialog selector = ServiceLocator.Instance.GetService <IAssemblySelectorDialog>();
                if (selector.ShowDialog(0))
                {
                    ImportAssemblies(system, selector.SelectedAssemblies);

                    // On arrange les shapes du composant
                    IList <PresentationElement> componentShapes = PresentationViewsSubject.GetPresentation(system.Component);
                    ArrangeShapesCommand        cmd             = new ArrangeShapesCommand((NodeShape)componentShapes[0]);
                    cmd.Exec();
                }
            }
        }
Exemplo n.º 14
0
        internal void Execute(GenerationContext context, string outputFile)
        {
            writer = new SafeStreamWriter(outputFile, false);
            try
            {
                this.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                this.WriteLine("<hibernate-mapping xmlns=\"urn:nhibernate-mapping-2.0\">");
                this.WriteLine("");

                CandleModel model = context.Model;
                if (model == null || !model.SoftwareComponent.IsDataLayerExists)
                {
                    return;
                }
                _modelsLayer = model.SoftwareComponent.DataLayer;

                _inheritanceTree = new ClassInheritanceTree(_modelsLayer);
                foreach (ClassInheritanceNode childNode in _inheritanceTree.Root.childs)
                {
                    GenerateClassMapping(childNode, 1, 1);
                }
                _inheritanceTree = null;

                this.WriteLine("");
                this.WriteLine("</hibernate-mapping>");
            }
            finally
            {
                writer.Close();
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// A la fin de la publication, on met à jour les fichiers des infos de l'assemblie avec le
 /// n° de version du modèle.
 /// </summary>
 /// <param name="model"></param>
 /// <param name="modelFileName"></param>
 void IStrategyPublishEvents.OnPublicationEnded(CandleModel model, string modelFileName)
 {
     if (!String.IsNullOrEmpty(T4Template))
     {
         if (model.SoftwareComponent != null)
         {
             // Création du fichier AssemblyInfo
             foreach (AbstractLayer layer in model.SoftwareComponent.Layers)
             {
                 if (layer is SoftwareLayer)
                 {
                     IShellHelper shell = ServiceLocator.Instance.GetService <IShellHelper>();
                     if (shell != null)
                     {
                         // Recherche du projet associé
                         Project prj = shell.FindProjectByName(((SoftwareLayer)layer).VSProjectName);
                         if (prj != null)
                         {
                             Context.Project = prj;
                             CallT4Template(prj, T4Template, layer, _outputFileName);
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 16
0
        public async Task BuyAsync(CandleModel candle)
        {
            if (candle != null)
            {
                if (_userBalanceService.HasOpenOrder)
                {
                    return;
                }

                var buyPrice = !_userBalanceService.EnableRealtimeTrading ? candle.ClosePrice : _exchangeProvider.GetTicker(_tradingPair).Result.LowestAsk;
                _userBalanceService.SetBuyPrice(new CandleModel
                {
                    ClosePrice    = buyPrice,
                    StartDateTime = DateTime.UtcNow
                });
                if (_userBalanceService.EnableRealtimeTrading)
                {
                    _userBalanceService.OpenOrderNumber = await _exchangeProvider.CreateOrderAsync(TradeType.Buy, _tradingPair, buyPrice, _userBalanceService.Rate);

                    _userBalanceService.HasOpenOrder = true;

                    await CheckOrderInvoked(_userBalanceService.OpenOrderNumber, TradeType.Buy);
                }

                var msg = $"Buy crypto currency. Date: {candle.StartDateTime}; Price: ${buyPrice}; Rate: {_userBalanceService.Rate}; OrderNumber: {_userBalanceService.OpenOrderNumber}\n";
                Console.WriteLine(msg);
                _emailService.SendEmail(string.Format(_cryptoTradingOptions.EmailSubject, _tradingPair), msg);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Création d'un fichier zip et envoi sur le serveur
        /// </summary>
        /// <param name="systemDefinition"></param>
        /// <param name="fileNames"></param>
        /// <param name="remoteName"></param>
        private static void PublishZip(CandleModel systemDefinition, List <string> fileNames, string remoteName)
        {
            IRepositoryProvider wsRepository = RepositoryManager.Instance.GetMainRemoteProvider();

            if (wsRepository == null)
            {
                return;
            }

            string tempFile = Path.GetTempFileName();

            try
            {
                RepositoryZipFile zipFile = new RepositoryZipFile(tempFile);
                zipFile.ArchiveFiles(fileNames);
                wsRepository.PublishModel(systemDefinition, tempFile, remoteName);
            }
            finally
            {
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Publication du modèle sur le serveur
        /// </summary>
        /// <param name="model"></param>
        public void PublishLocalModel(CandleModel model)
        {
            ILogger logger = ServiceLocator.Instance.GetService <ILogger>();

            if (logger != null)
            {
                logger.BeginProcess(false, true);
                logger.BeginStep("Publish on remote server", LogType.Info);
            }

            try
            {
                // On récupère ses métadonnées
                ComponentModelMetadata data = model.MetaData;
                if (data != null)
                {
                    //if( !data.IsLastVersion())
                    //{
                    //    if (System.Windows.Forms.MessageBox.Show("You want to publish an older version than the server. Do you want to continue ?", "Warning", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                    //        return;
                    //}

                    ModelLoader.Save(model, data.GetFileName(PathKind.Absolute));

                    // On prend tout ce qu'il y a dans le repository local (==> Il faut que la publication locale
                    // se fasse obligatoirement chaque fois avant )
                    string[] fileNames = System.IO.Directory.GetFiles(System.IO.Path.GetDirectoryName(data.GetFileName(PathKind.Absolute)));
                    PublishZip(model, new List <string>(fileNames), ZipFileName);

                    // Mise à jour des métadatas
                    Metadatas.SetMetadataPublished(data, model);

                    if (logger != null)
                    {
                        logger.Write("Publish on remote server", "Published on remote server ", LogType.Info);
                    }
                }
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.WriteError("Publish on remote server ", "Publish on remote server", ex);
                }
            }
            finally
            {
                if (logger != null)
                {
                    logger.EndStep();
                    logger.EndProcess();
                    IIDEHelper ide = ServiceLocator.Instance.IDEHelper;
                    if (ide != null)
                    {
                        ide.ShowErrorList();
                    }
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Indique qu'un modèle vient d'être publié
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="model">The model.</param>
        internal void SetMetadataPublished(ComponentModelMetadata data, CandleModel model)
        {
            data.ServerVersion = data.LocalVersion = model.Version.Revision;

            MetadataChangedEventArg e = new MetadataChangedEventArg(data);

            OnMetadataChanged(e);
        }
Exemplo n.º 20
0
        public Task BuyAsync(CandleModel candle)
        {
            _hasOpenPosition = true;
            _userBalanceService.SetBuyPrice(candle);
            Console.WriteLine($"Buy crypto currency. Date: {candle.StartDateTime}; Price: ${candle.ClosePrice}; Rate: {_userBalanceService.Rate}\n");

            return(Task.FromResult(0));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Initialisation du modèle (lors du chargement du modèle dans le DocData)
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="fileName">Name of the file.</param>
        internal void SetModel(CandleModel model, string fileName)
        {
            // On ne charge que celui de la solution courante (au cas ou on a ouvert d'autre modèle en navigant)
            string folder = Path.GetDirectoryName(fileName);

            try
            {
                if (!Utils.StringCompareEquals(folder, ServiceLocator.Instance.ShellHelper.SolutionFolder))
                {
                    return;
                }
            }
            catch
            {
                // Aucune solution ouverte
                return;
            }

            fileName = Path.ChangeExtension(fileName, FileExtension);
            if (_config != null && fileName == _filePath)
            {
                return;
            }

            // Si il y avait un modèle, on se désabonne.
            if (_model != null && _model.Store != null)
            {
                Dispose(true);

                model.Store.EventManagerDirectory.ElementAdded.Remove(
                    new EventHandler <ElementAddedEventArgs>(OnElementAdded));
                model.Store.EventManagerDirectory.ElementDeleted.Remove(
                    new EventHandler <ElementDeletedEventArgs>(OnElementDeleted));
                model.Store.EventManagerDirectory.ElementPropertyChanged.Remove(
                    new EventHandler <ElementPropertyChangedEventArgs>(OnPropertyChanged));
                _initialized = false;
            }

            _filePath = fileName;
            _model    = model;

            if (model != null)
            {
                if (Initialize())
                {
                    Load();
                    try
                    {
                        ServiceLocator.Instance.ShellHelper.AddFileToSolution(_filePath);
                    }
                    catch
                    {
                    }
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PublishAsTemplateCommand"/> class.
        /// </summary>
        /// <param name="selection">The selection.</param>
        /// <param name="fileName">Name of the file.</param>
        public PublishAsTemplateCommand(object selection, string fileName)
        {
            this._fileName = fileName;
            NodeShape shape = selection as NodeShape;

            if (shape != null)
            {
                this._model = shape.ModelElement as CandleModel;
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Copie les executables et les artefacts dans le répertoire d'exécution
        /// </summary>
        /// <param name="model">The model.</param>
        public static void CopyToRuntimeFolder(CandleModel model)
        {
            if (model.Component == null)
            {
                return;
            }

            ILogger logger       = ServiceLocator.Instance.GetService <ILogger>();
            string  targetFolder = string.Empty;

            try
            {
                // Recherche du projet de démarrage pour savoir dans quel répertoire copier les artifacts
                object[] files = (object[])ServiceLocator.Instance.ShellHelper.Solution.SolutionBuild.StartupProjects;
                if (files == null || files.Length == 0)
                {
                    return; // Pas trouvé
                }
                string startupProjectName = (string)files[0];
                startupProjectName = Path.GetFileNameWithoutExtension(startupProjectName);
                EnvDTE.Project startupProject = ServiceLocator.Instance.ShellHelper.FindProjectByName(startupProjectName);
                if (startupProject == null)
                {
                    // Recherche diffèrente pour un projet web
                    startupProjectName = Path.GetFileName(startupProjectName);
                    startupProject     = ServiceLocator.Instance.ShellHelper.FindProjectByName(startupProjectName);
                    if (startupProject == null)
                    {
                        if (logger != null)
                        {
                            logger.Write("Copy binary to runtime folder error", "Unable to find the startup project " + startupProjectName, LogType.Warning);
                        }
                        return;
                    }
                }

                // Vérification des dépendances
                ReferencesHelper.CheckReferences(false, null, new ConfigurationMode(), ReferenceScope.Runtime, model);

                ConfigurationMode mode = new ConfigurationMode(startupProject);

                // Répertoire destination
                targetFolder = Path.Combine(Path.GetDirectoryName(startupProject.FullName), mode.BinPath);

                CopyInFolder(targetFolder, model, mode);
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.WriteError("Copy to runtime folder", String.Format("erreur when copying runtime artifacts to {0}", targetFolder), ex);
                }
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GetLastVersionCommand"/> class.
 /// </summary>
 /// <param name="shape">The shape.</param>
 public GetLastVersionCommand(object shape)
 {
     if (shape != null && shape is PresentationElement)
     {
         _externalComponent = ((PresentationElement)shape).ModelElement as ExternalComponent;
         if (_externalComponent != null)
         {
             _externalModel = _externalComponent.ReferencedModel;
             this._force    = _externalComponent.MetaData.IsLastVersion();
         }
     }
 }
Exemplo n.º 25
0
        ProfitModel IUserBalanceService.GetProfit(decimal sellPrice, DateTime candleDateTime)
        {
            var sellProfit = sellPrice * Rate - _defaultAmount;

            _profit  += sellProfit;
            LastPrice = new CandleModel
            {
                ClosePrice    = sellPrice,
                StartDateTime = candleDateTime
            };
            return(GetProfit(sellProfit));
        }
Exemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GetLastVersionCommand"/> class.
 /// </summary>
 /// <param name="metadata">The metadata.</param>
 /// <param name="force">if set to <c>true</c> [force].</param>
 public GetLastVersionCommand(ComponentModelMetadata metadata, bool force)
 {
     if (metadata != null)
     {
         this._force = force;
         ModelLoader loader = ModelLoader.GetLoader(metadata);
         if (loader != null)
         {
             _externalModel = loader.Model;
         }
     }
 }
Exemplo n.º 27
0
        public Task SellAsync(CandleModel candle)
        {
            _hasOpenPosition = false;
            _userBalanceService.TradingCount++;
            var profit = _userBalanceService.GetProfit(candle.ClosePrice, candle.StartDateTime);
            var msg    = $"Sell crypto currency. Date: {candle.StartDateTime}; Price: ${candle.ClosePrice}; Rate: {_userBalanceService.Rate}\n" +
                         $"Profit: ${profit.Profit}\n" +
                         $"Trading time in hours: {Math.Round(profit.TradingTimeInMinutes / 60.0, 2)}\n";

            Console.WriteLine(msg);

            return(Task.FromResult(0));
        }
Exemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImportWsdlCommand"/> class.
 /// </summary>
 /// <param name="serviceProvider">The service provider.</param>
 /// <param name="obj">The obj.</param>
 public ImportWsdlCommand(IServiceProvider serviceProvider, object obj)
 {
     this._serviceProvider = serviceProvider;
     _nodeShape            = obj as ISupportArrangeShapes;
     if (obj is SoftwareComponentShape)
     {
         this._component = ((SoftwareComponentShape)obj).ModelElement as SoftwareComponent;
         _model          = _component.Model;
     }
     else if (obj is Diagram)
     {
         this._model = ((Diagram)obj).ModelElement as CandleModel;
     }
 }
Exemplo n.º 29
0
        /// <summary>
        /// Populates the specified current component.
        /// </summary>
        /// <param name="currentComponent">The current component.</param>
        /// <param name="model">The model.</param>
        private void Populate(SoftwareComponent currentComponent, CandleModel model)
        {
            _currentComponent = currentComponent;
            lstInheritedConfigurations.AutoGenerateColumns = false;
            lstConfigurations.AutoGenerateColumns          = false;

            if (currentComponent != null)
            {
                foreach (SoftwareLayer layer in currentComponent.Layers)
                {
                    ColLayer.Items.Add(layer.Name);
                }

                colVisibility.Items.Add(Visibility.Public);
                colVisibility.Items.Add(Visibility.Private);

                // Remplissage des configurations courantes
                _items = new ItemList();
                foreach (SoftwareLayer layer in currentComponent.Layers)
                {
                    foreach (ConfigurationPart cfg in layer.Configurations)
                    {
                        Item item = new Item();
                        item.ConfigName     = cfg.Name;
                        item.XmlContent     = cfg.XmlContent;
                        item.LayerName      = layer.Name;
                        item.LayerId        = layer.Id;
                        item.InitialEnabled = item.Enabled = cfg.Enabled;
                        item.IsExternal     = false;
                        item.Visibility     = cfg.Visibility;
                        _items.Add(item);
                    }
                }
                lstConfigurations.DataSource = _items;
            }
            else // On enlève cette page
            {
                tabControl1.TabPages.RemoveAt(0);
            }

            // Configurations externes
            ReferenceWalker      walker  = new ReferenceWalker(ReferenceScope.Runtime, new ConfigurationMode());
            ConfigurationVisitor visitor = new ConfigurationVisitor(true);

            walker.Traverse(visitor, model);

            lstInheritedConfigurations.DataSource =
                visitor.Configurations.FindAll(delegate(ConfigurationPart p) { return(p.Enabled); });
        }
Exemplo n.º 30
0
        /// <summary>
        /// Contextual dependency properties filter
        /// </summary>
        /// <param name="modelElement"></param>
        /// <returns></returns>
        public override PropertyDescriptorCollection GetCustomProperties(ModelElement modelElement)
        {
            PropertyDescriptorCollection collections = base.GetCustomProperties(modelElement);

            _appName = CandleModel.GetInstance(modelElement.Store).Name;

            if (modelElement is ServiceContract || modelElement is ClassImplementation ||
                modelElement is Operation || modelElement is Layer)
            {
                collections.Add(LogCallHandlerProperty.Register(modelElement));
                collections.Add(CacheCallHandlerProperty.Register(modelElement));
                collections.Add(PerformanceCounterCallHandlerProperty.Register(modelElement));
            }

            return(collections);
        }