示例#1
0
        public void testZipMsg()
        {
            byte[] outBytes = null;
            uint   outSize  = 0;

            byte[] inBytes = null;
            uint   inSize  = 0;

            ByteBuffer     pByteBuffer  = new ByteBuffer();
            UnitTestStrCmd pUnitTestCmd = new UnitTestStrCmd();

            // 发送第一个数据包
            pUnitTestCmd.testStr = "测试数据";
            pByteBuffer.clear();
            pUnitTestCmd.serialize(pByteBuffer);

            Compress.CompressData(pByteBuffer.dynBuff.buff, 0, pByteBuffer.length, ref outBytes, ref outSize);
            Compress.DecompressData(outBytes, 0, outSize, ref inBytes, ref inSize);

            pByteBuffer.clear();
            pByteBuffer.writeBytes(inBytes, 0, inSize);
            pByteBuffer.position = 0;
            pUnitTestCmd.derialize(pByteBuffer);

            UAssert.DebugAssert(pUnitTestCmd.testStr != "测试数据");
        }
示例#2
0
        public void WriteAppealToFile(string fullName, string phoneNumber, string date, string currentHour, string currentMinute, string status, string role, string email, string company, string appeal, string additionalInfo)
        {
            if (File.Exists(pathToAppeals))
            {
                File.Delete(pathToAppeals);
            }
            if (!File.Exists(pathToZipAppeals))
            {
                XDocument appeals = new XDocument(
                    new XComment("Обращения в службу поддержки ГИИС ДМДК"),
                    new XElement("Appeals",
                                 new XElement("Appeal",
                                              new XElement("fullName", fullName),
                                              new XElement("phoneNumber", phoneNumber),
                                              new XElement("date", date),
                                              new XElement("currentHour", currentHour),
                                              new XElement("currentMinute", currentMinute),
                                              new XElement("status", status),
                                              new XElement("role", role),
                                              new XElement("email", email),
                                              new XElement("company", company),
                                              new XElement("appeal", appeal),
                                              new XElement("additionalInfo", additionalInfo),
                                              new XElement("user", StaticData.User))
                                 )
                    );
                appeals.Save(pathToAppeals);
            }
            else
            {
                fileArchiving.DecompressData(pathToZipAppeals);
                XDocument appeals = XDocument.Load(pathToAppeals);

                XElement root = new XElement("Appeal");
                root.Add(new XElement("fullName", fullName));
                root.Add(new XElement("phoneNumber", phoneNumber));
                root.Add(new XElement("date", date));
                root.Add(new XElement("currentHour", currentHour));
                root.Add(new XElement("currentMinute", currentMinute));
                root.Add(new XElement("status", status));
                root.Add(new XElement("role", role));
                root.Add(new XElement("email", email));
                root.Add(new XElement("company", company));
                root.Add(new XElement("appeal", appeal));
                root.Add(new XElement("additionalInfo", additionalInfo));
                root.Add(new XElement("user", StaticData.User));
                appeals.Element("Appeals").Add(root);
                appeals.Save(pathToAppeals);
            }

            fileArchiving.CompressData(pathToAppeals, pathToZipAppeals);
            File.Delete(pathToAppeals);
        }
示例#3
0
        internal List <string[]> FillCallLog()
        {
            List <string[]> appeals = new List <string[]>();

            compress.DecompressData(_pathToZipAppeals);
            appeals = fileWorker.GetAppeals();
            File.Delete(_pathToAppeals);
            return(appeals);
            //using (StreamReader sr = new StreamReader(_pathToAppeals, Encoding.Unicode))
            //{
            //    int lenghtAppeal = 0;
            //    string temp;
            //    while (true)
            //    {
            //        temp = sr.ReadLine();

            //        if (temp == null || temp.Length < 1) break;
            //        lenghtAppeal++;
            //        while (true)
            //        {
            //            temp += sr.ReadLine();
            //            if (temp.Substring(temp.Length - 5, 5) == "%%#%%")
            //            {
            //                lenghtAppeal++;
            //                if (lenghtAppeal == 11)
            //                    break;
            //            }
            //            else temp += "\r";
            //        }
            //        string[] symbolsSplit = new string[] { "%%#%%" };
            //        string[] lines = temp.Split(symbolsSplit, StringSplitOptions.None);
            //        appeals.Add(lines);
            //        lenghtAppeal = 0;
            //    }
            //}

            //File.Delete(_pathToAppeals);
            //return appeals;
        }
示例#4
0
        public List <List <string> > GetAppeals()
        {
            StaticData.ClearData();
            fileArchiving.DecompressData(pathToZipAppeals);
            List <List <string> > appeals = new List <List <string> >();
            List <string>         appeal;
            XDocument             xdoc = XDocument.Load(pathToAppeals);

            foreach (XElement currentAppeal in xdoc.Element("Appeals").Elements("Appeal"))
            {
                appeal = new List <string>();

                XElement fullNameElement       = currentAppeal.Element("fullName");
                XElement phoneNumberElement    = currentAppeal.Element("phoneNumber");
                XElement dateElement           = currentAppeal.Element("date");
                XElement currentHourElement    = currentAppeal.Element("currentHour");
                XElement currentMinuteElement  = currentAppeal.Element("currentMinute");
                XElement statusElement         = currentAppeal.Element("status");
                XElement roleElement           = currentAppeal.Element("role");
                XElement emailElement          = currentAppeal.Element("email");
                XElement companyElement        = currentAppeal.Element("company");
                XElement appealElement         = currentAppeal.Element("appeal");
                XElement additionalInfoElement = currentAppeal.Element("additionalInfo");
                XElement userElement           = currentAppeal.Element("user");

                appeal.Add(fullNameElement.Value);
                appeal.Add(phoneNumberElement.Value);
                appeal.Add(dateElement.Value);
                appeal.Add(currentHourElement.Value);
                appeal.Add(currentMinuteElement.Value);
                appeal.Add(statusElement.Value);
                appeal.Add(roleElement.Value);
                appeal.Add(emailElement.Value);
                appeal.Add(companyElement.Value);
                appeal.Add(appealElement.Value);
                appeal.Add(additionalInfoElement.Value);
                appeal.Add(userElement.Value);
                appeals.Add(appeal);
                FillDataUser(statusElement.Value, userElement.Value);
            }
            File.Delete(pathToAppeals);
            appeals.Reverse();
            return(appeals);
        }
示例#5
0
        protected void testCompress()
        {
            //string testStr = "利用进行字符串的压缩和解压缩利用进行字符串的压缩和解压缩";
            string testStr = "asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdasfasdfasdfasdf";

            byte[] inBytes  = System.Text.Encoding.UTF8.GetBytes(testStr);
            byte[] outBytes = null;
            uint   inSize   = 0;
            uint   outSize  = 0;

            Compress.CompressData(inBytes, 0, (uint)inBytes.Length, ref outBytes, ref outSize);

            writeFile("e:\\log.zip", outBytes);

            Compress.DecompressData(outBytes, 0, outSize, ref inBytes, ref inSize);

            string str = System.Text.Encoding.UTF8.GetString(inBytes);

            UAssert.DebugAssert(str == testStr);
        }
        internal void RegistrationUser(string loginRegistration, string passwordRegistration)
        {
            if (!File.Exists(_zipPathToLogins))
            {
                using (FileStream fs = File.Create(PathToLogins))
                {
                    fs.Close();
                }
            }
            else
            {
                compress.DecompressData(_zipPathToLogins);
            }

            using (StreamWriter str = new StreamWriter(PathToLogins, true, Encoding.Unicode))
            {
                str.WriteLine($"{loginRegistration}-{passwordRegistration}");
            }
            compress.CompressData(PathToLogins, _zipPathToLogins);
            File.Delete(PathToLogins);
        }