예제 #1
0
        private void SetDataTable()
        {
            if (mActDSTableElement.DSList == null)
            {
                mActDSTableElement.DSList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <DataSourceBase>();
            }

            DataSourceBase dataSource = null;
            var            tableName  = mActDSTableElement.DSTableName;

            if (string.IsNullOrEmpty(tableName))
            {
                return;
            }

            foreach (var ds in mActDSTableElement.DSList)
            {
                if (ds.Name == mActDSTableElement.DSName)
                {
                    dataSource = ds;
                }
            }

            mDataTable = dataSource.GetTable(tableName);

            foreach (DataSourceTable dst in dataSource.GetTablesList())
            {
                if (dst.Name == mActDSTableElement.DSTableName)
                {
                    mDataSourceTable = dst;
                    break;
                }
            }
        }
예제 #2
0
        public static string CheckDataSource(string DataSourceVE, ObservableList <DataSourceBase> DSList)
        {
            string          DSVE       = DataSourceVE;
            DataSourceBase  DataSource = null;
            DataSourceTable DSTable    = null;

            if (string.IsNullOrEmpty(DataSourceVE) || DSVE.IndexOf("{DS Name=") != 0)
            {
                return("Invalid Data Source Value : '" + DataSourceVE + "'");
            }
            DSVE = DSVE.Replace("{DS Name=", "");
            DSVE = DSVE.Replace("}", "");
            if (DSVE.IndexOf(" DST=") == -1)
            {
                return("Invalid Data Source Value : '" + DataSourceVE + "'");
            }
            string DSName = DSVE.Substring(0, DSVE.IndexOf(" DST="));

            foreach (DataSourceBase ds in DSList)
            {
                if (ds.Name == DSName)
                {
                    DataSource = ds;
                    break;
                }
            }

            if (DataSource == null)
            {
                return("Data Source: '" + DSName + "' used in '" + DataSourceVE + "' not found in solution.");
            }

            DSVE = DSVE.Substring(DSVE.IndexOf(" DST=")).Trim();
            if (DSVE.IndexOf(" ") == -1)
            {
                return("Invalid Data Source Value : '" + DataSourceVE + "'");
            }
            string DSTableName = DSVE.Substring(DSVE.IndexOf("DST=") + 4, DSVE.IndexOf(" ") - 4);

            if (DataSource.DSType == DataSourceBase.eDSType.MSAccess)
            {
                DataSource.FileFullPath = WorkSpace.Instance.Solution.SolutionOperations.ConvertSolutionRelativePath(DataSource.FileFullPath);
                ObservableList <DataSourceTable> dsTables = DataSource.GetTablesList();

                foreach (DataSourceTable dst in dsTables)
                {
                    if (dst.Name == DSTableName)
                    {
                        DSTable = dst;
                        break;
                    }
                }
                if (DSTable == null)
                {
                    return("Data Source Table : '" + DSTableName + "' used in '" + DataSourceVE + "' not found in solution.");
                }
            }
            return("");
        }
예제 #3
0
파일: General.cs 프로젝트: romal22/Ginger
        public static string CheckDataSource(string DataSourceVE, ObservableList <DataSourceBase> DSList)
        {
            string          DSVE       = DataSourceVE;
            DataSourceBase  DataSource = null;
            DataSourceTable DSTable    = null;

            if (DSVE.IndexOf("{DS Name=") != 0)
            {
                return("Invalid Data Source Value : '" + DataSourceVE + "'");
            }
            DSVE = DSVE.Replace("{DS Name=", "");
            DSVE = DSVE.Replace("}", "");
            if (DSVE.IndexOf(" DST=") == -1)
            {
                return("Invalid Data Source Value : '" + DataSourceVE + "'");
            }
            string DSName = DSVE.Substring(0, DSVE.IndexOf(" DST="));

            foreach (DataSourceBase ds in DSList)
            {
                if (ds.Name == DSName)
                {
                    DataSource = ds;
                    break;
                }
            }


            if (DataSource == null)
            {
                return("Data Source: '" + DSName + "' used in '" + DataSourceVE + "' not found in solution.");
            }

            DSVE = DSVE.Substring(DSVE.IndexOf(" DST=")).Trim();
            if (DSVE.IndexOf(" ") == -1)
            {
                return("Invalid Data Source Value : '" + DataSourceVE + "'");
            }
            string DSTableName = DSVE.Substring(DSVE.IndexOf("DST=") + 4, DSVE.IndexOf(" ") - 4);

            if (DataSource.DSType == DataSourceBase.eDSType.MSAccess)
            {
                if (DataSource.FileFullPath.StartsWith("~"))
                {
                    DataSource.FileFullPath = DataSource.FileFullPath.Replace(@"~\", "").Replace("~", "");
                    DataSource.FileFullPath = Path.Combine(WorkSpace.Instance.SolutionRepository.SolutionFolder, DataSource.FileFullPath);
                }
                DataSource.Init(DataSource.FileFullPath);
                ObservableList <DataSourceTable> dsTables = DataSource.GetTablesList();
                foreach (DataSourceTable dst in dsTables)
                {
                    if (dst.Name == DSTableName)
                    {
                        DSTable = dst;
                        break;
                    }
                }
                if (DSTable == null)
                {
                    return("Data Source Table : '" + DSTableName + "' used in '" + DataSourceVE + "' not found in solution.");
                }
            }
            return("");
        }
 private void SetGridData()
 {
     mDSTableList = mDSDetails.GetTablesList();
     grdTableList.DataSourceList = mDSTableList;
 }
예제 #5
0
        public override void Execute()
        {
            DataSourceBase DataSource = null;
            string         outVal     = "";

            foreach (DataSourceBase ds in DSList)
            {
                if (DSName == null)
                {
                    string[] Token = ValueExp.Split(new[] { "{DS Name=", " " }, StringSplitOptions.None);
                    DSName = Token[1];
                }

                if (ds.Name == DSName)
                {
                    DataSource = ds;
                }
            }
            if (DataSource.DSType == DataSourceBase.eDSType.LiteDataBase)
            {
                GingerCoreNET.DataSource.GingerLiteDB liteDB = new GingerCoreNET.DataSource.GingerLiteDB();
                string Query = ValueExp.Substring(ValueExp.IndexOf("QUERY=") + 6, ValueExp.Length - (ValueExp.IndexOf("QUERY=") + 7));
                liteDB.FileFullPath = WorkSpace.Instance.SolutionRepository.ConvertSolutionRelativePath(DataSource.FileFullPath);
                liteDB.Execute(this, Query);
            }
            else if (DataSource.DSType == DataSourceBase.eDSType.MSAccess)
            {
                switch (ControlAction)
                {
                case eControlAction.GetValue:
                    ValueExpression VE = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList);
                    VE.Value = ValueExp;
                    AddOrUpdateReturnParamActual("Output", VE.ValueCalculated);
                    break;

                case eControlAction.SetValue:
                    ValueExpression SVE = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList);
                    SVE.Value = this.Value;

                    ValueExpression VEUpdate = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList, true, SVE.ValueCalculated);
                    VEUpdate.Value = ValueExp;
                    outVal         = VEUpdate.ValueCalculated;
                    break;

                case eControlAction.MarkAsDone:
                    ValueExpression VEMAD = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList);
                    VEMAD.Value = ValueExp;
                    outVal      = VEMAD.ValueCalculated;
                    break;

                case eControlAction.RowCount:
                case eControlAction.AvailableRowCount:
                    ValueExpression VERC = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList);
                    VERC.Value = ValueExp;
                    AddOrUpdateReturnParamActual("Output", VERC.ValueCalculated);
                    break;

                case eControlAction.ExportToExcel:
                    ValueExpression VEETE = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList);
                    VEETE.Value = ExcelPath;
                    string ExcelFilePath = VEETE.ValueCalculated;

                    if (ExcelFilePath.ToLower().EndsWith(".xlsx"))
                    {
                        DataSource.ExporttoExcel(DSTableName, ExcelFilePath, ExcelSheetName);
                    }
                    else
                    {
                        this.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
                        Error       = "The Export Excel can be *.xlsx only";
                    }
                    break;

                case eControlAction.DeleteRow:
                    ValueExpression veDel = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList);
                    veDel.Value = ValueExp;
                    outVal      = veDel.ValueCalculated;
                    int rowCount = 0;
                    if (!string.IsNullOrEmpty(outVal) && !int.TryParse(outVal, out rowCount))
                    {
                        this.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
                        Error       = outVal;
                    }
                    break;

                case eControlAction.AddRow:
                    DataSourceTable DSTable = null;
                    ObservableList <DataSourceTable> dstTables = DataSource.GetTablesList();
                    foreach (DataSourceTable dst in dstTables)
                    {
                        if (dst.Name == DSTableName)
                        {
                            DSTable           = dst;
                            DSTable.DataTable = dst.DSC.GetTable(DSTableName);
                            break;
                        }
                    }
                    if (DSTable != null)
                    {
                        List <string> mColumnNames = DataSource.GetColumnList(DSTableName);
                        DataSource.AddRow(mColumnNames, DSTable);
                        DataSource.SaveTable(DSTable.DataTable);
                        //Get GingerId
                        DataTable dt       = DataSource.GetTable(DSTableName);
                        DataRow   row      = dt.Rows[dt.Rows.Count - 1];
                        string    GingerId = Convert.ToString(row["GINGER_ID"]);
                        AddOrUpdateReturnParamActual("GINGER_ID", GingerId);
                    }
                    else
                    {
                        Error = "No table present in the DataSource with the name =" + DSTableName;
                    }
                    break;

                default:
                    ValueExpression VEDR = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList);
                    VEDR.Value = ValueExp;
                    outVal     = VEDR.ValueCalculated;
                    break;
                }
            }
            return;
        }