예제 #1
0
        public ActionResult SetAdminRole(string sType, string sUser)
        {
            ApplicationUser user = UserManager.FindByName <ApplicationUser, string>(sUser);

            Models.DBContext      dbContext = new Models.DBContext();
            Models.CompanyDetails cmp       = new Models.CompanyDetails();
            var FindCompany = (from d in dbContext.Company
                               where d.CompanyName == user.CompanyName
                               select new { d.CompanyName, d.Logo }).FirstOrDefault();

            if (sType == "Y")
            {
                cmp.CompanyName = user.CompanyName;
                cmp.EmailID     = user.Email;
                cmp.UserName    = user.UserName;
                cmp.Logo        = FindCompany.Logo;
                dbContext.Company.Add(cmp);
                dbContext.SaveChanges();
            }
            else
            {
                var userdata = dbContext.Company.Where(D => D.UserName == sUser).FirstOrDefault();
                dbContext.Company.Remove(userdata);
                dbContext.SaveChanges();
            }

            return(View());
        }
        private MyLastAction GetUserCurrentAction()
        {
            var UCA = (from uca in db.UserLastActions
                       where uca.UserId == UserData.UserName
                       select uca).FirstOrDefault();

            MyLastAction viewModel = new MyLastAction();

            if (UCA == null)
            {
                UserLastActions uca = new UserLastActions();
                uca.Company   = UserData.CompanyName;
                uca.KeyDate   = "2018/07/11";
                uca.UserId    = UserData.UserName;
                uca.Version   = "1";
                uca.UsedView  = "Normal";
                uca.Oper      = "OV";
                uca.Levels    = "One";
                uca.ShowLevel = "101212";
                uca.Country   = "";
                uca.Role      = "User";
                db.UserLastActions.Add(uca);

                db.SaveChanges();

                viewModel.ShowLevel = "101212";
                viewModel.KeyDate   = "2018/07/11";
                viewModel.Levels    = "One";
                viewModel.Version   = "1";
                viewModel.Oper      = "OV";
                viewModel.View      = "Normal";
                viewModel.Country   = "";
                viewModel.Role      = "User";
            }
            else
            {
                viewModel.KeyDate   = UCA.KeyDate;
                viewModel.ShowLevel = UCA.ShowLevel;
                viewModel.Levels    = UCA.Levels;
                viewModel.Version   = UCA.Version;
                viewModel.Oper      = UCA.Oper;
                viewModel.View      = UCA.UsedView;
                viewModel.Country   = UCA.Country;
                viewModel.Role      = UCA.Role;
            }

            return(viewModel);
        }
예제 #3
0
        public async Task <IActionResult> Index()
        {
            TipoCambioSoapClient client = new TipoCambioSoapClient(EndpointConfiguration.TipoCambioSoap);
            //var result = await client.AddAsync(5, 8);
            var result = await client.TipoCambioDiaAsync();

            var ResultOfTipoCambioBank = result.Body.TipoCambioDiaResult.CambioDolar[0];

            ViewBag.ResultOfBank = ResultOfTipoCambioBank;



            var contextOptions = new DbContextOptionsBuilder <Models.DBContext>()
                                 .UseSqlServer("Server=localhost;Database=DemoAzureInsight;User Id=elvis;Password=*Disdel100;")
                                 .Options;

            using var context = new Models.DBContext(contextOptions);
            Models.TipoCambio NewValueTipoCambios = new TipoCambio();
            NewValueTipoCambios.Fecha      = Convert.ToDateTime(ResultOfTipoCambioBank.fecha);
            NewValueTipoCambios.Referencia = Convert.ToDecimal(ResultOfTipoCambioBank.referencia);

            context.Add <Models.TipoCambio>(NewValueTipoCambios);
            context.SaveChanges();

            List <Models.TipoCambio> AllData = context.TipoCambios.ToList();

            ViewBag.AllData = AllData;


            return(View());
        }
예제 #4
0
        public ActionResult Store(Complaint c)
        {
            DBContext db = new Models.DBContext();

            if (ModelState.IsValid)
            {
                c.IsAdminShow = false;
                db.Complaints.Add(c);
                db.SaveChanges();
                ViewBag.Message = "پیام شما با موفقیت دریافت شد و بزودی توسط مدیران سایت بررسی خواهد شد";
            }
            return(View("Create"));
        }
예제 #5
0
        // POST: /Account/UploadLogo
        public ActionResult UploadLogo(HttpPostedFileBase file)
        {
            Models.DBContext      dbContext = new Models.DBContext();
            Models.CompanyDetails cmp       = new Models.CompanyDetails();
            var FindCompany = dbContext.Company.Where(C => C.UserName == User.Identity.Name).FirstOrDefault();

            if (file != null)
            {
                string pic  = System.IO.Path.GetFileName(file.FileName);
                string path = System.IO.Path.Combine(
                    Server.MapPath("~/Content/assets/CompanyLogo/"), pic);
                // file is uploaded
                file.SaveAs(path);

                if (FindCompany != null)
                {
                    FindCompany.Logo = pic;
                    dbContext.SaveChanges();
                }
                ViewBag.UploadSuccess = "Logo Uploaded Successfully, Please click on the link to dashboard list";
            }

            return(View());
        }
예제 #6
0
        public JsonResult SaveVersionInfo(string selFP, string txtFP, string chkSN,
                                          string selNL, string selPL, string txtUN,
                                          string chkFT, string txtFN)
        {
            var UserLastAction = (from ula in db.UserLastActions
                                  where ula.UserId == UserData.UserName && ula.Company == UserData.CompanyName
                                  select ula).FirstOrDefault();

            if (UserLastAction != null)
            {
                var UploadFilesHeader = (from ufh in db.UploadFilesHeaders
                                         where ufh.UserId == UserData.UserName &&
                                         ufh.CompanyName == UserData.CompanyName &&
                                         ufh.Role == UserLastAction.Role
                                         select ufh).FirstOrDefault();
                if (UploadFilesHeader != null)
                {
                    UploadFilesHeader.SerialNoFlag       = chkSN;
                    UploadFilesHeader.FirstPositionField = selFP;
                    UploadFilesHeader.FirstPosition      = txtFP;
                    UploadFilesHeader.KeyField           = selNL;
                    UploadFilesHeader.ParentField        = selPL;
                    UploadFilesHeader.FullNameFields     = txtUN;
                    UploadFilesHeader.FileType           = chkFT;
                    UploadFilesHeader.JSONFileName       = txtFN;

                    UploadFilesHeader.VersionNo++;
                    UploadFilesHeader.CurrentVersionNo = UploadFilesHeader.VersionNo;
                    UserLastAction.Version             = UploadFilesHeader.VersionNo.ToString();
                }
                else
                {
                    UploadFilesHeaders UFH = new UploadFilesHeaders();

                    UFH.SerialNoFlag       = chkSN;
                    UFH.FirstPositionField = selFP;
                    UFH.FirstPosition      = txtFP;
                    UFH.KeyField           = selNL;
                    UFH.ParentField        = selPL;
                    UFH.FullNameFields     = txtUN;
                    UFH.FileType           = chkFT;
                    UFH.JSONFileName       = txtFN;
                    UFH.Role               = UserLastAction.Role;
                    UFH.VersionNo          = 1;
                    UFH.CurrentVersionNo   = 1;
                    UserLastAction.Version = "1";

                    db.UploadFilesHeaders.Add(UFH);
                }

                UploadFileDetails UFD = new UploadFileDetails();

                UFD.JSONFileName  = txtFN;
                UFD.KeyDate       = DateTime.Now;
                UFD.VersionNo     = Convert.ToInt32(UserLastAction.Version);
                UFD.VersionStatus = "P";
                UFD.Role          = UserLastAction.Role;
                UFD.CompanyName   = UserData.CompanyName;
                UFD.UserId        = UserData.UserName;

                db.UploadFileDetails.Add(UFD);

                db.SaveChanges();
            }

            // Updates the Table with new Version
            if (chkFT == "JSON")
            {
                UpdateTableWithJSON(UserLastAction.Role, UserLastAction.Role);
            }
            else if (chkFT == "XLSX")
            {
                UpdateTableWithJSON(UserLastAction.Role, UserLastAction.Role);
            }

            return(Json(new
            {
                Success = "Yes"
            }));
        }
예제 #7
0
        public async Task <ActionResult> Register(RegisterModel model, string cbxDataPrivacy)
        {
            if (cbxDataPrivacy == "on")
            {
                Models.DBContext      dbContext = new Models.DBContext();
                Models.CompanyDetails cmp       = new Models.CompanyDetails();
                var FindCompany = (from d in dbContext.Company
                                   where d.CompanyName == model.CompanyName
                                   select new { d.CompanyName }).ToList();

                if (ModelState.IsValid)
                {
                    // Attempt to register the user

                    if (FindCompany.Count == 0)
                    {
                        var user = new ApplicationUser {
                            UserName = model.UserName, Email = model.Email, CompanyName = model.CompanyName
                        };
                        var result = await UserManager.CreateAsync(user, model.Password);

                        if (result.Succeeded)
                        {
                            cmp.CompanyName = user.CompanyName;
                            cmp.EmailID     = user.Email;
                            cmp.UserName    = user.UserName;
                            cmp.Logo        = null;
                            dbContext.Company.Add(cmp);
                            dbContext.SaveChanges();

                            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                            // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                            // Send an email with this link
                            string EMail = ConfigurationManager.AppSettings.Get("EmailID");
                            string To = EMail, UserID, Password, SMTPPort, Host;

                            var    request = HttpContext.Request;
                            string lnkHref = "<a href='" + HttpContext.Request.Url.Scheme + "://" +
                                             HttpContext.Request.Url.Authority +
                                             "/Home/ApprovalList/?CustRegId=" + user.Id +
                                             "'>" + "Approval link" + "</a>";

                            //HTML Template for Send email
                            string subject = "Request for Approval of subscription";
                            string body    = "<b>Dear Admin, </b><br/><br/>";
                            body = body + "<b>Kindly Approve The Customer: " + user.CompanyName + "&nbsp; Request for enrollement.</b><br/>" + "<b>Please find the Customers list </b>&nbsp; : " + lnkHref;
                            body = body + "<br/><br/><b>Thanks,</b><br/>" + "<b>Mcbitss Team.</b>";

                            //Get and set the AppSettings using configuration manager.
                            EmailManager.AppSettings(out UserID, out Password, out SMTPPort, out Host);

                            //Call send email methods.
                            EmailManager.SendEmail(UserID, subject, body, To, UserID, Password, SMTPPort, Host);

                            return(Redirect("/"));
                        }

                        ViewBag.ErrorMessage = result.Errors.First();
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "Company details are already added";
                    }
                }
            }
            else
            {
                ViewBag.ErrorMessage = "Please accept data privacy policy && Terms";
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public async Task <ActionResult> UserRegister(RegisterModel model, HttpPostedFileBase Upload, string cbxRequestType)
        {
            DataTable dtUsers = new DataTable();

            ViewBag.CompanyName = model.CompanyName;
            string UploadFileName = "";

            model.RequestType = cbxRequestType;
            if (cbxRequestType == "Individual")
            {
                model.Upload              = "No File";
                model.PasswordName        = model.Password;
                model.ConfirmPasswordName = model.ConfirmPassword;
                if (ModelState.IsValid)
                {
                    // Attempt to register the user
                    var user = new ApplicationUser {
                        UserName = model.UserName, Email = model.Email, CompanyName = model.CompanyName
                    };
                    var result = await UserManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        Models.DBContext dbContext = new Models.DBContext();
                        Models.UserRoles usr       = new Models.UserRoles();

                        usr.UserId      = model.UserName;
                        usr.Role        = model.Roles.Replace("Planner", "Player");
                        usr.CompanyName = model.CompanyName;
                        usr.Email       = model.Email;

                        dbContext.UserRoles.Add(usr);
                        dbContext.SaveChanges();

                        try
                        {
                            // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                            // Send an email with this link
                            string EMail = ConfigurationManager.AppSettings.Get("EmailID");
                            string To = model.Email, UserID, Password, SMTPPort, Host;

                            var    request = HttpContext.Request;
                            string lnkHref = "<a href='" + HttpContext.Request.Url.Scheme + "://" +
                                             HttpContext.Request.Url.Authority +
                                             "'> " + "link" + "</a>";

                            //HTML Template for Send email
                            string subject = "Login Created";
                            string body    = "<b>Dear " + model.UserName + ", </b><br/><br/>";
                            body = body + "<b>Your login credentials created, Kindly change the pasword at the earliest" + lnkHref + "</b><br/>";
                            body = body + "<b>User Name :  " + model.UserName + "</b><br/>";;
                            body = body + "<b>Password :  "******"</b><br/>";;
                            body = body + "<br/><br/><b>Thanks,</b><br/>" + "<b>" + model.CompanyName + "Team.</b>";

                            //Get and set the AppSettings using configuration manager.
                            EmailManager.AppSettings(out UserID, out Password, out SMTPPort, out Host);

                            //Call send email methods.
                            EmailManager.SendEmail(UserID, subject, body, To, UserID, Password, SMTPPort, Host);
                        }
                        catch (Exception ex)
                        {
                            UploadFileName += model.UserName + " email not sent to this user(" + ex.Message + ")\n";
                        }
                    }
                    else
                    {
                        UploadFileName += result.Errors.First() + "\n";
                    }

                    if (UploadFileName == "")
                    {
                        UploadFileName = "User Successfuly loaded.";
                    }
                    ViewBag.ErrorMessage = UploadFileName;
                }
            }
            else if (cbxRequestType == "Mass")
            {
                string fname;

                // Checking for Internet Explorer
                if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                {
                    string[] testfiles = Upload.FileName.Split(new char[] { '\\' });
                    fname = testfiles[testfiles.Length - 1];
                }
                else
                {
                    fname = Upload.FileName;
                }

                // Get the complete folder path and store the file inside it.
                fname = Path.Combine(Server.MapPath("~/App_Data/Uploads/"), fname);
                Upload.SaveAs(fname);

                ExcelAPI API = new ExcelAPI();
                API.CreateDataTableFromExcel(fname, dtUsers);

                foreach (DataRow dr in dtUsers.Rows)
                {
                    model.UserName        = dr["Name"].ToString();
                    model.Email           = dr["Email"].ToString();
                    model.Roles           = dr["Roles"].ToString();
                    model.Password        = model.PasswordName;
                    model.ConfirmPassword = model.ConfirmPasswordName;

                    // Attempt to register the user
                    var user = new ApplicationUser {
                        UserName    = dr["Name"].ToString(),
                        Email       = dr["Email"].ToString(),
                        CompanyName = model.CompanyName
                    };
                    var result = await UserManager.CreateAsync(user, model.PasswordName);

                    if (result.Succeeded)
                    {
                        Models.DBContext dbContext = new Models.DBContext();
                        Models.UserRoles usr       = new Models.UserRoles();

                        usr.UserId      = model.UserName;
                        usr.Role        = model.Roles.Replace("Planner", "Player");
                        usr.CompanyName = model.CompanyName;
                        usr.Email       = model.Email;

                        dbContext.UserRoles.Add(usr);
                        dbContext.SaveChanges();

                        try
                        {
                            // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                            // Send an email with this link
                            string EMail = ConfigurationManager.AppSettings.Get("EmailID");
                            string To = model.Email, UserID, Password, SMTPPort, Host;

                            var    request = HttpContext.Request;
                            string lnkHref = "<a href='" + HttpContext.Request.Url.Scheme + "://" +
                                             HttpContext.Request.Url.Authority +
                                             "'> " + "link" + "</a>";

                            //HTML Template for Send email
                            string subject = "Login Created";
                            string body    = "<b>Dear " + model.UserName + ", </b><br/><br/>";
                            body = body + "<b>Your login credentials created, Kindly change the pasword at the earliest" + lnkHref + "</b><br/>";
                            body = body + "<b>User Name :  " + model.UserName + "</b><br/>";;
                            body = body + "<b>Password :  "******"</b><br/>";;
                            body = body + "<br/><br/><b>Thanks,</b><br/>" + "<b>" + model.CompanyName + "Team.</b>";

                            //Get and set the AppSettings using configuration manager.
                            EmailManager.AppSettings(out UserID, out Password, out SMTPPort, out Host);

                            //Call send email methods.
                            EmailManager.SendEmail(UserID, subject, body, To, UserID, Password, SMTPPort, Host);
                        }
                        catch (Exception ex)
                        {
                            UploadFileName += model.UserName + " email not sent to this user(" + ex.Message + ")\n";
                        }
                    }
                    else
                    {
                        UploadFileName += result.Errors.First() + "\n";
                    }
                }
                if (UploadFileName == "")
                {
                    UploadFileName = "Users Successfuly loaded.";
                }
                ViewBag.ErrorMessage = UploadFileName;
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public async Task <ActionResult> Register(RegisterModel model, string cbxDataPrivacy)
        {
            if (cbxDataPrivacy == "on")
            {
                Models.DBContext      dbContext = new Models.DBContext();
                Models.CompanyDetails cmp       = new Models.CompanyDetails();
                var FindCompany = (from d in dbContext.Company
                                   where d.CompanyName == model.CompanyName
                                   select new { d.CompanyName }).ToList();

                string wcCompanyName = ConfigurationManager.AppSettings["wcCompanyName"].ToString();
                var    INI           = (from ini in dbContext.InitializeTables
                                        where ini.Authentication.ToUpper() == "WINDOWS" && ini.CompanyName == wcCompanyName
                                        select ini).FirstOrDefault();
                if (INI != null)
                {
                    string[] WindowsUser    = Request.LogonUserIdentity.User.ToString().Split('\\');
                    string   WindowUserName = WindowsUser[0];
                    if (WindowsUser.Length >= 2)
                    {
                        WindowUserName = WindowsUser[1];
                    }
                    model.UserName = WindowUserName;
                }

                if (ModelState.IsValid)
                {
                    // Attempt to register the user
                    if (FindCompany.Count == 0)
                    {
                        var user = new ApplicationUser {
                            UserName    = model.UserName,
                            Email       = model.Email,
                            CompanyName = model.CompanyName
                        };
                        var result = await UserManager.CreateAsync(user, model.Password);

                        if (result.Succeeded)
                        {
                            cmp.CompanyName = user.CompanyName;
                            cmp.EmailID     = user.Email;
                            cmp.UserName    = user.UserName;
                            cmp.Logo        = null;
                            dbContext.Company.Add(cmp);

                            Models.UserRoles usr = new Models.UserRoles();
                            usr.UserId      = model.UserName;
                            usr.Role        = model.Roles;
                            usr.CompanyName = user.CompanyName;
                            usr.Email       = model.Email;
                            dbContext.UserRoles.Add(usr);
                            dbContext.SaveChanges();

                            using (SqlCommand cmd = new SqlCommand())
                            {
                                cmd.CommandType    = CommandType.StoredProcedure;
                                cmd.CommandTimeout = 0;
                                cmd.CommandText    = "PROC_CONFIGURE_COMPANY";

                                cmd.Parameters.Add("@CURRENT_COMPANY", SqlDbType.VarChar, 500).Value   = ConfigureCompany;
                                cmd.Parameters.Add("@CONFIGURE_COMPANY", SqlDbType.VarChar, 500).Value = user.CompanyName;

                                Common csobj = new Common();
                                csobj.SPReturnDataTable(cmd);
                            }


                            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                            // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                            // Send an email with this link
                            string EMail = ConfigurationManager.AppSettings.Get("EmailID");
                            string To = model.Email, UserID, Password, SMTPPort, Host;

                            var    request = HttpContext.Request;
                            string lnkHref = "<a href='" + HttpContext.Request.Url.Scheme + "://" +
                                             HttpContext.Request.Url.Authority +
                                             "/Home/ApprovalList/?CustRegId=" + user.Id +
                                             "'>" + "Approval link" + "</a>";

                            //HTML Template for Send email
                            string subject = "Request for Approval of subscription";
                            string body    = "<b>Dear Admin, </b><br/><br/>";
                            body = body + "<b>Kindly Approve The Customer: " + user.CompanyName + "&nbsp; Request for enrollement.</b><br/>" + "<b>Please find the Customers list </b>&nbsp; : " + lnkHref;
                            body = body + "<br/><br/><b>Thanks,</b><br/>" + "<b>Mcbitss Team.</b>";

                            //Get and set the AppSettings using configuration manager.
                            EmailManager.AppSettings(out UserID, out Password, out SMTPPort, out Host);

                            //Call send email methods.
                            EmailManager.SendEmail(UserID, subject, body, To, UserID, Password, SMTPPort, Host);

                            return(Redirect("~/"));
                        }

                        ViewBag.ErrorMessage = result.Errors.First();
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "Company details are already added";
                    }
                }
            }
            else
            {
                ViewBag.ErrorMessage = "Please accept data privacy policy && Terms";
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
예제 #10
0
        public JsonResult SetSelectedValues(string KeyDate, string UsedView, string Country, string ShowLevel, string Levels, string Oper, string Version, string Role,
                                            string SelectedShape, string SelectedSkin, string SelectedShowPicture, string SelectedSplitScreen, string SelectedSplitScreenDirection,
                                            string SelectedTextColor, string SelectedBorderColor, string SelectedBorderWidth, string SelectedLineColor, string SelectedBoxWidth,
                                            string SelectedPortraitModeMultipleLevel, string SelectedFunctionalManagerType, string SelectedFMLine,
                                            string OrgChartType, string Type)
        {
            LoginUsers UserData = LI.GetLoginUserInfo("");
            var        UCA      = (from uca in db.UserLastActions
                                   where uca.UserId == UserData.UserName
                                   select uca).FirstOrDefault();

            if (UCA != null)
            {
                if (Type == "Role")
                {
                    string             UserRole = (Role == "User") ? "Finalyzer" : Role;
                    UploadFilesHeaders UFH      = null;
                    if (UserRole != "Finalyzer")
                    {
                        UFH = (from ufh in db.UploadFilesHeaders
                               where ufh.CompanyName == UserData.CompanyName &&
                               ufh.UserId == UserData.UserName &&
                               ufh.Role == UserRole
                               select ufh).FirstOrDefault();
                    }
                    else
                    {
                        UFH = (from ufh in db.UploadFilesHeaders
                               where ufh.CompanyName == UserData.CompanyName &&
                               ufh.Role == UserRole
                               select ufh).FirstOrDefault();
                    }

                    if (UFH != null)
                    {
                        UCA.Version = UFH.VersionNo.ToString();
                        UCA.Role    = Role;

                        int UserVersion = UFH.VersionNo;

                        var UFD = (from ufd in db.UploadFilesDetails
                                   where ufd.VersionNo == UserVersion
                                   select ufd).FirstOrDefault();
                        if (UFD != null)
                        {
                            UCA.ShowLevel = UFD.ShowLevel;
                        }
                    }
                    else
                    {
                        UCA.Version = "-999";
                        UCA.Role    = Role;
                    }

                    Session.Contents[UserData.UserName + "_MyModel"] = null;
                    return(Json(new
                    {
                        Success = "Yes",
                        ChartData = "Role Change",
                        TreeData = ""
                    }));
                }
                else if (Type == "View")
                {
                    UCA.UsedView = UsedView;
                }
                else if (Type == "Level")
                {
                    UCA.Levels = Levels;
                }
                else if (Type == "Type")
                {
                    UCA.Oper = Oper;
                }
                else if (Type == "Settings")
                {
                    UCA.UsedView                          = UsedView;
                    UCA.SelectedShape                     = SelectedShape;
                    UCA.SelectedSkin                      = SelectedSkin;
                    UCA.SelectedShowPicture               = SelectedShowPicture;
                    UCA.SelectedSplitScreen               = SelectedSplitScreen;
                    UCA.SelectedSplitScreenDirection      = SelectedSplitScreenDirection;
                    UCA.SelectedTextColor                 = SelectedTextColor;
                    UCA.SelectedBorderColor               = SelectedBorderColor;
                    UCA.SelectedBorderWidth               = SelectedBorderWidth;
                    UCA.SelectedLineColor                 = SelectedLineColor;
                    UCA.SelectedBoxWidth                  = SelectedBoxWidth;
                    UCA.SelectedPortraitModeMultipleLevel = SelectedPortraitModeMultipleLevel;
                    UCA.SelectedFunctionalManagerType     = SelectedFunctionalManagerType;
                    UCA.SelectedFMLine                    = SelectedFMLine;
                    UCA.OrgChartType                      = OrgChartType;
                    UCA.Levels = Levels;
                }
                else if (Type == "")
                {
                    UCA.KeyDate   = KeyDate;
                    UCA.Country   = Country;
                    UCA.ShowLevel = ShowLevel;
                }

                db.SaveChanges();
            }

            string[] ChangeLevel = LI.GetOrgChartData(UCA.Role, UCA.Country, UCA.ShowLevel, UCA.ParentLevel,
                                                      UCA.Levels, UCA.Oper, UCA.Version,
                                                      UCA.OrgChartType, UCA.SelectedPortraitModeMultipleLevel, UCA.SelectedFunctionalManagerType);
            if (Session.Contents[UserData.UserName + "_MyModel"] != null)
            {
                MyModel MyModel = (MyModel)Session.Contents[UserData.UserName + "_MyModel"];
                MyModel.ChartData = ChangeLevel[1];
                if (Type == "Settings")
                {
                    MyModel.View                              = UsedView;
                    MyModel.SelectedShape                     = SelectedShape;
                    MyModel.SelectedSkin                      = SelectedSkin;
                    MyModel.SelectedShowPicture               = SelectedShowPicture;
                    MyModel.SelectedSplitScreen               = SelectedSplitScreen;
                    MyModel.SelectedSplitScreenDirection      = SelectedSplitScreenDirection;
                    MyModel.SelectedTextColor                 = SelectedTextColor;
                    MyModel.SelectedBorderColor               = SelectedBorderColor;
                    MyModel.SelectedBorderWidth               = SelectedBorderWidth;
                    MyModel.SelectedBoxWidth                  = SelectedBoxWidth;
                    MyModel.SelectedLineColor                 = SelectedLineColor;
                    MyModel.SelectedPortraitModeMultipleLevel = SelectedPortraitModeMultipleLevel;
                    MyModel.SelectedFunctionalManagerType     = SelectedFunctionalManagerType;
                    MyModel.SelectedFMLine                    = SelectedFMLine;
                    MyModel.OrgChartType                      = OrgChartType;
                    MyModel.Levels                            = Levels;
                }
                else if (Type == "View")
                {
                    MyModel.View = UsedView;
                }
                else if (Type == "")
                {
                    MyModel.KeyDate   = KeyDate;
                    MyModel.Country   = Country;
                    MyModel.ShowLevel = ShowLevel;
                }
                Session.Contents[UserData.UserName + "_MyModel"] = MyModel;
            }

            return(Json(new
            {
                Success = "Yes",
                ChartData = ChangeLevel[1],
                TreeData = ChangeLevel[0]
            }));
        }