Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

.NET Programming

132K

Solutions

38K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a function defined like this:
    private string AuthOrCharge(ARequest a = null, CRequest c = null, 
                                PACRequest p = null, VRequest v = null,
                                BCRequest b = null, BRRequest cb = null, 
                                BCURequest cub = null, bool ur = false)

Open in new window

I want to refactor it to where I can use only 2 parameters:
    private string AuthOrCharge(Object o, bool ur = false)

Open in new window

I will then be able to call it using all the different request objects in the single parameter `o` and then use an `if` statement in the function to differentiate which one is being passed:
    private string AuthOrCharge(Object o, bool ur = false)
        // ***********************
        // some common objects needed
        // ***********************
        var da = new da
        {
            DId = 12345678,
            Ver = "1.2"
        };
        // ***********************
        // o will need to be cast here to the type passed as o doesn't have a da property
        // ***********************
        o.da = da;
        var a = new apiC();
        var controller = new PController();

        // ***********************
        // Now do the stuff that is different for each type
        // ***********************
        if(o.GetType() == typeof(ARequest))
        {
            if(ur) {    
                o.da.it = 1;
            }
            response = 

Open in new window

0
Give Your Engineering Team a Productivity Boost
Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Hello Experts

I am getting a json response from a URL which I am trying parse it and capture code to store in the DB

Its returning the string ok but I am unable to remove the quoted strings to save the code in the DB
 

 Dim jResults As Object = JObject.Parse(Json)
        Dim jsonResulttodict = JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(Json)
        Dim firstItem = jsonResulttodict.Item("error")
        Dim seconditem = jsonResulttodict.Item("success")
        Dim thirditem = jsonResulttodict.Item("codes")

example string:

'{"error":"","success":"1 code generated successfully","codes":["QTESTA2HLT"]}


I am getting the code as [{  "QTESTA2HLT"  }]

Al I want is to read as QTESTA2HLT

please advise

thanks
0
Hello,
I need to draw a linebetween two rows of datagridview .
Example gridA and gridB are two grids. The user select row1 of gridA and row3 of gridB , there should a line drawn in between row1 of gridA and row3 of gridB.
I have tried a lot to achieve this but with little success. Any suggestions are highly appreciated.
Regards
0
I am trying to install .net framework 4 and it is taking alot of time. I have tried to manually force the windows installer and also downloaded another offline installer but still the same.

It takes more than an hour for the framework to install which is very time consuming.
0
Hi Experts,

Looking for some options to integrate splunk + chatbot + amazon alex.

  1. Assume we have some data shipped to splunk.
  2. Some kind of chatbot to scan splunk data and send voice announcement on a particular event..probably to alexa? or pc speaker etc. (I know splunk has some inbuilt alerts)
  3. On demand - voice command to get status using Amazon Alex

any information would be really helpful.

thanks in advance
0
Dear,
I want to have the effect to disable further update (like to show gray background color), to whole page, when it's being idle for a while, by these

        .overlay {
            background: #e9e9e9;
            display: none;
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            opacity: 0.5;
        }
$(function () {
    // 1000ms=1s, here test use 10s, you could modify. 
    var time = 5000;
    var set = setInterval(function () {
        $(".overlay").show();
        $("#dialog").dialog();
    }, time);
});
    <div class="overlay">
        <div id="loading-img">
        </div>
    </div>

Open in new window

but I cannot get what I want, below
http://my-friend.co/RegRec2?id=18&user_abbr=mc2&readonly=n

what to adjust?
0
I need to get the width and height of a web page using vb.net code behind. Anyone have a clue?
0
I am a .NET Full Stack developer with UI experience, but little on Angular.

What's the best version to learn?

I want to learn that to maximize my value in the job market.

Thanks.
0
Hello,
How can I find listview item or datagridview item under the mouse click .
Regards
0
Using the below piece of code.  Attempting to test sending an email.  I do receive the "Sent" message box but never receive an email.  Any ideas?
 Private Sub SMTP_Click(sender As Object, e As RoutedEventArgs)

        Try
            Dim myServer As New SmtpClient()
            myServer.Host = Me.txtServer.Text
            myServer.Port = Me.txtPort.Text

            'Server Credentials
            Dim nc As New NetworkCredential()
            nc.UserName = Me.txtUserName.Text
            nc.Password = Me.txtPassword.Text
            'assigned credetial details to server
            myServer.Credentials = nc

            'create sender address
            Dim from = New MailAddress(Me.txtEmail.Text, Me.txtEmail.Text)

            'create receiver address
            Dim receiver = New MailAddress(Me.txtEmail.Text, Me.txtEmail.Text)

            Dim myMessage = New MailMessage(from, receiver)
            myMessage.Subject = "Test SMTP for " & Me.txtServer.Text
            myMessage.Body = "Test SMTP for Server: " & Me.txtServer.Text & _
                                         "; Port: " & Me.txtPort.Text & _
                                         "; UserName: " & Me.txtUserName.Text & _
                                         "; Password: " & Me.txtPassword.Text & _
                                         " - SUCCESSFUL! "

            myServer.Send(myMessage)
            MsgBox("Sent")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Open in new window

0
New feature and membership benefit!
LVL 10
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

If I remember correctly hen I was sitting in math classes a long time ago, there was a simple rule to establish the number of decimals needed to keep accuracy.

My problem is that I have a number of units and a price (resulting in a market value).

For example, if I have 3,976,796.834 units and the price is 10.052580533713, the resulting MV will be 39,977,070.4400.

Now I need to define how many digits I will need to keep (and I cannot keep 12) in order to keep the most accurate value.
0
I have msdn license on dynamics crm 2016
and want to find out the cost of hosting in azure
Or hosting using local vendor.

Of course, azure will be the best but not sure how to install dynamics and most important is the cost.

If anyone has been facing this and tell me more. I will be very appreciate

Thanks
0
Hi ,

I want suggestions to refactor the below code. The code is small.

1. map is a key value Dictionary Object. This populated from backend.
2. IEnumerable<SdtBlock> ccBlocks  [is Ienumerable collection]     . Content Control from Word file
3. IEnumerable<SdtRun> ccRuns       [is Ienumerable collection]    . Content Control from Word file

Each map item.Key can be Either ccBlocks or ccRun.

Based on map item.Value I need to perform actions.
Any recommendation is appreciated, you can point out if anything looks incorrect or adding property or sub function to make code leaner.

Thanks in advance

using (WordprocessingDocument myDoc = WordprocessingDocument.Open(destFilename, true))
            {
                MainDocumentPart mainPart = myDoc.MainDocumentPart;
                DocumentFormat.OpenXml.Wordprocessing.Document bodyDoc = mainPart.Document;
                IEnumerable<SdtBlock> ccBlocks = bodyDoc.Descendants<SdtBlock>();
                IEnumerable<SdtRun> ccRuns = bodyDoc.Descendants<SdtRun>();

                foreach (var item in cBO.map)
                {
                    
                    SdtBlock myBlock = ccBlocks.FirstOrDefault(ccb => ccb.Descendants<SdtAlias>().FirstOrDefault().Val == item.Key);
                    SdtRun myRun = ccRuns.FirstOrDefault(ccb => ccb.Descendants<SdtAlias>().FirstOrDefault().Val == item.Key);
                  
                    Text textContent=new Text();
                    if (myBlock != null)
 

Open in new window

0
I have a SQL database using various models including Customer, Meeting, and Attachment. I have controllers set up for each one of those models. Everything is working great in the navigation properties and links.

I am working off a database that was created before my time. It is used by a custom application that I am replacing with an ASP.NET MVC website. The Attachment table has the columns: Id, Path, Name, Meeting. The path is a location to a share on our network. Rather than listing the path on the webpage, I would like the name of the Attachment in the Meetings/Details view to hyperlink to the location on the network share. I am perplexed on how to set this up.

I would also like the Meetings view to have a link to upload an attachment.

I have attached a screenshot of the model diagram. Model
This is what I have for my CustomersController:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using WoodTrustCRM.Models;

namespace WoodTrustCRM.Controllers
{
    public class CustomersController : Controller
    {
        private WoodTrustCRMEntities db = new WoodTrustCRMEntities();

        // GET: Home - this is a view I created
        public ActionResult Home()
        {
            return View();
        }

        ////default GET: Customers
        //public ActionResult Index()
        //{
        //    return 

Open in new window

0
We are currently running VS Team Explorer 2017 (Version 15.2) in a Citrix environment.  This is running on 2012r2.  We have multiple users that run the system and a few are seeing issues with the application crashing within about 30 seconds after starting up.  It does not appear to be the application directly, but maybe something related to it.  The application actually starts, and if you click fast enough you can actually do things, but after about 30 seconds or so, we get a crash and it closes.

This does not effect all users, just a few.  We have tried resetting their Visual studio parts in the Registry, and Appdata folders, as well as even taking it as far as resetting their profile.  

In the logs I get a .NET crash, and then the Application Error.

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
   at System.Security.AccessControl.CommonAcl.ThrowIfNotCanonical()
   at System.Security.AccessControl.CommonAcl.AddQualifiedAce(System.Security.Principal.SecurityIdentifier, System.Security.AccessControl.AceQualifier, Int32, System.Security.AccessControl.AceFlags, System.Security.AccessControl.ObjectAceFlags, System.Guid, System.Guid)
   at System.Security.AccessControl.DiscretionaryAcl.AddAccess(System.Security.AccessControl.AccessControlType, System.Security.Principal.SecurityIdentifier, Int32, …
0
Using DirectoryServices.DirectoryEntry class I'm trying to remove a user entry from a group in active directory using C# .NET

I came across two ways of doing that,

First way:

DirectoryEntry directoryEntry = new DirectoryEntry(myGroupPath);
directoryEntry.Properties["member"].Remove(userDistinguishedName);
directoryEntry.CommitChanges();


Second way

DirectoryEntry directoryEntry = new DirectoryEntry(myGroupPath);
directoryEntry.Invoke("Remove", userDistinguishedName);



Acording to the msdn Invoke documentation, it says that Invoke Calls a method on the native Active Directory Domain Services object. How is it different than the first way?
0
I am fairly new to nHibernate and its the ORM of choice of the company I am working with.  I have created a new stored procedure that will get the data in one request rather than loop through and do upto 200 - 400 seperate databsase calls.  In doing so, this now needs a new process.  As nHibernate it the product of choice I thought it would be better to keep it as a standard.

So.. below is the structure that I have in place, i have changed schema to dbo and namespaces to xxx to keep identities simple and anonymous. Everything else is actual code and what I need help with.

The problem I get is when I try and complete the call to the stored procedure I get the error

Error message

could not execute query
[ exec dbo.sp_GET_BRANCH_ADDRESSES_AND_COPY_OPTIONS @p0 ]
  Name:MainDealer - Value: xxxxxxxx
[SQL: exec dbo.sp_GET_BRANCH_ADDRESSES_AND_COPY_OPTIONS @p0]

Inner Exception

{"MainDealer2_0_"}

Stack Trace

[IndexOutOfRangeException: MainDealer2_0_]
   System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +1754202
   System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +101
   NHibernate.Driver.NHybridDataReader.GetOrdinal(String name) +11
   NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name) +43
   NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner) +21
   NHibernate.Type.AbstractType.Hydrate(IDataReader
0
Dear,
I do not know why event cannot be fired below, after having clicked the button.

<input type="submit" name="LoginButton" value="登录" id="LoginButton" class="LoginButton" onclick="LoginButton_Click" style="font-weight: bold; position:fixed; top:30%;left:50%; z-index:1000"/>

Open in new window

0
Hi Experts,

How do I get the current Windows Region Format, e.g "French (France)" ?

Regards,
Leigh
0
Efficient way to get backups off site to Azure
LVL 1
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Hi-

I want to know how to remove temp files after Response.End

If I add File.Delete(prcss_docPath) in the finally the download does not complete.

        string srcTemplate = String.Empty;
        string prcss_docPath = String.Empty;
        string dnNo = String.Empty;
        try
        {
             srcTemplate    = "FileSrc.docx"
            prcss_docPath = "File.docx";
            bool processed = false;
            File.Copy(srcTemplate, prcss_docPath, false);
            ContractProcess cps = new ContractProcess();
            processed = cps.ParseWordTemplate(prcss_docPath, dnNo);

            if (processed)
            {
                Response.Clear();
                 FileInfo file = new FileInfo(prcss_docPath);
                Response.ContentType = "Application/msword";
                Response.AppendHeader("Content-Disposition", "inline; filename=" + file.Name);
                Response.AppendHeader("Content-Length", file.Length.ToString());
                Response.Flush();
                Response.TransmitFile(prcss_docPath);
                Response.End();
                Response.Close();
            }
        }
        finally //Delete the files.
        {

         }

Open in new window

0
In eclipse when i selected a method and do control+alt+H i get
An internal error occurred during: "Fetching children of orchestrate".
GC overhead limit exceeded

how to resolve this error. please advise
0
Hello,
How can i convert this functon compatible to listview
 Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
        If e.Button = MouseButtons.Left Then
            Dim pt As New Point(e.X, e.Y)
            startIndex = ListBox1.IndexFromPoint(pt)

            If startIndex >= 0 Then
                Dim itemRc As Rectangle = ListBox1.GetItemRectangle(startIndex)
                startPoint = ListBox1.PointToScreen(New Point(ListBox1.Width, itemRc.Top + (itemRc.Bottom - itemRc.Top) / 2))
                endPoint = startPoint
                lastIndex = -1
                ListBox1.DoDragDrop(ListBox1.Items(startIndex).ToString(), DragDropEffects.Move)
            End If
        End If
    End Sub

Open in new window



  Private Sub ListBox2_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragOver
        Dim lbPoint As Point = ListBox2.PointToClient(New Point(e.X, e.Y))
        Dim index As Integer = ListBox2.IndexFromPoint(lbPoint)
        If index >= 0 Then
            ListBox2.SelectedIndex = index
            Dim itemRc As Rectangle = ListBox2.GetItemRectangle(index)
            Dim key As String
            If lastIndex <> index Then
                If lastIndex <> -1 Then
                    key = startIndex & "|" & lastIndex
                    If Not connections.ContainsKey(key) Then
                        ControlPaint.DrawReversibleLine(startPoint, endPoint, Panel1.BackColor)
                    End If
                End If
                key = startIndex & "|" & index
                If Not connections.ContainsKey(key) Then
                    endPoint = ListBox2.PointToScreen(New Point(0, itemRc.Top + (itemRc.Bottom - itemRc.Top) / 2))
                    ControlPaint.DrawReversibleLine(startPoint, endPoint, Panel1.BackColor)
                End If
                lastIndex = index
            End If
        End If
    End Sub

Open in new window


  Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
        Try

            Dim endIndex As Integer = ListBox2.IndexFromPoint(ListBox2.PointToClient(New Point(e.X, e.Y)))
            If endIndex >= 0 Then
                connections.Add(startIndex & "|" & endIndex, Nothing)
            End If
            Panel1.Refresh()
        Catch ex As Exception
            Exit Sub
        Finally
            Panel1.Refresh()
        End Try

    End Sub

Open in new window


ListBox2.GetItemRectangle(index)
GetitemRectangle,IndexFromPoint is not a part of listview
0
Hello,
Need some advice on how to create a program that can draw data model?
This works but,need to use datagridview
https://www.experts-exchange.com/questions/21540913/Need-some-advice-on-how-to-create-a-program-that-can-draw-data-model.html


Any suggestions are appreciated.

Cheers
0
Hello,
How can I have a multicolumn bound listbox .
Bound to datatable
I am using vb.net desktop.
0
rest web services Standard vs business exception differences not clear. when to use which one and how. Both seems almost same to me in terms of error handling
 please advise​
0

.NET Programming

132K

Solutions

38K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.