示例#1
0
        public static void ShowAdsButEligibleForRenewFromClAccountManagement(long clPostingId)
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };

            if (context.vincontrolcraigslisttrackings.Any(x => x.CLPostingId == clPostingId))
            {
                var searchResult =
                    context.vincontrolcraigslisttrackings.First(x => x.CLPostingId == clPostingId);


                searchResult.AddedDate = DateTime.Now;

                searchResult.ExpirationDate = DateTime.Now.AddDays(2).AddHours(6);

                searchResult.ShowAd = true;

                searchResult.Renew = true;

                searchResult.CheckDate = DateTime.Now;

                context.SaveChanges();
            }
        }
示例#2
0
        public static void PinkAdInClAccountManagement(List <long> clPostingIdList)
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };

            foreach (var clPostingId in clPostingIdList)
            {
                if (context.vincontrolcraigslisttrackings.Any(x => x.CLPostingId == clPostingId))
                {
                    var searchResult =
                        context.vincontrolcraigslisttrackings.First(x => x.CLPostingId == clPostingId);


                    searchResult.ShowAd = false;

                    searchResult.Renew = false;

                    searchResult.CLPostingId = 0;

                    searchResult.CheckDate = DateTime.Now;
                }
            }
            context.SaveChanges();
        }
示例#3
0
        private void dGridPCSchedule_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dGridPCSchedule.Columns["ClearButton"].Index && e.RowIndex >= 0)
            {
                var computerId = Convert.ToInt32(dGridPCSchedule.Rows[e.RowIndex].Cells[0].Value.ToString());

                var context = new whitmanenterprisecraigslistEntities();



                if (context.vinclapppcschedules.Any(x => x.PC == computerId))
                {
                    var searchResult = context.vinclapppcschedules.First(x => x.PC == computerId);

                    context.Attach(searchResult);

                    context.DeleteObject(searchResult);

                    context.SaveChanges();
                }



                dGridPCSchedule.Rows[e.RowIndex].Cells[1].Value = "";
            }
        }
示例#4
0
        public static List <WhitmanEntepriseMasterVehicleInfo> PopulateEmailHavingRenewAds()
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };

            var bufferMasterVehicleList
                = new List <WhitmanEntepriseMasterVehicleInfo>();

            //var dtCompare = DateTime.Now.AddHours(-55);

            var checkList = from a in context.vincontrolcraigslisttrackings
                            from b in context.vinclappemailaccounts
                            where
                            a.EmailAccount == b.AccountName && a.CLPostingId > 0
                            select new
            {
                a.TrackingId,
                a.ListingId,
                a.CityId,
                a.CLPostingId,
                a.ShowAd,
                a.EmailAccount,
                a.DealerId,
                b.AccountPassword,
                b.Phone,
                a.AddedDate,
                a.ExpirationDate,
                a.HtmlCraigslistUrl
            };

            var hashSet = new HashSet <string>();

            foreach (var ads in checkList.OrderBy(x => x.EmailAccount))
            {
                if (!hashSet.Contains(ads.EmailAccount))
                {
                    var addCar = new WhitmanEntepriseMasterVehicleInfo()
                    {
                        AutoID = bufferMasterVehicleList.Count + 1,
                        CraigslistAccountName     = ads.EmailAccount,
                        CraigslistAccountPassword = ads.AccountPassword,
                    };
                    bufferMasterVehicleList.Add(addCar);
                }

                hashSet.Add(ads.EmailAccount);
            }



            return(bufferMasterVehicleList);
        }
示例#5
0
        public static List <WhitmanEntepriseMasterVehicleInfo> PopulateAvailableRenewAds()
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };

            var bufferMasterVehicleList
                = new List <WhitmanEntepriseMasterVehicleInfo>();

            var dtCompare = DateTime.Now.AddHours(-72);

            var cityList = context.whitmanenterprisecraigslistcities.ToList();

            var checkList = from a in context.vincontrolcraigslisttrackings
                            from b in context.vinclappemailaccounts
                            where
                            a.EmailAccount == b.AccountName && a.AddedDate <= dtCompare && a.CLPostingId > 0
                            select new
            {
                a.TrackingId,
                a.ListingId,
                a.CityId,
                a.CLPostingId,
                a.ShowAd,
                a.EmailAccount,
                a.DealerId,
                b.AccountPassword,
                b.Phone,
                a.AddedDate,
                a.ExpirationDate,
                a.HtmlCraigslistUrl
            };

            foreach (var ads in checkList.OrderBy(x => x.EmailAccount))
            {
                var addCar = new WhitmanEntepriseMasterVehicleInfo()
                {
                    AutoID                    = bufferMasterVehicleList.Count + 1,
                    CraigslistUrl             = ads.HtmlCraigslistUrl,
                    CraigslistAccountName     = ads.EmailAccount,
                    CraigslistAccountPassword = ads.AccountPassword,
                    CraigslistAccountPhone    = ads.Phone,
                    CLPostingId               = ads.CLPostingId.GetValueOrDefault(),
                    AdTrackingId              = ads.TrackingId,
                    CraigslistCityUrl         = cityList.First(x => x.CityID == ads.CityId).CraigsListCityURL
                };
                bufferMasterVehicleList.Add(addCar);
            }



            return(bufferMasterVehicleList);
        }
示例#6
0
        public PCSchedule(ScheudeForm frmMain)
        {
            InitializeComponent();

            dGridPCSchedule.Rows.Clear();

            var context = new whitmanenterprisecraigslistEntities();

            var pcScheduleList = context.vinclapppcschedules.ToList();

            var totalSchedule = context.vinclappdealerschedules.First().Schedules.GetValueOrDefault();


            for (var i = 1; i <= Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MaximumComputer"].ToString(CultureInfo.InvariantCulture)); i++)
            {
                var newRow = new DataGridViewRow();

                newRow.CreateCells(dGridPCSchedule);

                newRow.Cells[0].Value = i;

                if (pcScheduleList.Any(x => x.PC == i))
                {
                    newRow.Cells[1].Value = pcScheduleList.First(x => x.PC == i).Schedule;
                }

                dGridPCSchedule.Rows.Add(newRow);
            }

            var tmpCom = new List <ComplicatedValueComboBox>();

            for (var y = 1; y <= totalSchedule; y++)
            {
                var newComp = new ComplicatedValueComboBox()
                {
                    Text  = y,
                    Value = y
                };

                tmpCom.Add(newComp);
            }

            var comboCol = new DataGridViewComboBoxColumn
            {
                Name          = "cmbSchedule",
                HeaderText    = "Select Schedule",
                DataSource    = tmpCom,
                DisplayMember = "Text",
                ValueMember   = "Value",
            };

            dGridPCSchedule.Columns.Add(comboCol);
        }
示例#7
0
        public static List <WhitmanEntepriseMasterVehicleInfo> PopulateAvailableClickThroughAds()
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };

            var bufferMasterVehicleList
                = new List <WhitmanEntepriseMasterVehicleInfo>();

            var cityList = context.whitmanenterprisecraigslistcities.ToList();

            var checkList = from a in context.vincontrolcraigslisttrackings
                            where
                            a.DealerId == 3738 || a.DealerId == 113738 || a.DealerId == 115896 || a.DealerId == 44670 || a.DealerId == 144670 ||
                            a.DealerId == 15896 || a.DealerId == 11828 || a.DealerId == 111828 || a.DealerId == 7180 || a.DealerId == 112650 ||
                            a.DealerId == 2650 || a.DealerId == 15986 || a.DealerId == 115986
                            select new
            {
                a.TrackingId,
                a.ListingId,
                a.CityId,
                a.CLPostingId,
                a.ShowAd,
                a.EmailAccount,
                a.DealerId,
                a.AddedDate,
                a.ExpirationDate,
                a.HtmlCraigslistUrl
            };

            foreach (var ads in checkList.OrderBy(x => x.EmailAccount))
            {
                var addCar = new WhitmanEntepriseMasterVehicleInfo()
                {
                    AutoID                = bufferMasterVehicleList.Count + 1,
                    CraigslistUrl         = ads.HtmlCraigslistUrl,
                    CraigslistAccountName = ads.EmailAccount,
                    CLPostingId           = ads.CLPostingId.GetValueOrDefault(),
                    AdTrackingId          = ads.TrackingId,
                    CraigslistCityUrl     = cityList.First(x => x.CityID == ads.CityId).CraigsListCityURL
                };
                bufferMasterVehicleList.Add(addCar);
            }

            return(bufferMasterVehicleList.Where(x => !String.IsNullOrEmpty(x.CraigslistUrl)).ToList());
        }
示例#8
0
        public static List <WhitmanEntepriseMasterVehicleInfo> PopulateTodayNewPostAdsForReport()
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };

            var bufferMasterVehicleList
                = new List <WhitmanEntepriseMasterVehicleInfo>();

            var dtCompare = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddHours(8);

            var cityList = context.whitmanenterprisecraigslistcities.ToList();

            var checkList =
                context.vincontrolcraigslisttrackings.Where(
                    a =>
                    a.CLPostingId > 0 && a.AddedDate >= dtCompare && a.Renew == false).Select(a => new
            {
                a.TrackingId,
                a.CityId,
                a.CLPostingId,
                a.Computer,
                a.ShowAd,
                a.CheckDate,
                a.AddedDate,
                a.HtmlCraigslistUrl
            });

            foreach (var ads in checkList)
            {
                var addCar = new WhitmanEntepriseMasterVehicleInfo()
                {
                    AutoID            = bufferMasterVehicleList.Count + 1,
                    CLPostingId       = ads.CLPostingId.GetValueOrDefault(),
                    AdTrackingId      = ads.TrackingId,
                    CraigslistCityUrl = cityList.First(x => x.CityID == ads.CityId).CraigsListCityURL,
                    CraigslistUrl     = ads.HtmlCraigslistUrl
                };
                bufferMasterVehicleList.Add(addCar);
            }



            return(bufferMasterVehicleList);
        }
示例#9
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure to delete pc-schedule association?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (result.Equals(DialogResult.OK))
            {
                var context = new whitmanenterprisecraigslistEntities();

                foreach (var tmp in context.vinclapppcschedules.ToList())
                {
                    context.Attach(tmp);
                    context.DeleteObject(tmp);
                }

                InitializeSettingAfterSave();
            }
        }
示例#10
0
        public static void DeleteTracking(int trackingAdId)
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };

            var searchResult =
                context.vincontrolcraigslisttrackings.First(x => x.TrackingId == trackingAdId);

            if (searchResult != null)
            {
                context.Attach(searchResult);

                context.DeleteObject(searchResult);

                context.SaveChanges();
            }
        }
示例#11
0
        public static void NonShowAds(int trackingAdId)
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };

            var searchResult =
                context.vincontrolcraigslisttrackings.First(x => x.TrackingId == trackingAdId);

            if (searchResult != null)
            {
                searchResult.ShowAd = false;

                searchResult.CheckDate = DateTime.Now;

                context.SaveChanges();
            }
        }
示例#12
0
        public static List <CraigsListEmailAccount> PopulateIps()
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };


            var result = new List <CraigsListEmailAccount>();

            int position = 1;

            var emailListPerPcId = context.vinclappemailaccounts.Where(x => x.Active == true && !String.IsNullOrEmpty(x.ProxyIP) && x.DefaultGateway.Equals("12.31.180.129"));

            foreach (var tmp in emailListPerPcId)
            {
                if (!String.IsNullOrEmpty(tmp.AccountName) && !String.IsNullOrEmpty(tmp.AccountPassword))
                {
                    var clAccount = new CraigsListEmailAccount()
                    {
                        CraigslistAccount        = tmp.AccountName,
                        CraigsListPassword       = tmp.AccountPassword,
                        CraigsAccountPhoneNumber = tmp.Phone,
                        Proxy           = tmp.ProxyIP,
                        isCurrentlyUsed = false,
                        Position        = position++,
                        DefaultGateWay  = tmp.DefaultGateway,
                        Dns             = tmp.Dns
                    };

                    result.Add(clAccount);
                }
            }

            if (result.Any())
            {
                result.First().isCurrentlyUsed = true;
            }

            return(result);
        }
示例#13
0
        public static void ShowAdsButEligibleForRenew(int trackingAdId)
        {
            var context = new whitmanenterprisecraigslistEntities()
            {
                CommandTimeout = 18000
            };

            var searchResult =
                context.vincontrolcraigslisttrackings.First(x => x.TrackingId == trackingAdId);

            if (searchResult != null)
            {
                searchResult.AddedDate = DateTime.Now;

                searchResult.ExpirationDate = DateTime.Now.AddDays(2).AddHours(6);

                searchResult.ShowAd = true;

                searchResult.CheckDate = DateTime.Now;

                context.SaveChanges();
            }
        }
示例#14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var context = new whitmanenterprisecraigslistEntities();


            foreach (var tmp in context.vinclapppcschedules.ToList())
            {
                context.Attach(tmp);
                context.DeleteObject(tmp);
            }

            foreach (DataGridViewRow tmp in dGridPCSchedule.Rows)
            {
                var scheduleValue = tmp.Cells[3].Value;

                if (scheduleValue != null)
                {
                    var pcSchedule = new vinclapppcschedule()
                    {
                        PC          = Convert.ToInt32(tmp.Cells[0].Value),
                        Schedule    = Convert.ToInt32(scheduleValue),
                        LastUpdated = DateTime.Now
                    };

                    context.AddTovinclapppcschedules(pcSchedule);
                }
            }

            context.SaveChanges();

            InitializeSettingAfterSave();

            this.Refresh();

            MessageBox.Show("PC - Schedule was associated successfully. ");
        }
示例#15
0
        public static void InitializeSettings()
        {
            Globalvar.DealerList = new List <Dealer>();

            Globalvar.CityList = new List <City>();

            Globalvar.ComputerList = new List <Computer>();

            var context = new whitmanenterprisecraigslistEntities();

            var allInventory = context.whitmanenterprisecraigslistinventories.ToList();

            var allDealer = context.whitmanenterprisedealerlists.Where(x => x.Active == true).ToList();

            var dealerScheduleList = context.vinclappdealerschedules.ToList();

            if (dealerScheduleList.Any())
            {
                Globalvar.SplitSchedules = dealerScheduleList.First().Schedules.GetValueOrDefault();
            }

            foreach (var tmp in allDealer)
            {
                int numberOfCars = 0;

                if (allInventory.Any(x => x.DealershipId == tmp.VincontrolId))
                {
                    var preNumberOfCars =
                        allInventory.Where(x => x.DealershipId == tmp.VincontrolId && !String.IsNullOrEmpty(x.CarImageUrl));

                    foreach (var pretmp in preNumberOfCars)
                    {
                        int qualifiedImagesCount = 0;

                        string tmpString = pretmp.CarImageUrl.Replace(" ", "%20");

                        if (tmpString.Contains("|") || tmpString.Contains(","))
                        {
                            string[] totalImage = tmpString.Split(new[] { "|", "," },
                                                                  StringSplitOptions.RemoveEmptyEntries);

                            if (totalImage.Any())
                            {
                                qualifiedImagesCount = totalImage.Count();
                            }
                        }
                        if (qualifiedImagesCount >= 1)
                        {
                            numberOfCars++;
                        }
                    }
                }

                var d = new Dealer()
                {
                    DealerId         = Convert.ToInt32(tmp.VincontrolId),
                    DealershipName   = tmp.DealershipName,
                    State            = tmp.State,
                    City             = tmp.City,
                    ZipCode          = tmp.ZipCode,
                    Phone            = tmp.PhoneNumber,
                    NumberOfCars     = numberOfCars,
                    Round            = numberOfCars % 10 == 0? numberOfCars / 10:numberOfCars / 10 + 1,
                    ScheduleCityList = new List <ScheduleCity>(),
                };

                if (dealerScheduleList.Any(x => x.DealerId == d.DealerId))
                {
                    foreach (var scheduleTmp in dealerScheduleList.Where(x => x.DealerId == d.DealerId))
                    {
                        d.ScheduleCityList.Add(new ScheduleCity()
                        {
                            City      = scheduleTmp.CityId.GetValueOrDefault(),
                            Price     = scheduleTmp.Price.GetValueOrDefault(),
                            Split     = scheduleTmp.Split.GetValueOrDefault(),
                            Schedules = scheduleTmp.Schedules.GetValueOrDefault(),
                        });
                    }
                }

                Globalvar.DealerList.Add(d);
            }


            foreach (var citytmp in context.whitmanenterprisecraigslistcities.ToList())
            {
                Globalvar.CityList.Add(new City()
                {
                    CityID            = citytmp.CityID,
                    CityName          = citytmp.CityName,
                    CLIndex           = citytmp.CLIndex.GetValueOrDefault(),
                    CraigsListCityURL = citytmp.CraigsListCityURL,
                    SubCity           = citytmp.SubCity.GetValueOrDefault()
                }
                                       );
            }


            foreach (var computertmp in context.whitmanenterprisecomputeraccounts.ToList())
            {
                Globalvar.ComputerList.Add(new Computer()
                {
                    PcAccount = computertmp.AccountPC,
                    CityId    = computertmp.CityId,
                    DealerId  = computertmp.DealerId
                }
                                           );
            }
        }