Ejemplo n.º 1
0
        void AddDefaultDataSource()
        {
            byte[] obj = Properties.Resources.GingerDataSource;

            if (!File.Exists(System.IO.Path.Combine(mSolution.Folder, @"DataSources\GingerDataSource.mdb")))
            {
                Directory.CreateDirectory(System.IO.Path.Combine(mSolution.Folder, "DataSources"));
                System.IO.FileStream fs = new System.IO.FileStream(System.IO.Path.Combine(mSolution.Folder, @"DataSources\GingerDataSource.mdb"), System.IO.FileMode.Create, System.IO.FileAccess.Write);
                fs.Write(obj, 0, obj.Count());
                fs.Close();
                fs.Dispose();
            }

            DataSourceBase a = new AccessDataSource();

            a.Name     = "GingerDataSource";
            a.FilePath = @"~\DataSources\GingerDataSource.mdb";
            a.DSType   = DataSourceBase.eDSType.MSAccess;
            RepositoryFolder <DataSourceBase> dsTargetFolder = WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <DataSourceBase>();

            dsTargetFolder.AddRepositoryItem(a);

            // TODO: Try not to use resources, we can put the file in folder and copy
            // adding LiteDB while adding solution
            byte[] litedbobj = Properties.Resources.LiteDB;

            if (!File.Exists(System.IO.Path.Combine(mSolution.Folder, @"DataSources\LiteDB.db")))
            {
                Directory.CreateDirectory(System.IO.Path.Combine(mSolution.Folder, "DataSources"));
                System.IO.FileStream fs = new System.IO.FileStream(System.IO.Path.Combine(mSolution.Folder, @"DataSources\LiteDB.db"), System.IO.FileMode.Create, System.IO.FileAccess.Write);
                fs.Write(litedbobj, 0, litedbobj.Count());
                fs.Close();
                fs.Dispose();
            }

            DataSourceBase lite = new GingerCoreNET.DataSource.GingerLiteDB();

            lite.Name     = "LiteDB";
            lite.FilePath = @"~\DataSources\LiteDB.db";
            lite.DSType   = DataSourceBase.eDSType.LiteDataBase;

            RepositoryFolder <DataSourceBase> dsTargetFolder1 = WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <DataSourceBase>();

            dsTargetFolder.AddRepositoryItem(lite);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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 EVE = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList);
                    EVE.Value = this.Value;

                    ValueExpression ETERC = new ValueExpression(RunOnEnvironment, RunOnBusinessFlow, DSList, false, EVE.ValueCalculated);
                    ETERC.Value = ValueExp;
                    if (ETERC.ValueCalculated == "The Export Excel can be *.xlsx only")
                    {
                        this.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
                        Error       = "The Export Excel can be *.xlsx only";
                    }
                    else
                    {
                        outVal = ETERC.ValueCalculated;
                    }
                    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;

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