Example #1
0
        public MyRegion GetItem(string code)
        {
            //string sql = "select * from JCHVRF_Region where Code = '" + code + "'";

            string sql = "select t1.*,t2.RegistPassword,t2.PricePassword,t2.YorkPassword,t2.HitachiPassword from JCHVRF_Region t1 "
                         + "left join JCHVRF_Region_Password t2 on t1.code = t2.code "
                         + "where t1.Code = '" + code + "'";
            DataTable dt = _dao.GetRegionData(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];

                MyRegion reg = new MyRegion();
                reg.Code             = code;
                reg.Region           = (dr["Region"] is DBNull) ? "" : dr["Region"].ToString().Trim();
                reg.ParentRegionCode = (dr["ParentRegionCode"] is DBNull) ? "" : dr["ParentRegionCode"].ToString().Trim();
                reg.RegistPassword   = (dr["RegistPassword"] is DBNull) ? "" : dr["RegistPassword"].ToString().Trim();
                reg.PricePassword    = (dr["PricePassword"] is DBNull) ? "" : dr["PricePassword"].ToString().Trim();
                return(reg);
            }
            return(null);
        }
        public void calcClosedRegion(MyDB2 mydb, List <System.Drawing.Color> cl)
        {
            Editor         ed        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            ObjectId       layerId   = LayerUtil.CreateLayer(ccLayerNamePrefix + "_" + mydb.Resolution, 127, false);
            List <TBPoint> ps        = new List <TBPoint>();
            List <Loop>    boundarys = new List <Loop>();

            ed.WriteMessage("contours.count:" + contours.Count);
            for (int i = 0; i < contours.Count; i++)
            {
                CContour2 contour        = contours[i];
                Loop      closedBoundary = TraceBoundary.TraceBoundary.getClosedBoundary(contour.tbPLine, contour);
                if (closedBoundary != null)
                {
                    boundarys.Add(closedBoundary);
                    continue;
                }
                List <TBPLineSegment> segs = contour.tbPLine.SegmentedPlines;
                if (segs.Count <= 0)
                {
                    continue;
                }
                List <Point3d> boundaryPoints = new List <Point3d>();
                for (int j = 0; j < 2; j++)//两个方向都求边界,确保loop的elevation属于最小的contour的。
                {
                    Loop minBoundary =
                        TraceBoundary.TraceBoundary.getMinBoundary(segs[0], contour);
                    if (minBoundary == null)
                    {
                        //ed.WriteMessage("");
                        continue;
                    }
                    //minBoundary.userData = contour;
                    boundarys.Add(minBoundary);
                    List <LoopSeg> loopsegs = minBoundary.segments;
                    if (loopsegs == null)
                    {
                        continue;
                    }
                }
            }

            /*for (int j = 0; j < originalBoundarys.Count; j++)
             * {
             *  Loop minBoundary =
             *  TraceBoundary.TraceBoundary.getMinBoundary(originalBoundarys[j].segmentedPlines[0]);
             *  boundarys.Add(minBoundary);
             * }*/
            for (int k = 0; k < boundarys.Count - 1; k++)
            {
                try
                {
                    Loop boundary = boundarys[k];
                    TraceBoundary.TraceBoundary.calcAllInnerLoop(boundary, boundarys);
                    //TraceBoundary.TraceBoundary.calcAllInnerLoop(boundary, boundarys.GetRange(k+1,boundarys.Count-k-1));
                    //TraceBoundary.TraceBoundary.calcNeighbourInnerLoop(boundary);
                    //CContour2 contour = boundary.userData as CContour2;
                    //Color color = ColorizeBase.getColorIndex(mydb, contour.elevation);
                    //Region region = MyRegion.NewRegion(MyConvert.toDBObjects(boundary), color);
                }
                catch (System.Exception ex)
                {
                    ed.WriteMessage("\n192 k:" + k + "--" + ex.Message);
                }
            }

            for (int kk = 0; kk < boundarys.Count; kk++)
            {
                DBObjectCollection outerLoopObjs = null;
                try
                {
                    Loop boundary = boundarys[kk];
                    //TraceBoundary.TraceBoundary.calcAllInnerLoop(boundary, boundarys);
                    TraceBoundary.TraceBoundary.calcNeighbourInnerLoop(boundary);
                    CContour2 contour = boundary.userData as CContour2;
                    Color     color   = ColorizeBase.getColorIndex(mydb, contour.elevation);
                    //Region region = MyRegion.NewRegion(MyConvert.toDBObjects(boundary), color);
                    outerLoopObjs = boundary.getOuterLoopObjs();
                    Region region = MyRegion.NewRegion(outerLoopObjs, boundary.getInnerLoopObjsList(), color, layerId);
                    outerLoopObjs = null;
                }
                catch (System.Exception ex2)
                {
                    ed.WriteMessage("\n210 kk:" + kk + "--" + ex2.Message);
                    if (outerLoopObjs != null)
                    {
                        ed.WriteMessage("\nobjs:\n");
                        for (int ee = 0; ee < outerLoopObjs.Count; ee++)
                        {
                            Polyline3d pl = outerLoopObjs[ee] as Polyline3d;
                            if (pl != null)
                            {
                                ed.WriteMessage(pl.StartPoint.X + "," + pl.StartPoint.Y);
                                ed.WriteMessage("\n");
                                ed.WriteMessage(pl.EndPoint.X + "," + pl.EndPoint.Y);
                                ed.WriteMessage("\n");
                            }
                        }
                    }
                    ed.WriteMessage("\n210 kk:" + kk + "--" + ex2.Message);
                }
            }
            //Region region = MyRegion.NewRegion(MyConvert.toDBObjects(segs));
            //region.Color = ColorizeBase.getColorIndex(mydb, contour.elevation);
        }
        public static void Colorize(MyDB2 mydb, List <System.Drawing.Color> cl)
        {
            TEDictionary     ted = mydb.TEDicList[mydb.Resolution];
            AssistContourDic assistContourDic = mydb.assistContourDics[mydb.Resolution];
            Editor           editor           = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database         workingDatabase  = HostApplicationServices.WorkingDatabase;
            ProgressMeter    progressMeter    = new ProgressMeter();
            MessageFilter    messageFilter    = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(messageFilter);
            try
            {
                double num              = 1.7976931348623157E+308;
                double num2             = -1.7976931348623157E+308;
                string formatFromLUPREC = DBManager.GetFormatFromLUPREC();
                string a;
                double range = ted.maxMaxZ - ted.minCZ;

                double sec = range / cl.Count;

                progressMeter.SetLimit(assistContourDic.elevations.Count);
                progressMeter.Start("Colorizing property");
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    BlockTable       blockTable = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                    BlockTableRecord arg_3D7_0  = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                    int i = 0;
                    while (i < assistContourDic.elevations.Count)
                    {
                        try
                        {
                            progressMeter.MeterProgress();
                            messageFilter.CheckMessageFilter((long)i, 1000);
                        }
                        catch (System.Exception ex)
                        {
                            progressMeter.Stop();
                            throw;
                        }
                        int               colorIndex;
                        double            elevation = assistContourDic.elevations[i];
                        List <BASE.PLine> pls       = assistContourDic.plines[i];

                        colorIndex = (int)Math.Floor((elevation - ted.minCZ) / sec);

                        if (colorIndex >= cl.Count)
                        {
                            colorIndex = cl.Count - 1;
                        }
                        //Face face = (Face)transaction.GetObject(triList[i].AcDbFace.ObjectId, (OpenMode)1);
                        for (int j = 0; j < pls.Count; j++)
                        {
                            PointSet ps = pls[j].GetVertices();
                            if (ps.Count <= 2)
                            {
                                continue;
                            }
                            Region h = MyRegion.NewRegion(ps[1]);
                            if (h != null)
                            {
                                h.Color = Autodesk.AutoCAD.Colors.Color.FromColor(cl[colorIndex]);
                            }
                        }

                        i++;
                        continue;
                    }
                    transaction.Commit();
                }

                progressMeter.Stop();
                return;


                throw new System.Exception("Invalid target property");
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                editor.WriteMessage("\n" + ex.Message);
            }
        }
        private void ChangeCityCustomer(string role)
        {
            ComboBox        cbo;
            List <Customer> citiCustomer = new List <Customer>();

            if (role == "2")
            {
                cbo = cboSenderCustomer;
                MyRegion mr = cboSenderCId.SelectedItem as MyRegion;
                if (cboSenderPId.SelectedItem.ToString() == Common._DefaultProvince && mr != null && FrmParent.ParentForm._DefaultProvince.RangionSenderCustomer.ContainsKey(mr))
                {
                    citiCustomer = FrmParent.ParentForm._DefaultProvince.RangionSenderCustomer[mr];
                }
                else
                {
                    citiCustomer = (from l in _AllCustomer where l.Role == 2 & l.CityId == Convert.ToInt32(cboSenderCId.SelectedValue) select l).ToList();
                }
            }
            else if (role == "22")
            {
                citiCustomer = (from l in _AllCustomer where l.Role == 2 & l.CountyId == Convert.ToInt32(cboSenderAId.SelectedValue) select l).ToList();
                cbo          = cboSenderCustomer;
            }
            else if (role == "3")
            {
                cbo = cboReceiverCustomer;
                MyRegion mr = cboReceiverCId.SelectedItem as MyRegion;
                if (cboSenderPId.SelectedItem.ToString() == Common._DefaultProvince && mr != null && FrmParent.ParentForm._DefaultProvince.RangionReceiveCustomer.ContainsKey(mr))
                {
                    citiCustomer = FrmParent.ParentForm._DefaultProvince.RangionReceiveCustomer[mr];
                }
                else
                {
                    citiCustomer = (from l in _AllCustomer where l.Role == 3 & l.CityId == Convert.ToInt32(cboReceiverCId.SelectedValue) select l).ToList();
                }
            }
            else if (role == "33")
            {
                citiCustomer = (from l in _AllCustomer where l.Role == 3 & l.CountyId == Convert.ToInt32(cboReceiverAId.SelectedValue) select l).ToList();
                cbo          = cboReceiverCustomer;
            }
            else
            {
                return;
            }
            cbo.DisplayMember = "FullName";
            cbo.ValueMember   = "Id";
            if (cbo == cboSenderCustomer)
            {
                if ((citiCustomer == null || citiCustomer.Count == 0))
                {
                    cbo.Enabled = false;
                }
                else
                {
                    cbo.Enabled = true;
                }
            }
            else
            {
                cbo.Enabled = true;
                if (citiCustomer.Count == 0 || (citiCustomer.Count > 0 && citiCustomer.First().FullName != "手动输入"))
                {
                    citiCustomer.Insert(0, new Customer()
                    {
                        Id = null, FullName = "手动输入"
                    });
                }
            }
            cbo.DataSource = citiCustomer;
        }
Example #5
0
        public void DoRegistration(MyRegion myRegion, UserVRF user)
        {
            if (myRegion != null && !string.IsNullOrEmpty(myRegion.RegistPassword))
            {
                RegistrationModel registrationModel = new RegistrationModel();
                DateTime          dt = System.DateTime.Now;
                registrationModel.Dealer     = false;
                registrationModel.LeftDay    = 360;
                registrationModel.PriceValid = false;
                registrationModel.RegDate    = dt;
                registrationModel.SuperUser  = false;
                registrationModel.Validflag  = 0;
                //List<MyRegion> list = (new RegionBLL()).GetParentRegionList();
                if (list == null)
                {
                    return;
                }

                foreach (MyRegion item in list)
                {
                    registrationModel.Region = item.Code;
                    if (myRegion.RegistPassword == item.RegistPassword)
                    {
                        registrationModel.Validflag = 1;
                        if (user.UserRole.Equals("SuperUser", StringComparison.OrdinalIgnoreCase))
                        {
                            registrationModel.SuperUser  = true;
                            registrationModel.PriceValid = true;
                            registrationModel.BrandCode  = "ALL";
                        }
                        //if (registrationModel.Region == "Super")
                        //{
                        //    registrationModel.SuperUser = true;
                        //    registrationModel.PriceValid = true;
                        //    registrationModel.BrandCode = "ALL";

                        //}
                        registrationModel.Username = user.Username;
                        registrationModel.Password = user.Password;
                        registrationModel.Token    = user.Token;
                        registrationModel.SyncDate = user.SyncDate;
                        UpdateValidDate(registrationModel);
                        return;
                    }
                    else if (!string.IsNullOrWhiteSpace(myRegion.YorkPassword) && (myRegion.YorkPassword == item.YorkPassword))
                    {
                        registrationModel.Validflag = 1;
                        registrationModel.BrandCode = "Y";
                        registrationModel.Username  = user.Username;
                        registrationModel.Password  = user.Password;
                        registrationModel.Token     = user.Token;
                        registrationModel.SyncDate  = user.SyncDate;
                        UpdateValidDate(registrationModel);
                        return;
                    }
                    else if (!string.IsNullOrWhiteSpace(myRegion.HitachiPassword) && myRegion.HitachiPassword == item.HitachiPassword)
                    {
                        registrationModel.Validflag = 1;
                        registrationModel.BrandCode = "H";
                        registrationModel.Username  = user.Username;
                        registrationModel.Password  = user.Password;
                        registrationModel.Token     = user.Token;
                        registrationModel.SyncDate  = user.SyncDate;
                        UpdateValidDate(registrationModel);
                        return;
                    }
                }
            }
        }