private static void connectVents()
 {
     for (var i = 0; i < AllJackInTheBoxes.Count - 1; i++)
     {
         var a = AllJackInTheBoxes[i];
         var b = AllJackInTheBoxes[i + 1];
         a.vent.Right = b.vent;
         b.vent.Left  = a.vent;
     }
     // Connect first with last
     AllJackInTheBoxes.First().vent.Left = AllJackInTheBoxes.Last().vent;
     AllJackInTheBoxes.Last().vent.Right = AllJackInTheBoxes.First().vent;
 }
Beispiel #2
0
        public static Customer GetCustomerByEmail(string email)
        {
            Customer temp = Customers.First();

            foreach (Customer c in Customers)
            {
                if (c.getEmail() == email)
                {
                    temp = c;
                }
            }
            return(temp);
        }
 public static BPlayer Find(int ID)
 {
     try
     {
         return(Players.First(x => x.ID == ID));
     }
     catch (Exception) { return(null); }
 }
Beispiel #4
0
        public static Assembly FindAssemblyBy(this string assemblyName)
        {
            DependencyContext deps = DependencyContext.Default;

            System.Collections.Generic.List <CompilationLibrary> res = deps.CompileLibraries.Where(d => d.Name.Contains(assemblyName)).ToList();
            Assembly assembly = Assembly.Load(new AssemblyName(res.First().Name));

            return(assembly);
        }
Beispiel #5
0
        private void ResetTenderValueToZero(string currentTenderTypeID, string currentTenderName)
        {
            TenderData tenderData   = new TenderData(ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID);
            string     tenderTypeID = tenderData.GetTenderID(ApplicationSettings.Terminal.StoreId, ((int)(PosisOperations.PayCurrency)).ToString());

            if (!currentTenderTypeID.Equals(tenderTypeID, StringComparison.OrdinalIgnoreCase))
            {
                gridSource.First(tender =>
                                 tender.TenderTypeId.Equals(currentTenderTypeID, StringComparison.OrdinalIgnoreCase)).Total = 0m;
            }
            else
            {
                gridSource.First(tender =>
                                 tender.TenderName.Equals(currentTenderName, StringComparison.OrdinalIgnoreCase)).Total = 0m;
            }

            gvTenders.InvalidateRows();

            UpdateTotalAmount();
        }
Beispiel #6
0
        public static Lending GetLendingByID(int id)
        {
            Lending temp = Lendings.First();

            foreach (Lending l in Lendings)
            {
                if (l.getLendingID() == id)
                {
                    temp = l;
                }
            }
            return(temp);
        }
Beispiel #7
0
        public static Order GetOrderByID(int id)
        {
            Order temp = Orders.First();

            foreach (Order o in Orders)
            {
                if (o.getID() == id)
                {
                    temp = o;
                }
            }
            return(temp);
        }
Beispiel #8
0
        public static Sale GetSaleByID(int id)
        {
            Sale temp = Sales.First();

            foreach (Sale s in Sales)
            {
                if (s.getSaleID() == id)
                {
                    temp = s;
                }
            }
            return(temp);
        }
Beispiel #9
0
        public static Record GetRecordByQR(int qr)
        {
            Record temp = Records.First();

            foreach (Record r in Records)
            {
                if (r.getQrCode() == qr)
                {
                    temp = r;
                }
            }
            return(temp);
        }
Beispiel #10
0
        // Get methods for Lists
        public static Vendor GetVendorByID(int id)
        {
            Vendor temp = Vendors.First();

            foreach (Vendor v in Vendors)
            {
                if (v.getID() == id)
                {
                    temp = v;
                }
            }
            return(temp);
        }
Beispiel #11
0
        public List <G_UserDTO> Update(System.Collections.Generic.List <G_UserDTO> dtoList)
        {
            var user = Mapper.Map <G_UserDTO, G_User>(dtoList.First());

            this._IG_UserRepository.Update(user);
            return(new List <G_UserDTO>());
            //return base.F_Update<G_UserDTO, List<G_UserDTO>, G_User>(dtoList
            // , _IG_UserRepository
            // , dto => dto.Id
            // , (dto, entity) =>
            // {
            //     //entity.G_Entity = Mapper.Map<G_EntityDTO, G_Entity>(dto.G_Entity);
            //     entity.G_EntityId = dto.G_EntityId;
            //     entity.WebsiteId = dto.WebsiteId;
            //     entity.IsActive = dto.IsActive;
            //     entity.Password = dto.Password;
            //     entity.ModifiedBy = dto.ModifiedBy;
            // });
        }
Beispiel #12
0
        protected override void FixInternal()
        {
            if (!Movie.AutomaticFolderRoot.HasValue())
            {
                throw new FixCheckException("Movie has no automatic folder root");
            }
            if (Movie.ManualLocations.Count > 1)
            {
                throw new FixCheckException("Movie has multiple manual locations - unclear which to copy across");
            }
            if (Movie.ManualLocations.Count == 0)
            {
                //no files to copy
                Movie.UseAutomaticFolders = true;
                Movie.UseManualLocations  = false;
                return;
            }

            if (Movie.ManualLocations.Count == 1)
            {
                DirectoryInfo source = new DirectoryInfo(Movie.ManualLocations.First());
                if (!source.Exists)
                {
                    Movie.UseManualLocations  = false;
                    Movie.UseAutomaticFolders = true;
                    return;
                }

                if (!source.EnumerateFiles().Any() && !source.EnumerateDirectories().Any())
                {
                    //directory has nothing in it
                    FileHelper.RemoveDirectory(source.FullName);
                    Movie.UseManualLocations  = false;
                    Movie.UseAutomaticFolders = true;
                    return;
                }

                Movie.UseAutomaticFolders = true;
                //try to copy/move files
                System.Collections.Generic.List <string> automaticLocations = Movie.AutomaticLocations().ToList();

                if (automaticLocations.Count > 1)
                {
                    throw new FixCheckException("Multiple target locations for the automated folders");
                }

                if (!automaticLocations.Any())
                {
                    throw new FixCheckException("No target automatic folders can be established");
                }

                if (source.FullName.Equals(automaticLocations.First(), StringComparison.CurrentCultureIgnoreCase))
                {
                    Movie.UseManualLocations = false;
                    return;
                }

                //Do we want to copy the whole folder or just some files from witin?
                //we have one location to copy to

                bool manualLocationOnlyHasOneMovie = source.EnumerateFiles().Where(f => f.IsMovieFile()).All(file => Movie.NameMatch(file, false));

                if (manualLocationOnlyHasOneMovie)
                {
                    CopyOrMove(source, automaticLocations.First());
                }
                else
                {
                    MoveFiles(source.EnumerateFiles().Where(f => f.IsMovieFile()).Where(file => Movie.NameMatch(file, false)), automaticLocations.First());
                }

                Movie.UseManualLocations = false;
            }
        }
        public void KmeanPlusPlus(ref List <MyGrouping <int, Grade> > CentralPoint, System.Collections.Generic.List <IGrouping <int, Grade> > pointList)
        {
            Random ran = new Random();      // Khoi tao Student ID bat dau va ket thuc trong danh sach de random vi tri khoi tao
            int    startingStudentID = pointList.First().Key;
            int    endingStudentID   = pointList.Last().Key;

            var temporaryVariable = new MyGrouping <int, Grade>();       // Khoi tao central point dau tien bang cach random

            CentralPoint.Add(temporaryVariable);
            int kmeanPlusPlusInitializePoint = ran.Next(startingStudentID, endingStudentID);
            var TheFisrtPoint = CentralPoint[0];

            CopyPoint(ref TheFisrtPoint, pointList.Single(c => c.Key == kmeanPlusPlusInitializePoint));

            int Count = 1;                  // Da ton tai san 1 central point

            while (true)                    // Bat dau tim cac central point con lai
            {
                if (Count == ClusterAmount) // Thoa so luong cluster yeu cau thi break
                {
                    break;
                }

                List <MyGrouping <double?, Grade> > MinDistanceList = new List <MyGrouping <double?, Grade> >();      // Khoi tao List chua khoang cach be nhat den central point gan nhat cua tat cac cac point
                foreach (var point in pointList)
                {
                    List <double?> Result = new List <double?>(); // List chua khoang cach den tung central point cua 1 diem
                    for (int i = 0; i < Count; i++)
                    {
                        var temp = 0;
                        Result.Add(temp);
                    }
                    for (int i = 0; i < this.SubjectAmount; i++)        // Cong thuc tinh khoang cach, nhung khong tinh cang bac 2
                    {
                        for (int j = 0; j < Count; j++)
                        {
                            Result[j] += (point.ElementAt(i).Mark - CentralPoint[j].ElementAt(i).Mark) * (point.ElementAt(i).Mark - CentralPoint[j].ElementAt(i).Mark);
                        }
                    }

                    double?minResult = Result[0];       // Tim ra khoang cach be nhat
                    for (int i = 0; i < Count; i++)
                    {
                        if (Result[i] < minResult)
                        {
                            minResult = Result[i];
                        }
                    }

                    MyGrouping <double?, Grade> temporaryCentralPoint = new MyGrouping <double?, Grade>(); // khoi tao 1 instance dai dien cho 1 point voi key la khoang cach ngan nhat toi central point gan nhat cua point do
                    temporaryCentralPoint.Key = minResult;
                    for (int j = 0; j < this.SubjectAmount; j++)
                    {
                        temporaryCentralPoint.Add(new Grade {
                        });
                    }
                    int elementCount = 0;
                    foreach (var c in temporaryCentralPoint)
                    {
                        temporaryCentralPoint.ElementAt(elementCount).Mark = point.ElementAt(elementCount).Mark;
                        elementCount++;
                    }
                    MinDistanceList.Add(temporaryCentralPoint);
                }

                IGrouping <double?, Grade> MaxPoint = MinDistanceList.First(); // Sau khi da co duoc ket qua khoang cach cua tung point den central point gan nhat cua no, ta se duyet het tat ca cac khoang cach nay va tim ra khoang cach lon nhat, point tuong ung se tro thanh point tiep theo
                foreach (var Point in MinDistanceList)                         // key o day chinh la khoang cach giua 1 point va central point gan nhat cua no
                {
                    if (Point.Key > MaxPoint.Key)
                    {
                        MaxPoint = Point;
                    }
                }

                var TemporaryPoint = new MyGrouping <int, Grade>();      // Copy point cac thanh phan trong 1 reference type variable sang 1 variable khac
                CentralPoint.Add(TemporaryPoint);
                for (int j = 0; j < this.SubjectAmount; j++)
                {
                    CentralPoint[Count].Add(new Grade {
                    });
                }
                int gradeCount = 0;
                foreach (var c in CentralPoint[Count])
                {
                    CentralPoint[Count].ElementAt(gradeCount).Mark = MaxPoint.ElementAt(gradeCount).Mark;
                    gradeCount++;
                }

                Count++; // Them thanh cong 1 central point
            }
            return;
        }
Beispiel #14
0
            public void Process()
            {
                SySal.GPU.MapTracker mptk = Tracker;
                while (Terminate == false)
                {
                    Job o = null;
                    lock (Jobs)
                        if (Jobs.Count > 0)
                        {
                            o = Jobs.First();
                            Jobs.Remove(o);
                            Current = o;
                        }
                    if (o == null)
                    {
                        JobsWaiting.WaitOne(1000);
                        continue;
                    }
                    else if (o is RWDJob)
                    {
                        RWDJob rwdjo = o as RWDJob;
                        System.IO.FileStream outf = null;
                        try
                        {
                            if (C.LogLevel > 0)
                            {
                                Out.WriteLine("Starting processing for " + rwdjo.ZoneFile + " " + rwdjo.StripId);
                            }
                            Zone   z                 = Zone.FromFile(rwdjo.ZoneFile);
                            string imgcorrcfg        = null;
                            string clstchcfg         = null;
                            string trkcfg            = null;
                            string debugdumptemplate = null;
                            foreach (PostProcessingInfo ppi in z.PostProcessingSettings)
                            {
                                switch (ppi.Name.ToLower().Trim())
                                {
                                case "imagecorrection":
                                    imgcorrcfg = ppi.Settings;
                                    if (C.LogLevel >= 3)
                                    {
                                        Out.WriteLine("ImageCorrection: " + imgcorrcfg);
                                    }
                                    break;

                                case "clusterchainer":
                                    clstchcfg = ppi.Settings;
                                    if (C.LogLevel >= 3)
                                    {
                                        Out.WriteLine("ClusterChainer: " + clstchcfg);
                                    }
                                    break;

                                case "tracker":
                                    trkcfg = ppi.Settings;
                                    if (C.LogLevel >= 3)
                                    {
                                        Out.WriteLine("Tracker: " + trkcfg);
                                    }
                                    break;

                                case "debugdumptemplate":
                                    debugdumptemplate = ppi.Settings;
                                    if (C.LogLevel >= 3)
                                    {
                                        Out.WriteLine("DebugDumpTemplate: " + debugdumptemplate);
                                    }
                                    break;
                                }
                            }
                            if (C.LogLevel >= 3)
                            {
                                Out.WriteLine("Setting configuration for " + rwdjo.ZoneFile + " " + rwdjo.StripId);
                            }
                            if (string.IsNullOrWhiteSpace(C.DebugDumpDir) || string.IsNullOrWhiteSpace(debugdumptemplate))
                            {
                                mptk.SetDebugDumpTemplate(null);
                            }
                            else
                            {
                                string debd = C.DebugDumpDir + System.IO.Path.DirectorySeparatorChar + debugdumptemplate;
                                mptk.SetDebugDumpTemplate(debd);
                                if (C.LogLevel >= 3)
                                {
                                    Out.WriteLine("Debug Dump Template is " + debd);
                                }
                            }
                            mptk.SetVerbosity(C.LogLevel);
                            mptk.SetImageCorrection(imgcorrcfg);
                            mptk.SetClusterChainerConfig(clstchcfg);
                            mptk.SetTrackerConfig(trkcfg);
                            float basethickness = -1.0f;
                            try
                            {
                                var xmld = new XmlDocument();
                                xmld.LoadXml(z.ScanSettings);
                                basethickness = float.Parse(xmld.ChildNodes[1]["BaseThickness"].InnerText, System.Globalization.CultureInfo.InvariantCulture);
                            }
                            catch (Exception x)
                            {
                                if (C.LogLevel >= 1)
                                {
                                    Out.WriteLine("Can't find base thickness in zone info:" + Environment.NewLine + z.ScanSettings + Environment.NewLine + ", defaulting to " + basethickness.ToString(System.Globalization.CultureInfo.InvariantCulture) + " (" + x.Message + ")");
                                }
                            }
                            if (basethickness < 0)
                            {
                                throw new Exception("Base thickness is not positive, can't continue.");
                            }
                            if (C.LogLevel >= 1)
                            {
                                Out.WriteLine("Using base thickness = " + basethickness);
                            }
                            if (rwdjo.FirstView < 0 && rwdjo.LastView < 0)
                            {
                                rwdjo.FirstView = 0;
                                rwdjo.LastView  = (int)z.Views - 1;
                            }
                            if (rwdjo.FragmentIndex < 0)
                            {
                                rwdjo.FragmentIndex = (int)rwdjo.StripId + 1;
                            }
                            RawDataFragment rwdf = new RawDataFragment(z, rwdjo.StripId, (uint)rwdjo.FragmentIndex, (uint)rwdjo.FirstView, (uint)rwdjo.LastView);
                            mptk.SetRawDataViewSideConsumer(rwdf);
                            string[] files = new string[z.Views];
                            if (z.HasTop)
                            {
                                if (C.LogLevel >= 1)
                                {
                                    Out.WriteLine("Finding tracks on top for " + rwdjo.ZoneFile + " " + rwdjo.StripId);
                                }
                                int i;
                                for (i = 0; i < z.Views; i++)
                                {
                                    files[i] = z.GetClusterFileName(rwdjo.StripId, true, (uint)i);
                                }
                                mptk.SetDebugMark(rwdjo.StripId * 16);
                                mptk.FindTracks(files, true, 0.0f, z.PlateMap, (uint)rwdjo.FirstView, (uint)rwdjo.LastView);
                            }
                            if (z.HasBottom)
                            {
                                if (C.LogLevel >= 1)
                                {
                                    Out.WriteLine("Finding tracks on bottom for " + rwdjo.ZoneFile + " " + rwdjo.StripId);
                                }
                                int i;
                                for (i = 0; i < z.Views; i++)
                                {
                                    files[i] = z.GetClusterFileName(rwdjo.StripId, false, (uint)i);
                                }
                                mptk.SetDebugMark(rwdjo.StripId * 16 + 1);
                                mptk.FindTracks(files, false, -basethickness, z.PlateMap, (uint)rwdjo.FirstView, (uint)rwdjo.LastView);
                            }
                            if (C.LogLevel >= 1)
                            {
                                Out.WriteLine("Writing tracks for " + rwdjo.ZoneFile + " " + rwdjo.StripId);
                            }
                            string outname  = z.GetRWDFileName((uint)rwdjo.FragmentIndex, rwdjo.OutputDir);
                            string workname = outname + ".twr";
                            outf = new System.IO.FileStream(workname, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite);
                            rwdf.Save(outf);
                            outf.Flush();
                            outf.Close();
                            outf = null;
                            if (C.LogLevel >= 1)
                            {
                                Out.WriteLine("Done " + rwdjo.ZoneFile + " " + rwdjo.StripId);
                            }

                            /* The RWD must be finalized by the PostProcessManager,
                             * otherwise clashes may occur if the communication is lost while the job is completed. */
                            //System.IO.File.Move(workname, outname);
                        }
                        catch (Exception x)
                        {
                            o.ExitException = x.ToString();
                            Out.WriteLine("\r\nError for " + rwdjo.ZoneFile + " " + rwdjo.StripId + ":\r\n" + x.ToString());

                            /*if (x.Message.IndexOf("GPU-level") >= 0)
                             *  Environment.Exit(-1);*/
                            if (x is System.Runtime.InteropServices.SEHException)
                            {
                                Out.WriteLine("SEHException:\r\n" + (x as System.Runtime.InteropServices.SEHException).ErrorCode);
                            }
                        }
                        finally
                        {
                            if (outf != null)
                            {
                                outf.Close();
                            }
                            mptk.SetRawDataViewSideConsumer(null);
                        }
                    }
                    else
                    {
                        o.ExitException = "Unsupported job type.";
                    }
                    System.DateTime n = System.DateTime.Now;
                    o.ExpirationTime = n.AddHours(1);
                    lock (Completed)
                    {
                        Completed.Add(o);
                        Current = null;
                        System.Collections.Generic.List <Job> ncompl = new List <Job>();
                        ncompl.AddRange(Completed.Where(x => x.ExpirationTime >= n));
                        Completed = ncompl;
                    }
                }
            }