Example #1
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"
            }));
        }
        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]
            }));
        }