Exemple #1
0
        public override int Send(byte[] data, int offset, int length)
        {
            int count = 0;

            if (this._socket == null)
            {
                return(count);
            }

            byte[] buffer = this._iscompress
                ? this.BuilderPack(CompressHelper.Compress(data, offset, length))
                : this.BuilderPack(data, offset, length);

            Interlocked.Increment(ref _isuchannel);
            try
            {
                count = this._socket.Send(buffer);
            }
            catch { }
            finally {
                this.SendTransferredBytes = count;
                this._notifyEventHandler?.Invoke(TcpSocketCompletionNotify.OnSend, this);
                Interlocked.Decrement(ref _isuchannel);
            }
            return(count);
        }
Exemple #2
0
        public override void SendAsync(byte[] data, int offset, int length)
        {
            if (this._socket == null)
            {
                return;
            }

            byte[] buffer = this._iscompress
                ? this.BuilderPack(CompressHelper.Compress(data, offset, length))
                : this.BuilderPack(data, offset, length);

            var awaiter = _handlerSaeaPool.Take();

            awaiter.Saea.SetBuffer(buffer, 0, buffer.Length);

            Interlocked.Increment(ref _isuchannel);
            SaeaExHelper.SendAsync(this._socket, awaiter, (a, e) =>
            {
                Interlocked.Decrement(ref _isuchannel);
                this._handlerSaeaPool.Return(awaiter);
                this.SendTransferredBytes = a.Saea.Buffer.Length;
                this._notifyEventHandler?.Invoke(TcpSocketCompletionNotify.OnSend, this);
                if (e != SocketError.Success)
                {
                    _logger.WriteLog(string.Format("SendAsync--exception:{0}", e.ToString()));
                }
            });
        }
        public byte[] DealClientRequestByte(string condition)
        {
            string result = DealRequest(condition);

            byte[] bytResult    = ConvertUtility.CodingToByte(result, 2);
            byte[] returnResult = null;

            // 长度大于2048,要进行压缩。
            if (bytResult != null || bytResult.Length > WebServiceConst.Need_Compress_MinLength)
            {
                byte[] temp
                    = CompressHelper.Compress(EnumCompressType.MemCompress, bytResult);

                returnResult    = new byte[temp.Length + 1];
                returnResult[0] = 1;
                Array.Copy(temp, 0, returnResult, 1, temp.Length);
                temp = null;
            }
            else
            {
                returnResult    = new byte[bytResult.Length + 1];
                returnResult[0] = 0;
                Array.Copy(bytResult, 0, returnResult, 1, bytResult.Length);
            }

            bytResult = null;
            // 处理客户端请求
            return(returnResult);
        }
Exemple #4
0
        public void Compress5()
        {
            FileInfo file      = new FileInfo(@"D:\锋利的SQL.sql");
            FileInfo file_dest = new FileInfo(@"D:\123.sql");

            CompressHelper.Compress(file, file_dest);
        }
Exemple #5
0
        public override void SendAsync(byte[] data, int offset, int length)
        {
            if (this._disposable == 1)
            {
                return;
            }

            byte[] bytes = CompressHelper.Compress(data, offset, length);
            if ((SessionWorkType)_session.AppTokens[0] == SessionWorkType.ManagerSession)
            {
                byte[] body = new byte[sizeof(Int64) + sizeof(Int32) + bytes.Length];
                BitConverter.GetBytes(this.RemoteId).CopyTo(body, 0);
                BitConverter.GetBytes(bytes.Length).CopyTo(body, 8);
                bytes.CopyTo(body, 12);

                SendMessageHelper.SendMessage(_session, MsgCommand.Msg_MessageData, body);
            }
            else
            {
                byte[] body = new byte[bytes.Length + sizeof(Int32)];
                BitConverter.GetBytes(bytes.Length).CopyTo(body, 0);
                bytes.CopyTo(body, 4);

                _session.SendAsync(body, 0, body.Length);
            }
        }
Exemple #6
0
        public void Decompress3()
        {
            DirectoryInfo dir  = new DirectoryInfo(@"D:\123\");
            DirectoryInfo dest = new DirectoryInfo(@"D:\456\");

            CompressHelper.Compress(dir, dest);
        }
        public void SendCompressedCommand(RemoteCommand command, object obj, AppSession session)
        {
            LogHelper.WriteLog(typeof(RemoteCommand), "发送消息:" + command.ToString());
            var type = ((int)command).ToString().PadLeft(2, '0');

            byte[] typeByte = Encoding.UTF8.GetBytes(type);

            var str      = JsonConvert.SerializeObject(obj);
            var comp_str = CompressHelper.Compress(str);

            byte[] byteBuffer = Encoding.UTF8.GetBytes(comp_str);

            int len = byteBuffer.Length;

            byte[] length = BitConverter.GetBytes(len);

            var data = typeByte.Concat(length).Concat(byteBuffer).ToArray();

            if (type.Length != 2)
            {
                return;
            }
            try
            {
                session.Send(data, 0, data.Length);
            }
            catch (Exception)
            {
            }
        }
        public TranMsg[] NextPackages(out int len)
        {
            if (this._indexFiles.Length > 0)
            {
                FileInfo fi   = this._indexFiles[0];
                int      flen = fi.FullName.Length;
                FileInfo fd   = new FileInfo(fi.FullName.Substring(0, flen - 4) + ".odb");
                this._lastSynchronized = new FileInfo[] { fi, fd };

                byte[] buff1 = CompressHelper.Compress(fi.FullName);
                byte[] buff2 = CompressHelper.Compress(fd.FullName);
                len = buff1.Length + buff2.Length + 4;
                byte[] bb = new byte[len];
                ValueHelper.WriteShort(bb, 0, (short)buff1.Length);
                Array.Copy(buff1, 0, bb, 2, buff1.Length);
                ValueHelper.WriteShort(bb, buff1.Length + 2, (short)buff2.Length);
                Array.Copy(buff2, 0, bb, buff1.Length + 4, buff2.Length);
                return(this.Splite(bb, len));
            }
            else
            {
                len = 0;
                return(null);
            }
        }
Exemple #9
0
    public static void AllXlsToConfig(string path, string outPath)
    {
        //把文件夹下所有的xls转成一个总配置文件
        string[] paths = Directory.GetFiles(path, "*.xl*", SearchOption.AllDirectories);

        ByteArray ba = new ByteArray();

        for (int i = 0; i < paths.Length; i++)
        {
            byte[] data = XlsToConfig(paths[i]);
            if (data != null && data.LongLength > 0)
            {
                ba.Write(data);
            }
        }

        Directory.CreateDirectory(outPath);
        string cfgPath = outPath + Path.DirectorySeparatorChar + "cfg.bytes";

        if (File.Exists(cfgPath))
        {
            File.Delete(cfgPath);
        }

        //Console.WriteLine("压前 \n"+ba.GetBuffer().ToString());
        //Console.WriteLine("压后 \n" + CompressHelper.Compress(ba.GetBuffer()));
        File.WriteAllBytes(cfgPath, CompressHelper.Compress(ba.GetBuffer()));

        ba.Close();

        Console.WriteLine("配置数据导出成功");
    }
Exemple #10
0
 public void SendImageFile(Bitmap desktopImage, Graphics g)
 {
     using (MemoryStream ms = ImageHelper.GetLossyCompression(desktopImage, 15, "W", Screen.PrimaryScreen.Bounds.Width))
     {
         if (desktopImage != null)
         {
             try
             {
                 ms.Position = 0;
                 _mCleint.SendFile(_remote, CompressHelper.Compress(ms.GetBuffer()));
                 isBigChnage = true;
                 //if (_fps > 0)
                 //    sec = 1000 / _fps;
                 //else
                 //    sec = 2000;
                 //Thread.Sleep(sec);
             }
             catch
             {
             }
             finally
             {
                 ms.Dispose();
                 g.Dispose();
                 desktopImage.Dispose();
             }
         }
     }
 }
        public override ByteChunkModel ConvertReadToWriteModel(FileChunk readChunk)
        {
            var position   = BitConverter.GetBytes(readChunk.Position);
            var compressed = CompressHelper.Compress(readChunk.DataBuffer);
            var length     = BitConverter.GetBytes(compressed.Length);

            return(new ByteChunkModel(length, position, compressed));
        }
Exemple #12
0
        public void Compress()
        {
            var num = CompressHelper.Compress("1234567890");

            var result = CompressHelper.Decompress(num);

            Assert.AreEqual("1234567890", result);
        }
Exemple #13
0
        public void Compress2()
        {
            var str = "1234567890";

            var num = CompressHelper.Compress(Encoding.UTF8.GetBytes(str));

            var result = CompressHelper.Decompress(num);

            Assert.AreEqual("1234567890", Encoding.UTF8.GetString(result));
        }
        public void GzipTest()
        {
            var enumerable = GenerateArray(10000);

            var compressed   = CompressHelper.Compress(enumerable);
            var decompressed = CompressHelper.Decompress(compressed);

            enumerable.Should().BeEquivalentTo(decompressed);
            Console.Out.WriteLine("compressed.Length = {0}", compressed.Length);
        }
        /// <summary>
        /// 处理结收到结果信息
        /// </summary>
        private void DealResult()
        {
            while (true)
            {
                if (!m_IsLoadService)
                {
                    continue;
                }

                try
                {
                    string         resultId       = "";
                    ResponseEntity responseEntity = Singleton <ResultCacheManager <ResponseEntity> > .Instance
                                                    .GetOneResult(out resultId);

                    if (!string.IsNullOrEmpty(resultId) && responseEntity != null)
                    {
                        ServiceCommand resultCommand = new ServiceCommand();
                        ServiceCommand command       = m_ReceiveCommandCaches.GetResult(resultId);
                        if (command == null)
                        {
                            continue;
                        }

                        m_Logger.Debug("处理结果返回。");

                        // 初始化结果
                        resultCommand.CreateTime  = DateTime.Now.ToString("yyyyMMdd HH:mm:ss:fff");
                        resultCommand.Entity      = responseEntity;
                        resultCommand.Guid        = command.Guid;
                        resultCommand.Priority    = command.Priority;
                        resultCommand.ReceiveId   = command.SendId;
                        resultCommand.SendId      = m_ServerId;
                        resultCommand.ServiceName = command.ServiceName;

                        //m_CommunicationControl.Send(resultCommand);

                        ResultService.ResultService resultService = new ResultService.ResultService();
                        //this.BeginInvoke(new ExportLogHandler(ExportLog), "WebService URL:" + resultService.Url);
                        m_Logger.Debug(resultService.Url);
                        byte[] bytResult   = ConvertUtility.CodingToByte(resultCommand.ClassToCommandString(), 2);
                        byte[] bytCompress = CompressHelper.Compress(EnumCompressType.MemCompress, bytResult);
                        resultService.SendByteResult(bytCompress);
                    }
                }
                catch (Exception ex)
                {
                    LogExport(ex.Message);
                    LogExport(ex.StackTrace);
                }

                Thread.Sleep(100);
            }
        }
        public void TestMethod1()
        {
            var str = "123";

            var bt   = Encoding.UTF8.GetBytes(str);
            var enBt = CompressHelper.Compress(bt);

            var deBt = CompressHelper.Decompress(enBt);
            var res  = Encoding.UTF8.GetString(deBt);

            Assert.IsTrue(str == res);
        }
        public void Compress()
        {
            //var data = "The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.";
            var data = @"啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翱袄傲奥懊澳芭捌扒叭吧笆八疤巴拔跋靶把耙坝霸罢爸白柏百摆佰败拜稗斑班搬扳般颁板版扮拌伴瓣半办绊邦帮梆榜膀绑棒磅蚌镑傍谤苞胞包褒剥薄雹保堡饱宝抱报暴豹鲍爆杯碑悲卑北辈背贝钡倍狈备惫焙被奔苯本笨崩绷甭泵蹦迸逼鼻比鄙笔彼碧蓖蔽毕毙毖币庇痹闭敝弊必辟壁臂避陛鞭边编贬扁便变卞辨辩辫遍标彪膘表鳖憋别瘪彬斌濒滨宾摈兵冰柄丙秉饼炳病并玻菠播拨钵波博勃搏铂箔伯帛舶脖膊渤泊驳捕卜哺补埠不布步簿部怖擦猜裁材才财睬踩采彩菜蔡餐参蚕残惭惨灿苍舱仓沧藏操糙槽曹草厕策侧册测层蹭插叉茬茶查碴搽察岔差诧拆柴豺搀掺蝉馋谗缠铲产阐颤昌猖场尝常长偿肠厂敞畅唱倡超抄钞朝嘲潮巢吵炒车扯撤掣彻澈郴臣辰尘晨忱沉陈趁衬撑称城橙成呈乘程惩澄诚承逞骋秤吃痴持匙池迟弛驰耻齿侈尺赤翅斥炽充冲虫崇宠抽酬畴踌稠愁筹仇绸瞅丑臭初出橱厨躇锄雏滁除楚础储矗搐触处揣川穿椽传船喘串疮窗幢床闯创吹炊捶锤垂春椿醇唇淳纯蠢戳绰疵茨磁雌辞慈瓷词此刺赐次聪葱囱匆从丛凑粗醋簇促蹿篡窜摧崔催脆瘁粹淬翠村存寸磋撮搓措挫错搭达答瘩打大呆歹傣戴带殆代贷袋待逮怠耽担丹单郸掸胆旦氮但惮淡诞弹蛋当挡党荡档刀捣蹈倒岛祷导到稻悼道盗德得的蹬灯登等瞪凳邓堤低滴迪敌笛狄涤翟嫡抵底地蒂第帝弟递缔颠掂滇碘点典靛垫电佃甸店惦奠淀殿碉叼雕凋刁掉吊钓调跌爹碟蝶迭谍叠丁盯叮钉顶鼎锭定订丢东冬董懂动栋侗恫冻洞兜抖斗陡豆逗痘都督毒犊独读堵睹赌杜镀肚度渡妒端短锻段断缎堆兑队对墩吨蹲敦顿囤钝盾遁掇哆多夺垛躲朵跺舵剁惰堕蛾峨鹅俄额讹娥恶厄扼遏鄂饿恩而儿耳尔饵洱二贰发罚筏伐乏阀法珐藩帆番翻樊矾钒繁凡烦反返范贩犯饭泛坊芳方肪房防妨仿访纺放菲非啡飞肥匪诽吠肺废沸费芬酚吩氛分纷坟焚汾粉奋份忿愤粪丰封枫蜂峰锋风疯烽逢冯缝讽奉凤佛否夫敷肤孵扶拂辐幅氟符伏俘服浮涪福袱弗甫抚辅俯釜斧脯腑府腐赴副覆赋复傅付阜父腹负富讣附妇缚咐噶嘎该改概钙盖溉干甘杆柑竿肝赶感秆敢赣冈刚钢缸肛纲岗港杠篙皋高膏羔糕搞镐稿告哥歌搁戈鸽胳疙割革葛格蛤阁隔铬个各给根跟耕更庚羹埂耿梗工攻功恭龚供躬公宫弓巩汞拱贡共钩勾沟苟狗垢构购够辜菇咕箍估沽孤姑鼓古蛊骨谷股故顾固雇刮瓜剐寡挂褂乖拐怪棺关官冠观管馆罐惯灌贯光广逛瑰规圭硅归龟闺轨鬼诡癸桂柜跪贵刽辊滚棍锅郭国果裹过哈骸孩海氦亥害骇酣憨邯韩含涵寒函喊罕翰撼捍旱憾悍焊汗汉夯杭航壕嚎豪毫郝好耗号浩呵喝荷菏核禾和何合盒貉阂河涸赫褐鹤贺嘿黑痕很狠恨哼亨横衡恒轰哄烘虹鸿洪宏弘红喉侯猴吼厚候后呼乎忽瑚壶葫胡蝴狐糊湖弧虎唬护互沪户花哗华猾滑画划化话槐徊怀淮坏欢环桓还缓换患唤痪豢焕涣宦幻荒慌黄磺蝗簧皇凰惶煌晃幌恍谎灰挥辉徽恢蛔回毁悔慧卉惠晦贿秽会烩汇讳诲绘荤昏婚魂浑混豁活伙火获或惑霍货祸击圾基机畸稽积箕肌饥迹激讥鸡姬绩缉吉极棘辑籍集及急疾汲即嫉级挤几脊己蓟技冀季伎祭剂悸济寄寂计记既忌际继纪嘉枷夹佳家加荚颊贾甲钾假稼价架驾嫁歼监坚尖笺间煎兼肩艰奸缄茧检柬碱硷拣捡简俭剪减荐槛鉴践贱见键箭件健舰剑饯渐溅涧建僵姜将浆江疆蒋桨奖讲匠酱降蕉椒礁焦胶交郊浇骄娇嚼搅铰矫侥脚狡角饺缴绞剿教酵轿较叫窖揭接皆秸街阶截劫节茎睛晶鲸京惊精粳经井警景颈静境敬镜径痉靖竟竞净炯窘揪究纠玖韭久灸九酒厩救旧臼舅咎就疚鞠拘狙疽居驹菊局咀矩举沮聚拒据巨具距踞锯俱句惧炬剧捐鹃娟倦眷卷绢撅攫抉掘倔爵桔杰捷睫竭洁结解姐戒藉芥界借介疥诫届巾筋斤金今津襟紧锦仅谨进靳晋禁近烬浸尽劲荆兢觉决诀绝均菌钧军君峻俊竣浚郡骏喀咖卡咯开揩楷凯慨刊堪勘坎砍看康慷糠扛抗亢炕考拷烤靠坷苛柯棵磕颗科壳咳可渴克刻客课肯啃垦恳坑吭空恐孔控抠口扣寇枯哭窟苦酷库裤夸垮挎跨胯块筷侩快宽款匡筐狂框矿眶旷况亏盔岿窥葵奎魁傀馈愧溃坤昆捆困括扩廓阔垃拉喇蜡腊辣啦莱来赖蓝婪栏拦篮阑兰澜谰揽览懒缆烂滥琅榔狼廊郎朗浪捞劳牢老佬姥酪烙涝勒乐雷镭蕾磊累儡垒擂肋类泪棱楞冷厘梨犁黎篱狸离漓理李里鲤礼莉荔吏栗丽厉励砾历利傈例俐痢立粒沥隶力璃哩俩联莲连镰廉怜涟帘敛脸链恋炼练粮凉梁粱良两辆量晾亮谅撩聊僚疗燎寥辽潦了撂镣廖料列裂烈劣猎琳林磷霖临邻鳞淋凛赁吝拎玲菱零龄铃伶羚凌灵陵岭领另令溜琉榴硫馏留刘瘤流柳六龙聋咙笼窿隆垄拢陇楼娄搂篓漏陋芦卢颅庐炉掳卤虏鲁麓碌露路赂鹿潞禄录陆戮驴吕铝侣旅履屡缕虑氯律率滤绿峦挛孪滦卵乱掠略抡轮伦仑沦纶论萝螺罗逻锣箩骡裸落洛骆络妈麻玛码蚂马骂嘛吗埋买麦卖迈脉瞒馒蛮满蔓曼慢漫谩芒茫盲氓忙莽猫茅锚毛矛铆卯茂冒帽貌贸么玫枚梅酶霉煤没眉媒镁每美昧寐妹媚门闷们萌蒙檬盟锰猛梦孟眯醚靡糜迷谜弥米秘觅泌蜜密幂棉眠绵冕免勉娩缅面苗描瞄藐秒渺庙妙蔑灭民抿皿敏悯闽明螟鸣铭名命谬摸摹蘑模膜磨摩魔抹末莫墨默沫漠寞陌谋牟某拇牡亩姆母墓暮幕募慕木目睦牧穆拿哪呐钠那娜纳氖乃奶耐奈南男难囊挠脑恼闹淖呢馁内嫩能妮霓倪泥尼拟你匿腻逆溺蔫拈年碾撵捻念娘酿鸟尿捏聂孽啮镊镍涅您柠狞凝宁拧泞牛扭钮纽脓浓农弄奴努怒女暖虐疟挪懦糯诺哦欧鸥殴藕呕偶沤啪趴爬帕怕琶拍排牌徘湃派攀潘盘磐盼畔判叛乓庞旁耪胖抛咆刨炮袍跑泡呸胚培裴赔陪配佩沛喷盆砰抨烹澎彭蓬棚硼篷膨朋鹏捧碰坯砒霹批披劈琵毗啤脾疲皮匹痞僻屁譬篇偏片骗飘漂瓢票撇瞥拼频贫品聘乒坪苹萍平凭瓶评屏坡泼颇婆破魄迫粕剖扑铺仆莆葡菩蒲埔朴圃普浦谱曝瀑期欺栖戚妻七凄漆柒沏其棋奇歧畦崎脐齐旗祈祁骑起岂乞企启契砌器气迄弃汽泣讫掐洽牵扦钎铅千迁签仟谦乾黔钱钳前潜遣浅谴堑嵌欠歉枪呛腔羌墙蔷强抢橇锹敲悄桥瞧乔侨巧鞘撬翘峭俏窍切茄且怯窃钦侵亲秦琴勤芹擒禽寝沁青轻氢倾卿清擎晴氰情顷请庆琼穷秋丘邱球求囚酋泅趋区蛆曲躯屈驱渠取娶龋趣去圈颧权醛泉全痊拳犬券劝缺炔瘸却鹊榷确雀裙群然燃冉染瓤壤攘嚷让饶扰绕惹热壬仁人忍韧任认刃妊纫扔仍日戎茸蓉荣融熔溶容绒冗揉柔肉茹蠕儒孺如辱乳汝入褥软阮蕊瑞锐闰润若弱撒洒萨腮鳃塞赛三叁伞散桑嗓丧搔骚扫嫂瑟色涩森僧莎砂杀刹沙纱傻啥煞筛晒珊苫杉山删煽衫闪陕擅赡膳善汕扇缮墒伤商赏晌上尚裳梢捎稍烧芍勺韶少哨邵绍奢赊蛇舌舍赦摄射慑涉社设砷申呻伸身深娠绅神沈审婶甚肾慎渗声生甥牲升绳省盛剩胜圣师失狮施湿诗尸虱十石拾时什食蚀实识史矢使屎驶始式示士世柿事拭誓逝势是嗜噬适仕侍释饰氏市恃室视试收手首守寿授售受瘦兽蔬枢梳殊抒输叔舒淑疏书赎孰熟薯暑曙署蜀黍鼠属术述树束戍竖墅庶数漱恕刷耍摔衰甩帅栓拴霜双爽谁水睡税吮瞬顺舜说硕朔烁斯撕嘶思私司丝死肆寺嗣四伺似饲巳松耸怂颂送宋讼诵搜艘擞嗽苏酥俗素速粟僳塑溯宿诉肃酸蒜算虽隋随绥髓碎岁穗遂隧祟孙损笋蓑梭唆缩琐索锁所塌他它她塔獭挞蹋踏胎苔抬台泰酞太态汰坍摊贪瘫滩坛檀痰潭谭谈坦毯袒碳探叹炭汤塘搪堂棠膛唐糖倘躺淌趟烫掏涛滔绦萄桃逃淘陶讨套特藤腾疼誊梯剔踢锑提题蹄啼体替嚏惕涕剃屉天添填田甜恬舔腆挑条迢眺跳贴铁帖厅听烃汀廷停亭庭挺艇通桐酮瞳同铜彤童桶捅筒统痛偷投头透凸秃突图徒途涂屠土吐兔湍团推颓腿蜕褪退吞屯臀拖托脱鸵陀驮驼椭妥拓唾挖哇蛙洼娃瓦袜歪外豌弯湾玩顽丸烷完碗挽晚皖惋宛婉万腕汪王亡枉网往旺望忘妄威巍微危韦违桅围唯惟为潍维苇萎委伟伪尾纬未蔚味畏胃喂魏位渭谓尉慰卫瘟温蚊文闻纹吻稳紊问嗡翁瓮挝蜗涡窝我斡卧握沃巫呜钨乌污诬屋无芜梧吾吴毋武五捂午舞伍侮坞戊雾晤物勿务悟误昔熙析西硒矽晰嘻吸锡牺稀息希悉膝夕惜熄烯溪汐犀檄袭席习媳喜铣洗系隙戏细瞎虾匣霞辖暇峡侠狭下厦夏吓掀锨先仙鲜纤咸贤衔舷闲涎弦嫌显险现献县腺馅羡宪陷限线相厢镶香箱襄湘乡翔祥详想响享项巷橡像向象萧硝霄削哮嚣销消宵淆晓小孝校肖啸笑效楔些歇蝎鞋协挟携邪斜胁谐写械卸蟹懈泄泻谢屑薪芯锌欣辛新忻心信衅星腥猩惺兴刑型形邢行醒幸杏性姓兄凶胸匈汹雄熊休修羞朽嗅锈秀袖绣墟戌需虚嘘须徐许蓄酗叙旭序畜恤絮婿绪续轩喧宣悬旋玄选癣眩绚靴薛学穴雪血勋熏循旬询寻驯巡殉汛训讯逊迅压押鸦鸭呀丫芽牙蚜崖衙涯雅哑亚讶焉咽阉烟淹盐严研蜒岩延言颜阎炎沿奄掩眼衍演艳堰燕厌砚雁唁彦焰宴谚验殃央鸯秧杨扬佯疡羊洋阳氧仰痒养样漾邀腰妖瑶摇尧遥窑谣姚咬舀药要耀椰噎耶爷野冶也页掖业叶曳腋夜液一壹医揖铱依伊衣颐夷遗移仪胰疑沂宜姨彝椅蚁倚已乙矣以艺抑易邑屹亿役臆逸肄疫亦裔意毅忆义益溢诣议谊译异翼翌绎茵荫因殷音阴姻吟银淫寅饮尹引隐印英樱婴鹰应缨莹萤营荧蝇迎赢盈影颖硬映哟拥佣臃痈庸雍踊蛹咏泳涌永恿勇用幽优悠忧尤由邮铀犹油游酉有友右佑釉诱又幼迂淤于盂榆虞愚舆余俞逾鱼愉渝渔隅予娱雨与屿禹宇语羽玉域芋郁吁遇喻峪御愈欲狱育誉浴寓裕预豫驭鸳渊冤元垣袁原援辕园员圆猿源缘远苑愿怨院曰约越跃钥岳粤月悦阅耘云郧匀陨允运蕴酝晕韵孕匝砸杂栽哉灾宰载再在咱攒暂赞赃脏葬遭糟凿藻枣早澡蚤躁噪造皂灶燥责择则泽贼怎增憎曾赠扎喳渣札轧铡闸眨栅榨咋乍炸诈摘斋宅窄债寨瞻毡詹粘沾盏斩辗崭展蘸栈占战站湛绽樟章彰漳张掌涨杖丈帐账仗胀瘴障招昭找沼赵照罩兆肇召遮折哲蛰辙者锗蔗这浙珍斟真甄砧臻贞针侦枕疹诊震振镇阵蒸挣睁征狰争怔整拯正政帧症郑证芝枝支吱蜘知肢脂汁之织职直植殖执值侄址指止趾只旨纸志挚掷至致置帜峙制智秩稚质炙痔滞治窒中盅忠钟衷终种肿重仲众舟周州洲诌粥轴肘帚咒皱宙昼骤珠株蛛朱猪诸诛逐竹烛煮拄瞩嘱主著柱助蛀贮铸筑住注祝驻抓爪拽专砖转撰赚篆桩庄装妆撞壮状椎锥追赘坠缀谆准捉拙卓桌琢茁酌啄着灼浊兹咨资姿滋淄孜紫仔籽滓子自渍字鬃棕踪宗综总纵邹走奏揍租足卒族祖诅阻组钻纂嘴醉最罪尊遵昨左佐柞做作坐座锕嗳嫒瑷暧霭谙铵鹌媪骜鳌钯呗钣鸨龅鹎贲锛荜哔滗铋筚跸苄缏笾骠飑飙镖镳鳔傧缤槟殡膑镔髌鬓禀饽钹鹁钸骖黪恻锸侪钗冁谄谶蒇忏婵骣觇禅镡伥苌怅阊鲳砗伧谌榇碜龀枨柽铖铛饬鸱铳俦帱雠刍绌蹰钏怆缍鹑辍龊鹚苁骢枞辏撺锉鹾哒鞑骀绐殚赕瘅箪谠砀裆焘镫籴诋谛绨觌镝巅钿癫铫鲷鲽铤铥岽鸫窦渎椟牍笃黩簖怼镦炖趸铎谔垩阏轭锇锷鹗颚颛鳄诶迩铒鸸鲕钫鲂绯镄鲱偾沣凫驸绂绋赙麸鲋鳆钆赅尴擀绀戆睾诰缟锆纥镉颍亘赓绠鲠诟缑觏诂毂钴锢鸪鹄鹘鸹掴诖掼鹳鳏犷匦刿妫桧鲑鳜衮绲鲧埚呙帼椁蝈铪阚绗颉灏颢诃阖蛎黉讧荭闳鲎浒鹕骅桦铧奂缳锾鲩鳇诙荟哕浍缋珲晖诨馄阍钬镬讦诘荠叽哜骥玑觊齑矶羁虿跻霁鲚鲫郏浃铗镓蛲谏缣戋戬睑鹣笕鲣鞯绛缰挢峤鹪鲛疖颌鲒卺荩馑缙赆觐刭泾迳弪胫靓阄鸠鹫讵屦榉飓钜锔窭龃锩镌隽谲珏皲剀垲忾恺铠锴龛闶钪铐骒缂轲钶锞颔龈铿喾郐哙脍狯髋诓诳邝圹纩贶匮蒉愦聩篑阃锟鲲蛴崃徕涞濑赉睐铼癞籁岚榄斓镧褴阆锒唠崂铑铹痨鳓诔缧俪郦坜苈莅蓠呖逦骊缡枥栎轹砺锂鹂疠粝跞雳鲡鳢蔹奁潋琏殓裢裣鲢魉缭钌鹩蔺廪檩辚躏绫棂蛏鲮浏骝绺镏鹨茏泷珑栊胧砻偻蒌喽嵝镂瘘耧蝼髅垆撸噜闾泸渌栌橹轳辂辘氇胪鸬鹭舻鲈脔娈栾鸾銮囵荦猡泺椤脶镙榈褛锊呒唛嬷杩劢缦镘颡鳗麽扪焖懑钔芈谧猕祢渑腼黾缈缪闵缗谟蓦馍殁镆钼铙讷铌鲵辇鲶茑袅陧蘖嗫颟蹑苎咛聍侬哝驽钕傩讴怄瓯蹒疱辔纰罴铍谝骈缥嫔钋镤镨蕲骐绮桤碛颀颃鳍佥荨悭骞缱椠钤嫱樯戗炝锖锵镪羟跄诮谯荞缲硗跷惬锲箧锓揿鲭茕蛱巯赇虮鳅诎岖阒觑鸲诠绻辁铨阕阙悫荛娆桡饪轫嵘蝾缛铷颦蚬飒毵糁缫啬铯穑铩鲨酾讪姗骟钐鳝垧殇觞厍滠畲诜谂渖谥埘莳弑轼贳铈鲥绶摅纾闩铄厮驷缌锶鸶薮馊飕锼谡稣谇荪狲唢睃闼铊鳎钛鲐昙钽锬顸傥饧铴镗韬铽缇鹈阗粜龆鲦恸钭钍抟饨箨鼍娲腽纨绾辋诿帏闱沩涠玮韪炜鲔阌莴龌邬庑怃妩骛鹉鹜饩阋玺觋硖苋莶藓岘猃娴鹇痫蚝籼跹芗饷骧缃飨哓潇骁绡枭箫亵撷绁缬陉荥馐鸺诩顼谖铉镟谑泶鳕埙浔鲟垭娅桠氩厣赝俨兖谳恹闫酽魇餍鼹炀轺鹞鳐靥谒邺晔烨诒呓峄饴怿驿缢轶贻钇镒镱瘗舣铟瘾茔莺萦蓥撄嘤滢潆璎鹦瘿颏罂镛莸铕鱿伛俣谀谕蓣嵛饫阈妪纡觎欤钰鹆鹬龉橼鸢鼋钺郓芸恽愠纭韫殒氲瓒趱錾驵赜啧帻箦谮缯谵诏钊谪辄鹧浈缜桢轸赈祯鸩诤峥钲铮筝骘栉栀轵轾贽鸷蛳絷踬踯觯锺纣绉伫槠铢啭馔颞骓缒诼镯谘缁辎赀眦锱龇鲻偬诹驺鲰镞缵躜鳟讠谫郄勐凼坂垅垴埯埝苘荬荮莜莼菰藁揸吒吣咔咝咴噘噼嚯幞岙嵴彷徼犸狍馀馇馓馕愣憷懔丬溆滟溷漤潴澹甯纟绔绱珉枧桊桉槔橥轱轷赍肷胨飚煳煅熘愍淼砜磙眍钚钷铘铞锃锍锎锏锘锝锪锫锿镅镎镢镥镩镲稆鹋鹛鹱疬疴痖癯裥襁耢颥螨麴鲅鲆鲇鲞鲴鲺鲼鳊鳋鳘鳙鞒鞴齄";

            var compress    = new CompressHelper();
            var deflateByte = compress.Compress(data.ToBytes(), CompressMode.Deflate);
            var gzipByte    = compress.Compress(data.ToBytes(), CompressMode.GZip);
            var brotliByte  = compress.Compress(data.ToBytes(), CompressMode.Brotli);

            var deflateBase64 = compress.CompressToBase64(data, CompressMode.Deflate); //deflateBase64.Length = 14064
            var gzipBase64    = compress.CompressToBase64(data, CompressMode.GZip);    //gzipBase64.Length = 14088
            var brotliBase64  = compress.CompressToBase64(data, CompressMode.Brotli);  //brotliBase64.Length = 11612

            var deflatDeCompressFormByte = compress.DeCompressFromByte(deflateByte, CompressMode.Deflate);
            var gzipDeCompressFormByte   = compress.DeCompressFromByte(gzipByte, CompressMode.GZip);
            var brotliDeCompressFormByte = compress.DeCompressFromByte(brotliByte, CompressMode.Brotli);

            var deflatDeCompressFormBase64 = compress.DeCompressFromBase64(deflateBase64, CompressMode.Deflate);
            var gzipDeCompressFormBase64   = compress.DeCompressFromBase64(gzipBase64, CompressMode.GZip);
            var brotliDeCompressFormBase64 = compress.DeCompressFromBase64(brotliBase64, CompressMode.Brotli);

            Assert.IsTrue(data.Length > 0);
        }
Exemple #18
0
        private void SendAck(TcpSocketSaeaSession session, SessionWorkType type)
        {
            //                          //命令头      //accesskey     //workType
            byte[] bytes = new byte[sizeof(Int16) + sizeof(Int64) + sizeof(Byte)];
            BitConverter.GetBytes(AckPacket).CopyTo(bytes, 0);
            BitConverter.GetBytes(_options.AccessKey).CopyTo(bytes, 2);
            bytes[10] = (Byte)type;

            byte[] body = CompressHelper.Compress(bytes, 0, bytes.Length);

            byte[] data = new byte[sizeof(Int32) + body.Length];
            BitConverter.GetBytes(body.Length).CopyTo(data, 0);
            body.CopyTo(data, 4);

            session.SendAsync(data);
        }
    /// <summary>
    /// Save the region data in a file.
    /// </summary>
    public void SaveRegionData()
    {
        if (!modified)
        {
            return;
        }

        if (Constants.REGION_SAVE_COMPRESSED)
        {
            byte[] Compressed = CompressHelper.Compress(regionData.ToArray());
            File.WriteAllBytes(DirectionChunkFile(), Compressed);
        }
        else
        {
            File.WriteAllBytes(DirectionChunkFile(), regionData.ToArray());
        }
    }
Exemple #20
0
        public void TestCompress()
        {
            string _testString = "Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!", _decompressString;
            int    _rawBytesLength = 0, _compressBytesLength = 0, _decompressBytesLength = 0;

            var _bytes = Encoding.Default.GetBytes(_testString);

            _rawBytesLength = _bytes.Length;

            _bytes = CompressHelper.Compress(_bytes);
            _compressBytesLength = _bytes.Length;

            _bytes = CompressHelper.Decompress(_bytes);
            _decompressBytesLength = _bytes.Length;

            _decompressString = Encoding.Default.GetString(_bytes);

            Assert.IsTrue(_rawBytesLength > _compressBytesLength, string.Format("压缩不成功,压缩前字节数:{0},压缩后字节数:{1}", _rawBytesLength, _compressBytesLength));
            Assert.AreEqual(_testString, _decompressString, string.Format("压缩、解压失败,压缩前:{0},压缩解压后:{1}", _testString, _decompressString));
        }
Exemple #21
0
 public override void Add(DataTable data)
 {
     try
     {
         if ((data != null) && (data.Rows.Count <= base._Size))
         {
             lock (base._PosList.SyncRoot)
             {
                 base._PosList.Add(CompressHelper.Compress(data));
                 return;
             }
         }
         this.DataDisBach(data);
     }
     catch (Exception exception)
     {
         ErrorMsg msg = new ErrorMsg("RemotingDataCS", "Add", exception.Message + exception.StackTrace);
         new LogHelper().WriteError(msg);
         base._PosList = new ArrayList(100);
     }
 }
Exemple #22
0
 private void DataDisBach(DataTable data)
 {
     if ((data != null) && (data.Rows.Count > 0))
     {
         DataTable table = data.Clone();
         int       num   = 1;
         for (int i = 0; i <= (data.Rows.Count - 1); i++)
         {
             table.Rows.Add(data.Rows[i].ItemArray);
             if ((num >= base._Size) || (i == (data.Rows.Count - 1)))
             {
                 lock (base._PosList.SyncRoot)
                 {
                     base._PosList.Add(CompressHelper.Compress(table.Copy()));
                 }
                 table.Clear();
                 num = 0;
             }
             num++;
         }
     }
 }
Exemple #23
0
        private async void BackgroundUploader_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Invoke(new Action(() =>
                {
                    ProgressUpload.MarqueeAnimationSpeed = 100;
                    MainGroupBox.Enabled = false;
                }));

                var bytes = File.ReadAllBytes(PathTextBox.Text);

                var fullSize = bytes.Length;

                if (CompressCheckBox.Checked)
                {
                    bytes = CompressHelper.Compress(bytes);
                }

                var compressedSize = bytes.Length;

                NewFile = await _DBProvider.SaveFile(NameTextBox.Text, Path.GetFileName(PathTextBox.Text), Path.GetExtension(PathTextBox.Text), CompressCheckBox.Checked, compressedSize, fullSize, bytes);

                NewFile.Compressed     = CompressCheckBox.Checked;
                NewFile.FullSize       = fullSize;
                NewFile.CompressedSize = compressedSize;
            }
            finally
            {
                Invoke(new Action(() =>
                {
                    ProgressUpload.MarqueeAnimationSpeed = 0;
                    MainGroupBox.Enabled = true;
                    this.DialogResult    = DialogResult.OK;
                    this.Close();
                }));
            }
        }
        public void SendCompressedCommand(RemoteCommand cmd, object obj)
        {
            var type  = ((int)cmd).ToString().PadLeft(2, '0');
            var data0 = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
            var data  = CompressHelper.Compress(data0);

            if (IsConnected)
            {
                byte[] arr = Encoding.UTF8.GetBytes(string.Format("{0} {1}\r\n", type, data));
                try
                {
                    //Send(arr, 0, arr.Length);
                    Send(arr, 0, arr.Length);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("SendCommand函数出错");
                }
            }
            else
            {
                MessageBox.Show("未建立连接");
            }
        }
        public override void SendAsync(byte[] data, int offset, int lenght)
        {
            if (this._socket == null)
            {
                return;
            }

            byte[] buffer = this._iscompress
                ? this.BuilderPack(CompressHelper.Compress(data, offset, lenght))
                : this.BuilderPack(data, offset, lenght);

            var awaiter = _handlerSaeaPool.Take();

            awaiter.Saea.SetBuffer(buffer, 0, buffer.Length);

            Interlocked.Increment(ref _isuchannel);
            SaeaExHelper.SendAsync(this._socket, awaiter, (a, e) =>
            {
                Interlocked.Decrement(ref _isuchannel);
                this._handlerSaeaPool.Return(awaiter);
                this.SendTransferredBytes = a.Saea.Buffer.Length;
                this._notifyEventHandler?.Invoke(TcpSocketCompletionNotify.OnSend, this);
            });
        }
Exemple #26
0
        public static byte[] Pack(PacketBodyBase packetBody, bool compressed = true)
        {
            try
            {
                byte[] _head, _compress, _body;
                string _md5;

                //编码包体
                _body = SerializationHelper.Encode(packetBody);
                _md5  = SecurityHelper.GetMD5(_body);

                //编码压缩包头
                CompressHeader _compressHeader = new CompressHeader();
                _compressHeader.Compressed = (short)(compressed ? 1 : 0);
                _compressHeader.DataSize   = _body.Length;
                if (compressed)
                {
                    _body = CompressHelper.Compress(_body);
                }
                _compressHeader.CompressedSize = _body.Length;
                _compress = SerializationHelper.Encode(_compressHeader);
                _body     = _compress.Concat(_body).ToArray();

                //编码数据包包头
                if (typeof(RequestPacket).IsAssignableFrom(packetBody.GetType()))
                {
                    RequestHeader _requestHeader = new RequestHeader
                    {
                        MsgId   = packetBody.GetMsgId(),
                        PkgSize = _body.Length,
                        MD5     = _md5,
                    };
                    _head = SerializationHelper.Encode(_requestHeader);
                }
                else if (typeof(ResponsePacket).IsAssignableFrom(packetBody.GetType()))
                {
                    ResponseHeader _responseHeader = new ResponseHeader
                    {
                        MsgId   = packetBody.GetMsgId(),
                        PkgSize = _body.Length,
                        MD5     = _md5,
                    };
                    _head = SerializationHelper.Encode(_responseHeader);
                }
                else
                {
                    throw new NotSupportedPacketTypeException(string.Format("暂不支持类型为{0}的数据包", packetBody.GetType().ToString()), packetBody.GetType());
                }

                return(_head.Concat(_body).ToArray());
            }
            catch (NotSupportedPacketTypeException ex)
            {
                ex.Source += ".PacketUtil.Pack";
                throw;
            }
            catch (Exception ex)
            {
                ex.Source += ".PacketUtil.Pack";
                throw new PackException("数据包打包出现异常", packetBody, ex);
            }
        }
Exemple #27
0
        void generateExeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog sv = new SaveFileDialog())
            {
                sv.Filter     = "Exe file|*.exe";
                sv.DefaultExt = "exe";

                if (sv.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                string pwd = FCreatePassword.ShowForm();
                if (string.IsNullOrEmpty(pwd))
                {
                    return;
                }

                // Copiar librerias
                if (Path.GetDirectoryName(Application.ExecutablePath) != Path.GetDirectoryName(sv.FileName))
                {
                    if (MessageBox.Show("Do you want to copy dll files to?", "Library files", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        foreach (string file in Directory.GetFiles(Path.GetDirectoryName(Application.ExecutablePath), "*.dll", SearchOption.TopDirectoryOnly))
                        {
                            string dest = Path.Combine(Path.GetDirectoryName(sv.FileName), Path.GetFileName(file));
                            if (dest == file)
                            {
                                continue;
                            }

                            if (File.Exists(dest))
                            {
                                File.Delete(dest);
                            }
                            File.Copy(file, dest);
                        }
                    }
                }

                byte[] hash = Encoding.UTF8.GetBytes(pwd);
                hash = HashHelper.HashRaw(HashHelper.EHashType.Sha512, hash, 0, hash.Length);

                TLYFile      t      = GetSaveFile();
                PacketHeader header = new PacketHeader()
                {
                    H = hash,
                    D = Encoding.UTF8.GetBytes(t.Save())
                };

                header.Encrypt(true);

                // Leer exe original
                byte[] ar = File.ReadAllBytes(Application.ExecutablePath);

                using (FileStream fs = new FileStream(sv.FileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    // Escribir exe
                    fs.Write(ar, 0, ar.Length);

                    // Escribir contenido comprimido, en UTF8
                    ar = Encoding.UTF8.GetBytes(SerializationHelper.Serialize(header, SerializationHelper.EFormat.Json));
                    ar = CompressHelper.Compress(ar, 0, ar.Length, true);
                    fs.Write(ar, 0, ar.Length);

                    // Grabar tamaño añadido
                    ar = BitConverter.GetBytes(ar.Length);
                    fs.Write(ar, 0, ar.Length);

                    // Grabar palabra clave de fin de archivo
                    ar = Encoding.ASCII.GetBytes("PACK");
                    fs.Write(ar, 0, ar.Length);
                }

                Pr.Process.Start(Path.GetDirectoryName(sv.FileName));
            }
        }
Exemple #28
0
 /// <summary>
 /// 发送图像到远程
 /// </summary>
 private void SendImage()
 {
     Task.Factory.StartNew(() =>
     {
         //Bitmap lastBitmap = null;
         Rectangle rectangle = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
         while (!_isClose)
         {
             try
             {
                 if (true)
                 {
                     using (Bitmap desktopImage = new Bitmap(rectangle.Width, rectangle.Height))
                     {
                         using (Graphics g = Graphics.FromImage(desktopImage))
                         {
                             try
                             {
                                 g.CopyFromScreen(0, 0, 0, 0, desktopImage.Size);
                             }
                             catch (Exception ex)
                             {
                                 continue;
                             }
                             MouseAndKeyHelper.DrawMouse(g);
                             //比较此次截图与上一张截图的差异
                             if (lastBitmap != null)
                             {
                                 List <Rectangle> rects = ImageComparer.Compare(lastBitmap, desktopImage);
                                 lastBitmap             = (Bitmap)desktopImage.Clone();
                                 if (rects.Count == 0)//无变化不发送
                                 {
                                     Thread.Sleep(sec);
                                 }
                                 if (rects.Count <= 480)//差异小于7块则分段传输
                                 {
                                     Dictionary <Rectangle, Bitmap> dic = new Dictionary <Rectangle, Bitmap>();
                                     foreach (var rect in rects)
                                     {
                                         Bitmap bmSmall = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppRgb);
                                         using (Graphics grSmall = Graphics.FromImage(bmSmall))
                                         {
                                             grSmall.DrawImage(desktopImage, 0, 0,
                                                               rect, GraphicsUnit.Pixel);
                                             grSmall.Save();
                                             grSmall.Dispose();
                                         }
                                         dic.Add(rect, (Bitmap)bmSmall.Clone());
                                     }
                                     if (dic.Count > 0)
                                     {
                                         _mCleint.SendFileSlice(_remote, CompressHelper.Compress(SerializeHelper.ByteSerialize(dic)));
                                         isBigChnage = false;
                                         Thread.Sleep(sec);
                                     }
                                 }
                                 else
                                 {//发送完整的图片
                                     if (isBigChnage == false)
                                     {
                                         SendImageFile(desktopImage, g);
                                         lastBitmap = (Bitmap)desktopImage.Clone();//要在之前否则销毁掉了
                                         Thread.Sleep(sec);
                                     }
                                     else
                                     {
                                         isBigChnage = false;
                                     }
                                 }
                             }
                             else
                             {                                              //第一张图片
                                 lastBitmap = (Bitmap)desktopImage.Clone(); //要在之前否则销毁掉了
                                 SendImageFile(desktopImage, g);
                                 Thread.Sleep(sec);
                             }
                         }
                     }
                 }
                 else
                 {
                     Thread.Sleep(100);
                 }
             }
             catch (Exception ex)
             {
                 continue;
             }
         }
     }, cts.Token);
 }
Exemple #29
0
        public void Compress4()
        {
            DirectoryInfo dir = new DirectoryInfo(@"D:\123");

            CompressHelper.Compress(dir);
        }
Exemple #30
0
        public void Compress3()
        {
            FileInfo file = new FileInfo(@"D:\锋利的SQL.sql");

            CompressHelper.Compress(file);
        }