/// <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 = Mapper.ToEF(SurveyInfo);

                    SurveyMetaData Row = Context.SurveyMetaDatas.First(x => x.SurveyId == Id);
                    Row.IsSQLProject     = SurveyInfo.IsSqlProject;
                    Row.TemplateXML      = SurveyInfo.XML;
                    Row.IsDraftMode      = SurveyInfo.IsDraftMode;
                    Row.IsShareable      = SurveyInfo.IsShareable;
                    Row.DataAccessRuleId = SurveyInfo.DataAccessRuleId;
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        public List <ReportInfoBO> GetReport(string ReportID)
        {
            List <ReportInfoBO> ReportInfoBOList = new List <ReportInfoBO>();

            try
            {
                ReportInfoBO ReportInfoBO = new ReportInfoBO();

                var reportid = Guid.Parse(ReportID);

                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = Context.SurveyReportsInfoes.Where(x => x.ReportId == reportid);//.OrderBy(x=>x.GadgetNumber);

                    foreach (var item in Query)
                    {
                        ReportInfoBO = Mapper.ToReportInfoBO(item);
                        ReportInfoBOList.Add(ReportInfoBO);
                    }
                }


                return(ReportInfoBOList);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        /// <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 = Epi.Web.Enter.Common.Security.Cryptography.Encrypt(SurveyInfo.OrganizationKey.ToString());
                        OrganizationId = ContextOrg.Organizations.FirstOrDefault(x => x.OrganizationKey == OrgKey).OrganizationId;
                    }

                    SurveyInfo.TemplateXMLSize = RemoveWhitespace(SurveyInfo.XML).Length;
                    SurveyInfo.DateCreated     = DateTime.Now;



                    var  SurveyMetaDataEntity = Mapper.Map(SurveyInfo);
                    User User = Context.Users.FirstOrDefault(x => x.UserID == SurveyInfo.OwnerId);
                    SurveyMetaDataEntity.Users.Add(User);

                    SurveyMetaDataEntity.OrganizationId = OrganizationId;
                    Context.SurveyMetaDatas.Add(SurveyMetaDataEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        public bool UpdateUserInfo(UserBO User, OrganizationBO OrgBO)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    User user = Context.Users.First(x => x.UserID == User.UserId);
                    // user.UserName = User.UserName;
                    user.EmailAddress = User.EmailAddress;
                    user.FirstName    = User.FirstName;
                    user.LastName     = User.LastName;

                    UserOrganization UserOrganization = Context.UserOrganizations.First(x => x.OrganizationID == OrgBO.OrganizationId && x.UserID == User.UserId);
                    UserOrganization.RoleId = User.Role;
                    UserOrganization.Active = User.IsActive;

                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        public bool InsertUser(UserBO User, OrganizationBO OrgBO)
        {
            try
            {
                User.UGuid = Guid.NewGuid();
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Org = Context.Organizations.Where(x => x.OrganizationId == OrgBO.OrganizationId).Single();

                    Context.Organizations.Attach(Org);



                    Context.Users.AddObject(Mapper.ToUserEntity(User));

                    UserOrganization UserOrganizationEntity = Mapper.ToUserOrganizationEntity(User, OrgBO);
                    Context.UserOrganizations.AddObject(UserOrganizationEntity);



                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Esempio n. 6
0
        public List <UserBO> GetOrgAdminsByFormId(string FormId)
        {
            List <UserBO>            BoList       = new List <UserBO>();
            Dictionary <int, string> GetOrgAdmins = new Dictionary <int, string>();
            Guid Id = new Guid(FormId);

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    SurveyMetaData Response = Context.SurveyMetaDatas.First(x => x.SurveyId == Id);
                    var            _Org     = new HashSet <int>(Response.Organizations.Select(x => x.OrganizationId));
                    var            Orgs     = Context.Organizations.Where(t => _Org.Contains(t.OrganizationId)).ToList();


                    foreach (var Org in Orgs)
                    {
                        var AdminList = Context.UserOrganizations.Where(x => x.OrganizationID == Org.OrganizationId && x.RoleId == 2 && x.Active == true);
                        foreach (var Admin in AdminList)
                        {
                            UserBO UserBO = new UserBO();
                            UserBO.EmailAddress = Admin.User.EmailAddress;
                            UserBO.UserId       = Admin.User.UserID;
                            BoList.Add(UserBO);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(BoList);
        }
Esempio n. 7
0
        public Dictionary <int, string> GetOrgAdmins(Dictionary <int, string> SelectedOrgList)
        {
            Dictionary <int, string> GetOrgAdmins = new Dictionary <int, string>();

            int i = 0;

            try
            {
                foreach (var org in SelectedOrgList)
                {
                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        int OrgId = int.Parse(org.Value);

                        var AdminList = Context.UserOrganizations.Where(x => x.OrganizationID == OrgId && x.RoleId == 2 && x.Active == true).ToList();

                        foreach (var item in AdminList)
                        {
                            GetOrgAdmins.Add(i, item.User.EmailAddress);
                            i++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }


            return(GetOrgAdmins);
        }
Esempio n. 8
0
        public FormSettingBO GetFormSettings()
        {
            FormSettingBO FormSettingBO = new FormSettingBO();

            Dictionary <int, string>    DataAccessRuleIds         = new Dictionary <int, string>();
            Dictionary <string, string> DataAccessRuleDescription = new Dictionary <string, string>();
            int selectedDataAccessRuleId = -1;;
            var Context = DataObjectFactory.CreateContext();

            try
            {
                ////  Available DataAccess Rule Ids  list

                IQueryable <DataAccessRule> RuleIDs = Context.DataAccessRules.ToList().AsQueryable();
                foreach (var Rule in RuleIDs)
                {
                    DataAccessRuleIds.Add(Rule.RuleId, Rule.RuleName);
                    DataAccessRuleDescription.Add(Rule.RuleName, Rule.RuleDescription);
                }

                FormSettingBO.SelectedDataAccessRule    = selectedDataAccessRuleId;
                FormSettingBO.DataAccessRuleDescription = DataAccessRuleDescription;
                FormSettingBO.DataAccessRuleIds         = DataAccessRuleIds;
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(FormSettingBO);
        }
Esempio n. 9
0
        public void UpDateFormMode(FormInfoBO FormInfoBO)
        {
            try
            {
                Guid Id = new Guid(FormInfoBO.FormId);

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

                    var DataRow = Query.Single();
                    DataRow.IsDraftMode      = FormInfoBO.IsDraftMode;
                    DataRow.IsShareable      = FormInfoBO.IsShareable;
                    DataRow.DataAccessRuleId = FormInfoBO.DataAccesRuleId;

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Esempio n. 10
0
        public void UpDateColumnNames(FormSettingBO FormSettingBO, string FormId)
        {
            Guid Id = new Guid(FormId);

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    IQueryable <ResponseDisplaySetting> ColumnList = Context.ResponseDisplaySettings.Where(x => x.FormId == Id);

                    //Delete old columns
                    foreach (var item in ColumnList)
                    {
                        Context.ResponseDisplaySettings.DeleteObject(item);
                    }
                    Context.SaveChanges();

                    //insert new columns

                    ResponseDisplaySetting ResponseDisplaySettingEntity = new ResponseDisplaySetting();
                    foreach (var item in FormSettingBO.ColumnNameList)
                    {
                        ResponseDisplaySettingEntity = Mapper.ToColumnName(item, Id);
                        Context.AddToResponseDisplaySettings(ResponseDisplaySettingEntity);
                        //Context.SaveChanges();
                    }
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Esempio n. 11
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 Common.BusinessObject.AdminBO();
                        AdminBO.AdminEmail = row.response.AdminEmail;
                        AdminBO.IsActive   = row.response.IsActive;

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

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



            return(AdminList);
        }
        public void UpdateSettingsList(FormSettingBO formSettingBO, string formId, int CurrentOrg = -1)
        {
            Guid id = new Guid(formId);

            try
            {
                using (var context = DataObjectFactory.CreateContext())
                {
                    SurveyMetaData response = context.SurveyMetaDatas.First(x => x.SurveyId == id);

                    //Remove old Users
                    var userHashSet = new HashSet <string>(response.Users.Select(x => x.UserName));
                    var users       = context.Users.Where(t => userHashSet.Contains(t.UserName)).ToList();

                    foreach (User user in users)
                    {
                        if (user.UserOrganizations.Where(x => x.OrganizationID == CurrentOrg).Count() > 0)
                        {
                            response.Users.Remove(user);
                        }
                    }
                    context.SaveChanges();

                    //insert new users
                    foreach (var item in formSettingBO.AssignedUserList)
                    {
                        User User = context.Users.FirstOrDefault(x => x.UserName == item.Value);
                        response.Users.Add(User);
                    }
                    context.SaveChanges();

                    //Remove old Orgs
                    var orgHashSet = new HashSet <int>(response.Organizations.Select(x => x.OrganizationId));
                    var orgs       = context.Organizations.Where(t => orgHashSet.Contains(t.OrganizationId)).ToList();

                    foreach (Organization org in orgs)
                    {
                        response.Organizations.Remove(org);
                    }
                    context.SaveChanges();

                    //insert new Orgs
                    List <User> orgAdmins = new List <User>();

                    foreach (var item in formSettingBO.SelectedOrgList)
                    {
                        int          orgId = int.Parse(item.Value);
                        Organization org   = context.Organizations.FirstOrDefault(x => x.OrganizationId == orgId);
                        response.Organizations.Add(org);
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Esempio n. 13
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())
                        {
                            var response = Context.SurveyMetaDatas.FirstOrDefault(x => x.SurveyId == Id);
                            result.Add(Mapper.Map(response));
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }
            else
            {
                try
                {
                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        result.Add(Mapper.Map(Context.SurveyMetaDatas.First()));
                    }
                }
                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);
        }
Esempio n. 14
0
        public bool IsUserActive(int UserID, int OrganizationId)
        {
            using (var Context = DataObjectFactory.CreateContext())
            {
                var _User = Context.UserOrganizations.Where(x => x.UserID == UserID && x.OrganizationID == OrganizationId).Single();

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



                    Context.Admins.Add(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.Addresses.Add(AddressEntity);

                Context.SaveChanges();
            }
        }
Esempio n. 16
0
        public List <OrganizationBO> GetOrganizationInfoForAdmin(int UserId, int UserRole)
        {
            List <OrganizationBO> result = new List <OrganizationBO>();


            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    if (UserRole == 3)
                    {
                        var Query = from OrganizationTable in Context.Organizations
                                    from UserOrganizationTable in Context.UserOrganizations

                                    where UserOrganizationTable.OrganizationID == OrganizationTable.OrganizationId &&
                                    UserOrganizationTable.UserID == UserId &&
                                    UserOrganizationTable.RoleId >= 2 &&
                                    UserOrganizationTable.Active == true &&
                                    OrganizationTable.IsEnabled == true
                                    select OrganizationTable;

                        var DataRow = Query.Distinct();
                        foreach (var Row in DataRow)
                        {
                            result.Add(Mapper.Map(Row));
                        }

                        return(result);
                    }
                    else
                    {
                        var Query = from OrganizationTable in Context.Organizations
                                    from UserOrganizationTable in Context.UserOrganizations

                                    where UserOrganizationTable.OrganizationID == OrganizationTable.OrganizationId &&
                                    UserOrganizationTable.UserID == UserId &&
                                    UserOrganizationTable.RoleId == 2 &&
                                    UserOrganizationTable.Active == true &&
                                    OrganizationTable.IsEnabled == true
                                    select OrganizationTable;

                        var DataRow = Query.Distinct();
                        foreach (var Row in DataRow)
                        {
                            result.Add(Mapper.Map(Row));
                        }

                        return(result);
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        public UserBO GetCurrentUser(int UserId)
        {
            UserBO Result = new UserBO();

            using (var Context = DataObjectFactory.CreateContext())
            {
                Result = Mapper.MapToUserBO(Context.Users.Single(x => x.UserID == UserId));
            }



            return(Result);
        }
        public bool UpdateUserOrganization(UserBO User, OrganizationBO OrgBO)
        {
            UserOrganization UserOrganizationEntity = Mapper.ToUserOrganizationEntity(User, OrgBO);

            using (var Context = DataObjectFactory.CreateContext())
            {
                UserOrganizationEntity.UserID = User.UserId;
                Context.UserOrganizations.Add(UserOrganizationEntity);
                Context.SaveChanges();

                return(true);
            }
        }
Esempio n. 19
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);
        }
        public bool IsUserExistsInOrganization(string OrgKey, int UserId)
        {
            var Context   = DataObjectFactory.CreateContext();
            var UserQuery = from userorganization in Context.UserOrganizations
                            join organization in Context.Organizations on userorganization.OrganizationID equals organization.OrganizationId
                            where userorganization.UserID == UserId && organization.OrganizationKey == OrgKey
                            select userorganization;
            bool Result = false;

            foreach (var user in UserQuery)
            {
                Result = true;
            }
            return(Result);
        }
Esempio n. 21
0
        public UserBO GetUserByUserId(UserBO User)
        {
            var Context   = DataObjectFactory.CreateContext();
            var UserQuery = from Users in Context.Users
                            where Users.UserID == User.UserId
                            select Users;
            UserBO Result = new UserBO();

            foreach (var user in UserQuery)
            {
                Result = Mapper.MapToUserBO(user);
            }

            return(Result);
        }
        public bool IsUserExistsInOrganizaion(UserBO User, OrganizationBO OrgBO)
        {
            var Context   = DataObjectFactory.CreateContext();
            var UserQuery = from userorganization in Context.UserOrganizations
                            where userorganization.UserID == User.UserId && userorganization.OrganizationID == OrgBO.OrganizationId
                            select userorganization;
            bool Result = false;

            foreach (var user in UserQuery)
            {
                Result = true;
            }

            return(Result);
        }
        public bool GetExistingUser(UserBO User)
        {
            var Context   = DataObjectFactory.CreateContext();
            var UserQuery = from user in Context.Users
                            where user.UserName == User.UserName && user.LastName == User.LastName && user.EmailAddress == User.EmailAddress
                            select user;
            bool Result = false;

            foreach (var user in UserQuery)
            {
                Result = true;
            }

            return(Result);
        }
Esempio n. 24
0
        public UserBO GetUserByEmail(UserBO User)
        {
            var Context   = DataObjectFactory.CreateContext();
            var UserQuery = from Users in Context.Users
                            where Users.EmailAddress == User.EmailAddress
                            select Users;
            UserBO Result = new UserBO();

            foreach (var user in UserQuery)
            {
                Result = Mapper.MapToUserBO(user);
                return(Result);
            }

            return(null);
        }
Esempio n. 25
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.Organizations.Add(OrganizationEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
 public bool UpdateUserPassword(UserBO User)
 {
     try
     {
         var Context = DataObjectFactory.CreateContext();
         var user    = Context.Users.Single(a => a.UserName == User.UserName);
         user.PasswordHash  = User.PasswordHash;
         user.ResetPassword = User.ResetPassword;
         Context.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
        public UserBO GetUser(UserBO User)
        {
            var Context   = DataObjectFactory.CreateContext();
            var UserQuery = from user in Context.Users
                            where user.UserName == User.UserName && user.PasswordHash == User.PasswordHash
                            select user;
            UserBO Result = new UserBO();

            foreach (var user in UserQuery)
            {
                Result = Mapper.MapToUserBO(user);
                return(Result);
            }

            return(null);
        }
Esempio n. 28
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();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Esempio n. 29
0
        public void InsertFormdefaultSettings(string FormId, bool IsSqlProject, List <string> ControlsNameList)
        {
            try
            {
                //Delete old columns
                using (var Context = DataObjectFactory.CreateContext())
                {
                    Guid Id = new Guid(FormId);
                    IQueryable <ResponseDisplaySetting> ColumnList = Context.ResponseDisplaySettings.Where(x => x.FormId == Id);


                    foreach (var item in ColumnList)
                    {
                        Context.ResponseDisplaySettings.Remove(item);
                    }
                    Context.SaveChanges();
                }
                // Adding new columns
                List <string> ColumnNames = new List <string>();
                if (!IsSqlProject)
                {
                    ColumnNames = MetaDaTaColumnNames();
                }
                else
                {
                    ColumnNames = ControlsNameList;
                }
                int i = 1;
                foreach (string Column in ColumnNames)
                {
                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        ResponseDisplaySetting SettingEntity = Mapper.Map(FormId, i, Column);

                        Context.ResponseDisplaySettings.Add(SettingEntity);

                        Context.SaveChanges();
                    }
                    i++;
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Esempio n. 30
0
        public List <ReportInfoBO> GetSurveyReports(string SurveyID, bool IncludHTML)
        {
            try
            {
                var surveyid             = Guid.Parse(SurveyID);
                List <ReportInfoBO> List = new List <ReportInfoBO>();
                using (var Context = DataObjectFactory.CreateContext())
                {
                    if (IncludHTML)
                    {
                        var Query = Context.SurveyReportsInfoes.Where(x => x.SurveyId == surveyid);

                        foreach (var item in Query)
                        {
                            List.Add(Mapper.ToReportInfoBO(item));
                        }
                    }
                    else
                    {
                        var NoHtmlQuery = (from response in Context.SurveyReportsInfoes
                                           where response.SurveyId == surveyid
                                           select new { response.ReportId, response.ReportVersion, response.DateCreated, response.DateEdited, response.DataSource, response.RecordCount });
                        foreach (var reportInfo in NoHtmlQuery)
                        {
                            ReportInfoBO ReportInfoBO = new ReportInfoBO();
                            ReportInfoBO.CreatedDate = reportInfo.DateCreated;
                            ReportInfoBO.EditedDate  = (DateTime)reportInfo.DateEdited;
                            if (!string.IsNullOrEmpty(reportInfo.ReportId.ToString()))
                            {
                                ReportInfoBO.ReportId = reportInfo.ReportId.ToString();
                            }
                            ReportInfoBO.DataSource    = reportInfo.DataSource;
                            ReportInfoBO.RecordCount   = reportInfo.RecordCount;
                            ReportInfoBO.ReportVersion = reportInfo.ReportVersion;

                            List.Add(ReportInfoBO);
                        }
                    }
                }
                return(List);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }