コード例 #1
0
        public ActionResult CreateEdit(user user, FormCollection frm, HttpPostedFileBase user_photo)
        {
            try
            {
                string rol_id       = frm["rol_id"];
                string hdnUserPhoto = frm["hdnUserPhoto"];
                if (user_photo != null)
                {
                    string AWSProfileName    = STUtil.GetWebConfigValue("AWSProfileName");
                    string GenFileName       = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + SessionUtil.GetCompanyID().ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_");
                    String companyFolderName = STUtil.GetSessionValue(UserInfo.CompanyFolderName.ToString()).ToString().Replace("/", "");
                    user.user_photo = GenFileName;
                }
                else
                {
                    user.user_photo = hdnUserPhoto != null ? (hdnUserPhoto != "" ? hdnUserPhoto : user.gender + ".JPG") : user.gender + ".JPG";
                }
                result              = userUtil.PostCreateEdit(user, frm);
                ViewBag.Title       = user == null ? "User Create" : "User Edit";
                ViewBag.action_name = STUtil.GetListAllActionByController("");
                switch (result.MessageType)
                {
                case MessageType.Success:
                    return(RedirectToAction("Index", "User", new { id = rol_id, Result = result.Message, MessageType = result.MessageType }));

                default:
                    return(RedirectToAction("CreateEdit", "User", new { id = user.user_id, Result = result.Message, MessageType = result.MessageType }));
                }
                return(View(user));
            }
            catch (Exception ex)
            {
                return(View(user));
            }
        }
コード例 #2
0
        public ActionResult UserEdit(string id)
        {
            var     userList   = db.users.AsEnumerable().Where(u => u.user_id == Convert.ToInt32(id)).ToList();
            int     company_id = userList.FirstOrDefault().company_id;
            company company    = new company();

            company = company_id > 0 ? db.companies.Find(company_id) : company;
            string SNAG_ImagePath    = STUtil.GetWebConfigValue("ImagePath");
            String companyFolderName = company.company_folder_name != null?company.company_folder_name.ToString() : "";

            var UserPhoto = userList.FirstOrDefault().user_photo != null ? SNAG_ImagePath + companyFolderName + userList.FirstOrDefault().user_photo : SNAG_ImagePath + userList.FirstOrDefault().user_photo;
            var data      = (from u in userList
                             select new
            {
                user_id = u.user_id,
                user_name = u.user_name,
                login_id = u.login_id,
                email_id = u.email_id,
                mobile = u.mobile,
                gender = u.gender,
                parent_id = u.role_bit,
                role_bit = u.role_bit,
                is_active = u.is_active,
                UserPhoto = UserPhoto,
                hdnUserPhoto = u.user_photo
            }).FirstOrDefault();

            return(Json(data));
        }
コード例 #3
0
 public ActionResult CreateEditAdmin(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser)
 {
     try
     {
         var     userid             = user.user_id;
         user    UserInformation    = db.users.Find(userid);
         company CompanyInformation = db.companies.Find(UserInformation.company_id);
         if (user_photo != null)
         {
             string AWSProfileName    = STUtil.GetWebConfigValue("AWSProfileName");
             string GenFileName       = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_");
             String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", "");
             // AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName);
             UserInformation.user_photo = GenFileName;
         }
         UserInformation.user_name = user.user_name;
         UserInformation.mobile    = user.mobile;
         UserInformation.gender    = user.gender;
         result = companyUtil.PostUserEdit(UserInformation);
     }
     catch (Exception ex)
     {
         result.Message = ex.Message;
     }
     return(RedirectToAction("EditCompany", "CompanySetting", new { id = user.company_id, Result = result.Message, MessageType = result.MessageType }));
 }
コード例 #4
0
        public ActionResult LoadAdminUser(int id)
        {
            int user_id    = 0;
            int company_id = Convert.ToInt32(id);

            company company = new company();

            company = company_id > 0 ? db.companies.Find(company_id) : company;
            user user = new user();

            if (company != null)
            {
                string SNAG_ImagePath    = STUtil.GetWebConfigValue("ImagePath");
                String companyFolderName = company.company_folder_name != null?company.company_folder_name.ToString() : "";

                #region EditAdminUser
                user_id         = Convert.ToInt32(company.users.Count() > 0 ? company.users.FirstOrDefault().user_id : 0);
                user            = user_id > 0 ? db.users.Find(user_id) : user;
                user.company_id = company_id;
                if (user != null)
                {
                    ViewBag.UserPhoto = user.user_photo != string.Concat(user.gender, ".JPG") ? SNAG_ImagePath + companyFolderName + user.user_photo : SNAG_ImagePath + user.user_photo;
                }
                ViewBag.company_logo = company.company_logo != "NA.JPG" ? SNAG_ImagePath + companyFolderName + company.company_logo : SNAG_ImagePath + company.company_logo;
                #endregion
            }
            return(PartialView("_CompanyAdminUser", user));
        }
コード例 #5
0
 public ActionResult CreateEditUser(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser)
 {
     try
     {
         user.role_id = String.IsNullOrEmpty(frmAdminUser["role_id"]) ? 0 : Convert.ToInt32(frmAdminUser["role_id"]);
         var     userdata           = db.users.Find(user.user_id);
         company CompanyInformation = db.companies.Find(user.company_id);
         if (user_photo != null)
         {
             string AWSProfileName    = STUtil.GetWebConfigValue("AWSProfileName");
             string GenFileName       = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_");
             String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", "");
             //// AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName);
             user.user_photo = GenFileName;
         }
         else
         {
             user.user_photo = userdata != null ? userdata.user_photo : "NA.jpg";
         }
         user.parent_user_id = SessionUtil.GetUserID();
         result = userUtil.PostUserEdit(user);
     }
     catch (Exception ex)
     {
         result.Message     = ex.Message;
         result.MessageType = MessageType.Error;
     }
     return(RedirectToAction("Index", "User", new { id = String.Format("{0},{1}", user.role_id, user.role_bit), Result = result.Message, MessageType = result.MessageType }));
 }
コード例 #6
0
        public ActionResult CreateEdit(company company, HttpPostedFileBase company_logo, FormCollection frmUser)
        {
            try
            {
                string  AWSProfileName     = STUtil.GetWebConfigValue("AWSProfileName");
                string  SystemImagePath    = STUtil.GetWebConfigValue("SystemImagePath");
                company CompanyInformation = db.companies.Find(company.company_id);
                if (company_logo != null)
                {
                    string GenFileName       = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(company_logo.FileName).Replace(" ", "_");
                    String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", "");
                    //// AWSUtil.UploadFile(company_logo.InputStream, AWSProfileName, companyFolderName, GenFileName);
                    CompanyInformation.company_logo = GenFileName;
                    UploadFile(companyFolderName, company_logo);
                }
                CompanyInformation.business_name = company.business_name;
                CompanyInformation.licence_no    = company.licence_no;
                //CompanyInformation.application_type_id = company.application_type_id;
                CompanyInformation.time_zone    = company.time_zone;
                CompanyInformation.country_code = company.country_code;
                CompanyInformation.phone        = company.phone;
                CompanyInformation.state_id     = company.state_id;
                CompanyInformation.city         = company.city;
                CompanyInformation.address      = company.address;
                CompanyInformation.zip          = company.zip;
                CompanyInformation.is_active    = company.is_active;

                db.Entry(CompanyInformation).State = System.Data.Entity.EntityState.Modified;
                result.Message = string.Format(BaseConst.MSG_SUCCESS_UPDATE, "Company");
                STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "0");
                db.SaveChanges();

                #region FolderCreation
                string ImagePath = STUtil.GetWebConfigValue("ImagePath");
                //AWSUtil.FolderCreation(AWSProfileName, companyInfo.company_folder_name);
                #endregion

                STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1");
            }
            catch (Exception ex)
            {
                STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1");
                result.Message = ex.Message;
            }
            return(RedirectToAction("EditCompany", "Company", new { id = company.company_id, Result = result.Message, MessageType = result.MessageType }));
        }
コード例 #7
0
        public ActionResult CompanyList()
        {
            var path = RoleUtil.IsInRole(Role.SuperAdmin)?STUtil.GetWebConfigValue("SystemImagePath"):SessionUtil.GetCompanyFolderName().ToString();
            //var list = db.companies.Where(x => x.parent_company_id != null).AsEnumerable().ToList();
            var list = db.companies.AsEnumerable().ToList();
            var data = (from li in list
                        select new
            {
                company_id = li.company_id,
                business_name = li.business_name,
                admin_user_name = li.admin_user_name,
                address = li.state != null ? li.address + ", " + li.city + ", " + li.zip + ", " + li.state.state_name + ", " + li.state.country.country_name : "",
                image = AWSUtil.GetFileURL(li.company_logo, li.company_folder_name),
                is_active = li.is_active,
            }).ToList();

            return(Json(data));
        }
コード例 #8
0
        public ActionResult CreateEditClient(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser)
        {
            var isRole = frmAdminUser["IsJob"];
            var JobId  = frmAdminUser["hdnJobId"] == ""?0:Convert.ToInt32(frmAdminUser["hdnJobId"]);

            try
            {
                user.role_bit = (Int32)Role.Client;
                user.role_id  = db.roles.AsEnumerable().Where(x => x.role_bit == (Int32)Role.Client && x.company_id == (Int32)SessionUtil.GetCompanyID()).FirstOrDefault().role_id;
                var role = db.roles.AsEnumerable().Where(x => x.company_id == user.company_id && x.role_bit == (Int32)Role.Client && x.is_active).ToList();
                user.role_id = role.Count > 0 ? role.Select(x => x.role_id).FirstOrDefault() : 0;
                var     userdata           = db.users.Find(user.user_id);
                company CompanyInformation = db.companies.Find(user.company_id);
                if (user_photo != null)
                {
                    string AWSProfileName    = STUtil.GetWebConfigValue("AWSProfileName");
                    string GenFileName       = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_");
                    String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", "");
                    //// AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName);
                    user.user_photo = GenFileName;
                    UploadFile(SessionUtil.GetCompanyFolderName().ToString(), user_photo);
                }
                else
                {
                    user.user_photo = userdata != null ? userdata.user_photo : "NA.jpg";
                }
                user.parent_user_id = SessionUtil.GetUserID();
                result = userUtil.PostUserEdit(user);
            }
            catch (Exception ex)
            {
                result.Message     = ex.Message;
                result.MessageType = MessageType.Error;
            }
            if (string.IsNullOrEmpty(isRole))
            {
                return(RedirectToAction("Index", "Client", new { Result = result.Message, MessageType = result.MessageType }));
            }
            else
            {
                return(RedirectToAction("CreateEditJob", "Job", new { id = JobId, Result = result.Message, MessageType = result.MessageType }));
            }
        }
コード例 #9
0
 public ActionResult AddCompany(company company, HttpPostedFileBase company_logo, FormCollection frmUser)
 {
     try
     {
         string AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName");
         string userName       = frmUser["user_name"];
         string loginID        = frmUser["login_id"];
         string emailID        = frmUser["email_id"];
         string mobile         = frmUser["mobile"];
         string password       = frmUser["password"];
         string gender         = frmUser["gender"];
         STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1");
         result = companyUtil.PostCompanyCreateEdit(company, company_logo, userName, loginID, emailID, mobile, gender, password);
         var companyEdit = db.companies.Find(company.company_id);
         //if (company_logo != null)
         //{
         //    string fileName = string.Empty;
         //
         //    String companyFolderName = companyEdit.company_folder_name.Replace("/", "");
         //    fileName = company.company_logo;
         //    var path = Path.Combine(Server.MapPath("~/Files/" + companyFolderName), fileName);
         //    company_logo.SaveAs(path);
         //}
         string GenFileName = "";
         if (company_logo != null)
         {
             GenFileName          = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + company.company_id.ToString() + "_" + Path.GetFileName(company_logo.FileName).Replace(" ", "_");
             company.company_logo = GenFileName;
         }
         UploadFile(companyEdit.company_folder_name, company_logo, GenFileName);
         STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), "1");
     }
     catch (Exception ex)
     {
         STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1");
         result.Message = ex.Message;
     }
     return(RedirectToAction("Index", "Company", new { Result = result.Message, MessageType = result.MessageType }));
 }
コード例 #10
0
        public ActionResult ClientEdit(string id)
        {
            var     userList   = db.users.AsEnumerable().Where(u => u.user_id == Convert.ToInt32(id)).ToList();
            int     company_id = userList.FirstOrDefault().company_id;
            company company    = new company();

            company = company_id > 0 ? db.companies.Find(company_id) : company;
            string SNAG_AWS_S3       = STUtil.GetWebConfigValue("ImagePath");
            String companyFolderName = company.company_folder_name != null?company.company_folder_name.ToString() : "";

            var UserPhoto = userList.FirstOrDefault().user_photo != null ? SNAG_AWS_S3 + companyFolderName + userList.FirstOrDefault().user_photo : SNAG_AWS_S3 + userList.FirstOrDefault().user_photo;
            var data      = (from u in userList
                             select new
            {
                user_id = u.user_id,
                user_name = u.user_name,
                login_id = u.login_id,
                email_id = u.email_id,
                mobile = u.mobile,
                gender = u.gender,
                payment_term_idList = new UserUtil().GetPaymentTermList(),
                payment_term_id = u.payment_term_id,
                parent_id = u.role_bit,
                role_bit = u.role_bit,
                is_active = u.is_active,
                UserPhoto = UserPhoto,
                user_photo = u.user_photo,
                user_photoSRC = AWSUtil.GetFileURL(u.user_photo),
                hdnUserPhoto = u.user_photo,
                role_id = u.role_id,
                gstin_numer = u.gstin_numer,
                billing_address = u.billing_address,
                shipping_address = u.shipping_address,
                payment_terms = u.payment_terms,
            }).FirstOrDefault();

            return(Json(data));
        }
コード例 #11
0
 public ActionResult AddCompany(company company, HttpPostedFileBase company_logo, FormCollection frmUser)
 {
     try
     {
         string AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName");
         string userName       = frmUser["user_name"];
         string loginID        = frmUser["login_id"];
         string emailID        = frmUser["email_id"];
         string mobile         = frmUser["mobile"];
         string password       = frmUser["password"];
         string gender         = frmUser["gender"];
         STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1");
         result = companyUtil.PostCompanyCreateEdit(company, company_logo, userName, loginID, emailID, mobile, gender, password);
         UploadFile(SessionUtil.GetCompanyFolderName().ToString(), company_logo);
         STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), "1");
     }
     catch (Exception ex)
     {
         STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1");
         result.Message = ex.Message;
     }
     return(RedirectToAction("EditCompany", "CompanySetting", new { Result = result.Message, MessageType = result.MessageType }));
 }
コード例 #12
0
        public ActionResult EditProfile(user user, HttpPostedFileBase user_photo)
        {
            try
            {
                if (user_photo != null)
                {
                    string AWSProfileName    = STUtil.GetWebConfigValue("AWSProfileName");
                    string GenFileName       = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + SessionUtil.GetCompanyID().ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_");
                    String companyFolderName = STUtil.GetSessionValue(UserInfo.CompanyFolderName.ToString()).ToString().Replace("/", "");
                    UploadFile(SessionUtil.GetCompanyFolderName().ToString(), user_photo);
                    user.user_photo = GenFileName;
                }
                else
                {
                }
                result = userUtil.PostProfileEdit(user);
                ViewBag.action_name = STUtil.GetListAllActionByController("");
                switch (result.MessageType)
                {
                case MessageType.Success:
                    STUtil.SetSessionValue(UserInfo.FullName.ToString(), Convert.ToString(user.user_name));
                    STUtil.SetSessionValue(UserInfo.Mobile.ToString(), Convert.ToString(user.mobile));
                    STUtil.SetSessionValue(UserInfo.UserPhoto.ToString(), Convert.ToString(user.user_photo));
                    STUtil.SetSessionValue(UserInfo.Gender.ToString(), Convert.ToString(user.gender));

                    return(RedirectToAction("MyProfile", "MyProfile", new { Result = result.Message, MessageType = result.MessageType }));

                default:
                    return(RedirectToAction("MyProfile", "MyProfile", new { Result = result.Message, MessageType = result.MessageType }));
                }
                return(View(user));
            }
            catch
            {
                return(View(user));
            }
        }
コード例 #13
0
 public ActionResult General(int id)
 {
     ViewBag.Title    = STUtil.GetWebConfigValue("APPLICATION_NAME") + " Error";
     ViewBag.SubTitle = "Error";
     return(View(db.app_error_log.Find(id)));
 }
コード例 #14
0
        public ActionResult getinvoice(int id)
        {
            ViewBag.Title = "Invoice";
            var li = db.package_subscription.Where(x => x.package_subscription_id == id).FirstOrDefault();

            ViewBag.admincompany = db.companies.AsEnumerable().Where(x => x.company_id == Convert.ToInt32(STUtil.GetWebConfigValue("COMPANY_ID"))).FirstOrDefault();
            return(View(li));
        }
コード例 #15
0
        public static String CheckUserFrofile(String LoginID, String PWD, Int32 userID = 0)
        {
            String result = "Invalid Login ID or Password ";

            var userInfo = (from U in db.USP_Login(LoginID, PWD, true)
                            select new
            {
                UserID = U.user_id,
                IsActive = U.is_active,
                CompanyActive = U.CompanyActive,
                FullName = U.user_name,
                LoginID = U.email_id,
                Email = U.email_id,
                gender = U.gender,
                Mobile = U.mobile,
                RoleBit = U.role_bit,
                RoleName = U.role_name,
                RoleID = U.role_id,
                CompanyID = U.company_id,
                CompanyName = U.business_name,
                CompanyFolderName = U.company_folder_name,
                company_logo = U.company_logo,

                time_zone = U.time_zone,
                currency_id = (int)U.currency_id,
                currency_name = U.currency_name,
                currency_symbol = U.currency_symbol,
                date_format_id = (int)U.date_format_id,
                date_format_name = U.date_format_name,
                date_format_code_csharp = U.date_format_code_csharp,
                date_format_code_js = U.date_format_code_js,
                time_format_id = (int)U.time_format_id,
                time_format_name = U.time_format_name,
                time_format_code_csharp = U.time_format_code_csharp,
                time_format_code_js = U.time_format_code_js,

                Photo = U.user_photo,

                last_login_date = U.last_login_date,
                password_failed_attempt = U.password_failed_attempt,
                is_account_locked = U.is_account_locked,

                system_company_folder = U.system_company_folder,
                company_doc_file_name = U.company_doc_file_name,

                create_work_order_access_id = U.create_work_order_access_id,
                view_work_order_access_id = U.view_work_order_access_id,
                is_change_requester = U.is_change_requester,
                is_service_provider = U.is_service_provider,

                theme_color = U.theme_color,
            }).FirstOrDefault();

            #region AutoLogin By UserID


            if (userID > 0)
            {
                userInfo = (from U in db.users.AsEnumerable()
                            join C in db.companies.AsEnumerable() on U.company_id equals C.company_id
                            join R in db.roles.AsEnumerable() on U.role_bit equals R.role_bit
                            join CU in db.currencies.AsEnumerable() on C.currency_id equals CU.currency_id into curr
                            from CU in curr.DefaultIfEmpty()
                            join DF in db.date_format.AsEnumerable() on C.date_format_id equals DF.date_format_id into DateFo
                            from DF in DateFo.DefaultIfEmpty()
                            join TF in db.time_format.AsEnumerable() on C.time_format_id equals TF.time_format_id into TimeFo
                            from TF in TimeFo.DefaultIfEmpty()
                            where U.user_id == userID
                            select new
                {
                    UserID = U.user_id,
                    IsActive = U.is_active,
                    CompanyActive = C.is_active,
                    FullName = U.user_name,
                    LoginID = U.email_id,
                    Email = U.email_id,
                    gender = U.gender,
                    Mobile = U.mobile,
                    RoleBit = U.role_bit,
                    RoleName = R.role_name,
                    RoleID = R.role_id,

                    CompanyID = U.company_id,
                    CompanyName = C.business_name,
                    CompanyFolderName = C.company_folder_name,
                    company_logo = C.company_logo,

                    time_zone = C.time_zone,
                    currency_id = CU != null ? CU.currency_id : 0,
                    currency_name = CU != null ? CU.currency_name : "",
                    currency_symbol = CU != null ? CU.currency_symbol : "",

                    date_format_id = DF != null ? DF.date_format_id : 0,
                    date_format_name = DF != null ? DF.date_format_name : "",
                    date_format_code_csharp = DF != null ? DF.date_format_code_csharp : "",
                    date_format_code_js = DF != null ? DF.date_format_code_js : "",

                    time_format_id = TF != null ? TF.time_format_id : 0,
                    time_format_name = TF != null ? TF.time_format_name : "",
                    time_format_code_csharp = TF != null ? TF.time_format_code_csharp : "",
                    time_format_code_js = TF != null ? TF.time_format_code_js : "",

                    Photo = U.user_photo,

                    last_login_date = U.last_login_date,
                    password_failed_attempt = U.password_failed_attempt,
                    is_account_locked = U.is_account_locked,

                    system_company_folder = C.system_company_folder,
                    company_doc_file_name = C.company_doc_file_name,

                    create_work_order_access_id = U.create_work_order_access_id,
                    view_work_order_access_id = U.view_work_order_access_id,
                    is_change_requester = U.is_change_requester,
                    is_service_provider = U.is_service_provider,

                    theme_color = U.theme_color_id == null ? C.theme_color.theme_css : U.theme_color.theme_css,
                }).FirstOrDefault();
            }
            #endregion
            if (userInfo == null)
            {
                var userRecord = (from U in db.users
                                  join C in db.companies on U.company_id equals C.company_id
                                  where (U.login_id == LoginID)
                                  select U).FirstOrDefault();
                if (userRecord != null)
                {
                    result = STUtil.UserLoginPolicy(userRecord.user_id, true);
                }
            }
            try
            {
                if (userInfo != null)
                {
                    if (userInfo.is_account_locked)
                    {
                        result = "Your acount has been locked. Due to multiple invalid password ! Please contact to Admin";
                    }
                    else
                    {
                        if (userInfo.IsActive)
                        {
                            STUtil.SetSessionValue(UserInfo.UserID.ToString(), Convert.ToString(userInfo.UserID));
                            STUtil.SetSessionValue(UserInfo.FullName.ToString(), Convert.ToString(userInfo.FullName));

                            STUtil.SetSessionValue(UserInfo.LoginID.ToString(), Convert.ToString(userInfo.LoginID));
                            STUtil.SetSessionValue(UserInfo.EmailID.ToString(), Convert.ToString(userInfo.Email));
                            STUtil.SetSessionValue(UserInfo.Mobile.ToString(), Convert.ToString(userInfo.Mobile));
                            STUtil.SetSessionValue(UserInfo.RoleBit.ToString(), Convert.ToString(userInfo.RoleBit));
                            STUtil.SetSessionValue(UserInfo.RoleID.ToString(), Convert.ToString(userInfo.RoleID));
                            STUtil.SetSessionValue(UserInfo.RoleName.ToString(), Convert.ToString(userInfo.RoleName));
                            STUtil.SetSessionValue(UserInfo.CompanyID.ToString(), Convert.ToString(userInfo.CompanyID));

                            STUtil.SetSessionValue(UserInfo.CompanyName.ToString(), Convert.ToString(userInfo.CompanyName));
                            STUtil.SetSessionValue(UserInfo.CompanyFolderName.ToString(), Convert.ToString(userInfo.CompanyFolderName));
                            STUtil.SetSessionValue(UserInfo.CompanyLogo.ToString(), Convert.ToString(userInfo.company_logo));

                            STUtil.SetSessionValue(UserInfo.UserPhoto.ToString(), Convert.ToString(userInfo.Photo));
                            STUtil.SetSessionValue(UserInfo.Gender.ToString(), Convert.ToString(userInfo.gender.ToUpper()));

                            STUtil.SetSessionValue(UserInfo.time_zone.ToString(), Convert.ToString(userInfo.time_zone));

                            STUtil.SetSessionValue(UserInfo.currency_id.ToString(), Convert.ToString(userInfo.currency_id));
                            STUtil.SetSessionValue(UserInfo.currency_name.ToString(), Convert.ToString(userInfo.currency_name));
                            STUtil.SetSessionValue(UserInfo.currency_symbol.ToString(), Convert.ToString(userInfo.currency_symbol));

                            STUtil.SetSessionValue(UserInfo.date_format_id.ToString(), Convert.ToString(userInfo.date_format_id));
                            STUtil.SetSessionValue(UserInfo.date_format_name.ToString(), Convert.ToString(userInfo.date_format_name));
                            STUtil.SetSessionValue(UserInfo.date_format_code_csharp.ToString(), Convert.ToString(userInfo.date_format_code_csharp));
                            STUtil.SetSessionValue(UserInfo.date_format_code_js.ToString(), Convert.ToString(userInfo.date_format_code_js));

                            STUtil.SetSessionValue(UserInfo.time_format_id.ToString(), Convert.ToString(userInfo.time_format_id));
                            STUtil.SetSessionValue(UserInfo.time_format_name.ToString(), Convert.ToString(userInfo.time_format_name));
                            STUtil.SetSessionValue(UserInfo.time_format_code_csharp.ToString(), Convert.ToString(userInfo.time_format_code_csharp));
                            STUtil.SetSessionValue(UserInfo.time_format_code_js.ToString(), Convert.ToString(userInfo.time_format_code_js));

                            STUtil.SetSessionValue(UserInfo.system_company_folder.ToString(), Convert.ToString(userInfo.system_company_folder));

                            STUtil.SetSessionValue(UserInfo.company_doc_file_name.ToString(), Convert.ToString(userInfo.company_doc_file_name));

                            STUtil.SetSessionValue(UserInfo.create_work_order_access_id.ToString(), Convert.ToString(userInfo.create_work_order_access_id));
                            STUtil.SetSessionValue(UserInfo.view_work_order_access_id.ToString(), Convert.ToString(userInfo.view_work_order_access_id));
                            STUtil.SetSessionValue(UserInfo.is_change_requester.ToString(), Convert.ToString(userInfo.is_change_requester));
                            STUtil.SetSessionValue(UserInfo.is_service_provider.ToString(), Convert.ToString(userInfo.is_service_provider));

                            STUtil.SetSessionValue(UserInfo.theme_color.ToString(), Convert.ToString(userInfo.theme_color));

                            STUtil.SetSessionValue(UserInfo.SERVER_TIME_ZONE.ToString(), STUtil.GetWebConfigValue("SERVER_TIME_ZONE"));

                            STUtil.SetSessionValue(UserInfo.SuperAdmin.ToString(), Convert.ToString(RoleUtil.IsInRole(Role.SuperAdmin, userInfo.RoleBit)));

                            STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), "1");
                            //STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), string.IsNullOrEmpty(userInfo.time_zone) ? "0" : "1");
                            //STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), string.IsNullOrEmpty(userInfo.currency_name) ? "0" : "1");
                            //STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), string.IsNullOrEmpty(userInfo.time_format_name) ? "0" : "1");
                            //STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), string.IsNullOrEmpty(userInfo.date_format_name) ? "0" : "1");
                            //STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), string.IsNullOrEmpty(userInfo.system_company_folder) ? "0" : "1");
                            //STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), userInfo.default_contact_id == null ? "0" : "1");

                            STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1");

                            //STUtil.SetSessionValue(UserInfo.Admin.ToString(), Convert.ToString(RoleUtil.IsInRole(Role.Admin, userInfo.RoleBit)));
                            //STUtil.SetSessionValue(UserInfo.CRMExecutive.ToString(), Convert.ToString(RoleUtil.IsInRole(Role.CRMExecutive, userInfo.RoleBit)));
                            //STUtil.SetSessionValue(UserInfo.Account.ToString(), Convert.ToString(RoleUtil.IsInRole(Role.Account, userInfo.RoleBit)));
                            //STUtil.SetSessionValue(UserInfo.Manager.ToString(), Convert.ToString(RoleUtil.IsInRole(Role.Manager, userInfo.RoleBit)));
                            //STUtil.SetSessionValue(UserInfo.Agent.ToString(), Convert.ToString(RoleUtil.IsInRole(Role.Agent, userInfo.RoleBit)));


                            STUtil.UserLoginPolicy(userInfo.UserID, false);
                            result = "PASS";
                        }
                        else
                        {
                            result = !userInfo.IsActive ? "Your are Inactive! Please contact to Admin" : String.Empty;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //// ExceptionLogging.SendErrorToText(ex);
            }

            return(result);
        }
コード例 #16
0
        public Result PostCompanyCreateEdit(company company, HttpPostedFileBase company_logo, string userName, string loginID, string emailID, string mobile, string gender, string password)
        {
            try
            {
                string  AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName");
                int     userID         = SessionUtil.GetUserID();
                company companyEdit    = new company();
                if (company_logo != null)
                {
                    string GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + company.company_id.ToString() + "_" + Path.GetFileName(company_logo.FileName).Replace(" ", "_");
                    company.company_logo = GenFileName;
                }
                if (company.company_id > 0)
                {
                    companyEdit          = db.companies.Find(company.company_id);
                    company.company_logo = (company.company_logo != "" && company.company_logo != null) ? company.company_logo : (companyEdit.company_logo);
                    var isUpadte = db.USP_UpdateCompany(company.company_id, userID, company.business_name, company.time_zone, company.country_code,
                                                        company.phone, company.state_id, company.city, company.address, company.zip, companyEdit.admin_user_name, company.is_active,
                                                        System.DateTime.Now, company.licence_no, company.company_logo);
                    db.SaveChanges();

                    #region FileUpload
                    if (company_logo != null)
                    {
                        String companyFolderName = companyEdit.company_folder_name.Replace("/", "");
                        //// AWSUtil.UploadFile(company_logo.InputStream, AWSProfileName, companyFolderName, company.company_logo);
                    }
                    #endregion

                    result.Message = string.Format(BaseConst.MSG_SUCCESS_UPDATE, "Company");
                    result.Id      = company.company_id;
                }
                else
                {
                    var companyInfo = db.USP_Create_Company_user_SA(company.time_zone, company.business_name, company.country_code, company.phone,
                                                                    company.address, company.city, company.zip, company.state_id, userName, loginID,
                                                                    mobile, emailID, password, gender, company.licence_no, company.company_logo);
                    db.SaveChanges();
                    result.Message     = string.Format(BaseConst.MSG_SUCCESS_CREATE, "Company");
                    result.MessageType = MessageType.Success;
                    ///result.Id = companyInfo.FirstOrDefault().company_id;
                    #region FolderCreation
                    //string company_folder_name = companyInfo.FirstOrDefault().company_folder_name;
                    //string company_folder_name = "COMPANY_73_20180719/";
                    //////AWSUtil.FolderCreation(AWSProfileName, company_folder_name);
                    #endregion

                    #region FileUpload
                    if (company_logo != null)
                    {
                        // String companyFolderName = company_folder_name.Replace("/", "");
                        //    AWSUtil.UploadFile(company_logo.InputStream, AWSProfileName,  companyFolderName, company.company_logo);
                    }
                    #endregion


                    //#region SendMail
                    //string EMAIL_TEMPALTE_FOLDER = STUtil.GetWebConfigValue("EMAIL_TEMPALTE_FOLDER");
                    //var emailTempRecord = db.email_template.AsEnumerable().Where(x => x.email_template_type_id == 5).OrderByDescending(x => x.email_template_id).FirstOrDefault();//5 - ACCOUNT_ACTIVATED
                    //if (emailTempRecord != null)
                    //{
                    //    ImagePath = STUtil.GetWebConfigValue("ImagePath");
                    //    EMAIL_TEMPALTE_FOLDER = STUtil.GetWebConfigValue("EMAIL_TEMPALTE_FOLDER");
                    //    string APPLICATION_URL = STUtil.GetWebConfigValue("APPLICATION_URL");
                    //    String templateName = ImagePath + EMAIL_TEMPALTE_FOLDER + "/" + emailTempRecord.email_template_file_name;
                    //    var filePath = (new WebClient()).DownloadString(templateName);
                    //    //filePath = filePath.Replace("{UserName}", companyInfo.user_name);
                    //    //filePath = filePath.Replace("{business_name}", companyInfo.business_name);
                    //    filePath = filePath.Replace("{LOGIN_ID}", loginID);
                    //    filePath = filePath.Replace("{PASSWORD}", password);
                    //    filePath = filePath.Replace("{EMAIL_ID}", emailID);
                    //    filePath = filePath.Replace("{APPLICATION_URL}", APPLICATION_URL);
                    //    STUtil.SendMail(emailID, "Welcome to SnagTick: " + loginID, filePath, null);
                    //}
                    //#endregion
                }
            }
            catch (Exception ex)
            {
                result.MessageType = MessageType.Error;
                result.Message     = ex.Message;
            }
            return(result);
        }