예제 #1
0
 public static System.Net.Authorization? Authenticate(string challenge, System.Net.WebRequest request, System.Net.ICredentials credentials)
 {
     throw null;
 }
예제 #2
0
        public SharePointBackend(string url, Dictionary <string, string> options)
        {
            m_deleteToRecycler    = Utility.Utility.ParseBoolOption(options, "delete-to-recycler");
            m_useBinaryDirectMode = Utility.Utility.ParseBoolOption(options, "binary-direct-mode");

            try
            {
                string strSpan;
                if (options.TryGetValue("web-timeout", out strSpan))
                {
                    TimeSpan ts = Timeparser.ParseTimeSpan(strSpan);
                    if (ts.TotalMilliseconds > 30000 && ts.TotalMilliseconds < int.MaxValue)
                    {
                        this.m_useContextTimeoutMs = (int)ts.TotalMilliseconds;
                    }
                }
            }
            catch { }

            try
            {
                string strChunkSize;
                if (options.TryGetValue("chunk-size", out strChunkSize))
                {
                    long pSize = Utility.Sizeparser.ParseSize(strChunkSize, "MB");
                    if (pSize >= (1 << 14) && pSize <= (1 << 30)) // [16kb .. 1GB]
                    {
                        this.m_fileChunkSize = (int)pSize;
                    }
                }
            }
            catch { }


            var u = new Utility.Uri(url);

            u.RequireHost();

            // Create sanitized plain https-URI (note: still has double slashes for processing web)
            m_orgUrl = new Utility.Uri("https", u.Host, u.Path, null, null, null, u.Port);

            // Actual path to Web will be searched for on first use. Ctor should not throw.
            m_spWebUrl = null;

            m_serverRelPath = u.Path;
            if (!m_serverRelPath.StartsWith("/", StringComparison.Ordinal))
            {
                m_serverRelPath = "/" + m_serverRelPath;
            }
            if (!m_serverRelPath.EndsWith("/", StringComparison.Ordinal))
            {
                m_serverRelPath += "/";
            }
            // remove marker for SP-Web
            m_serverRelPath = m_serverRelPath.Replace("//", "/");

            // Authentication settings processing:
            // Default: try integrated auth (will normally not work for Office365, but maybe with on-prem SharePoint...).
            // Otherwise: Use settings from URL(precedence) or from command line options.
            bool useIntegratedAuthentication = Utility.Utility.ParseBoolOption(options, "integrated-authentication");

            string useUsername = null;
            string usePassword = null;

            if (!useIntegratedAuthentication)
            {
                if (!string.IsNullOrEmpty(u.Username))
                {
                    useUsername = u.Username;
                    if (!string.IsNullOrEmpty(u.Password))
                    {
                        usePassword = u.Password;
                    }
                    else if (options.ContainsKey("auth-password"))
                    {
                        usePassword = options["auth-password"];
                    }
                }
                else
                {
                    if (options.ContainsKey("auth-username"))
                    {
                        useUsername = options["auth-username"];
                        if (options.ContainsKey("auth-password"))
                        {
                            usePassword = options["auth-password"];
                        }
                    }
                }
            }

            if (useIntegratedAuthentication || (useUsername == null || usePassword == null))
            {
                // This might or might not work for on-premises SP. Maybe support if someone complains...
                m_userInfo = System.Net.CredentialCache.DefaultNetworkCredentials;
            }
            else
            {
                System.Security.SecureString securePwd = new System.Security.SecureString();
                usePassword.ToList().ForEach(c => securePwd.AppendChar(c));
                m_userInfo = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(useUsername, securePwd);
                // Other options (also ADAL, see class remarks) might be supported on request.
                // Maybe go in deep then and also look at:
                // - Microsoft.SharePoint.Client.AppPrincipalCredential.CreateFromKeyGroup()
                // - ctx.AuthenticationMode = SP.ClientAuthenticationMode.FormsAuthentication;
                // - ctx.FormsAuthenticationLoginInfo = new SP.FormsAuthenticationLoginInfo(user, pwd);
            }
        }
 public static System.Net.Authorization PreAuthenticate(System.Net.WebRequest request, System.Net.ICredentials credentials)
 {
     return(default(System.Net.Authorization));
 }
예제 #4
0
 public WebProxy(string Address, bool BypassOnLocal, string[] BypassList, System.Net.ICredentials Credentials)
 {
 }
 public static void Initialize(Uri teamCollectionUrl, string projectName, System.Net.ICredentials credentials)
 {
     manager = new Manager(teamCollectionUrl, projectName, credentials);
 }
예제 #6
0
 public bool TryGetLastKnownGoodCredentialsFromCache(System.Uri uri, bool isProxy, out System.Net.ICredentials credentials)
 {
     throw null;
 }
예제 #7
0
 public void Dispose()
 {
     try
     {
         if (m_spContext != null)
             m_spContext.Dispose();
     }
     catch { }
     m_userInfo = null;
 }
예제 #8
0
 public bool CanPreAuthenticate(IHttpClient client, IHttpRequestMessage request, System.Net.ICredentials credentials)
 {
     return(false);
 }
예제 #9
0
 public WindowsCredentials(string database)
 {
   _credentials = System.Net.CredentialCache.DefaultCredentials;
   _database = database;
 }
예제 #10
0
 public WindowsCredentials(string database, System.Net.ICredentials credentials)
 {
   _credentials = credentials;
   _database = database;
 }
예제 #11
0
        public static void CreateSubSites(XNamespace _NameSpace, TokenParser _TokenParser, XElement _Branding, string siteUrl, System.Net.ICredentials creds)
        {
            Console.WriteLine("Creating Sub-Sites . . . ");

            foreach (var site in _Branding.GetDescendants("sites", "site"))
            {
                string web                = site.GetAttributeValue(_TokenParser, "web");
                string title              = site.GetAttributeValue(_TokenParser, "title");
                string leafUrl            = site.GetAttributeValue(_TokenParser, "leafUrl");
                string description        = site.GetAttributeValue(_TokenParser, "description");
                string template           = site.GetAttributeValue(_TokenParser, "template");
                int    language           = site.GetAttributeValue <int>(_TokenParser, "language");
                bool   inheritPermissions = Convert.ToBoolean(site.GetAttributeValue(_TokenParser, "inheritpermissions"));
                bool   inheritNavigation  = Convert.ToBoolean(site.GetAttributeValue(_TokenParser, "inheritnavigation"));
                string lists              = site.GetAttributeValue(_TokenParser, "lists");

                //pre-pend site collection path
                if (String.IsNullOrEmpty(web))
                {
                    web = siteUrl;
                }
                else
                {
                    web = siteUrl + "/" + web;
                }

                // create new Sub-site after testing for existence
                Web newWeb = null;
                using (ClientContext clientContext = new ClientContext(web))
                {
                    clientContext.Credentials    = creds;
                    clientContext.RequestTimeout = 10 * 60 * 1000;
                    clientContext.Load(clientContext.Web);
                    clientContext.ExecuteQueryRetry();

                    string newWebUrl = clientContext.Web.Url + "/" + leafUrl;
                    if (clientContext.WebExistsFullUrl(newWebUrl))
                    {
                        Console.WriteLine("Sub-Site {0} already exists, skipping provisioning.", leafUrl);
                    }
                    else
                    {
                        Console.WriteLine("Creating Sub-Site {0} . . .", leafUrl);

                        newWeb = clientContext.Web.CreateWeb(title, leafUrl, description, template, language, inheritPermissions, inheritNavigation);

                        clientContext.Load(newWeb, w => w.Lists);
                        clientContext.ExecuteQueryRetry();

                        Microsoft.SharePoint.Client.File welcomePageFile = newWeb.Lists.GetByTitle("Pages").GetItemById(1).File;
                        welcomePageFile.Publish("Initial Publish");
                        clientContext.Load(welcomePageFile);
                        clientContext.ExecuteQueryRetry();

                        if (!inheritPermissions)
                        {
                            SitePermissions.ApplyPermissions(clientContext, newWeb);
                        }
                    }

                    if (!String.IsNullOrEmpty(lists))
                    {
                        CreateLists(_NameSpace, _TokenParser, _Branding, clientContext, lists);
                    }
                }
            }
        }
 public void UploadFile(string sourceFileName, System.Uri address, System.Net.ICredentials networkCredentials, bool showUI, int connectionTimeout)
 {
 }
 public void DownloadFile(System.Uri address, string destinationFileName, System.Net.ICredentials networkCredentials, bool showUI, int connectionTimeout, bool overwrite, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel)
 {
 }
예제 #14
0
 public HttpClient CreateHttpClient(string endpoint, System.Net.ICredentials credentials)
 {
     throw new NotImplementedException();
 }
예제 #15
0
        public SharePointBackend(string url, Dictionary<string, string> options)
        {
            m_deleteToRecycler = Utility.Utility.ParseBoolOption(options, "delete-to-recycler");
            m_useBinaryDirectMode = Utility.Utility.ParseBoolOption(options, "binary-direct-mode");

            try
            {
                string strSpan;
                if (options.TryGetValue("web-timeout", out strSpan))
                {
                    TimeSpan ts = Timeparser.ParseTimeSpan(strSpan);
                    if (ts.TotalMilliseconds > 30000 && ts.TotalMilliseconds < int.MaxValue)
                        this.m_useContextTimeoutMs = (int)ts.TotalMilliseconds;
                }
            }
            catch { }

            try
            {
                string strChunkSize;
                if (options.TryGetValue("chunk-size", out strChunkSize))
                {
                    long pSize = Utility.Sizeparser.ParseSize(strChunkSize, "MB");
                    if (pSize >= (1 << 14) && pSize <= (1 << 30)) // [16kb .. 1GB]
                        this.m_fileChunkSize = (int)pSize;
                }
            }
            catch { }

            var u = new Utility.Uri(url);
            u.RequireHost();

            // Create sanitized plain https-URI (note: still has double slashes for processing web)
            m_orgUrl = new Utility.Uri("https", u.Host, u.Path, null, null, null, u.Port);

            // Actual path to Web will be searched for on first use. Ctor should not throw.
            m_spWebUrl = null;

            m_serverRelPath = u.Path;
            if (!m_serverRelPath.StartsWith("/"))
                m_serverRelPath = "/" + m_serverRelPath;
            if (!m_serverRelPath.EndsWith("/"))
                m_serverRelPath += "/";
            // remove marker for SP-Web
            m_serverRelPath = m_serverRelPath.Replace("//", "/");

            // Authentication settings processing:
            // Default: try integrated auth (will normally not work for Office365, but maybe with on-prem SharePoint...).
            // Otherwise: Use settings from URL(precedence) or from command line options.
            bool useIntegratedAuthentication = Utility.Utility.ParseBoolOption(options, "integrated-authentication");

            string useUsername = null;
            string usePassword = null;

            if (!useIntegratedAuthentication)
            {
                if (!string.IsNullOrEmpty(u.Username))
                {
                    useUsername = u.Username;
                    if (!string.IsNullOrEmpty(u.Password))
                        usePassword = u.Password;
                    else if (options.ContainsKey("auth-password"))
                        usePassword = options["auth-password"];
                }
                else
                {
                    if (options.ContainsKey("auth-username"))
                    {
                        useUsername = options["auth-username"];
                        if (options.ContainsKey("auth-password"))
                            usePassword = options["auth-password"];
                    }
                }
            }

            if (useIntegratedAuthentication || (useUsername == null || usePassword == null))
            {
                // This might or might not work for on-premises SP. Maybe support if someone complains...
                m_userInfo = System.Net.CredentialCache.DefaultNetworkCredentials;
            }
            else
            {
                System.Security.SecureString securePwd = new System.Security.SecureString();
                usePassword.ToList().ForEach(c => securePwd.AppendChar(c));
                m_userInfo = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(useUsername, securePwd);
                // Other options (also ADAL, see class remarks) might be supported on request.
                // Maybe go in deep then and also look at:
                // - Microsoft.SharePoint.Client.AppPrincipalCredential.CreateFromKeyGroup()
                // - ctx.AuthenticationMode = SP.ClientAuthenticationMode.FormsAuthentication;
                // - ctx.FormsAuthenticationLoginInfo = new SP.FormsAuthenticationLoginInfo(user, pwd);
            }
        }
 public void DownloadFile(System.Uri address, string destinationFileName, System.Net.ICredentials networkCredentials, bool showUI, int connectionTimeout, bool overwrite)
 {
 }
예제 #17
0
        public SharePointBackend(string url, Dictionary <string, string> options)
        {
            m_deleteToRecycler = Utility.Utility.ParseBoolOption(options, "delete-to-recycler");

            var u = new Utility.Uri(url);

            u.RequireHost();

            // Create sanitized plain https-URI (note: still has double slashes for processing web)
            m_orgUrl = new Utility.Uri("https", u.Host, u.Path, null, null, null, u.Port);

            // Actual path to Web will be searched for on first use. Ctor should not throw.
            m_spWebUrl = null;

            m_serverRelPath = u.Path;
            if (!m_serverRelPath.StartsWith("/"))
            {
                m_serverRelPath = "/" + m_serverRelPath;
            }
            if (!m_serverRelPath.EndsWith("/"))
            {
                m_serverRelPath += "/";
            }
            // remove marker for SP-Web
            m_serverRelPath = m_serverRelPath.Replace("//", "/");

            // Authentication settings processing:
            // Default: try integrated auth (will normally not work for Office365, but maybe with on-prem SharePoint...).
            // Otherwise: Use settings from URL(precedence) or from command line options.
            bool useIntegratedAuthentication = Utility.Utility.ParseBoolOption(options, "integrated-authentication");

            string useUsername = null;
            string usePassword = null;

            if (!useIntegratedAuthentication)
            {
                if (!string.IsNullOrEmpty(u.Username))
                {
                    useUsername = u.Username;
                    if (!string.IsNullOrEmpty(u.Password))
                    {
                        usePassword = u.Password;
                    }
                    else if (options.ContainsKey("auth-password"))
                    {
                        usePassword = options["auth-password"];
                    }
                }
                else
                {
                    if (options.ContainsKey("auth-username"))
                    {
                        useUsername = options["auth-username"];
                        if (options.ContainsKey("auth-password"))
                        {
                            usePassword = options["auth-password"];
                        }
                    }
                }
            }

            if (useIntegratedAuthentication || (useUsername == null || usePassword == null))
            {
                // This might or might not work for on-premises SP. Maybe support if someone complains...
                m_userInfo = System.Net.CredentialCache.DefaultNetworkCredentials;
            }
            else
            {
                System.Security.SecureString securePwd = new System.Security.SecureString();
                usePassword.ToList().ForEach(c => securePwd.AppendChar(c));
                m_userInfo = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(useUsername, securePwd);
                // Other options (also ADAL, see class remarks) might be supported on request.
                // Maybe go in deep then and also look at:
                // - Microsoft.SharePoint.Client.AppPrincipalCredential.CreateFromKeyGroup()
                // - ctx.AuthenticationMode = SP.ClientAuthenticationMode.FormsAuthentication;
                // - ctx.FormsAuthenticationLoginInfo = new SP.FormsAuthenticationLoginInfo(user, pwd);
            }
        }
예제 #18
0
 public bool CanHandleChallenge(IHttpClient client, IHttpRequestMessage request, System.Net.ICredentials credentials, IHttpResponseMessage response)
 {
     return(false);
 }
예제 #19
0
             internal void SPUploader(Stream fs, string fn)
              {
                 ClientContext context = new ClientContext("http://Sharepointsite");///SitePages/Home.aspx");
                 System.Net.ICredentials creds = System.Net.CredentialCache.DefaultCredentials;
     
                 context.Credentials = creds;
                 context.RequestTimeout = 60000000; // Time in milliseconds
     
                 string url = "/Members/";
                 string fileName = Path.GetFileName(fn);                   
     
                 string fnUrl = url + fn;
     
                 Microsoft.SharePoint.Client.File.SaveBinaryDirect(context, fnUrl, fs, true);
     
                 string uniqueRefNo = GetNextDocRefNo();
                
                 SP.Web web = context.Web;
     
                 Microsoft.SharePoint.Client.File newFile = web.GetFileByServerRelativeUrl(fnUrl);
                 context.Load(newFile);
                 context.ExecuteQuery();
     
                 Web site = context.Web;
                 List docList = site.Lists.GetByTitle("Members");
     
                 context.Load(docList);
                 context.ExecuteQuery();
     
 
                 context.Load(docList.Fields.GetByTitle("Workflow Number"));
                 context.Load(docList.Fields.GetByTitle("Agreement Number"));
                 context.Load(docList.Fields.GetByTitle("First Name"));
                 context.Load(docList.Fields.GetByTitle("Surname"));
                 context.Load(docList.Fields.GetByTitle("ID Number"));
                 context.Load(docList.Fields.GetByTitle("Date of Birth"));
                 context.Load(docList.Fields.GetByTitle("Country"));
                 context.Load(docList.Fields.GetByTitle("Document Description"));
                 context.Load(docList.Fields.GetByTitle("Document Type"));
                 context.Load(docList.Fields.GetByTitle("Document Group"));
     
                 context.ExecuteQuery();                                
     
 *********NEED TO GET THE INTERNAL COLUMN NAMES FROM SHAREPOINT************
                 var name = docList.Fields.GetByTitle("Workflow Number").InternalName;
                 var name2 = docList.Fields.GetByTitle("Agreement Number").InternalName;
                 var name3 = docList.Fields.GetByTitle("First Name").InternalName;
                 var name4 = docList.Fields.GetByTitle("Surname").InternalName;
                 var name5 = docList.Fields.GetByTitle("ID Number").InternalName;
                 var name6 = docList.Fields.GetByTitle("Date of Birth").InternalName;
                 var name7 = docList.Fields.GetByTitle("Country").InternalName;
                 var name8 = docList.Fields.GetByTitle("Document Description").InternalName;
                 var name9 = docList.Fields.GetByTitle("Document Type").InternalName;
                 var name10 = docList.Fields.GetByTitle("Document Group").InternalName;
                 var name11 = docList.Fields.GetByTitle("Unique Document Ref No").InternalName;     
     
 **********NOW SAVE THE METADATA TO SHAREPOINT**********
                 newFile.ListItemAllFields[name] = "927015";
                 newFile.ListItemAllFields[name2] = "1234565";
                 newFile.ListItemAllFields[name3] = "Joe";
                 newFile.ListItemAllFields[name4] = "Soap";
                 newFile.ListItemAllFields[name5] = "7502015147852";
                 newFile.ListItemAllFields[name6] = "1975-02-01";
                 newFile.ListItemAllFields[name7] = "ZA";
                 newFile.ListItemAllFields[name8] = "Test";
                 newFile.ListItemAllFields[name9] = "Requirements";
                 newFile.ListItemAllFields[name10] = "Requirements";
                 newFile.ListItemAllFields[name11] = uniqueRefNo;
     
                 newFile.ListItemAllFields.Update();
                 context.Load(newFile);
                 context.ExecuteQuery();
예제 #20
0
 public CredentialResponse(System.Net.ICredentials credentials)
 {
 }
예제 #21
0
 public System.IO.Stream Get(System.Net.ICredentials credentials)
 {
     return(new FileStream(this.Uri.LocalPath, FileMode.Open));
 }
 public static System.Net.Authorization Authenticate(string challenge, System.Net.WebRequest request, System.Net.ICredentials credentials)
 {
     return(default(System.Net.Authorization));
 }
예제 #23
0
 public void Move(Uri destination, System.Net.ICredentials credentials)
 {
     File.Move(this.Uri.LocalPath, destination.LocalPath);
 }
        private void PublishNext()
        {
            List <YellowstonePathology.Business.Test.PanelSetOrderView> caseList = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetNextCasesToPublish();

            int maxProcessCount = 2;

            if (caseList.Count >= 10)
            {
                maxProcessCount = 10;
            }

            int processCount = 0;

            foreach (YellowstonePathology.Business.Test.PanelSetOrderView view in caseList)
            {
                YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullAccessionOrder(view.MasterAccessionNo, this);
                YellowstonePathology.Business.Test.PanelSetOrder  panelSetOrder  = accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(view.ReportNo);

                if (panelSetOrder.PanelSetId == 116)
                {
                    this.HandleWHP(accessionOrder, panelSetOrder);
                }

                YellowstonePathology.Business.PanelSet.Model.PanelSetCollection panelSetCollection = YellowstonePathology.Business.PanelSet.Model.PanelSetCollection.GetAll();
                YellowstonePathology.Business.PanelSet.Model.PanelSet           panelSet           = panelSetCollection.GetPanelSet(panelSetOrder.PanelSetId);

                YellowstonePathology.Business.Interface.ICaseDocument caseDocument  = YellowstonePathology.Business.Document.DocumentFactory.GetDocument(accessionOrder, panelSetOrder, Business.Document.ReportSaveModeEnum.Normal);
                YellowstonePathology.Business.OrderIdParser           orderIdParser = new YellowstonePathology.Business.OrderIdParser(panelSetOrder.ReportNo);

                if (panelSetOrder.HoldDistribution == false)
                {
                    if (this.TryDelete(panelSetOrder, caseDocument, orderIdParser) == true)
                    {
                        if (this.TryPublish(caseDocument, accessionOrder, panelSetOrder) == true)
                        {
                            if (panelSetOrder.Distribute == true)
                            {
                                foreach (YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistribution testOrderReportDistribution in panelSetOrder.TestOrderReportDistributionCollection)
                                {
                                    if (testOrderReportDistribution.Distributed == false)
                                    {
                                        YellowstonePathology.Business.ReportDistribution.Model.DistributionResult distributionResult = this.Distribute(testOrderReportDistribution, accessionOrder, panelSetOrder);
                                        if (distributionResult.IsComplete == true)
                                        {
                                            testOrderReportDistribution.TimeOfLastDistribution    = DateTime.Now;
                                            testOrderReportDistribution.ScheduledDistributionTime = null;
                                            testOrderReportDistribution.Distributed = true;

                                            string testOrderReportDistributionLogId = Guid.NewGuid().ToString();
                                            string objectId = MongoDB.Bson.ObjectId.GenerateNewId().ToString();
                                            YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog testOrderReportDistributionLog = new YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog(testOrderReportDistributionLogId, objectId);
                                            testOrderReportDistributionLog.FromTestOrderReportDistribution(testOrderReportDistribution);
                                            testOrderReportDistributionLog.TimeDistributed = DateTime.Now;
                                            panelSetOrder.TestOrderReportDistributionLogCollection.Add(testOrderReportDistributionLog);

                                            this.m_ReportDistributionLogEntryCollection.AddEntry("INFO", "Publish Next", testOrderReportDistribution.DistributionType, panelSetOrder.ReportNo, panelSetOrder.MasterAccessionNo,
                                                                                                 testOrderReportDistribution.PhysicianName, testOrderReportDistribution.ClientName, "TestOrderReportDistribution Distributed");
                                        }
                                        else
                                        {
                                            testOrderReportDistribution.ScheduledDistributionTime = DateTime.Now.AddMinutes(30);
                                            testOrderReportDistribution.Rescheduled        = true;
                                            testOrderReportDistribution.RescheduledMessage = distributionResult.Message;

                                            this.m_ReportDistributionLogEntryCollection.AddEntry("ERROR", "Publish Next", testOrderReportDistribution.DistributionType, panelSetOrder.ReportNo, panelSetOrder.MasterAccessionNo,
                                                                                                 testOrderReportDistribution.PhysicianName, testOrderReportDistribution.ClientName, distributionResult.Message);

                                            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**", System.Windows.Forms.SystemInformation.UserName, distributionResult.Message);
                                            System.Net.Mail.SmtpClient  client  = new System.Net.Mail.SmtpClient("10.1.2.111");

                                            Uri uri = new Uri("http://tempuri.org/");
                                            System.Net.ICredentials      credentials = System.Net.CredentialCache.DefaultCredentials;
                                            System.Net.NetworkCredential credential  = credentials.GetCredential(uri, "Basic");

                                            client.Credentials = credential;
                                            client.Send(message);
                                        }
                                    }
                                }
                            }

                            panelSetOrder.Published            = true;
                            panelSetOrder.TimeLastPublished    = DateTime.Now;
                            panelSetOrder.ScheduledPublishTime = null;

                            Business.Persistence.DocumentGateway.Instance.Save();
                        }
                    }

                    processCount += 1;
                    if (processCount == maxProcessCount)
                    {
                        break;
                    }
                }
            }

            YellowstonePathology.Business.Persistence.DocumentGateway.Instance.Push(this);
        }
예제 #25
0
 public System.Threading.Tasks.Task PreAuthenticate(IRestClient client, IRestRequest request, System.Net.ICredentials credentials)
 {
     return(Task.Run(() =>
     {
         if (!string.IsNullOrEmpty(AccessToken))
         {
             request.AddHeader("Authorization", "Bearer " + AccessToken);
         }
     }));
 }
예제 #26
0
 public Manager(Uri tfsUrl, string projectName, System.Net.ICredentials credentials)
 {
     server       = new Server(tfsUrl, projectName, credentials);
     reportEngine = new ReportEngine();
 }
예제 #27
0
 public System.Threading.Tasks.Task PreAuthenticate(IHttpClient client, IHttpRequestMessage request, System.Net.ICredentials credentials)
 {
     throw new NotImplementedException();
 }
예제 #28
0
 public static System.Net.Authorization? PreAuthenticate(System.Net.WebRequest request, System.Net.ICredentials credentials)
 {
     throw null;
 }
예제 #29
0
 public System.Threading.Tasks.Task HandleChallenge(IHttpClient client, IHttpRequestMessage request, System.Net.ICredentials credentials, IHttpResponseMessage response)
 {
     throw new NotImplementedException();
 }
예제 #30
0
        private PingCollectorResult PingHTTP()
        {
            PingCollectorResult result = new PingCollectorResult();
            string lastStep            = "[Create WebClientEx]";

            result.Success         = false;
            result.PingTime        = -1;
            result.ResponseDetails = "";
            try
            {
                lastStep = "[HTTPSSetup]";
                if (Address.ToLower().StartsWith("https://"))
                {
                    System.Net.ServicePointManager.Expect100Continue = true;
                    System.Net.ServicePointManager.SecurityProtocol  = System.Net.SecurityProtocolType.Ssl3;
                    if (IgnoreInvalidHTTPSCerts)
                    {
                        System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }
                    }
                    ;
                    else
                    {
                        System.Net.ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
                    }
                }

                Stopwatch sw = new Stopwatch();
                using (WebClientEx wc = new WebClientEx())
                {
                    wc.Timeout = (TimeOutMS * 1000);
                    if (HttpProxyServer.Length > 0)
                    {
                        System.Net.WebProxy     proxy       = null;
                        System.Net.ICredentials credentials = null;
                        if (HttpProxyUserName.Length == 0)
                        {
                            credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                            proxy       = new System.Net.WebProxy(HttpProxyServer, true, null, credentials);
                            proxy.UseDefaultCredentials = true;
                        }
                        else
                        {
                            if (HttpProxyUserName.Contains('\\'))
                            {
                                string domain   = HttpProxyUserName.Split('\\')[0];
                                string userName = HttpProxyUserName.Split('\\')[1];
                                credentials = new System.Net.NetworkCredential(userName, HttpProxyPassword, domain);
                            }
                            else
                            {
                                credentials = new System.Net.NetworkCredential(HttpProxyUserName, HttpProxyPassword);
                            }
                            proxy = new System.Net.WebProxy(HttpProxyServer, true, null, credentials);
                            proxy.UseDefaultCredentials = false;
                            proxy.Credentials           = credentials;
                        }
                        wc.Proxy = proxy;
                    }
                    else
                    {
                        wc.Proxy = null;
                    }
                    wc.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache);
                    sw.Start();

                    if (HttpHeaderUserName.Trim().Length > 0)
                    {
                        wc.UseDefaultCredentials = false;
                        wc.Credentials           = new System.Net.NetworkCredential(HttpHeaderUserName, HttpHeaderPassword);
                    }
                    else
                    {
                        wc.UseDefaultCredentials = true;
                    }

                    lastStep = "[OpenRead]";
                    using (System.IO.Stream webRequest = wc.OpenRead(Address))
                    {
                        int           chars       = 0;
                        StringBuilder docContents = new StringBuilder();
                        lastStep = "[CanRead]";
                        if (webRequest.CanRead)
                        {
                            lastStep = "[ReadByte]";
                            int readByte = webRequest.ReadByte();
                            while (readByte != -1) // && chars < 256)
                            {
                                chars++;
                                docContents.Append(Char.ConvertFromUtf32(readByte));
                                readByte = webRequest.ReadByte();

                                if (sw.ElapsedMilliseconds > TimeOutMS)
                                {
                                    break;
                                }
                            }
                            if (chars > 1)
                            {
                                result.ResponseContent = docContents.ToString();
                                result.ResponseDetails = "Characters returned:" + chars.ToString();
                            }
                        }
                        else
                        {
                            throw new Exception("Could not read web request stream");
                        }
                    }
                    sw.Stop();
                }
                result.PingTime = (int)sw.ElapsedMilliseconds;
                if (sw.ElapsedMilliseconds < TimeOutMS)
                {
                    result.Success = true;
                }
                else
                {
                    result.Success = false;
                }
            }
            catch (Exception ex)
            {
                result.Success  = false;
                result.PingTime = -1;

                if (ex is System.Net.WebException)
                {
                    if (((System.Net.WebException)ex).Response != null && ((System.Net.WebException)ex).Response is System.Net.HttpWebResponse)
                    {
                        System.Net.HttpWebResponse httpResp = ((System.Net.HttpWebResponse)((System.Net.WebException)ex).Response);
                        if (httpResp.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                        {
                            result.ResponseDetails = string.Format("The URL '{0}' requires authorization to connect - i.e. Username/Password", Address);
                        }
                        else
                        {
                            result.ResponseDetails = string.Format("The URL '{0}' returned an HTTP error: {1}", httpResp);
                        }
                    }
                    else
                    {
                        result.ResponseDetails = lastStep + " " + ex.Message;
                    }
                }
                else
                {
                    if (ex.InnerException != null)
                    {
                        result.ResponseDetails = lastStep + " " + ex.InnerException.Message;
                    }
                    else
                    {
                        result.ResponseDetails = lastStep + " " + ex.Message;
                    }
                }
            }
            return(result);
        }
예제 #31
0
 public bool CanPreAuthenticate(IRestClient client, IRestRequest request, System.Net.ICredentials credentials)
 {
     return(true);
 }
예제 #32
0
        /// <summary>
        /// Grabs the build number of the environment that we're testing
        /// </summary>
        /// <returns>Build number of the environment that's being tested</returns>
        private string GetBuildNumber()
        {
            string build = "";

            try
            {
                AuthenticationManager am = new AuthenticationManager();
                if (testConfiguration.TestAuthentication.AppOnly)
                {
                    string realm = TokenHelper.GetRealmFromTargetUrl(new Uri(testConfiguration.TestSiteUrl));

                    ClientContext ctx = null;

                    if (new Uri(testConfiguration.TestSiteUrl).DnsSafeHost.Contains("spoppe.com"))
                    {
                        ctx = am.GetAppOnlyAuthenticatedContext(testConfiguration.TestSiteUrl, realm, testConfiguration.TestAuthentication.AppId, testConfiguration.TestAuthentication.AppSecret, acsHostUrl: "windows-ppe.net", globalEndPointPrefix: "login");
                    }
                    else
                    {
                        ctx = am.GetAppOnlyAuthenticatedContext(testConfiguration.TestSiteUrl, realm, testConfiguration.TestAuthentication.AppId, testConfiguration.TestAuthentication.AppSecret);
                    }

                    using (ctx)
                    {
                        ctx.Load(ctx.Web, w => w.Title);
                        ctx.ExecuteQueryRetry();
                        build = ctx.ServerLibraryVersion.ToString();
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(testConfiguration.TestAuthentication.CredentialManagerLabel))
                    {
                        System.Net.ICredentials credentials = null;

                        if (testConfiguration.TestAuthentication.Type == TestAuthenticationType.OnPremises)
                        {
                            var tempCred = CredentialManager.GetCredential(testConfiguration.TestAuthentication.CredentialManagerLabel);
                            if (tempCred.UserName.IndexOf("\\") > 0)
                            {
                                string[] userParts = tempCred.UserName.Split('\\');
                                credentials = new System.Net.NetworkCredential(userParts[1], tempCred.SecurePassword, userParts[0]);
                            }
                            else
                            {
                                throw new ArgumentException(String.Format("Username {0} stored in credential manager value {1} needs to be formatted as domain\\user", tempCred.UserName, testConfiguration.TestAuthentication.CredentialManagerLabel));
                            }
                        }
                        else
                        {
                            credentials = CredentialManager.GetSharePointOnlineCredential(testConfiguration.TestAuthentication.CredentialManagerLabel);
                        }

                        using (ClientContext ctx = new ClientContext(testConfiguration.TestSiteUrl))
                        {
                            ctx.Credentials = credentials;
                            ctx.Load(ctx.Web, w => w.Title);
                            ctx.ExecuteQueryRetry();
                            build = ctx.ServerLibraryVersion.ToString();
                        }
                    }
                    else
                    {
                        if (testConfiguration.TestAuthentication.Type == TestAuthenticationType.Online)
                        {
                            using (ClientContext ctx = am.GetSharePointOnlineAuthenticatedContextTenant(testConfiguration.TestSiteUrl, testConfiguration.TestAuthentication.User, testConfiguration.TestAuthentication.Password))
                            {
                                ctx.Load(ctx.Web, w => w.Title);
                                ctx.ExecuteQueryRetry();
                                build = ctx.ServerLibraryVersion.ToString();
                            }
                        }
                        else
                        {
                            using (ClientContext ctx = am.GetNetworkCredentialAuthenticatedContext(testConfiguration.TestSiteUrl, testConfiguration.TestAuthentication.User, testConfiguration.TestAuthentication.Password, testConfiguration.TestAuthentication.Domain))
                            {
                                ctx.Load(ctx.Web, w => w.Title);
                                ctx.ExecuteQueryRetry();
                                build = ctx.ServerLibraryVersion.ToString();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: Most likely something is wrong with the provided credentials (username+pwd, appid+secret, credential manager setting) causing the below error:");
                Console.WriteLine(ex.ToString());
                //throw;
            }

            return(build);
        }
 public void UploadFile(string sourceFileName, System.Uri address, System.Net.ICredentials networkCredentials, bool showUI, int connectionTimeout, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel)
 {
 }