Example #1
0
 /// <summary>
 /// Downloads provider update info
 /// </summary>
 public static ProviderUpdateInfo DownloadProviderUpdateInfo(ProviderInfo provider)
 {
     if (provider != null)
     {
         ProviderUpdateInfo info = (ProviderUpdateInfo)Updaters.DownloadUpdateInfo(typeof(ProviderUpdateInfo), provider.UpdateInfoUrl);
         return info;
     }
     return null;
 }
Example #2
0
 public string getDOCName(ProviderInfo pInfo)
 {
     SqlConnection con = new SqlConnection(ConStr);
     SqlCommand sqlCmd = new SqlCommand("select Doc_FullName from Doctor_Info where Status<>'N' and Doc_ID = '" + pInfo.Prov_ID + "'", con);
     // SqlDataReader sqlDr;
     // DataTable dtable = new DataTable();
     // DataRow dr;
     con.Open();
     string DOC_Name = sqlCmd.ExecuteScalar().ToString();
     con.Close();
     return DOC_Name;
 }
Example #3
0
 public int getDOCID(ProviderInfo pInfo)
 {
     SqlConnection con = new SqlConnection(ConStr);
     SqlCommand sqlCmd = new SqlCommand("select Doc_ID from Doctor_Info where Status<>'N' and Doc_FullName = '" + pInfo.FullName + "'", con);
     // SqlDataReader sqlDr;
     // DataTable dtable = new DataTable();
     // DataRow dr;
     con.Open();
     int DOCID = Convert.ToInt32(sqlCmd.ExecuteScalar());
     con.Close();
     return DOCID;
 }
        public IProvider GetOrCreateProvider(
            StandardSingletonDeclaration dec, Func<DiContainer, Type, IProvider> providerCreator)
        {
            // These ones are actually fine when used with Bind<GameObject>() (see TypeBinderBase.ToPrefabSelf)
            //Assert.IsNotEqual(dec.Type, SingletonTypes.ToPrefab);
            //Assert.IsNotEqual(dec.Type, SingletonTypes.ToPrefabResource);

            Assert.IsNotEqual(dec.Type, SingletonTypes.ToSubContainerInstaller);
            Assert.IsNotEqual(dec.Type, SingletonTypes.ToSubContainerMethod);
            Assert.IsNotEqual(dec.Type, SingletonTypes.ToSubContainerPrefab);
            Assert.IsNotEqual(dec.Type, SingletonTypes.ToSubContainerPrefabResource);

            _markRegistry.MarkSingleton(dec.Id, dec.Type);

            ProviderInfo providerInfo;

            if (_providerMap.TryGetValue(dec.Id, out providerInfo))
            {
                Assert.That(providerInfo.Type == dec.Type,
                    "Cannot use both '{0}' and '{1}' for the same dec.Type/ConcreteIdentifier!", providerInfo.Type, dec.Type);

                Assert.That(providerInfo.Arguments.Count == dec.Arguments.Count,
                    "Invalid use of binding '{0}'.  Ambiguous set of creation properties found (argument length mismatch)", dec.Type);

                foreach (var pair in providerInfo.Arguments.Zipper(dec.Arguments))
                {
                    var arg1 = pair.First;
                    var arg2 = pair.Second;

                    Assert.That(arg1.Type == arg2.Type && object.Equals(arg1.Value, arg2.Value),
                        "Invalid use of binding '{0}'.  Ambiguous set of creation properties found (argument value mismatch)", dec.Type);
                }

                Assert.That(object.Equals(providerInfo.SingletonSpecificId, dec.SpecificId),
                    "Invalid use of binding '{0}'.  Found ambiguous set of creation properties.", dec.Type);
            }
            else
            {
                providerInfo = new ProviderInfo(
                    dec.Type,
                    new CachedProvider(
                        providerCreator(_container, dec.Id.ConcreteType)),
                    dec.SpecificId,
                    dec.Arguments);

                _providerMap.Add(dec.Id, providerInfo);
            }

            return providerInfo.Provider;
        }
Example #5
0
    // Newly Added
    public string Delete_ProvFacility(ProviderInfo Pro_FaclityDet)
    {
        SqlConnection sqlCon = new SqlConnection(ConStr);
        SqlCommand sqlCmd = new SqlCommand("sp_Delete_ProviderFacilities", sqlCon);
        sqlCmd.CommandType = CommandType.StoredProcedure;
        sqlCmd.Connection = sqlCon;

        string msg="";

        SqlParameter Doc_Id = sqlCmd.Parameters.Add("@Doc_Id", SqlDbType.Int);
        if (Pro_FaclityDet.Doc_Id != null)
            Doc_Id.Value = Pro_FaclityDet.Doc_Id;
        else
            Doc_Id.Value = Convert.DBNull;

        SqlParameter Fac_Id = sqlCmd.Parameters.Add("@Fac_Id", SqlDbType.Int);
        if (Pro_FaclityDet.Fac_Id != null)
            Fac_Id.Value = Pro_FaclityDet.Fac_Id;
        else
            Fac_Id.Value = Convert.DBNull;

        try
        {
            sqlCon.Open();
            sqlCmd.ExecuteNonQuery();
            msg = "Deleted Provider Facility Information Successfully";
        }
        catch (SqlException SqlEx)
        {
            objNLog.Error("SQLException : " + SqlEx.Message);
            throw new Exception("Exception re-Raised from DL with SQLError# " + SqlEx.Number + " while Deleting Provider Facility Info.", SqlEx);
        }
        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);
            throw new Exception("**Error occured while Deleting Provider Facility Info.", ex);
        }
        finally
        {
            sqlCon.Close();
        }

        return msg;
    }
Example #6
0
 public Folder <string> GetRootFolder(string folderId)
 {
     return(ProviderInfo.ToFolder(ProviderInfo.RootFolder));
 }
Example #7
0
 public bool IsEmpty(string folderId)
 {
     return(ProviderInfo.GetFolderById(folderId).ItemCount == 0);
 }
Example #8
0
 public bool IsExist(string title, Microsoft.SharePoint.Client.Folder folder)
 {
     return(ProviderInfo.GetFolderFolders(folder.ServerRelativeUrl)
            .Any(item => item.Name.Equals(title, StringComparison.InvariantCultureIgnoreCase)));
 }
Example #9
0
 public DataTable getProviderSearch(ProviderInfo ProvInfo)
 {
     SqlConnection con = new SqlConnection(ConStr);
     SqlCommand sqlCmd = new SqlCommand("select * from Doctor_Info where Doc_FName ='" + ProvInfo.FirstName + "' and Doc_LName = '" + ProvInfo.LastName + "'", con);
     SqlDataReader sqlDr;
     DataTable dtable = new DataTable();
     // DataRow dr;
     con.Open();
     sqlDr = sqlCmd.ExecuteReader();
     dtable.Load(sqlDr);
     con.Close();
     return dtable;
 }
Example #10
0
 internal ProviderInfo Start(ProviderInfo providerInfo, ProviderRuntime providerRuntime)
 {
     ProviderRuntime = providerRuntime;
     return Start(providerInfo);
 }
Example #11
0
 public DataProviderHelper()
 {
     _providerInfo = new ProviderInfo();
     SetDefaultProperties();
     List<string> reservedWords = new List<string>();
     for (int t = Token._RS_START + 1; t < Token._RS_END; t++)
         _providerInfo.keywords.Add(YYParser.yyname(t).ToUpper(), 0);
 }
Example #12
0
        } // ClearContentDynamicParameters


        #endregion IContentCmdletProvider method wrappers

        #endregion internal members

        #region protected members

        /// <summary>
        /// Gives the provider the opportunity to initialize itself.
        /// </summary>
        /// 
        /// <param name="providerInfo">
        /// The information about the provider that is being started.
        /// </param>
        /// 
        /// <remarks>
        /// The default implementation returns the ProviderInfo instance that
        /// was passed.
        /// 
        /// To have session state maintain persisted data on behalf of the provider,
        /// the provider should derive from <see cref="System.Management.Automation.ProviderInfo"/>
        /// and add any properties or
        /// methods for the data it wishes to persist.  When Start gets called the
        /// provider should construct an instance of its derived ProviderInfo using the
        /// providerInfo that is passed in and return that new instance.
        /// </remarks>
        protected virtual ProviderInfo Start(ProviderInfo providerInfo)
        {
            using (PSTransactionManager.GetEngineProtectionScope())
            {
                return providerInfo;
            }
        }
 public AzureDriveInfo(string name, ProviderInfo provider, string root, string description, PSCredential credential)
     : base(name, provider, root, description, credential)
 {
     Init(provider, root, credential);
 }
Example #14
0
 public File <string> GetFile(string parentId, string title)
 {
     return(ProviderInfo.ToFile(ProviderInfo.GetFolderFiles(parentId).FirstOrDefault(item => item.Name.Equals(title, StringComparison.InvariantCultureIgnoreCase))));
 }
Example #15
0
    public string Delete_Provider(ProviderInfo ProvInfo,string userID)
    {
        string msg = "";
        SqlConnection sqlCon = new SqlConnection(ConStr);

        SqlCommand sqlCmd = new SqlCommand("sp_delete_Provider_Details", sqlCon);
        sqlCmd.CommandType = CommandType.StoredProcedure;

        SqlParameter P_ID = sqlCmd.Parameters.Add("@Prov_ID", SqlDbType.Int);
        P_ID.Value = ProvInfo.Prov_ID;

        SqlParameter pUserID = sqlCmd.Parameters.Add("@UserID", SqlDbType.VarChar, 20);
        pUserID.Value = userID;

        try
        {
            sqlCon.Open();
            sqlCmd.ExecuteNonQuery();
            msg = "Deleted Provider Information Successfully";
        }
        catch (SqlException SqlEx)
        {
            objNLog.Error("SQLException : " + SqlEx.Message);
            throw new Exception("Exception re-Raised from DL with SQLError# " + SqlEx.Number + " while Deleting Provider Info.", SqlEx);
        }
        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);
            throw new Exception("**Error occured while Deleting Provider Info.", ex);
        }
        finally
        {
            sqlCon.Close();
        }

        return msg;
    }
Example #16
0
    public string Update_Provider(ProviderInfo ProvInfo, Clinic clinic,string userID)
    {
        string msg = "";
        SqlConnection sqlCon = new SqlConnection(ConStr);
        SqlCommand sqlCmd = new SqlCommand("sp_update_Provider_Details", sqlCon);
        sqlCmd.CommandType = CommandType.StoredProcedure;

        SqlParameter P_ID = sqlCmd.Parameters.Add("@Prov_ID", SqlDbType.Int);
        P_ID.Value = ProvInfo.Prov_ID;

        SqlParameter P_MName = sqlCmd.Parameters.Add("@Prov_MName", SqlDbType.VarChar, 2);
        if (ProvInfo.MiddleName != null)
            P_MName.Value = ProvInfo.MiddleName;
        else
            P_MName.Value = Convert.DBNull;

        SqlParameter P_Spec = sqlCmd.Parameters.Add("@Prov_Speciality", SqlDbType.VarChar, 25);
        if (ProvInfo.Speciality != null)
            P_Spec.Value = ProvInfo.Speciality;
        else
            P_Spec.Value = Convert.DBNull;

        SqlParameter P_Degree = sqlCmd.Parameters.Add("@Prov_Degree", SqlDbType.VarChar, 50);
        if (ProvInfo.Degree != null)
            P_Degree.Value = ProvInfo.Degree;
        else
            P_Degree.Value = Convert.DBNull;
        SqlParameter P_DeaNo = sqlCmd.Parameters.Add("@Prov_DeaNo", SqlDbType.VarChar, 50);
        if (ProvInfo.DeaNumber != null)
            P_DeaNo.Value = ProvInfo.DeaNumber;
        else
            P_DeaNo.Value = Convert.DBNull;

        SqlParameter P_Location = sqlCmd.Parameters.Add("@Prov_Location", SqlDbType.VarChar, 50);
        if (ProvInfo.Location != null)
            P_Location.Value = ProvInfo.Location;
        else
            P_Location.Value = Convert.DBNull;

        SqlParameter P_Address1 = sqlCmd.Parameters.Add("@Prov_Address1", SqlDbType.VarChar, 50);
        if (ProvInfo.Address1 != null)
            P_Address1.Value = ProvInfo.Address1;
        else
            P_Address1.Value = Convert.DBNull;

        SqlParameter P_Address2 = sqlCmd.Parameters.Add("@Prov_Address2", SqlDbType.VarChar, 50);
        if (ProvInfo.Address2 != null)
            P_Address2.Value = ProvInfo.Address2;
        else
            P_Address2.Value = Convert.DBNull;

        SqlParameter P_City = sqlCmd.Parameters.Add("@Prov_City", SqlDbType.VarChar, 50);
        if (ProvInfo.City != null)
            P_City.Value = ProvInfo.City;
        else
            P_City.Value = Convert.DBNull;

        SqlParameter P_State = sqlCmd.Parameters.Add("@Prov_State", SqlDbType.VarChar, 50);
        if (ProvInfo.State != null)
            P_State.Value = ProvInfo.State;
        else
            P_State.Value = Convert.DBNull;
        SqlParameter P_ZIP = sqlCmd.Parameters.Add("@Prov_Zip", SqlDbType.VarChar, 50);
        if (ProvInfo.Zip != null)
            P_ZIP.Value = ProvInfo.Zip;
        else
            P_ZIP.Value = Convert.DBNull;

        SqlParameter P_HPhone = sqlCmd.Parameters.Add("@Prov_HPhone", SqlDbType.VarChar, 50);
        if (ProvInfo.HPhone != null)
            P_HPhone.Value = ProvInfo.HPhone;
        else
            P_HPhone.Value = Convert.DBNull;

        SqlParameter P_CPhone = sqlCmd.Parameters.Add("@Prov_CPhone", SqlDbType.VarChar, 50);
        if (ProvInfo.CPhone != null)
            P_CPhone.Value = ProvInfo.CPhone;
        else
            P_CPhone.Value = Convert.DBNull;
        SqlParameter P_EMail = sqlCmd.Parameters.Add("@Prov_EMail", SqlDbType.VarChar, 50);
        if (ProvInfo.EMail != null)
            P_EMail.Value = ProvInfo.EMail;
        else
            P_EMail.Value = Convert.DBNull;

        SqlParameter P_Fax = sqlCmd.Parameters.Add("@Prov_Fax", SqlDbType.VarChar, 50);
        if (ProvInfo.Fax != null)
            P_Fax.Value = ProvInfo.Fax;
        else
            P_Fax.Value = Convert.DBNull;

        SqlParameter P_LICNo = sqlCmd.Parameters.Add("@Prov_LICNo", SqlDbType.VarChar, 50);
        if (ProvInfo.LicNo != null)
            P_LICNo.Value = ProvInfo.LicNo;
        else
            P_LICNo.Value = Convert.DBNull;

        SqlParameter P_Status = sqlCmd.Parameters.Add("@Prov_Status", SqlDbType.VarChar, 50);
        if (ProvInfo.Status != null)
            P_Status.Value = ProvInfo.Status;
        else
            P_Status.Value = Convert.DBNull;

        SqlParameter ClinicID = sqlCmd.Parameters.Add("@ClinicID", SqlDbType.Int);
        if (clinic.ClinicID != null)
            ClinicID.Value = clinic.ClinicID;
        else
            ClinicID.Value = Convert.DBNull;

        SqlParameter P_NPI = sqlCmd.Parameters.Add("@Prov_NPI", SqlDbType.VarChar, 50);
        if (ProvInfo.NPI != null)
            P_NPI.Value = ProvInfo.NPI;
        else
            P_NPI.Value = Convert.DBNull;

        SqlParameter P_Sign = sqlCmd.Parameters.Add("@Prov_Sign", SqlDbType.Image);
        if (ProvInfo.Signature != null)
            P_Sign.Value = ProvInfo.Signature;
        else
            P_Sign.Value = Convert.DBNull;

        SqlParameter P_Type = sqlCmd.Parameters.Add("@Prov_Type", SqlDbType.Char);
        P_Type.Value = ProvInfo.UserType;

         SqlParameter pUserID = sqlCmd.Parameters.Add("@UserID", SqlDbType.VarChar,20);
         pUserID.Value =userID;

        try
        {
            sqlCon.Open();
            sqlCmd.ExecuteNonQuery();
            msg = "Updated Provider Information Successfully";
        }
        catch (SqlException SqlEx)
        {
            objNLog.Error("SQLException : " + SqlEx.Message);
            throw new Exception("Exception re-Raised from DL with SQLError# " + SqlEx.Number + " while Updaing Provider Info.", SqlEx);
        }
        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);
            throw new Exception("**Error occured while Updaing Provider Info.", ex);
        }
        finally
        {
            sqlCon.Close();
        }

        return msg;
    }
Example #17
0
    public string Update_ProvFacility(ProviderInfo Prov_FaclityInfo, DateTime LastUTime, string Admin_User)
    {
        string msg="";
        SqlConnection sqlCon = new SqlConnection(ConStr);
        SqlCommand sqlCmd = new SqlCommand("sp_Update_ProviderFacilities", sqlCon);
        sqlCmd.CommandType = CommandType.StoredProcedure;
        sqlCmd.Connection = sqlCon;

        SqlParameter Doc_Id = sqlCmd.Parameters.Add("@Doc_Id", SqlDbType.Int);
        if (Prov_FaclityInfo.Doc_Id != null)
            Doc_Id.Value = Prov_FaclityInfo.Doc_Id;
        else
            Doc_Id.Value = Convert.DBNull;

        SqlParameter Fac_Id = sqlCmd.Parameters.Add("@Fac_Id", SqlDbType.Int);
        if (Prov_FaclityInfo.Fac_Id != null)
            Fac_Id.Value = Prov_FaclityInfo.Fac_Id;
        else
            Fac_Id.Value = Convert.DBNull;

        SqlParameter Doc_WPNo = sqlCmd.Parameters.Add("@Doc_WPNo", SqlDbType.VarChar, 25);
        if (Prov_FaclityInfo.WPhone != null)
            Doc_WPNo.Value = Prov_FaclityInfo.WPhone;
        else
            Doc_WPNo.Value = Convert.DBNull;

        SqlParameter Doc_Mail = sqlCmd.Parameters.Add("@Doc_Mail", SqlDbType.VarChar, 50);
        if (Prov_FaclityInfo.EMail != null)
            Doc_Mail.Value = Prov_FaclityInfo.EMail;
        else
            Doc_Mail.Value = Convert.DBNull;

        SqlParameter Doc_Fax = sqlCmd.Parameters.Add("@Doc_Fax", SqlDbType.VarChar, 25);
        if (Prov_FaclityInfo.Fax != null)
            Doc_Fax.Value = Prov_FaclityInfo.Fax;
        else
            Doc_Fax.Value = Convert.DBNull;

        SqlParameter Doc_NPINo = sqlCmd.Parameters.Add("@Doc_NPINo", SqlDbType.VarChar, 15);
        if (Prov_FaclityInfo.NPI != null)
            Doc_NPINo.Value = Prov_FaclityInfo.NPI;
        else
            Doc_NPINo.Value = Convert.DBNull;

        SqlParameter Doc_LICNo = sqlCmd.Parameters.Add("@Doc_LICNo", SqlDbType.VarChar, 25);
        if (Prov_FaclityInfo.LicNo != null)
            Doc_LICNo.Value = Prov_FaclityInfo.LicNo;
        else
            Doc_LICNo.Value = Convert.DBNull;

        SqlParameter Doc_DEANo = sqlCmd.Parameters.Add("@Doc_DEANo", SqlDbType.VarChar, 25);
        if (Prov_FaclityInfo.DeaNumber != null)
            Doc_DEANo.Value = Prov_FaclityInfo.DeaNumber;
        else
            Doc_DEANo.Value = Convert.DBNull;

        SqlParameter Stat = sqlCmd.Parameters.Add("@Stat", SqlDbType.VarChar, 50);
        if (Prov_FaclityInfo.Status != null)
            Stat.Value = Prov_FaclityInfo.Status;
        else
            Stat.Value = Convert.DBNull;

        SqlParameter LUT = sqlCmd.Parameters.Add("@lastUpdateTime", SqlDbType.DateTime2, 7);
        LUT.Value = LastUTime;

        SqlParameter LModBy = sqlCmd.Parameters.Add("@LastModTimeBy", SqlDbType.VarChar, 50);
        LModBy.Value = Admin_User;

        try
        {
            sqlCon.Open();
            sqlCmd.ExecuteNonQuery();
            msg = "Successfully Updated";
        }
        catch (SqlException SqlEx)
        {
            objNLog.Error("SQLException : " + SqlEx.Message);
            throw new Exception("Exception re-Raised from DL with SQLError# " + SqlEx.Number + " while Updating Provider Facility.", SqlEx);
        }
        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);
            throw new Exception("**Error occured while Updating Provider Facility.", ex);
        }
        finally
        {
            sqlCon.Close();
        }
        return msg;
    }
Example #18
0
        /// <summary>
        /// The expression will be executed in the remote computer if a
        /// remote runspace parameter or computer name is specified. If
        /// none other than command parameter is specified, then it
        /// just executes the command locally without creating a new
        /// remote runspace object.
        /// </summary>
        protected override void ProcessRecord()
        {
            if (ParameterSetName == DefinitionNameParameterSet)
            {
                // Get the Job2 object from the Job Manager for this definition name and start the job.
                string resolvedPath = null;
                if (!string.IsNullOrEmpty(_definitionPath))
                {
                    ProviderInfo provider = null;
                    System.Collections.ObjectModel.Collection <string> paths =
                        this.Context.SessionState.Path.GetResolvedProviderPathFromPSPath(_definitionPath, out provider);

                    // Only file system paths are allowed.
                    if (!provider.NameEquals(this.Context.ProviderNames.FileSystem))
                    {
                        string message = StringUtil.Format(RemotingErrorIdStrings.StartJobDefinitionPathInvalidNotFSProvider,
                                                           _definitionName,
                                                           _definitionPath,
                                                           provider.FullName);
                        WriteError(new ErrorRecord(new RuntimeException(message), "StartJobFromDefinitionNamePathInvalidNotFileSystemProvider",
                                                   ErrorCategory.InvalidArgument, null));

                        return;
                    }

                    // Only a single file path is allowed.
                    if (paths.Count != 1)
                    {
                        string message = StringUtil.Format(RemotingErrorIdStrings.StartJobDefinitionPathInvalidNotSingle,
                                                           _definitionName,
                                                           _definitionPath);
                        WriteError(new ErrorRecord(new RuntimeException(message), "StartJobFromDefinitionNamePathInvalidNotSingle",
                                                   ErrorCategory.InvalidArgument, null));

                        return;
                    }

                    resolvedPath = paths[0];
                }

                List <Job2> jobs = JobManager.GetJobToStart(_definitionName, resolvedPath, _definitionType, this, false);

                if (jobs.Count == 0)
                {
                    string message = (_definitionType != null) ?
                                     StringUtil.Format(RemotingErrorIdStrings.StartJobDefinitionNotFound2, _definitionType, _definitionName) :
                                     StringUtil.Format(RemotingErrorIdStrings.StartJobDefinitionNotFound1, _definitionName);

                    WriteError(new ErrorRecord(new RuntimeException(message), "StartJobFromDefinitionNameNotFound",
                                               ErrorCategory.ObjectNotFound, null));

                    return;
                }

                if (jobs.Count > 1)
                {
                    string message = StringUtil.Format(RemotingErrorIdStrings.StartJobManyDefNameMatches, _definitionName);
                    WriteError(new ErrorRecord(new RuntimeException(message), "StartJobFromDefinitionNameMoreThanOneMatch",
                                               ErrorCategory.InvalidResult, null));

                    return;
                }

                // Start job.
                Job2 job = jobs[0];
                job.StartJob();

                // Write job object to host.
                WriteObject(job);

                return;
            }

            if (_firstProcessRecord)
            {
                _firstProcessRecord = false;

                PSRemotingJob job = new PSRemotingJob(ResolvedComputerNames, Operations,
                                                      ScriptBlock.ToString(), ThrottleLimit, _name);

                job.PSJobTypeName = s_startJobType;

                this.JobRepository.Add(job);
                WriteObject(job);
            }

            // inject input
            if (InputObject != AutomationNull.Value)
            {
                foreach (IThrottleOperation operation in Operations)
                {
                    ExecutionCmdletHelper helper = (ExecutionCmdletHelper)operation;
                    helper.Pipeline.Input.Write(InputObject);
                }
            }
        }
        /*
         * public static string SetRoot(string root, PSCredential credential) {
         *  if (credential != null && credential.UserName.Contains(" "))
         *  {
         *      var sasUsernamePieces = credential.UserName.Split(' ');
         *      if (sasUsernamePieces.Length != 2)
         *      {
         *          throw new ClrPlusException("Wrong number of SASUsername pieces, should be 2");
         *
         *      }
         *
         *      if (!sasUsernamePieces[1].IsWebUri())
         *          throw new ClrPlusException("Second part of SASUsername must be a valid Azure Uri");
         *
         *      var containerUri = new Uri(sasUsernamePieces[1]);
         *
         *      //TODO Do I actually need to flip the slashes here? I'll do it to be safe for now
         *      root = @"azure:\\{0}\{1}".format(sasUsernamePieces[0], containerUri.AbsolutePath.Replace('/', '\\'));
         *
         *      SasAccountUri = "https://" + containerUri.Host;
         *      SasContainer = containerUri.AbsolutePath;
         *
         *
         *
         *
         *      //it's a SASToken!
         *  }
         *
         *  return root;
         * }*/

        private void Init(ProviderInfo provider, string root, PSCredential credential)
        {
            // first, try to get the account from the credential
            // if that fails, attempt to get it from the root.
            // http://account.blob.core.windows.net ... guess the account, have the base uri
            // https://account.blob.core.windows.net ... guess the account, have the base uri

            // azure://coapp ... -> guess the account, generate the baseuri

            // http://downloads.coapp.org  user must supply account, have the base uri
            // https://downloads.coapp.org user must supply account, have the base uri
            // http://127.0.0.1:10000/     user must supply account, have the base uri

            var parsedPath = Path.ParseWithContainer(root);


            //check if Credential is Sas


            if (credential != null && credential.UserName != null && credential.Password != null)
            {
                if (credential.UserName.Contains(SAS_GUID))
                {
                    _accountName = credential.UserName.Split(new[] {
                        SAS_GUID
                    }, StringSplitOptions.RemoveEmptyEntries)[0];
                    _isSas = true;
                }
                else
                {
                    _accountName = credential.UserName;
                }



                if (parsedPath.Scheme == ProviderScheme)
                {
                    // generate the baseuri like they do
                    _baseUri = new Uri("https://{0}.blob.core.windows.net/".format(_accountName));
                }
                else
                {
                    _baseUri = new Uri("{0}://{1}/".format(parsedPath.Scheme, parsedPath.HostAndPort));
                }

                Secret = credential.Password.ToUnsecureString();
            }
            else
            {
                if (parsedPath.Scheme == ProviderScheme)
                {
                    _accountName = parsedPath.HostName;
                    _baseUri     = new Uri("https://{0}.blob.core.windows.net/".format(_accountName));
                }
                else if (parsedPath.HostName.ToLower().EndsWith(".blob.core.windows.net"))
                {
                    _accountName = parsedPath.HostName.Substring(0, parsedPath.HostName.IndexOf('.'));
                    _baseUri     = new Uri("{0}://{1}/".format(parsedPath.Scheme, parsedPath.HostAndPort));
                }
                else
                {
                    // throw xxx
                }
            }

            Path = parsedPath;



            if (string.IsNullOrEmpty(parsedPath.HostAndPort) || string.IsNullOrEmpty(parsedPath.Scheme))
            {
                Path = parsedPath;
                return; // this is the root azure namespace.
            }

            var pi = provider as AzureProviderInfo;

            if (pi == null)
            {
                throw new ClrPlusException("Invalid ProviderInfo");
            }


            var alldrives = (pi.AddingDrives.Union(pi.Drives)).Select(each => each as AzureDriveInfo).ToArray();

            if (parsedPath.Scheme == ProviderScheme)
            {
                // it's being passed a full url to a blob storage
                Path = parsedPath;

                if (credential == null || credential.Password == null)
                {
                    // look for another mount off the same account and container for the credential
                    foreach (var d in alldrives.Where(d => d.HostAndPort == HostAndPort && d.ContainerName == ContainerName))
                    {
                        Secret = d.Secret;
                        return;
                    }
                    // now look for another mount off just the same account for the credential
                    foreach (var d in alldrives.Where(d => d.HostAndPort == HostAndPort))
                    {
                        Secret = d.Secret;
                        return;
                    }
                    throw new ClrPlusException("Missing credential information for {0} mount '{1}'".format(ProviderScheme, root));
                }

                Secret = credential.Password.ToUnsecureString();
                return;
            }

            // otherwise, it's an sub-folder off of another mount.
            foreach (var d in alldrives.Where(d => d.Name == parsedPath.Scheme))
            {
                Path = new Path {
                    HostAndPort = d.HostAndPort,
                    Container   = string.IsNullOrEmpty(d.ContainerName) ? parsedPath.HostAndPort : d.ContainerName,
                    SubPath     = string.IsNullOrEmpty(d.RootPath) ? parsedPath.SubPath : d.RootPath + '\\' + parsedPath.SubPath
                };
                Path.Validate();
                Secret = d.Secret;
                return;
            }
        }
Example #20
0
        public static object CreateProvider(ProviderInfo providerInfo)
        {
            object provider = null;
            ObjectHandle handle;
            string name = providerInfo.Name;
            string assemblyName = providerInfo.Assembly;
            string className = providerInfo.Class;

            try
            {
                switch (providerInfo.Type)
                {
                    case StoreProviderType.Address:
                        handle = Activator.CreateInstance(assemblyName, className);
                        provider = (Address.IAddressProvider)handle.Unwrap();
                        (provider as Address.IAddressProvider).Info = providerInfo;
                        break;

                    case StoreProviderType.Catalog:
                        throw new NotImplementedException("The 'Catalog' provider type has not been implemented.");
                        //break;

                    case StoreProviderType.Fulfillment:
                        throw new NotImplementedException("The 'Fulfillment' provider type has not been implemented.");
                        //break;

                    case StoreProviderType.Payment:
                        throw new NotImplementedException("The 'Payment' provider type has not been implemented.");
                        //break;

                    case StoreProviderType.Promotion:
                        throw new NotImplementedException("The 'Promotion' provider type has not been implemented.");
                        //break;

                    case StoreProviderType.Shipping:
                        handle = Activator.CreateInstance(assemblyName, className);
                        provider = (Shipping.IShippingProvider)handle.Unwrap();
                        (provider as Shipping.IShippingProvider).Info = providerInfo;
                        break;

                    case StoreProviderType.Subscription:
                        throw new NotImplementedException("The 'Subscription' provider type has not been implemented.");
                        //break;

                    case StoreProviderType.Tax:
                        handle = Activator.CreateInstance(assemblyName, className);
                        provider = (Tax.ITaxProvider)handle.Unwrap();
                        (provider as Tax.ITaxProvider).Info = providerInfo;
                        break;

                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("An error ocurred while creating the '" + name + "' " + Enum.GetName(typeof(StoreProviderType), providerInfo.Type) + " provider.", ex);
            }

            return provider;
        }
        public IEnumerable <Tag> GetNewTags(Guid subject, Folder parentFolder, bool deepSearch)
        {
            using (var dbManager = DbManager.FromHttpContext(FileConstant.DatabaseId))
            {
                var folderId = SharePointDaoSelector.ConvertId(parentFolder.ID);

                var fakeFolderId = parentFolder.ID.ToString();

                var entryIDs = dbManager.ExecuteList(Query("files_thirdparty_id_mapping")
                                                     .Select("hash_id")
                                                     .Where(Exp.Like("id", fakeFolderId, SqlLike.StartWith)))
                               .ConvertAll(x => x[0]);

                if (!entryIDs.Any())
                {
                    return(new List <Tag>());
                }

                var sqlQuery = new SqlQuery("files_tag ft")
                               .Select("ft.name",
                                       "ft.flag",
                                       "ft.owner",
                                       "ftl.entry_id",
                                       "ftl.entry_type",
                                       "ftl.tag_count",
                                       "ft.id")
                               .Distinct()
                               .LeftOuterJoin("files_tag_link ftl",
                                              Exp.EqColumns("ft.tenant_id", "ftl.tenant_id") &
                                              Exp.EqColumns("ft.id", "ftl.tag_id"))
                               .Where(Exp.Eq("ft.tenant_id", TenantID) &
                                      Exp.Eq("ftl.tenant_id", TenantID) &
                                      Exp.Eq("ft.flag", (int)TagType.New) &
                                      Exp.In("ftl.entry_id", entryIDs));

                if (subject != Guid.Empty)
                {
                    sqlQuery.Where(Exp.Eq("ft.owner", subject));
                }

                var tags = dbManager.ExecuteList(sqlQuery).ConvertAll(r => new Tag
                {
                    TagName   = Convert.ToString(r[0]),
                    TagType   = (TagType)r[1],
                    Owner     = new Guid(r[2].ToString()),
                    EntryId   = MappingID(r[3]),
                    EntryType = (FileEntryType)r[4],
                    Count     = Convert.ToInt32(r[5]),
                    Id        = Convert.ToInt32(r[6])
                });

                if (deepSearch)
                {
                    return(tags);
                }

                var folderFileIds = new[] { fakeFolderId }
                .Concat(ProviderInfo.GetFolderFolders(folderId).Select(x => ProviderInfo.MakeId(x.ServerRelativeUrl)))
                .Concat(ProviderInfo.GetFolderFiles(folderId).Select(x => ProviderInfo.MakeId(x.ServerRelativeUrl)));

                return(tags.Where(tag => folderFileIds.Contains(tag.EntryId.ToString())));
            }
        }
Example #22
0
        ProviderInfo getProviderInfo(string providerPath)
        {
            ProviderInfo providerInfo = new ProviderInfo();

            string providerName = getTrailingFolder(providerPath);
            string infoFile = providerPath + "\\" + providerName + "Info.xml";

            if (!providerPath.EndsWith("\\")) providerPath += "\\";

            if (Directory.Exists(providerPath))
            {
                if (File.Exists(infoFile))
                {
                    try
                    {
                        Stream infoDoc = File.Open(infoFile, FileMode.Open, FileAccess.Read, FileShare.Read);
                        XmlSerializer serializer = new XmlSerializer(typeof(ProviderInfo));

                        providerInfo = (ProviderInfo)serializer.Deserialize(infoDoc);

                        infoDoc.Close();

                        if (providerInfo.Controls == null || providerInfo.Controls.Length < 1)
                        {
                            throw new ApplicationException("No controls are defined in '" + providerPath + "ProviderInfo.xml'.");
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("An error ocurred while reading '" + providerPath + "ProviderInfo.xml'.", ex);
                    }
                }
                else
                {
                    throw new FileNotFoundException("No ProviderInfo.xml file was found in '" + providerPath + "'.");
                }
            }
            else
            {
                throw new DirectoryNotFoundException("The provider path '" + providerPath + "' does not exist.");
            }

            return providerInfo;
        }
        public override Object Transform(EngineIntrinsics engineIntrinsics, Object input)
        {
            List <String> transformedPaths = new List <String>();
            bool          useResolvedPath  = !Literal;

            if (input is ICollection)
            {
                foreach (Object inputPath in (ICollection)input)
                {
                    transformedPaths.AddRange((ICollection <String>)Transform(engineIntrinsics, inputPath));
                }
            }
            else
            {
                IEnumerable <String> inputPaths = null;

                ProviderInfo provider = null;
                PSDriveInfo  drive;

                if (useResolvedPath)
                {
                    /* Expand wildcards, recurse */
                    try
                    {
                        inputPaths = engineIntrinsics.SessionState.Path.GetResolvedProviderPathFromPSPath(input.ToString(), out provider);
                    }
                    catch (ItemNotFoundException)
                    {
                        /*
                         * This will occur when a user specifies a path to a file that no longer exists.  We should try to
                         * use a literal path here to retry.  If the caller does not want to allow nonexistant paths, we
                         * will error below instead.
                         */

                        useResolvedPath = false; /* retry below */
                    }
                }

                if (!useResolvedPath)
                {
                    inputPaths = new String[] {
                        engineIntrinsics.SessionState.Path.GetUnresolvedProviderPathFromPSPath(input.ToString(), out provider, out drive)
                    };
                }

                Debug.Assert(provider != null);
                Debug.Assert(inputPaths != null);

                if (provider == null || inputPaths == null)
                {
                    throw new Exception("Invalid path transformation");
                }

                if (provider.ImplementingType != typeof(FileSystemProvider))
                {
                    throw new ArgumentException(String.Format("Files must be located on the filesystem, they cannot be provided by {0}", provider.ImplementingType.Name));
                }

                foreach (String inputPath in inputPaths)
                {
                    if (Directory.Exists(inputPath) && Recursive)
                    {
                        transformedPaths.AddRange(FileSystemUtil.GetFilesRecursive(inputPath));
                    }
                    else if (!File.Exists(inputPath) && MustExist)
                    {
                        throw new FileNotFoundException(String.Format("The file {0} does not exist", inputPath));
                    }
                    else
                    {
                        transformedPaths.Add(inputPath);
                    }
                }
            }

            return(transformedPaths);
        }
Example #24
0
	void DisplayProviderUpdate(ProviderUpdateInfo updateInfo, ProviderInfo installedInfo, bool installed, string message)
	{
		pgUpdateProvider.Visible = true;
		lblUpProviderName.Text = installedInfo.Name;
		lblUpProviderVersion.Text = installedInfo.Version;

		if (installed)
		{
			lblUpProviderStatus.Text = "Update was successful.";
			lblUpProviderStatus.ForeColor = Color.Green;
			btnUpProviderUpdate.Enabled = false;
		}
		else if (updateInfo == null)
		{
			lblUpProviderStatus.Text = "Unable to check for update.";
			lblUpProviderStatus.ForeColor = Color.Red;
			btnUpProviderUpdate.Enabled = false;
		}
		else
		{
			lblUpProviderName.Text = updateInfo.ProviderName;
			lblUpProviderVersion.Text = updateInfo.Version;
			if (Common.CompareASProxyVersions(updateInfo.Version, installedInfo.Version) == 1)
			{
				lblUpProviderStatus.Text = "Update is available.";
				lblUpProviderStatus.ForeColor = Color.Green;
				btnUpProviderUpdate.Enabled = true;
			}
			else
			{
				lblUpProviderStatus.Text = "Update is not available.";
				lblUpProviderStatus.ForeColor = Color.Red;
				btnUpProviderUpdate.Enabled = false;
			}
		}

		if (!string.IsNullOrEmpty(message))
			lblUpProviderStatus.Text = message;

	}
Example #25
0
 public Folder <string> GetRootFolderByFile(string fileId)
 {
     return(ProviderInfo.ToFolder(ProviderInfo.RootFolder));
 }
 public void DeleteFile(object fileId)
 {
     ProviderInfo.DeleteFile((string)fileId);
 }
Example #27
0
 // Newly Added
 public DataTable GetDoc_FacilityInfo(ProviderInfo Pro_Info)
 {
     SqlConnection con = new SqlConnection(ConStr);
     SqlDataAdapter da = new SqlDataAdapter("select * from Doctor_Facility_Info where Doc_Id="+Pro_Info.Doc_Id+" and Facility_ID="+Pro_Info.Fac_Id, con);
     DataSet ds = new DataSet();
     da.Fill(ds, "DocFac_Det");
     return ds.Tables["DocFac_Det"];
 }
        /// <summary>
        /// </summary>
        protected override void ProcessRecord()
        {
            ProviderInfo        provider = null;
            Collection <string> filePaths;

            try
            {
                if (this.Context.EngineSessionState.IsProviderLoaded(Context.ProviderNames.FileSystem))
                {
                    filePaths = SessionState.Path.GetResolvedProviderPathFromPSPath(_path, out provider);
                }
                else
                {
                    filePaths = new Collection <string>();
                    filePaths.Add(_path);
                }
            }
            catch (ItemNotFoundException)
            {
                string message            = StringUtil.Format(RemotingErrorIdStrings.PSSessionConfigurationFileNotFound, _path);
                FileNotFoundException fnf = new FileNotFoundException(message);
                ErrorRecord           er  = new ErrorRecord(fnf, "PSSessionConfigurationFileNotFound",
                                                            ErrorCategory.ResourceUnavailable, _path);
                WriteError(er);
                return;
            }

            // Make sure that the path is in the file system - that's all we can handle currently...
            if (!provider.NameEquals(this.Context.ProviderNames.FileSystem))
            {
                // "The current provider ({0}) cannot open a file"
                throw InterpreterError.NewInterpreterException(_path, typeof(RuntimeException),
                                                               null, "FileOpenError", ParserStrings.FileOpenError, provider.FullName);
            }

            // Make sure at least one file was found...
            if (filePaths == null || filePaths.Count < 1)
            {
                string message            = StringUtil.Format(RemotingErrorIdStrings.PSSessionConfigurationFileNotFound, _path);
                FileNotFoundException fnf = new FileNotFoundException(message);
                ErrorRecord           er  = new ErrorRecord(fnf, "PSSessionConfigurationFileNotFound",
                                                            ErrorCategory.ResourceUnavailable, _path);
                WriteError(er);
                return;
            }

            if (filePaths.Count > 1)
            {
                // "The path resolved to more than one file; can only process one file at a time."
                throw InterpreterError.NewInterpreterException(filePaths, typeof(RuntimeException),
                                                               null, "AmbiguousPath", ParserStrings.AmbiguousPath);
            }

            string             filePath   = filePaths[0];
            ExternalScriptInfo scriptInfo = null;
            string             ext        = System.IO.Path.GetExtension(filePath);

            if (ext.Equals(StringLiterals.PowerShellDISCFileExtension, StringComparison.OrdinalIgnoreCase))
            {
                // Create a script info for loading the file...
                string scriptName;
                scriptInfo = DISCUtils.GetScriptInfoForFile(this.Context, filePath, out scriptName);

                Hashtable configTable = null;

                try
                {
                    configTable = DISCUtils.LoadConfigFile(this.Context, scriptInfo);
                }
                catch (RuntimeException e)
                {
                    WriteVerbose(StringUtil.Format(RemotingErrorIdStrings.DISCErrorParsingConfigFile, filePath, e.Message));
                    WriteObject(false);
                    return;
                }

                if (configTable == null)
                {
                    WriteObject(false);
                    return;
                }

                DISCUtils.ExecutionPolicyType = typeof(ExecutionPolicy);
                WriteObject(DISCUtils.VerifyConfigTable(configTable, this, filePath));
            }
            else
            {
                string message = StringUtil.Format(RemotingErrorIdStrings.InvalidPSSessionConfigurationFilePath, filePath);
                InvalidOperationException ioe = new InvalidOperationException(message);
                ErrorRecord er = new ErrorRecord(ioe, "InvalidPSSessionConfigurationFilePath",
                                                 ErrorCategory.InvalidArgument, _path);
                ThrowTerminatingError(er);
            }
        }
 public bool IsExist(string title, object folderId)
 {
     return(ProviderInfo.GetFolderFiles(folderId).FirstOrDefault(x => x.Name.Contains(title)) != null);
 }
Example #30
0
 /// <summary>
 /// Creates the <see cref="VfsProviderInfo"/> object for the provider.
 /// </summary>
 /// <param name="providerInfo">A <see cref="ProviderInfo"/> object that describes the provider to be initialized.</param>
 /// <param name="container">The dependency injection container.</param>
 /// <returns>The created <see cref="VfsProviderInfo"/> object.</returns>
 protected override VfsProviderInfo CreateProviderInfo(ProviderInfo providerInfo, IContainer container)
 {
     return(new OrchardProviderInfo(providerInfo, container));
 }
 public bool IsExist(string title, Microsoft.SharePoint.Client.Folder folder)
 {
     return(ProviderInfo.GetFolderFiles(folder.ServerRelativeUrl).FirstOrDefault(x => x.Name.Contains(title)) != null);
 }
Example #32
0
 public List <Folder <string> > GetFolders(string parentId)
 {
     return(ProviderInfo.GetFolderFolders(parentId).Select(r => ProviderInfo.ToFolder(r)).ToList());
 }
 public File CopyFile(object fileId, object toFolderId)
 {
     return(ProviderInfo.ToFile(ProviderInfo.CopyFile(fileId, toFolderId)));
 }
Example #34
0
 public Folder <string> CopyFolder(string folderId, string toFolderId, CancellationToken?cancellationToken)
 {
     return(ProviderInfo.ToFolder(ProviderInfo.CopyFolder(folderId, toFolderId)));
 }
 public void InvalidateCache(object fileId)
 {
     ProviderInfo.InvalidateStorage();
 }
Example #36
0
 public Folder <string> GetFolder(string folderId)
 {
     return(ProviderInfo.ToFolder(ProviderInfo.GetFolderById(folderId)));
 }
 public File GetFile(object fileId, int fileVersion)
 {
     return(ProviderInfo.ToFile(ProviderInfo.GetFileById(fileId)));
 }
Example #38
0
        public string EditPrividerInfo(string billno, string name, string bankname, string bankcode, string swift, string iban, string num, string providercode, string companycode)
        {
            string error = string.Empty;
            string msg   = string.Empty;

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(bankname) || string.IsNullOrEmpty(bankcode))
            {
                error = "1";
                msg   = "供应商信息缺失";
                return(Public.JsonSerializeHelper.SerializeToJson(new { error = error, msg = msg }));
            }

            if (string.IsNullOrEmpty(num))
            {
                var grade = GetSubjectCode(name);
                //只有外汇可以没有联行号
                if (grade != 3)
                {
                    error = "1";
                    msg   = "支行数据错误";
                    return(Public.JsonSerializeHelper.SerializeToJson(new { error = error, msg = msg }));
                }
            }


            billno = billno.ToUpper().Replace(",", "").Replace(" ", "").Replace("/", "").Replace("F", ",F").Replace("J", ",J").Replace("H", ",H");
            var list = billno.Split(',').ToList();

            var FT = new NoticeBill();

            ProviderInfo provider = new ProviderInfo();

            provider.ProviderName      = name;
            provider.BankName          = bankname;
            provider.BankNo            = bankcode;
            provider.CompanyCode       = companycode;
            provider.IBAN              = iban;
            provider.BankCode          = swift;
            provider.ProviderCode      = providercode;
            provider.SubbranchBankCode = num;

            Dictionary <string, ProviderInfo> dic = new Dictionary <string, ProviderInfo>();

            dic.Add("ProviderInfo", provider);

            foreach (var item in list)
            {
                if (item.Contains("FT"))
                {
                    //通过的单不处理
                    var model = FT.GetBillModel(item);
                    if (model != null & model.ApprovalStatus != 2)
                    {
                        FT.PublicEditMethod <ProviderInfo>(item, dic);
                    }
                    else
                    {
                        msg += "单号" + item + "未做处理;";
                    }
                }
                //不处理
            }

            error = "0";
            if (string.IsNullOrEmpty(msg))
            {
                msg = "修改成功";
            }

            return(Public.JsonSerializeHelper.SerializeToJson(new { error = error, msg = msg }));
        }
 public File GetFile(object parentId, string title)
 {
     return(ProviderInfo.ToFile(ProviderInfo.GetFolderFiles(parentId).FirstOrDefault(x => x.Name.Contains(title))));
 }
        /// <summary>
        /// Adds the console, debugger, file, or host listener
        /// if requested.
        /// </summary>
        ///
        internal void AddTraceListenersToSources(Collection <PSTraceSource> matchingSources)
        {
            if (DebuggerListener)
            {
                if (_defaultListener == null)
                {
                    _defaultListener =
                        new DefaultTraceListener();

                    // Note, this is not meant to be localized.
                    _defaultListener.Name = "Debug";
                }
                AddListenerToSources(matchingSources, _defaultListener);
            }

            if (PSHostListener)
            {
                if (_hostListener == null)
                {
                    ((MshCommandRuntime)this.CommandRuntime).DebugPreference = ActionPreference.Continue;
                    _hostListener = new PSHostTraceListener(this);

                    // Note, this is not meant to be localized.
                    _hostListener.Name = "Host";
                }
                AddListenerToSources(matchingSources, _hostListener);
            }

            if (FileListener != null)
            {
                if (_fileListeners == null)
                {
                    _fileListeners = new Collection <TextWriterTraceListener>();
                    FileStreams    = new Collection <FileStream>();

                    Exception error = null;

                    try
                    {
                        Collection <string> resolvedPaths = new Collection <string>();
                        try
                        {
                            // Resolve the file path
                            ProviderInfo provider = null;
                            resolvedPaths = this.SessionState.Path.GetResolvedProviderPathFromPSPath(FileListener, out provider);

                            // We can only export aliases to the file system
                            if (!provider.NameEquals(this.Context.ProviderNames.FileSystem))
                            {
                                throw
                                    new PSNotSupportedException(
                                        StringUtil.Format(TraceCommandStrings.TraceFileOnly,
                                                          FileListener,
                                                          provider.FullName));
                            }
                        }
                        catch (ItemNotFoundException)
                        {
                            // Since the file wasn't found, just make a provider-qualified path out if it
                            // and use that.

                            PSDriveInfo  driveInfo = null;
                            ProviderInfo provider  = null;
                            string       path      =
                                this.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
                                    FileListener,
                                    new CmdletProviderContext(this.Context),
                                    out provider,
                                    out driveInfo);

                            // We can only export aliases to the file system
                            if (!provider.NameEquals(this.Context.ProviderNames.FileSystem))
                            {
                                throw
                                    new PSNotSupportedException(
                                        StringUtil.Format(TraceCommandStrings.TraceFileOnly,
                                                          FileListener,
                                                          provider.FullName));
                            }
                            resolvedPaths.Add(path);
                        }

                        if (resolvedPaths.Count > 1)
                        {
                            throw
                                new PSNotSupportedException(StringUtil.Format(TraceCommandStrings.TraceSingleFileOnly, FileListener));
                        }

                        string resolvedPath = resolvedPaths[0];

                        Exception fileOpenError = null;
                        try
                        {
                            if (ForceWrite && System.IO.File.Exists(resolvedPath))
                            {
                                // remove readonly attributes on the file
                                System.IO.FileInfo fInfo = new System.IO.FileInfo(resolvedPath);
                                if (fInfo != null)
                                {
                                    // Save some disk write time by checking whether file is readonly..
                                    if ((fInfo.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                                    {
                                        //Make sure the file is not read only
                                        fInfo.Attributes &= ~(FileAttributes.ReadOnly);
                                    }
                                }
                            }

                            // Trace commands always append..So there is no need to set overwrite with force..
                            FileStream fileStream = new FileStream(resolvedPath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                            FileStreams.Add(fileStream);

                            // Open the file stream

                            TextWriterTraceListener fileListener =
                                new TextWriterTraceListener(fileStream, resolvedPath);

                            fileListener.Name = FileListener;

                            _fileListeners.Add(fileListener);
                        }
                        catch (IOException ioException)
                        {
                            fileOpenError = ioException;
                        }
                        catch (SecurityException securityException)
                        {
                            fileOpenError = securityException;
                        }
                        catch (UnauthorizedAccessException unauthorized)
                        {
                            fileOpenError = unauthorized;
                        }

                        if (fileOpenError != null)
                        {
                            ErrorRecord errorRecord =
                                new ErrorRecord(
                                    fileOpenError,
                                    "FileListenerPathResolutionFailed",
                                    ErrorCategory.OpenError,
                                    resolvedPath);

                            WriteError(errorRecord);
                        }
                    }
                    catch (ProviderNotFoundException providerNotFound)
                    {
                        error = providerNotFound;
                    }
                    catch (System.Management.Automation.DriveNotFoundException driveNotFound)
                    {
                        error = driveNotFound;
                    }
                    catch (NotSupportedException notSupported)
                    {
                        error = notSupported;
                    }

                    if (error != null)
                    {
                        ErrorRecord errorRecord =
                            new ErrorRecord(
                                error,
                                "FileListenerPathResolutionFailed",
                                ErrorCategory.InvalidArgument,
                                FileListener);

                        WriteError(errorRecord);
                    }
                }

                foreach (TraceListener listener in _fileListeners)
                {
                    AddListenerToSources(matchingSources, listener);
                }
            }
        }
 public List <File> GetFiles(object[] fileIds)
 {
     return(fileIds.Select(fileId => ProviderInfo.ToFile(ProviderInfo.GetFileById(fileId))).ToList());
 }
Example #42
0
        /// <summary>
        /// Sets the provider information that is stored in the Monad engine into the
        /// provider base class.
        /// </summary>
        ///
        /// <param name="providerInfoToSet">
        /// The provider information that is stored by the Monad engine.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="providerInformation"/> is null.
        /// </exception>
        /// 
        internal void SetProviderInformation(ProviderInfo providerInfoToSet)
        {
            if (providerInfoToSet == null)
            {
                throw PSTraceSource.NewArgumentNullException("providerInfoToSet");
            }

            _providerInformation = providerInfoToSet;
        } // SetProviderInformation
        /// <summary>
        /// Copy the file format to clipboard.
        /// </summary>
        /// <param name="fileList"></param>
        /// <param name="append"></param>
        /// <param name="isLiteralPath"></param>
        private void CopyFilesToClipboard(List <string> fileList, bool append, bool isLiteralPath)
        {
            int clipBoardContentLength = 0;
            HashSet <string> dropFiles = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            // Append the new file list after the file list exists in the clipboard.
            if (append)
            {
                if (!Clipboard.ContainsFileDropList())
                {
                    WriteVerbose(string.Format(CultureInfo.InvariantCulture, ClipboardResources.NoAppendableClipboardContent));
                    append = false;
                }
                else
                {
                    StringCollection clipBoardContent = Clipboard.GetFileDropList();
                    dropFiles = new HashSet <string>(clipBoardContent.Cast <string>().ToList(), StringComparer.OrdinalIgnoreCase);

                    // we need the count of original files so we can get the accurate files number that has been appended.
                    clipBoardContentLength = clipBoardContent.Count;
                }
            }

            ProviderInfo provider = null;

            for (int i = 0; i < fileList.Count; i++)
            {
                Collection <string> newPaths = new Collection <string>();

                try
                {
                    if (isLiteralPath)
                    {
                        newPaths.Add(Context.SessionState.Path.GetUnresolvedProviderPathFromPSPath(fileList[i]));
                    }
                    else
                    {
                        newPaths = Context.SessionState.Path.GetResolvedProviderPathFromPSPath(fileList[i], out provider);
                    }
                }
                catch (ItemNotFoundException exception)
                {
                    WriteError(new ErrorRecord(exception, "FailedToSetClipboard", ErrorCategory.InvalidOperation, "Clipboard"));
                }

                foreach (string fileName in newPaths)
                {
                    // Avoid adding duplicated files.
                    if (!dropFiles.Contains(fileName))
                    {
                        dropFiles.Add(fileName);
                    }
                }
            }

            if (dropFiles.Count == 0)
            {
                return;
            }

            // Verbose output
            string setClipboardShouldProcessTarget;

            if ((dropFiles.Count - clipBoardContentLength) == 1)
            {
                if (append)
                {
                    setClipboardShouldProcessTarget = string.Format(CultureInfo.InvariantCulture, ClipboardResources.AppendSingleFileToClipboard, dropFiles.ElementAt <string>(dropFiles.Count - 1));
                }
                else
                {
                    setClipboardShouldProcessTarget = string.Format(CultureInfo.InvariantCulture, ClipboardResources.SetSingleFileToClipboard, dropFiles.ElementAt <string>(0));
                }
            }
            else
            {
                if (append)
                {
                    setClipboardShouldProcessTarget = string.Format(CultureInfo.InvariantCulture, ClipboardResources.AppendMultipleFilesToClipboard, (dropFiles.Count - clipBoardContentLength));
                }
                else
                {
                    setClipboardShouldProcessTarget = string.Format(CultureInfo.InvariantCulture, ClipboardResources.SetMultipleFilesToClipboard, dropFiles.Count);
                }
            }

            if (ShouldProcess(setClipboardShouldProcessTarget, "Set-Clipboard"))
            {
                // Set file list formats to clipboard.
                Clipboard.Clear();
                StringCollection fileDropList = new StringCollection();
                fileDropList.AddRange(dropFiles.ToArray());
                Clipboard.SetFileDropList(fileDropList);
            }
        }
Example #44
0
        } // Context

        /// <summary>
        /// Called when the provider is first initialized. It sets the context
        /// of the call and then calls the derived providers Start method.
        /// </summary>
        ///
        /// <param name="providerInfo">
        /// The information about the provider.
        /// </param>
        /// 
        /// <param name="cmdletProviderContext">
        /// The context under which this method is being called.
        /// </param>
        ///
        internal ProviderInfo Start(ProviderInfo providerInfo, CmdletProviderContext cmdletProviderContext)
        {
            Context = cmdletProviderContext;
            return Start(providerInfo);
        } // Start
Example #45
0
        /// <summary>
        /// Generate the module manifest...
        /// </summary>
        protected override void EndProcessing()
        {
            // Win8: 264471 - Error message for New-ModuleManifest -ProcessorArchitecture is obsolete.
            // If an undefined value is passed for the ProcessorArchitecture parameter, the error message from parameter binder includes all the values from the enum.
            // The value 'IA64' for ProcessorArchitecture is not supported. But since we do not own the enum System.Reflection.ProcessorArchitecture, we cannot control the values in it.
            // So, we add a separate check in our code to give an error if user specifies IA64
            if (ProcessorArchitecture == ProcessorArchitecture.IA64)
            {
                string message = StringUtil.Format(Modules.InvalidProcessorArchitectureInManifest, ProcessorArchitecture);
                InvalidOperationException ioe = new InvalidOperationException(message);
                ErrorRecord er = new ErrorRecord(ioe, "Modules_InvalidProcessorArchitectureInManifest",
                                                 ErrorCategory.InvalidArgument, ProcessorArchitecture);
                ThrowTerminatingError(er);
            }

            ProviderInfo provider = null;
            PSDriveInfo  drive;
            string       filePath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(_path, out provider, out drive);

            if (!provider.NameEquals(Context.ProviderNames.FileSystem) || !filePath.EndsWith(StringLiterals.PowerShellDataFileExtension, StringComparison.OrdinalIgnoreCase))
            {
                string message = StringUtil.Format(Modules.InvalidModuleManifestPath, _path);
                InvalidOperationException ioe = new InvalidOperationException(message);
                ErrorRecord er = new ErrorRecord(ioe, "Modules_InvalidModuleManifestPath",
                                                 ErrorCategory.InvalidArgument, _path);
                ThrowTerminatingError(er);
            }

            // By default, we want to generate a module manifest the encourages the best practice of explicitly specifying
            // the commands exported (even if it's an empty array.) Unfortunately, changing the default breaks automation
            // (however unlikely, this cmdlet isn't really meant for automation). Instead of trying to detect interactive
            // use (which is quite hard), we infer interactive use if none of RootModule/NestedModules/RequiredModules is
            // specified - because the manifest needs to be edited to actually be of use in those cases.
            //
            // If one of these parameters has been specified, default back to the old behavior by specifying
            // wildcards for exported commands that weren't specified on the command line.
            if (_rootModule != null || _nestedModules != null || _requiredModules != null)
            {
                if (_exportedFunctions == null)
                {
                    _exportedFunctions = new string[] { "*" }
                }
                ;
                if (_exportedAliases == null)
                {
                    _exportedAliases = new string[] { "*" }
                }
                ;
                if (_exportedCmdlets == null)
                {
                    _exportedCmdlets = new string[] { "*" }
                }
                ;
            }

            ValidateUriParameterValue(ProjectUri, "ProjectUri");
            ValidateUriParameterValue(LicenseUri, "LicenseUri");
            ValidateUriParameterValue(IconUri, "IconUri");
            if (_helpInfoUri != null)
            {
                ValidateUriParameterValue(new Uri(_helpInfoUri), "HelpInfoUri");
            }

            if (CompatiblePSEditions != null && (CompatiblePSEditions.Distinct(StringComparer.OrdinalIgnoreCase).Count() != CompatiblePSEditions.Count()))
            {
                string message = StringUtil.Format(Modules.DuplicateEntriesInCompatiblePSEditions, string.Join(",", CompatiblePSEditions));
                var    ioe     = new InvalidOperationException(message);
                var    er      = new ErrorRecord(ioe, "Modules_DuplicateEntriesInCompatiblePSEditions", ErrorCategory.InvalidArgument, CompatiblePSEditions);
                ThrowTerminatingError(er);
            }

            string action = StringUtil.Format(Modules.CreatingModuleManifestFile, filePath);

            if (ShouldProcess(filePath, action))
            {
                if (string.IsNullOrEmpty(_author))
                {
                    _author = Environment.UserName;
                }

                if (string.IsNullOrEmpty(_companyName))
                {
                    _companyName = Modules.DefaultCompanyName;
                }

                if (string.IsNullOrEmpty(_copyright))
                {
                    _copyright = StringUtil.Format(Modules.DefaultCopyrightMessage, _author);
                }

                FileStream   fileStream;
                StreamWriter streamWriter;
                FileInfo     readOnlyFileInfo;

                // Now open the output file...
                PathUtils.MasterStreamOpen(
                    cmdlet: this,
                    filePath: filePath,
                    resolvedEncoding: new UTF8Encoding(encoderShouldEmitUTF8Identifier: false),
                    defaultEncoding: false,
                    Append: false,
                    Force: false,
                    NoClobber: false,
                    fileStream: out fileStream,
                    streamWriter: out streamWriter,
                    readOnlyFileInfo: out readOnlyFileInfo,
                    isLiteralPath: false
                    );

                try
                {
                    StringBuilder result = new StringBuilder();

                    // Insert the formatted manifest header...
                    result.Append(ManifestComment(string.Empty, streamWriter));
                    result.Append(ManifestComment(StringUtil.Format(Modules.ManifestHeaderLine1, System.IO.Path.GetFileNameWithoutExtension(filePath)),
                                                  streamWriter));
                    result.Append(ManifestComment(string.Empty, streamWriter));
                    result.Append(ManifestComment(StringUtil.Format(Modules.ManifestHeaderLine2, _author),
                                                  streamWriter));
                    result.Append(ManifestComment(string.Empty, streamWriter));
                    result.Append(ManifestComment(StringUtil.Format(Modules.ManifestHeaderLine3, DateTime.Now.ToString("d", CultureInfo.CurrentCulture)),
                                                  streamWriter));
                    result.Append(ManifestComment(string.Empty, streamWriter));
                    result.Append(streamWriter.NewLine);
                    result.Append("@{");
                    result.Append(streamWriter.NewLine);
                    result.Append(streamWriter.NewLine);

                    if (_rootModule == null)
                    {
                        _rootModule = string.Empty;
                    }

                    BuildModuleManifest(result, nameof(RootModule), Modules.RootModule, !string.IsNullOrEmpty(_rootModule), () => QuoteName(_rootModule), streamWriter);

                    BuildModuleManifest(result, nameof(ModuleVersion), Modules.ModuleVersion, _moduleVersion != null && !string.IsNullOrEmpty(_moduleVersion.ToString()), () => QuoteName(_moduleVersion), streamWriter);

                    BuildModuleManifest(result, nameof(CompatiblePSEditions), Modules.CompatiblePSEditions, _compatiblePSEditions != null && _compatiblePSEditions.Length > 0, () => QuoteNames(_compatiblePSEditions, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(Modules.GUID), Modules.GUID, !string.IsNullOrEmpty(_guid.ToString()), () => QuoteName(_guid.ToString()), streamWriter);

                    BuildModuleManifest(result, nameof(Author), Modules.Author, !string.IsNullOrEmpty(_author), () => QuoteName(Author), streamWriter);

                    BuildModuleManifest(result, nameof(CompanyName), Modules.CompanyName, !string.IsNullOrEmpty(_companyName), () => QuoteName(_companyName), streamWriter);

                    BuildModuleManifest(result, nameof(Copyright), Modules.Copyright, !string.IsNullOrEmpty(_copyright), () => QuoteName(_copyright), streamWriter);

                    BuildModuleManifest(result, nameof(Description), Modules.Description, !string.IsNullOrEmpty(_description), () => QuoteName(_description), streamWriter);

                    BuildModuleManifest(result, nameof(PowerShellVersion), Modules.PowerShellVersion, _powerShellVersion != null && !string.IsNullOrEmpty(_powerShellVersion.ToString()), () => QuoteName(_powerShellVersion), streamWriter);

                    BuildModuleManifest(result, nameof(PowerShellHostName), Modules.PowerShellHostName, !string.IsNullOrEmpty(_PowerShellHostName), () => QuoteName(_PowerShellHostName), streamWriter);

                    BuildModuleManifest(result, nameof(PowerShellHostVersion), Modules.PowerShellHostVersion, _PowerShellHostVersion != null && !string.IsNullOrEmpty(_PowerShellHostVersion.ToString()), () => QuoteName(_PowerShellHostVersion), streamWriter);

                    BuildModuleManifest(result, nameof(DotNetFrameworkVersion), StringUtil.Format(Modules.DotNetFrameworkVersion, Modules.PrerequisiteForDesktopEditionOnly), _DotNetFrameworkVersion != null && !string.IsNullOrEmpty(_DotNetFrameworkVersion.ToString()), () => QuoteName(_DotNetFrameworkVersion), streamWriter);

                    BuildModuleManifest(result, nameof(ClrVersion), StringUtil.Format(Modules.CLRVersion, Modules.PrerequisiteForDesktopEditionOnly), _ClrVersion != null && !string.IsNullOrEmpty(_ClrVersion.ToString()), () => QuoteName(_ClrVersion), streamWriter);

                    BuildModuleManifest(result, nameof(ProcessorArchitecture), Modules.ProcessorArchitecture, _processorArchitecture.HasValue, () => QuoteName(_processorArchitecture.ToString()), streamWriter);

                    BuildModuleManifest(result, nameof(RequiredModules), Modules.RequiredModules, _requiredModules != null && _requiredModules.Length > 0, () => QuoteModules(_requiredModules, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(RequiredAssemblies), Modules.RequiredAssemblies, _requiredAssemblies != null, () => QuoteFiles(_requiredAssemblies, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(ScriptsToProcess), Modules.ScriptsToProcess, _scripts != null, () => QuoteFiles(_scripts, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(TypesToProcess), Modules.TypesToProcess, _types != null, () => QuoteFiles(_types, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(FormatsToProcess), Modules.FormatsToProcess, _formats != null, () => QuoteFiles(_formats, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(NestedModules), Modules.NestedModules, _nestedModules != null, () => QuoteModules(PreProcessModuleSpec(_nestedModules), streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(FunctionsToExport), Modules.FunctionsToExport, true, () => QuoteNames(_exportedFunctions, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(CmdletsToExport), Modules.CmdletsToExport, true, () => QuoteNames(_exportedCmdlets, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(VariablesToExport), Modules.VariablesToExport, _exportedVariables != null && _exportedVariables.Length > 0, () => QuoteNames(_exportedVariables, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(AliasesToExport), Modules.AliasesToExport, true, () => QuoteNames(_exportedAliases, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(DscResourcesToExport), Modules.DscResourcesToExport, _dscResourcesToExport != null && _dscResourcesToExport.Length > 0, () => QuoteNames(_dscResourcesToExport, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(ModuleList), Modules.ModuleList, _moduleList != null, () => QuoteModules(_moduleList, streamWriter), streamWriter);

                    BuildModuleManifest(result, nameof(FileList), Modules.FileList, _miscFiles != null, () => QuoteFiles(_miscFiles, streamWriter), streamWriter);

                    BuildPrivateDataInModuleManifest(result, streamWriter);

                    BuildModuleManifest(result, nameof(Modules.HelpInfoURI), Modules.HelpInfoURI, !string.IsNullOrEmpty(_helpInfoUri), () => QuoteName((_helpInfoUri != null) ? new Uri(_helpInfoUri) : null), streamWriter);

                    BuildModuleManifest(result, nameof(DefaultCommandPrefix), Modules.DefaultCommandPrefix, !string.IsNullOrEmpty(_defaultCommandPrefix), () => QuoteName(_defaultCommandPrefix), streamWriter);

                    result.Append("}");
                    result.Append(streamWriter.NewLine);
                    result.Append(streamWriter.NewLine);
                    string strResult = result.ToString();

                    if (_passThru)
                    {
                        WriteObject(strResult);
                    }

                    streamWriter.Write(strResult);
                }
                finally
                {
                    streamWriter.Dispose();
                }
            }
        }
Example #46
0
        public DataProviderHelper(string providerInvariantName, string connectionString)
        {
            string configName = providerInvariantName;
            if (providerInvariantName == "System.Data.OleDb")
            {
                string OLEDBprovider;
                if (RemoteDbProviderFactories.Isx64())
                {
                    RemoteDbProviderFactory f = RemoteDbProviderFactories.GetFactory(providerInvariantName);
                    ProxyConnectionStringBuilder csb = f.CreateConnectionStringBuilder();
                    csb.ConnectionString = connectionString;
                    OLEDBprovider = (string)csb["Provider"];
                }
                else
                {
                    DbProviderFactory f = DbProviderFactories.GetFactory(providerInvariantName);
                    DbConnectionStringBuilder csb = f.CreateConnectionStringBuilder();
                    csb.ConnectionString = connectionString;
                    OLEDBprovider = (string)csb["Provider"];
                }                
                if (!String.IsNullOrEmpty(OLEDBprovider))
                    configName = OLEDBprovider;
            }
            lock (_cached_info)
                if (!_cached_info.TryGetValue(configName, out _providerInfo))
                {
                    _providerInfo = new ProviderInfo();

                    using (DbConnection connection = CreateDbConnection(providerInvariantName))
                    {
                        connection.ConnectionString = connectionString;
                        connection.Open();

                        DataTable dt = connection.GetSchema("DataSourceInformation");
                        DataRow r = dt.Rows[0];

                        _providerInfo.ConfigName = configName;
                        _providerInfo.ProviderInvariantName = providerInvariantName;
                        _providerInfo.DataSourceProductName = (string)r["DataSourceProductName"];
                        _providerInfo.IdentifierCase = (IdentifierCase)Convert.ToInt32(r["IdentifierCase"]);
                        _providerInfo.IdentifierPattern = (String)r["IdentifierPattern"];
                        _providerInfo.OrderByColumnsInSelect = (bool)r["OrderByColumnsInSelect"];
                        _providerInfo.ParameterMarkerFormat = (string)r["ParameterMarkerFormat"];
                        _providerInfo.QuotedIdentifierCase = (IdentifierCase)Convert.ToInt32(r["QuotedIdentifierCase"]);
                        _providerInfo.QuotedIdentifierPattern = (string)r["QuotedIdentifierPattern"];
                        if (!r.IsNull("StringLiteralPattern"))
                            _providerInfo.StringLiteralPattern = (string)r["StringLiteralPattern"];
                        if (!r.IsNull("SupportedJoinOperators"))
                            _providerInfo.SupportedJoinOperators = (SupportedJoinOperators)Convert.ToInt32(r["SupportedJoinOperators"]);

                        dt = connection.GetSchema("ReservedWords");
                        foreach (DataRow r0 in dt.Rows)
                        {
                            String kw = ((string)r0[0]).ToUpperInvariant();
                            if (!_providerInfo.keywords.ContainsKey(kw)) // MySQL Bug
                                _providerInfo.keywords.Add(kw, 0);
                        }

                        _cached_info.Add(configName, _providerInfo);
                        connection.Close();
                    }
                }
            ReadProperties();
        }
Example #47
0
        /// <summary>
        /// ProcessRecord() override.
        /// This is for paths collecting from pipe.
        /// </summary>
        protected override void ProcessRecord()
        {
            List <string> pathsToProcess = new List <string>();
            ProviderInfo  provider       = null;

            switch (ParameterSetName)
            {
            case PathParameterSet:
                // Resolve paths and check existence
                foreach (string path in _paths)
                {
                    try
                    {
                        Collection <string> newPaths = Context.SessionState.Path.GetResolvedProviderPathFromPSPath(path, out provider);
                        if (newPaths != null)
                        {
                            pathsToProcess.AddRange(newPaths);
                        }
                    }
                    catch (ItemNotFoundException e)
                    {
                        if (!WildcardPattern.ContainsWildcardCharacters(path))
                        {
                            ErrorRecord errorRecord = new ErrorRecord(e,
                                                                      "FileNotFound",
                                                                      ErrorCategory.ObjectNotFound,
                                                                      path);
                            WriteError(errorRecord);
                        }
                    }
                }

                break;

            case LiteralPathParameterSet:
                foreach (string path in _paths)
                {
                    string newPath = Context.SessionState.Path.GetUnresolvedProviderPathFromPSPath(path);
                    pathsToProcess.Add(newPath);
                }

                break;
            }

            foreach (string path in pathsToProcess)
            {
                byte[] bytehash       = null;
                string hash           = null;
                Stream openfilestream = null;

                try
                {
                    openfilestream = File.OpenRead(path);
                    bytehash       = hasher.ComputeHash(openfilestream);

                    hash = BitConverter.ToString(bytehash).Replace("-", string.Empty);
                    WriteHashResult(Algorithm, hash, path);
                }
                catch (FileNotFoundException ex)
                {
                    var errorRecord = new ErrorRecord(
                        ex,
                        "FileNotFound",
                        ErrorCategory.ObjectNotFound,
                        path);
                    WriteError(errorRecord);
                }
                catch (UnauthorizedAccessException ex)
                {
                    var errorRecord = new ErrorRecord(
                        ex,
                        "UnauthorizedAccessError",
                        ErrorCategory.InvalidData,
                        path);
                    WriteError(errorRecord);
                }
                catch (IOException ioException)
                {
                    var errorRecord = new ErrorRecord(
                        ioException,
                        "FileReadError",
                        ErrorCategory.ReadError,
                        path);
                    WriteError(errorRecord);
                }
                finally
                {
                    openfilestream?.Dispose();
                }
            }
        }
Example #48
0
	ProviderInfo GetProviderInfo (short id)
	{
	    if (providers.ContainsKey (id))
		return providers[id];

	    ProviderInfo pi = new ProviderInfo (id, this);

	    if (pi.InitializeBuilddir (this))
		return null;

	    providers[id] = pi;
	    return pi;
	}
Example #49
0
 protected override ProviderInfo Start(ProviderInfo providerInfo)
 {
     providerInfo.Home = HomePath;
     return(providerInfo);
 }
Example #50
0
 internal void SetProviderInfo(ProviderInfo providerInfo)
 {
     ProviderInfo = providerInfo;
 }
 public void Dispose()
 {
     ProviderInfo.Dispose();
 }
Example #52
0
 protected virtual ProviderInfo Start(ProviderInfo providerInfo)
 {
     return providerInfo;
 }
Example #53
0
    public string Update_Patient(PatientName Pat_Name, PatientPersonalDetails Pat_Per_Details, PatientAddress Pat_Add,
                           PatientInsuranceDetails Pat_Ins_Details, PatientAllergies Pat_Allergies,
                           FacilityInfo Fac_Info, PharmacyInfo Phrm_Info,ProviderInfo Prov_Info)
    {
        SqlConnection sqlCon = new SqlConnection(ConStr);
        SqlCommand sqlCmd = new SqlCommand("sp_update_Patient", sqlCon);
        sqlCmd.CommandType = CommandType.StoredProcedure;

        SqlParameter P_ID = sqlCmd.Parameters.Add("@Pat_ID", SqlDbType.Int);
        P_ID.Value = Pat_Name.Pat_ID;

        SqlParameter P_MName = sqlCmd.Parameters.Add("@Pat_MName", SqlDbType.VarChar, 50);
        if (Pat_Name.MiddleName != null)
            P_MName.Value = Pat_Name.MiddleName;
        else
            P_MName.Value = Convert.DBNull;

        SqlParameter P_Gender = sqlCmd.Parameters.Add("@Pat_Gender", SqlDbType.Char, 1);
        if (Pat_Per_Details.Gender != null)
            P_Gender.Value = Pat_Per_Details.Gender;
        else
            P_Gender.Value = Convert.DBNull;

        SqlParameter P_DOB = sqlCmd.Parameters.Add("@Pat_DOB", SqlDbType.DateTime);
        if (Pat_Per_Details.DOB != null)
            P_DOB.Value = DateTime.Parse(Pat_Per_Details.DOB);
        else
        {
            Nullable<DateTime> NullDate = null;
            P_DOB.Value = NullDate;
        }

        SqlParameter P_SSN = sqlCmd.Parameters.Add("@Pat_SSN", SqlDbType.VarChar, 50);
        if (Pat_Per_Details.SSN != null)
            P_SSN.Value = Pat_Per_Details.SSN;
        else
            P_SSN.Value = Convert.DBNull;

        SqlParameter P_Address1 = sqlCmd.Parameters.Add("@Pat_Address1", SqlDbType.VarChar, 50);
        if (Pat_Add.Address1 != null)
            P_Address1.Value = Pat_Add.Address1;
        else
            P_Address1.Value = Convert.DBNull;

        SqlParameter P_Address2 = sqlCmd.Parameters.Add("@Pat_Address2", SqlDbType.VarChar, 50);
        if (Pat_Add.Address2 != null)
            P_Address2.Value = Pat_Add.Address2;
        else
            P_Address2.Value = Convert.DBNull;

        SqlParameter P_City = sqlCmd.Parameters.Add("@Pat_City", SqlDbType.VarChar, 50);
        if (Pat_Add.City != null)
            P_City.Value = Pat_Add.City;
        else
            P_City.Value = Convert.DBNull;
        SqlParameter P_State = sqlCmd.Parameters.Add("@Pat_State", SqlDbType.VarChar, 50);
        if (Pat_Add.State != null)
            P_State.Value = Pat_Add.State;
        else
            P_State.Value = Convert.DBNull;
        SqlParameter P_ZIP = sqlCmd.Parameters.Add("@Pat_Zip", SqlDbType.VarChar, 50);
        if (Pat_Add.Zip != null)
            P_ZIP.Value = Pat_Add.Zip;
        else
            P_ZIP.Value = Convert.DBNull;
        SqlParameter P_PDoc = sqlCmd.Parameters.Add("@Pat_PDoc", SqlDbType.VarChar, 50);
        if (Pat_Per_Details.Pat_Pre_Doc != null)
            P_PDoc.Value = Pat_Per_Details.Pat_Pre_Doc;
        else
            P_PDoc.Value = Convert.DBNull;

        SqlParameter P_MRN = sqlCmd.Parameters.Add("@Pat_MRN", SqlDbType.VarChar, 15);
        if (Pat_Per_Details.MRN != null)
            P_MRN.Value = Pat_Per_Details.MRN;
        else
            P_MRN.Value = Convert.DBNull;

        SqlParameter Fac_ID = sqlCmd.Parameters.Add("@Fac_ID", SqlDbType.Int);
        if (Fac_Info.FacilityNO != null)
            Fac_ID.Value = Fac_Info.FacilityNO;
        else
            Fac_ID.Value = Convert.DBNull;

        SqlParameter Phrm_ID = sqlCmd.Parameters.Add("@Phrm_ID", SqlDbType.Int);
        if (Phrm_Info.PhrmID != null)
            Phrm_ID.Value = Phrm_Info.PhrmID;
        else
            Phrm_ID.Value = Convert.DBNull;

        //SqlParameter PI_InsName = sqlCmd.Parameters.Add("@Ins_Name", SqlDbType.VarChar, 50);
        //if (Pat_Ins_Details.InsuranceName != null)
        //    PI_InsName.Value = Pat_Ins_Details.InsuranceName;
        //else
        //    PI_InsName.Value = Convert.DBNull;

        int InsID = getInsuranceID(Pat_Ins_Details);
        Pat_Ins_Details.InsuranceID = InsID;

        SqlParameter Ins_ID = sqlCmd.Parameters.Add("@Ins_ID", SqlDbType.Int);
        if (Pat_Ins_Details.InsuranceID.ToString() != "0")
            Ins_ID.Value = Pat_Ins_Details.InsuranceID;
        else
            Ins_ID.Value = Convert.DBNull;

        SqlParameter PI_No = sqlCmd.Parameters.Add("@PI_Number", SqlDbType.Int);
        if (Pat_Ins_Details.PI_PolicyNo.ToString() != "0")
            PI_No.Value = Pat_Ins_Details.PI_PolicyNo;
        else
            PI_No.Value = Convert.DBNull;

        SqlParameter PI_PolicyID = sqlCmd.Parameters.Add("@PI_PolicyID", SqlDbType.Int);
        if (Pat_Ins_Details.PI_PolicyID.ToString() != "0")
            PI_PolicyID.Value = Pat_Ins_Details.PI_PolicyID;
        else
            PI_PolicyID.Value = Convert.DBNull;

        SqlParameter PI_GroupNo = sqlCmd.Parameters.Add("@PI_GroupNo", SqlDbType.Int);
        if (Pat_Ins_Details.PI_GroupNo.ToString() != "0")
            PI_GroupNo.Value = Pat_Ins_Details.PI_GroupNo;
        else
            PI_GroupNo.Value = Convert.DBNull;

        SqlParameter PI_BINNo = sqlCmd.Parameters.Add("@PI_BINNo", SqlDbType.Int);
        if (Pat_Ins_Details.PI_BINNo.ToString() != "0")
            PI_BINNo.Value = Pat_Ins_Details.PI_BINNo;
        else
            PI_BINNo.Value = Convert.DBNull;

        SqlParameter PI_InsdName = sqlCmd.Parameters.Add("@PI_InsdName", SqlDbType.VarChar, 50);
        if (Pat_Ins_Details.InsuredName != null)
            PI_InsdName.Value = Pat_Ins_Details.InsuredName;
        else
            PI_InsdName.Value = Convert.DBNull;

        SqlParameter PI_InsdDOB = sqlCmd.Parameters.Add("@PI_InsdDOB", SqlDbType.DateTime);
        if (Pat_Ins_Details.InsuredDOB != null)
            PI_InsdDOB.Value = DateTime.Parse( Pat_Ins_Details.InsuredDOB);
        else
        {
            Nullable<DateTime> NullDate = null;
            PI_InsdDOB.Value = NullDate;
        }
        SqlParameter PI_InsdSSN = sqlCmd.Parameters.Add("@PI_InsdSSN", SqlDbType.VarChar, 50);
        if (Pat_Ins_Details.InsuredSSN != null)
            PI_InsdSSN.Value = Pat_Ins_Details.InsuredSSN;
        else
            PI_InsdSSN.Value = Convert.DBNull;
        SqlParameter PI_InsdRel = sqlCmd.Parameters.Add("@PI_InsdRel", SqlDbType.VarChar, 50);
        if (Pat_Ins_Details.InsuredRelation != null)
            PI_InsdRel.Value = Pat_Ins_Details.InsuredRelation;
        else
            PI_InsdRel.Value = Convert.DBNull;

        SqlParameter PA_Desc = sqlCmd.Parameters.Add("@PA_Desc", SqlDbType.VarChar, 200);
        if (Pat_Allergies.AllergyDescription != null)
            PA_Desc.Value = Pat_Allergies.AllergyDescription;
        else
            PA_Desc.Value = Convert.DBNull;

        try
        {
            sqlCon.Open();
            sqlCmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        finally
        {
            sqlCon.Close();
        }

        return "Updated Patient Information Successfully";
    }