Ejemplo n.º 1
0
        public override bool ReadData(ReadBuffer reader)
        {
            // TODO; validate status
            var operationStatus = (OperationStatus)reader.ReadInt32();
            var systemTime      = reader.ReadInt64();
            var dataLenght      = reader.ReadInt32();
            var bodyData        = new byte[dataLenght];

            int readOffset;

            reader.ReserveForReading(dataLenght, out readOffset);

            unsafe
            {
                var buffer = reader.GetBuffer();
                fixed(byte *bodyDataPtr = bodyData)
                fixed(byte *bufferPtr = buffer)
                {
                    DataManipulation.Copy(bufferPtr + readOffset, bodyDataPtr, (uint)dataLenght);
                }
            }
            BodyFrame = BodyFrame.Parse(bodyData, TimeSpan.FromTicks(systemTime));

            return(true);
        }
        public dynamic GetProviderInfo(string data)
        {
            try
            {
                //    if (data == null)
                //    {
                //        data = "\"0\"";
                //    }
                //string jsonData = "{\"CusCategoryId\":" + data + "}";
                string  url  = ConfigurationManager.AppSettings["mTaka_server"] + "/api/UsbReceive/GetUsbParam";
                dynamic json = DataManipulation.SetObject(url, data);
                return(json);
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }

            //try
            //{
            //    string url = ConfigurationManager.AppSettings["mTaka_server"] + "/api/CusType/CusTypeForCusCategory";
            //    dynamic json = DataManipulation.SetObject(url, data);
            //    return json;
            //}
            //catch (Exception ex)
            //{
            //    return Json(ex.Message, JsonRequestBehavior.AllowGet);
            //}
        }
        public void ShouldResolveUpdateStatement()
        {
            //Arrange
            string rawTsql = "update someFactTable " +
                             "set somecolumn = nil.col_01, someOtherColumn = [dbo].gl.col_02 " +
                             "from DWH_DB.[dbo].[someFactTable]";

            IDataManipulationResolver resolver = new UpdateStatementResolver();
            int                      fileIndex = 0;
            CompilerContext          context   = new CompilerContext("xUnit", "stdserver", "stdDatabase", true);
            ReadOnlySpan <TSQLToken> tokens    = TSQLTokenizer.ParseTokens(rawTsql).ToArray();

            //Act
            DataManipulation statement = resolver.Resolve(tokens, ref fileIndex, context);

            //Assert
            Assert.Equal(tokens.Length, fileIndex);
            Assert.Equal(2, statement.Expressions.Count);
            Assert.Equal(ExpressionType.COLUMN, statement.Expressions[0].Type);
            Assert.Equal("DWH_DB.dbo.someFactTable.somecolumn", statement.Expressions[0].Name);
            Assert.Equal("stdDatabase.unrelated.nil.col_01", statement.Expressions[0].ChildExpressions[0].Name);
            Assert.Equal(ExpressionType.COLUMN, statement.Expressions[1].Type);
            Assert.Equal("DWH_DB.dbo.someFactTable.someOtherColumn", statement.Expressions[1].Name);
            Assert.Equal("stdDatabase.dbo.gl.col_02", statement.Expressions[1].ChildExpressions[0].Name);
        }
        public void ShouldResolveUpdateStatementWithAliasTarget()
        {
            //Arrange
            string rawTsql = "update GL " +
                             "set somevalue = nil.col_01, someOtherValue = gl.col_02 " +
                             "from [SOME_table] nil " +
                             "inner join [dbo].[TABLE_02] GL";

            IDataManipulationResolver resolver = new UpdateStatementResolver();
            int                      fileIndex = 0;
            CompilerContext          context   = new CompilerContext("xUnit", "stdserver", "stdDatabase", true);
            ReadOnlySpan <TSQLToken> tokens    = TSQLTokenizer.ParseTokens(rawTsql).ToArray();

            //Act
            DataManipulation statement = resolver.Resolve(tokens, ref fileIndex, context);

            //Assert
            Assert.Equal(tokens.Length, fileIndex);
            Assert.Equal(ExpressionType.COLUMN, statement.Expressions[0].Type);
            Assert.Equal("stdDatabase.dbo.TABLE_02.somevalue", statement.Expressions[0].Name);
            Assert.Equal("stdDatabase.unrelated.SOME_table.col_01", statement.Expressions[0].ChildExpressions[0].Name);
            Assert.Equal(ExpressionType.COLUMN, statement.Expressions[1].Type);
            Assert.Equal("stdDatabase.dbo.TABLE_02.someOtherValue", statement.Expressions[1].Name);
            Assert.Equal("stdDatabase.dbo.TABLE_02.col_02", statement.Expressions[1].ChildExpressions[0].Name);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// After the forward and backward pass, the weights must be updated. This is done in this function.
        /// </summary>
        /// <param name="pat">input pattern</param>
        /// <param name="dw">delta w, from last updates. Used to update weights1 after recalculation.</param>
        /// <param name="dv">delta v, from last updates. Used to update weights2 after recalculation.</param>
        private void weightUpdate(Matrix <float> pat, Matrix <float> dw, Matrix <float> dv, Matrix <float> targets)
        {
            /*
             *  % weight update, MATLAB code
             *  dw = (dw .* alpha) - (delta_h * pat') .* (1-alpha);
             *  dv = (dv .* alpha) - (delta_o * hout') .* (1-alpha);
             *  w = w + dw .* eta .* (1 + rand(1,1)/1000)';
             *  v = v + dv .* eta .* (1 + rand(1,1)/1000)';
             *
             *  error(epoch) = sum(sum(abs(sign(out) - targets)./2));
             */
            float alpha = 0.9f;
            float eta   = 0.1f;

            dw = (dw.Multiply(alpha)).Subtract((net_deltah.Multiply(pat.Transpose())).Multiply(1 - alpha));
            dv = (dv.Multiply(alpha)).Subtract((net_deltao.Multiply(net_hout.Transpose())).Multiply(1 - alpha));

            weights1 += dw.Multiply(eta).Multiply(1 + DataManipulation.rand(1, 1)[0, 0] / 1000f);
            weights2 += dv.Multiply(eta).Multiply(1 + DataManipulation.rand(1, 1)[0, 0] / 1000f);

            Matrix <float> e1 = (MatrixSign(net_out) - targets).Multiply(0.5f).Multiply(new DenseMatrix(net_out.ColumnCount, 1, 1.0f)).Transpose().Multiply(new DenseMatrix(net_out.RowCount, 1, 1.0f));
            double         e  = e1[0, 0];

            e = e;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 64B + 4B flag
        /// </summary>
        protected Matrix4x4?ReadTransformation(ReadBuffer reader)
        {
            var hasValue = reader.ReadInt32() == 1;

            // 4 * 4 * sizeof(float)
            int readOffset;

            reader.ReserveForReading(64, out readOffset);

            if (!hasValue)
            {
                return(null);
            }

            unsafe
            {
                var buffer = reader.GetBuffer();
                fixed(byte *bufferPtr = buffer)
                {
                    Matrix4x4 result;
                    byte *    resultMatrixPtr = (byte *)&result;

                    DataManipulation.Copy(bufferPtr + readOffset, resultMatrixPtr, 64);

                    return(result);
                }
            }
        }
        public string AddUser(UserData uData)
        {
            MySqlConnection connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["database"].ToString());

            try
            {
                connection.Open();
                string cmd = string.Format("INSERT INTO users(UserName, PasswordHash, DateCreated, DateModified) VALUES({0}, {1}, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP()); SELECT LAST_INSERT_ID();",
                                           DataManipulation.FormatForSql(uData.UserName),
                                           DataManipulation.FormatForSql(uData.PasswordHash));

                MySqlCommand command             = new MySqlCommand(cmd, connection);
                int          curUserId           = Convert.ToInt32(command.ExecuteScalar());
                Dictionary <string, string> resp = new Dictionary <string, string>();
                resp.Add("UserId", curUserId.ToString());
                return(JsonConvert.SerializeObject(resp));
            }
            catch (Exception e)
            {
                return(JsonConvert.SerializeObject(e));
            }
            finally
            {
                connection.Close();
            }
        }
Ejemplo n.º 8
0
        public dynamic CusTypeForAccCategory(string data)
        {
            try
            {
                if (data == null)
                {
                    data = "\"0\"";
                }
                string  jsonData = "{\"AccCategoryId\":" + data + "}";
                string  url      = ConfigurationManager.AppSettings["mTaka_server"] + "/api/CusTypeWiseServiceList/AccTypeForCusCategory";
                dynamic json     = DataManipulation.SetObject(url, jsonData);
                return(json);
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }

            //try
            //{
            //    string url = ConfigurationManager.AppSettings["mTaka_server"] + "/api/CusType/CusTypeForCusCategory";
            //    dynamic json = DataManipulation.SetObject(url, data);
            //    return json;
            //}
            //catch (Exception ex)
            //{
            //    return Json(ex.Message, JsonRequestBehavior.AllowGet);
            //}
        }
 private void ShowReceiptRecord_Load(object sender, EventArgs e)
 {
     if (type.Equals("OTHER"))
     {
         List <string> otherTypeRecord = DataManipulation.getOtherTypeReceiptRecord(receiptNumber);
         showSlipGridView.Rows.Add(1);
         showSlipGridView.Rows[0].Cells[0].Value = otherTypeRecord[0];
         showSlipGridView.Rows[0].Cells[1].Value = otherTypeRecord[1];
         showSlipGridView.Rows[0].Cells[2].Value = otherTypeRecord[2];
         showSlipGridView.Rows[0].Cells[3].Value = otherTypeRecord[3];
         showSlipGridView.Rows[0].Cells[4].Value = otherTypeRecord[4];
         showSlipGridView.Rows[0].Cells[5].Value = otherTypeRecord[5];
     }
     else
     {
         List <List <string> > studentTypeRecords = DataManipulation.getStudentTypeReceiptRecord(receiptNumber);
         if (studentTypeRecords.Count > 0)
         {
             showSlipGridView.Rows.Add(studentTypeRecords.Count);
             int row = 0;
             foreach (List <string> bookRecord in studentTypeRecords)
             {
                 int column = 0;
                 foreach (string record in bookRecord)
                 {
                     showSlipGridView.Rows[row].Cells[column].Value = record;
                     column++;
                 }
                 row++;
             }
         }
     }
 }
Ejemplo n.º 10
0
 public dynamic Edit(string data)
 {
     //try
     //{
     //    string a = data + "}";
     //    //string jsonData = @"{'AccTypeId':data,'AccTypeNm':'Individual','AccTypeShortNm':'In','AccCategoryId':'002','AccTypeParentAcc':'003'}";
     //    //string[] customJson = new string[] { "005", "Individual", "Ind" };
     //    string url = ConfigurationManager.AppSettings["mTaka_server"] + "/api/AccType/UpdateAccType";
     //    dynamic json = DataManipulation.SetObject(url, a);
     //    return json;
     //}
     //catch (Exception ex)
     //{
     //    return Json(ex.Message, JsonRequestBehavior.AllowGet);
     //}
     try
     {
         string  url  = ConfigurationManager.AppSettings["mTaka_server"] + "/api/AccType/UpdateAccType";
         dynamic json = DataManipulation.SetObject(url, data);
         return(json);
     }
     catch (Exception ex)
     {
         return(Json(ex.Message, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 11
0
        internal static int Update <TEntity, TResult>(this ITable table,
                                                      Expression <Func <TEntity, TResult> > entity,
                                                      Expression <Func <TEntity, bool> > predicate) where TEntity : class
        {
            var Context = table.Context;

            if (entity == null)
            {
                throw Error.ArgumentNull("entity");
            }
            var entityType = table.ElementType;
            var resutlType = typeof(object);

            var inheritanceType = Context.Mapping.GetMetaType(entityType);
            var inheritanceRoot = inheritanceType.InheritanceRoot;

            Expression <Func <int> > l = () => DataManipulation.Update <TEntity, TResult>(table, entity, predicate);
            var m = ((MethodCallExpression)l.Body).Method;
            //var exp = Expression.Call(typeof(DataManipulation), "Update", new[] { inheritanceRoot.Type, resutlType },
            //                          Expression.Constant(table), entity, predicate);
            var exp    = Expression.Call(m, Expression.Constant(table), entity, predicate);
            var result = (int)Context.Provider.Execute(exp).ReturnValue;

            return(result);
        }
Ejemplo n.º 12
0
        public void DataManipulation_ReturnComposites_ReturnsComposites(long c1, long p1, long c2, long p2, long p3)
        {
            // Arrange
            var testFactors = new LinkedList <IFactor>();

            testFactors.AddLast(new CompositeNumber(c1));
            testFactors.AddLast(new PrimeNumber(p1));
            testFactors.AddLast(new CompositeNumber(c2));
            testFactors.AddLast(new PrimeNumber(p2));
            testFactors.AddLast(new PrimeNumber(p3));

            // Act
            var testComposites = DataManipulation.ReturnComposites(testFactors);

            // Assert
            Assert.True(testComposites.Count == 2);

            long sum = 0;

            foreach (var factor in testComposites)
            {
                sum += factor.Value;
                Assert.True(factor.GetType() == typeof(CompositeNumber));
            }
            Assert.True(sum == c1 + c2);
        }
Ejemplo n.º 13
0
        public dynamic Logout()
        {
            string data    = string.Empty;
            var    session = System.Web.HttpContext.Current.Session["MTKSession"] as mTakaSession;

            if (session != null && session.CurrentUserId != null)
            {
                //dynamic DynamicBizObject = new System.Dynamic.ExpandoObject();
                //DynamicBizObject.UserId = Session["currentUserID"];
                //var data = new JavaScriptSerializer().Serialize(DynamicBizObject);

                data = Newtonsoft.Json.JsonConvert.SerializeObject(new { UserId = session.CurrentUserId });
            }
            else
            {
                Session.Clear();
                Session.Abandon();
                return("1");
            }

            string  url  = ConfigurationManager.AppSettings["mTaka_server"] + "/api/SignIn/Logout";
            dynamic json = DataManipulation.SetObject(url, data);

            if (json == "1")
            {
                //Session["currentUserID"] = null; //it's my session variable
                Session.Clear();
                Session.Abandon();
                //FormsAuthentication.SignOut(); //you write this when you use FormsAuthentication
            }
            return(json);
        }
Ejemplo n.º 14
0
 public EncryptString(String messageValue)
 {
     message    = messageValue;
     bytes      = DataManipulation.convertStringToBytes(message);
     binaryList = DataManipulation.convertByteListToBinaryList(bytes, byteSize);
     bitList    = DataManipulation.convertBinaryListToBitList(binaryList);
 }
Ejemplo n.º 15
0
 public void TestMethodCanProcessDepretiatin()
 {
     Assert.IsFalse(DataManipulation.CanProcessDepretiatin(new DateTime(2017, 1, 1), new DateTime(2017, 1, 1)));
     Assert.IsFalse(DataManipulation.CanProcessDepretiatin(new DateTime(2017, 2, 1), new DateTime(2017, 1, 1)));
     Assert.IsTrue(DataManipulation.CanProcessDepretiatin(new DateTime(2016, 2, 1), new DateTime(2017, 3, 1)));
     Assert.IsFalse(DataManipulation.CanProcessDepretiatin(new DateTime(2017, 8, 1), new DateTime(2016, 3, 1)));
     Assert.IsTrue(DataManipulation.CanProcessDepretiatin(new DateTime(2017, 8, 1), new DateTime(2017, 9, 1)));
 }
Ejemplo n.º 16
0
        private bool parseCamFile(string camFile)
        {
            fileInfo = new FileInfo(camFile);

            camData = new CamData[DataManipulation.getNumberOfFrames(fileInfo)];

            return(DataManipulation.parse(fileInfo, ref camData));
        }
Ejemplo n.º 17
0
 public MyDataSet(ApplicationDbContext db)
 {
     MonthNames          = DataManipulation.GetMonthNames(db);
     DepreciationTypes   = DataManipulation.GetDepreciationTypes(db);
     AssetList           = DataManipulation.GetAssetList(db);
     DepreciationCharges = DataManipulation.GetDepreciationCharges(db);
     AssetTypes          = DataManipulation.GetAssetTypes(db);
 }
Ejemplo n.º 18
0
 private void Form1_Load(object sender, EventArgs e)
 {
     Map();
     DataManipulation.GetListOfStates();
     DataManipulation.GetListOfSentiments();
     update();
     label1.Text = "Ready!";
 }
Ejemplo n.º 19
0
        public override bool WriteData(WriteBuffer writer)
        {
            if (_init)
            {
                _dataCapacity = Bitmap.PixelWidth * Bitmap.PixelHeight * 2;

                writer.Write((int)OperationCode.DepthFrameTransfer);
                writer.Write((int)OperationStatus.PushInit);
                writer.Write((int)Bitmap.BitmapPixelFormat);
                writer.Write(Bitmap.PixelWidth);
                writer.Write(Bitmap.PixelHeight);
                writer.Write(_dataCapacity);

                // camera intrinsics
                WriteIntrinsics(writer, CameraIntrinsics);

                // write transformation
                WriteTransformation(writer, DepthToColorTransform);
                _init = false;

                return(false);
            }

            writer.Write((int)OperationCode.DepthFrameTransfer);
            writer.Write((int)OperationStatus.Push);

            // just for check?
            writer.Write(_offset);

            // todo configurable chunks size support
            // account for 4 bytes taken by chunkSize info!!
            var dataChunkSize = Math.Min(_dataCapacity - _offset, writer.RemainingPacketWriteCapacity - 4);

            writer.Write(dataChunkSize);

            int writeOffset;

            writer.ReserveForWrite(dataChunkSize, out writeOffset);

            unsafe
            {
                using (var bitBuffer = Bitmap.LockBuffer(BitmapBufferAccessMode.Read))
                    using (var bufferRef = bitBuffer.CreateReference())
                    {
                        byte *dataSourcePtr;
                        uint  bufferCapacity;
                        ((IMemoryBufferByteAccess)bufferRef).GetBuffer(out dataSourcePtr, out bufferCapacity);

                        var buffer = writer.GetBuffer();
                        fixed(byte *bufferPtr = buffer)
                        {
                            DataManipulation.Copy(dataSourcePtr + _offset, bufferPtr + writeOffset, (uint)dataChunkSize);
                        }
                    }
            }
            _offset += dataChunkSize;
            return(_offset == _dataCapacity);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Recreates every data structure based on the decrypted bits EXCEPT for the original string value
        /// </summary>
        /// <param name="originalComparisonBits"></param>
        /// <param name="byteOffset">the number of bytes that the encrypted bits are from the actual start of the message (0 if the first bit represents the first bit of the message)</param>
        /// <returns></returns>
        public LinkedList <char> decrypt(LinkedList <char> originalComparisonBits, int byteOffset)
        {
            int compareBitOffset            = byteOffset * 8;
            LinkedList <char> decryptedBits = DataManipulation.bitXORListReverse(bitList, originalComparisonBits, compareBitOffset);

            bitList = decryptedBits;
            recreateDataStructuresFromBits();
            return(decryptedBits);
        }
 private void editRecordBtn_Click(object sender, EventArgs e)
 {
     DataManipulation.updateFeeRecord(Double.Parse(amountER.Text), monthListER.Text, type, id, year);
     if (!type.Equals("OTHER"))
     {
         DataManipulation.updateTransaction(receiptNumber);
     }
     this.Close();
 }
Ejemplo n.º 22
0
 async public void SaveToDatabase(Initialization ini, HistoryDemo.Entities.Configuration conf)
 {
     string fileName = $"datalog\\{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.mat";
     await Task.Run(() => {
         Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
         SaveToFile(fileName);
         DataManipulation.Create(ini, conf, fileName);
     });
 }
Ejemplo n.º 23
0
        // Delete existing Role
        public int deleteRole(int RoleID)
        {
            DataManipulation dm = new DataManipulation();

            SqlParameter[] paras = new SqlParameter[1];
            paras[0]       = new SqlParameter("@RoleID", SqlDbType.Int);
            paras[0].Value = RoleID;

            return(dm.manipulateData("prcRole_Delete", paras));
        }
Ejemplo n.º 24
0
        private void update()
        {
            string filename = DataManipulation.GetPath(radioButton1, radioButton2, radioButton3, radioButton4,
                                                       radioButton5, radioButton6, radioButton7, radioButton8, radioButton9);

            DataManipulation.GetListOfTweets(@"C:\Users\Denis\source\repos\Tweets\Tweets\files\" + filename);
            DataManipulation.GetTweetsByStates();
            DataManipulation.GetMoodByStates();
            DataManipulation.GetListOfPolygons();
            DataManipulation.Layout(map);
        }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            string userInput    = null;
            bool   userContinue = true;

            while (userContinue)
            {
                userInput = StandardInputMessage.RequestInput();

                if (DataValidation.ValidateInput(userInput) == false)
                {
                    bool retry = StandardInputMessage.RePrompt();
                    if (retry == false)
                    {
                        userContinue         = false;
                        Environment.ExitCode = 22;
                    }
                }
                else
                {
                    long userNumber = DataManipulation.ReturnValue(userInput);
                    if (DataValidation.ValidateComposite(userNumber) == false)
                    {
                        bool retry = StandardInputMessage.RePrompt(); //refactor using userContinue from RePrompt()
                        if (retry == false)
                        {
                            userContinue         = false;
                            Environment.ExitCode = 44;
                        }
                    }
                    else
                    {
                        CompositeNumber userComposite = new CompositeNumber(userNumber);

                        LinkedList <IFactor> factors = Factorize.Factor(userComposite);

                        List <IFactor>    primeNumbers     = DataManipulation.ReturnPrimes(factors);     //Should be list of primes
                        List <IFactor>    compositeNumbers = DataManipulation.ReturnComposites(factors); //Should be list of composites
                        FactorizationTree factorTree       = DataManipulation.ReturnPopulatedTree(factors);

                        StandardOutputMessage.OutputFactors(compositeNumbers, userNumber);
                        StandardOutputMessage.OutputFactors(primeNumbers, userNumber);
                        StandardOutputMessage.OutputFactorizationTree(factorTree, userNumber);

                        bool retry = StandardInputMessage.RePrompt();
                        if (retry == false)
                        {
                            userContinue         = false;
                            Environment.ExitCode = 100;
                        }
                    }
                }
            }
        }
Ejemplo n.º 26
0
        public ActionResult Index() //ucitavanje stranice, pokupi kategorije, smesti ih u model i posalje u View
        {
            DataManipulation data = new DataManipulation();
            var categories        = data.getCategories();

            var model = new LayersModel()
            {
                categories = categories
            };

            return(View(model));
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Returns the parameter value
        /// </summary>
        /// <param name="index">Parameter index</param>
        /// <param name="gObject">Game object</param>
        /// <returns></returns>
        public string GetParamValue(int index, GameObject gObject)
        {
            if (index < 0 || index >= DataNames.Length)
            {
                return("");
            }
            try
            {
                int dpos = 0;
                if (DataTypes[index] != ParameterDataTypes.COMMENT)
                {
                    dpos = DataPositions[index];
                }

                switch (DataTypes[index])
                {
                case ParameterDataTypes.BYTE:
                    return(gObject.Values[dpos].ToString());

                case ParameterDataTypes.SHORT:
                    return(BitConverter.ToInt16(DataManipulation.SwapEndian(gObject.Values, dpos, 2), 0).ToString());

                case ParameterDataTypes.INT:
                    return(BitConverter.ToInt32(DataManipulation.SwapEndian(gObject.Values, dpos, 4), 0).ToString());

                case ParameterDataTypes.FLOAT:
                    return(BitConverter.ToSingle(DataManipulation.SwapEndian(gObject.Values, dpos, 4), 0).ToString());

                case ParameterDataTypes.DOUBLE:
                    return(BitConverter.ToDouble(DataManipulation.SwapEndian(gObject.Values, dpos, 8), 0).ToString());

                case ParameterDataTypes.STRING:
                    int length = BitConverter.ToInt16(DataManipulation.SwapEndian(gObject.Values, dpos, 2), 0);

                    MemoryStream ms = new MemoryStream(gObject.Values);
                    ms.Position = dpos + 2;
                    return(DataManipulation.ReadString(ms, length));

                case ParameterDataTypes.BUFFER:
                    string array = "";
                    for (int i = dpos; i < dpos + CustomInfo[index]; i++)
                    {
                        array += gObject.Values[i].ToString("X2") + " ";
                    }
                    return(array.Substring(0, array.Length - 1));

                case ParameterDataTypes.COMMENT:
                    return(CommentInfo[index]);
                }
            }
            catch { return(""); }
            return("");
        }
Ejemplo n.º 28
0
        public void DataManipulation_ReturnValue_ReturnsLong()
        {
            // Arrange
            Random random = new Random(1000000);

            // Act
            var actual   = DataManipulation.ReturnValue(random.Next().ToString());
            var expected = typeof(long);

            // Assert
            Assert.IsType(expected, actual);
        }
Ejemplo n.º 29
0
        public ActionResult Details(int?id)
        {
            var client = ClientUtilitaire.FindClientParId(db, id.Value);

            if (client == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            var clientDetailsView = DataManipulation.copyClientToClientDetailsView(client);

            return(View(clientDetailsView));
        }
Ejemplo n.º 30
0
 /**
  * Will throw an exception if the bytes don't convert to an actual string
  * */
 public String recreateStringFromBytes()
 {
     try
     {
         String stringValue = DataManipulation.convertBytesToString(bytes);
         message = stringValue;
     } catch (Exception ex)
     {
         throw ex; // throw the error if an error occurred while converting the bytes to a string, probably because one of the bytes did not represent a real character
     }
     return(message);
 }