コード例 #1
0
        public static void Main(string[] args)
        {
            Parser.Default.ParseArguments <CommandLineOptions>(args)
            .WithParsed(o =>
            {
                var lcgHelper = new LCGHelper();
                lcgHelper.LoadSettingsFromFile(o.SettingsFilePath);

                if (o.ConnectionString != null)
                {
                    lcgHelper.ConnectCrm(o.ConnectionString);
                }
                else
                {
                    var credentials = new CrmCredentials
                    {
                        Domain     = o.Domain,
                        OrgUnit    = o.OrgUnit,
                        ServerName = o.ServerName,
                        Password   = o.Password,
                        Protocol   = o.Protocol,
                        User       = o.User
                    };

                    lcgHelper.ConnectCrm(credentials);
                }

                lcgHelper.GenerateConstants();
            });
        }
コード例 #2
0
        public static CrmConnection ConnectCrm(CrmCredentials credentials)
        {
            var organizationServiceUri = $@"{credentials.Protocol}://{credentials.ServerName}/{credentials.OrgUnit}/XRMServices/2011/Organization.svc";
            var serverUri         = new Uri(organizationServiceUri);
            var clientCredentials = new ClientCredentials();

            clientCredentials.Windows.ClientCredential = new NetworkCredential(credentials.User, credentials.Password, credentials.Domain);
            var organizationServiceProxy = new OrganizationServiceProxy(serverUri, null, clientCredentials, null);

            organizationServiceProxy.EnableProxyTypes();
            return(new CrmConnection(organizationServiceProxy, organizationServiceUri));
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            try
            {
                Parser.Default.ParseArguments <CommandLineOptions>(args)
                .WithParsed(o =>
                {
                    Console.WriteLine($"********************** Authorized By Appsurfs {DateTime.Now.Year} Author: Ian Mok **********************");

                    var lcgHelper = new LCGHelper();
                    lcgHelper.LoadSettingsFromFile(o.SettingsFilePath);

                    if (o.ConnectionString != null)
                    {
                        lcgHelper.ConnectCrm(o.ConnectionString);
                    }
                    else
                    {
                        var credentials = new CrmCredentials
                        {
                            Domain     = o.Domain,
                            OrgUnit    = o.OrgUnit,
                            ServerName = o.ServerName,
                            Password   = o.Password,
                            Protocol   = o.Protocol,
                            User       = o.User
                        };

                        lcgHelper.ConnectCrm(credentials);
                    }

                    lcgHelper.GenerateConstants();
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
 public void ConnectCrm(CrmCredentials credentials)
 {
     this.crmConnection = CrmConnection.ConnectCrm(credentials);
 }