示例#1
0
        public static void sendNews(string newsPic, string newsTitle, string newsDigest, string newsUrl)
        {
            List <NewsArticle> news = new List <NewsArticle>()
            {
                new NewsArticle {
                    title = newsTitle, description = newsDigest, picurl = newsPic, url = newsUrl
                }
            };

            CorpNewsMessage ctx = new CorpNewsMessage
            {
                touser  = WechatCommonPara.ToUser,
                toparty = "",
                totag   = "",
                news    = new News {
                    articles = news
                },
                safe = 0
            };
            ICropMessage cm     = new CropMessage();
            CommonResult result = cm.SendMessage(ctx);
        }
        //截图每个解决方案
        static public bool createScreenShot(ProgressMeter pm)
        {
            var doc = Application.DocumentManager.MdiActiveDocument;

            if (doc == null)
            {
                return(false);
            }

            CropMessage message = new CropMessage();
            Rectangle   rect    = new Rectangle();
            bool        Crop    = false;

            if (message.ShowDialog() == false)
            {
                if (message.SelectedValue == true)
                {
                    Crop = true;
                    bool status = ScreenshotUtil.SelectCropArea(out rect);
                    if (status == false)
                    {
                        return(false);
                    }
                }
            }
            int number_display = 10;//进度条的进度;

            if (solutions.Count <= 0)
            {
                return(false);
            }
            int len = (100 - number_display) / solutions.Count;

            foreach (var i_solution in solutions)
            {
                //隐藏云线
                solutionPanel.chrometabs.ChangeSelectedItem(i_solution.TabItem);
                HeatSourceLayoutApp.currentSolution = i_solution;
                using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
                {
                    using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
                    {
                        foreach (var district in i_solution.Districts)
                        {
                            Entity obj = (Entity)(tr.GetObject(district.Value.BaseObjectId, OpenMode.ForRead));
                            if (!obj.IsErased)
                            {
                                obj.UpgradeOpen();
                                obj.Visible = false;
                            }
                        }
                        tr.Commit();
                    }
                }
                //重新生成模型
                Application.DocumentManager.MdiActiveDocument.Editor.Regen();
                //创建截图目录
                var dir = HeatSourceLayoutApp.CurrentDirectory + "\\tmp\\";
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                //截图
                Bitmap pic = null;
                if (Crop)
                {
                    pic = ScreenshotUtil.CreateScreenShot(rect);
                }
                else
                {
                    pic = ScreenshotUtil.CreateScreenShot();
                }
                if (pic != null)
                {
                    var i       = solutions.IndexOf(i_solution);
                    var outFile = HeatSourceLayoutApp.CurrentDirectory + "\\tmp\\" + (i + ".jpg");
                    pic.Save(outFile, GetFormat(outFile));
                }
                //完成一个更新一下进度条
                for (int i = number_display; i < number_display + len; i++)
                {
                    System.Threading.Thread.Sleep(5);
                    pm.MeterProgress();
                    System.Windows.Forms.Application.DoEvents();
                }
                number_display = number_display + len;
                //重新显示云线
                using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
                {
                    using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
                    {
                        foreach (var district in i_solution.Districts)
                        {
                            Entity obj = (Entity)(tr.GetObject(district.Value.BaseObjectId, OpenMode.ForRead));
                            if (!obj.IsErased)
                            {
                                obj.UpgradeOpen();
                                obj.Visible = true;
                            }
                        }
                        tr.Commit();
                    }
                }
            }
            return(true);
        }