Beispiel #1
0
        public ActionResult Edit(string ResourceKey, int acid)
        {
            LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
            ResourcesDTO     objResourcesDTO     = null;
            ResourcesSL      objResourcesSL      = new ResourcesSL();

            try
            {
                objResourcesDTO = objResourcesSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, ResourceKey);
                ResourceModel objResourceModel = new ResourceModel();
                ViewBag.ColumnAlignmentList = FillComboValues(ConstEnum.ComboType.ListOfCode, InsiderTrading.Common.ConstEnum.CodeGroup.ColumnAlignment, null, null, null, null, true);
                Common.Common.CopyObjectPropertyByName(objResourcesDTO, objResourceModel);
                return(PartialView("~/Views/Resource/Create.cshtml", objResourceModel));
            }
            catch (Exception exp)
            {
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());
                ModelState.AddModelError("Error", sErrMessage);
                return(RedirectToAction("Index"));
            }
            finally
            {
                objLoginUserDetails = null;
                objResourcesDTO     = null;
                objResourcesSL      = null;
            }
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            CompilationSection compilationSection = (CompilationSection)System.Configuration.ConfigurationManager.GetSection(@"system.web/compilation");

            //UserInfoSL objUserInfoSL = new UserInfoSL();
            CompaniesSL objCompaniesSL = new CompaniesSL();
            ResourcesSL objResourcesSL = new ResourcesSL();

            InsiderTradingDAL.CompanyDTO objSelectedCompany  = new CompanyDTO();
            LoginUserDetails             objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails);
            string sConnectionString = "";

            if (objLoginUserDetails == null || objLoginUserDetails.CompanyName == null)
            {
                sConnectionString = Common.Common.getSystemConnectionString();
                Dictionary <string, string> lstCompanyResources = new Dictionary <string, string>();
                objResourcesSL.GetAllResources(sConnectionString, out lstCompanyResources);
                HttpContext.Current.Application.Set("InsiderTrading", lstCompanyResources);

                if (compilationSection.Debug)
                {
                    using (FileStream filestream = new FileStream((System.Web.HttpContext.Current.Server.MapPath("~/DebugLogs/DebugLogs.txt")), FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
                    {
                        StreamWriter sWriter = new StreamWriter(filestream);
                        sWriter.WriteLine("UpdateResourcesFilter--> OnActionExecuting method called and got Exception for - Login details || Company name is null :- " + DateTime.Now);
                        sWriter.WriteLine("--------------------------------------------------------------------");
                        sWriter.Close();
                        sWriter.Dispose();
                        filestream.Close();
                        filestream.Dispose();
                    }
                }
            }
            else
            {
                objSelectedCompany = objCompaniesSL.getSingleCompanies(Common.Common.getSystemConnectionString(), objLoginUserDetails.CompanyName);
                sConnectionString  = objLoginUserDetails.CompanyDBConnectionString;
                Dictionary <string, string> objResourceFromContext = ((Dictionary <string, string>)HttpContext.Current.Application.Get(objLoginUserDetails.CompanyName));
                if (objSelectedCompany.nUpdateResources == 1 || (objResourceFromContext == null || objResourceFromContext.Count == 0))
                {
                    Common.Common.UpdateCompanyResources(sConnectionString, objLoginUserDetails.CompanyName);
                }

                if (compilationSection.Debug)
                {
                    using (FileStream filestream = new FileStream((System.Web.HttpContext.Current.Server.MapPath("~/DebugLogs/DebugLogs.txt")), FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
                    {
                        StreamWriter sWriter = new StreamWriter(filestream);
                        sWriter.WriteLine("UpdateResourcesFilter--> OnActionExecuting method called :- " + DateTime.Now);
                        sWriter.WriteLine("--------------------------------------------------------------------");
                        sWriter.Close();
                        sWriter.Dispose();
                        filestream.Close();
                        filestream.Dispose();
                    }
                }
            }

            //Note: Fetch the activity access for user and load in session here

            base.OnActionExecuting(filterContext);
        }
Beispiel #3
0
        public JsonResult UpdateResourceValue(ResourceModel objResourceModel, int acid)
        {
            bool             bReturn             = false;
            LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
            ResourcesSL      objResourcesSL      = new ResourcesSL();
            ResourcesDTO     objResourcesDTO     = new ResourcesDTO();
            CompaniesSL      objCompaniesSL      = new CompaniesSL();
            bool             statusFlag          = false;
            var ErrorDictionary = new Dictionary <string, string>();

            Common.Common objCommon = new Common.Common();
            string        message   = string.Empty;

            try
            {
                if (!objCommon.ValidateCSRFForAJAX())
                {
                    return(Json(new
                    {
                        status = statusFlag,
                        Message = ErrorDictionary
                    }, JsonRequestBehavior.AllowGet));
                }
                Common.Common.CopyObjectPropertyByName(objResourceModel, objResourcesDTO);
                objResourcesDTO.LoggedInUserId = objLoginUserDetails.LoggedInUserID;
                bReturn = objResourcesSL.SaveDetails(objLoginUserDetails.CompanyDBConnectionString, objResourcesDTO);
                if (bReturn)
                {
                    objCompaniesSL.UpdateMasterCompanyDetails(Common.Common.getSystemConnectionString(), objLoginUserDetails.CompanyName, 1);
                    Common.Common.UpdateCompanyResources(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.CompanyName);
                    //return Json(new
                    //{
                    //    status = true,
                    //    Message = InsiderTrading.Common.Common.getResource("mst_msg_10049") //"Resource Update Successfully."

                    //}, JsonRequestBehavior.AllowGet);
                    statusFlag = true;
                    message    = InsiderTrading.Common.Common.getResource("mst_msg_10049");
                }
                else
                {
                    statusFlag = false;
                    message    = "Resource not saved.";
                }
                //return Json(new
                //{
                //    status = false,
                //    Message = "Resource not saved."

                //}, JsonRequestBehavior.AllowGet);
            }
            catch (Exception exp)
            {
                ModelState.Remove("KEY");
                ModelState.Add("KEY", new ModelState());
                ModelState.Clear();
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());
                ModelState.AddModelError("error", sErrMessage);
                ErrorDictionary = GetModelStateErrorsAsString();
            }
            finally
            {
                objLoginUserDetails = null;
                objResourcesSL      = null;
                objResourcesDTO     = null;
                objCompaniesSL      = null;
            }
            return(Json(new
            {
                status = statusFlag,
                Message = message
            }, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        /// <summary>
        /// This method is used to get all Resource
        /// </summary>
        /// <param name="s_sConnectionString">string: connection string</param>
        /// <param name="o_lstResources">out Dictionary: Resources list</param>
        public static void getResource(string s_sConnectionString, out Dictionary <string, string> o_lstResources)
        {
            ResourcesSL resourcesSL = new ResourcesSL();

            resourcesSL.GetAllResources(s_sConnectionString, out o_lstResources);
        }