Esempio n. 1
0
        //
        // Deserialize JSON and load faculty information we need
        //
        public personInfo LoadFacultyInfo(NameValueCollection allFaculties, string personId)
        {
            HealthIS.Apps.MVC.Models.personInfo person = new HealthIS.Apps.MVC.Models.personInfo();
            try
            {
                string jobTitle = allFaculties[personId];
                jobTitle = jobTitle.Replace(";amp;", "&");
                jobTitle = jobTitle.Replace(";eq;", "=");
                jobTitle = jobTitle.Replace(";dump;", ""); // default value

                person.jobTitle = jobTitle;

                if (!personId.ToLower().Contains("temp_") && allFaculties.Count > 0)
                {
                    // Get data from FacultyInfo method
                    System.Data.DataSet   dataSet   = Newtonsoft.Json.JsonConvert.DeserializeObject <System.Data.DataSet>(FacultyInfo(personId));
                    System.Data.DataTable dataTable = dataSet.Tables[0];

                    person.PERSON_ID = personId;
                    foreach (System.Data.DataRow row in dataTable.Rows)
                    {
                        person.FIRST_NAME = row["FIRST_NAME"].ToString();
                        person.LAST_NAME  = row["LAST_NAME"].ToString();
                        person.TITLE      = row["TITLE"].ToString();
                        person.EMAIL      = row["EMAIL"].ToString();
                        var hscId = row["EMAIL"].ToString().Split('@');
                        person.HSCNET_ID = hscId[0].ToString();
                    }

                    // If FacultyInfo method doesn't have enough information, call SearchHD method to add more information
                    if (String.IsNullOrEmpty(person.EMAIL) && !String.IsNullOrEmpty(personId))
                    {
                        personInfo searchedData = SearchHD(person.FIRST_NAME, person.LAST_NAME, personId);
                        person.FIRST_NAME = searchedData.FIRST_NAME;
                        person.LAST_NAME  = searchedData.LAST_NAME;
                        person.EMAIL      = searchedData.EMAIL;
                        person.HSCNET_ID  = searchedData.HSCNET_ID;
                    }
                }
            }
            catch (Exception ex)
            {
                string error = "Error: " + ex.Message + "<br/>" + ex.StackTrace;
                error += ex.InnerException == null ? "" : "<br/>Inner Exception: " + ex.InnerException.Message;
                Sitecore.Diagnostics.Log.Error("Faculty Direcotry Error - 'LoadFacultyInfo' method: ", error);
            }
            return(person);
        }
Esempio n. 2
0
        //
        // This method is for addtional information, such as Credential and Email
        //
        public personInfo SearchHD(string fname, string lname, string personIdFromList)
        {
            string strConnect = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dbprod2.hscnet.hsc.usf.edu)(PORT=1522)))(CONNECT_DATA=(SID=DBAFRZN)(SERVER=DEDICATED)));User Id=hd_search_web;Password=flakSchn0z;";

            HealthIS.Apps.MVC.Models.personInfo person = new HealthIS.Apps.MVC.Models.personInfo();
            try
            {
                using (OracleConnection orCN = new OracleConnection(strConnect))
                {
                    orCN.Open();
                    OracleCommand orCmd = new OracleCommand("hsc.hd_search.sel_matching_entries", orCN);
                    orCmd.CommandType = System.Data.CommandType.StoredProcedure;

                    orCmd.Parameters.Add("p_first_name", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input;
                    orCmd.Parameters["p_first_name"].Value = fname;

                    orCmd.Parameters.Add("p_last_name", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input;
                    orCmd.Parameters["p_last_name"].Value = lname;

                    orCmd.Parameters.Add("p_unique_id", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input;
                    orCmd.Parameters["p_unique_id"].Value = "";

                    orCmd.Parameters.Add("p_mdm_id", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input;
                    orCmd.Parameters["p_mdm_id"].Value = "";

                    orCmd.Parameters.Add("p_persons", OracleDbType.RefCursor).Direction = System.Data.ParameterDirection.Output;
                    orCmd.Parameters.Add("p_roles", OracleDbType.RefCursor).Direction   = System.Data.ParameterDirection.Output;

                    orCmd.Parameters.Add("p_limit", OracleDbType.Int16).Direction = System.Data.ParameterDirection.Input;
                    orCmd.Parameters["p_limit"].Value = 10;

                    OracleDataAdapter   adapt = new OracleDataAdapter(orCmd);
                    System.Data.DataSet orDS  = new System.Data.DataSet();
                    orCmd.ExecuteNonQuery();
                    adapt.Fill(orDS);

                    foreach (System.Data.DataRow dr in orDS.Tables[0].Rows)
                    {
                        string personIdFromSearch = dr["PERSON_ID"].ToString();
                        if (personIdFromList == personIdFromSearch)
                        {
                            person.PERSON_ID  = dr["PERSON_ID"].ToString();
                            person.FIRST_NAME = dr["FNAME"].ToString();
                            person.LAST_NAME  = dr["LNAME"].ToString();
                            person.EMAIL      = dr["EMAIL"].ToString();
                            person.HSCNET_ID  = dr["HSCNET_ID"].ToString();
                        }
                    }
                    orDS.Dispose();
                    adapt.Dispose();
                    orCmd.Dispose();
                    orCN.Close();
                    orCN.Dispose();
                }
            }
            catch (Exception ex)
            {
                string error = "Error: " + ex.Message + "<br/>" + ex.StackTrace;
                error += ex.InnerException == null ? "" : "<br/>Inner Exception: " + ex.InnerException.Message;
                Sitecore.Diagnostics.Log.Error("Faculty Direcotry Error - 'SearchHD' method: ", error);
            }
            return(person);
        }