コード例 #1
0
        public static void Initialize(TestContext context)
        {
            ARSession session = new ARSession();

            try
            {
                session.Login(TestServer, TestAdmin, TestAdminPwd);
                int            totalCount = -1;
                List <AREntry> allentries = session.GetEntryList(
                    TestRegularFormName,
                    null,
                    null,
                    null,
                    null,
                    ref totalCount,
                    null);

                foreach (AREntry entry in allentries)
                {
                    session.DeleteEntry(TestRegularFormName, entry.EntryIds.ToArray());
                }
            }
            catch (ARException ex)
            {
            }
            finally
            {
                session.LogOut();
            }
        }
コード例 #2
0
        public static void Cleanup()
        {
            //cleanup the user which has been created in Initialize
            ARSession session = new ARSession();

            try
            {
                session.Login(TestServer, TestAdmin, TestAdminPwd);
                List <uint> fieldIds = new List <uint>();
                fieldIds.Add(1u);
                int total = -1;
                var entry = session.GetEntryList("User", "'101'=\"周平\"", fieldIds.ToArray(), null, null, ref total, null);
                if (entry != null || entry.Count != 0)
                {
                    foreach (var e in entry)
                    {
                        session.DeleteEntry("User", e.EntryIds.ToArray());
                    }
                }
            }
            finally
            {
                session.LogOut();
            }
        }
コード例 #3
0
        public static void Initialize(TestContext context)
        {
            ARSession session = new ARSession();
            try
            {
                session.Login(TestServer,TestAdmin,TestAdminPwd);
                int totalCount = -1;
                List<AREntry> allentries = session.GetEntryList(
                    TestRegularFormName,
                    null,
                    null,
                    null,
                    null,
                    ref totalCount,
                    null);

                foreach (AREntry entry in allentries)
                {
                    session.DeleteEntry(TestRegularFormName,entry.EntryIds.ToArray());
                }

            }
            catch (ARException ex)
            {

            }
            finally
            {
                session.LogOut();
            }
        }
コード例 #4
0
        public void GetEntryList_qulifier_fieldIds_nopage_nocount_noorder_success()
        {
            ARSession session = new ARSession();

            try
            {
                int total = -1;
                session.Login(TestServer, TestAdmin, TestAdminPwd);
                List <UInt32> fieldIds = new List <UInt32>();
                fieldIds.Add(TestCharacterFieldId);
                fieldIds.Add(TestIntFieldId);
                //fieldIds.Add(1);
                var retlist = session.GetEntryList(
                    TestRegularFormName,
                    "'Character Field' LIKE \"%你好%\"",
                    fieldIds.ToArray(),
                    null,
                    null,
                    ref total,
                    null
                    );
                Assert.AreEqual(11, retlist.Count);
                Assert.AreEqual(-1, total);
                foreach (var entry in retlist)
                {
                    //Assert.AreEqual(entry.EntryIds.First(), entry.FieldValues.First(f => f.FieldId == 1).Value.ToString());
                    Assert.IsTrue(entry.FieldValues.First(f => f.FieldId == TestCharacterFieldId).Value.ToString().Contains("你好"));
                }
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            session.LogOut();
        }
コード例 #5
0
        public static void Initialize(TestContext context)
        {
            ARSession session = new ARSession();

            try
            {
                session.Login(TestServer, TestAdmin, TestAdminPwd);
                int            totalCount = -1;
                List <AREntry> allentries = session.GetEntryList(
                    TestRegularFormName,
                    null,
                    null,
                    null,
                    null,
                    ref totalCount,
                    null);

                foreach (AREntry entry in allentries)
                {
                    session.DeleteEntry(TestRegularFormName, entry.EntryIds.ToArray());
                }

                //add test data
                List <ARFieldValue> fv1 = new List <ARFieldValue>();
                fv1.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValue, ARDataType.DATA_TYPE_CHAR));
                fv1.Add(new ARFieldValue(TestIntFieldId, 1, ARDataType.DATA_TYPE_INTEGER));
                List <ARFieldValue> fv2 = new List <ARFieldValue>();
                fv2.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValueChinese, ARDataType.DATA_TYPE_CHAR));
                fv2.Add(new ARFieldValue(TestIntFieldId, 1, ARDataType.DATA_TYPE_INTEGER));
                List <ARFieldValue> fv3 = new List <ARFieldValue>();
                fv3.Add(new ARFieldValue(TestCharacterFieldId, (object)(TestCharacterFieldValueChinese + "Set Something"), ARDataType.DATA_TYPE_CHAR));
                fv3.Add(new ARFieldValue(TestIntFieldId, 1, ARDataType.DATA_TYPE_INTEGER));

                for (int i = 0; i < 7; i++)
                {
                    session.CreateEntry(TestRegularFormName, fv1.ToArray());
                }
                for (int i = 0; i < 9; i++)
                {
                    session.CreateEntry(TestRegularFormName, fv2.ToArray());
                }
                for (int i = 0; i < 2; i++)
                {
                    session.CreateEntry(TestRegularFormName, fv3.ToArray());
                }
            }
            catch (ARException ex)
            {
            }
            finally
            {
                session.LogOut();
            }
        }
コード例 #6
0
        public static void Initialize(TestContext context)
        {
            ARSession session = new ARSession();
            try
            {
                session.Login(TestServer, TestAdmin, TestAdminPwd);
                int totalCount = -1;
                List<AREntry> allentries = session.GetEntryList(
                    TestRegularFormName,
                    null,
                    null,
                    null,
                    null,
                    ref totalCount,
                    null);

                foreach (AREntry entry in allentries)
                {
                    session.DeleteEntry(TestRegularFormName, entry.EntryIds.ToArray());
                }

                //add test data
                List<ARFieldValue> fv1 = new List<ARFieldValue>();
                fv1.Add(new ARFieldValue(TestCharacterFieldId,(object)TestCharacterFieldValue,ARDataType.DATA_TYPE_CHAR));
                fv1.Add(new ARFieldValue(TestIntFieldId,1,ARDataType.DATA_TYPE_INTEGER));
                List<ARFieldValue> fv2 = new List<ARFieldValue>();
                fv2.Add(new ARFieldValue(TestCharacterFieldId,(object)TestCharacterFieldValueChinese,ARDataType.DATA_TYPE_CHAR));
                fv2.Add(new ARFieldValue(TestIntFieldId,1,ARDataType.DATA_TYPE_INTEGER));
                List<ARFieldValue> fv3 = new List<ARFieldValue>();
                fv3.Add(new ARFieldValue(TestCharacterFieldId,(object)(TestCharacterFieldValueChinese + "Set Something"),ARDataType.DATA_TYPE_CHAR));
                fv3.Add(new ARFieldValue(TestIntFieldId,1,ARDataType.DATA_TYPE_INTEGER));

                for (int i = 0; i < 7; i++)
                    session.CreateEntry(TestRegularFormName, fv1.ToArray());
                for (int i = 0; i < 9; i++)
                    session.CreateEntry(TestRegularFormName, fv2.ToArray());
                for (int i = 0; i < 2; i++)
                    session.CreateEntry(TestRegularFormName, fv3.ToArray());

            }
            catch (ARException ex)
            {

            }
            finally
            {
                session.LogOut();
            }
        }
コード例 #7
0
        public void GetEntryList_qulifier_fieldIds_nopage_hascount_hasorder_success()
        {
            ARSession session = new ARSession();

            try
            {
                int total = 0;
                session.Login(TestServer, TestAdmin, TestAdminPwd);
                List <UInt32> fieldIds = new List <UInt32>();
                fieldIds.Add(TestCharacterFieldId);
                fieldIds.Add(TestIntFieldId);
                List <ARSortInfo> sortInfo = new List <ARSortInfo>();
                sortInfo.Add(new ARSortInfo {
                    FieldId = TestCharacterFieldId,
                    Order   = SortOrder.SORT_DESCENDING
                });
                var retlist = session.GetEntryList(
                    TestRegularFormName,
                    "'Character Field' LIKE \"%你好%\"",
                    fieldIds.ToArray(),
                    null,
                    null,
                    ref total,
                    sortInfo.ToArray()
                    );
                Assert.AreEqual(11, retlist.Count);
                Assert.AreEqual(11, total);
                foreach (var entry in retlist)
                {
                    //Assert.AreEqual(entry.EntryIds.First(), entry.FieldValues.First(f => f.FieldId == 1).Value.ToString());
                    Assert.IsTrue(entry.FieldValues.First(f => f.FieldId == TestCharacterFieldId).Value.ToString().Contains("你好"));
                }

                string maxentrylist = retlist.Max(e => e.EntryIds.First());
                string minentrylist = retlist.Min(e => e.EntryIds.First());
                Assert.AreEqual(10, Convert.ToInt32(maxentrylist) - Convert.ToInt32(minentrylist));

                Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[0].FieldValues[0].Value);
                Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[1].FieldValues[0].Value);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            session.LogOut();
        }
コード例 #8
0
 public static void Cleanup()
 {
     //cleanup the user which has been created in Initialize
     ARSession session = new ARSession();
     try
     {
         session.Login(TestServer, TestAdmin, TestAdminPwd);
         List<uint> fieldIds = new List<uint>();
         fieldIds.Add(1u);
         int total = -1;
         var entry = session.GetEntryList("User", "'101'=\"周平\"", fieldIds.ToArray(), null, null, ref total, null);
         if (entry != null || entry.Count != 0){
             foreach (var e in entry)
                 session.DeleteEntry("User", e.EntryIds.ToArray());
         }
     }
     finally
     {
         session.LogOut();
     }
 }
コード例 #9
0
ファイル: ARSession.BLOB.Test.cs プロジェクト: cjdtppmm/PChou
        public void ARSession_Create_Entry_with_Att_01()
        {
            ARSession session = new ARSession();

            try
            {
                session.Login(TestServer, TestAdmin, TestAdminPwd);

                /* create entry with att and get it for assert */
                string testStr = "先假设这就是附件内容";

                byte[] buff = Encoding.UTF8.GetBytes(testStr);

                List <ARFieldValue> fvl = new List <ARFieldValue>();
                fvl.Add(new ARFieldValue
                {
                    FieldId  = attchFId,
                    DataType = ARDataType.DATA_TYPE_ATTACH,
                    Value    = new ARAttachment
                    {
                        AttchmentName = "附件.txt",
                        Buff          = buff
                    }
                });

                fvl.Add(new ARFieldValue(TestCharacterFieldId, "Attachment Flag", ARDataType.DATA_TYPE_CHAR));

                string entryId = session.CreateEntry(TestRegularFormName, fvl.ToArray());

                Assert.IsNotNull(entryId);

                List <uint> fieldIds = new List <uint>();
                fieldIds.Add(attchFId);
                List <string> entryIds = new List <string>();
                entryIds.Add(entryId);

                List <ARFieldValue> arfvl = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray());

                Assert.AreEqual(1, arfvl.Count);
                Assert.IsTrue(arfvl[0].Value is ARAttachment);

                ARAttachment att = (ARAttachment)arfvl[0].Value;

                String rStr = Encoding.UTF8.GetString(att.Buff);

                Assert.AreEqual(
                    testStr,
                    rStr);



                byte[] setByte = Encoding.UTF8.GetBytes(testStr + " after set.");
                List <ARFieldValue> set_arfvl = new List <ARFieldValue>();
                set_arfvl.Add(new ARFieldValue {
                    DataType = ARDataType.DATA_TYPE_ATTACH,
                    FieldId  = attchFId,
                    Value    = new ARAttachment
                    {
                        AttchmentName = "ARSession_Create_Entry_with_Att_01.txt",
                        Buff          = setByte
                    }
                });
                session.SetEntry(TestRegularFormName, entryIds.ToArray(), set_arfvl.ToArray());



                /* Get blob from the entry */
                byte[] buffer = session.GetBLOB(TestRegularFormName, entryIds.ToArray(), attchFId);
                String rStr2  = Encoding.UTF8.GetString(buffer);
                Assert.AreEqual(
                    testStr + " after set.",
                    rStr2);

                /* Get entry list */
                int total = -1;

                var listEntry = session.GetEntryList(TestRegularFormName,

                                                     "'Character Field' = \"Attachment Flag\""
                                                     , fieldIds.ToArray(), null, null, ref total, null);

                foreach (var l in listEntry)
                {
                    Assert.IsTrue(l.FieldValues[0].Value is ARAttachment);
                    ARAttachment att2  = (ARAttachment)l.FieldValues[0].Value;
                    String       rStr3 = Encoding.UTF8.GetString(att2.Buff);
                    Assert.AreEqual(
                        testStr + " after set.",
                        rStr3);
                }
            }
            catch (ARException ex)
            {
                Assert.AreEqual(null, ex);
            }
            session.LogOut();
        }
コード例 #10
0
        public List <AREntry> GetEntryList(string SchemaName, string Qulification, List <uint> FieldIdList, uint StartIndex, uint?RetrieveCount, ref int totalMatch, List <ARSortInfo> SortInfo)
        {
            CheckSessionNull();

            //try to get the SERVER_INFO_MAX_ENTRIES when first GetEntryList call
            //consider multi-thread problem
            if (SERVER_INFO_MAX_ENTRIES == -1)
            {
                //thread may suspend just here,so we had better double check the SERVER_INFO_MAX_ENTRIES
                lock (_lock){
                    if (SERVER_INFO_MAX_ENTRIES == -1)
                    {
                        List <uint> request = new List <uint>()
                        {
                            (uint)ServerInfoType.SERVER_INFO_MAX_ENTRIES
                        };
                        var result = SessionInstance.GetServerInfo(request.ToArray());
                        SERVER_INFO_MAX_ENTRIES = (int)result[0].Value;
                    }
                }
            }

            //if SERVER_INFO_MAX_ENTRIES is 0 or -1, no need to cut page
            if ((SERVER_INFO_MAX_ENTRIES == 0 || SERVER_INFO_MAX_ENTRIES == -1)
                //if maxEntriesPerQuery can cover per Query,only one query needed.
                || RetrieveCount <= SERVER_INFO_MAX_ENTRIES)
            {
                return(SessionInstance.GetEntryList(
                           SchemaName,
                           Qulification,
                           FieldIdList == null ? null : FieldIdList.ToArray(),
                           StartIndex,
                           RetrieveCount,
                           ref totalMatch,
                           SortInfo == null ? null : SortInfo.ToArray()
                           ));
            }
            else
            {
                List <AREntry> list = new List <AREntry>();
                //if StartIndex or RetrieveCount is null, all records should be return
                if (StartIndex == null || RetrieveCount == null)
                {
                    uint startIndex = StartIndex;
                    int  totalm     = -1;
                    do
                    {
                        var l = SessionInstance.GetEntryList(SchemaName, Qulification,
                                                             FieldIdList == null ? null : FieldIdList.ToArray(),
                                                             startIndex, (uint)SERVER_INFO_MAX_ENTRIES, ref totalm, //loop the page
                                                             SortInfo == null ? null : SortInfo.ToArray());
                        if (l.Count <= 0)
                        {
                            break;
                        }
                        list.AddRange(l);
                        startIndex += (uint)SERVER_INFO_MAX_ENTRIES;
                    }while (true);
                    if (totalMatch != -1)
                    {
                        totalMatch = list.Count;
                    }
                }
                //if both StartIndex and RetrieveCount is not null, only one page should be return
                else
                {
                    uint startIndex2 = (uint)StartIndex;
                    //we must seperaly use the parameter : totalMatch, in order to get the totalMatch once in this case
                    var l2 = SessionInstance.GetEntryList(SchemaName, Qulification,
                                                          FieldIdList == null ? null : FieldIdList.ToArray(),
                                                          startIndex2, (uint)SERVER_INFO_MAX_ENTRIES, ref totalMatch,
                                                          SortInfo == null ? null : SortInfo.ToArray());
                    int reservedCount = (int)RetrieveCount - SERVER_INFO_MAX_ENTRIES;
                    startIndex2 += (uint)SERVER_INFO_MAX_ENTRIES;
                    list.AddRange(l2);
                    int tlm = -1; //avoid count(*) multiple times
                    while (reservedCount > 0)
                    {
                        List <AREntry> l3;
                        if (reservedCount > SERVER_INFO_MAX_ENTRIES)
                        {
                            l3 = SessionInstance.GetEntryList(SchemaName, Qulification,
                                                              FieldIdList == null ? null : FieldIdList.ToArray(),
                                                              startIndex2, (uint)SERVER_INFO_MAX_ENTRIES, ref tlm,
                                                              SortInfo == null ? null : SortInfo.ToArray());
                            reservedCount = reservedCount - SERVER_INFO_MAX_ENTRIES;
                            startIndex2  += (uint)SERVER_INFO_MAX_ENTRIES;
                        }
                        else
                        {
                            l3 = SessionInstance.GetEntryList(SchemaName, Qulification,
                                                              FieldIdList == null ? null : FieldIdList.ToArray(),
                                                              startIndex2, (uint)reservedCount, ref tlm,
                                                              SortInfo == null ? null : SortInfo.ToArray());
                            reservedCount = 0;
                        }
                        list.AddRange(l3);
                    }
                }

                return(list);
            }
        }
コード例 #11
0
        public void GetEntryList_qulifier_fieldIds_nopage_nocount_noorder_success()
        {
            ARSession session = new ARSession();
            try
            {
                int total = -1;
                session.Login(TestServer, TestAdmin, TestAdminPwd);
                List<UInt32> fieldIds = new List<UInt32>();
                fieldIds.Add(TestCharacterFieldId);
                fieldIds.Add(TestIntFieldId);
                //fieldIds.Add(1);
                var retlist = session.GetEntryList(
                    TestRegularFormName,
                    "'Character Field' LIKE \"%你好%\"",
                    fieldIds.ToArray(),
                    null,
                    null,
                    ref total,
                    null
                    );
                Assert.AreEqual(11, retlist.Count);
                Assert.AreEqual(-1, total);
                foreach (var entry in retlist)
                {
                    //Assert.AreEqual(entry.EntryIds.First(), entry.FieldValues.First(f => f.FieldId == 1).Value.ToString());
                    Assert.IsTrue(entry.FieldValues.First(f => f.FieldId == TestCharacterFieldId).Value.ToString().Contains("你好"));
                }

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);

            }
            session.LogOut();
        }
コード例 #12
0
        public void GetEntryList_qulifier_fieldIds_nopage_hascount_hasorder_success()
        {
            ARSession session = new ARSession();
            try
            {
                int total = 0;
                session.Login(TestServer, TestAdmin, TestAdminPwd);
                List<UInt32> fieldIds = new List<UInt32>();
                fieldIds.Add(TestCharacterFieldId);
                fieldIds.Add(TestIntFieldId);
                List<ARSortInfo> sortInfo = new List<ARSortInfo>();
                sortInfo.Add(new ARSortInfo {
                    FieldId = TestCharacterFieldId,
                    Order = SortOrder.SORT_DESCENDING
                });
                var retlist = session.GetEntryList(
                    TestRegularFormName,
                    "'Character Field' LIKE \"%你好%\"",
                    fieldIds.ToArray(),
                    null,
                    null,
                    ref total,
                    sortInfo.ToArray()
                    );
                Assert.AreEqual(11, retlist.Count);
                Assert.AreEqual(11, total);
                foreach (var entry in retlist)
                {
                    //Assert.AreEqual(entry.EntryIds.First(), entry.FieldValues.First(f => f.FieldId == 1).Value.ToString());
                    Assert.IsTrue(entry.FieldValues.First(f => f.FieldId == TestCharacterFieldId).Value.ToString().Contains("你好"));
                }

                string maxentrylist = retlist.Max(e => e.EntryIds.First());
                string minentrylist = retlist.Min(e => e.EntryIds.First());
                Assert.AreEqual(10, Convert.ToInt32(maxentrylist) - Convert.ToInt32(minentrylist));

                Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[0].FieldValues[0].Value);
                Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[1].FieldValues[0].Value);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);

            }
            session.LogOut();
        }
コード例 #13
0
        public void ARSession_Create_Entry_with_Att_01()
        {
            ARSession session = new ARSession();
            try
            {
                session.Login(TestServer, TestAdmin, TestAdminPwd);

                /* create entry with att and get it for assert */
                string testStr = "先假设这就是附件内容";

                byte[] buff = Encoding.UTF8.GetBytes(testStr);

                List<ARFieldValue> fvl = new List<ARFieldValue>();
                fvl.Add(new ARFieldValue
                {
                    FieldId = attchFId,
                    DataType = ARDataType.DATA_TYPE_ATTACH,
                    Value = new ARAttachment
                    {
                        AttchmentName = "附件.txt",
                        Buff = buff
                    }
                });

                fvl.Add(new ARFieldValue(TestCharacterFieldId, "Attachment Flag", ARDataType.DATA_TYPE_CHAR));

                string entryId = session.CreateEntry(TestRegularFormName, fvl.ToArray());

                Assert.IsNotNull(entryId);

                List<uint> fieldIds = new List<uint>();
                fieldIds.Add(attchFId);
                List<string> entryIds = new List<string>();
                entryIds.Add(entryId);

                List<ARFieldValue> arfvl = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray());

                Assert.AreEqual(1, arfvl.Count);
                Assert.IsTrue(arfvl[0].Value is ARAttachment);

                ARAttachment att = (ARAttachment)arfvl[0].Value;

                String rStr = Encoding.UTF8.GetString(att.Buff);

                Assert.AreEqual(
                    testStr,
                    rStr);

                byte[] setByte = Encoding.UTF8.GetBytes(testStr + " after set.");
                List<ARFieldValue> set_arfvl = new List<ARFieldValue>();
                set_arfvl.Add(new ARFieldValue{
                    DataType = ARDataType.DATA_TYPE_ATTACH,
                    FieldId = attchFId,
                    Value = new ARAttachment
                    {
                        AttchmentName = "ARSession_Create_Entry_with_Att_01.txt",
                        Buff = setByte
                    }
                });
                session.SetEntry(TestRegularFormName, entryIds.ToArray(), set_arfvl.ToArray());

                /* Get blob from the entry */
                byte[] buffer = session.GetBLOB(TestRegularFormName, entryIds.ToArray(), attchFId);
                String rStr2 = Encoding.UTF8.GetString(buffer);
                Assert.AreEqual(
                    testStr + " after set.",
                    rStr2);

                /* Get entry list */
                int total = -1;

                var listEntry = session.GetEntryList(TestRegularFormName,

                    "'Character Field' = \"Attachment Flag\""
                    , fieldIds.ToArray(), null, null, ref total, null);

                foreach (var l in listEntry)
                {
                    Assert.IsTrue(l.FieldValues[0].Value is ARAttachment);
                    ARAttachment att2 = (ARAttachment)l.FieldValues[0].Value;
                    String rStr3 = Encoding.UTF8.GetString(att2.Buff);
                    Assert.AreEqual(
                        testStr + " after set.",
                        rStr3);
                }

            }
            catch (ARException ex)
            {
                Assert.AreEqual(null, ex);
            }
            session.LogOut();
        }