如何通过c# - Dynamics CRM Online在子菜单选项中添加项目

时间:2017-07-24 14:42:07

标签: c# microsoft-dynamics dynamics-crm-online

我现在有机会使用一些菜单项,如下图所示。

enter image description here

我想使用Windows窗体应用程序以编程方式添加产品。使用Dynamics Online Portal添加现有产品。但是,我需要通过c#做同样的事情。

在互联网上搜索后,我发现我们可以通过使用相关设施来实现这一目标。调用Service.Execute(Request)。

首先,我找到了所需的实体名称。当我找到Motor Products的实体名称时,我使用了Service.Create(实体)来添加产品。该产品已添加但未在此机会下展示,因为我没有通过此参考的参考。

然后,我试图找到商机和产品线项目之间的关系,但我找不到任何常见的唯一属性(例如:在产品线项目中没有opportunityid)。最终,该应用程序正在抛出错误。

我们是否可以通过编程方式在Motor Products中添加产品?

1 个答案:

答案 0 :(得分:1)

您在电机产品下看到的网格未显示与商机相关的产品,但商机产品

机会产品是一个不同的实体,充当机会及其相关产品之间的交集。

机会产品可以用C#编程创建。以下是它的外观:

while(driver.FindElement(By.Id("Captcha")).GetCssValue("display").ToString().Trim() == "block")
                    { 
                ITakesScreenshot ssdriver = driver as ITakesScreenshot;
                byte[] screenshot = ssdriver.GetScreenshot().AsByteArray;
                MemoryStream ms = new MemoryStream(screenshot);
                IWebElement my_image = driver.FindElement(By.XPath("//*[@id=\"Captcha\"]/img"));

                Point point = my_image.Location;
                int width = my_image.Size.Width;
                int height = my_image.Size.Height;
                Rectangle section = new Rectangle(point, new Size(width, height));

                Bitmap originalScreenshot = (Bitmap)Bitmap.FromStream(ms);
                Bitmap final_image = CropImage(originalScreenshot, section);

                MemoryStream ms2 = new MemoryStream();
                final_image.Save(ms2, ImageFormat.Png);
                byte[] captchaimage = ms2.ToArray();
                Image image = Image.FromStream(ms2);
                image.Save(@"C:\Users\bulut\Desktop\testcaptcha.png");
                OcrEngine ocrEngine = new OcrEngine();
                ocrEngine.Image = ImageStream.FromStream(ms2, ImageStreamFormat.Png);
                string SolvedCaptcha = "";
                if (ocrEngine.Process())
                {

                    string OcrCaptcha = ocrEngine.Text.ToString().Trim();
                    SolvedCaptcha = Regex.Replace(OcrCaptcha, "[^a-zA-Z0-9]", "").Trim();

                }
                var script = "document.getElementById('ContentPlaceHolder1_txtCaptcha').value = '';";
                IWebElement element = (IWebElement)((IJavaScriptExecutor)driver).ExecuteScript(script);
                IWebElement captcha = driver.FindElement(By.XPath("//*[@id=\"ContentPlaceHolder1_txtCaptcha\"]"));
                captcha.SendKeys(SolvedCaptcha);
                captcha.SendKeys(Keys.Enter);

                    var wait5 = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                    wait5.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete"));
                    Thread.Sleep(2000);
            }

你是正确的寻找struct TaggedClosure<P, R>: Equatable, Hashable { let id: Int let closure: (P) -> R static func == (lhs: TaggedClosure, rhs: TaggedClosure) -> Bool { return lhs.id == rhs.id } var hashValue: Int { return id } } let a = TaggedClosure(id: 1) { print("foo") } let b = TaggedClosure(id: 1) { print("foo") } let c = TaggedClosure(id: 2) { print("bar") } print("a == b:", a == b) // => true print("a == c:", a == c) // => false print("b == c:", b == c) // => false 字段;它不在表单上,​​而是在实体的架构上。您可以检查SDK元数据文件以获取证据。