private void CommandAddContact(Connection Connection, Data dato)
        {
            string[] payloadSplitted = dato.Payload.Message.Split('|');
            string   login           = payloadSplitted[0];
            string   contactToAdd    = payloadSplitted[1];

            bool ok = UsersContactsPersistenceHandler.GetInstance().AddContact(login, contactToAdd);

            string statusMessage = ok ? "SUCCESS" : "ERROR";
            string message       = contactToAdd + STATUS_DELIMITER + "0" + CONTACT_DELIMITER + statusMessage;

            Data retDato = new Data()
            {
                Command = Command.RES,
                OpCode  = OpCodeConstants.RES_ADD_CONTACT,
                Payload = new MultiplePayload()
                {
                    Message = message, Destination = login
                }
            };

            foreach (var item in retDato.GetBytes())
            {
                Console.WriteLine("Envio :{0}", ConversionUtil.GetString(item));
                Connection.WriteToStream(item);
            }
        }
Exemple #2
0
        private static object GetValueFromJson(string type, JToken value)
        {
            //TODO: review.
            if (null == value)
            {
                return(null);
            }
            if (value.Type != JTokenType.Array)
            {
                var stValue = value.ToString();
                if (stValue == "")
                {
                    return(value.Type == JTokenType.Null ? null : value.ToString());
                }
                if (stValue == "$null$ignorewatch")
                {
                    return(null);
                }

                return(ConversionUtil.ConvertFromMetadataType(type, stValue));
            }
            var array = value.ToObject <Object[]>();

            for (var i = 0; i < array.Length; i++)
            {
                if (array[i] != null)
                {
                    array[i] = ConversionUtil.ConvertFromMetadataType(type, array[i].ToString());
                }
            }

            return(array);
        }
Exemple #3
0
        private void BuildLanguage(Dictionary <string, LanguageTable> tables, bool build)
        {
            string allLanguages = ConversionUtil.GetConfig(ConfigKey.AllLanguage, ConfigFile.LanguageConfig);
            //string languageDirectory = ConversionUtil.GetPath(ConversionUtil.GetConfig(ConfigKey.LanguageDirectory, ConfigFile.LanguageConfig));
            string          languageDirectory = ConversionUtil.GetPath(textTableFolder.Text);
            LanguageBuilder builder           = new LanguageBuilder(
                allLanguages,
                languageDirectory,
                ConversionUtil.GetPath(ConversionUtil.GetConfig(ConfigKey.TranslationDirectory, ConfigFile.LanguageConfig)),
                tables);
            bool success = build ? builder.Build() : builder.RefreshLanguage();

            if (success)
            {
                string[]      languages     = builder.GetLanguages();
                List <string> languageFiles = new List <string>();
                foreach (var language in languages)
                {
                    languageFiles.Add(languageDirectory + "/Language_" + language + ".xls");
                }
                new TableBuilder().Transform(string.Join(";", languageFiles.ToArray()),
                                             textTableConfig.Text,
                                             textBoxPackage.Text,
                                             ConversionUtil.GetConfig(ConfigKey.SpawnList, ConfigFile.InitConfig),
                                             false,
                                             Extends.GetChecked(refreshNote),
                                             ConversionUtil.GetProgramConfig());
            }
        }
        public void GetAltitudeUnit_Test()
        {
            // arrange
            var values = new List <(string locale, string result, Type exceptionType)>
            {
                ("", "", typeof(ArgumentException)),
                ("de", "", typeof(ArgumentException)),
                ("de-DE", "m", null),
                ("en-US", "ft", null),
                ("en-GB", "m", null)
            };

            // act && assert
            values.ForEach(
                v =>
            {
                if (v.exceptionType != null)
                {
                    NAssert.Throws(v.exceptionType, () => ConversionUtil.GetAltitudeUnit(v.locale), "Expected exception not thrown.");
                    return;
                }
                var result = ConversionUtil.GetAltitudeUnit(v.locale);
                Assert.AreEqual(v.result, result, "Resulting text does not match.");
            });
        }
Exemple #5
0
        /// <summary>
        ///     Decodes an input byte stream into seperate values.
        ///     If input is not emptied or set to null, it will be appended with future data
        /// </summary>
        /// <param name="input">The input byte array to convert</param>
        /// <returns>A series of doubles representing the decoded data</returns>
        public override DataPacket DecodeData(ref byte[] input)
        {
            // Only decode when possible
            if (input.Length < DataSize)
            {
                return(null);
            }

            // Take out everything possible from the input
            var pieceCount = input.Length / DataSize;
            var toReturn   = new DataPacket();

            toReturn.AddChannel();
            for (var k = 0; k < pieceCount; k++)
            {
                toReturn[0].Add(ConversionUtil.BytesToDouble(input, k * DataSize, DataSize, Signed, LittleEndianMode));
            }

            // Set the input to the correct sub-buffer
            var fullSize = pieceCount * DataSize;

            if (fullSize == input.Length)
            {
                input = null;
            }
            else
            {
                var temp = new byte[input.Length - fullSize];
                Buffer.BlockCopy(input, fullSize, temp, 0, temp.Length);
            }

            return(toReturn);
        }
        private void CommandGetContactList(Connection Connection, Data dato)
        {
            string        login    = dato.Payload.Message;
            List <string> contacts = UsersContactsPersistenceHandler.GetInstance().GetContacts(login);

            StringBuilder message = new StringBuilder();
            bool          first   = true;

            foreach (var item in contacts)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    message.Append(CONTACT_DELIMITER);
                }
                message.Append(item).Append(STATUS_DELIMITER).Append("0");
            }
            Data retDato = new Data()
            {
                Command = Command.RES, OpCode = OpCodeConstants.RES_CONTACT_LIST, Payload = new MultiplePayload()
                {
                    Message = message.ToString(), Destination = login
                }
            };

            foreach (var item in retDato.GetBytes())
            {
                Console.WriteLine("Envio :{0}", ConversionUtil.GetString(item));
                Connection.WriteToStream(item);
            }
            Console.WriteLine("termina :CommandGetContactList");
        }
Exemple #7
0
        protected void SetupInsertBindVariables(object bean)
        {
            ArrayList varList     = new ArrayList();
            ArrayList varTypeList = new ArrayList();

            for (int i = 0; i < _propertyTypes.Length; ++i)
            {
                IPropertyType pt = _propertyTypes[i];
                if (string.Compare(pt.PropertyName, BeanMetaData.TimestampPropertyName, true) == 0)
                {
                    Timestamp = DateTime.Now;
                    SetupTimestampVariableList(varList, pt);
                }
                else if (pt.PropertyName.Equals(BeanMetaData.VersionNoPropertyName))
                {
                    VersionNo = 0;
                    varList.Add(ConversionUtil.ConvertTargetType(VersionNo, pt.PropertyInfo.PropertyType));
                }
                else
                {
                    varList.Add(pt.PropertyInfo.GetValue(bean, null));
                }
                varTypeList.Add(pt.PropertyInfo.PropertyType);
            }
            BindVariables     = varList.ToArray();
            BindVariableTypes = (Type[])varTypeList.ToArray(typeof(Type));
        }
Exemple #8
0
        public void SetupConn()  // Setup connection and login
        {
            connection = new Connection("DNS", new TcpClient(DNSServer, DNSPort), new ReceiveEventHandler(), delegado);


            string payload = Settings.GetInstance().GetProperty("server.name", "rodrigo-nb")
                             + ":" + Settings.GetInstance().GetProperty("server.ip", "127.0.0.1")
                             + ":" + Settings.GetInstance().GetProperty("server.port", "2001")
                             + ":" + Settings.GetInstance().GetProperty("server.transfers.port", "20001")
                             + ":" + UsersContactsPersistenceHandler.GetInstance().Count;

            Data data = new Data()
            {
                Command = Command.REQ,
                OpCode  = 3,//REQ_SERVER_CONNECT
                Payload = new Payload(payload)
            };

            int cont = 0;

            foreach (var item in data.GetBytes())
            {
                Console.WriteLine("line " + cont++ + "   --->" + ConversionUtil.GetString(item));
                log.Info("Enviando linea " + cont++ + "   --->" + ConversionUtil.GetString(item));
                connection.WriteToStream(item);
            }

            log.Info("End Register Server");
        }
Exemple #9
0
 public FormMain()
 {
     InitializeComponent();
     FormClosing    += (sender, e) => { this.Visible = false; e.Cancel = true; };
     VisibleChanged += (sender, e) => { ConversionUtil.CheckExit(); };
     UpdateUtil.Init(this);
 }
Exemple #10
0
 public static T SetConstantValues <T>(T integrationObject, EntityMetadata metadata)
 {
     if (metadata.Targetschema == null)
     {
         return(integrationObject);
     }
     foreach (var constValue in metadata.Targetschema.ConstValues)
     {
         var    key         = constValue.Key;
         var    splitted    = key.Split('/');
         object objectToUse = integrationObject;
         for (var i = 0; i < splitted.Count(); i++)
         {
             var propertyName = splitted[i];
             if (i != splitted.Count() - 1)
             {
                 objectToUse = ReflectionUtil.InstantiateAndSetIfNull(objectToUse, propertyName);
             }
             else
             {
                 WsUtil.SetValueIfNull(objectToUse, propertyName, ConversionUtil.ConvertFromMetadataType(constValue.Type, constValue.Value));
                 //                        ReflectionUtil.SetProperty(objectToUse, propertyName, constValue.Value);
             }
         }
     }
     return(integrationObject);
 }
Exemple #11
0
    /// <summary>
    /// 位置を同期する
    /// </summary>
    private void SyncPosition()
    {
        if (!_isServer && !_hasConnected)
        {
            return;
        }

        if (!_hasAuthorized)
        {
            return;
        }

        byte[] x = ConversionUtil.ToBytes(_target.position.x);
        byte[] y = ConversionUtil.ToBytes(_target.position.y);
        byte[] z = ConversionUtil.ToBytes(_target.position.z);

        byte[] pos = ConversionUtil.Serialize(x, y, z);

        if (_isServer)
        {
            for (int i = 0; i < _clientIds.Count; i++)
            {
                SendData(pos, _clientIds[i], pos.Length);
            }
        }
        else
        {
            SendData(pos, _connectionId, pos.Length);
        }
    }
        private void ReadPeriodPass(byte[] periodPassBytes)
        {
            // We'll be reusing these as temp holder variables
            ushort date1;
            ushort date2;

            //Read PERIOD PASS 1 data
            ProductCode1      = (ushort)(((periodPassBytes[0] & 0xFF) << 6) | ((periodPassBytes[1] & 0xFC) >> 2));
            ValidityAreaType1 = (byte)((periodPassBytes[1] & 0x02) >> 1);
            ValidityArea1     = (byte)(((periodPassBytes[1] & 0x01) << 3) | ((periodPassBytes[2] & 0xE0) >> 5));

            date1            = (ushort)(((periodPassBytes[2] & 0x1F) << 9) | ((periodPassBytes[3] & 0xFF) << 1) | ((periodPassBytes[4] & 0x80) >> 7));
            PeriodStartDate1 = ConversionUtil.FromEn1545Date(date1);

            date2          = (ushort)(((periodPassBytes[4] & 0x7F) << 7) | ((periodPassBytes[5] & 0xFE) >> 1));
            PeriodEndDate1 = ConversionUtil.FromEn1545Date(date2);
            //Add a day minus a single tick to get us to the VERY end of the given day. (Note, this only works because the PeriodEndDate explicitly has a time of 00:00)
            PeriodEndDate1.Add(TimeSpan.FromDays(1)).Add(TimeSpan.FromTicks(-1));
            //store period length
            PeriodLength1 = (ushort)(date2 - date1 + 1);

            //Read PERIOD PASS 2 data
            ProductCode2      = (ushort)(((periodPassBytes[6] & 0xFF) << 8) | (periodPassBytes[7] & 0xFC));
            ProductCode2    >>= 2;
            ValidityAreaType2 = (byte)(periodPassBytes[7] & 0x02);
            ValidityArea2     = (byte)(((periodPassBytes[7] & 0x01) << 3) | ((periodPassBytes[8] & 0xE0) >> 5));

            date1            = (ushort)(((periodPassBytes[8] & 0x1F) << 9) | ((periodPassBytes[9] & 0xFF) << 1) | ((periodPassBytes[10] & 0x80) >> 7));
            PeriodStartDate2 = ConversionUtil.FromEn1545Date(date1);

            date2          = (ushort)(((periodPassBytes[10] & 0x7F) << 7) | ((periodPassBytes[11] & 0xFE) >> 1));
            PeriodEndDate2 = ConversionUtil.FromEn1545Date(date2);
            //Add a day minus a single tick to get us to the VERY end of the given day. (Note, this only works because the PeriodEndDate explicitly has a time of 00:00)
            PeriodEndDate2.Add(TimeSpan.FromDays(1)).Add(TimeSpan.FromTicks(-1));

            //store period length
            PeriodLength2 = (ushort)(date2 - date1 + 1);

            //LAST LOADING
            LoadedPeriodProduct = (ushort)(((periodPassBytes[12] & 0xFF) << 6) | ((periodPassBytes[13] & 0xFC) >> 2));
            date1 = (ushort)(((periodPassBytes[13] & 0x03) << 12) | ((periodPassBytes[14] & 0xFF) << 4) | ((periodPassBytes[15] & 0xF0) >> 4));
            ushort time1 = (ushort)(((periodPassBytes[15] & 0x0F) << 7) | ((periodPassBytes[16] & 0xFE) >> 1));

            PeriodLoadingDate         = ConversionUtil.FromEn1545DateAndTime(date1, time1);
            LoadedPeriodLength        = (ushort)(((periodPassBytes[16] & 0x01) << 8) | (periodPassBytes[17] & 0xFF));
            LoadedPeriodPrice         = (uint)(periodPassBytes[18] & 0xFF) << 12 | ((uint)(periodPassBytes[19] & 0xFF) << 4) | (uint)(periodPassBytes[20] & 0xF0) >> 4;
            PeriodLoadingOrganisation = (ushort)(((periodPassBytes[20] & 0x0F) << 10) | ((periodPassBytes[21] & 0xFF) << 2) | ((periodPassBytes[22] & 0xC0) >> 6));
            PeriodLoadingDeviceNumber = (ushort)(((periodPassBytes[22] & 0x3F) << 8) | (periodPassBytes[23] & 0xFF));

            //LAST USE (BOARDING DATA)
            date1                   = (ushort)(((periodPassBytes[24] & 0xFF) << 6) | ((periodPassBytes[25] & 0xFC) >> 2));
            time1                   = (ushort)(((periodPassBytes[25] & 0x03) << 9) | ((periodPassBytes[26] & 0xFF) << 1) | ((periodPassBytes[27] & 0x80) >> 7));
            BoardingDate            = ConversionUtil.FromEn1545DateAndTime(date1, time1);
            BoardingVehicle         = (ushort)(((periodPassBytes[27] & 0x7F) << 7) | (periodPassBytes[28] & 0xFE) >> 1);
            BoardingLocationNumType = (byte)(((periodPassBytes[28] & 0x01) << 1) | ((periodPassBytes[29] & 0x80) >> 7));
            BoardingLocationNum     = (ushort)(((periodPassBytes[29] & 0x7F) << 7) | ((periodPassBytes[30] & 0xFE) >> 1));
            BoardingDirection       = (byte)(periodPassBytes[30] & 0x01);
            BoardingArea            = (byte)((periodPassBytes[31] & 0xF0) >> 4);
        }
Exemple #13
0
        protected void SetupVersionNoValiableList(IList varList, IPropertyType pt, object bean)
        {
            object value    = pt.PropertyInfo.GetValue(bean, null);
            int    intValue = Convert.ToInt32(value) + 1;

            VersionNo = intValue;
            varList.Add(ConversionUtil.ConvertTargetType(VersionNo, pt.PropertyInfo.PropertyType));
        }
Exemple #14
0
    /// <summary>
    /// データ配列からpositionをパースする
    /// </summary>
    /// <param name="data">データ配列</param>
    /// <returns>パースしたVector3の位置データ</returns>
    private Vector3 Parse(byte[] data)
    {
        float x = ConversionUtil.Deserialize(data, 0, 4);
        float y = ConversionUtil.Deserialize(data, 4, 8);
        float z = ConversionUtil.Deserialize(data, 8, 12);

        return(new Vector3(x, y, z));
    }
 public void SetProgram(PROGRAM program)
 {
     m_Program = program;
     ConversionUtil.Bind(CodePath, m_Program, ConfigKey.CodeDirectory, ConfigFile.PathConfig);
     ConversionUtil.Bind(DataPath, m_Program, ConfigKey.DataDirectory, ConfigFile.PathConfig);
     ConversionUtil.Bind(CheckCreate, m_Program, ConfigKey.Create, ConfigFile.PathConfig);
     ConversionUtil.Bind(CheckCompress, m_Program, ConfigKey.Compress, ConfigFile.PathConfig);
     SetProgram_impl();
 }
 public bool?GetValueAsBoolean()
 {
     if (IsSelected)
     {
         var rawValue = Selection.Value;
         return(ConversionUtil.ConvertBooleanMultiCulture(rawValue));
     }
     return(null);
 }
 public bool TryGetValueAsDouble(out double value)
 {
     if (IsSelected)
     {
         var rawValue = Selection.Value;
         return(ConversionUtil.TryConvertDoubleMultiCulture(rawValue, out value));
     }
     value = default(double);
     return(false);
 }
        private void ReadApplicationInfo(byte[] appInfoBytes)
        {
            ApplicationVersion = (byte)(appInfoBytes[0] & 0xF0);

            //Card number
            byte[] temp = new byte[9];
            Array.Copy(appInfoBytes, 1, temp, 0, 9);
            ApplicationInstanceId = ConversionUtil.GetHexString(temp);

            PlatformType = (byte)(appInfoBytes[10] & 0xE0);
        }
Exemple #19
0
        static void Main(string[] args)
        {
            Data data = new Data();

            data.OpCode  = (int)OpCode.HELLO;
            data.Command = Command.REQ;
            data.Payload = new Payload("Hola soy Cli 1");


            List <char[]> lista = data.GetBytes();

            foreach (var item in lista)
            {
                Console.WriteLine(ConversionUtil.GetString(item));
            }
            Console.WriteLine("Done Payload");


            data         = new Data();
            data.OpCode  = (int)OpCode.HELLO;
            data.Command = Command.REQ;
            data.Payload = new MultiplePayload()
            {
                Destination = "rodrigo"
            };

            for (int i = 0; i < MultiplePayload.MAX_PAYLOAD_LENGTH; i++)
            {
                ((MultiplePayload)data.Payload).Message += "A";
            }


            lista = data.GetBytes();
            foreach (var item in lista)
            {
                Console.WriteLine(ConversionUtil.GetString(item));
            }
            Console.WriteLine("Done Multiple Payload");



            Console.WriteLine("|" + Settings.GetInstance().GetProperty("REQ01") + "|");
            Console.WriteLine("Done reading property");



            Consola();



            Console.WriteLine("Done");
            Console.ReadLine();
        }
Exemple #20
0
        public RawETicket(byte[] eTicketData, Boolean isSingleTicket)
        {
            ProductCode        = (ushort)((ushort)((eTicketData[0] & 0xFF) << 6) | ((eTicketData[1] & 0xFC) >> 2));
            Child              = (byte)((eTicketData[1] & 0x02) >> 1);
            LanguageCode       = (byte)(((eTicketData[1] & 0x01) << 1) | ((eTicketData[2] & 0x80) >> 7));
            ValidityLengthType = (byte)((eTicketData[2] & 0x60) >> 5);
            ValidityLength     = (byte)(((eTicketData[2] & 0x1F) << 3) | ((eTicketData[3] & 0xE0) >> 5));
            ValidityAreaType   = (byte)((eTicketData[3] & 0x10) >> 4);
            ValidityArea       = (byte)(eTicketData[3] & 0x0F);

            ushort date1 = (ushort)(((eTicketData[4] & 0xFF) << 6) | ((eTicketData[5] & 0xFC) >> 2));

            SaleDate  = ConversionUtil.FromEn1545Date(date1).UtcDateTime;
            SaleTime  = (byte)(((eTicketData[5] & 0x03) << 3) | ((eTicketData[6] & 0xE0) >> 5));
            GroupSize = (byte)((eTicketData[10] & 0x3E) >> 1);
            //sale status is relevant only in value tickets on desfire cards
            SaleStatus = (byte)(eTicketData[10] & 0x01);

            int count = 0;

            //if we're reading separate eTicket (single ticket) skip over some data
            if (isSingleTicket)
            {
                count = 6;
            }

            //read validity start datestamp
            date1 = (ushort)(((eTicketData[11 + count] & 0xFF) << 6) | ((eTicketData[12 + count] & 0xFC) >> 2));
            //read validity start timestamp
            ushort time1 = (ushort)(((eTicketData[12 + count] & 0x03) << 9) | ((eTicketData[13 + count] & 0xFF) << 1) | ((eTicketData[14 + count] & 0x80) >> 7));

            ValidityStartDate = ConversionUtil.FromEn1545DateAndTime(date1, time1);

            //read validity end datestamp
            date1 = (ushort)(((eTicketData[14 + count] & 0x7F) << 7) | ((eTicketData[15 + count] & 0xFF) >> 1));
            //read validity end timestamp
            time1           = (ushort)(((eTicketData[15 + count] & 0x01) << 10) | ((eTicketData[16 + count] & 0xFF) << 2) | ((eTicketData[17 + count] & 0xC0) >> 6));
            ValidityEndDate = ConversionUtil.FromEn1545DateAndTime(date1, time1);

            //validity status is relevant only in value tickets on desfire cards
            ValidityStatus = (byte)(eTicketData[17 + count] & 0x01);

            //LAST USE (BOARDING)

            date1                   = (ushort)(((eTicketData[18 + count] & 0xFF) << 6) | ((eTicketData[19 + count] & 0xFC) >> 2));
            time1                   = (ushort)(((eTicketData[19 + count] & 0x03) << 9) | ((eTicketData[20 + count] & 0xFF) << 1) | ((eTicketData[21 + count] & 0x80) >> 7));
            BoardingDate            = ConversionUtil.FromEn1545DateAndTime(date1, time1);
            BoardingVehicle         = (ushort)(((eTicketData[21 + count] & 0x7F) << 7) | (eTicketData[22 + count] & 0xFE) >> 1);
            BoardingLocationNumType = (byte)(((eTicketData[22 + count] & 0x01) << 1) | ((eTicketData[23 + count] & 0x80) >> 7));
            BoardingLocationNum     = (ushort)(((eTicketData[23 + count] & 0x7F) << 7) | ((eTicketData[24 + count] & 0xFE) >> 1));
            BoardingDirection       = (byte)(eTicketData[24 + count] & 0x01);
            BoardingArea            = (byte)((eTicketData[25 + count] & 0xF0) >> 4);
        }
Exemple #21
0
 private void buttonDatabase_Click(object sender, EventArgs e)
 {
     StartRun(() => {
         if (string.IsNullOrEmpty(textDatabaseConfig.Text))
         {
             return;
         }
         new DatabaseBuilder().Transform(ConversionUtil.GetPath(textDatabaseConfig.Text),
                                         textBoxPackage.Text,
                                         ConversionUtil.GetProgramConfig());
     });
 }
Exemple #22
0
 private void buttonTransform_Click(object sender, EventArgs e)
 {
     StartRun(() => {
         new TableBuilder().Transform(this.textTransformFiles.Text,
                                      ConversionUtil.GetPath(textTableConfig.Text),
                                      textBoxPackage.Text,
                                      ConversionUtil.GetConfig(ConfigKey.SpawnList, ConfigFile.InitConfig),
                                      Extends.GetChecked(getManager),
                                      Extends.GetChecked(refreshNote),
                                      ConversionUtil.GetProgramConfig());
     });
 }
Exemple #23
0
        public ActionResult DeleteComment(Guid reportGuid, DiscussionTargetType targetType, Guid targetGuid, Guid commentGuid, string authorHash)
        {
            // company admins can delete any comment for their company.
            // non admins can only delete their own comments
            var deletionAuthorised = false;

            var discussion = _discussionManager.Get(reportGuid, targetType, targetGuid);
            var comment    = discussion.Comments.SingleOrDefault(c => c.UniqueId == commentGuid);

            if (Request.IsAuthenticated)
            {
                InitializeContext();
                if (discussion.CompanyId == CurrentUser.CompanyId && CurrentUser.IsCompanyAdmin)
                {
                    deletionAuthorised = true;
                }
            }

            if (!deletionAuthorised)
            {
                // let's see if the comment is made by the person trying to delete it

                if (authorHash == ConversionUtil.CommentToHashString(comment))
                {
                    deletionAuthorised = true;
                }
            }

            if (deletionAuthorised)
            {
                discussion.Comments.Remove(comment);
                _discussionManager.DeleteComment(comment);

                try
                {
                    // update others
                    GlobalHost.ConnectionManager.GetHubContext <DiscussionHub>()
                    .Clients.Group(discussion.DiscussionName)
                    .removeComment(discussion.DiscussionName, commentGuid, discussion.CommentCount);
                }
                catch (Exception exception)
                {
                    ErrorStore.LogException(exception, System.Web.HttpContext.Current);
                }
            }
            else
            {
                throw new HttpException(401, "Unauthorized");
            }

            return(Json(new { success = true, commentGuid, commentCount = discussion.CommentCount }));
        }
 public double?GetValueAsDouble()
 {
     if (IsSelected)
     {
         var    rawValue = Selection.Value;
         double value;
         if (ConversionUtil.TryConvertDoubleMultiCulture(rawValue, out value))
         {
             return(value);
         }
     }
     return(null);
 }
        private void ReadStoredValues(byte[] storedValueBytes)
        {
            //Value
            ValueCounter = (uint)(((storedValueBytes[0] & 0xFF) << 12) | ((storedValueBytes[1] & 0xFF) << 4) | ((storedValueBytes[2] & 0xF0) >> 4));
            //Last value loading
            ushort date1 = (ushort)(((storedValueBytes[2] & 0x0F) << 10) | ((storedValueBytes[3] & 0xFF) << 2) | ((storedValueBytes[4] & 0xC0) >> 6));
            ushort time1 = (ushort)(((storedValueBytes[4] & 0x3F) << 5) | ((storedValueBytes[5] & 0xF8) >> 3));

            LoadingDate           = ConversionUtil.FromEn1545DateAndTime(date1, time1);
            LoadedValue           = (uint)(((storedValueBytes[5] & 0x07) << 17) | ((storedValueBytes[6] & 0xFF) << 9) | ((storedValueBytes[7] & 0xFF) << 1) | ((storedValueBytes[8] & 0x80) >> 7));
            LoadingOrganisationID = (ushort)(((storedValueBytes[8] & 0x7F) << 4) | ((storedValueBytes[9] & 0xFE) >> 1));
            LoadingDeviceNumber   = (ushort)(((storedValueBytes[9] & 0x01) << 13) | ((storedValueBytes[10] & 0xFF) << 5) | ((storedValueBytes[11] & 0xF8) >> 3));
        }
Exemple #26
0
        public void ConversionUtilConvertsEnumValues()
        {
            // Arrange
            string original = "Weekday";

            // Act
            object result;
            bool   success = ConversionUtil.TryFromString(typeof(TestEnum), original, out result);

            // Assert
            Assert.True(success);
            Assert.Equal(TestEnum.Weekday, result);
        }
Exemple #27
0
        public void ConversionUtilConvertsStringsToColor()
        {
            // Arrange
            string original = "Blue";

            // Act
            object result;
            bool   success = ConversionUtil.TryFromString(typeof(Color), original, out result);

            // Assert
            Assert.True(success);
            Assert.Equal(Color.Blue, result);
        }
Exemple #28
0
        public void ConversionUtilReturnsStringTypes()
        {
            // Arrange
            string original = "Foo";

            // Act
            object result;
            bool   success = ConversionUtil.TryFromString(typeof(String), original, out result);

            // Assert
            Assert.True(success);
            Assert.Equal(original, result);
        }
Exemple #29
0
 public void SaveDisplayOrder(int companyId, IList <EntityDisplayOrder> displayOrders)
 {
     try
     {
         var orderData = ConversionUtil.EntityDisplayOrderToDataTable(displayOrders);
         OpenConnection();
         Connection.Execute("MetricsSaveOrder", new { companyId = companyId, OrderData = orderData }, commandType: CommandType.StoredProcedure);
     }
     finally
     {
         CloseConnection();
     }
 }
Exemple #30
0
        /// <summary>
        /// Initializes a new mongo repository configuration
        /// </summary>
        /// <param name="connectionString">The connection string</param>
        public MongoRepositoryConfig(string connectionString)
        {
            Condition.Requires(connectionString, "connectionString").IsNotNullOrWhiteSpace();
            this.ConnectionString = connectionString;

            // Init properties
            var queryString     = new Uri(connectionString).Query;
            var queryDictionary = System.Web.HttpUtility.ParseQueryString(queryString);

            this.VirtualCollectionDefault     = queryDictionary["virtualCollection"];
            this.VirtualCollectionEnabled     = ConversionUtil.Bool(queryDictionary["virtual"]);
            this.VirtualCollectionForceGlobal = ConversionUtil.Bool(queryDictionary["virtualCollectionGlobal"]);
        }