コード例 #1
0
 void bw4_DoWork(object sender, DoWorkEventArgs e)
 {
     e.Result=true;
     for (int i = 0; i < viewinvoices.Count; i++)
     {
         if (viewinvoices[i].latitude == 0 && viewinvoices[i].longitude == 0)
         {
             Mapquest mapquest = new Mapquest(GlobalVar.sqlsettings.mapquestkey);
             string address = "";
             if (viewinvoices[i].addr1 != "")
             {
                 address = address + viewinvoices[i].addr1;
             }
             else
             {
                 address = address + viewinvoices[i].addr2;
             }
             address = address + ", " + viewinvoices[i].city;
             address = address + ", " + viewinvoices[i].state;
             address = address + ",  " + viewinvoices[i].zip;
             GeoData currentgeodata = mapquest.GetLocation(address);
             if (currentgeodata == null)
             {
                 e.Result = false;
             }
             else
             {
                 viewinvoices[i].latitude = (double)currentgeodata.latitude[0];
                 viewinvoices[i].longitude = (double)currentgeodata.longitude[0];
                 mysql_invoices.UpdateInvoice(viewinvoices[i], viewinvoices[i]);
             }
         }
     }
 }
コード例 #2
0
        void bw3_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                rrsdatareader = new RRSDataReader(GlobalVar.sqlsettings.RRSHeaderFile, GlobalVar.sqlsettings.RRSLinesFile);
                rrsdatareader.ReadInvoices(viewdate);

                List<Invoice> filteredinvoices = rrsdatareader.FilterInvoices(viewdate, null);
                rrsdatareader.ReadLineItems();
                List<LineItem> filteredlineitems = rrsdatareader.FilterLineItems(filteredinvoices);
                List<Invoice> newfilteredinvoices = new List<Invoice>(filteredinvoices);
                newfilteredinvoices = mysql_invoices.AddInvoices(newfilteredinvoices, true);
                List<LineItem> templineitems = new List<LineItem>();
                for (int i = 0; i < newfilteredinvoices.Count; i++)
                {
                    for (int j = 0; j < filteredlineitems.Count; j++)
                    {
                        if (filteredlineitems[j].invoicenumber == newfilteredinvoices[i].number)
                        {
                            templineitems.Add(filteredlineitems[j]);
                        }

                    }
                }
                if((bool)e.Argument==true){
                mysql_invoices.UpdateInvoices(filteredinvoices, viewdate, true);
                }

                filteredlineitems = templineitems;
                mysql_lineitems.AddLineItems(filteredlineitems);
                if ((bool)e.Argument == true||listInvoices.Items.Count==0)
                {
                    //do lookup
                    for (int i = 0; i < filteredinvoices.Count; i++)
                    {
                        string address = filteredinvoices[i].addr1;
                        address = address + ", " + filteredinvoices[i].city;
                        address = address + ", " + filteredinvoices[i].state;
                        address = address + ",  " + filteredinvoices[i].zip;
                        Mapquest mapquest = new Mapquest(GlobalVar.sqlsettings.mapquestkey);

                        GeoData geodata = mapquest.GetLocation(address);
                        if (geodata != null)
                        {
                            filteredinvoices[i].latitude = geodata.latitude[0];
                            filteredinvoices[i].longitude = geodata.longitude[0];

                            mysql_invoices.UpdateInvoice(filteredinvoices[i], filteredinvoices[i]);
                        }
                        InvoiceRouteInfo invoicerouteinfo = mysql_invoiceroutes.GetRouteInfo(filteredinvoices[i].number);
                        if (invoicerouteinfo != null)
                        {
                            RouteInfo routeinfo = mysql_routes.GetRouteInfo(invoicerouteinfo);
                            if (routeinfo != null)
                            {
                                if (routeinfo.date.Day == viewdate.Day && routeinfo.date.Month == viewdate.Month && routeinfo.date.Year == viewdate.Year)
                                {

                                }
                                else
                                {
                                    mysql_invoiceroutes.DeleteRouteInfo(invoicerouteinfo, true);
                                }
                            }
                        }
                    }
                }

            }
            catch { }
        }
コード例 #3
0
        void bw2_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Mapquest mapquest = new Mapquest(GlobalVar.sqlsettings.mapquestkey);
                Map.Directions directions = new Map.Directions(GlobalVar.sqlsettings.mapquestkey);

                DirectionArgs args = (DirectionArgs)e.Argument;
                for (int i = 0; i < args.latitude.Count; i++)
                {
                    for (int j = 0; j < args.latitude[i].Count; j++)
                    {
                        if (args.latitude[i][j] == 0 && args.longitude[i][j] == 0)
                        {
                            GeoData geodata = mapquest.GetLocation(args.address[i][j]);
                            if (geodata == null)
                            {
                                args.counter = -1;
                                break;
                            }
                            args.latitude[i][j] = geodata.latitude[0];
                            args.longitude[i][j] = geodata.longitude[0];

                                viewinvoices[i].latitude = (double)geodata.latitude[0];
                                viewinvoices[i].longitude = (double)geodata.longitude[0];
                                mysql_invoices.UpdateInvoice(viewinvoices[i], viewinvoices[i]);

                        }
                    }
                }
                if (args.counter != -1)
                {
                    for (int i = 0; i < args.latitude.Count;i++ )
                    {
                        DirectionData directiondata = directions.GetDirections(args.latitude[i], args.longitude[i], args.optimize);
                        args.directiondata.Add(directiondata);
                    }
                }
                e.Result = args;
            }
            catch { }
        }
コード例 #4
0
        void bw1_DoWork(object sender, DoWorkEventArgs e)
        {
            ThreadArgs temp = (ThreadArgs)e.Argument;

            Mapquest mapquest = new Mapquest(GlobalVar.sqlsettings.mapquestkey);
            GeoData currentgeodata = mapquest.GetLocation(temp.address);
            temp.geodata = currentgeodata;
            e.Result = temp;
        }
コード例 #5
0
        private void DoReorder(bool listflag, int select)
        {
            listRouteItems.Items.Clear();

            stopcounter = 1;
            for (int i = 0; i < scheduledinvoices.Count; i++)
            {
                for (int j = 0; j < scheduledinvoices.Count; j++)
                {
                    if (i == (scheduledinvoicesorder[j]))
                    {
                        int index=-1;
                        for(int k=0;k<scheduledinvoices.Count;k++)
                        {
                            if ((scheduledinvoicesorder[j] - 1) == scheduledinvoicesorder[k])
                            {
                                index=k;
                            }
                        }
                        if (index != -1)
                        {
                            if (scheduledinvoices[j].latitude == 0)
                            {
                                string address = scheduledinvoices[j].addr1;
                                address= address + ", " + scheduledinvoices[j].city;
                                address = address + ", " + scheduledinvoices[j].state;
                                address = address + ",  " + scheduledinvoices[j].zip;
                                Mapquest mapquest = new Mapquest(GlobalVar.sqlsettings.mapquestkey);
                                GeoData geodata = mapquest.GetLocation(address);
                                scheduledinvoices[j].latitude = geodata.latitude[0];
                                scheduledinvoices[j].longitude = geodata.longitude[0];
                            }
                            if (scheduledinvoices[index].latitude == scheduledinvoices[j].latitude && scheduledinvoices[index].latitude == scheduledinvoices[j].latitude)
                            {

                            }
                            else
                            {
                                stopcounter++;
                            }
                        }
                        else { counter++; }

                        string toinsert = "#"+(stopcounter)+" - "+scheduledinvoices[j].number +" - "+ scheduledinvoices[j].city + ", " + scheduledinvoices[j].state +" - " + driver.name.ToString();
                        listRouteItems.Items.Insert(i,toinsert);
                    }
                }
            }
            if (listflag == true)
            {
                listRouteItems.SelectedIndex = select;
            }
        }
コード例 #6
0
        void bw3_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Mapquest mapquest = new Mapquest(GlobalVar.sqlsettings.mapquestkey);
                Map.Directions directions = new Map.Directions(GlobalVar.sqlsettings.mapquestkey);

                DirectionArgs args = (DirectionArgs)e.Argument;
                for (int i = 0; i < args.latitude.Count; i++)
                {
                    if (args.latitude[i] == 0 && args.longitude[i] == 0)
                    {
                        GeoData geodata = mapquest.GetLocation(args.address[i]);
                        if (geodata == null)
                        {
                            args.counter = -1;
                            break;
                        }
                        args.latitude[i] = geodata.latitude[0];
                        args.longitude[i] = geodata.longitude[0];
                    }
                }
                /*for (int i = 1; i<args.latitude.Count-1; i++)
                {
                    for(int j=1;j<args.latitude.Count-1;j++)
                    {
                        if (args.longitude[j] == args.longitude[i] && args.latitude[j] == args.latitude[i]&&i!=j)
                        {
                            args.longitude.RemoveAt(j);
                            args.latitude.RemoveAt(j);
                            args.address.RemoveAt(j);
                            j = 1;
                        }
                    }
                }*/
                    if (args.counter != -1)
                    {
                        DirectionData directiondata = directions.GetDirections(args.latitude, args.longitude, args.optimize);
                        args.directiondata = directiondata;
                    }
                e.Result = args;
            }
            catch { }
        }