mardi 4 août 2015

Internal Webservice IIS .NET

We have two sites on one IIS 7.5 server. Site B needs to talk to Site A through a SOAP service (Site B used to be external hence using SOAP, but now they are on the same server).

How can I reference Site A in Site B's web config without having a roundtrip through the absolute path http://ift.tt/1Dqg84B?

Essentially I want

      <endpoint address="foolocalhost/webservice/endpoint.asmx"
    binding="basicHttpBinding" bindingConfiguration="WebServiceSoap"
    contract="Reference.WebServiceSoap" name="WebServiceSoap" />

Rather than

      <endpoint address="http://ift.tt/1Dqg84B"
    binding="basicHttpBinding" bindingConfiguration="WebServiceSoap"
    contract="Reference.WebServiceSoap" name="WebServiceSoap" />

Would I need to change my host file to set foolocalhost up as a binding? Or is there an easier way around it using just the IIS GUI?



via Chebli Mohamed

Azure Web App switches server automatically?

We have a website running in azure as a Web App. Only 1 instance of the site is running. We are seeing regular downtimes for the site, and wondering why.

We use Elmah to log exceptions, and before a downtime occurs we can't see any relevant or critical errors. What we do see however, is that AFTER the downtime, the site is back up but on another server. (We can see this because the hostname of the server changes, and when an exception is thrown we can see in Elmah from which server it originated.) Small example:

Server: X
Some small Exception thrown on server X, shows up in Elmah
site goes down
Site comes back up
Server: Y
Some small exception thrown on server Y, shows up in Elmah

Now I know that azure has Rapid Fail Protection and Auto Healing, but in our scenario, I cant tell the difference between our site

a) moving to another server and going down (because there is only 1 instance)

b) rapid fail protection or auto healing kicking in

If it's option a: does anyone know based on what azure moves sites?

if it's option b: does anyone know how I can determine why/how something triggered a rapid fail protection or auto healing kick in?



via Chebli Mohamed

Given a string with day of week, return integer

Is there a way to have something like:

string day = "Sunday";
int num = getDayOfWeek(day); //returns 0

I understand we could something like, and I wanted the reverse:

int num = 0;

//returns "Sunday"
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.DayNames[(int)i] 

The easiest way would probably be to implement a dictionary that does what I am asking, but I wonder if there is something in C# DateTime functions that already does so for me.



via Chebli Mohamed

Implementing Tracing in VB .Net App

This is my fist attempt to get tracing up and running in a multi-class application. The examples I've followed and had success with aren't translating to the app I need to trace. I've read up on SO, MSDN and elsewhere, still missing something. Here's a snip of the code that's not generating anything in logs:

Imports System.Windows.Forms
Imports Inventor
Imports System.Runtime.InteropServices
Imports tankBuilder.MainForm
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System

Namespace tankBuilder
    <ProgIdAttribute("singleCourseMasterTank.StandardAddInServer"), _
    GuidAttribute("70f8dedc-4ae1-4bb9-be6b-c275afcd1333")> _
    Public Class StandardAddInServer
    Implements Inventor.ApplicationAddInServer
    Friend Shared PI As Double = 3.14159
    Friend Shared Tracer As New TraceSource("TraceSource1")
    ... logic...
Tracer.TraceInformation("Informational message.")
Tracer.TraceEvent(TraceEventType.Error, 1, "Error message.")
Tracer.TraceEvent(TraceEventType.Warning, 2, "Warning message.")

Here's the corresponding section from app.config

<system.diagnostics>
   <sources>
     <source name="TraceSource1"
       switchName="sourceSwitch"
       switchType="System.Diagnostics.SourceSwitch">
       <listeners>
         <add name="console"
           type="System.Diagnostics.ConsoleTraceListener">
           <filter type="System.Diagnostics.EventTypeFilter"
             initializeData="Error"/>
         </add>
         <add name="prodListener"
           type="System.Diagnostics.TextWriterTraceListener"
           initializeData="C:\Data\Projects\trace.log">
         </add>
         <remove name="Default"/>
       </listeners>
     </source>
   </sources>
   <switches>
     <add name="sourceSwitch" value="4"/>
   </switches>
</system.diagnostics>

Thanks so much in advance!



via Chebli Mohamed

Modifying a list from another form

I am trying to set up a list in C# and I want it so that when I press the an add button it will open a window with fields where I can enter data press and ok button and then have those text box fields transferred into the list. This is my code for the popup form.

public partial class addtoLibraryDialog : Form
{
    public addtoLibraryDialog()
    {
        InitializeComponent();
    }


    private void btnOK_Click(object sender, EventArgs e)
    {
        ListViewItem list = new ListViewItem("name");
        list.SubItems.Add("path");
        listView1.Items.Add(list);
    }
}

And I was wondering how I can make it so the listview1 is recognised. I have found information on this outline but as I am new to programming I can't really make heads of tails of them.



via Chebli Mohamed

dimanche 28 juin 2015

Executing non-database actions in a transaction in Slick 3

I'm having trouble understanding the new Slick DBIOAction API, which does not seem to have a lot of examples in the docs. I am using Slick 3.0.0, and I need to execute some DB actions and also some calculations with the data received from the database, but all of those actions have to be done inside a single transaction. I'm trying to do the following:

  1. Execute a query to database (the types table).
  2. Do some aggregations and filtering of the query results (this calculation can't be done on the database).
  3. Execute another query, based on the calculations from step 2 (the messages table — due to some limitations, this query has to be in raw SQL).
  4. Join data from step 2 and 3 in memory.

I want the queries from step 1 and 3 to be executed inside a transaction, as the data from their result sets has to be consistent.

I've tried to do this in a monadic join style. Here's an overly simplified version of my code, but I can't even get it to compile:

  val compositeAction = (for {
    rawTypes <- TableQuery[DBType].result
    (projectId, types) <- rawTypes.groupBy(_.projectId).toSeq.map(group => (group._1, group._2.slice(0, 10)))
    counts <- DBIO.sequence(types.map(aType => sql"""select count(*) from messages where type_id = ${aType.id}""".as[Int]))
  } yield (projectId, types.zip(counts))).transactionally

  1. The first row of for comprehension selects the data from the types table.
  2. The second row of for comprehension is supposed to do some grouping and slicing of the results, resulting in a Seq[(Option[String], Seq[String])]
  3. The third row of for comprehension has to execute a set of queries for every element from the previous step, in particular, it has to execute a single SQL query for each of the values inside Seq[String]. So in the third row I build a sequence of DBIOActions.
  4. The yield clause zips types from the second step and counts from the third step.

This construction, however, does not work and gives two compile time errors:

Error:(129, 16) type mismatch;
 found   : slick.dbio.DBIOAction[(Option[String], Seq[(com.centreit.proto.repiso.storage.db.models.DBType#TableElementType, Vector[Int])]),slick.dbio.NoStream,slick.dbio.Effect]
    (which expands to)  slick.dbio.DBIOAction[(Option[String], Seq[(com.centreit.proto.repiso.storage.db.models.TypeModel, Vector[Int])]),slick.dbio.NoStream,slick.dbio.Effect]
 required: scala.collection.GenTraversableOnce[?]
        counts <- DBIO.sequence(types.map(aType => sql"""select count(*) from messages where type_id = ${aType.id}""".as[Int]))
               ^
Error:(128, 28) type mismatch;
 found   : Seq[Nothing]
 required: slick.dbio.DBIOAction[?,?,?]
        (projectId, types) <- rawTypes.groupBy(_.projectId).toSeq.map(group => (group._1, group._2.slice(0, 10)))
                           ^

I've tried to wrap the second line in a DBIOAction by using DBIO.successful, which is supposed to lift a constant value into the DBIOAction monad:

(projectId, types) <- DBIO.successful(rawTypes.groupBy(_.projectId).toSeq.map(group => (group._1, group._2.slice(0, 10))))

But in this code the types variable is inferred to be Any, and the code does not compile because of that.

Full Export in PHPMyAdmin Problems

So today i was switching to my new webserver and when i backed up my mysql databases a did a full export.... is there anyway to import my full.sql file and still have all the databases separate and not all in one database?