|
You know, I'm fairly good with MVC 4 Web Services. Any reason I shouldn't use that?
If it's not broken, fix it until it is
|
|
|
|
|
No, I think that's a good idea. If your server talks JSON, you could also use it with native mobile clients.
/ravi
|
|
|
|
|
Agreed. And it should be fairly simple.
If it's not broken, fix it until it is
|
|
|
|
|
Have you considered using a Jabber server instead of writing one from scratch?
/ravi
|
|
|
|
|
Kevin Marois wrote: I'm fairly good with MVC 4 Web Services
Then it might be a good opportunity to teach rather than learn. 
|
|
|
|
|
The part I'm not sure about is getting notifications in the client from the Server.
Ever done this?
If it's not broken, fix it until it is
|
|
|
|
|
Details. Details. Don't bother me with details.
(I don't even know what MVC 4 is.)
|
|
|
|
|
Several years ago I wrote one that was just WinForms-to-SQL-Server, then I started working on a WCF service for it (again, it was quite a while ago), but since then it has stagnated. It's something I'd like to finish for an article.
Calling it a "chat app" isn't terribly accurate, as it is something between that and a simple e-mail system. It supports message threads (like forum posts here on CP) and delayed delivery for recipient(s) who are offline.
Kevin Marois wrote: as a learning experience
Should be a good way to learn the communication framework du jour and allow clients to be created for a number of devices.
|
|
|
|
|
I'm thinking I could create a Web API that maintains a list of Conversations. Each Conversation would have a unique Id and a list of Participants.
The only problem I see is the API notifying clients that they have a message. I'm guessing a callback of some sort would do the trick.
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: Each Conversation would have a unique Id and a list of Participants.
I put it in a database. Each message has its own ID, the ID of its parent, and the ID of the first message in the thread. Each message also has its own set of recipients (many-to-many relationship between Message and User). The client could then display each message as it arrives, or show the entire thread in a TreeView.
Kevin Marois wrote: API notifying clients
"Push" sucks; always has, always will. I always use polling; it allows the client/user to control frequency or even disable polling altogether. I also put in a "get messages now" feature. The server should only handle requests as they are made and not try to keep track of all the possible connections or it won't scale well. You probably also don't want to waste cycles re-trying broadcasts to clients that have lost connectivity. If no one is asking for data, don't try to send it; just wait.
|
|
|
|
|
Ok but with polling the client would have to make queries every 2 or 3 seconds to get close to real time
If it's not broken, fix it until it is
|
|
|
|
|
Yes, only as frequently as the user wants.
|
|
|
|
|
SignalR will be a better component for a chat application. I done a real-time time application with SignalR.. Its very interesting 
|
|
|
|
|
Except is seems to be designed around ASP.Net. My usage will NOT be asp.Net
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: My usage will NOT be asp.Net
So what language are you going to use?
|
|
|
|
|
Language? C#
ASP.Net is not a language. It's a Web Development platform
If it's not broken, fix it until it is
|
|
|
|
|
my bad.. forgot the forum title .. thought about PHP and Java .. apologies
|
|
|
|
|
Please can somebody help I'm struggling to display the thumbnailPhoto attribute in Active Directory on my gridview website.
Please find below the code and asp.net files
<%@ Page Title="AD USERS" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" Inherits="_Default" Codebehind="Default.aspx.cs" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<table cellpadding="4" cellspacing="4" width="90%" align="center" style="border: 1px solid Green;">
<tr>
<td>
<asp:GridView ID="grdViewAllADSUsers" runat="server" AllowPaging="True" CellPadding="4"
Width="98%" ForeColor="#333333" GridLines="None" OnPageIndexChanging="grdViewAllADSUsers_PageIndexChanging">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
<Columns>
<asp:ImageField DataImageUrlField="thumbnailPhoto" HeaderText="Image">
<ControlStyle Height="48px" Width="50px" />
</asp:ImageField>
<asp:BoundField DataField="displayName" HeaderText="Name" />
<asp:BoundField DataField="title" HeaderText="Job title" />
<asp:BoundField DataField="mail" HeaderText="E-mail" />
<asp:BoundField DataField="telephonenumber" HeaderText="Telephone Number" />
<asp:BoundField DataField="mobile" HeaderText="Mobile Number" />
<asp:BoundField DataField="facsimileTelephoneNumber" HeaderText="Fax Number" />
<asp:BoundField DataField="department" HeaderText="Department" />
<asp:BoundField DataField="manager" HeaderText="Manager" />
<asp:BoundField DataField="st" HeaderText="Car Registration" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</asp:Content>
C# code:
using System;
using System.Drawing;
using System.IO;
using System.Data.SqlTypes;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
using System.Web.Security;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
GetAllADUsers();
}
public void GetAllADUsers()
{
try
{
DirectoryEntry myLdapConnection = createDirectoryEntry();
DirectorySearcher search = new DirectorySearcher(myLdapConnection);
search.Filter = "(&(objectClass=user)(objectCategory=person)(!sAMAccountType=805306370)(!userAccountControl:1.2.840.113556.1.4.803:=2)(description=Exchange User))";
search.SearchScope = SearchScope.Subtree;
search.PropertiesToLoad.Add("thumbnailPhoto");
search.PropertiesToLoad.Add("samaccountname");
search.PropertiesToLoad.Add("displayName");
search.PropertiesToLoad.Add("title");
search.PropertiesToLoad.Add("mail");
search.PropertiesToLoad.Add("telephoneNumber");
search.PropertiesToLoad.Add("mobile");
search.PropertiesToLoad.Add("facsimileTelephoneNumber");
search.PropertiesToLoad.Add("department");
search.PropertiesToLoad.Add("manager");
search.PropertiesToLoad.Add("st");
search.CacheResults = true;
SearchResultCollection allResults = search.FindAll();
DataTable resultsTable = new DataTable();
foreach (String colName in search.PropertiesToLoad)
{
if (colName == "thumbnailPhoto")
resultsTable.Columns.Add(colName, typeof(System.Drawing.Bitmap));
else
resultsTable.Columns.Add(colName,typeof(String));
}
resultsTable.Columns.Remove("ADsPath");
resultsTable.Columns.Remove("samaccountname");
foreach (SearchResult searchResult in allResults)
{
DataRow dr = resultsTable.NewRow();
if (searchResult.Properties.Contains("thumbnailPhoto"))
{
dr["thumbnailPhoto"] = byteArrayToImage((byte[])searchResult.Properties["thumbnailPhoto"][0]);
//byte[]staffPic = ((byte[])searchResult.Properties["thumbnailPhoto"][0]);
//Response.BinaryWrite(staffPic);
//Response.Flush();
//dr["thumbnailPhoto"] = GetUserPicture(searchResult.Properties["samaccountname"][0].ToString());
}
if (searchResult.Properties.Contains("displayName"))
dr["displayName"] = searchResult.Properties["displayName"][0].ToString();
if (searchResult.Properties.Contains("title"))
dr["title"] = searchResult.Properties["title"][0].ToString();
if (searchResult.Properties.Contains("mail"))
dr["mail"] = searchResult.Properties["mail"][0].ToString();
if (searchResult.Properties.Contains("telephoneNumber"))
dr["telephoneNumber"] = searchResult.Properties["telephoneNumber"][0].ToString();
if (searchResult.Properties.Contains("mobile"))
dr["mobile"] = searchResult.Properties["mobile"][0].ToString();
if (searchResult.Properties.Contains("facsimileTelephoneNumber"))
dr["facsimileTelephoneNumber"] = searchResult.Properties["facsimileTelephoneNumber"][0].ToString();
if (searchResult.Properties.Contains("department"))
dr["department"] = searchResult.Properties["department"][0].ToString();
if (searchResult.Properties.Contains("manager"))
{
String managerDN = searchResult.Properties["manager"][0].ToString();
String managerFQDN = "LDAP://" + managerDN;
DirectoryEntry manager = new DirectoryEntry(managerFQDN);
dr["manager"] = manager.Properties["displayName"][0].ToString();
}
if (searchResult.Properties.Contains("st"))
dr["st"] = searchResult.Properties["st"][0].ToString();
resultsTable.Rows.Add(dr);
}
grdViewAllADSUsers.DataSource = resultsTable;
grdViewAllADSUsers.ShowHeader = true;
grdViewAllADSUsers.AutoGenerateColumns = false;
grdViewAllADSUsers.DataBind();
}
catch (Exception)
{
}
}
public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
return ms.ToArray();
}
public System.Drawing.Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
return returnImage;
}
static System.Drawing.Image GetUserPicture(string userName)
{
using (DirectorySearcher dsSearcher = new DirectorySearcher())
{
dsSearcher.Filter = "(&(objectClass=user) (cn=" + userName + "))";
SearchResult result = dsSearcher.FindOne();
using (DirectoryEntry user = new DirectoryEntry(result.Path))
{
byte[] data = user.Properties["thumbnailPhoto"][0] as byte[];
if (data != null)
{
using (MemoryStream s = new MemoryStream(data))
{
return System.Drawing.Bitmap.FromStream(s);
}
}
return null;
}
}
}
static DirectoryEntry createDirectoryEntry()
{
// create and return new LDAP connection with desired settings
DirectoryEntry ldapConnection = new DirectoryEntry("my.domain");
ldapConnection.Path = "LDAP://my.domain/OU=Users,OU=Users & Computers,DC=my,DC=domain";
ldapConnection.AuthenticationType = AuthenticationTypes.Secure;
return ldapConnection;
}
protected void grdViewAllADSUsers_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdViewAllADSUsers.PageIndex = e.NewPageIndex;
GetAllADUsers();
}
}
|
|
|
|
|
Can you narrow down where the specific issue is?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I think the problem is here:
if (searchResult.Properties.Contains("thumbnailPhoto"))
{
dr["thumbnailPhoto"] = byteArrayToImage((byte[])searchResult.Properties["thumbnailPhoto"][0]);
}
Or maybe in the asp code.
At the moment I get a table with every field populated how it is intended to be however the thumbnailPhoto field display a image of an X as though it isn't being pulled through.
If I run the command Response.BinaryWrite(staffPic); it displays the image on a complete blank screen.
What I'm trying to do is pull through the thumbnailPhoto pic into the datatable and then onto the gridview
|
|
|
|
|
Hi everybody,
On my Windows Mobile 6.5 application (developped in C# and DOTNET 3.5), I want use a VPN connection. My goals is the following: I connect my PDA on my PC via USB. Then, by clicking on a button of my WinCE application, I would send http request (with the object "HttpWebRequest" of C#) directly on PC (because VPN would be intalled on the PC).
I have already searched a solution of my problem but I have not found a solution.
Have you got an idea to do this?
Best regards
|
|
|
|
|
Wakonda wrote: Have you got an idea to do this? Google for instructions on how to set up VPN.
Wakonda wrote: directly on PC (because VPN would be intalled on the PC). ..if you're trying to talk to the server-VPN using TCP/IP from the mobile device, then that's not going to work. Try talking to a webserver on the PC.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i think you should write another application for your PC also which will receive requests from your windows phone and talk with VPN connection in pc and again send results to your phone but talking directly with windows phone is not a good and practical approach!
|
|
|
|
|
That could also be considered as opening a security hole in the VPN!
|
|
|
|
|
I am trying to move items up and down in generic list but not getting desired results If I have 5 items and and one their be 6 with order id's of 1 to 6 then when i move an item up one position via button click say item 6 it would become 5 and what was at 5 would become 6.
Can Someone help me out here please on the logic below?
ObservableCollection<CustomColumnsModel> columnsList = this.WizardData.ConcreteCustomColumnsProxy;
Extensions.MoveItemUp(columnsList, this.listView1.SelectedIndex);
List<CustomColumnsModel> forUpdate = new List<CustomColumnsModel>();
int offset = 0;
foreach (CustomColumnsModel item in this.listView1.Items)
{
if (this.listView1.SelectedItems.Contains(item))
{
offset++;
item.CustomColumnsOrder--;
}else
item.CustomColumnsOrder += offset;
}
|
|
|
|