コード例 #1
1
		public void GetCustomErrors(ServerManager srvman, WebVirtualDirectory virtualDir)
		{
			var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
			//
			var httpErrorsSection = config.GetSection(Constants.HttpErrorsSection);

		    virtualDir.ErrorMode = (HttpErrorsMode)httpErrorsSection.GetAttributeValue("errorMode");
            virtualDir.ExistingResponse = (HttpErrorsExistingResponse)httpErrorsSection.GetAttributeValue("existingResponse");
			//
			var errorsCollection = httpErrorsSection.GetCollection();
			//
			var errors = new List<HttpError>();
			//
			foreach (var item in errorsCollection)
			{
				var item2Get = GetHttpError(item, virtualDir);
				//
				if (item2Get == null)
					continue;
				//
				errors.Add(item2Get);
			}
			//
			virtualDir.HttpErrors = errors.ToArray();
		}
コード例 #2
0
        public ActionResult BuyProducts()
        {
            Order order = new Order();

            order.ID = Guid.NewGuid();
            order.Username = @User.Identity.Name;
            order.DateOrdered = DateTime.Now;

            //products to add to the order
            List<Cart_Product> cartProductsToBuy = new List<Cart_Product>();

            foreach (Cart_Product cp in new WCFCart_OrderClient().GetCart(@User.Identity.Name))
            {
                Product p = new WCFProduct().GetProductByID(cp.ProductID);

                if (p.Stock_Amount - cp.Quantity >= 0)
                {
                    cartProductsToBuy.Add(cp);

                    //delete cart product
                    new WCFCart_Order().DeleteProductFromCart(cp);

                    //decrease stock
                    p.Stock_Amount = p.Stock_Amount - cp.Quantity;

                    new WCFProduct().UpdateProduct(p);
                }
            }

            //add the order
            new WCFCart_OrderClient().AddOrder(order, cartProductsToBuy.ToArray());

            //testing
            return RedirectToAction("Home", "Product");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: balazsmolnar/Euler
        public static BigInt Calculate(int D)
        {
            if (Square.IsPerfectSquare(D))
            {
                return 0;
            }

            for (;;)
            {
                List<int> coeffs = new List<int>();
                foreach (var i in CalculateSquareCoefficients(D))
                {
                    coeffs.Add(i);
                    var frac = Calculate(coeffs.ToArray());
                    var x = frac.Nominator;
                    var y = frac.Denominator;

                    if (x * x - D * y * y == 1)
                    {
                        Console.WriteLine("D={0} x={1}", D, x);
                        return x;
                    }
                }
            }
        }
コード例 #4
0
ファイル: RegressionTaskV3.cs プロジェクト: vadimostanin/AIML
        protected override void PrepareData()
        {
            base.PrepareData();

            var newLearningInputs = new List<double[]>();
            var newLearningAnswers = new List<double[]>();
            var controlInputs = new List<double[]>();
            var controlAnsers = new List<double[]>();

            for (int i = 0; i < LearningInputs.Length; i++)
            {
                if (i % 2 == 0)
                {
                    newLearningInputs.Add(LearningInputs[i]);
                    newLearningAnswers.Add(LearningAnswers[i]);
                }
                else
                {
                    controlInputs.Add(LearningInputs[i]);
                    controlAnsers.Add(LearningAnswers[i]);
                }

            }

            LearningInputs = newLearningInputs.ToArray();
            LearningAnswers = newLearningAnswers.ToArray();
            ControlInputs = controlInputs.ToArray();
            ControlAnswers = controlAnsers.ToArray();
        }
コード例 #5
0
        public string[] CheckProductQuantities()
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    List<ShoppingCart> myShoppingCartItems = new ShoppingCartLogic().RetrieveAllShoppingCartItems(myLoggedUser.Id).ToList();

                    List<string> ViolatingIDs = new List<string>();

                    foreach (ShoppingCart myShoppingCartItem in myShoppingCartItems)
                    {
                        if (!new OrdersLogic().HasSufficientQuantity(myShoppingCartItem.ProductFK, myShoppingCartItem.Quantity))
                        {
                            ViolatingIDs.Add(myShoppingCartItem.ProductFK.ToString());
                        }
                    }

                    return ViolatingIDs.ToArray();
                }
                else
                {
                    return new string[] { "" };
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #6
0
		public string GetDefaultDocumentSettings(string siteId)
		{
			using (var srvman = GetServerManager())
			{
				// Load web site configuration
				var config = srvman.GetWebConfiguration(siteId);
				// Load corresponding section
				var section = config.GetSection(Constants.DefaultDocumentsSection);
				//
				var filesCollection = section.GetCollection("files");
				// Build default documents
				var defaultDocs = new List<String>();
				//
				foreach (var item in filesCollection)
				{
					var item2Get = GetDefaultDocument(item);
					//
					if (String.IsNullOrEmpty(item2Get))
						continue;
					//
					defaultDocs.Add(item2Get);
				}
				//
				return String.Join(",", defaultDocs.ToArray());
			}
		}
コード例 #7
0
ファイル: TunnelHost.cs プロジェクト: dabeku/FileTunnel
 public void Start()
 {
     while (true) {
         // Wait for incoming request
         string request = WaitForRequest();
         // Send data to server
         TcpClient client = new TcpClient(ApplicationConfiguration.HostDestinationUrl, ApplicationConfiguration.HostDestinationPort);
         NetworkStream stream = client.GetStream();
         byte[] bytesToSend = Constants.ENCODING_DEFAULT.GetBytes(request);
         stream.Write(bytesToSend, 0, bytesToSend.Length);
         // Receive data from server
         // TODO: Make configurable
         byte[] bufferReceive = new byte[8192];
         List<byte> bufferComplete = new List<byte>();
         int bytesRead = stream.Read(bufferReceive, 0, bufferReceive.Length);
         while (bytesRead > 0) {
             bufferComplete.AddRange(bufferReceive.Take(bytesRead));
             // TODO: Make configurable
             for (int i = 0; i < 10; i++) {
                 Console.WriteLine("Is more data available: " + stream.DataAvailable);
                 if (stream.DataAvailable) {
                     break;
                 }
                 // TODO: Make configurable
                 Thread.Sleep(100);
             }
             if (!stream.DataAvailable) {
                 break;
             }
             bytesRead = stream.Read(bufferReceive, 0, bufferReceive.Length);
         }
         client.Close();
         WriteResponseToFile(bufferComplete.ToArray());
     }
 }
コード例 #8
0
ファイル: ViewService.cs プロジェクト: exrin/Exrin
        private object GetBindingContext(Type viewType)
        {
            var viewModelType = _viewsByType[viewType];

            ConstructorInfo constructor = null;

            var parameters = new object[] { };

            constructor = viewModelType.Type.GetTypeInfo()
                   .DeclaredConstructors
                   .FirstOrDefault(c => !c.GetParameters().Any());

            if (constructor == null)
            {
                constructor = viewModelType.Type.GetTypeInfo()
                   .DeclaredConstructors.First();

                var parameterList = new List<object>();

                foreach (var param in constructor.GetParameters())
                    parameterList.Add(_injection.Get(param.ParameterType));

                parameters = parameterList.ToArray();
            }

            if (constructor == null)
                throw new InvalidOperationException(
                    $"No suitable constructor found for ViewModel {viewModelType.ToString()}");

            return constructor.Invoke(parameters);
        }
コード例 #9
0
        protected override void CreateDeviceDependentResources()
        {
            base.CreateDeviceDependentResources();

            RemoveAndDispose(ref vertexBuffer);

            // Retrieve our SharpDX.Direct3D11.Device1 instance
            var device = this.DeviceManager.Direct3DDevice;

            List<Vertex> vertices = new List<Vertex>();

            vertices.AddRange(new[] {
                new Vertex(0, 0, -4, Vector3.UnitY, Color.Blue),
                new Vertex(0, 0, 4,Vector3.UnitY,  Color.Blue),
                new Vertex(-4, 0, 0, Vector3.UnitY, Color.Red),
                new Vertex(4, 0, 0,Vector3.UnitY,  Color.Red),
            });
            for (var i = -4f; i < -0.09f; i += 0.2f)
            {
                vertices.Add(new Vertex(i, 0, -4, Color.Gray));
                vertices.Add(new Vertex(i, 0, 4, Color.Gray));
                vertices.Add(new Vertex(-i, 0, -4, Color.Gray));
                vertices.Add(new Vertex(-i, 0, 4, Color.Gray));

                vertices.Add(new Vertex(-4, 0, i, Color.Gray));
                vertices.Add(new Vertex(4, 0, i, Color.Gray));
                vertices.Add(new Vertex(-4, 0, -i, Color.Gray));
                vertices.Add(new Vertex(4, 0, -i, Color.Gray));
            }
            vertexCount = vertices.Count;
            vertexBuffer = ToDispose(Buffer.Create(device, BindFlags.VertexBuffer, vertices.ToArray()));
        }
コード例 #10
0
		public void GetCustomErrors(WebVirtualDirectory virtualDir)
		{
			//
			using (var srvman = GetServerManager())
			{
				var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
				//
				var httpErrorsSection = config.GetSection(Constants.HttpErrorsSection);
				//
				var errorsCollection = httpErrorsSection.GetCollection();
				//
				var errors = new List<HttpError>();
				//
				foreach (var item in errorsCollection)
				{
					var item2Get = GetHttpError(item, virtualDir);
					//
					if (item2Get == null)
						continue;
					//
					errors.Add(item2Get);
				}
				//
				virtualDir.HttpErrors = errors.ToArray();
			}
		}
コード例 #11
0
 public Uri[] GetProxyParticlesAddresses()
 {
     var uris = new List<Uri>();
     if (_left != null) uris.Add(_left.Item2.Address);
     if (_right != null) uris.Add(_right.Item2.Address);
     return uris.ToArray();
 }
コード例 #12
0
ファイル: RLE.cs プロジェクト: MetLob/tinke
        public static byte[] Descomprimir_Pixel(byte[] datos, byte depth)
        {
            if (depth % 8 != 0)
                throw new NotImplementedException("Profundidad no soportada: " + depth.ToString());

            List<byte> des = new List<byte>();

            for (int pos = 0; pos < datos.Length; )
            {
                if (datos[pos] >= 0x80)
                {
                    int rep = datos[pos] - 0x80 + 1;
                    pos++;

                    for (; rep > 0; rep--)
                        for (int d = 0; d < (depth / 8); d++)
                            des.Add(datos[pos]);
                }
                else
                {
                    int rep = datos[pos] + 1;
                    pos++;

                    for (; rep > 0; rep--)
                        for (int d = 0; d < (depth/8); d++, pos++)
                            des.Add(datos[pos]);
                }
                pos++;
            }

            return des.ToArray();
        }
コード例 #13
0
        public ActionResult CreateUser(RegistrationModel model)
        {
            if (model.Password.ToString().Length < 6)
            {
                ViewBag.Message = "Password length must be at least 6 characters.";
            }
            else if (new UserAccountServ.UserAccountClient().GetAccountByUsername(model.Username.ToString()) != null)
            {
                ModelState.AddModelError("", "Username taken.");
                ViewBag.Message = "Username already taken.";
            }
            else if (new UserAccountServ.UserAccountClient().GetUserByEmail(model.Email.ToString()) != null)
            {
                ModelState.AddModelError("", "Email taken.");
                ViewBag.Message = "Email already taken.";
            }
            else if (new UserAccountServ.UserAccountClient().GetAccountByPIN(model.PIN) != null)
            {
                ModelState.AddModelError("", "PIN taken.");
                ViewBag.Message = "PIN already taken.";
            }
            else
            {
                Account acc = new UserAccountServ.UserAccountClient().GetAccountByUsername(model.Username);
                int roleID = 0;
                List<int> add = new List<int>();

                for (int i = 0; i < model.roles.Count; i++)
                {
                    if (model.checkboxes[i].Checked)
                    {
                        roleID = model.roles[i].ID;
                        add.Add(roleID);
                    }
                }
                int[] arraylist = add.ToArray();

                User u = new User();
                u.Name = model.Name;
                u.Surname = model.Surname;
                u.Email = model.Email;
                u.Mobile = model.Mobile;
                u.ResidenceName = model.ResidenceName;
                u.StreetName = model.StreetName;

                Account a = new Account();
                a.Username = model.Username;
                a.Password = model.Password;
                a.PIN = model.PIN;

                new UserAccountServ.UserAccountClient().AddUser(u, arraylist, a);

                UtilitiesApplication.Encryption encrytion = new UtilitiesApplication.Encryption();
                ViewBag.Token = "Your token is  " + encrytion.EncryptTripleDES(model.Password.ToString(), model.PIN.ToString()) + "  Please use this to log in.";

            }

            return View(model);
        }
コード例 #14
0
        public string LoadShoppingCartItems()
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    string HTML = "";

                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    List<ShoppingCart> myShoppingCartItems = new ShoppingCartLogic().RetrieveAllShoppingCartItems(myLoggedUser.Id).ToList();
                    List<Product> myProductList = new List<Product>();

                    foreach (ShoppingCart myShoppingCartItem in myShoppingCartItems)
                    {
                        myProductList.Add(new ProductsLogic().RetrieveProductByID(myShoppingCartItem.ProductFK.ToString()));
                    }

                    Product[] myProducts = myProductList.ToArray();

                    if (myProducts.Length > 0)
                    {
                        for (int i = 1; i <= (myProducts.Length + 4 / 4); i++)
                        {
                            int Counter = i * 4;

                            HTML += "<tr>";

                            for (int j = (Counter - 3); j <= Counter; j++)
                            {
                                HTML += "<td>";

                                HTML += TDContents(myProducts[j - 1]);

                                HTML += "</td>";

                                if (j == myProducts.Length)
                                {
                                    goto LoopEnd;
                                }
                            }

                            HTML += "</tr>";
                        }
                    }

                LoopEnd:

                    return HTML;
                }
                else
                {
                    return "";
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #15
0
        void ConvertDirectionsBack()
        {
            var innerDirections = new List<partType>();
            int no = 0;

            foreach (var direction in DeviceConfiguration.Directions)
            {
                var innerDirection = new partType()
                {
                    type = "direction",
                    no = no.ToString(),
                    id = direction.Id.ToString(),
                    gid = Gid++.ToString(),
                    name = direction.Name
                };
                ++no;

                var zones = new List<partTypePinZ>();
                foreach (var zone in direction.Zones)
                {
                    zones.Add(new partTypePinZ() { pidz = zone.ToString() });
                }
                innerDirection.PinZ = zones.ToArray();

                if (direction.DeviceRm != Guid.Empty || direction.DeviceButton != Guid.Empty)
                {
                    var innerDirectionParameters = new List<paramType>();
                    innerDirectionParameters.Add(new paramType()
                    {
                        name = "Device_RM",
                        type = "String",
                        value = GuidHelper.ToString(direction.DeviceRm)
                    });

                    innerDirectionParameters.Add(new paramType()
                    {
                        name = "Device_AM",
                        type = "String",
                        value = GuidHelper.ToString(direction.DeviceRm)
                    });

                    innerDirection.param = innerDirectionParameters.ToArray();
                }

                if (innerDirection.param != null)
                {
                    var rmParameter = innerDirection.param.FirstOrDefault(x => x.name == "Device_RM");
                    direction.DeviceRm = GuidHelper.ToGuid(rmParameter.value);
                    var buttonParameter = innerDirection.param.FirstOrDefault(x => x.name == "Device_AM");
                    direction.DeviceButton = GuidHelper.ToGuid(buttonParameter.value);
                }

                innerDirections.Add(innerDirection);
            }

            FiresecConfiguration.part = innerDirections.ToArray();
        }
コード例 #16
0
 private static string[] GetProgramTypes(string types)
 {
     var list = new List<string>();
     if (types.Contains("one-to-one", true)) list.Add("1");
     if (types.Contains("group", true)) list.Add("2");
     //if (types.Contains("peer to peer")) list.Add("");
     if (types.Contains("e-mentoring", true)) list.Add("5");
     return list.ToArray();
 }
コード例 #17
0
        /// <summary>
        /// Response for clients solution request
        /// </summary>
        /// <param name="networkAdapter"></param>
        /// <param name="message"></param>
        /// <param name="messageType"></param>
        /// <param name="timeout"></param>        
        public void HandleMessage(ServerNetworkAdapter networkAdapter, string message, MessageType messageType, TimeSpan timeout)
        {
            SolutionRequest request = MessageSerialization.Deserialize<SolutionRequest>(message);

            if (request == null)
                return;

            DvrpProblem.WaitEvent.WaitOne();

            if (!DvrpProblem.Problems.ContainsKey(request.Id))
            {
                DvrpProblem.WaitEvent.Set();
                return;
            }
            if (DvrpProblem.ProblemSolutions.ContainsKey(request.Id))
            {
                Solutions solution = DvrpProblem.ProblemSolutions[request.Id];

                DvrpProblem.ProblemsID.Remove(request.Id);
                DvrpProblem.Problems.Remove(request.Id);
                DvrpProblem.ProblemSolutions.Remove(request.Id);

                networkAdapter.Send(solution);
                DvrpProblem.WaitEvent.Set();
                return;
            }

            SolveRequest problem = DvrpProblem.Problems[request.Id];
            Solutions response = new Solutions();
            response.Id = request.Id;
            response.ProblemType = problem.ProblemType;
            response.CommonData = problem.Data;
            List<SolutionsSolution> solutionList = new List<SolutionsSolution>();

            if (DvrpProblem.PartialSolutions.ContainsKey(request.Id))
                solutionList.AddRange(DvrpProblem.PartialSolutions[request.Id]);

            if (DvrpProblem.PartialProblems.ContainsKey(request.Id))
                foreach (var element in DvrpProblem.PartialProblems[request.Id])
                    if (element.Value > 0)
                    {
                        SolutionsSolution sol = new SolutionsSolution();
                        sol.TaskId = element.Key.TaskId;
                        sol.Data = element.Key.Data;
                        sol.Type = SolutionsSolutionType.Ongoing;
                        solutionList.Add(sol);
                    }

            if (solutionList.Count > 0)
                response.Solutions1 = solutionList.ToArray();
            else
                response.Solutions1 = new SolutionsSolution[] { new SolutionsSolution { Data = new byte[1] } };

            networkAdapter.Send(response);
            DvrpProblem.WaitEvent.Set();
        }
コード例 #18
0
        public Point[] Calculate(IEquation e, double start, double end)
        {
            List<Point> results = new List<Point>();
            equation ef = e.f;
            CalculateZeros cs = new CalculateZeros(ef);

            cs.FindZerosInRange(start, end);
            results = cs.Zeros;
            return results.ToArray();
        }
コード例 #19
0
		private static string[] GetParts(CacheKey[] namespaceCacheKeys, string[] keyParts)
		{
			List<string> returnList = new List<string>();
			string[] versionKeys = namespaceCacheKeys.ConvertAll(key => key.ToString());
			Getter<string>[] getters = new Getter<string>[namespaceCacheKeys.Length];
			getters.Length.Times(i => getters[i] = () => Guid.NewGuid().ToString());
			string[] versionValues = Caching.Instances.Main.MultiGet<string>(versionKeys, getters, DateTime.MaxValue);
			returnList.AddRange(versionValues);
			returnList.AddRange(keyParts);
			return returnList.ToArray();
		}
コード例 #20
0
 /// <summary>Uses Ruffini's rule</summary>
 public PolynomialEq EliminateRootNoRemainder(double root)
 {
     List<double> tempList = new List<double>(coefficients.Count);
     List<double> newCoef = new List<double>(coefficients.Count); //last guy is the remainder
     newCoef.Add(coefficients[0]);
     for (int i = 1; i < coefficients.Count - 1; i++) {
         tempList.Add( newCoef.Last()* root);
         newCoef.Add(coefficients[i] + tempList.Last());
     }
     return new PolynomialEq(newCoef.ToArray());
 }
コード例 #21
0
ファイル: Tasks.cs プロジェクト: winmissupport/FeatureUpate
        /// <summary>
        /// Perform one or more tasks asyncronously.
        /// </summary>
        /// <param name="actions">The action(s) to perform</param>
        public static void RunAsyncTasks(params Action[] actions)
        {
            var tasks = new List<Task>();

            foreach (var action in actions)
            {
                tasks.Add(Task.Factory.StartNew(action));
            }

            Task.WaitAll(tasks.ToArray());
            tasks.Clear();
        }
コード例 #22
0
ファイル: UserInfoDAL.cs プロジェクト: JoiWilliam/OAProject
 public int DeleteUsers(string userID)
 {
     string[] id = userID.Split(',');
     string sql = "delete UserInfo where UserID in({0})";
     List<string> columnsNameList = new List<string>();
     List<SqlParameter> paraList = new List<SqlParameter>();
     for (int i = 0; i < id.Length; i++)
     {
         columnsNameList.Add("@UserID" + i);
         paraList.Add(new SqlParameter("@UserID" + i, id[i]));
     }
     sql = string.Format(sql, string.Join(",", columnsNameList));
     return SqlHelper.ExecuteNonQuery(sql, paraList.ToArray());
 }
コード例 #23
0
ファイル: UserInfoDAL.cs プロジェクト: JoiWilliam/OAProject
 public int EditPrivate(UserInfoModel user)
 {
     string sql = "update UserInfo set {0}Cellphone=@Cellphone where UserID=@UserID";
     List<SqlParameter> list = new List<SqlParameter>();
     list.Add(new SqlParameter("@UserID", user.UserID));
     list.Add(new SqlParameter("@Cellphone", user.Cellphone));
     if (user.Password != null)
     {
         sql = string.Format(sql, "Password=@Password,");
         list.Add(new SqlParameter("@Password", user.Password));
     }
     else sql = string.Format(sql, "");
     return SqlHelper.ExecuteNonQuery(sql, list.ToArray());
 }
コード例 #24
0
ファイル: frmEvalJS.cs プロジェクト: jango2015/MongoCola
 /// <summary>
 ///     eval Javascript
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdEval_Click(object sender, EventArgs e)
 {
     var mongoDb = RuntimeMongoDbContext.GetCurrentDataBase();
     var js = new BsonJavaScript(ctlEval.Context);
     var Params = new List<BsonValue>();
     if (txtParm.Text != string.Empty)
     {
         foreach (var parm in txtParm.Text.Split(",".ToCharArray()))
         {
             if (parm.StartsWith("'") & parm.EndsWith("'"))
             {
                 Params.Add(parm.Trim("'".ToCharArray()));
             }
             else
             {
                 try
                 {
                     var isNuberic = true;
                     for (var i = 0; i < parm.Length; i++)
                     {
                         if (!char.IsNumber(parm, i))
                         {
                             isNuberic = false;
                         }
                     }
                     if (isNuberic)
                     {
                         Params.Add(Convert.ToInt16(parm));
                     }
                 }
                 catch (Exception ex)
                 {
                     Utility.ExceptionDeal(ex, "Exception", "Parameter Exception");
                 }
             }
         }
     }
     try
     {
         var args = new EvalArgs {Args = Params.ToArray(), Code = js};
         var result = mongoDb.Eval(args);
         MyMessageBox.ShowMessage("Result", "Result",
             result.ToJson(MongoHelper.JsonWriterSettings), true);
     }
     catch (Exception ex)
     {
         Utility.ExceptionDeal(ex, "Exception", "Result");
     }
 }
コード例 #25
0
        private async Task InitializeNavigator()
        {
            List<List<string>> itemListArray = new List<List<string>>();
            foreach (StorageFolder storageFolder in DataSource.NavigatorStorageFolders)
            {
                var items = await storageFolder.GetItemsAsync();
                List<string> folderNames = items.OfType<StorageFolder>().Select(item => item.Name).ToList();

                itemListArray.Add(folderNames);
            }
            Navigator.ItemListArray = itemListArray.ToArray();
            Navigator.Path = DataSource.GetPath();

            var currentItems = await DataSource.CurrentStorageFolder.GetItemsAsync();
            CurrentItems = currentItems.Select(item => item.Name).ToList();
        }
コード例 #26
0
        private static string AddPath(string list, string item)
        {
            var paths = new List<string>(list.Split(';'));

            foreach (string path in paths)
            {
                if (string.Compare(path, item, true) == 0)
                {
                    // already present
                    return list;
                }
            }

            paths.Add(item);
            return string.Join(";", paths.ToArray());
        }
コード例 #27
0
ファイル: FrmMain.cs プロジェクト: ysjr-2002/DeviceTest
        //心跳
        private void button1_Click(object sender, EventArgs e)
        {
            cmd = 0x11;
            List<byte> data = new List<byte>();
            data.Add(0x04);
            data.Add((byte)'A');
            data.Add(0x00);
            data.Add(0x00);
            data.Add(cmd);
            data.Add(0x00);
            data.Add(0x00);
            data.Add(0x00);

            var arr = data.ToArray();
            Debug.WriteLine(arr.Length);
        }
コード例 #28
0
ファイル: UserInfoDAL.cs プロジェクト: JoiWilliam/OAProject
 public int EditUser(UserInfoModel user)
 {
     string sql = "update UserInfo set UserName=@UserName,DeptID=@DeptID,{0}Cellphone=@Cellphone,UserType=@UserType where UserID=@UserID";
     List<SqlParameter> list = new List<SqlParameter>();
     list.Add(new SqlParameter("@UserID", user.UserID));
     list.Add(new SqlParameter("@UserName", user.UserName));
     list.Add(new SqlParameter("@DeptID", user.DeptID));
     list.Add(new SqlParameter("@Cellphone", user.Cellphone));
     list.Add(new SqlParameter("@UserType", user.UserType));
     if (user.Password != null)
     {
         sql = string.Format(sql, "Password=@Password,");
         list.Add(new SqlParameter("@Password", MD5Maker.GetMD5(user.Password)));
     }
     else sql = string.Format(sql, "");
     return SqlHelper.ExecuteNonQuery(sql, list.ToArray());
 }
コード例 #29
0
 public static async Task ReadIncomingAsync(Stream stream, string expectedMessage)
 {
     var incomingBytes = new List<byte>();
     do
     {
         var buffer = new byte[1];
         var count = await stream.ReadAsync(buffer, 0, 1);
         if (count >= 1)
         {
             incomingBytes.Add(buffer[0]);
         }
     } while (IsReadingShouldContinue(incomingBytes));
     var actual = Encoding.UTF8.GetString(incomingBytes.ToArray());
     if (actual != expectedMessage)
     {
         ErrorWrongMessage(actual);
     }
 }
コード例 #30
-1
 private static async Task ReceiveAndCheckAsync(UdpClient client, string expectedMessage)
 {
         var incomingBytes = new List<byte>();
     var connectionReset=false;
     try
     {
         do
         {
             var udpReceiveResult = await client.ReceiveAsync();
             incomingBytes.AddRange(udpReceiveResult.Buffer);
         } while (TcpMessenger.IsReadingShouldContinue(incomingBytes));
     }
     catch (SocketException ex)
     {
         if (ex.SocketErrorCode == SocketError.ConnectionReset)
         {
             connectionReset = true;
         }
     }
     var actual = Encoding.UTF8.GetString(incomingBytes.ToArray());
     if (connectionReset)
     {
         TcpMessenger.ErrorConnectionReset(actual);
     }
     else if (actual != expectedMessage)
     {
         TcpMessenger.ErrorWrongMessage(actual);
     }
 }