コード例 #1
0
        public double CalculateDistance(string PostalCodeStart, double EndLatitude, double EndLongitude)
        {
            distance = -1;

            appDB.PostalCodeLocationRow StartPoint = myPostalCodeLocationDT.FindByPostalCode(PostalCodeStart);
            if (StartPoint == null)
            {
                StartPoint = this.Load(PostalCodeStart);
            }

            if (StartPoint != null)
            {
                distance = CalculateDistance((double)StartPoint.Latitude, (double)StartPoint.Longitude, EndLatitude, EndLongitude);
            }

            return(distance);
        }
コード例 #2
0
        public double CalculateDistance(string PostalCodeStart, string PostalCodeEnd)
        {
            // using the Spherical Law of Cosines formula


            distance = -1; // in kilometres

            appDB.PostalCodeLocationRow StartPoint = this.Load(PostalCodeStart);
            appDB.PostalCodeLocationRow EndPoint   = this.Load(PostalCodeEnd);

            if (StartPoint != null && EndPoint != null)
            {
                distance = CalculateDistance((double)StartPoint.Latitude, (double)StartPoint.Longitude, (double)EndPoint.Latitude, (double)EndPoint.Longitude);
            }

            return(distance);
        }
コード例 #3
0
 protected override void AfterAdd(DataRow row)
 {
     appDB.PostalCodeLocationRow dr = (appDB.PostalCodeLocationRow)row;
     string ObjectName = this.myPostalCodeLocationDT.TableName;
 }
コード例 #4
0
        public void CalcRecipType()
        {
            myA.isMerging = true;
            //clear column first
            myFilePartyDT.AcceptChanges();
            foreach (SST.FilePartyRow fpr in myFilePartyDT)
            {
                if (fpr.RowState != DataRowState.Deleted)
                {
                    fpr.SetRecipTypeNull();
                    fpr.AcceptChanges();
                }
            }

            //determine whether this record should be the recipient
            foreach (SST.FilePartyRow fpr in myFilePartyDT)
            {
                fpr.ClosestSCCId = 0;
                atriumDB.FileContactRow fcr = myA.FM.DB.FileContact.FindByFileContactid(fpr.FileContactId);

                if (fcr != null)
                {
                    if (fcr.ContactRow != null)
                    {
                        if (!fcr.ContactRow.IsAddressCurrentIDNull())
                        {
                            //calc sc
                            atriumDB.AddressRow         ar   = myA.FM.DB.Address.FindByAddressId(fcr.ContactRow.AddressCurrentID);
                            appDB.PostalCodeLocationRow pclr = null;
                            if (ar != null)
                            {
                                if (!ar.IsPostalCodeNull())
                                {
                                    pclr = myA.AtMng.GetPostalCodeLocation().Load(ar.PostalCode.Replace(" ", ""));
                                }

                                if (pclr != null)
                                {
                                    MemberManager mem = myA.AtMng.GetMemberMng();
                                    fpr.ClosestSCCId = mem.GetClosestSCC(pclr.Latitude, pclr.Longitude);
                                    fpr.AcceptChanges();
                                }
                            }
                        }
                    }

                    //calc recip type
                    if (fcr.IsDelegateForNull())
                    {
                        atriumDB.FileContactRow[] fcrRep = (atriumDB.FileContactRow[])myA.FM.DB.FileContact.Select("DelegateFor='" + fcr.ContactType + "'");
                        if (fcrRep.Length == 1)
                        {
                            SST.FilePartyRow[] fprs = (SST.FilePartyRow[])myFilePartyDT.Select("FileContactId=" + fcrRep[0].FileContactid.ToString());
                            if (!fprs[0].IsPending)
                            {
                                fprs[0].RecipType = fpr.ContactType;
                                fprs[0].AcceptChanges();
                            }
                            else
                            {
                                fpr.RecipType = fpr.ContactType;
                                fpr.AcceptChanges();
                            }
                        }
                        else
                        {
                            fpr.RecipType = fpr.ContactType;
                            fpr.AcceptChanges();
                        }
                    }
                }
            }
            myA.isMerging = false;
        }