Ejemplo n.º 1
0
        /// <summary>
        /// Loads the record set data.
        /// </summary>
        /// <param name="data">
        /// The record set with the data.
        /// </param>
        /// <exception cref="XmlException">
        /// There is a load or parse error in the XML.<para/>
        /// In this case, the document remains empty.
        /// </exception>
        /// <exception cref="XPathException">
        /// The XPath expression contains a prefix.
        /// </exception>
        private void Load(IRecordset data)
        {
            // get data
            var xmlData = ExtractXmlFromRecordset(data);

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

            xmlDoc.LoadXml(xmlData);

            var rows = xmlDoc.SelectNodes(@"//Row");

            if (rows != null)
            {
                rowEnumerator = rows.GetEnumerator();

                var firstNode = rows[0];
                var aliases   = firstNode.SelectNodes(@"descendant::Alias");
                var fields    = data.Fields;
                if (aliases != null)
                {
                    foreach (XmlNode alias in aliases)
                    {
                        var name = alias.InnerXml;
                        var type = fields.Item(name).Type;

                        columns.Add(new Column(name, type));
                    }

                    columns = columns.ToList();
                }
            }
        }
Ejemplo n.º 2
0
    public void LocalSave()
    {
        string path = Application.persistentDataPath + "/Documents/";

        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXEditor)
        {
            path = Application.dataPath + "/../Documents/";
        }

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        MemoryStream ms = new MemoryStream();
        BinaryWriter bw = new BinaryWriter(ms);

        bw.Write(mVersion);
        IRecordset rec = RecordFactory.CreateRecord(mVersion);

        if (rec != null)
        {
            rec.SaveData(bw);
        }
        byte[] buffer = ms.ToArray();
        ms.Close();
        bw.Close();

        buffer = CryptBuffer(buffer);
        Stream stream = File.Open(path + "MiaoBoxLocal", FileMode.Create);

        stream.Write(buffer, 0, buffer.Length);
        stream.Flush();
        stream.Close();
        Debug.Log("save");
    }
Ejemplo n.º 3
0
        /*
         * //try
         * //{
         * //  ////get list of column name
         * //  //List fieldList = TDConnHandle.get_Fields("TEST");
         * //  //int a = fieldList.Count;
         * //  //foreach (TDField aField in fieldList)
         * //  //{
         * //  //  Console.WriteLine("Field name:{0}", aField.Name);
         * //  //}
         *
         * //  //TestSetTreeManager TestSetTreeMana = TDConnHandle.TestSetTreeManager as TestSetTreeManager;
         * //  //TestSetFolder TestSetFolderPath = TestSetTreeMana.get_NodeByPath(rootPath) as TestSetFolder;
         * //  ////Add a new folder under the rootPath
         * //  //SysTreeNode CurTestSetFolder = TestSetFolderPath.AddNode(TestSetFolderName) as SysTreeNode;
         * //  //CurTestSetFolder.Post();
         *
         * //  ////The new test set will be added under the newly test folder
         * //  //TestSetFolder TSFolder = TestSetTreeMana.get_NodeById(CurTestSetFolder.NodeID) as TestSetFolder;
         * //  //TestSetFactory TSFact = TSFolder.TestSetFactory as TestSetFactory;
         *
         * //  //TestFactory TestFact = TDConnHandle.TestFactory as TestFactory;
         * //  //TDFilter TFilter = TestFact.Filter as TDFilter;
         * //  ////All match item will be filtered by the provided field and value
         * //  //foreach (TestConfigFile.AutorunFilerConfig filter in TConfig.CaseFilter.AutorunFilter)
         * //  //{
         * //  //  TFilter[filter.FieldName] = filter.FieldValue;
         * //  //}
         *
         * //  ////All matched test cases will be storaged in TList temporarily
         * //  //List TList = TFilter.NewList();
         *
         * //  ////Add test set name
         * //  //TestSet TestSetName;
         * //  //TSTestFactory TSTestFact;
         *
         * //  //TestSetName = TSFact.AddItem("test set 1") as TestSet;
         * //  //TestSetName.Post();
         * //  //TSTestFact = TestSetName.TSTestFactory as TSTestFactory;
         *
         * //  //foreach (Test t in TList)
         * //  //{
         *
         * //  //  TSTestFact.AddItem(t.ID);
         * //  //}
         * //  //All test cases will be saved into the specified folder's testSet
         * //  return true;
         * //}
         * //catch (Exception e)
         * //{
         * //  Console.WriteLine("Create Test Cases Error!");
         * //  Console.WriteLine("{0}", e.Message);
         * //  return false;
         * //}
         * */


        //According to the search conditions defined in XML, generate a list of TestSet names
        private List <string> GetAllTestSetNames(string TestSetNameField)
        {
            // Using SQL and ICommand to get the specified filed values, and store them to a List
            try
            {
                ICommand com = tdConn.Command as ICommand;
                com.CommandText = "select distinct " + TestSetNameField + " from test";
                IRecordset recList = com.Execute() as IRecordset;
                // Console.WriteLine("Get record count: {0}", recList.RecordCount);

                recList.First();
                object        specColumnValue;
                List <string> TestSetNameList = new List <string>();

                while (!recList.EOR)
                {
                    specColumnValue = recList[TestSetNameField];
                    if (specColumnValue != null)
                    {
                        TestSetNameList.Insert(0, specColumnValue.ToString());
                    }
                    recList.Next();
                }
                return(TestSetNameList);
            }
            catch (Exception e)
            {
                AutoLog.Info("AutoIntSys: Exception with " + e.Message);
                AutoLog.Info("AutoIntSys: Fail to get Specified Field Value from TEST Table!");
                //Debug.Print("AutoIntSys:" + e);
                //Debug.Print("AutoIntSys:Fail to get Specified Field Value from TEST Table!");
                return(null);
            }
        }
Ejemplo n.º 4
0
        private string ExtractXmlFromRecordset(IRecordset data)
        {
            var fixedXml = data.GetFixedXML(RecordsetXMLModeEnum.rxmData);

            if (string.IsNullOrEmpty(fixedXml))
            {
                return(string.Empty);
            }

            return(fixedXml.Replace(SapNamespace, string.Empty));
        }
Ejemplo n.º 5
0
        public static XmlRecordsetReader CreateNew([NotNull] IRecordset data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var reader = new XmlRecordsetReader();

            reader.Load(data);

            return(reader);
        }
Ejemplo n.º 6
0
    public static IRecordset CreateRecord(string version)
    {
        IRecordset rec = null;

#if UNITY_EDITOR
        UnityEngine.Debug.Log("version = " + version);
#endif

        if (version.Equals(Record100.mVersion))
        {
            rec = new Record100();
        }

        return(rec);
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Obtiene el listado de sucursales para los rangos activos
        /// </summary>
        /// <param name="comp"></param>
        /// <returns></returns>
        public List <string> ObtenerSucursales()
        {
            IRecordset    recSet          = null;
            string        consulta        = "";
            List <string> listaSucursales = new List <string>();

            try
            {
                //Obtener objeto estandar de record set
                recSet = ProcConexion.Comp.GetBusinessObject(BoObjectTypes.BoRecordset);

                //Establecer consulta
                consulta = "SELECT DISTINCT(U_Sucursal) FROM [@TFECAE] WHERE U_ValDesde <= GETDATE() AND U_ValHasta >= GETDATE()";

                //Ejecutar consulta
                recSet.DoQuery(consulta);

                recSet.MoveFirst();

                for (int i = 0; i < recSet.RecordCount; i++)
                {
                    listaSucursales.Add(recSet.Fields.Item("U_Sucursal").Value + "");
                    recSet.MoveNext();
                }
            }
            catch (Exception)
            {
                listaSucursales = null;
            }
            finally
            {
                if (recSet != null)
                {
                    //Liberar memoria utilizada por el objeto record set
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(recSet);
                    System.GC.Collect();
                }
            }
            return(listaSucursales);
        }
Ejemplo n.º 8
0
        public static IEnumerable <TDestiny> AsEnumerable <TDestiny>(IRecordset source, bool useXmlAttributes = true)
            where TDestiny : new()
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (source.RecordCount == 0)
            {
                yield break;
            }

            source.MoveFirst();

            var fnMemberInit = GetMemberInit <TDestiny>(source.Fields, useXmlAttributes).Compile();

            while (!source.EoF)
            {
                yield return(fnMemberInit(source.Fields));

                source.MoveNext();
            }
        }
Ejemplo n.º 9
0
    public byte LocalLoad()
    {
        string path = Application.persistentDataPath + "/Documents/";

        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXEditor)
        {
            path = Application.dataPath + "/../Documents/";
        }

        if (File.Exists(path + "MiaoBoxLocal"))
        {
            Stream stream   = File.Open(path + "MiaoBoxLocal", FileMode.Open);
            byte[] original = GetBytesFromStream(stream);
            byte[] buffer   = DecryptBuffer(original);
            stream.Close();
            MemoryStream ms  = new MemoryStream(buffer);
            BinaryReader br  = new BinaryReader(ms);
            string       ver = string.Empty;
            try
            {
                Debug.Log("Load");

                //BinaryReader.ReadString()方法如何确定从数据流中读多少内容
                //是这样的,BinaryReader.ReadString是和BinaryWriter.Write(string)配合使用的。
                //使用后者写入文件的时候,如果写入字符串,是会将字符串的长度也写在文件中的。你可以用BinaryWriter.Write(string)写入文件

                ver          = br.ReadString();
                mReadVersion = ver;
                IRecordset rec = RecordFactory.CreateRecord(mReadVersion);
                if (rec != null)
                {
                    rec.LoadData(br);
                }
            }
            catch (System.Exception e)
            {
                Debug.LogWarning("Version: " + ver);
                Debug.LogWarning(e.StackTrace);

                if (!File.Exists(path + "MiaoBoxLocal" + "_" + ver))
                {
                    File.Copy(path + "MiaoBoxLocal", path + "MiaoBoxLocal" + "_" + ver);
                }
                return(1);
            }
            finally
            {
                br.Close();
                ms.Close();
            }

            if (!ver.Equals(mVersion))
            {
                LocalSave();
            }
            return(0);
        }
        else
        {
            return(2);
        }
    }
Ejemplo n.º 10
0
        private TestSetFolder CreateTestSetNames(List <string> TestSetNames, TestSetFolder TSFolder)
        {
            List <ItemValue> tcList = new List <ItemValue>();

            #region Generate TestSet Name
            //Get all match test cases and store it to a List
            try
            {
                ICommand com        = tdConn.Command as ICommand;
                string[] columnName = { "TS_TEST_ID", configFile.CaseFilter.TestSetName };

                string sqlCommand = GenerateSQLText(columnName);
                com.CommandText = sqlCommand;

                IRecordset recList = com.Execute() as IRecordset;

                recList.First();
                for (int num = 0; num < recList.RecordCount; num++)
                {
                    ItemValue tc = new ItemValue();
                    tc.Test_ID = recList["TS_TEST_ID"].ToString();
                    if (recList[configFile.CaseFilter.TestSetName] != null)
                    {
                        tc.Test_Custom = recList[configFile.CaseFilter.TestSetName].ToString();
                    }
                    tcList.Insert(0, tc);
                    recList.Next();
                }
            }
            catch (Exception e)
            {
                AutoLog.Info("AutoIntSys: Exception with " + e.Message);
                AutoLog.Info("AutoIntSys: Fail to get Specified Field Value from TEST Table!");
                //Debug.Print("AutoIntSys:Fail to get Specified Field Value from TEST Table!");
                //Debug.Print("AutoIntSys:" + e);
                return(null);
            }
            #endregion

            #region Generate TestSet
            try
            {
                TestSetFactory TSFact   = TSFolder.TestSetFactory as TestSetFactory;
                TestFactory    TestFact = tdConn.TestFactory as TestFactory;
                foreach (string TSName in TestSetNames)
                {
                    TestSet       TestSetName;
                    TSTestFactory TSTestFact;

                    TestSetName = TSFact.AddItem(TSName) as TestSet;
                    TestSetName.Post();
                    TSTestFact = TestSetName.TSTestFactory as TSTestFactory;

                    foreach (ItemValue t in tcList)
                    {
                        if (t.Test_Custom == TSName)
                        {
                            TSTestFact.AddItem(t.Test_ID);
                        }
                    }
                }

                createTSSucess = true;
                return(TSFolder);
            }
            catch (Exception e)
            {
                AutoLog.Info("AutoIntSys: Exception with " + e.Message);
                AutoLog.Info("AutoIntSys: Create Test Sets Error!");
                //Debug.Print("AutoIntSys:Create Test Sets Error!");
                //Debug.Print("AutoIntSys:" + e.Message);
                return(null);
            }
            #endregion
        }