Beispiel #1
0
 public virtual Task<Stream> ReceiveAsync(TimeSpan timeout, Information options)
 {
     return Task.Run(() =>
     {
         return this.Receive(timeout, options);
     });
 }
Beispiel #2
0
 public virtual Task ConnectAsync(TimeSpan timeout, Information options)
 {
     return Task.Factory.StartNew(() =>
     {
         this.Connect(timeout, options);
     });
 }
 public static Exporter SqlScriptExporter(Information serverInformation)
 {
     if (serverInformation.Version.Major == 9)
         return new XsltExporter("sql2005Output.xslt");
     else
         return new XsltExporter("sql2000Output.xslt");
 }
Beispiel #4
0
 public virtual Task ConnectAsync(TimeSpan timeout, Information options)
 {
     return Task.Run(() =>
     {
         this.Connect(timeout, options);
     });
 }
Beispiel #5
0
        public IInformation Parse(string bnf)
        {
            var result = new Information();

            foreach (Match match in regex.Matches(bnf))
            {
                var command = match.Groups["command"].Value;
                var argument = match.Groups["argument"].Value;

                switch (command)
                {
                    case "using":
                        result.AddUsing(argument);
                        break;

                    case "mode":
                        if (result.HasMode)
                            throw new Exception(@"Meta tag @mode specified twice");
                        if (argument == "strict")
                            result.Mode = BnfGrammar.Mode.Strict;
                        else if (argument == "http-comaptible")
                            result.Mode = BnfGrammar.Mode.HttpCompatible;
                        else
                            throw new Exception(string.Format(@"Unknow @mode specified: {0}", argument));
                        break;
                }
            }

            return result;
        }
Beispiel #6
0
 protected override void AwakeDevice()
 {
     for (var i = 1; i <= Sensor.Count; i++)
     {
         // fill the sensor information array with debug values
         Sensors[i] = new Information(GetSensorDebugAvailable(i), 1, 0, "DEBUG", 0, 100, "DEBUG", 0, Description[i]);
     }
 }
    protected override void AwakeDevice()
    {
        if (SystemInfo.supportsGyroscope)
        {
            Input.gyro.enabled = true;
        }

        //// old and deprecated way
        //		// set up connection to java class
        //
        //        var clsActivity = AndroidJNI.FindClass("com/unity3d/player/UnityPlayer");
        //        var fidActivity = AndroidJNI.GetStaticFieldID(clsActivity, "currentActivity", "Landroid/app/Activity;");
        //        var objActivity = AndroidJNI.GetStaticObjectField(clsActivity, fidActivity);
        //
        //        var clsJavaClass = AndroidJNI.FindClass("com/pfc/sensors/SensorClass");
        //        var midJavaClass = AndroidJNI.GetMethodID(clsJavaClass, "<init>", "(Landroid/app/Activity;)V");
        //
        //        var args = new jvalue[1];
        //        args[0].l = objActivity;
        //
        //        var objJavaClass = AndroidJNI.NewObject(clsJavaClass, midJavaClass, args);

        //// new way
        AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject obj = jc.GetStatic<AndroidJavaObject>("currentActivity");
        _ao = new AndroidJavaObject("com.pfc.sensors.SensorClass", obj);

        // get all sensor informations (including whether they area available)
        for (var i = 1; i <= Sensor.Count; i++)
        {
            // fill the sensor information array
            Sensors[i] = new Information(_ao.Call<bool>("isSensorAvailable", i), _ao.Call<float>("getMaximumRange", i), _ao.Call<int>("getMinDelay", i),
                                               _ao.Call<string>("getName", i), _ao.Call<float>("getPower", i), _ao.Call<float>("getResolution", i),
                                               _ao.Call<string>("getVendor", i), _ao.Call<int>("getVersion", i), Description[i]);
        }

        base.AwakeDevice();

        // this does not work, no need to try it - just experimental
        //		// setup LocationManager
        //		LocationManager.SetInternalObject(_ao);
        //
        //		// setup mock providers
        //		LocationManager.AddTestProvider(LocationProvider.GPS);
        //		LocationManager.SetTestProviderLocation(LocationProvider.GPS, new Location(LocationProvider.GPS, 10, 10));
        //
        //		// request updates
        //		LocationManager.RequestLocationUpdates(LocationProvider.GPS,0,0);
        //		// LocationManager.RequestLocationUpdates(LocationProvider.Network,0,0);
        //
        //		LocationManager.SetTestProviderLocation(LocationProvider.GPS, new Location(LocationProvider.GPS, 50, 15));
        //
        //
        //		// Debug.Log("### " + _ao.Call<string>("GetLastKnownLocation", "gps"));
    }
Beispiel #8
0
        public static void LogEvent(string category, string message)
        {
            DatabaseDataContext db = new DatabaseDataContext();

            Information e = new Information();
            e.Message = "[" + category + "] " + message;
            e.CreatedDate = DateTime.UtcNow;

            db.Informations.InsertOnSubmit(e);

            db.SubmitChanges();
        }
	protected override void AwakeDevice()
    {
		if(!Application.isEditor) {
			Singleton = null;
			Destroy(this);
		}
		
		for (var i = 1; i <= Sensor.Count; i++) 
		{
			// fill the sensor information array with debug values
			Sensors[i] = new Information(this.GetSensorDebugAvailable(i), 1, 0, "DEBUG", 0, 100, "DEBUG", 0, Description[i]);
		}
	}
Beispiel #10
0
        public static void test(object o, ElapsedEventArgs e)
        {
            int size;
            Information info = new Information();
            AlertInformation ai;
            NicoCommunity.CommunityInfo ci;
            lock (obj)
            {
                size = queue.Count();
                if (size != 0)
                {
                    info = queue.Dequeue();
                }
            }

            ai = info.ai;
            ci = info.ci;

            if (size != 0)
            {
                StringBuilder sb = new StringBuilder();
                TcpClient tcp = new TcpClient("localhost", 9821);
                Stream s = tcp.GetStream();
                StreamWriter sw = new StreamWriter(s);
                StreamReader sr = new StreamReader(s);
                //sw.Write(sb);
                //sw.Flush();
                char[] c = new char[512];
                //sr.Read(c, 0, c.Length);
                //Console.WriteLine(c);
                //tcp.Close();

                //tcp = new TcpClient("localhost", 9821);
                //s = tcp.GetStream();
                //sw = new StreamWriter(s);
                //sr = new StreamReader(s);
                sb = new StringBuilder();
                sb.Append("SEND SSTP/1.1\r\n");
                sb.Append("Sender: MomeNicoLibrary\r\n");
                sb.Append("Script: \\0\\s0MoeNicoLiveAlert: " + ci.title + "\\e\r\n");
                sb.Append("Option: nodescript,notranslate\r\n");
                sb.Append("Charset: UTF-8\r\n\r\n");
                sw.Write(sb);
                sw.Flush();
                sr.Read(c, 0, c.Length);
            //				Console.WriteLine(c);
                tcp.Close();
            }
        }
Beispiel #11
0
        public AboutBox(Information info)
        {
            InitializeComponent();

            //  Initialize the AboutBox to display the product information from the assembly information.
            //  Change assembly information settings for your application through either:
            //  - Project->Properties->Application->Assembly Information
            //  - AssemblyInfo.cs
            this.Text = String.Format("About {0}", "FolderTrack");
            this.labelProductName.Text = String.Format("Build {0}", info.Build);
            this.labelVersion.Text = String.Format("Version {0}", info.ReleaseName);
            this.labelCopyright.Text = AssemblyCopyright;
            this.labelCompanyName.Text = AssemblyCompany;
            this.textBoxDescription.Text = info.Discription;
        }
Beispiel #12
0
    public void SetPosition(Information panoInfo)
    {
        Vector3 _rotation = new Vector3(panoInfo.lat, -panoInfo.lng, 0.0f);
        Vector3 _translate = new Vector3(0, 0, -37.5f);

        Lat = _rotation.x;
        Lng = -(_rotation.y);
        panoID = panoInfo.panoid;
        isFamous = panoInfo.isFamous;

        thumbnailURL = thumbnailURL + panoID;

        Debug.Log(Lat + " " + Lng + " " + panoID );

        transform.Rotate(Vector3.up, 5);
        transform.Rotate(Vector3.back, 15);
        transform.Rotate(_rotation);
        transform.Translate(_translate);
    }
Beispiel #13
0
        private void RunTool(Information information)
        {
            // Example:
            // verpatch.exe MyFile.exe /s CompanyName "My Company" /s LegalCopyright "My Copyright" /s ProductName "My Product"
            string arguments = string.Format(
                "\"{0}\" /s CompanyName \"{1}\" /s LegalCopyright \"{2}\" /s ProductName \"{3}\"",
                fileName,
                information.Company,
                information.Copyright,
                information.Product);

            var info = new ProcessStartInfo(ToolFilePath, arguments)
            {
                CreateNoWindow = true,
                UseShellExecute = false
            };

            Process process = Process.Start(info);
            process.WaitForExit();
        }
        public ActionResult GetPatientHistory(string voterId)
        {
            var history = db.TreatmentRelations.Where(p => p.VoterId == voterId);
            var serviceCenters = db.ServiceCenters.ToList();

            List<Information> informations = new List<Information>();

            foreach (TreatmentRelation relation in history)
            {

                Information aInformation = new Information();
                //string code = Convert.ToString(relation.ServiceCenterCode);
                var servciecenter = serviceCenters.FirstOrDefault(p => p.Code == relation.ServiceCenterCode);

                    aInformation.ServcieCenterCode = servciecenter.Code;
                    aInformation.ServiceCenterName=servciecenter.Name;

                aInformation.Dates = relation.DateOfObservation;
                informations.Add(aInformation);
            }
            return Json(informations, JsonRequestBehavior.AllowGet);
        }
Beispiel #15
0
        public static void callback(AlertInformation ai)
        {
            Information info = new Information();

            NicoCommunity nc = new NicoCommunity();
            NicoCommunity.CommunityInfo ci = nc.GetCommunityInfo(ai.BroadcastId);

            StringBuilder sb = new StringBuilder();
            sb.Append(ai.BroadcastId).Append(",")
                .Append(ai.CasterId).Append(",")
                .Append(ai.ChannelId).Append("\t: ")
                .Append(ci.title);
            Console.WriteLine(sb);
            if (ci.title.IndexOf("雑談") != -1)
            {
                info.ci = ci;
                info.ai = ai;
                lock (obj)
                {
                    queue.Enqueue(info);
                }
            }
        }
        public override void Close(TimeSpan timeout, Information options)
        {
            if (_disposed) throw new ObjectDisposedException(this.GetType().FullName);
            if (!_connect) throw new ConnectionException();

            lock (this.ThisLock)
            {
                if (_connection != null)
                {
                    try
                    {
                        _connection.Close(timeout);
                    }
                    catch (Exception)
                    {

                    }

                    _connection = null;
                }

                _connect = false;
            }
        }
Beispiel #17
0
        private AnsiCPMaps()
        {
            aCPLN      = Strings.Split(Maps.sCPLN, "|");
            aCPL       = Strings.Split(Maps.sCPL, "|");
            aCPLISO    = Strings.Split(Maps.sCPLISO, "|");
            aWinCPL    = Strings.Split(Maps.sWinCPL, "|");
            aWinCPLN   = Strings.Split(Maps.sWinCPLN, "|");
            aWinCPLISO = Strings.Split(Maps.sWinCPLISO, "|");

            CodePages          = new List <CP>();
            CodePagesSelection = new ArrayList();
            CP437 = new CP("CP437", "Latin US/United States/Canada", "DOS", "iso-8859-1", Maps.sUniCodeCP437, Maps.sCP437desc, Maps.sCP437HTML);
            CodePages.Add(CP437);
            CP737 = new CP("CP737", "Greek", "DOS", "iso-8859-7", Maps.sUniCodeCP737, Maps.sCP737desc, Maps.sCP737HTML);
            CodePages.Add(CP737);
            CP775 = new CP("CP775", "Baltic Rim", "DOS", "iso-8859-4", Maps.sUniCodeCP775, Maps.sCP775desc, Maps.sCP775HTML);
            CodePages.Add(CP775);
            CP850 = new CP("CP850", "Latin 1 (Western Europe: DE, FR, ES)", "DOS", "iso-8859-1", Maps.sUniCodeCP850, Maps.sCP850desc, Maps.sCP850HTML);
            CodePages.Add(CP850);
            CP852 = new CP("CP852", "Latin 2 (Slavic: PL, RU, BA, HR, HU, CZ, SK)", "DOS", "iso-8859-2", Maps.sUniCodeCP852, Maps.sCP852desc, Maps.sCP852HTML);
            CodePages.Add(CP852);
            CP855 = new CP("CP855", "Cyrillic (RU, BG, UA)", "DOS", "iso-8859-5", Maps.sUniCodeCP855, Maps.sCP855desc, Maps.sCP855HTML);
            CodePages.Add(CP855);
            CP857 = new CP("CP857", "Turkish, TR", "DOS", "iso-8859-9", Maps.sUniCodeCP857, Maps.sCP857desc, Maps.sCP857HTML);
            CodePages.Add(CP857);
            CP858 = new CP("CP858", "Latin 1 Alt (= 850, 0xD5 = U+20AC EURO SYM)", "DOS", "iso-8859-1", Maps.sUniCodeCP858, Maps.sCP858desc, Maps.sCP858HTML);
            CodePages.Add(CP858);
            CP860 = new CP("CP860", "Portuguese, PT", "DOS", "iso-8859-15", Maps.sUniCodeCP860, Maps.sCP860desc, Maps.sCP860HTML);
            CodePages.Add(CP860);
            CP861 = new CP("CP861", "Islandic, IS", "DOS", "iso-8859-8", Maps.sUniCodeCP861, Maps.sCP861desc, Maps.sCP861HTML);
            CodePages.Add(CP861);
            CP862 = new CP("CP862", "Hebrew, IL", "DOS", "iso-8859-1", Maps.sUniCodeCP862, Maps.sCP862desc, Maps.sCP862HTML);
            CodePages.Add(CP862);
            CP863 = new CP("CP863", "Canada, CA (French)", "DOS", "iso-8859-1", Maps.sUniCodeCP863, Maps.sCP863desc, Maps.sCP863HTML);
            CodePages.Add(CP863);
            CP864 = new CP("CP864", "Arabic", "DOS", "iso-8859-5", Maps.sUniCodeCP864, Maps.sCP864desc, Maps.sCP864HTML);
            CodePages.Add(CP864);
            CP865 = new CP("CP865", "Nordic (except IS) (DK, SE, NO, FI)", "DOS", "iso-8859-7", Maps.sUniCodeCP865, Maps.sCP865desc, Maps.sCP865HTML);
            CodePages.Add(CP865);
            CP866 = new CP("CP866", "Cyrillic Russian (based on GOST 19768-87)", "DOS", "tactis", Maps.sUniCodeCP866, Maps.sCP866desc, Maps.sCP866HTML);
            CodePages.Add(CP866);
            CP869 = new CP("CP869", "Greek 2 (IBM Modern GR)", "DOS", "-", Maps.sUniCodeCP869, Maps.sCP869desc, Maps.sCP869HTML);
            CodePages.Add(CP869);
            CP874 = new CP("CP874", "MS-DOS Thai", "DOS", "-", Maps.sUniCodeCP874, Maps.sCP874desc, Maps.sCP874HTML);
            CodePages.Add(CP874);


            CP1250 = new CP("CP1250", "Windows Latin-2", "WIN", "iso-8859-2", Maps.sWinUniCodeCP1250, Maps.sWinCP1250desc, Maps.sCP1250HTML);
            CodePages.Add(CP1250);
            CP1251 = new CP("CP1251", "Windows Cyrillic", "WIN", "iso-8859-5", Maps.sWinUniCodeCP1251, Maps.sWinCP1251desc, Maps.sCP1251HTML);
            CodePages.Add(CP1251);
            CP1252 = new CP("CP1252", "Windows Latin-1", "WIN", "us-ascii", Maps.sWinUniCodeCP1252, Maps.sWinCP1252desc, Maps.sCP1252HTML);
            CodePages.Add(CP1252);
            CP1253 = new CP("CP1253", "Windows Greek", "WIN", "iso-8859-7", Maps.sWinUniCodeCP1253, Maps.sWinCP1253desc, Maps.sCP1253HTML);
            CodePages.Add(CP1253);
            CP1254 = new CP("CP1254", "Windows Turkish", "WIN", "iso-8859-9", Maps.sWinUniCodeCP1254, Maps.sWinCP1254desc, Maps.sCP1254HTML);
            CodePages.Add(CP1254);
            CP1255 = new CP("CP1255", "Windows Hebrew", "WIN", "iso-8859-8", Maps.sWinUniCodeCP1255, Maps.sWinCP1255desc, Maps.sCP1255HTML);
            CodePages.Add(CP1255);
            CP1256 = new CP("CP1256", "Windows Arabic", "WIN", "-", Maps.sWinUniCodeCP1256, Maps.sWinCP1256desc, Maps.sCP1256HTML);
            CodePages.Add(CP1256);
            CP1257 = new CP("CP1257", "Windows Baltic (1)", "WIN", "iso-8859-4", Maps.sWinUniCodeCP1257, Maps.sWinCP1257desc, Maps.sCP1257HTML);
            CodePages.Add(CP1257);
            CP1258 = new CP("CP1258", "Windows Vietnamese", "WIN", "-", Maps.sWinUniCodeCP1258, Maps.sWinCP1258desc, Maps.sCP1258HTML);
            CodePages.Add(CP1258);
            CP874W = new CP("CP874", "Windows Thai", "WIN", "tactis", Maps.sWinUniCodeCP874, Maps.sWinCP874desc, Maps.sCP874WHTML);
            CodePages.Add(CP874W);
            CP932 = new CP("CP932", "Windows Japanese", "WIN", "-", Maps.sWinUniCodeCP932, Maps.sWinCP932desc, Maps.sCP932HTML);
            CodePages.Add(CP932);
            CP936 = new CP("CP936", "Windows Chinese (VRCN)", "WIN", "-", Maps.sWinUniCodeCP936, Maps.sWinCP936desc, Maps.sCP936HTML);
            CodePages.Add(CP936);
            CP949 = new CP("CP949", "Windows Korean", "WIN", "-", Maps.sWinUniCodeCP949, Maps.sWinCP949desc, Maps.sCP949HTML);
            CodePages.Add(CP949);
            CP950 = new CP("CP950", "Windows Chinese (HK)", "WIN", "-", Maps.sWinUniCodeCP950, Maps.sWinCP950desc, Maps.sCP950HTML);
            CodePages.Add(CP950);

            int iEnumCnt = 0;

            for (int a = 0; a <= Information.UBound(aCPL); a++)
            {
                CodePagesSelection.Add(new clsCodePage((CodePg)iEnumCnt, aCPLN[a] + " (" + aCPL[a] + ")", aCPL[a], aCPLISO[a]));
                iEnumCnt += 1;
            }
            for (int a = 0; a <= Information.UBound(aWinCPL); a++)
            {
                CodePagesSelection.Add(new clsCodePage((CodePg)iEnumCnt, aWinCPLN[a] + " (" + aCPL[a] + ")", aWinCPL[a], aWinCPLISO[a]));
                iEnumCnt += 1;
            }
        }
            public ShareListViewItem(Information information)
            {
                this.Information = information;

                _id = (int)this.Information["Id"];
            }
Beispiel #19
0
        /// <summary>
        /// Loads a map from a stream.
        /// </summary>
        /// <param name="stream">The stream to load from.</param>
        public static Map Load(Stream stream)
        {
            using (StreamReader sreader = new StreamReader(stream, Encoding.UTF8))
            {
                try
                {
                    int         w    = 50;
                    int         h    = 50;
                    Information info = new Information("", Environment.Forest, Weather.Sunny);

                    Map map = null;

                    using (JsonReader reader = new JsonTextReader(sreader))
                    {
                        reader.CloseInput = false;

                        while (reader.Read())
                        {
                            if (reader.TokenType == JsonToken.PropertyName)
                            {
                                switch (reader.Value)
                                {
                                case "version":
                                    int version = reader.ReadAsInt32().Value;
                                    if (version != MAP_FORMAT_VERSION)
                                    {
                                        throw new Exception("Loaded map was created in " +
                                                            (version > MAP_FORMAT_VERSION ? "a newer" : "an older") +
                                                            " version (" + MAP_FORMAT_VERSION + " != " + version + ")");
                                    }
                                    break;

                                case "info":
                                    ReadJSONInfo(reader, info);
                                    break;

                                case "width":
                                    w = reader.ReadAsInt32().Value;
                                    break;

                                case "height":
                                    h = reader.ReadAsInt32().Value;
                                    break;

                                case "layers":
                                    if (map == null)
                                    {
                                        map = new Map(w, h, info);

                                        if (stream is FileStream)
                                        {
                                            FileStream fstream = stream as FileStream;
                                            map.File = fstream.Name.Replace(Path.GetDirectoryName(Assembly.GetAssembly(typeof(Map)).Location), "");
                                        }
                                    }

                                    ReadJSONLayers(reader, map);
                                    break;
                                }
                            }
                        }
                    }

                    return(map);
                }
                catch (JsonReaderException e)
                {
                    stream.Seek(0, SeekOrigin.Begin);

                    // this might be an old map
                    return(OldMapLoader.Load(stream));
                }
            }
        }
        public void EqualsReturnsFalseOnNull()
        {
            Information bit = Information.FromBits(1);

            Assert.False(bit.Equals(null));
        }
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = Information.FromBits(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(Information.FromBits(1), -1, ComparisonType.Relative));
        }
        public void CompareToThrowsOnTypeMismatch()
        {
            Information bit = Information.FromBits(1);

            Assert.Throws <ArgumentException>(() => bit.CompareTo(new object()));
        }
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(Information)));
        }
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
        public void Convert_ToString_EqualsToString()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Beispiel #27
0
        public void HandleInformation(string sourceUserID, int informationType, byte[] information)
        {
            if (informationType == this.groupInfoTypes.P2PChannelOpen)
            {
                P2PChannelReportContract contract = CompactPropertySerializer.Default.Deserialize <P2PChannelReportContract>(information, 0);
                this.p2PChannelManager.Register(sourceUserID, contract.DestUserID);
                return;
            }

            if (informationType == this.groupInfoTypes.P2PChannelClose)
            {
                P2PChannelReportContract contract = CompactPropertySerializer.Default.Deserialize <P2PChannelReportContract>(information, 0);
                this.p2PChannelManager.Unregister(sourceUserID, contract.DestUserID);
                return;
            }

            if (informationType == this.groupInfoTypes.Join)
            {
                GroupContract contract = CompactPropertySerializer.Default.Deserialize <GroupContract>(information, 0);
                this.dynamicGroupManager.JoinGroup(contract.GroupID, sourceUserID);
                return;
            }

            if (informationType == this.groupInfoTypes.DestroyGroup)
            {
                GroupContract contract = CompactPropertySerializer.Default.Deserialize <GroupContract>(information, 0);
                this.dynamicGroupManager.DestroyGroup(sourceUserID, contract.GroupID);
                return;
            }

            if (informationType == this.groupInfoTypes.QuitGroup)
            {
                GroupContract contract = CompactPropertySerializer.Default.Deserialize <GroupContract>(information, 0);
                this.dynamicGroupManager.QuitGroup(contract.GroupID, sourceUserID);
                return;
            }

            if (informationType == this.groupInfoTypes.Fire)
            {
                RecruitOrFireContract contract = CompactPropertySerializer.Default.Deserialize <RecruitOrFireContract>(information, 0);
                this.dynamicGroupManager.QuitGroup(contract.GroupID, contract.MemberID);
                return;
            }

            if (informationType == this.groupInfoTypes.Broadcast || informationType == this.groupInfoTypes.BroadcastByServer)
            {
                bool transfer = informationType == this.groupInfoTypes.BroadcastByServer;
                BroadcastContract contract = CompactPropertySerializer.Default.Deserialize <BroadcastContract>(information, 0);
                string            groupID  = contract.GroupID;
                if (this.BroadcastReceived != null)
                {
                    this.BroadcastReceived(sourceUserID, groupID, contract.InformationType, contract.Content);
                }

                List <string> members = this.dynamicGroupManager.GetGroupMembers(groupID);
                if (members != null)
                {
                    foreach (string memberID in members)
                    {
                        bool useP2PChannel = transfer ? false : this.p2PChannelManager.IsP2PChannelExist(sourceUserID, memberID);
                        if (memberID != sourceUserID && !useP2PChannel)
                        {
                            this.customizeController.Send(memberID, informationType, information, true, contract.ActionTypeOnChannelIsBusy);
                        }
                    }
                }
                return;
            }
            if (informationType == this.groupInfoTypes.BroadcastBlob || informationType == this.groupInfoTypes.BroadcastBlobByServer)
            {
                BlobFragmentContract contract = CompactPropertySerializer.Default.Deserialize <BlobFragmentContract>(information, 0);
                if (this.BroadcastReceived != null)
                {
                    Information info = this.blobReceiver.Receive(sourceUserID, contract.DestUserID, contract);
                    if (info != null)
                    {
                        this.BroadcastReceived(sourceUserID, contract.DestUserID, info.InformationType, info.Content);
                    }
                }

                bool          transfer = informationType == this.groupInfoTypes.BroadcastBlobByServer;
                List <string> members  = this.dynamicGroupManager.GetGroupMembers(contract.DestUserID);
                if (members != null)
                {
                    foreach (string memberID in members)
                    {
                        bool useP2PChannel = transfer ? false : this.p2PChannelManager.IsP2PChannelExist(sourceUserID, memberID);
                        if (memberID != sourceUserID && !useP2PChannel)
                        {
                            this.customizeController.Send(memberID, informationType, information, true, ActionTypeOnChannelIsBusy.Continue);
                        }
                    }
                }
                return;
            }
        }
 public static object IsDate(object expression)
 {
     return(Information.IsDate(expression));
 }
 public static object IsArray(object varname)
 {
     return(Information.IsArray(varname));
 }
Beispiel #30
0
        public byte[] DecodeArray64(string sInput)
        {
            if (m_bytReverseIndex[47] != 63)
            {
                Initialize64();
            }
            byte[] bytInput          = null;
            byte[] bytWorkspace      = null;
            byte[] bytResult         = null;
            long   lInputCounter     = 0;
            long   lWorkspaceCounter = 0;

            string innerString = Strings.Replace(sInput, Constants.vbCrLf, "");
            string outerString = Strings.Replace(innerString, "=", "");

            bytInput          = UTF8Encoding.UTF8.GetBytes(outerString);
            bytWorkspace      = new byte[(Information.UBound(bytInput) * 2) + 1];
            lWorkspaceCounter = Information.LBound(bytWorkspace);
            for (lInputCounter = Information.LBound(bytInput); lInputCounter <= Information.UBound(bytInput); lInputCounter++)
            {
                bytInput[lInputCounter] = m_bytReverseIndex[bytInput[lInputCounter]];
            }

            for (lInputCounter = Information.LBound(bytInput); lInputCounter <= (Information.UBound(bytInput) - ((Information.UBound(bytInput) % 8) + 8)); lInputCounter += 8)
            {
                bytWorkspace[lWorkspaceCounter]     = (bytInput[lInputCounter] * k_bytShift2) + (bytInput[lInputCounter + 2] / k_bytShift4);
                bytWorkspace[lWorkspaceCounter + 1] = ((bytInput[lInputCounter + 2] & k_bytMask2) * k_bytShift4) + (bytInput[lInputCounter + 4] / k_bytShift2);
                bytWorkspace[lWorkspaceCounter + 2] = ((bytInput[lInputCounter + 4] & k_bytMask1) * k_bytShift6) + bytInput[lInputCounter + 6];
                lWorkspaceCounter = lWorkspaceCounter + 3;
            }

            switch ((Information.UBound(bytInput) % 8))
            {
            case 3:
                bytWorkspace[lWorkspaceCounter] = (bytInput[lInputCounter] * k_bytShift2) + (bytInput[lInputCounter + 2] / k_bytShift4);
                break;

            case 5:
                bytWorkspace[lWorkspaceCounter]     = (bytInput[lInputCounter] * k_bytShift2) + (bytInput[lInputCounter + 2] / k_bytShift4);
                bytWorkspace[lWorkspaceCounter + 1] = ((bytInput[lInputCounter + 2] & k_bytMask2) * k_bytShift4) + (bytInput[lInputCounter + 4] / k_bytShift2);
                lWorkspaceCounter = lWorkspaceCounter + 1;
                break;

            case 7:
                bytWorkspace[lWorkspaceCounter]     = (bytInput[lInputCounter] * k_bytShift2) + (bytInput[lInputCounter + 2] / k_bytShift4);
                bytWorkspace[lWorkspaceCounter + 1] = ((bytInput[lInputCounter + 2] & k_bytMask2) * k_bytShift4) + (bytInput[lInputCounter + 4] / k_bytShift2);
                bytWorkspace[lWorkspaceCounter + 2] = ((bytInput[lInputCounter + 4] & k_bytMask1) * k_bytShift6) + bytInput[lInputCounter + 6];
                lWorkspaceCounter = lWorkspaceCounter + 2;
                break;
            }

            bytResult = new byte[lWorkspaceCounter + 1];
            if (Information.LBound(bytWorkspace) == 0)
            {
                lWorkspaceCounter = lWorkspaceCounter + 1;
            }
            CopyMemory(VarPtr.VarPtr(bytResult[Information.LBound(bytResult)]), VarPtr.VarPtr(bytWorkspace[Information.LBound(bytWorkspace)]), lWorkspaceCounter);
            return(bytResult);
        }
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = Information.FromBits(1).ToBaseUnit();

            Assert.Equal(Information.BaseUnit, quantityInBaseUnit.Unit);
        }
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(InformationUnit)));
        }
        public void CompareToThrowsOnNull()
        {
            Information bit = Information.FromBits(1);

            Assert.Throws <ArgumentNullException>(() => bit.CompareTo(null));
        }
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Equal(QuantityType.Information, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Information bit = Information.FromBits(1);

            Assert.False(bit.Equals(new object()));
        }
Beispiel #36
0
 // Close
 public abstract void Close(TimeSpan timeout, Information options);
        public void ToString_NullFormat_ThrowsArgumentNullException()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, null, null));
        }
Beispiel #38
0
        public override void VisitIdentifierName(IdentifierNameSyntax node)
        {
            Information.Add(InfoExtractor.Info.NAME, node.Identifier.Value);

            base.VisitIdentifierName(node);
        }
        /// <summary>
        /// Command implementation of Information menu item. Executing command.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Information_Executed(object sender, ExecutedRoutedEventArgs e) {
            if (m_data.M_inputFilename == string.Empty || m_data.M_bitmap == null) {
                MessageBox.Show("Open image first!", "ArgumentsNull", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try {
                Information informationWindow = new Information(m_data);
                informationWindow.Owner = this;
                informationWindow.Show();
            } catch (FileNotFoundException ex) {
                MessageBox.Show(ex.Message, "FileNotFoundException", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (ArgumentException ex) {
                MessageBox.Show(ex.Message, "ArgumentException", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (InvalidOperationException ex) {
                MessageBox.Show(ex.Message, "InvalidOperationException", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (IndexOutOfRangeException ex) {
                MessageBox.Show(ex.Message, "IndexOutOfRangeException", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public void setTopic()
 {
     Information info = new Information();
      writer.WriteLine("TOPIC {0} :{1}", channel, info.msg().Substring(nick.Length + 8));
      writer.Flush();
 }
Beispiel #41
0
        private void button16_Click(object sender, EventArgs e)
        {
            Information info = new Information();
            DialogResult dialogResult = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo);
            if (dialogResult == DialogResult.Yes)
            {
                Kaziknop.Image = Image.FromFile("Money.png");
                Money = 0;
                CPS = 0;
                ClickerPrice = 25;
                FarmPrice = 125;
                MinePrice = 250;
                VillagePrice = 750;
                CityPrice = 1500;
                CountryPrice = 2500;
                PlanetPrice = 12500;
                GalaxyPrice = 25000;
                ClickingPrice = 750;
                ClickingSpeed = 1;
                ClickerAmount = 0;
                GodPrice = 250000000;
                GodAmount = 0;
                UniversePrice = 25000000;
                UniverseAmount = 0;
                UniverseBuffer = 0;
                FarmAmount = 0;
                MineAmount = 0;
                VillageAmount = 0;
                CityAmount = 0;
                CountryAmount = 0;
                PlanetAmount = 0;
                GalaxyAmount = 0;
                ClickingAmount = 0;
                BankRente = 11;
                ClickerSpeed = 1;
                FarmSpeed = 3;
                MineSpeed = 5;
                VillageSpeed = 10;
                CitySpeed = 20;
                CountrySpeed = 35;
                PlanetSpeed = 50;
                GalaxySpeed = 75;
                UniverseSpeed = 100000;
                OpBank = 0;
                ClickerBuffer = 0;
                FarmBuffer = 0;
                MineBuffer = 0;
                VillageBuffer = 0;
                CityBuffer = 0;
                CountryBuffer = 0;
                PlanetBuffer = 0;
                GalaxyBuffer = 0;
                TotalClicks = 0;
                TickSpeed = 1000;
                SellMode = false;
                CreditsBuffer = 1;
                checkBox3.Checked = false;
            }
            else if (dialogResult == DialogResult.No)
            {

            }
        }
        private void LoadData()
        {
            try
            {
                string strFilter = strSeniorFilterHidden;
                if (txtWaterUserNOSearch.Text.Trim() != "")
                {
                    strFilter += " AND waterUserNO='" + txtWaterUserNOSearch.Text.Trim().PadLeft(8, '0') + "'";
                }

                if (txtWaterUserNameSearch.Text.Trim() != "")
                {
                    strFilter += " AND waterUserName like '%" + txtWaterUserNameSearch.Text.Trim() + "%'";
                }

                if (cmbWaterUserTypeSearch.SelectedValue != null && cmbWaterUserTypeSearch.SelectedValue != DBNull.Value)
                {
                    strFilter += " AND waterUserTypeId='" + cmbWaterUserTypeSearch.SelectedValue.ToString() + "'";
                }

                if (cmbMFYH.SelectedIndex > 0)
                {
                    if (cmbMFYH.SelectedIndex == 1)
                    {
                        strFilter += " AND memo='MFYH@'";
                    }
                    else if (cmbMFYH.SelectedIndex == 2)
                    {
                        strFilter += " AND (MEMO<>'MFYH@' OR MEMO is null) ";
                    }
                }

                if (chkZSH.Checked)
                {
                    strFilter += " AND waterUserTypeId<>'0004'";
                }

                if (cmbWaterUserMeterReadingNO.SelectedValue != null && cmbWaterUserMeterReadingNO.SelectedValue != DBNull.Value)
                {
                    strFilter += " AND meterReadingID='" + cmbWaterUserMeterReadingNO.SelectedValue.ToString() + "'";
                }

                if (cmbArea.SelectedValue != null && cmbArea.SelectedValue != DBNull.Value)
                {
                    strFilter += " AND areaId='" + cmbArea.SelectedValue.ToString() + "'";
                }

                if (cmbWaterUserIsAgentSearch.Text != "")
                {
                    strFilter += " AND agentsign='" + cmbWaterUserIsAgentSearch.SelectedIndex.ToString() + "'";
                }

                if (cmbWaterUserAgentBankSearch.SelectedValue != null && cmbWaterUserAgentBankSearch.SelectedValue != DBNull.Value)
                {
                    strFilter += " AND bankId='" + cmbWaterUserAgentBankSearch.SelectedValue.ToString() + "'";
                }

                if (cmbWaterMeterType.SelectedValue != null && cmbWaterMeterType.SelectedValue != DBNull.Value)
                {
                    strFilter += " AND waterMeterTypeId='" + cmbWaterMeterType.SelectedValue.ToString() + "'";
                }

                if (cmbChargeType.SelectedValue != null && cmbChargeType.SelectedValue != DBNull.Value)
                {
                    strFilter += " AND CHARGETYPEID='" + cmbChargeType.SelectedValue.ToString() + "'";
                }

                if (cmbWaterFeeYear.Text != "")
                {
                    strFilter += " AND readMeterRecordYear=" + cmbWaterFeeYear.Text;
                }

                if (cmbWaterFeeMonth.Text != "")
                {
                    strFilter += " AND readMeterRecordMonth=" + cmbWaterFeeMonth.Text;
                }

                if (cmbChargerWorkName.SelectedValue != null && cmbChargerWorkName.SelectedValue != DBNull.Value)
                {
                    strFilter += " AND CHARGEWORKERID='" + cmbChargerWorkName.SelectedValue.ToString() + "'";
                }

                if (chkChargeDateTime.Checked)
                {
                    strFilter += " AND CHARGEDATETIME BETWEEN '" + dtpStart.Text + "' AND '" + dtpEnd.Text + "'";
                }

                dgList.DataSource = null;

                DataTable dtStastics = BLLWATERFEECHARGE.WaterChargeStatistics(strFilter + strSeniorFilterHidden, cmbType.Text);
                DataTable dtTemp     = dtStastics.Copy();
                switch (cmbType.Text)
                {
                case "收费员":
                    #region 统计信息
                    DataRow dr = dtTemp.Rows.Add();
                    dr["收费员"]   = "合计:";
                    dr["单据数量"]  = 0;
                    dr["用水量"]   = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    object objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按收费员)";
                    break;

                case "收费方式":
                    #region 统计信息
                    dr          = dtTemp.Rows.Add();
                    dr["收费方式"]  = "合计:";
                    dr["单据数量"]  = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按收费方式)";
                    break;

                case "用户类型":
                    #region 统计信息
                    dr          = dtTemp.Rows.Add();
                    dr["用户类型"]  = "合计:";
                    dr["单据数量"]  = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按用户类型)";
                    break;

                case "抄表本":
                    #region 统计信息
                    dr          = dtTemp.Rows.Add();
                    dr["抄表本"]   = "合计:";
                    dr["单据数量"]  = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按抄表本)";
                    break;

                case "区域":
                    #region 统计信息
                    dr          = dtTemp.Rows.Add();
                    dr["区域名称"]  = "合计:";
                    dr["单据数量"]  = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按区域)";
                    break;

                case "抄表员":
                    #region 统计信息
                    dr          = dtTemp.Rows.Add();
                    dr["抄表员"]   = "合计:";
                    dr["单据数量"]  = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按抄表员)";
                    break;

                case "银行托收":
                    #region 统计信息
                    dr          = dtTemp.Rows.Add();
                    dr["银行托收"]  = "合计:";
                    dr["单据数量"]  = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按银行托收)";
                    break;

                case "托收银行":
                    #region 统计信息
                    dr          = dtTemp.Rows.Add();
                    dr["托收银行"]  = "合计:";
                    dr["单据数量"]  = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按托收银行)";
                    break;

                case "用水性质":
                    #region 统计信息
                    dr          = dtTemp.Rows.Add();
                    dr["用水性质"]  = "合计:";
                    dr["单据数量"]  = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按用水性质)";
                    break;

                case "用户名":
                    #region 统计信息
                    dr          = dtTemp.Rows.Add();
                    dr["用户名"]   = "合计:";
                    dr["单据数量"]  = 0;
                    dr["水费"]    = 0;
                    dr["污水处理费"] = 0;
                    dr["附加费"]   = 0;
                    dr["总金额"]   = 0;


                    objSum = dtTemp.Compute("SUM(单据数量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["单据数量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(用水量)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["用水量"] = Convert.ToInt64(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(水费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["水费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(污水处理费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["污水处理费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(附加费)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["附加费"] = Convert.ToDecimal(objSum);
                    }

                    objSum = dtTemp.Compute("SUM(总金额)", "");
                    if (Information.IsNumeric(objSum))
                    {
                        dr["总金额"] = Convert.ToDecimal(objSum).ToString("F2");
                    }

                    dgList.DataSource = dtTemp;
                    #endregion
                    strStaticsName = "收费统计(按用户名)";
                    break;
                }

                if (dgList.Rows.Count > 0)
                {
                    for (int i = 0; i < dgList.Columns.Count; i++)
                    {
                        //禁止列排序
                        dgList.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
                        dgList.Columns[i].DefaultCellStyle.Format = "0.##";

                        if (dgList.Columns[i].Name == "水费小计")
                        {
                            dgList.Columns[i].Visible = false;
                        }
                    }
                    toolPrint.Enabled        = true;
                    toolPrintPreview.Enabled = true;
                }
                else
                {
                    toolPrint.Enabled        = false;
                    toolPrintPreview.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                mes.Show(ex.Message);
                log.Write(ex.ToString(), MsgType.Error);
            }
        }
Beispiel #43
0
            public UploadListViewModel(Information information)
            {
                this.Information = information;

                _id = (int)this.Information["Id"];
            }
Beispiel #44
0
 public void GenerateQRCode(Information model)
 {
     throw new NotImplementedException();
 }
    public void processHeader()
    {
        IrcBot bot = new IrcBot();
         Information info = new Information();
         try
         {
         string[] httpInput = Regex.Split(inputLine, httpRegex.ToString(), RegexOptions.IgnoreCase);
         string[] input = info.msg().Split(' ');
         foreach (string text in input)
             if (Regex.IsMatch(text, httpRegex.ToString()))
             {

                 WebClient web = new WebClient();
                 byte[] bInHttpStream = web.DownloadData(text);
                 string inHttpString = Encoding.Default.GetString(bInHttpStream).Trim();
                 string[] data1 = Regex.Split(inHttpString.Trim(), "<title>|<TITLE>");
                 string[] titleContent = Regex.Split(data1[1].Trim(), "</title>|</TITLE>");

                 ChannelActions chanAct = new ChannelActions();
                 chanAct.say("[" + titleContent[0].Replace('\n',' ') + "]");
             }
         }
         catch (Exception e)
         {
         Console.WriteLine(e.ToString());
         }
    }
Beispiel #46
0
 public virtual Task SendAsync(Stream stream, TimeSpan timeout, Information options)
 {
     return Task.Run(() =>
     {
         this.Send(stream, timeout, options);
     });
 }
    public string mainLoop(int startTime)
    {
        Information information = new Information();
         ChannelActions ChanActs = new ChannelActions();
         ChanModes mode = new ChanModes();
         Loader load = new Loader();
         CTCP ctcp = new CTCP();
         UserControl users = new UserControl();
         httpRegex = new Regex(@"(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*))*)))");
         try
         {

         ThreadStart userThreadStart = new ThreadStart(users.userControl);
         Thread userThread = new Thread(userThreadStart);
         userThread.Start();
         }
         catch (Exception e)
         {
         Console.WriteLine(e.ToString());
         }

         while (true)
         {
         while ((inputLine = reader.ReadLine()) != null)
         {
             Console.WriteLine(inputLine);

             if (inputLine.IndexOf("376") >= 0) //End of MOTD
             {
                 writer.WriteLine("JOIN " + channel);
                 writer.Flush();

          }
             else
                 break;

             while ((inputLine = reader.ReadLine()) != null)
             {
                 Console.WriteLine(inputLine);

                 if (ctcp.isCTCP())
                     ctcp.processCTCPType();

                 else if (inputLine == ("PING :" + server))
                 {
                     writer.WriteLine("PONG " + server);
                     writer.Flush();
                 }

                 else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": op me") >= 0 && information.sender() == owner)
                 {
                     mode.setMode("+o", owner);
                 }

                 else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": op") >= 0)
                 {
                     string realSender = information.sender();
                     string realMsg = information.msg();
                     information.sendNamesToSrv();
                     inputLine = reader.ReadLine();
                     if (information.isOped(realSender) || information.sender() == owner && information.senderHost() == ownerhost)
                         mode.setMode("+o", realMsg.Substring(nick.Length + 5));

                 }

                 else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": voice me") >= 0 || inputLine.ToLower().IndexOf(nick.ToLower() + ": voice ") >= 0)
                 {
                     mode.setMode("+v", information.sender());
                 }

                 else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": uptime") >= 0)
                 {
                     Uptime uptime = new Uptime();
                     uptime.uptime(startTime);

                 }

                 else if (inputLine.IndexOf("PART " + channel) >= 0)
                 {
                     users.userPart();

                 }

                 else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": die") >= 0 && information.sender() == owner)
                 {
                     writer.WriteLine("QUIT :My master killed me");
                     writer.Flush();
                     cleanup();

                     return "ok";
                 }
                 else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": topic") >=0  && information.sender() == owner)
                 {
                     mode.setTopic();
                 }
                 else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": !load") >= 0 && information.sender() == owner)
                 {

                     load.createAD("load");

                 }
                 else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": !unload") >= 0 && information.sender() == owner)
                 {

                     load.createAD("unload");

                 }

                else if (Regex.IsMatch(inputLine, httpRegex.ToString()) && information.sender() != nick)
                 {

                     HttpHeader hh = new HttpHeader();
                     ThreadStart thStart = new ThreadStart(hh.processHeader);
                     Thread th = new Thread(thStart);
                     th.Start();

                 }

                 if (inputLine.StartsWith("ERROR"))
                 {
                     Console.WriteLine(inputLine);
                     return "error";

                 }

             }
         }
         }
    }
        public override System.IO.Stream Receive(TimeSpan timeout, Information options)
        {
            if (_disposed) throw new ObjectDisposedException(this.GetType().FullName);
            if (!_connect) throw new ConnectionException();

            lock (_receiveLock)
            {
                Stream stream = null;

                try
                {
                    stream = _connection.Receive(timeout, options);

                    var version = (byte)stream.ReadByte();

                    Stream dataStream = null;

                    try
                    {
                        dataStream = new RangeStream(stream, stream.Position, stream.Length - stream.Position);

                        if (version == (byte)0)
                        {
                            return dataStream;
                        }
                        else if (version == (byte)1)
                        {
                            BufferStream deflateBufferStream = null;

                            try
                            {
                                deflateBufferStream = new BufferStream(_bufferManager);

                                using (DeflateStream deflateStream = new DeflateStream(dataStream, CompressionMode.Decompress, true))
                                using (var safeBuffer = _bufferManager.CreateSafeBuffer(1024 * 4))
                                {
                                    int length;

                                    while ((length = deflateStream.Read(safeBuffer.Value, 0, safeBuffer.Value.Length)) > 0)
                                    {
                                        deflateBufferStream.Write(safeBuffer.Value, 0, length);

                                        if (deflateBufferStream.Length > _maxReceiveCount) throw new ConnectionException();
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                if (deflateBufferStream != null)
                                {
                                    deflateBufferStream.Dispose();
                                }

                                throw e;
                            }

            #if DEBUG
                            Debug.WriteLine("Receive : {0}→{1} {2}",
                                NetworkConverter.ToSizeString(stream.Length),
                                NetworkConverter.ToSizeString(deflateBufferStream.Length),
                                NetworkConverter.ToSizeString(stream.Length - deflateBufferStream.Length));
            #endif

                            deflateBufferStream.Seek(0, SeekOrigin.Begin);
                            dataStream.Dispose();

                            return deflateBufferStream;
                        }
                        else
                        {
                            throw new ArgumentException("ArgumentException");
                        }
                    }
                    catch (ConnectionException e)
                    {
                        if (dataStream != null) dataStream.Dispose();

                        throw e;
                    }
                    catch (Exception e)
                    {
                        if (dataStream != null) dataStream.Dispose();

                        throw new ConnectionException(e.Message, e);
                    }
                }
                catch (ConnectionException e)
                {
                    if (stream != null) stream.Dispose();

                    throw e;
                }
                catch (Exception e)
                {
                    if (stream != null) stream.Dispose();

                    throw new ConnectionException(e.Message, e);
                }
            }
        }
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Equal(Information.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Beispiel #50
0
        public string EncodeArray64(ref byte[] bytInput)
        {
            string functionReturnValue = null;

            // ERROR: Not supported in C#: OnErrorStatement


            if (m_bytReverseIndex[47] != 63)
            {
                Initialize64();
            }
            byte[] bytWorkspace      = null;
            byte[] bytResult         = null;
            byte[] bytCrLf           = new byte[4];
            long   lCounter          = 0;
            long   lWorkspaceCounter = 0;
            long   lLineCounter      = 0;
            long   lCompleteLines    = 0;
            long   lBytesRemaining   = 0;
            long   lpWorkSpace       = 0;
            long   lpResult          = 0;
            long   lpCrLf            = 0;

            if (Information.UBound(bytInput) < 1024)
            {
                bytWorkspace = new byte[(Information.LBound(bytInput) + 4096) + 1];
            }
            else
            {
                bytWorkspace = new byte[(Information.UBound(bytInput) * 4) + 1];
            }

            lWorkspaceCounter = Information.LBound(bytWorkspace);

            for (lCounter = Information.LBound(bytInput); lCounter <= (Information.UBound(bytInput) - ((Information.UBound(bytInput) % 3) + 3)); lCounter += 3)
            {
                bytWorkspace[lWorkspaceCounter]     = m_bytIndex[(bytInput[lCounter] / k_bytShift2)];
                bytWorkspace[lWorkspaceCounter + 2] = m_bytIndex[((bytInput[lCounter] & k_bytMask1) * k_bytShift4) + ((bytInput[lCounter + 1]) / k_bytShift4)];
                bytWorkspace[lWorkspaceCounter + 4] = m_bytIndex[((bytInput[lCounter + 1] & k_bytMask2) * k_bytShift2) + (bytInput[lCounter + 2] / k_bytShift6)];
                bytWorkspace[lWorkspaceCounter + 6] = m_bytIndex[bytInput[lCounter + 2] & k_bytMask3];
                lWorkspaceCounter = lWorkspaceCounter + 8;
            }

            switch ((Information.UBound(bytInput) % 3))
            {
            case 0:
                bytWorkspace[lWorkspaceCounter]     = m_bytIndex[(bytInput[lCounter] / k_bytShift2)];
                bytWorkspace[lWorkspaceCounter + 2] = m_bytIndex[(bytInput[lCounter] & k_bytMask1) * k_bytShift4];
                bytWorkspace[lWorkspaceCounter + 4] = k_bytEqualSign;
                bytWorkspace[lWorkspaceCounter + 6] = k_bytEqualSign;
                break;

            case 1:
                bytWorkspace[lWorkspaceCounter]     = m_bytIndex[(bytInput[lCounter] / k_bytShift2)];
                bytWorkspace[lWorkspaceCounter + 2] = m_bytIndex[((bytInput[lCounter] & k_bytMask1) * k_bytShift4) + ((bytInput[lCounter + 1]) / k_bytShift4)];
                bytWorkspace[lWorkspaceCounter + 4] = m_bytIndex[(bytInput[lCounter + 1] & k_bytMask2) * k_bytShift2];
                bytWorkspace[lWorkspaceCounter + 6] = k_bytEqualSign;
                break;

            case 2:
                bytWorkspace[lWorkspaceCounter]     = m_bytIndex[(bytInput[lCounter] / k_bytShift2)];
                bytWorkspace[lWorkspaceCounter + 2] = m_bytIndex[((bytInput[lCounter] & k_bytMask1) * k_bytShift4) + ((bytInput[lCounter + 1]) / k_bytShift4)];
                bytWorkspace[lWorkspaceCounter + 4] = m_bytIndex[((bytInput[lCounter + 1] & k_bytMask2) * k_bytShift2) + ((bytInput[lCounter + 2]) / k_bytShift6)];
                bytWorkspace[lWorkspaceCounter + 6] = m_bytIndex[bytInput[lCounter + 2] & k_bytMask3];
                break;
            }

            lWorkspaceCounter = lWorkspaceCounter + 8;

            if (lWorkspaceCounter <= k_lMaxBytesPerLine)
            {
                functionReturnValue = Strings.Left(bytWorkspace.ToString(), Strings.InStr(1, bytWorkspace.ToString(), "") - 1);
            }
            else
            {
                bytCrLf[0]     = 13;
                bytCrLf[1]     = 0;
                bytCrLf[2]     = 10;
                bytCrLf[3]     = 0;
                bytResult      = new byte[Information.UBound(bytWorkspace) + 1];
                lpWorkSpace    = VarPtr.VarPtr(bytWorkspace[Information.LBound(bytWorkspace)]);
                lpResult       = VarPtr.VarPtr(bytResult[Information.LBound(bytResult)]);
                lpCrLf         = VarPtr.VarPtr(bytCrLf[Information.LBound(bytCrLf)]);
                lCompleteLines = Conversion.Fix(lWorkspaceCounter / k_lMaxBytesPerLine);

                for (lLineCounter = 0; lLineCounter <= lCompleteLines; lLineCounter++)
                {
                    CopyMemory(lpResult, lpWorkSpace, k_lMaxBytesPerLine);
                    lpWorkSpace = lpWorkSpace + k_lMaxBytesPerLine;
                    lpResult    = lpResult + k_lMaxBytesPerLine;
                    CopyMemory(lpResult, lpCrLf, 4L);
                    lpResult = lpResult + 4L;
                }

                lBytesRemaining = lWorkspaceCounter - (lCompleteLines * k_lMaxBytesPerLine);
                if (lBytesRemaining > 0)
                {
                    CopyMemory(lpResult, lpWorkSpace, lBytesRemaining);
                }
                functionReturnValue = Strings.Left(bytResult.ToString(), Strings.InStr(1, bytResult.ToString(), "") - 1);
            }
            return(functionReturnValue);

ErrorHandler:

            bytResult           = null;
            functionReturnValue = bytResult.ToString();
            return(functionReturnValue);
        }
Beispiel #51
0
 // Connect
 public abstract void Connect(TimeSpan timeout, Information options);
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Beispiel #53
0
 // Receive
 public abstract Stream Receive(TimeSpan timeout, Information options);
        public void GetHashCode_Equals()
        {
            var quantity = Information.FromBits(1.0);

            Assert.Equal(new { Information.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Beispiel #55
0
 // Send
 public abstract void Send(Stream stream, TimeSpan timeout, Information options);
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(decimal value)
        {
            var quantity = Information.FromBits(value);

            Assert.Equal(Information.FromBits(-value), -quantity);
        }
        public override void Connect(TimeSpan timeout, Information options)
        {
            if (_disposed) throw new ObjectDisposedException(this.GetType().FullName);

            lock (this.ThisLock)
            {
                try
                {
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();

                    using (BufferStream stream = new BufferStream(_bufferManager))
                    {
                        byte[] buffer = NetworkConverter.GetBytes((uint)_myCompressAlgorithm);
                        stream.Write(buffer, 0, buffer.Length);
                        stream.Flush();
                        stream.Seek(0, SeekOrigin.Begin);

                        _connection.Send(stream, CheckTimeout(stopwatch.Elapsed, timeout));
                    }

                    using (Stream stream = _connection.Receive(CheckTimeout(stopwatch.Elapsed, timeout)))
                    {
                        byte[] buffer = new byte[4];
                        stream.Read(buffer, 0, buffer.Length);

                        _otherCompressAlgorithm = (CompressAlgorithm)NetworkConverter.ToUInt32(buffer);
                    }
                }
                catch (ConnectionException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    throw new ConnectionException(ex.Message, ex);
                }

                _connect = true;
            }
        }
        public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
        {
            var quantity00 = Information.From(1, InformationUnit.Bit);

            AssertEx.EqualTolerance(1, quantity00.Bits, BitsTolerance);
            Assert.Equal(InformationUnit.Bit, quantity00.Unit);

            var quantity01 = Information.From(1, InformationUnit.Byte);

            AssertEx.EqualTolerance(1, quantity01.Bytes, BytesTolerance);
            Assert.Equal(InformationUnit.Byte, quantity01.Unit);

            var quantity02 = Information.From(1, InformationUnit.Exabit);

            AssertEx.EqualTolerance(1, quantity02.Exabits, ExabitsTolerance);
            Assert.Equal(InformationUnit.Exabit, quantity02.Unit);

            var quantity03 = Information.From(1, InformationUnit.Exabyte);

            AssertEx.EqualTolerance(1, quantity03.Exabytes, ExabytesTolerance);
            Assert.Equal(InformationUnit.Exabyte, quantity03.Unit);

            var quantity04 = Information.From(1, InformationUnit.Exbibit);

            AssertEx.EqualTolerance(1, quantity04.Exbibits, ExbibitsTolerance);
            Assert.Equal(InformationUnit.Exbibit, quantity04.Unit);

            var quantity05 = Information.From(1, InformationUnit.Exbibyte);

            AssertEx.EqualTolerance(1, quantity05.Exbibytes, ExbibytesTolerance);
            Assert.Equal(InformationUnit.Exbibyte, quantity05.Unit);

            var quantity06 = Information.From(1, InformationUnit.Gibibit);

            AssertEx.EqualTolerance(1, quantity06.Gibibits, GibibitsTolerance);
            Assert.Equal(InformationUnit.Gibibit, quantity06.Unit);

            var quantity07 = Information.From(1, InformationUnit.Gibibyte);

            AssertEx.EqualTolerance(1, quantity07.Gibibytes, GibibytesTolerance);
            Assert.Equal(InformationUnit.Gibibyte, quantity07.Unit);

            var quantity08 = Information.From(1, InformationUnit.Gigabit);

            AssertEx.EqualTolerance(1, quantity08.Gigabits, GigabitsTolerance);
            Assert.Equal(InformationUnit.Gigabit, quantity08.Unit);

            var quantity09 = Information.From(1, InformationUnit.Gigabyte);

            AssertEx.EqualTolerance(1, quantity09.Gigabytes, GigabytesTolerance);
            Assert.Equal(InformationUnit.Gigabyte, quantity09.Unit);

            var quantity10 = Information.From(1, InformationUnit.Kibibit);

            AssertEx.EqualTolerance(1, quantity10.Kibibits, KibibitsTolerance);
            Assert.Equal(InformationUnit.Kibibit, quantity10.Unit);

            var quantity11 = Information.From(1, InformationUnit.Kibibyte);

            AssertEx.EqualTolerance(1, quantity11.Kibibytes, KibibytesTolerance);
            Assert.Equal(InformationUnit.Kibibyte, quantity11.Unit);

            var quantity12 = Information.From(1, InformationUnit.Kilobit);

            AssertEx.EqualTolerance(1, quantity12.Kilobits, KilobitsTolerance);
            Assert.Equal(InformationUnit.Kilobit, quantity12.Unit);

            var quantity13 = Information.From(1, InformationUnit.Kilobyte);

            AssertEx.EqualTolerance(1, quantity13.Kilobytes, KilobytesTolerance);
            Assert.Equal(InformationUnit.Kilobyte, quantity13.Unit);

            var quantity14 = Information.From(1, InformationUnit.Mebibit);

            AssertEx.EqualTolerance(1, quantity14.Mebibits, MebibitsTolerance);
            Assert.Equal(InformationUnit.Mebibit, quantity14.Unit);

            var quantity15 = Information.From(1, InformationUnit.Mebibyte);

            AssertEx.EqualTolerance(1, quantity15.Mebibytes, MebibytesTolerance);
            Assert.Equal(InformationUnit.Mebibyte, quantity15.Unit);

            var quantity16 = Information.From(1, InformationUnit.Megabit);

            AssertEx.EqualTolerance(1, quantity16.Megabits, MegabitsTolerance);
            Assert.Equal(InformationUnit.Megabit, quantity16.Unit);

            var quantity17 = Information.From(1, InformationUnit.Megabyte);

            AssertEx.EqualTolerance(1, quantity17.Megabytes, MegabytesTolerance);
            Assert.Equal(InformationUnit.Megabyte, quantity17.Unit);

            var quantity18 = Information.From(1, InformationUnit.Pebibit);

            AssertEx.EqualTolerance(1, quantity18.Pebibits, PebibitsTolerance);
            Assert.Equal(InformationUnit.Pebibit, quantity18.Unit);

            var quantity19 = Information.From(1, InformationUnit.Pebibyte);

            AssertEx.EqualTolerance(1, quantity19.Pebibytes, PebibytesTolerance);
            Assert.Equal(InformationUnit.Pebibyte, quantity19.Unit);

            var quantity20 = Information.From(1, InformationUnit.Petabit);

            AssertEx.EqualTolerance(1, quantity20.Petabits, PetabitsTolerance);
            Assert.Equal(InformationUnit.Petabit, quantity20.Unit);

            var quantity21 = Information.From(1, InformationUnit.Petabyte);

            AssertEx.EqualTolerance(1, quantity21.Petabytes, PetabytesTolerance);
            Assert.Equal(InformationUnit.Petabyte, quantity21.Unit);

            var quantity22 = Information.From(1, InformationUnit.Tebibit);

            AssertEx.EqualTolerance(1, quantity22.Tebibits, TebibitsTolerance);
            Assert.Equal(InformationUnit.Tebibit, quantity22.Unit);

            var quantity23 = Information.From(1, InformationUnit.Tebibyte);

            AssertEx.EqualTolerance(1, quantity23.Tebibytes, TebibytesTolerance);
            Assert.Equal(InformationUnit.Tebibyte, quantity23.Unit);

            var quantity24 = Information.From(1, InformationUnit.Terabit);

            AssertEx.EqualTolerance(1, quantity24.Terabits, TerabitsTolerance);
            Assert.Equal(InformationUnit.Terabit, quantity24.Unit);

            var quantity25 = Information.From(1, InformationUnit.Terabyte);

            AssertEx.EqualTolerance(1, quantity25.Terabytes, TerabytesTolerance);
            Assert.Equal(InformationUnit.Terabyte, quantity25.Unit);
        }
        public override void Send(System.IO.Stream stream, TimeSpan timeout, Information options)
        {
            if (_disposed) throw new ObjectDisposedException(this.GetType().FullName);
            if (!_connect) throw new ConnectionException();
            if (stream == null) throw new ArgumentNullException(nameof(stream));
            if (stream.Length == 0) throw new ArgumentOutOfRangeException(nameof(stream));

            bool isCompress = true;

            if (options != null)
            {
                if (options.Contains("IsCompress")) isCompress = (bool)options["IsCompress"];
            }

            lock (_sendLock)
            {
                using (RangeStream targetStream = new RangeStream(stream, stream.Position, stream.Length - stream.Position, true))
                {
                    try
                    {
                        var list = new List<KeyValuePair<byte, Stream>>();

                        if (isCompress)
                        {
                            if (_otherCompressAlgorithm.HasFlag(CompressAlgorithm.Deflate))
                            {
                                BufferStream deflateBufferStream = null;

                                try
                                {
                                    deflateBufferStream = new BufferStream(_bufferManager);

                                    using (DeflateStream deflateStream = new DeflateStream(deflateBufferStream, CompressionMode.Compress, true))
                                    using (var safeBuffer = _bufferManager.CreateSafeBuffer(1024 * 4))
                                    {
                                        int length;

                                        while ((length = targetStream.Read(safeBuffer.Value, 0, safeBuffer.Value.Length)) > 0)
                                        {
                                            deflateStream.Write(safeBuffer.Value, 0, length);
                                        }
                                    }

                                    deflateBufferStream.Seek(0, SeekOrigin.Begin);

                                    list.Add(new KeyValuePair<byte, Stream>((byte)1, deflateBufferStream));
                                }
                                catch (Exception e)
                                {
                                    if (deflateBufferStream != null)
                                    {
                                        deflateBufferStream.Dispose();
                                    }

                                    throw e;
                                }
                            }
                        }

                        list.Add(new KeyValuePair<byte, Stream>((byte)0, new WrapperStream(targetStream, true)));

                        list.Sort((x, y) =>
                        {
                            int c = x.Value.Length.CompareTo(y.Value.Length);
                            if (c != 0) return c;

                            return x.Key.CompareTo(y.Key);
                        });

            #if DEBUG
                        if (list[0].Value.Length != targetStream.Length)
                        {
                            Debug.WriteLine("Send : {0}→{1} {2}",
                                NetworkConverter.ToSizeString(targetStream.Length),
                                NetworkConverter.ToSizeString(list[0].Value.Length),
                                NetworkConverter.ToSizeString(list[0].Value.Length - targetStream.Length));
                        }
            #endif

                        for (int i = 1; i < list.Count; i++)
                        {
                            list[i].Value.Dispose();
                        }

                        var headerStream = new BufferStream(_bufferManager);
                        headerStream.WriteByte((byte)list[0].Key);

                        using (var dataStream = new UniteStream(headerStream, list[0].Value))
                        {
                            _connection.Send(dataStream, timeout, options);
                        }
                    }
                    catch (ConnectionException e)
                    {
                        throw e;
                    }
                    catch (Exception e)
                    {
                        throw new ConnectionException(e.Message, e);
                    }
                }
            }
        }
        public void ToUnit()
        {
            var bit = Information.FromBits(1);

            var bitQuantity = bit.ToUnit(InformationUnit.Bit);

            AssertEx.EqualTolerance(BitsInOneBit, (decimal)bitQuantity.Value, BitsTolerance);
            Assert.Equal(InformationUnit.Bit, bitQuantity.Unit);

            var byteQuantity = bit.ToUnit(InformationUnit.Byte);

            AssertEx.EqualTolerance(BytesInOneBit, (decimal)byteQuantity.Value, BytesTolerance);
            Assert.Equal(InformationUnit.Byte, byteQuantity.Unit);

            var exabitQuantity = bit.ToUnit(InformationUnit.Exabit);

            AssertEx.EqualTolerance(ExabitsInOneBit, (decimal)exabitQuantity.Value, ExabitsTolerance);
            Assert.Equal(InformationUnit.Exabit, exabitQuantity.Unit);

            var exabyteQuantity = bit.ToUnit(InformationUnit.Exabyte);

            AssertEx.EqualTolerance(ExabytesInOneBit, (decimal)exabyteQuantity.Value, ExabytesTolerance);
            Assert.Equal(InformationUnit.Exabyte, exabyteQuantity.Unit);

            var exbibitQuantity = bit.ToUnit(InformationUnit.Exbibit);

            AssertEx.EqualTolerance(ExbibitsInOneBit, (decimal)exbibitQuantity.Value, ExbibitsTolerance);
            Assert.Equal(InformationUnit.Exbibit, exbibitQuantity.Unit);

            var exbibyteQuantity = bit.ToUnit(InformationUnit.Exbibyte);

            AssertEx.EqualTolerance(ExbibytesInOneBit, (decimal)exbibyteQuantity.Value, ExbibytesTolerance);
            Assert.Equal(InformationUnit.Exbibyte, exbibyteQuantity.Unit);

            var gibibitQuantity = bit.ToUnit(InformationUnit.Gibibit);

            AssertEx.EqualTolerance(GibibitsInOneBit, (decimal)gibibitQuantity.Value, GibibitsTolerance);
            Assert.Equal(InformationUnit.Gibibit, gibibitQuantity.Unit);

            var gibibyteQuantity = bit.ToUnit(InformationUnit.Gibibyte);

            AssertEx.EqualTolerance(GibibytesInOneBit, (decimal)gibibyteQuantity.Value, GibibytesTolerance);
            Assert.Equal(InformationUnit.Gibibyte, gibibyteQuantity.Unit);

            var gigabitQuantity = bit.ToUnit(InformationUnit.Gigabit);

            AssertEx.EqualTolerance(GigabitsInOneBit, (decimal)gigabitQuantity.Value, GigabitsTolerance);
            Assert.Equal(InformationUnit.Gigabit, gigabitQuantity.Unit);

            var gigabyteQuantity = bit.ToUnit(InformationUnit.Gigabyte);

            AssertEx.EqualTolerance(GigabytesInOneBit, (decimal)gigabyteQuantity.Value, GigabytesTolerance);
            Assert.Equal(InformationUnit.Gigabyte, gigabyteQuantity.Unit);

            var kibibitQuantity = bit.ToUnit(InformationUnit.Kibibit);

            AssertEx.EqualTolerance(KibibitsInOneBit, (decimal)kibibitQuantity.Value, KibibitsTolerance);
            Assert.Equal(InformationUnit.Kibibit, kibibitQuantity.Unit);

            var kibibyteQuantity = bit.ToUnit(InformationUnit.Kibibyte);

            AssertEx.EqualTolerance(KibibytesInOneBit, (decimal)kibibyteQuantity.Value, KibibytesTolerance);
            Assert.Equal(InformationUnit.Kibibyte, kibibyteQuantity.Unit);

            var kilobitQuantity = bit.ToUnit(InformationUnit.Kilobit);

            AssertEx.EqualTolerance(KilobitsInOneBit, (decimal)kilobitQuantity.Value, KilobitsTolerance);
            Assert.Equal(InformationUnit.Kilobit, kilobitQuantity.Unit);

            var kilobyteQuantity = bit.ToUnit(InformationUnit.Kilobyte);

            AssertEx.EqualTolerance(KilobytesInOneBit, (decimal)kilobyteQuantity.Value, KilobytesTolerance);
            Assert.Equal(InformationUnit.Kilobyte, kilobyteQuantity.Unit);

            var mebibitQuantity = bit.ToUnit(InformationUnit.Mebibit);

            AssertEx.EqualTolerance(MebibitsInOneBit, (decimal)mebibitQuantity.Value, MebibitsTolerance);
            Assert.Equal(InformationUnit.Mebibit, mebibitQuantity.Unit);

            var mebibyteQuantity = bit.ToUnit(InformationUnit.Mebibyte);

            AssertEx.EqualTolerance(MebibytesInOneBit, (decimal)mebibyteQuantity.Value, MebibytesTolerance);
            Assert.Equal(InformationUnit.Mebibyte, mebibyteQuantity.Unit);

            var megabitQuantity = bit.ToUnit(InformationUnit.Megabit);

            AssertEx.EqualTolerance(MegabitsInOneBit, (decimal)megabitQuantity.Value, MegabitsTolerance);
            Assert.Equal(InformationUnit.Megabit, megabitQuantity.Unit);

            var megabyteQuantity = bit.ToUnit(InformationUnit.Megabyte);

            AssertEx.EqualTolerance(MegabytesInOneBit, (decimal)megabyteQuantity.Value, MegabytesTolerance);
            Assert.Equal(InformationUnit.Megabyte, megabyteQuantity.Unit);

            var pebibitQuantity = bit.ToUnit(InformationUnit.Pebibit);

            AssertEx.EqualTolerance(PebibitsInOneBit, (decimal)pebibitQuantity.Value, PebibitsTolerance);
            Assert.Equal(InformationUnit.Pebibit, pebibitQuantity.Unit);

            var pebibyteQuantity = bit.ToUnit(InformationUnit.Pebibyte);

            AssertEx.EqualTolerance(PebibytesInOneBit, (decimal)pebibyteQuantity.Value, PebibytesTolerance);
            Assert.Equal(InformationUnit.Pebibyte, pebibyteQuantity.Unit);

            var petabitQuantity = bit.ToUnit(InformationUnit.Petabit);

            AssertEx.EqualTolerance(PetabitsInOneBit, (decimal)petabitQuantity.Value, PetabitsTolerance);
            Assert.Equal(InformationUnit.Petabit, petabitQuantity.Unit);

            var petabyteQuantity = bit.ToUnit(InformationUnit.Petabyte);

            AssertEx.EqualTolerance(PetabytesInOneBit, (decimal)petabyteQuantity.Value, PetabytesTolerance);
            Assert.Equal(InformationUnit.Petabyte, petabyteQuantity.Unit);

            var tebibitQuantity = bit.ToUnit(InformationUnit.Tebibit);

            AssertEx.EqualTolerance(TebibitsInOneBit, (decimal)tebibitQuantity.Value, TebibitsTolerance);
            Assert.Equal(InformationUnit.Tebibit, tebibitQuantity.Unit);

            var tebibyteQuantity = bit.ToUnit(InformationUnit.Tebibyte);

            AssertEx.EqualTolerance(TebibytesInOneBit, (decimal)tebibyteQuantity.Value, TebibytesTolerance);
            Assert.Equal(InformationUnit.Tebibyte, tebibyteQuantity.Unit);

            var terabitQuantity = bit.ToUnit(InformationUnit.Terabit);

            AssertEx.EqualTolerance(TerabitsInOneBit, (decimal)terabitQuantity.Value, TerabitsTolerance);
            Assert.Equal(InformationUnit.Terabit, terabitQuantity.Unit);

            var terabyteQuantity = bit.ToUnit(InformationUnit.Terabyte);

            AssertEx.EqualTolerance(TerabytesInOneBit, (decimal)terabyteQuantity.Value, TerabytesTolerance);
            Assert.Equal(InformationUnit.Terabyte, terabyteQuantity.Unit);
        }