private DataTable GetDataForDataCommand(string dataCommand, List <ScreenDataCommandParameter> parameters)
        {
            DataTable retVal = null;

            if (Connection == null)
            {
                retVal = sql.GetDataForDataCommand(dataCommand, parameters);
            }
            else
            {
                DataCommand command = DataCommand.GetDataCommand(dataCommand);

                if (command == null)
                {
                    throw new Exception(String.Format("DataCommand {0} could not be found in configuration", dataCommand));
                }

                retVal = sql.GetData(null, Connection, command, parameters, command.Text);
            }

            return(retVal);
        }
Esempio n. 2
0
        private DataTable GetData(System.Data.Common.DbTransaction tran,
                                  string CommandName,
                                  string WorkflowCode,
                                  string FromWorkflowStepCode,
                                  string ToWorkflowStepCode,
                                  string EntityID,
                                  string Comment,
                                  string UserName,

                                  string WorkflowCodeParameter,
                                  string FromWorkflowStepCodeParameter,
                                  string ToWorkflowStepCodeParameter,
                                  string EntityIDParameter,
                                  string CommentParameter,
                                  string UsernameParameter
                                  )
        {
            DataCommandService dataCommandDB = DataCommandService.GetInstance();

            List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>();
            ScreenDataCommandParameter        parameter  = null;

            DataCommand command = DataCommand.GetDataCommand(CommandName);

            if (command == null)
            {
                throw new ApplicationException(String.Format("DataCommand {0} could not be found in configuration", CommandName));
            }

            if (!String.IsNullOrEmpty(WorkflowCodeParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = WorkflowCodeParameter;
                parameter.Value = WorkflowCode;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(FromWorkflowStepCodeParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = FromWorkflowStepCodeParameter;
                parameter.Value = FromWorkflowStepCode;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(ToWorkflowStepCodeParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = ToWorkflowStepCodeParameter;
                parameter.Value = ToWorkflowStepCode;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(EntityIDParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = EntityIDParameter;
                parameter.Value = EntityID;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(CommentParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = CommentParameter;
                parameter.Value = Comment;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(UsernameParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = UsernameParameter;
                parameter.Value = UserName;
                parameters.Add(parameter);
            }

            //execute command with transaction
            // CommandType type = (command.Type == DataCommandCommandType.StoredProcedure) ? CommandType.StoredProcedure : CommandType.Text;
            DataTable data = dataCommandDB.GetData(tran, command, parameters, command.Text);

            return(data);
        }
Esempio n. 3
0
        public static void GenerateCultureTrackingCookie()
        {
            App app = CodeTorch.Core.Configuration.GetInstance().App;

            if (app.EnableLocalization)
            {
                //get localization data command for retrieval

                DataCommandService dataCommandDB = DataCommandService.GetInstance();

                if (!String.IsNullOrEmpty(app.LocalizationCommand))
                {
                    DataCommand command = DataCommand.GetDataCommand(app.LocalizationCommand);

                    if (command == null)
                    {
                        throw new ApplicationException(String.Format("DataCommand {0} could not be found in configuration - Common.GenerateCultureTrackingCookie", app.LocalizationCommand));
                    }

                    //set any parameters needed
                    List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>();
                    ScreenDataCommandParameter        parameter  = null;

                    if (!String.IsNullOrEmpty(app.LocalizationUserNameParameter))
                    {
                        parameter = new ScreenDataCommandParameter();
                        if (app.LocalizationUserNameParameter.StartsWith("@"))
                        {
                            parameter.Name = app.LocalizationUserNameParameter;
                        }
                        else
                        {
                            parameter.Name = "@" + app.LocalizationUserNameParameter;
                        }
                        parameter.Value = Common.UserName;
                        parameters.Add(parameter);
                    }


                    //execute command

                    DataTable retVal = dataCommandDB.GetData(null, command, parameters, command.Text);


                    string culture = "en-US";
                    //get data from culture field
                    if (retVal != null)
                    {
                        if (retVal.Rows.Count > 0)
                        {
                            if (retVal.Columns.Contains(app.LocalizationCultureField))
                            {
                                if (retVal.Rows[0][app.LocalizationCultureField] != DBNull.Value)
                                {
                                    culture = retVal.Rows[0][app.LocalizationCultureField].ToString();
                                }
                            }
                        }
                    }

                    //generate culture cookie
                    HttpCookie c;

                    if (HttpContext.Current.Request.Cookies["CultureCode"] == null)
                    {
                        c = new HttpCookie("CultureCode");
                    }
                    else
                    {
                        c = HttpContext.Current.Request.Cookies["CultureCode"];
                    }

                    c.Value = culture;
                    c.Path  = "/";

                    HttpContext.Current.Response.Cookies.Add(c);
                }
            }
        }