Exemplo n.º 1
0
        public List <StateBO> GetStateList()
        {
            List <StateBO> List = new List <StateBO>();


            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from state in Context.States

                                select state;

                    var DataRow = Query;
                    foreach (var Row in DataRow)
                    {
                        List.Add(Mapper.Map(Row));
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }


            return(List);
        }
Exemplo n.º 2
0
        public List <OrganizationBO> GetOrganizationInfoByOrgKey(string gOrgKeyEncrypted)
        {
            List <OrganizationBO> OrganizationBO = new List <OrganizationBO>();

            try{
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Organizations
                                 where response.OrganizationKey == gOrgKeyEncrypted && response.IsEnabled == true

                                 select response);


                    var DataRow = Query;
                    foreach (var Row in DataRow)
                    {
                        OrganizationBO.Add(Mapper.Map(Row));
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(OrganizationBO);
        }
Exemplo n.º 3
0
        public List <CacheDependencyBO> GetCacheDependencyInfo(List <string> surveyKeys)
        {
            List <CacheDependencyBO> result = new List <CacheDependencyBO>();

            if (surveyKeys.Count > 0)
            {
                try
                {
                    foreach (string key in surveyKeys)
                    {
                        Guid guid = new Guid(key);

                        using (var Context = DataObjectFactory.CreateContext())
                        {
                            SurveyMetaData    surveyMetaDatas   = Context.SurveyMetaDatas.FirstOrDefault(x => x.SurveyId == guid);
                            CacheDependencyBO cacheDependencyBO = Mapper.MapDependency(surveyMetaDatas);
                            result.Add(cacheDependencyBO);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        public List <OrganizationBO> GetOrganizationInfo()
        {
            List <OrganizationBO> OrganizationBO = new List <OrganizationBO>();

            try{
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Organizations

                                 select response);


                    var DataRow = Query.Distinct();
                    foreach (var Row in DataRow)
                    {
                        OrganizationBO.Add(Mapper.Map(Row));
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(OrganizationBO);
        }
Exemplo n.º 5
0
        public List <SurveyInfoBO> GetSurveyInfoByOrgKeyAndPublishKey(string SurveyId, string Okey, Guid publishKey)
        {
            List <SurveyInfoBO> result = new List <SurveyInfoBO>();

            List <SurveyMetaData> responseList = new List <SurveyMetaData>();

            int OrganizationId = 0;

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Organizations
                                 where response.OrganizationKey == Okey
                                 select response).SingleOrDefault();

                    if (Query != null)
                    {
                        OrganizationId = Query.OrganizationId;
                    }
                }
            }
            catch (System.Reflection.ReflectionTypeLoadException ex)
            {
                // throw(ex.LoaderExceptions.ToString());
            }
            catch (Exception ex)
            {
                if (ex is System.Reflection.ReflectionTypeLoadException)
                {
                }
                //throw(((System.Reflection.ReflectionTypeLoadException)ex).LoaderExceptions);
            }
            //  catch (Exception ex)
            // {
            //throw (ex);
            // }

            if (!string.IsNullOrEmpty(SurveyId))
            {
                try
                {
                    Guid Id = new Guid(SurveyId);
                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        responseList.Add(Context.SurveyMetaDatas.FirstOrDefault(x => x.SurveyId == Id && x.OrganizationId == OrganizationId && x.UserPublishKey == publishKey));
                        if (responseList[0] != null)
                        {
                            result = Mapper.Map(responseList);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }

            return(result);
        }
Exemplo n.º 6
0
        public List <AdminBO> GetAdminEmails()
        {
            List <AdminBO> AdminBO = new List <AdminBO>();

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Admins

                                 select new { response.AdminEmail }).Distinct();


                    var DataRow = Query.Distinct();
                    foreach (var Row in DataRow)
                    {
                        AdminBO.Add(Mapper.MapAdminEmail(Row.AdminEmail));
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(AdminBO);
        }
Exemplo n.º 7
0
        public int GetOrganizationId(string OrgKey)
        {
            int OrganizationId = -1;

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Organizations
                                 where response.OrganizationKey == OrgKey
                                 select response).SingleOrDefault();

                    if (Query != null)
                    {
                        OrganizationId = Query.OrganizationId;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(OrganizationId);
        }
Exemplo n.º 8
0
        public void UpdateRecordStatus(SurveyResponseBO SurveyResponseBO)
        {
            try
            {
                Guid Id = new Guid(SurveyResponseBO.ResponseId);


                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from response in Context.SurveyResponses
                                where response.ResponseId == Id
                                select response;

                    var DataRow = Query.Single();

                    if (DataRow.StatusId == 3 && SurveyResponseBO.Status == 4)
                    {
                        DataRow.StatusId = SurveyResponseBO.Status;
                    }

                    if (SurveyResponseBO.Status != 4)
                    {
                        DataRow.StatusId = SurveyResponseBO.Status;
                    }


                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Updates a SurveyResponse.
        /// </summary>
        /// <param name="SurveyResponse">SurveyResponse.</param>
        public void UpdateSurveyResponse(SurveyResponseBO SurveyResponse)
        {
            try{
                Guid Id = new Guid(SurveyResponse.ResponseId);

                //Update Survey
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from response in Context.SurveyResponses
                                where response.ResponseId == Id
                                select response;

                    var DataRow = Query.Single();

                    if (!string.IsNullOrEmpty(SurveyResponse.RelateParentId) && SurveyResponse.RelateParentId != Guid.Empty.ToString())
                    {
                        DataRow.RelateParentId = new Guid(SurveyResponse.RelateParentId);
                    }

                    DataRow.ResponseXML = SurveyResponse.XML;
                    //DataRow.DateCompleted = DateTime.Now;
                    DataRow.DateCompleted = SurveyResponse.DateCompleted;
                    DataRow.StatusId      = SurveyResponse.Status;
                    DataRow.DateUpdated   = DateTime.Now;
                    //   DataRow.ResponsePasscode = SurveyResponse.ResponsePassCode;
                    DataRow.IsDraftMode     = SurveyResponse.IsDraftMode;
                    DataRow.ResponseXMLSize = RemoveWhitespace(SurveyResponse.XML).Length;
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 10
0
        public AdminBO GetAdminEmailByAdminId(string AdminEmail)
        {
            AdminBO AdminBO = new AdminBO();

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Admins
                                 where response.AdminEmail == AdminEmail
                                 select new { response.AdminEmail }).Distinct();


                    var DataRow = Query.Distinct();
                    foreach (var Row in DataRow)
                    {
                        AdminBO = Mapper.MapAdminEmail(Row.AdminEmail);
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(AdminBO);
        }
Exemplo n.º 11
0
        public string GetAdminOrgKeyByEmail(string UserEmail)
        {
            var OrgKey = "";

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Admins
                                 where response.AdminEmail == UserEmail
                                 select new { response.Organization.OrganizationKey }).Distinct();

                    foreach (var item in Query)
                    {
                        OrgKey = item.OrganizationKey.ToString();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(OrgKey);
        }
Exemplo n.º 12
0
        public OrganizationBO  GetOrganizationInfoByKey(string key)
        {
            OrganizationBO OrganizationBO = new  OrganizationBO();

            try{
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Organizations
                                 where response.OrganizationKey == key
                                 select response);
                    if (Query.Count() > 0)
                    {
                        OrganizationBO = Mapper.Map(Query.SingleOrDefault());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(OrganizationBO);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Inserts a new SurveyInfo.
        /// </summary>
        /// <remarks>
        /// Following insert, SurveyInfo object will contain the new identifier.
        /// </remarks>
        /// <param name="SurveyInfo">SurveyInfo.</param>
        public void InsertSurveyInfo(SurveyInfoBO SurveyInfo)
        {
            int OrganizationId = 0;

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    //retrieve OrganizationId based on OrganizationKey
                    using (var ContextOrg = DataObjectFactory.CreateContext())
                    {
                        string OrgKey = Cryptography.Encrypt(SurveyInfo.OrganizationKey.ToString());
                        OrganizationId = ContextOrg.Organizations.FirstOrDefault(x => x.OrganizationKey == OrgKey).OrganizationId;
                    }

                    SurveyInfo.TemplateXMLSize = RemoveWhitespace(SurveyInfo.XML).Length;
                    SurveyInfo.DateCreated     = DateTime.Now;
                    SurveyInfo.LastUpdate      = DateTime.Now;
                    SurveyInfo.IsSqlProject    = SurveyInfo.IsSqlProject;
                    var SurveyMetaDataEntity = Mapper.Map(SurveyInfo);
                    SurveyMetaDataEntity.OrganizationId = OrganizationId;
                    Context.AddToSurveyMetaDatas(SurveyMetaDataEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 14
0
        public List <AdminBO> GetAdminInfoByOrgKey(string gOrgKeyEncrypted)
        {
            List <AdminBO> AdminList = new List <AdminBO>();

            int OrgId      = 0;
            int AdminOrgId = 0;

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var OrgQuery = (from response in Context.Organizations
                                    where response.OrganizationKey == gOrgKeyEncrypted
                                    select new { response.OrganizationId }).First();

                    OrgId = OrgQuery.OrganizationId;



                    var AdminOrgQuery = (from response in Context.Organizations
                                         where response.IsHostOrganization == true
                                         select new { response.OrganizationId }).First();
                    AdminOrgId = AdminOrgQuery.OrganizationId;


                    var AdminQuery = (from response in Context.Admins
                                      where response.OrganizationId == OrgId && response.IsActive == true && response.Notify == true
                                      select new { response });
                    var AdminQuery1 = (from response in Context.Admins
                                       where  response.OrganizationId == AdminOrgId && response.IsActive == true && response.Notify == true
                                       select new { response });

                    foreach (var row in AdminQuery)
                    {
                        AdminBO AdminBO = new AdminBO();
                        AdminBO.AdminEmail = row.response.AdminEmail;
                        AdminBO.IsActive   = row.response.IsActive;

                        AdminList.Add(AdminBO);
                    }
                    foreach (var row in AdminQuery1)
                    {
                        AdminBO AdminBO = new AdminBO();
                        AdminBO.AdminEmail = row.response.AdminEmail;
                        AdminBO.IsActive   = row.response.IsActive;

                        AdminList.Add(AdminBO);
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }



            return(AdminList);
        }
Exemplo n.º 15
0
        public void InsertAdmin(AdminBO Admin)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    Admin AdminEntity = Mapper.ToEF(Admin);



                    Context.AddToAdmins(AdminEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }



            // Get Admin Id
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from _Admin in Context.Admins
                                 where _Admin.AdminEmail == Admin.AdminEmail && _Admin.FirstName == Admin.FirstName && Admin.LastName == _Admin.LastName
                                 select new { _Admin.AdminId }).Distinct();


                    var DataRow = Query.Distinct();
                    foreach (var Row in DataRow)
                    {
                        Admin.AdminId = Row.AdminId;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            // Insert Address
            using (var Context = DataObjectFactory.CreateContext())
            {
                Address AddressEntity = Mapper.ToAddressEF(Admin);



                Context.AddToAddresses(AddressEntity);

                Context.SaveChanges();
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Gets SurveyInfo based on a list of ids
        /// </summary>
        /// <param name="SurveyInfoId">Unique SurveyInfo identifier.</param>
        /// <returns>SurveyInfo.</returns>
        public List <SurveyInfoBO> GetSurveyInfo(List <string> SurveyInfoIdList, int PageNumber = -1, int PageSize = -1)
        {
            List <SurveyInfoBO> result = new List <SurveyInfoBO>();

            if (SurveyInfoIdList.Count > 0)
            {
                try
                {
                    foreach (string surveyInfoId in SurveyInfoIdList.Distinct())
                    {
                        Guid Id = new Guid(surveyInfoId);

                        using (var Context = DataObjectFactory.CreateContext())
                        {
                            result.Add(Mapper.Map(Context.SurveyMetaDatas.FirstOrDefault(x => x.SurveyId == Id)));
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }
            else
            {
                try
                {
                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        result = Mapper.Map(Context.SurveyMetaDatas.ToList());
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }

            // remove the items to skip
            // remove the items after the page size
            if (PageNumber > 0 && PageSize > 0)
            {
                result.Sort(CompareByDateCreated);
                // remove the items to skip
                if (PageNumber * PageSize - PageSize > 0)
                {
                    result.RemoveRange(0, PageSize);
                }

                if (PageNumber * PageSize < result.Count)
                {
                    result.RemoveRange(PageNumber * PageSize, result.Count - PageNumber * PageSize);
                }
            }

            return(result);
        }
Exemplo n.º 17
0
        public void ValidateServername(SurveyInfoBO pRequestMessage)
        {
            var    Context      = DataObjectFactory.CreateContext();
            string eweAdostring = Context.Connection.ConnectionString.Substring(Context.Connection.ConnectionString.ToLower().IndexOf("data source="), Context.Connection.ConnectionString.Substring(Context.Connection.ConnectionString.ToLower().IndexOf("data source=")).IndexOf(";"));

            string epiDBstring = pRequestMessage.DBConnectionString.Substring(0, pRequestMessage.DBConnectionString.IndexOf(";"));

            if (eweAdostring.ToLower() != epiDBstring.ToLower())
            {
                pRequestMessage.IsSqlProject = false;
            }
        }
Exemplo n.º 18
0
        public List <SurveyInfoBO> GetSurveyInfoByOrgKey(string SurveyId, string Okey)
        {
            List <SurveyInfoBO> result = new List <SurveyInfoBO>();

            List <SurveyMetaData> responseList = new List <SurveyMetaData>();

            int OrganizationId = 0;

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Organizations
                                 where response.OrganizationKey == Okey
                                 select response).SingleOrDefault();

                    if (Query != null)
                    {
                        OrganizationId = Query.OrganizationId;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            if (!string.IsNullOrEmpty(SurveyId))
            {
                try
                {
                    Guid Id = new Guid(SurveyId);
                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        responseList.Add(Context.SurveyMetaDatas.FirstOrDefault(x => x.SurveyId == Id && x.OrganizationId == OrganizationId));
                        if (responseList[0] != null)
                        {
                            result = Mapper.Map(responseList);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }

            return(result);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Inserts a new Organization.
        /// </summary>
        /// <remarks>
        /// Following insert, Organization object will contain the new identifier.
        /// </remarks>
        /// <param name="Organization">Organization.</param>
        public void InsertOrganization(OrganizationBO Organization)
        {
            try{
                using (var Context = DataObjectFactory.CreateContext())
                {
                    Organization OrganizationEntity = Mapper.ToEF(Organization);
                    Context.AddToOrganizations(OrganizationEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 20
0
        public List <SurveyInfoBO> GetAllSurveysByOrgKey(string Okey)
        {
            List <SurveyInfoBO> result = new List <SurveyInfoBO>();

            List <SurveyMetaData> responseList = new List <SurveyMetaData>();

            int OrganizationId = 0;

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Organizations
                                 where response.OrganizationKey == Okey
                                 select response).SingleOrDefault();

                    if (Query != null)
                    {
                        OrganizationId = Query.OrganizationId;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }


            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    responseList = Context.SurveyMetaDatas.Where(x => x.OrganizationId == OrganizationId).ToList();
                    if (responseList.Count() > 0 && responseList[0] != null)
                    {
                        result = Mapper.Map(responseList);
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }


            return(result);
        }
Exemplo n.º 21
0
        public void InsertConnectionString(DbConnectionStringBO ConnectionString)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    //Context.usp_AddDatasource(ConnectionString.DatasourceServerName, ConnectionString.DatabaseType, ConnectionString.InitialCatalog, ConnectionString.PersistSecurityInfo, ConnectionString.DatabaseUserID, ConnectionString.SurveyId, ConnectionString.Password);

                    //Context.SaveChanges();
                    Context.AddToEIDatasources(Mapper.Map(ConnectionString));
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Gets a specific SurveyResponse.
        /// </summary>
        /// <param name="SurveyResponseId">Unique SurveyResponse identifier.</param>
        /// <returns>SurveyResponse.</returns>
        public List <SurveyResponseBO> GetSurveyResponse(List <string> SurveyResponseIdList, Guid UserPublishKey, int PageNumber = -1, int PageSize = -1)
        {
            List <SurveyResponseBO> result = new List <SurveyResponseBO>();

            if (SurveyResponseIdList.Count > 0)
            {
                foreach (string surveyResponseId in SurveyResponseIdList.Distinct())
                {
                    Guid Id = new Guid(surveyResponseId);

                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        result.Add(Mapper.Map(Context.SurveyResponses.FirstOrDefault(x => x.ResponseId == Id)));
                    }
                }
            }
            else
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    result = Mapper.Map(Context.SurveyResponses.ToList());
                }
            }

            if (PageNumber > 0 && PageSize > 0)
            {
                result.Sort(CompareByDateCreated);
                // remove the items to skip
                if (PageNumber * PageSize - PageSize > 0)
                {
                    result.RemoveRange(0, PageSize);
                }

                if (PageNumber * PageSize < result.Count)
                {
                    result.RemoveRange(PageNumber * PageSize, result.Count - PageNumber * PageSize);
                }
            }


            return(result);
        }
Exemplo n.º 23
0
        public void InsertAdminInfo(AdminBO Admin)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    Admin AdminEntity = Mapper.ToEF(Admin);



                    Context.AddToAdmins(AdminEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Updates a Organization.
        /// </summary>
        /// <param name="Organization">Organization.</param>
        public void UpdateOrganization(OrganizationBO Organization)
        {
            ////Update Survey
            try{
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from response in Context.Organizations
                                where response.OrganizationKey == Organization.OrganizationKey
                                select response;

                    var DataRow = Query.Single();
                    DataRow.Organization1 = Organization.Organization;

                    DataRow.IsEnabled = Organization.IsEnabled;
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Updates a SurveyInfo.
        /// </summary>
        /// <param name="SurveyInfo">SurveyInfo.</param>
        public void UpdateSurveyInfo(SurveyInfoBO SurveyInfo)
        {
            try
            {
                Guid Id = new Guid(SurveyInfo.SurveyId);

                //Update Survey
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from response in Context.SurveyMetaDatas
                                where response.SurveyId == Id
                                select response;

                    var DataRow = Query.Single();
                    DataRow.SurveyName       = SurveyInfo.SurveyName;
                    DataRow.SurveyNumber     = SurveyInfo.SurveyNumber;
                    DataRow.TemplateXML      = SurveyInfo.XML;
                    DataRow.IntroductionText = SurveyInfo.IntroductionText;
                    DataRow.ExitText         = SurveyInfo.ExitText;
                    DataRow.OrganizationName = SurveyInfo.OrganizationName;
                    DataRow.DepartmentName   = SurveyInfo.DepartmentName;
                    DataRow.ClosingDate      = SurveyInfo.ClosingDate;
                    DataRow.SurveyTypeId     = SurveyInfo.SurveyType;
                    DataRow.UserPublishKey   = SurveyInfo.UserPublishKey;
                    DataRow.TemplateXMLSize  = RemoveWhitespace(SurveyInfo.XML).Length;
                    DataRow.IsDraftMode      = SurveyInfo.IsDraftMode;
                    DataRow.StartDate        = SurveyInfo.StartDate;
                    DataRow.LastUpdate       = DateTime.Now;
                    DataRow.IsSQLProject     = SurveyInfo.IsSqlProject;

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 26
0
        public void UpdateConnectionString(DbConnectionStringBO ConnectionString)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from DataSource in Context.EIDatasources
                                where DataSource.SurveyId == ConnectionString.SurveyId
                                select DataSource;

                    var DataRow = Query.Single();
                    DataRow = Mapper.Map(ConnectionString);



                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Inserts a new ErrorLog.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="pValue">ErrorText.</param>
        public void InsertErrorLog(Dictionary <string, string> pValue)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    ErrorLog ErrorLogEntity = new ErrorLog();
                    ErrorLogEntity.ErrorDate = DateTime.Now;
                    ErrorLogEntity.Comment   = "SurveyAPI Error";
                    StringBuilder ErrText = new StringBuilder();
                    foreach (KeyValuePair <string, string> kvp in  pValue)
                    {
                        if (kvp.Key == "SurveyId")
                        {
                            ErrorLogEntity.SurveyId = new Guid(kvp.Value.ToString());
                        }
                        else if (kvp.Key == "ResponseId")
                        {
                            ErrorLogEntity.ResponseId = new Guid(kvp.Value.ToString());
                        }
                        else
                        {
                            ErrText.Append(" " + kvp.Key + " " + kvp.Value + ". ");
                        }
                    }
                    ErrorLogEntity.ErrorText = ErrText.ToString();

                    Context.AddToErrorLogs(ErrorLogEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Inserts a new SurveyResponse.
        /// </summary>
        /// <remarks>
        /// Following insert, SurveyResponse object will contain the new identifier.
        /// </remarks>
        /// <param name="SurveyResponse">SurveyResponse.</param>
        public void InsertSurveyResponse(SurveyResponseBO SurveyResponse)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    SurveyResponse SurveyResponseEntity = Mapper.ToEF(SurveyResponse);
                    try
                    {
                        // SurveyResponseEntity.RecordSourceId = Context.lk_RecordSource.Where(u => u.RecordSource == "EIWS").Select(u => u.RecordSourceId).SingleOrDefault();
                    }
                    catch (Exception)
                    {
                    }
                    Context.AddToSurveyResponses(SurveyResponseEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 29
0
        public void UpdatePassCode(UserAuthenticationRequestBO passcodeBO)
        {
            try
            {
                Guid Id = new Guid(passcodeBO.ResponseId);

                //Update Survey
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from response in Context.SurveyResponses
                                where response.ResponseId == Id
                                select response;

                    var DataRow = Query.Single();

                    DataRow.ResponsePasscode = passcodeBO.PassCode;
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 30
0
        public UserAuthenticationResponseBO GetAuthenticationResponse(UserAuthenticationRequestBO UserAuthenticationRequestBO)
        {
            UserAuthenticationResponseBO UserAuthenticationResponseBO = Mapper.ToAuthenticationResponseBO(UserAuthenticationRequestBO);

            try
            {
                Guid Id = new Guid(UserAuthenticationRequestBO.ResponseId);


                using (var Context = DataObjectFactory.CreateContext())
                {
                    SurveyResponse surveyResponse = Context.SurveyResponses.First(x => x.ResponseId == Id);
                    if (surveyResponse != null)
                    {
                        UserAuthenticationResponseBO.PassCode = surveyResponse.ResponsePasscode;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(UserAuthenticationResponseBO);
        }