Exemple #1
0
        //get the asset's spec by the machine's serial number
        public List <Models.magentoViewModel> get_spec(int asset_tag)
        {
            string result = (from b in db.rediscovery where b.ictag == asset_tag select b.serial).SingleOrDefault();


            var spec = (from t in db.production_log where t.serial == result from h in db.rediscovery where t.serial == h.serial select new Models.magentoViewModel {
                hdd = t.HDD, cpu = t.CPU, brand = t.Manufacture, ram = t.RAM, ictags = asset_tag, model = t.Model, serial = h.serial, screen_size = t.screen_size, video_card = t.video_card, optical = h.optical_drive, pallet_name = h.pallet
            }).ToList();

            if (spec.Count() == 0)
            {
                spec = rediscovery(asset_tag);
                return(spec);
            }
            var temp_cpu = spec[0].cpu;
            var temp_hdd = spec[0].hdd;

            if (temp_hdd.Contains("GB"))
            {
                temp_hdd = temp_hdd.Replace("GB", "");
            }

            int formatted_hdd = int.Parse(temp_hdd);

            formatted_hdd = Convert.ToInt32(formatted_hdd * 1.024 * 1.024); formatted_hdd = Levenshtein.Round(formatted_hdd, 10);
            switch (formatted_hdd)
            {
            case 480:
                formatted_hdd = 500;
                temp_hdd      = formatted_hdd + "GB HDD";
                break;

            case 980:
                formatted_hdd = 1000;
                temp_hdd      = formatted_hdd / 1000 + "TB HDD";
                break;

            default:
                temp_hdd = formatted_hdd + "GB HDD";
                break;
            }


            string formatted_cpu = Levenshtein.comput_title(temp_cpu);

            spec[0].cpu = formatted_cpu;
            spec[0].hdd = temp_hdd;
            return(spec);
        }
Exemple #2
0
        public List <Models.magentoViewModel> rediscovery(int asset_tag)
        {
            var result = (from t in db.rediscovery where t.ictag == asset_tag select new Models.magentoViewModel {
                hdd = t.hdd, cpu = t.cpu, brand = t.brand, ram = t.ram, ictags = asset_tag, model = t.model, serial = t.serial, screen_size = "NA", video_card = "NA", optical = t.optical_drive, pallet_name = t.pallet
            }).ToList();

            var temp_cpu = result[0].cpu;
            var temp_hdd = result[0].hdd;

            if (temp_hdd.Contains("GB"))
            {
                temp_hdd = temp_hdd.Replace("GB", "");
            }
            if (temp_hdd.Contains("SSD"))
            {
                temp_hdd = temp_hdd.Replace("SSD", "");
            }
            int formatted_hdd = int.Parse(temp_hdd);

            formatted_hdd = Convert.ToInt32(formatted_hdd * 1.024 * 1.024);
            formatted_hdd = Levenshtein.Round(formatted_hdd, 10);
            switch (formatted_hdd)
            {
            case 480:
                formatted_hdd = 500;
                temp_hdd      = formatted_hdd + "GB HDD";
                break;

            case 980:
                formatted_hdd = 1000;
                temp_hdd      = formatted_hdd / 1000 + "TB HDD";
                break;

            default:
                temp_hdd = formatted_hdd + "GB HDD";
                break;
            }
            string formatted_cpu = Levenshtein.comput_title(temp_cpu);

            result[0].cpu = formatted_cpu;
            result[0].hdd = temp_hdd;

            return(result);
        }
Exemple #3
0
        public static string ram_format(string ram, bool IsMagento)
        {
            if (!string.IsNullOrEmpty(ram))
            {
                bool result = ram.Any(x => !char.IsLetter(x));
                if (result == true)
                {
                    ram = Regex.Replace(ram, "[^0-9]", "");
                }
                int formatted_ram = int.Parse(ram);

                if (IsMagento == false)
                {
                    formatted_ram = Levenshtein.Round(formatted_ram, 100);
                    formatted_ram = Convert.ToInt32(formatted_ram / 1000);
                }
                ram = formatted_ram + "GB RAM";
            }
            return(ram);
        }
Exemple #4
0
        public static string hdd_format(string temp_hdd, bool IsMagento)
        {
            if (!string.IsNullOrEmpty(temp_hdd))
            {
                bool result = temp_hdd.Any(x => !char.IsLetter(x));
                if (result == true)
                {
                    temp_hdd = Regex.Replace(temp_hdd, "[^0-9]", "");
                }

                int formatted_hdd = int.Parse(temp_hdd);
                if (IsMagento == false)
                {
                    formatted_hdd = Convert.ToInt32(formatted_hdd * 1.024 * 1.024);
                }
                formatted_hdd = Levenshtein.Round(formatted_hdd, 10);
                switch (formatted_hdd)
                {
                case 480:
                    formatted_hdd = 500;
                    temp_hdd      = formatted_hdd + "GB HDD";
                    break;

                case 980:
                    formatted_hdd = 1000;
                    temp_hdd      = formatted_hdd / 1000 + "TB HDD";
                    break;

                default:
                    temp_hdd = formatted_hdd + "GB HDD";
                    break;
                }
            }


            return(temp_hdd);
        }