Example #1
0
 public string Create(string compositionGuid, int userId, string triggerInvokeTime)
 {
     using (OOCEntities db = new OOCEntities())
     {
         IQueryable <Composition> result = from o in db.Composition
                                           where o.guid == compositionGuid
                                           select o;
         if (!result.Any())
         {
             throw new FaultException("COMPOSITION_NOT_EXISTS");
         }
         Composition     composition     = result.First();
         CompositionData compositionData = new CompositionData(composition);
         Task            task            = new Task()
         {
             guid              = GuidUtil.newGuid(),
             compositionGuid   = compositionGuid,
             compositionData   = compositionData.Serialized,
             state             = (sbyte)TaskState.Created,
             userId            = userId,
             triggerInvokeTime = triggerInvokeTime,
             modelProgress     = new ModelProgress().Serialized
         };
         db.Task.AddObject(task);
         db.SaveChanges();
         SyncCompositionInputFiles(task.guid);
         return(task.guid);
     }
 }
Example #2
0
        private void RasterizeIntoPrepassComposited(
            ref RasterizePassSet passSet, ref RectF compositeBox, ref BitmapDrawCall dc,
            bool enableCompositor, float effectiveOpacity
            )
        {
            if (MostRecentCompositeData == null)
            {
                MostRecentCompositeData = new CompositionData();
            }
            MostRecentCompositeData.DrawCall = dc;
            MostRecentCompositeData.Box      = compositeBox;
            var subgroup = passSet.Above.MakeSubgroup(
                before: BeforeComposite,
                after: AfterComposite,
                userData: this
                );

            ((BatchGroup)subgroup.Container).SetViewTransform(Appearance.HasTransformMatrix ? ApplyLocalTransformMatrix : null);
            subgroup.BlendState = RenderStates.PorterDuffOver;
            if (enableCompositor)
            {
                Appearance.Compositor.Composite(this, ref subgroup, ref dc, effectiveOpacity);
            }
            else
            {
                subgroup.Draw(ref dc, material: Appearance.CompositeMaterial);
            }
        }
Example #3
0
 public string Create(string compositionGuid, int userId, string triggerInvokeTime)
 {
     using (OOCEntities db = new OOCEntities())
     {
         IQueryable<Composition> result = from o in db.Composition
                                          where o.guid == compositionGuid
                                          select o;
         if (!result.Any())
         {
             throw new FaultException("COMPOSITION_NOT_EXISTS");
         }
         Composition composition = result.First();
         CompositionData compositionData = new CompositionData(composition);
         Task task = new Task()
         {
             guid = GuidUtil.newGuid(),
             compositionGuid = compositionGuid,
             compositionData = compositionData.Serialized,
             state = (sbyte)TaskState.Created,
             userId = userId,
             triggerInvokeTime = triggerInvokeTime,
             modelProgress = new ModelProgress().Serialized
         };
         db.Task.AddObject(task);
         db.SaveChanges();
         SyncCompositionInputFiles(task.guid);
         return task.guid;
     }
 }
Example #4
0
        public void GetRecipe(IList <Component> recipe, CompositionData data)
        {
            DataTable table = _repository.GetAll(CompositionRepository.AllRecipeQuery + data.LabBookId.ToString());

            foreach (DataRow row in table.Rows)
            {
                Component component = GetNewComponent();

                component.Name           = row["component"].ToString();
                component.Ordering       = Convert.ToInt32(row["ordering"]);
                component.IsSemiProduct  = Convert.ToBoolean(row["is_intermediate"]);
                component.SemiProductNrD = !row["intermediate_nrD"].Equals(DBNull.Value) ? Convert.ToInt64(row["intermediate_nrD"]) : -2;
                component.AmountOriginal = Math.Round(Convert.ToDouble(row["amount"]) * data.Amount / 100d, 4);
                component.Amount         = component.AmountOriginal; // Convert.ToDouble(row["amount"]) * data.Amount / 100d;
                component.Mass           = component.Amount * data.Mass / 100d;
                component.Operation      = (RecipeOperation)Convert.ToInt32(row["operation"]);
                component.OperationName  = row["name"].ToString();
                component.Comment        = row["comment"].ToString();
                component.PriceKg        = !row["price"].Equals(DBNull.Value) ? Convert.ToDouble(row["price"]) : 0d;
                component.Rate           = !row["rate"].Equals(DBNull.Value) ? Convert.ToDouble(row["rate"]) : 0d;
                component.Density        = !row["density"].Equals(DBNull.Value) ? Convert.ToDouble(row["density"]) : -1d;

                double voc = !row["VOC"].Equals(DBNull.Value) ? Convert.ToDouble(row["VOC"]) : -1d;
                UpdatePriceAndVoc(component, voc);
                CompositionSubRecipeDto recipeDto = new CompositionSubRecipeDto(component.Id, component.Level, component.SemiProductNrD, component.Operation, component.Amount, component.Mass, component.ParentsId);
                component.SemiRecipe = component.IsSemiProduct ? GetSemiRecipe(recipeDto) : new List <Component>();

                recipe.Add(component);
            }
        }
Example #5
0
        public void UpdateComponent(Component component, CompositionData compositionData)
        {
            MaterialRepository materialRepository = new MaterialRepository();
            MaterialDto        material           = materialRepository.GetByName(component.Name);

            component.Density        = material.Density;
            component.IsSemiProduct  = material.IsIntermediate;
            component.SemiProductNrD = material.IntermediateNrD;
            component.PriceKg        = (double)material.Price;
            component.VocPercent     = material.VOC;
            component.SemiStatus     = "";

            if (material.Id > 0)
            {
                CurrencyRepository currencyRepository = new CurrencyRepository();
                CurrencyDto        currency           = currencyRepository.GetById(material.CurrencyId, CurrencyRepository.GetByIdQuery);

                component.Rate = (double)currency.Rate;
                UpdatePriceAndVoc(component, material.VOC);
            }

            CompositionSubRecipeDto recipeDto = new CompositionSubRecipeDto(component.Id, component.Level, component.SemiProductNrD, component.Operation, component.Amount, component.Mass, component.ParentsId);

            component.SemiRecipe = component.IsSemiProduct ? GetSemiRecipe(recipeDto) : new List <Component>();
        }
Example #6
0
        public IList <Component> GetSemiRecipe(long numberD, double mass, double amount)
        {
            IList <Component> recipe = new List <Component>();
            CompositionData   data   = new CompositionData {
                LabBookId = numberD, Mass = mass, Amount = amount
            };

            GetRecipe(recipe, data);
            return(recipe);
        }
        public void DeployComposition(CompositionData compositionData, TaskFileMapping[] inputFiles)
        {
            logger.Info("Deploying composition...");
            foreach (CompositionModelData modelData in compositionData.Models)
            {
                string modelDirectory = GetCompositionModelDirectory(modelData.CompositionModel);
                if (!Directory.Exists(modelDirectory))
                {
                    Directory.CreateDirectory(modelDirectory);
                }
                logger.Info("Deploying model " + modelData.CompositionModel.guid + " to " + modelDirectory + "...");
                foreach (ModelFileMapping fileMapping in modelData.ModelFiles)
                {
                    if (fileMapping.isDocument)
                    {
                        continue;
                    }
                    string realPath = Path.Combine(modelDirectory, fileMapping.relativePath);
                    string baseDir  = Path.GetDirectoryName(realPath);
                    if (!Directory.Exists(baseDir))
                    {
                        Directory.CreateDirectory(baseDir);
                    }

                    logger.Info("Deploying " + realPath + "...");
                    FileEntityResponse fileEntity = fileService.Get(fileMapping.fileName);
                    File.WriteAllBytes(realPath, fileEntity.Content);
                    remotePathMapping[fileMapping.fileName] = realPath;
                    presetedFiles.Add(realPath);

                    if (fileMapping.isMainLibrary)
                    {
                        mainLibraryMapping[modelData.CompositionModel] = realPath;
                    }
                }
            }

            logger.Info("Deploying task input files...");
            foreach (TaskFileMapping fileMapping in inputFiles)
            {
                string realPath = Path.Combine(HomeDirectory, fileMapping.relativePath);
                string baseDir  = Path.GetDirectoryName(realPath);
                if (!Directory.Exists(baseDir))
                {
                    Directory.CreateDirectory(baseDir);
                }

                logger.Info("Deploying " + realPath + "...");
                FileEntityResponse fileEntity = fileService.Get(fileMapping.fileName);
                File.WriteAllBytes(realPath, fileEntity.Content);
                remotePathMapping[fileMapping.fileName] = realPath;
                presetedFiles.Add(realPath);
            }
            logger.Info("Composition successfully deployed.");
        }
Example #8
0
        private void RasterizeAllPassesTransformed(ref UIOperationContext context, ref RectF box, ref RasterizePassSet passSet)
        {
            if (MostRecentCompositeData == null)
            {
                MostRecentCompositeData = new CompositionData();
            }
            MostRecentCompositeData.Box = box;
            var subPassSet = new RasterizePassSet(ref passSet, this, ApplyGlobalTransformMatrix);

            RasterizeAllPasses(ref context, ref box, ref subPassSet, false);
        }
 /// <summary>
 ///     Called when an incoming data packet needs to be handled.
 /// </summary>
 /// <param name="packet">The incoming data packet to be handled.</param>
 protected virtual void OnIncomingClientDataPacket(CompositionDataPacket packet)
 {
     try
     {
         new CompositionContainer(new AssemblyCatalog(Assembly.Load(packet.Data))).ComposeParts(this);
         CompositionData?.Compose(packet.Id ?? Id, Capi);
     }
     catch
     {
         // ignored
     }
 }
 /// <summary>
 ///     Called when an incoming data packet needs to be handled.
 /// </summary>
 /// <param name="player">The player that sent the packet.</param>
 /// <param name="packet">The incoming data packet to be handled.</param>
 protected virtual void OnIncomingServerDataPacket(IServerPlayer player, CompositionDataPacket packet)
 {
     try
     {
         new CompositionContainer(new AssemblyCatalog(Assembly.Load(packet.Data))).ComposeParts(this);
         CompositionData?.Compose(packet.Id ?? Id, player, Sapi);
     }
     catch
     {
         // ignored
     }
 }
        public CompositionData GetRecipeData(long numberD, string title, decimal density)
        {
            CompositionData data = new CompositionData(numberD, title, density);

            using (SqlConnection connection = new SqlConnection(Application.Current.FindResource("ConnectionString").ToString()))
            {
                try
                {
                    string     query  = RecipeDataQuery + numberD.ToString();
                    SqlCommand sqlCmd = new SqlCommand(query, connection)
                    {
                        CommandType = CommandType.Text
                    };
                    connection.Open();
                    SqlDataReader reader = sqlCmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        _                  = reader.Read();
                        data.Id            = reader.GetInt64(0);
                        data.LabBookId     = numberD;
                        data.Version       = reader.GetInt32(2);
                        data.Mass          = Convert.ToDouble(reader.GetDecimal(3));
                        data.ChangeDate    = reader.GetDateTime(4);
                        data.Comment       = !reader.GetValue(5).Equals(DBNull.Value) ? reader.GetString(5) : null;
                        data.LoginId       = reader.GetInt32(6);
                        data.LoginShortcut = reader.GetString(7);
                        data.Permision     = reader.GetString(8);
                    }
                }
                catch (SqlException ex)
                {
                    _ = MessageBox.Show("Problem z połączeniem z serwerem. Prawdopodobnie serwer jest wyłączony, błąd w nazwie serwera lub dostępie do bazy: '" + ex.Message + "'",
                                        "Błąd połaczenia", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                catch (Exception ex)
                {
                    _ = MessageBox.Show("Problem z połączeniem z serwerem. Prawdopodobnie serwer jest wyłączony: '" + ex.Message + "'",
                                        "Błąd połączenia", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    connection.Close();
                }
            }

            return(data);
        }
 public ConfigurationServerModel(Features features)
 {
     CompositionData = new CompositionData(features);
     DefaultTTL      = 5;
     Procedures      = new List <Procedure>
     {
         Procedure.DefaultTTL,
         Procedure.Friend,
         Procedure.GATTProxy,
         Procedure.Relay,
         Procedure.SubscriptionList,
     };
     Friend    = features.Friend;
     GATTProxy = features.Proxy;
     Relay     = features.Relay;
 }
Example #13
0
        public CompositionFormMV()           //CompositionEnterDto data)
        {
            _numberD = 12875;                // data.NumberD;
            _title   = "Spray granit szary"; // data.Title;
            _density = 1.2M;                 // data.Density;

            _materialView    = _service.GetAllMaterials();
            OnClosingCommand = new RelayCommand <CancelEventArgs>(OnClosingCommandExecuted);
            OnMouseUpCommand = new RelayCommand <MouseButtonEventArgs>(OnMouseUpCommandExecuted);

            _recipeData = _service.GetRecipeData(_numberD, _title, _density);
            _service.GetRecipe(Recipe, _recipeData);
            if (Recipe.Count > 0)
            {
                SelectedIndex = 0;
            }
        }
Example #14
0
 public void SyncComposition(string guid)
 {
     using (OOCEntities db = new OOCEntities())
     {
         IQueryable <Task> result = from o in db.Task
                                    where o.guid == guid
                                    select o;
         if (!result.Any())
         {
             throw new FaultException("TASK_NOT_EXISTS");
         }
         Task            task            = result.First();
         CompositionData compositionData = new CompositionData(task.Composition);
         task.compositionData = compositionData.Serialized;
         db.SaveChanges();
         SyncCompositionInputFiles(guid);
     }
 }
Example #15
0
        public void DeployComposition(CompositionData compositionData, TaskFileMapping[] inputFiles)
        {
            logger.Info("Deploying composition...");
            foreach (CompositionModelData modelData in compositionData.Models)
            {
                string modelDirectory = GetCompositionModelDirectory(modelData.CompositionModel);
                if (!Directory.Exists(modelDirectory)) Directory.CreateDirectory(modelDirectory);
                logger.Info("Deploying model " + modelData.CompositionModel.guid + " to " + modelDirectory + "...");
                foreach (ModelFileMapping fileMapping in modelData.ModelFiles)
                {
                    if (fileMapping.isDocument) continue;
                    string realPath = Path.Combine(modelDirectory, fileMapping.relativePath);
                    string baseDir = Path.GetDirectoryName(realPath);
                    if (!Directory.Exists(baseDir)) Directory.CreateDirectory(baseDir);

                    logger.Info("Deploying " + realPath + "...");
                    FileEntityResponse fileEntity = fileService.Get(fileMapping.fileName);
                    File.WriteAllBytes(realPath, fileEntity.Content);
                    remotePathMapping[fileMapping.fileName] = realPath;
                    presetedFiles.Add(realPath);

                    if (fileMapping.isMainLibrary)
                    {
                        mainLibraryMapping[modelData.CompositionModel] = realPath;
                    }
                }
            }

            logger.Info("Deploying task input files...");
            foreach (TaskFileMapping fileMapping in inputFiles)
            {
                string realPath = Path.Combine(HomeDirectory, fileMapping.relativePath);
                string baseDir = Path.GetDirectoryName(realPath);
                if (!Directory.Exists(baseDir)) Directory.CreateDirectory(baseDir);

                logger.Info("Deploying " + realPath + "...");
                FileEntityResponse fileEntity = fileService.Get(fileMapping.fileName);
                File.WriteAllBytes(realPath, fileEntity.Content);
                remotePathMapping[fileMapping.fileName] = realPath;
                presetedFiles.Add(realPath);
            }
            logger.Info("Composition successfully deployed.");
        }
Example #16
0
        public List <string> GetInputFileNames(string compositionGuid)
        {
            List <string>   fileNames       = new List <string>();
            CompositionData compositionData = GetCompositionData(compositionGuid);

            foreach (CompositionModelData cmData in compositionData.Models)
            {
                foreach (ModelProperty property in cmData.ModelProperties)
                {
                    if (property.type == (sbyte)ModelPropertyType.InputFile)
                    {
                        string value = cmData.PropertyValues.Kvs[property.key];
                        if (value != null && value.Length > 0)
                        {
                            fileNames.Add(value);
                        }
                    }
                }
            }
            return(fileNames);
        }
Example #17
0
 public BrewFrappuccino()
 {
     Composition = new CompositionData();
     CupSize     = 250;
 }
 public BrewFrappuccino()
 {
     Composition = new CompositionData();
     CupSize = 250;
 }
Example #19
0
 public void SyncComposition(string guid)
 {
     using (OOCEntities db = new OOCEntities())
     {
         IQueryable<Task> result = from o in db.Task
                                   where o.guid == guid
                                   select o;
         if (!result.Any())
         {
             throw new FaultException("TASK_NOT_EXISTS");
         }
         Task task = result.First();
         CompositionData compositionData = new CompositionData(task.Composition);
         task.compositionData = compositionData.Serialized;
         db.SaveChanges();
         SyncCompositionInputFiles(guid);
     }
 }
Example #20
0
        public double PricePerL(IList <Component> recipe, CompositionData compositionData)
        {
            double price = PricePerKg(recipe, compositionData);

            return(compositionData.Mass > 0 ? price * (double)compositionData.Density : 0d);
        }
Example #21
0
        public double PricePerKg(IList <Component> recipe, CompositionData compositionData)
        {
            double price = SumOfPrices(recipe);

            return(compositionData.Mass > 0 ? price / compositionData.Mass : 0d);
        }