コード例 #1
0
        internal static void ClickNew(DTE dte)
        {
            try
            {
                dte.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);
                if (UtilityPackage.GetCrmServiceClient(dte))
                {
                    var crmServiceClient = (CrmServiceClient)UtilityPackage.GetGlobal("CrmServiceClient", dte);
                    var crmUrl           = (string)UtilityPackage.GetGlobal("CrmUrl", dte);

                    UtilityPackage.SetDTEStatusBar(dte, $"[{crmUrl}] Connected");

                    var fullFileName = dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
                    var fileName     = Path.GetFileName(fullFileName);
                    var solutions    = XrmHelper.GetAllSolutions(crmServiceClient);
                    var formItems    = new FormItems(CrmItemType.NewWebResource, solutions, fullFileName, crmUrl);
                    formItems.SetWebResourceName(Utility.GetCurrentProjectDirectoryName(dte));
                    if (formItems.ShowDialog() == DialogResult.OK)
                    {
                        var solutionUniqueName = formItems.SolutionUniqueName;
                        var resourceName       = formItems.ResourceName;
                        var resourceId         = DeployNewWebResource(dte, crmServiceClient, crmUrl, fullFileName, resourceName, solutionUniqueName);
                        AddToCache(dte, fullFileName, resourceId, resourceName);
                    }
                }
                dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
            }
            catch
            {
                UtilityPackage.SetDTEStatusBarAndStopAnimate(dte, "Deploy WebResource failed");
            }
        }
コード例 #2
0
 internal static void Click(DTE dte)
 {
     try
     {
         dte.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);
         if (UtilityPackage.GetCrmServiceClient(dte))
         {
             var crmServiceClient = (CrmServiceClient)UtilityPackage.GetGlobal("CrmServiceClient", dte);
             var crmUrl           = (string)UtilityPackage.GetGlobal("CrmUrl", dte);
             UtilityPackage.SetDTEStatusBar(dte, $"[{crmUrl}] Connected");
             var fullFileName = dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
             var fileName     = Path.GetFileName(fullFileName);
             var resourceId   = GetCachedResourceId(fullFileName, dte);
             if (resourceId != Guid.Empty)
             {
                 DeployWebResource(dte, crmServiceClient, crmUrl, fullFileName, fileName, resourceId);
             }
             else
             {
                 var resources = GetResources(crmServiceClient, fullFileName);
                 if (resources.Count == 0)
                 {
                     UtilityPackage.SetDTEStatusBar(dte, $"[{crmUrl}] WebResource: {fileName} not found");
                 }
                 else
                 {
                     var formItems = new FormItems(CrmItemType.WebResource, resources, fullFileName, crmUrl);
                     if (formItems.ShowDialog() == DialogResult.OK)
                     {
                         resourceId = formItems.ObjectId;
                         var resourceName = formItems.ResourceName;
                         AddToCache(dte, fullFileName, resourceId, resourceName);
                         DeployWebResource(dte, crmServiceClient, crmUrl, fullFileName, fileName, resourceId);
                     }
                 }
             }
         }
         dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
     }
     catch
     {
         UtilityPackage.SetDTEStatusBarAndStopAnimate(dte, "Deploy WebResource failed");
     }
 }
コード例 #3
0
        internal static void Click(DTE dte)
        {
            try
            {
                dte.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);
                if (UtilityPackage.GetCrmServiceClient(dte))
                {
                    var crmServiceClient = (CrmServiceClient)UtilityPackage.GetGlobal("CrmServiceClient", dte);
                    var crmUrl           = (string)UtilityPackage.GetGlobal("CrmUrl", dte);
                    UtilityPackage.SetDTEStatusBar(dte, $"[{crmUrl}] Connected");

                    var fullFileName = dte.SelectedItems.Item(1).ProjectItem.FileNames[0];

                    var cacheReportFromVS = GetCacheReportFromVS(dte, fullFileName);
                    if (cacheReportFromVS == null)
                    {
                        var cacheReportFromFile = GetCacheReportFromFile(fullFileName);

                        var formReport = new FormReport(crmServiceClient, cacheReportFromFile);
                        if (formReport.ShowDialog() == DialogResult.OK)
                        {
                            var language   = formReport.Language;
                            var solution   = formReport.Solution;
                            var reportName = formReport.ReportName;
                            var reportId   = formReport.ReportId;

                            DoDeployReport(dte, crmServiceClient, reportId, fullFileName);
                            AddToCache(dte, language, solution, reportName, reportId, fullFileName);
                        }
                    }
                    else
                    {
                        DoDeployReport(dte, crmServiceClient, cacheReportFromVS.Value, fullFileName);
                    }
                }
                dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
            }
            catch
            {
                UtilityPackage.SetDTEStatusBarAndStopAnimate(dte, "Deploy WebResource failed");
            }
        }