public void Should_list_all_books()
        {
            Catalogue catalogue = new Catalogue();
            catalogue.Add(new Book("1857239407", "George Lucas", "Star Wars: A New Hope", 256, 20));
            catalogue.Add(new Ebook("0450011844", "Frank Herbert", "Dune", 608));

            Assert.That(catalogue.GetTitles(), Is.EqualTo(new[]
            {
                "Dune",
                "Star Wars: A New Hope"
            }));
        }
        static void Main(string[] args)
        {
            var catalogue = new Catalogue();
            catalogue.AddAlbum("dai mu","hisarskiq pop","mitko painera",1998,10m);
            catalogue.AddAlbum("tralala","kichka","painera",2004,0.5m);
            catalogue.AddSong("dai mu","olele",3.55);
            catalogue.AddSong("tralala","nqkva chalga",2.88);

            catalogue.AddAlbum("shat na patkata glavata","slavi","slavi",1997,5m);
            catalogue.AddSong("shat na patkata glavata", "f**k off", 3.55);
            catalogue.AddSong("shat na patkata glavata", "baby", 3.55);
            catalogue.AddAlbum("No Mercy", "slavi", "slavi", 2009, 5m);
            catalogue.AddSong("No Mercy", "ad i rai", 3.55);
            catalogue.AddSong("No Mercy", "bi wish they still", 3.55);
            catalogue.Save("..//..//..//catalogue.xml");

        }
 public ExecuteCommandAddNewCatalogueItem(IBasicActivateItems activator, Catalogue catalogue, ColumnInfoCombineable colInfo) : this(activator, catalogue, colInfo.ColumnInfos)
 {
 }
示例#4
0
        /// <summary>
        /// Importe les données du fichier XML et les enregistre en base de données
        /// </summary>
        /// <param name="filePath">Chemin du fichier XML</param>
        private static void ImportXMLFile(string filePath)
        {
            Console.WriteLine("Import du fichier : " + filePath);
            //Console.WriteLine($"Import du fichier : {filePath}");

            try
            {
                using (LISAEntities entities = new LISAEntities())
                {
                    // Ouvre la connexion vers la base de donnée
                    entities.Database.Connection.Open();
                    XDocument document = XDocument.Load(filePath);

                    ParseTypeMedia(entities);

                    // Boucle sur les opérations du fichier XML
                    foreach (XElement operationElement in document.Descendants(XName.Get("operation")))
                    {
                        Operation operation = ParseOperationElement(operationElement, entities);

                        // Boucle sur les catalogue du fichier XML
                        foreach (XElement catalogElement in operationElement.Elements(XName.Get("catalog")))
                        {
                            Catalogue catalog = ParseCatalogElement(catalogElement, entities, operation);

                            // Boucle sur les magasins du fichier XML
                            foreach (XElement shopElement in catalogElement.Elements(XName.Get("shops")).Elements())
                            {
                                Magasin shop = ParseShopElement(shopElement, entities);
                                ParseShopCatalogElement(shopElement, entities, catalog, shop);
                            }

                            // Boucle sur les pages du fichier XML
                            foreach (XElement pageElement in catalogElement.Elements(XName.Get("pages")).Elements())
                            {
                                Page page = ParsePageElement(pageElement, entities, catalog);

                                foreach (XElement articleElement in pageElement.Elements(XName.Get("products")).Elements())
                                {
                                    Categorie categorie = ParseCategorieElement(articleElement, entities);

                                    Article article = ParseArticleElement(articleElement, entities, pageElement, categorie);

                                    ParseMediumPictoElement(articleElement, entities, article);

                                    //ParseMediumImageElement(articleElement, entities, article);

                                    PageArticle pageArticle = ParsePageArticleElement(articleElement, entities, page, article);

                                    PrixCatalogueArticle prixCatalogueArticle = ParsePrixCatalogueArticleElement(articleElement, entities, catalog, article);
                                }
                            }
                        }
                    }
                    entities.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Impossible d'importer le fichier {filePath + Environment.NewLine + ex.Message}");
            }

            #region Exo : Ajout opération, catalogue, page
            ////Créer la chaine de connexion
            //using (LISAEntities entities = new LISAEntities())
            //{
            //    entities.Operations.ToList().ForEach(o => entities.Operations.Remove(o));
            //    entities.Catalogues.ToList().ForEach(c => entities.Catalogues.Remove(c));
            //    entities.Pages.ToList().ForEach(p => entities.Pages.Remove(p));
            //    //Créer une opération
            //    Operation op = new Operation
            //    {
            //        Code = "Je suis le code de l'opération",
            //        Titre = "Je suis le titre de l'opération",
            //        DateDebut = DateTime.Now,
            //        DateFin = DateTime.Now,
            //        Catalogues = null
            //    };

            //    entities.Operations.Add(op);

            //    //Créer un catalogue
            //    Catalogue cat = new Catalogue
            //    {
            //        Hauteur = 500,
            //        Largeur = 500,
            //        Libelle = "Je suis le libelle du catalogue",
            //        Type = "Je suis le type du catalogue",
            //        Vitesse = "V3",
            //        Operation = op
            //    };

            //    entities.Catalogues.Add(cat);

            //    //Créer trois pages

            //    List<Page> allPages = new List<Page>();
            //    for (int i = 0; i < 10; i++)
            //    {
            //        Page page = new Page()
            //        {
            //            Numero = i,
            //            Catalogue = cat
            //        };
            //        allPages.Add(page);
            //    }

            //    //Page page1 = new Page()
            //    //{
            //    //    Numero = 1,
            //    //    Catalogue = cat
            //    //};

            //    //Page page2 = new Page()
            //    //{
            //    //    Numero = 2,
            //    //    Catalogue = cat
            //    //};

            //    //Page page3 = new Page()
            //    //{
            //    //    Numero = 3,
            //    //    Catalogue = cat
            //    //};

            //    //entities.Pages.Add(page1);
            //    //entities.Pages.Add(page2);
            //    //entities.Pages.Add(page3);

            //    foreach (Page page in allPages)
            //    {
            //        entities.Pages.Add(page);
            //    }
            #endregion
        }
示例#5
0
        /// <summary>
        /// Importe une #<see cref="Page"/> du fichier XML et l'enregistre dans la base de donnée. Si la page importée est déjà en base de données,
        /// la supprime et la restaure avec les nouvelles données.
        /// </summary>
        /// <param name="pageElement">XElement de page</param>
        /// <param name="entities">Gestionnaire DB</param>
        /// <param name="catalog">Catalogue en liaison avec la page</param>
        /// <returns>Retourne la page importée</returns>
        private static Page ParsePageElement(XElement pageElement, LISAEntities entities, Catalogue catalog)
        {
            int pageId  = int.Parse(pageElement.Attribute(XName.Get("id")).Value);
            int pageNum = int.Parse(pageElement.Element(XName.Get("number")).Value);

            Page result = entities.Pages.FirstOrDefault(p => p.ImportId == pageId);

            if (result != null)
            {
                entities.Pages.Remove(result);
            }

            result = new Page()
            {
                ImportId  = pageId,
                Numero    = pageNum,
                Catalogue = catalog,
            };

            entities.Pages.Add(result);

            return(result);
        }
 public ExecuteCommandEditExistingCatalogue(IActivateItems activator, Catalogue catalogue)
     : base(activator)
 {
     Catalogue = catalogue;
 }
示例#7
0
 public WarehouseActions(Warehouse warehouse, Catalogue catalogue)
 {
     this.warehouse = warehouse;
     this.catalogue = catalogue;
 }
 public ExecuteCommandImportCatalogueDescriptionsFromShare(IActivateItems activator, FileCollectionCommand sourceFileCollection, Catalogue targetCatalogue) : base(activator, sourceFileCollection)
 {
     _targetCatalogue   = targetCatalogue;
     UseTripleDotSuffix = true;
 }
示例#9
0
 private void AddCatalogue(Catalogue cata)
 {
     _collection.AddCatalogue(cata);
 }
示例#10
0
 public CatalogueManager(Catalogue catalogue)
 {
     Catalogue = catalogue;
 }
示例#11
0
        private void InitializeData()
        {
            var catalId   = Guid.NewGuid();
            var catalName = "Catalogue # 1";
            var catalogue = new Catalogue
            {
                Id   = catalId,
                Name = catalName
            };

            var cvm = new FullCatalogueViewModel
            {
                Id   = catalId,
                Name = catalName
            };

            var catalId1   = Guid.NewGuid();
            var catalName1 = "Catalogue # 2";
            var catalogue1 = new Catalogue
            {
                Id   = catalId1,
                Name = catalName1
            };

            var cvm1 = new FullCatalogueViewModel
            {
                Id   = catalId1,
                Name = catalName1
            };

            Context.Set <Catalogue>().Add(catalogue);
            Context.Set <Catalogue>().Add(catalogue1);

            var catalGrId      = Guid.NewGuid();
            var catalGrName    = "CatalogueGroup #1";
            var catalogueGroup = new CatalogueGroup
            {
                Id   = catalGrId,
                Name = catalGrName
            };

            catalogueGroup.Catalogues.Add(catalogue);

            var cvtgr = new FullCatalogueGroupViewModel
            {
                Id         = catalGrId,
                Name       = catalGrName,
                Catalogues = new List <FullCatalogueViewModel> {
                    cvm
                }
            };

            var catalGrId1      = Guid.NewGuid();
            var catalGrName1    = "CatalogueGroup #2";
            var catalogueGroup1 = new CatalogueGroup
            {
                Id   = catalGrId1,
                Name = catalGrName1
            };

            catalogueGroup1.Catalogues.AddRange(new[] { catalogue, catalogue1 });

            var cvtgr1 = new FullCatalogueGroupViewModel
            {
                Id         = catalGrId1,
                Name       = catalGrName1,
                Catalogues = new List <FullCatalogueViewModel> {
                    cvm, cvm1
                }
            };

            Context.Set <CatalogueGroup>().Add(catalogueGroup);
            Context.Set <CatalogueGroup>().Add(catalogueGroup1);

            Context.SaveChanges();
            _planResult = new List <FullCatalogueGroupViewModel>
            {
                cvtgr, cvtgr1
            };
        }
示例#12
0
        /// <inheritdoc/>
        public string GetHumanReadableTimepsanIfKnownOf(Catalogue catalogue, bool discardOutliers)
        {
            DataTable dt;

            try
            {
                var repo = new DQERepository(catalogue.CatalogueRepository);

                Evaluation mostRecentEvaluation = repo.GetMostRecentEvaluationFor(catalogue);

                if (mostRecentEvaluation == null)
                {
                    return("Unknown");
                }

                dt = PeriodicityState.GetPeriodicityForDataTableForEvaluation(mostRecentEvaluation, "ALL", false);
            }
            catch (Exception e)
            {
                return("Unknown:" + e.Message);
            }

            if (dt == null || dt.Rows.Count < 2)
            {
                return("Unknown");
            }

            int discardThreshold = discardOutliers? GetDiscardThreshold(dt):-1;

            string minMonth = null;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (Convert.ToInt32(dt.Rows[i]["CountOfRecords"]) > discardThreshold)
                {
                    minMonth = dt.Rows[i][1].ToString();
                    break;
                }
            }

            string maxMonth = null;

            for (int i = dt.Rows.Count - 1; i >= 0; i--)
            {
                if (Convert.ToInt32(dt.Rows[i]["CountOfRecords"]) > discardThreshold)
                {
                    maxMonth = dt.Rows[i][1].ToString();
                    break;
                }
            }

            if (maxMonth == null || minMonth == null)
            {
                return("All Values Below Threshold");
            }

            if (maxMonth == minMonth)
            {
                return(minMonth);
            }


            return(minMonth + " To " + maxMonth);
        }
 public void AddToCatalogues(Catalogue catalogue)
 {
     base.AddObject("Catalogues", catalogue);
 }
 public static Catalogue CreateCatalogue(string version, long ID, global::System.Guid tid, string name, long createdById, long modifiedById, global::System.DateTimeOffset created, global::System.DateTimeOffset modified)
 {
     Catalogue catalogue = new Catalogue();
     catalogue.Version = version;
     catalogue.Id = ID;
     catalogue.Tid = tid;
     catalogue.Name = name;
     catalogue.CreatedById = createdById;
     catalogue.ModifiedById = modifiedById;
     catalogue.Created = created;
     catalogue.Modified = modified;
     return catalogue;
 }
示例#15
0
文件: TestBit.cs 项目: kjk/volante
        public void Run(TestConfig config)
        {
            int count = config.Count;
            var res = new TestBitResult();
            config.Result = res;

            DateTime start = DateTime.Now;
            IDatabase db = config.GetDatabase();

            Catalogue root = (Catalogue)db.Root;
            Tests.Assert(root == null);
            root = new Catalogue();
            root.optionIndex = db.CreateBitIndex<Car>();
            root.modelIndex = db.CreateFieldIndex<string, Car>("model", IndexType.Unique);
            db.Root = root;

            long rnd = 1999;
            int i, n;

            Options selectedOptions = Options.TURBO | Options.DISEL | Options.FWD | Options.ABS | Options.EBD | Options.ESP | Options.AIR_COND | Options.HATCHBACK | Options.CLASS_C;
            Options unselectedOptions = Options.AUTOMATIC;

            for (i = 0, n = 0; i < count; i++)
            {
                Options options = (Options)rnd;
                Car car = new Car();
                car.hps = i;
                car.maxSpeed = car.hps * 10;
                car.timeTo100 = 12;
                car.vendor = "Toyota";
                car.specification = "unknown";
                car.model = Convert.ToString(rnd);
                car.options = options;
                root.modelIndex.Put(car);
                root.optionIndex[car] = (int)options;
                if ((options & selectedOptions) == selectedOptions && (options & unselectedOptions) == 0)
                {
                    n += 1;
                }
                rnd = (3141592621L * rnd + 2718281829L) % 1000000007L;
            }
            res.InsertTime = DateTime.Now - start;

            start = DateTime.Now;
            i = 0;
            foreach (Car car in root.optionIndex.Select((int)selectedOptions, (int)unselectedOptions))
            {
                Tests.Assert((car.options & selectedOptions) == selectedOptions);
                Tests.Assert((car.options & unselectedOptions) == 0);
                i += 1;
            }
            Tests.Assert(i == n);
            res.SearchTime = DateTime.Now - start;

            start = DateTime.Now;
            i = 0;
            foreach (Car car in root.modelIndex)
            {
                root.optionIndex.Remove(car);
                car.Deallocate();
                i += 1;
            }
            Tests.Assert(i == count);
            root.optionIndex.Clear();
            res.RemoveTime = DateTime.Now - start;
            db.Close();
        }
示例#16
0
        private int ScoreMatches(KeyValuePair <IMapsDirectlyToDatabaseTable, DescendancyList> kvp, List <Regex> regexes, string[] explicitTypeNames, CancellationToken cancellationToken)
        {
            int score = 0;

            if (cancellationToken.IsCancellationRequested)
            {
                return(0);
            }

            //if we are searching for a specific ID
            if (ID.HasValue)
            {
                var obj = kvp.Key;

                //If the object is masquerading as something else, better to check that
                if (kvp.Key is IMasqueradeAs m)
                {
                    obj = m.MasqueradingAs() as IMapsDirectlyToDatabaseTable ?? obj;
                }

                if (obj.ID != ID.Value)
                {
                    return(0);
                }
                else
                {
                    score += 10;
                }
            }

            if (RespectUserSettings && ScoreZeroBecauseOfUserSettings(kvp))
            {
                return(0);
            }

            // if user is searching for a specific Type of object and we ain't it
            if (explicitTypeNames.Any())
            {
                if (!explicitTypeNames.Contains(kvp.Key.GetType().Name))
                {
                    return(0);
                }
            }

            //don't suggest AND/OR containers it's not helpful to navigate to these (unless user is searching by Type explicitly)
            if (explicitTypeNames.Length == 0 && kvp.Key is IContainer)
            {
                return(0);
            }

            //don't suggest AND/OR containers it's not helpful to navigate to these (unless user is searching by Type explicitly)
            if (_scoreZeroForCohortAggregateContainers && explicitTypeNames.Length == 0 && kvp.Key is CohortAggregateContainer)
            {
                return(0);
            }

            //if there are no tokens
            if (!regexes.Any())
            {
                if (explicitTypeNames.Any()) //if they have so far just typed a TypeName
                {
                    return(1);
                }
                else
                {
                    return(1);//no regexes AND no TypeName what did they type! whatever everyone scores the same
                }
            }
            //make a new list so we can destructively read it
            regexes = new List <Regex>(regexes);

            //match on the head vs the regex tokens
            score += Weights[0] * CountMatchToString(regexes, kvp.Key);

            score += Weights[0] * CountMatchType(regexes, kvp.Key);

            //match on the parents if there's a decendancy list
            if (kvp.Value != null)
            {
                var parents         = kvp.Value.Parents;
                int numberOfParents = parents.Length;

                //for each prime after the first apply it as a multiple of the parent match
                for (int i = 1; i < Weights.Length; i++)
                {
                    //if we have run out of parents
                    if (i > numberOfParents)
                    {
                        break;
                    }

                    var parent = parents[parents.Length - i];

                    if (parent != null)
                    {
                        if (!(parent is IContainer))
                        {
                            score += Weights[i] * CountMatchToString(regexes, parent);
                            score += Weights[i] * CountMatchType(regexes, parent);
                        }
                    }
                }
            }

            //if there were unmatched regexes
            if (regexes.Any())
            {
                return(0);
            }

            Catalogue catalogueIfAny = GetCatalogueIfAnyInDescendancy(kvp);

            if (catalogueIfAny != null && catalogueIfAny.IsDeprecated)
            {
                return(score / 10);
            }

            //if we are bumping up matches
            if (score > 0 && BumpMatches.Contains(kvp.Key))
            {
                score += BumpWeight;
            }

            return(score);
        }
示例#17
0
        private void clkAjouterMeuble(object sender, RoutedEventArgs e)
        {
            Catalogue popup = new Catalogue();

            popup.ShowDialog();
        }
示例#18
0
        /////////////////////////////////Temp modify "userinput" to "retrievaldetaillist" START
        public static void UpdateRetrievalDetailsFull(int retrievalid, List <RetrievalDetail> retrievaldetaillist, int clerkid)
        {
            using (Team10ADModel context = new Team10ADModel())
            {
                //Updating quantities in Catalogue, Retrieval and RetrievalDetail tables
                foreach (RetrievalDetail userdetail in retrievaldetaillist)
                {
                    RetrievalDetail existingdata = context.RetrievalDetails.Where(r => r.RetrievalID == userdetail.RetrievalID && r.ItemCode == userdetail.ItemCode).First();

                    existingdata.RetrievedQuantity = userdetail.RetrievedQuantity;

                    Catalogue item = context.Catalogues.Where(x => x.ItemCode == userdetail.ItemCode).First();
                    item.BalanceQuantity        -= userdetail.RetrievedQuantity;
                    item.PendingRequestQuantity -= userdetail.RetrievedQuantity;

                    context.SaveChanges();
                }

                Retrieval retrieval = context.Retrievals.Where(x => x.RetrievalID == retrievalid).First();
                retrieval.Status = "Retrieved";
                context.SaveChanges();

                //Generate Disbursement and DisbursementDetails
                //List<RetrievalDetail> retrievaldetaillist = retrieval.RetrievalDetails.ToList();

                /////////////////////////////////Temp modify "userinput" to "retrievaldetaillist" END

                List <Requisition> reqlist      = retrieval.Requisitions.ToList();
                List <Department>  fulldeptlist = context.Departments.ToList();

                //Preparing the retrieved qty of the item to be splitted amount the disbursement
                Dictionary <string, int> retrievedqtybal = new Dictionary <string, int>();
                foreach (RetrievalDetail rd in retrievaldetaillist)
                {
                    //Assign zero if there is no value stored
                    int balqty = (rd.RetrievedQuantity == null) ? 0 : (int)rd.RetrievedQuantity;
                    retrievedqtybal.Add(rd.ItemCode, balqty);
                }

                foreach (Department d in fulldeptlist)
                {
                    //Counter to check if disbursement record was generated for this department
                    //This will determine to create a new disbursement for this department or not
                    int deptcounter = 0;
                    List <DisbursementDetail> disDetailList = new List <DisbursementDetail>();

                    //Disbursement disbursementnew = new Disbursement();
                    Disbursement disbursement = new Disbursement();

                    foreach (RetrievalDetail retrievaldetail in retrievaldetaillist)
                    {
                        //Match all requisition record of this retrieval to see if any match a department
                        foreach (Requisition r in reqlist)
                        {
                            //Counter to check for partial or completed requisition
                            int notcompletedcheck = 0;

                            //If match department, loop through the requisition detail and save into disbursement detail
                            if (d.DepartmentCode == r.Employee.DepartmentCode)
                            {
                                deptcounter++;
                                //Creating a new disbursement
                                if (deptcounter == 1)
                                {
                                    //Disbursement disbursement = new Disbursement();
                                    disbursement.CollectionDate = DateTime.Now;
                                    disbursement.PointID        = r.Employee.Department.CollectionPoint.PointID;
                                    disbursement.DepartmentCode = r.Employee.DepartmentCode;
                                    disbursement.Status         = "Uncollected";
                                    disbursement.StoreStaffID   = clerkid;
                                    context.Disbursements.Add(disbursement);
                                    context.SaveChanges();

                                    //disbursementnew = context.Disbursements.OrderByDescending(x => x.DisbursementID).First();
                                }
                                List <RequisitionDetail> reqDetailList = r.RequisitionDetails.ToList();
                                foreach (RequisitionDetail reqdetail in reqDetailList)
                                {
                                    //Counter to make sure no duplicates of the item is created in the details
                                    int itemcounter = 0;
                                    foreach (DisbursementDetail disDetail in disDetailList)
                                    {
                                        //If itemcode exist, increment the requested quantity in the disbursement
                                        //Assign the quantity retrieved to the corresponding requisition
                                        //Decrement from the temporary store of the balance retrieved quantity
                                        if (disDetail.ItemCode == reqdetail.ItemCode && reqdetail.ItemCode == retrievaldetail.ItemCode)
                                        {
                                            itemcounter++;

                                            //The outer if set checks if the retrieved qty is sufficient to split among the departments
                                            if (retrievedqtybal[disDetail.ItemCode] >= reqdetail.QuantityRequested)
                                            {
                                                //Checks for partial/new requisition cases
                                                //If null can ignore the quantity retrieved in the requisition
                                                if (reqdetail.QuantityRetrieved == null)
                                                {
                                                    disDetail.QuantityRequested         += reqdetail.QuantityRequested;
                                                    reqdetail.QuantityRetrieved          = reqdetail.QuantityRequested;
                                                    retrievedqtybal[disDetail.ItemCode] -= (int)reqdetail.QuantityRequested;
                                                }
                                                //If not null can safetly do the math
                                                else
                                                {
                                                    disDetail.QuantityRequested         += (reqdetail.QuantityRequested - reqdetail.QuantityRetrieved);
                                                    reqdetail.QuantityRetrieved         += (reqdetail.QuantityRequested - reqdetail.QuantityRetrieved);
                                                    retrievedqtybal[disDetail.ItemCode] -= (int)(reqdetail.QuantityRequested - reqdetail.QuantityRetrieved);
                                                }
                                            }
                                            else if ((retrievedqtybal[disDetail.ItemCode] < reqdetail.QuantityRequested) && (retrievedqtybal[disDetail.ItemCode] > 0))
                                            {
                                                if (reqdetail.QuantityRetrieved == null)
                                                {
                                                    disDetail.QuantityRequested         += retrievedqtybal[disDetail.ItemCode];
                                                    reqdetail.QuantityRetrieved         += retrievedqtybal[disDetail.ItemCode];
                                                    retrievedqtybal[disDetail.ItemCode] -= (int)retrievedqtybal[disDetail.ItemCode];
                                                }
                                                else
                                                {
                                                    if (reqdetail.QuantityRetrieved + retrievedqtybal[disDetail.ItemCode] > reqdetail.QuantityRequested)
                                                    {
                                                        disDetail.QuantityRequested         += (retrievedqtybal[disDetail.ItemCode] - reqdetail.QuantityRetrieved);
                                                        reqdetail.QuantityRetrieved         += (retrievedqtybal[disDetail.ItemCode] - reqdetail.QuantityRetrieved);
                                                        retrievedqtybal[disDetail.ItemCode] -= (int)(retrievedqtybal[disDetail.ItemCode] - reqdetail.QuantityRetrieved);
                                                    }
                                                    else
                                                    {
                                                        disDetail.QuantityRequested         += retrievedqtybal[disDetail.ItemCode];
                                                        reqdetail.QuantityRetrieved         += retrievedqtybal[disDetail.ItemCode];
                                                        retrievedqtybal[disDetail.ItemCode] -= retrievedqtybal[disDetail.ItemCode];
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                //Actually not necessary since balance available to split to disbursement is already 0
                                                //Just putting a zero incase of null value
                                                if (reqdetail.QuantityRetrieved == null)
                                                {
                                                    disDetail.QuantityRequested += 0;
                                                    reqdetail.QuantityRetrieved  = 0;
                                                }
                                            }
                                        }
                                    }
                                    //If no existing itemcode in the List<RequisitionDetail>, create a new instance of it
                                    if (reqdetail.ItemCode == retrievaldetail.ItemCode && itemcounter == 0)
                                    {
                                        DisbursementDetail disburementdetail = new DisbursementDetail();
                                        disburementdetail.DisbursementID = disbursement.DisbursementID;
                                        disburementdetail.ItemCode       = reqdetail.ItemCode;

                                        if (retrievedqtybal[disburementdetail.ItemCode] >= reqdetail.QuantityRequested)
                                        {
                                            //Checks for partial/new requisition cases
                                            //If null can ignore the quantity retrieved in the requisition
                                            if (reqdetail.QuantityRetrieved == null)
                                            {
                                                disburementdetail.QuantityRequested          = reqdetail.QuantityRequested;
                                                reqdetail.QuantityRetrieved                  = reqdetail.QuantityRequested;
                                                retrievedqtybal[disburementdetail.ItemCode] -= (int)reqdetail.QuantityRequested;
                                            }
                                            //If not null can safetly do the math
                                            else
                                            {
                                                disburementdetail.QuantityRequested          = (reqdetail.QuantityRequested - reqdetail.QuantityRetrieved);
                                                reqdetail.QuantityRetrieved                 += (reqdetail.QuantityRequested - reqdetail.QuantityRetrieved);
                                                retrievedqtybal[disburementdetail.ItemCode] -= (int)(reqdetail.QuantityRequested - reqdetail.QuantityRetrieved);
                                            }
                                        }
                                        else if ((retrievedqtybal[disburementdetail.ItemCode] < reqdetail.QuantityRequested) && (retrievedqtybal[disburementdetail.ItemCode] > 0))
                                        {
                                            if (reqdetail.QuantityRetrieved == null)
                                            {
                                                disburementdetail.QuantityRequested          = retrievedqtybal[disburementdetail.ItemCode];
                                                reqdetail.QuantityRetrieved                  = retrievedqtybal[disburementdetail.ItemCode];
                                                retrievedqtybal[disburementdetail.ItemCode] -= retrievedqtybal[disburementdetail.ItemCode];
                                            }
                                            else
                                            {
                                                if (reqdetail.QuantityRetrieved + retrievedqtybal[disburementdetail.ItemCode] > reqdetail.QuantityRequested)
                                                {
                                                    disburementdetail.QuantityRequested          = (retrievedqtybal[disburementdetail.ItemCode] - reqdetail.QuantityRetrieved);
                                                    reqdetail.QuantityRetrieved                 += (retrievedqtybal[disburementdetail.ItemCode] - reqdetail.QuantityRetrieved);
                                                    retrievedqtybal[disburementdetail.ItemCode] -= (int)(retrievedqtybal[disburementdetail.ItemCode] - reqdetail.QuantityRetrieved);
                                                }
                                                else
                                                {
                                                    disburementdetail.QuantityRequested          = retrievedqtybal[disburementdetail.ItemCode];
                                                    reqdetail.QuantityRetrieved                 += retrievedqtybal[disburementdetail.ItemCode];
                                                    retrievedqtybal[disburementdetail.ItemCode] -= retrievedqtybal[disburementdetail.ItemCode];
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (reqdetail.QuantityRetrieved == null)
                                            {
                                                reqdetail.QuantityRetrieved = 0;
                                            }
                                            disburementdetail.QuantityRequested = 0;
                                        }

                                        disDetailList.Add(disburementdetail);
                                    }
                                }
                                //Loop through details of requisition to check for completeness
                                foreach (RequisitionDetail rd in reqDetailList)
                                {
                                    if (rd.QuantityRequested != rd.QuantityRetrieved)
                                    {
                                        notcompletedcheck++;
                                    }
                                }
                                if (notcompletedcheck == 0)
                                {
                                    r.Status = "Completed";
                                }
                                else
                                {
                                    r.Status = "Partial";
                                }
                                context.SaveChanges();
                            }
                        }
                    }
                    //Creating a new set of disbursement details
                    if (deptcounter > 0)
                    {
                        foreach (DisbursementDetail ddetail in disDetailList)
                        {
                            context.DisbursementDetails.Add(ddetail);
                            //TODO: Send notification email
                            context.SaveChanges();
                        }
                        LogicUtility.Instance.SendDisbursementEmail(disbursement.DisbursementID);
                    }
                }
            }
        }
        private void InitializeData()
        {
            var sizeId = Guid.NewGuid();
            var sizeName = "Medium";
            var sizeCode = "M";

            var size = new Size
            {
                Id = sizeId,
                Name = sizeName,
                Code = sizeCode
            };

            var sizeVm = new SizeViewModel
            {
                Id = sizeId,
                Name = sizeName,
                Code = sizeCode
            };

            var productVarId = Guid.NewGuid();
            var productVarName = "Orange";
            var productVarColor = "Orange";
            var productVariant = new ProductVariant
            {
                Id = productVarId,
                Name = productVarName,
                Color = productVarColor,
                Size = size,
                SizeId = size.Id
            };

            var productVariantVm = new ProductVariantViewModel
            {
                Id = productVarId,
                Name = productVarName,
                Color = productVarColor,
                Size = sizeVm
            };

            var productId = Guid.NewGuid();
            var prodName = "Blue Jeans";
            var prodDimensions = "23x56x21";
            var product = new Product
            {
                Id = productId,
                Name = prodName,
                Dimensions = prodDimensions,
                Variant = productVariant,
                VariantId = productVariant.Id
            };

            var productViewModel = new ProductViewModel
            {
                Id = productId,
                Name = prodName,
                Dimensions = prodDimensions,
                Variant = productVariantVm
            };

            var prodVarId1 = Guid.NewGuid();
            var prodVarName1 = "Yellow";
            var prodVarColor1 = "Yellow";
            var productVariant1 = new ProductVariant
            {
                Id = prodVarId1,
                Name = prodVarName1,
                Color = prodVarColor1
            };

            var productVariantVm1 = new ProductVariantViewModel
            {
                Id = prodVarId1,
                Name = prodVarName1,
                Color = prodVarColor1
            };

            var prodId1 = Guid.NewGuid();
            var prodName1 = "Blue Jeans";
            var prodDimensions1 = "53x51x99";
            var product1 = new Product
            {
                Id = prodId1,
                Name = prodName1,
                Dimensions = prodDimensions1,
                Variant = productVariant1,
                VariantId = productVariant1.Id
            };

            var productVm1 = new ProductViewModel
            {
                Id = prodId1,
                Name = prodName1,
                Dimensions = prodDimensions1,
                Variant = productVariantVm1
            };

            var prodId2 = Guid.NewGuid();
            var prodName2 = "Precious";
            var prodDimensions2 = "13x36x61";
            var product2 = new Product
            {
                Id = prodId2,
                Name = prodName2,
                Dimensions = prodDimensions2
            };

            var prodVm2 = new ProductViewModel
            {
                Id = prodId2,
                Name = prodName2,
                Dimensions = prodDimensions2
            };

            Context.Set<Size>().Add(size);
            Context.Set<ProductVariant>().Add(productVariant);
            Context.Set<Product>().Add(product);

            Context.Set<ProductVariant>().Add(productVariant1);
            Context.Set<Product>().Add(product1);

            Context.Set<Product>().Add(product2);

            var catId = Guid.NewGuid();
            var catName = "Halloween";
            var category = new Category
            {
                Id = catId,
                Name = catName,
                Products = new List<Product>
              {
                  product, product2, product1
              }
            };

            var cat = new CategoryViewModel
            {
                Id = catId,
                Name = catName,
                Products = new List<ProductViewModel>
                {
                    productViewModel, productVm1, prodVm2
                }
            };

            var catId1 = Guid.NewGuid();
            var catName1 = "Test Drive";
            var category1 = new Category
            {
                Id = catId1,
                Name = catName1,
                Products = new List<Product>
              {
                  product2, product1
              }
            };

            var cat1 = new CategoryViewModel
            {
                Id = catId1,
                Name = catName1,
                Products = new List<ProductViewModel>
                {
                    prodVm2, productVm1
                }
            };

            var catId2 = Guid.NewGuid();
            var catName2 = "Empty products";
            var category2 = new Category
            {
                Id = catId2,
                Name = catName2
            };

            var cat2 = new CategoryViewModel
            {
                Id = catId2,
                Name = catName2
            };

            Context.Set<Category>().Add(category);
            Context.Set<Category>().Add(category1);
            Context.Set<Category>().Add(category2);

            var catalId = Guid.NewGuid();
            var catalName = "Catalogue # 1";
            var catalogue = new Catalogue
            {
                Id = catalId,
                Name = catalName
            };
            catalogue.Categories.AddRange(new[] { category, category1 });

            var catalVm = new CatalogueViewModel
            {
                Id = catalId,
                Name = catalName,
                Categories = new[]
                {
                    cat, cat1
                }
            };

            var catalId1 = Guid.NewGuid();
            var catalName1 = "Catalogue # 2";
            var catalogue1 = new Catalogue
            {
                Id = catalId1,
                Name = catalName1
            };
            catalogue1.Categories.AddRange(new[] { category, category1, category2 });

            var catalVm1 = new CatalogueViewModel
            {
                Id = catalId1,
                Name = catalName1,
                Categories = new []
                {
                    cat, cat1, cat2
                }
            };

            Context.Set<Catalogue>().Add(catalogue);
            Context.Set<Catalogue>().Add(catalogue1);

            var catalGrId = Guid.NewGuid();
            var catalGrName = "CatalogueGroup #1";
            var catalogueGroup = new CatalogueGroup
            {
                Id = catalGrId,
                Name = catalGrName
            };
            catalogueGroup.Catalogues.Add(catalogue);

            var catalGrVm = new CatalogueGroupViewModel
            {
                Id = catalGrId,
                Name = catalGrName,
                Catalogues = new List<CatalogueViewModel>
                {
                   catalVm
                }
            };

            var catalGrId1 = Guid.NewGuid();
            var catalGrId2 = "CatalogueGroup #2";
            var catalogueGroup1 = new CatalogueGroup
            {
                Id = catalGrId1,
                Name = catalGrId2
            };
            catalogueGroup1.Catalogues.AddRange(new[] { catalogue, catalogue1 });

            var catalGrVm1 = new CatalogueGroupViewModel
            {
                Id = catalGrId1,
                Name = catalGrId2,
                Catalogues = new List<CatalogueViewModel>
                {
                    catalVm, catalVm1
                }
            };

            _planResult = new List<CatalogueGroupViewModel>
            {
                catalGrVm, catalGrVm1
            };

            Context.Set<CatalogueGroup>().Add(catalogueGroup);
            Context.Set<CatalogueGroup>().Add(catalogueGroup1);

            Context.SaveChanges();
        }
示例#20
0
        public static int GenerateAdjustmentVoucherDetails(List <RetrievalDetail> suggested, List <RetrievalDetail> userinput, int clerkid)
        {
            using (Team10ADModel context = new Team10ADModel())
            {
                //To be returned for redirecting to the correct adjustment detail
                int adjustmentVoucherId = 0;
                //Counter to check whether there is any item that need adjustment
                int needAdjustment = 0;

                //StockAdjustmentVoucher adjNew = new StockAdjustmentVoucher();
                List <StockAdjustmentVoucherDetail> adjDetailList = new List <StockAdjustmentVoucherDetail>();

                foreach (RetrievalDetail sDetail in suggested)
                {
                    foreach (RetrievalDetail uDetail in userinput)
                    {
                        if (sDetail.ItemCode == uDetail.ItemCode)
                        {
                            //Check that there is a change in suggested quantity and that the balance is below the requested quantity
                            //This is to give clerk the flexibility to still reduce the quantity and not trigger an adjustment
                            if (sDetail.RetrievedQuantity < sDetail.RequestedQuantity && sDetail.RetrievedQuantity != uDetail.RetrievedQuantity)
                            {
                                needAdjustment++;
                                if (needAdjustment == 1)
                                {
                                    StockAdjustmentVoucher adj = new StockAdjustmentVoucher();
                                    adj.StoreStaffID = clerkid;
                                    adj.DateIssue    = DateTime.Now;
                                    adj.Status       = "Pending";
                                    context.StockAdjustmentVouchers.Add(adj);
                                    context.SaveChanges();

                                    //adjNew = context.StockAdjustmentVouchers.OrderByDescending(x => x.VoucherID).First();
                                    //adjustmentVoucherId = adjNew.VoucherID;

                                    adjustmentVoucherId = adj.VoucherID;
                                }

                                StockAdjustmentVoucherDetail adjDetail = new StockAdjustmentVoucherDetail();
                                adjDetail.VoucherID        = adjustmentVoucherId;
                                adjDetail.ItemCode         = uDetail.ItemCode;
                                adjDetail.QuantityAdjusted = -(uDetail.Catalogue.BalanceQuantity - uDetail.RetrievedQuantity);

                                Catalogue item = context.Catalogues.Where(x => x.ItemCode == adjDetail.ItemCode).First();
                                item.BalanceQuantity -= (uDetail.Catalogue.BalanceQuantity - uDetail.RetrievedQuantity);

                                adjDetail.QuantityAfter = item.BalanceQuantity;
                                adjDetailList.Add(adjDetail);
                                context.SaveChanges();
                            }
                        }
                    }
                }

                if (needAdjustment > 0)
                {
                    foreach (StockAdjustmentVoucherDetail detail in adjDetailList)
                    {
                        context.StockAdjustmentVoucherDetails.Add(detail);
                        context.SaveChanges();
                    }
                }

                StoreStaff supervisor = context.StoreStaffs.Where(x => x.Title == "Supervisor").First();
                StoreStaff manager    = context.StoreStaffs.Where(x => x.Title == "Manager").First();
                if (adjustmentVoucherId > 0 && AdjustmentVoucherCost(adjustmentVoucherId) <= 250)
                {
                    LogicUtility.Instance.SendAdjustmentEmail(adjustmentVoucherId, supervisor.StoreStaffID);
                }
                else if (adjustmentVoucherId > 0 && AdjustmentVoucherCost(adjustmentVoucherId) > 250)
                {
                    LogicUtility.Instance.SendAdjustmentEmail(adjustmentVoucherId, manager.StoreStaffID);
                }

                return(adjustmentVoucherId);
            }
        }
 public ExecuteCommandImportCatalogueDescriptionsFromShare(IActivateItems activator, Catalogue targetCatalogue) : base(activator, null)
 {
     _targetCatalogue   = targetCatalogue;
     UseTripleDotSuffix = true;
 }
示例#22
0
        private void cbxCatalogues_SelectedIndexChanged(object sender, EventArgs e)
        {
            var cata = cbxCatalogues.SelectedItem as Catalogue;

            if (cata == null)
            {
                return;
            }

            //if the Catalogue changes clear the old filters because they apply to the last dataset
            if (_lastCatalogue != null)
            {
                if (!Equals(_lastCatalogue, cata))//catalogue has changed
                {
                    //if there are no user specified ones clear the mandatory filters (if there are any)
                    if (_filterUIs.All(f => f.Mandatory))
                    {
                        ClearFilters();
                    }
                    else //there are some user specified ones
                    if (
                        //confirm with user before we erase these
                        _activator.YesNo(
                            "Changing the dataset will clear the Filters you have configured, is this what you want?",
                            "Change Dataset"))
                    {
                        ClearFilters();
                    }
                    else
                    {
                        cbxCatalogues.SelectedItem = _lastCatalogue;
                        return;
                    }
                }
            }

            //add any mandatory filters that are not yet part of the configuration
            foreach (var mandatoryFilter in cata.GetAllMandatoryFilters())
            {
                if (!_filterUIs.Any(f => f.Filter.Equals(mandatoryFilter)))
                {
                    var m = AddFilter(mandatoryFilter);
                    m.Mandatory = true; //mandatory ones cannot be changed or gotten rid of
                }
            }

            //set the columns
            var allColumns = cata.GetAllExtractionInformation(ExtractionCategory.Any).ToArray();

            cbxColumns.DataSource = allColumns;

            var identifiers = allColumns.Where(ei => ei.IsExtractionIdentifier).ToArray();

            //if no columns have yet been marked as IsExtractionIdentifier then we show all columns and demand that the user lock one in
            if (identifiers.Length == 0)
            {
                UnlockIdentifier(null);
            }
            else
            if (identifiers.Length == 1)
            {
                LockIdentifier(identifiers[0]);//there is only one IsExtractionIdentifier so lock it in automatically
            }
            else
            {
                _knownIdentifiersMode = true;

                //if there are multiple columns marked with IsExtractionIdentifier then we show all of them but no others
                //e.g. SMR02 where there could be Mother CHI, Baby CHI and Father CHI do not unmark extraction identifier just because they changed it
                cbxColumns.DataSource = identifiers;
                UnlockIdentifier(null);
            }

            var allFilters = allColumns.SelectMany(c => c.ExtractionFilters).ToArray();

            ddAvailableFilters.DataSource = allFilters;

            _lastCatalogue = cata;
        }
示例#23
0
        private string CreateCorpusCatalogue()
        {
            // Create the package catalogue imdi file
            var catalogue = new Catalogue
            {
                Name  = Name + " Catalogue",
                Title = Title,
                Date  = DateTime.Today.ToISO8601TimeFormatDateOnlyString(),
            };

            foreach (var language in MetadataIso3Languages)
            {
                var imdiLanguage = LanguageList.Find(language).ToSimpleLanguageType();
                if (imdiLanguage != null)
                {
                    catalogue.DocumentLanguages.Language.Add(imdiLanguage);
                }
            }


            foreach (var language in ContentIso3Languages)
            {
                var imdiLanguage = LanguageList.Find(language).ToSubjectLanguageType();
                if (imdiLanguage != null)
                {
                    catalogue.SubjectLanguages.Language.Add(imdiLanguage);
                }
            }

            // project
            catalogue.Project.Add(new Project(this));

            // location
            if (Location != null)
            {
                catalogue.Location.Add(new LocationType(Location));
            }

            // content type
            if (!string.IsNullOrEmpty(ContentType))
            {
                catalogue.ContentType.Add(ContentType);
            }

            // applications
            if (!string.IsNullOrEmpty(Applications))
            {
                catalogue.Applications = Applications;
            }

            // author
            if (!string.IsNullOrEmpty(Author))
            {
                catalogue.Author.Add(new CommaSeparatedStringType {
                    Value = Author
                });
            }

            // publisher
            if (!string.IsNullOrEmpty(Publisher))
            {
                catalogue.Publisher.Add(Publisher);
            }

            // keys
            foreach (var kvp in _keys)
            {
                catalogue.Keys.Key.Add(new KeyType {
                    Name = kvp.Key, Value = kvp.Value
                });
            }

            // access
            if (!string.IsNullOrEmpty(Access.DateAvailable))
            {
                catalogue.Access.Date = Access.DateAvailable;
            }

            if (!string.IsNullOrEmpty(Access.Owner))
            {
                catalogue.Access.Owner = Access.Owner;
            }

            // description
            foreach (var item in BaseMajorObject.Description)
            {
                catalogue.Description.Add(new DescriptionType
                {
                    ArchiveHandle = item.ArchiveHandle,
                    LanguageId    = item.LanguageId,
                    Link          = item.Link,
                    Name          = item.Name,
                    Value         = item.Value
                });
            }

            // write the xml file
            var catImdi = new MetaTranscript {
                Items = new object[] { catalogue }, Type = MetatranscriptValueType.CATALOGUE
            };

            return(catImdi.WriteImdiFile(PackagePath, Name).Replace("\\", "/"));
        }
示例#24
0
 private void SetDefaultCatalogue(Catalogue catalog)
 {
     InterplayStorage.SetSelectedCatalog(catalog.name);
     this.CreateProductButtons();
 }
示例#25
0
        /// <summary>
        /// Importe un #<see cref="PrixCatalogueArticle"/> du fichier XML et l'enregistre dans la base de donnée. Si la PrixCatalogueArticle
        /// importée est déjà en base de données, la supprime et la restaure avec les nouvelles données.
        /// </summary>
        /// <param name="articleElement">XElement article</param>
        /// <param name="entities">Gestionnaire DB</param>
        /// <param name="catalog">Catalogue en liaison avec PrixCatalogueArticle</param>
        /// <param name="article">Article en liaison avec PrixCatalogueArticle</param>
        /// <returns>Retourne le PrixCatalogueArticle importé</returns>
        private static PrixCatalogueArticle ParsePrixCatalogueArticleElement(XElement articleElement, LISAEntities entities, Catalogue catalog, Article article)
        {
            decimal.TryParse(articleElement.Element(XName.Get("price")).Value, out decimal prixCatalogueArticlePrix);
            decimal.TryParse(articleElement.Element(XName.Get("price_before_coupon")).Value, out decimal prixCatalogueArticlePrixAvantCoupon);
            decimal.TryParse(articleElement.Element(XName.Get("price_crossed")).Value, out decimal prixCatalogueArticlePrixAvantCroise);
            decimal.TryParse(articleElement.Element(XName.Get("Reduction_euro")).Value, out decimal prixCatalogueArticleReductionEuro);
            decimal.TryParse(articleElement.Element(XName.Get("Reduction_percent")).Value, out decimal prixCatalogueArticleReductionPourcent);
            decimal.TryParse(articleElement.Element(XName.Get("Avantage_euro")).Value, out decimal prixCatalogueArticleAvantageEuro);
            decimal.TryParse(articleElement.Element(XName.Get("Avantage_percent")).Value, out decimal prixCatalogueArticleAvantagePourcent);
            decimal.TryParse(articleElement.Element(XName.Get("ecotaxe")).Value, out decimal prixCatalogueArticleEcotaxe);

            PrixCatalogueArticle result = entities.PrixCatalogueArticles.FirstOrDefault(p => p.IdArticle == article.Id && p.IdCatalogue == catalog.Id);

            if (result != null)
            {
                entities.PrixCatalogueArticles.Remove(result);
            }

            result = new PrixCatalogueArticle()
            {
                Prix              = prixCatalogueArticlePrix,
                PrixAvantCoupon   = prixCatalogueArticlePrixAvantCoupon,
                PrixAvantCroise   = prixCatalogueArticlePrixAvantCroise,
                ReductionEuro     = prixCatalogueArticleReductionEuro,
                ReductionPourcent = prixCatalogueArticleReductionPourcent,
                AvantageEuro      = prixCatalogueArticleAvantageEuro,
                AvantagePourcent  = prixCatalogueArticleAvantagePourcent,
                Ecotaxe           = prixCatalogueArticleEcotaxe,
                Article           = article,
                Catalogue         = catalog
            };

            entities.PrixCatalogueArticles.Add(result);

            return(result);
        }
 public ExecuteCommandAddNewSupportingDocument(IBasicActivateItems activator, Catalogue catalogue) : base(activator)
 {
     _targetCatalogue = catalogue;
 }
示例#27
0
        /// <summary>
        /// Importe un #<see cref="MagasinCatalogue"/> du fichier XML. Si le MagasinCatalogue est déjà en base de données,
        /// le supprime et le restaure avec les nouvelles données.
        /// </summary>
        /// <param name="shopElement">Element de magasin</param>
        /// <param name="entities">Gestionnaire DB</param>
        /// <param name="catalog">Catalogue en liaison avec la table MagasinCatalogue</param>
        /// <param name="shop">Magasin en liaison avec la table MagasinCatalogue</param>
        private static MagasinCatalogue ParseShopCatalogElement(XElement shopElement, LISAEntities entities, Catalogue catalog, Magasin shop)
        {
            DateTime shopStartdate        = UnixTimeStampToDateTime(double.Parse(shopElement.Element(XName.Get("startDate")).Value));
            DateTime shopDisplaystartdate = UnixTimeStampToDateTime(double.Parse(shopElement.Element(XName.Get("displayStartDate")).Value));
            DateTime shopDisplayenddate   = UnixTimeStampToDateTime(double.Parse(shopElement.Element(XName.Get("displayEndDate")).Value));


            MagasinCatalogue result = entities.MagasinCatalogues.FirstOrDefault(c => c.IdCatalogue == catalog.ImportId && c.IdMagasin == shop.Id);

            if (result != null)
            {
                entities.MagasinCatalogues.Remove(result);
            }

            result = new MagasinCatalogue()
            {
                DateDebut = shopDisplaystartdate,
                DateFin   = shopDisplayenddate,
                Catalogue = catalog,
                Magasin   = shop
            };

            entities.MagasinCatalogues.Add(result);

            return(result);
        }
        public ExecuteCommandAddNewSupportingDocument(IBasicActivateItems activator, FileCollectionCombineable fileCollectionCombineable, Catalogue targetCatalogue) : base(activator)
        {
            _fileCollectionCombineable = fileCollectionCombineable;
            _targetCatalogue           = targetCatalogue;
            var allExisting = targetCatalogue.GetAllSupportingDocuments(FetchOptions.AllGlobalsAndAllLocals);

            foreach (var doc in allExisting)
            {
                FileInfo filename = doc.GetFileName();

                if (filename == null)
                {
                    continue;
                }

                var collisions = _fileCollectionCombineable.Files.FirstOrDefault(f => f.FullName.Equals(filename.FullName, StringComparison.CurrentCultureIgnoreCase));

                if (collisions != null)
                {
                    SetImpossible("File '" + collisions.Name + "' is already a SupportingDocument (ID=" + doc.ID + " - '" + doc.Name + "')");
                }
            }
        }
示例#29
0
        private void GetRecordCount(Catalogue c, out int count, out int distinct, out string identifierName)
        {
            //one of the fields will be marked IsExtractionIdentifier (e.g. CHI column)
            ExtractionInformation[] bestExtractionInformation = c.GetAllExtractionInformation(ExtractionCategory.Any).Where(e => e.IsExtractionIdentifier).ToArray();

            TableInfo tableToQuery = null;

            //there is no extraction identifier or we are not doing distincts
            if (!bestExtractionInformation.Any())
            {
                //there is no extraction identifier, let's see what tables there are that we can query
                var tableInfos =
                    c.GetAllExtractionInformation(ExtractionCategory.Any)
                    .Select(ei => ei.ColumnInfo.TableInfo_ID)
                    .Distinct()
                    .Select(_repository.GetObjectByID <TableInfo>)
                    .ToArray();

                //there is only one table that we can query
                if (tableInfos.Count() == 1)
                {
                    tableToQuery = tableInfos.Single();//query that one
                }
                else
                if (tableInfos.Count(t => t.IsPrimaryExtractionTable) == 1)//there are multiple tables but there is only one IsPrimaryExtractionTable
                {
                    tableToQuery = tableInfos.Single(t => t.IsPrimaryExtractionTable);
                }
                else
                {
                    throw new Exception("Did not know which table to query out of " + string.Join(",", tableInfos.Select(t => t.GetRuntimeName())) + " you can resolve this by marking one (AND ONLY ONE) of these tables as IsPrimaryExtractionTable=true");//there are multiple tables and multiple or no IsPrimaryExtractionTable
                }
            }
            else
            {
                tableToQuery = bestExtractionInformation[0].ColumnInfo.TableInfo;//there is an extraction identifier so use it's table to query
            }
            bool hasExtractionIdentifier = bestExtractionInformation.Any();

            var server = c.GetDistinctLiveDatabaseServer(DataAccessContext.InternalDataProcessing, true);

            using (var con = server.GetConnection())
            {
                con.Open();

                if (tableToQuery.Name.Contains("@"))
                {
                    throw new Exception("Table '" + tableToQuery.Name + "' looks like a table valued function so cannot be processed");
                }

                string sql = "SELECT " + Environment.NewLine;
                sql += "count(*) as recordCount";

                //if it has extraction information and we want a distinct count
                if (hasExtractionIdentifier && _args.IncludeDistinctIdentifierCounts)
                {
                    sql += ",\r\ncount(distinct " + bestExtractionInformation[0].SelectSQL + ") as recordCountDistinct" + Environment.NewLine;
                }

                sql += " from " + Environment.NewLine;
                sql += tableToQuery.Name;

                identifierName = hasExtractionIdentifier ? bestExtractionInformation[0].GetRuntimeName() : null;

                DbCommand cmd = server.GetCommand(sql, con);
                cmd.CommandTimeout = _args.Timeout;

                DbDataReader r = cmd.ExecuteReader();
                r.Read();

                count    = Convert.ToInt32(r["recordCount"]);
                distinct = hasExtractionIdentifier && _args.IncludeDistinctIdentifierCounts ? Convert.ToInt32(r["recordCountDistinct"]) : -1;

                con.Close();
            }
        }
示例#30
0
 public ExecuteCommandRunDQEOnCatalogue(IActivateItems activator, Catalogue catalogue) : base(activator)
 {
     _catalogue = catalogue;
 }
 public IAtomicCommandWithTarget SetTarget(DatabaseEntity target)
 {
     _catalogue = (Catalogue)target;
     return(this);
 }
示例#32
0
 public abstract void GenerateReport(Catalogue c, IDataLoadEventListener listener, CancellationToken cancellationToken);
示例#33
0
 public ExecuteCommandBulkProcessCatalogueItems(IActivateItems activator, Catalogue catalogue) : base(activator)
 {
     _catalogue = catalogue;
 }
示例#34
0
        /// <summary>
        /// Maps a KeyValuePair of <ViewComic, int> to a dictionary of <Comic, int>
        /// </summary>
        /// <param name="viewcomicDict"></param>
        /// <returns>Dictionary consisting of comics with amounts in dictionary</returns>
        public static Dictionary <Comic, int> ComicDictMapper(ObservableCollection <KeyValuePair <ViewComic, int> > viewcomicDict, Catalogue catalogue)
        {
            Dictionary <Comic, int> comicDict = new Dictionary <Comic, int>();

            for (int i = 0; i < viewcomicDict.Count; i++)
            {
                Comic comic = catalogue.Comics.Single(c => c.GetHashCode() == Mapper.ViewComicMapper(viewcomicDict[i].Key).GetHashCode());

                comicDict.Add(comic, viewcomicDict[i].Value);
            }

            return(comicDict);
        }
示例#35
0
 public RunDataQualityEngineWindow(IBasicActivateItems activator, Catalogue c)
     : base(activator, () => GetCommand(c))
 {
 }
示例#36
0
 private static DqeOptions GetCommand(Catalogue c)
 {
     return(new DqeOptions {
         Catalogue = c.ID
     });
 }
示例#37
0
文件: TestBit.cs 项目: kjk/tenderbase
    public static void Main(string[] args)
    {
        Storage db = StorageFactory.Instance.CreateStorage();
        db.Open("testbit.dbs", pagePoolSize);

        Catalogue root = (Catalogue) db.GetRoot();
        if (root == null)
        {
            root = new Catalogue();
            root.optionIndex = db.CreateBitIndex();
            root.modelIndex = db.CreateFieldIndex(typeof(Car), "model", true);
            db.SetRoot(root);
        }
        BitIndex index = root.optionIndex;
        long start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
        long rnd = 1999;
        int i, n;

        int selectedOptions = Car.TURBO | Car.DISEL | Car.FWD | Car.ABS | Car.EBD | Car.ESP | Car.AIR_COND | Car.HATCHBACK | Car.CLASS_C;
        int unselectedOptions = Car.AUTOMATIC;

        for (i = 0, n = 0; i < nRecords; i++)
        {
            rnd = (3141592621L * rnd + 2718281829L) % 1000000007L;
            int options = (int) rnd;
            Car car = new Car();
            car.model = Convert.ToString(rnd);
            car.options = options;
            root.modelIndex.Put(car);
            root.optionIndex.Put(car, options);
            if ((options & selectedOptions) == selectedOptions && (options & unselectedOptions) == 0)
            {
                n += 1;
            }
        }
        Console.Out.WriteLine("Elapsed time for inserting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");

        start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
        IEnumerator iterator = root.optionIndex.GetEnumerator(selectedOptions, unselectedOptions);
        for (i = 0; iterator.MoveNext(); i++)
        {
            Car car = (Car) iterator.Current;
            Assert.That((car.options & selectedOptions) == selectedOptions);
            Assert.That((car.options & unselectedOptions) == 0);
        }

        Console.Out.WriteLine("Number of selected cars: " + i);
        Assert.That(i == n);
        Console.Out.WriteLine("Elapsed time for bit search through " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
        start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
        foreach (var o in root.modelIndex)
        {
            Car car = (Car) o;
            root.optionIndex.Remove(car);
            car.Deallocate();
        }
        root.optionIndex.Clear();
        Console.Out.WriteLine("Elapsed time for removing " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");

        db.Close();
    }
        private void InitializeData()
        {
            var catalId = Guid.NewGuid();
            var catalName = "Catalogue # 1";
            var catalogue = new Catalogue
            {
                Id = catalId,
                Name = catalName
            };

            var cvm = new FullCatalogueViewModel
            {
                Id = catalId,
                Name = catalName
            };

            var catalId1 = Guid.NewGuid();
            var catalName1 = "Catalogue # 2";
            var catalogue1 = new Catalogue
            {
                Id = catalId1,
                Name = catalName1
            };

            var cvm1 = new FullCatalogueViewModel
            {
                Id = catalId1,
                Name = catalName1
            };

            Context.Set<Catalogue>().Add(catalogue);
            Context.Set<Catalogue>().Add(catalogue1);

            var catalGrId = Guid.NewGuid();
            var catalGrName = "CatalogueGroup #1";
            var catalogueGroup = new CatalogueGroup
            {
                Id = catalGrId,
                Name = catalGrName
            };
            catalogueGroup.Catalogues.Add(catalogue);

            var cvtgr = new FullCatalogueGroupViewModel
            {
                Id = catalGrId,
                Name = catalGrName,
                Catalogues = new List<FullCatalogueViewModel> { cvm }
            };

            var catalGrId1 = Guid.NewGuid();
            var catalGrName1 = "CatalogueGroup #2";
            var catalogueGroup1 = new CatalogueGroup
            {
                Id = catalGrId1,
                Name = catalGrName1
            };
            catalogueGroup1.Catalogues.AddRange(new[] { catalogue, catalogue1 });

            var cvtgr1 = new FullCatalogueGroupViewModel
            {
                Id = catalGrId1,
                Name = catalGrName1,
                Catalogues = new List<FullCatalogueViewModel> { cvm, cvm1 }
            };

            Context.Set<CatalogueGroup>().Add(catalogueGroup);
            Context.Set<CatalogueGroup>().Add(catalogueGroup1);

            Context.SaveChanges();
            _planResult = new List<FullCatalogueGroupViewModel>
            {
                cvtgr, cvtgr1
            };
        }