Click here to Skip to main content
15,885,906 members
Home / Discussions / C#
   

C#

 
GeneralRe: Printing Persian Words Pin
Keith Barrow5-Oct-12 9:06
professionalKeith Barrow5-Oct-12 9:06 
QuestionOleDbException : SQL: Column 'Q0P2' is not found [update dbf free tables from oledbdataadapter] Pin
Paramu19735-Oct-12 0:45
Paramu19735-Oct-12 0:45 
AnswerRe: OleDbException : SQL: Column 'Q0P2' is not found [update dbf free tables from oledbdataadapter] Pin
Eddy Vluggen5-Oct-12 1:34
professionalEddy Vluggen5-Oct-12 1:34 
GeneralRe: OleDbException : SQL: Column 'Q0P2' is not found [update dbf free tables from oledbdataadapter] Pin
Paramu19735-Oct-12 2:10
Paramu19735-Oct-12 2:10 
GeneralRe: OleDbException : SQL: Column 'Q0P2' is not found [update dbf free tables from oledbdataadapter] Pin
Eddy Vluggen5-Oct-12 2:13
professionalEddy Vluggen5-Oct-12 2:13 
GeneralRe: OleDbException : SQL: Column 'Q0P2' is not found [update dbf free tables from oledbdataadapter] Pin
Paramu19735-Oct-12 2:23
Paramu19735-Oct-12 2:23 
GeneralRe: OleDbException : SQL: Column 'Q0P2' is not found [update dbf free tables from oledbdataadapter] Pin
Eddy Vluggen5-Oct-12 2:24
professionalEddy Vluggen5-Oct-12 2:24 
QuestionAssistence required with this spacific Program Pin
Cihangir Giray Han4-Oct-12 22:01
Cihangir Giray Han4-Oct-12 22:01 
The other day I have asked a question about a program which sits in a place where images come and once its started, function is that it updates when a new image is added, I have found a relevant code for this but I would like to know that would this do the desired task which I require. Appreciate any assistance.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foundation;
using System.IO;
using System.Data.SqlClient;
using System.Data;
using System.Threading;
using WindowsFormsApplication1;

namespace HotFolderLoader
{
class Program
{
//private BaseFuncs theBaseFuncs = new BaseFuncs();

static void Main(string[] args)
{

string tt = System.Environment.MachineName;
Foundation.BaseFuncs theFoundation = new BaseFuncs();

if (tt == "NEO") //devel
{
//Foundation.getConstr.initialize("Data Source=neo\\neosqlserver;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=xxxxxx");
Foundation.getConstr.initialize("Data Source=xx.xxx.xxx.xxx\\bcwebsql;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=mr2BCweb");
//Foundation.getConstr.initialize("Data Source=xxx.xx.xxx.xxx\\nmcsql;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=xxxxx");
}
else
{
Foundation.getConstr.initialize("Data Source=xx.xxx.xxx.xxx\\bcwebsql;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=xxxxx");
}


//CCaseObject gg = new CCaseObject("test1-lil");
int idx = 0;
while (true)
{
System.Console.WriteLine("Starting");
doWork();
idx++;
System.Console.WriteLine("parsing: " + idx.ToString());
Thread.Sleep(80 * 1000);
}

}

public static void doWork()
{
BaseFuncs theBaseFuncs = new Foundation.BaseFuncs();
//D:\Google Drev\CloudHotFolder
//E:\google-drive\Google Drive\CloudHotFolder
DirectoryInfo dirInfo = new DirectoryInfo(@"D:\Google Drev\CloudHotFolder");
//DirectoryInfo dirInfo = new DirectoryInfo(@"E:\google-drive\Google Drive\CloudHotFolder");
FileInfo[] files = dirInfo.GetFiles("*.jpg");
string caseno = "";
string imageType = "";
string previousCaseno = "";
int i = 0;

System.Console.WriteLine("files: " + files.Count().ToString());
while (i < files.Count())
{

FileInfo fileItem = files[i];
bool nameOK = true;
bool isError = fileItem.Name.Contains("Error");
string[] fileData = fileItem.Name.Split('#');
if (fileData.Length < 2)
{
nameOK = false;
}
else
{
caseno = fileData[1];
imageType = fileData[2];
}
System.Console.WriteLine("parsing file: " + fileItem.FullName);
/*
* photo_org = 1,
floor_plan_org = 2,
Panorama_360 = 3,
photo_stage_2 = 4,
floor_plan_stage_2 = 5,
photo_thumbnail = 6,
Panorama_360_stage_2 = 7,
photo_final = 8,
floor_plan_final = 9,
Panorama_360_final = 10,
deleted = 11,
junk = 12,
visual_tour_org = 12,
visual_tour = 13
* */
string imgtypeid = "";
bool typeOK = true;
bool caseOK = true;

switch (imageType)
{
case "1":
case "4":
imgtypeid = "4"; //photo stage 2
break;

case "2":
case "5":
imgtypeid = "5"; //floor plan stage 2
break;

case "3":
case "7":
imgtypeid = "7";
break;

default:
typeOK = false;
break;
}

string sql = "select count(id) from cases where caseno ='" + caseno + "'";
string casecount = theBaseFuncs.doSQLScalar(sql);
if (casecount != "1")
{
caseOK = false;
}

if (typeOK && !isError && caseOK && nameOK)
{

try
{ //(expiryDate - DateTime.Now).Days < 30
if ((DateTime.Now - fileItem.LastAccessTime).Minutes > 1 && fileItem.Length > 10)
{

//check if filename exists
string checkSql = "select count (id) from images where case_id=" + theBaseFuncs.getCaseIDByCaseNo(caseno) + " and image_name='" + fileItem.Name + "'";
int count = Convert.ToInt16(theBaseFuncs.doSQLScalar(checkSql));

if (count > 0)
{
//delete image in db - and then normal upload new version
System.Console.Write("Deleting " + fileItem.Name + "in DB");
string delImages = "delete from images where case_id=" + theBaseFuncs.getCaseIDByCaseNo(caseno) + " and image_name='" + fileItem.Name + "'";
theBaseFuncs.doSQLnonQuery(delImages);
System.Console.Write("...Done");
}

int picID = theBaseFuncs.saveIMG2DB(fileItem, fileItem.Name, "image/jpeg", caseno, imgtypeid, 5, false);
SqlConnection connection = new SqlConnection("Data Source=xx.xxx.xxx.xxx\\bcwebsql;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=xxxxx");
System.Drawing.Image img = System.Drawing.Image.FromFile(fileItem.FullName);

//System.Drawing.Image thumbImg = createHQThumb(fullImg, xparm);
string strSql = "UPDATE Images set Image_Data_Thumb=@imagedata ";
strSql += "where id=@picid";
SqlCommand updatecmd = new SqlCommand(strSql, connection);
updatecmd.CommandType = CommandType.Text;
SqlParameter pImg = new SqlParameter("@imagedata", SqlDbType.Image);
pImg.Value = BaseFuncs.imageToByteArray(BaseFuncs.createHQThumb(img, 600));
img.Dispose();
updatecmd.Parameters.Add(pImg);
SqlParameter pPicid = new SqlParameter("@picid", SqlDbType.Int);
pPicid.Value = picID;
updatecmd.Parameters.Add(pPicid);
connection.Open();
updatecmd.ExecuteNonQuery();
fileItem.Delete();
connection.Close();

//System.Console.WriteLine("counter: i=" + i.ToString() + " max=" + files.Count().ToString());

}
if (caseno != previousCaseno || i == files.Count() - 1) //do target check
{
if (i == files.Count())
{
System.Console.WriteLine("swapping caseno - lastfile in list!");
previousCaseno = caseno;
}
System.Console.Write("Making target check case: " + previousCaseno);
theBaseFuncs.logStatus(theBaseFuncs.getCaseIDByCaseNo(caseno), 3, 36, "Hotfolder target check");
if (theBaseFuncs.targetImgCheck(previousCaseno) == 1 && theBaseFuncs.targetPlanCheck(previousCaseno) == 1)
{
System.Console.Write("...target match");
Foundation.CCaseObject theCase = new Foundation.CCaseObject(previousCaseno);
theBaseFuncs.logStatus(theCase.CaseID, 3, 36, "Hotfolder target OK");
theCase.sendToNaming();
System.Console.Write("...case sent!!!!!!!!\n");
}
else
{
theBaseFuncs.logStatus(theBaseFuncs.getCaseIDByCaseNo(caseno), 3, 36, "Hotfolder target not OK");
System.Console.Write(".no match!\n");

}

}
previousCaseno = caseno;
}
catch (Exception ex)
{
string gg = ex.Message;
throw;
}
}
else
{
if (!isError)
{
fileItem.MoveTo(fileItem.FullName + ".type_error");
}

if (!caseOK)
{
fileItem.MoveTo(fileItem.FullName + ".caseno_error");
}

if (!nameOK)
{
fileItem.MoveTo(fileItem.FullName + ".navngivning_error");
}
}
i++;
}
}

}
}

modified 5-Oct-12 4:08am.

AnswerRe: Assistence required with this spacific Program Pin
Richard MacCutchan4-Oct-12 23:04
mveRichard MacCutchan4-Oct-12 23:04 
AnswerRe: Assistence required with this spacific Program Pin
V.5-Oct-12 0:41
professionalV.5-Oct-12 0:41 
QuestionHow to configure post-build events for setup/deployment projects in Visual Studio Pin
Tridip Bhattacharjee4-Oct-12 21:25
professionalTridip Bhattacharjee4-Oct-12 21:25 
AnswerRe: How to configure post-build events for setup/deployment projects in Visual Studio Pin
Richard MacCutchan4-Oct-12 21:50
mveRichard MacCutchan4-Oct-12 21:50 
GeneralRe: How to configure post-build events for setup/deployment projects in Visual Studio Pin
Tridip Bhattacharjee6-Oct-12 7:07
professionalTridip Bhattacharjee6-Oct-12 7:07 
GeneralRe: How to configure post-build events for setup/deployment projects in Visual Studio Pin
Richard MacCutchan6-Oct-12 7:18
mveRichard MacCutchan6-Oct-12 7:18 
QuestionBasic Polymorphism Problem Pin
AmbiguousName4-Oct-12 18:54
AmbiguousName4-Oct-12 18:54 
AnswerRe: Basic Polymorphism Problem Pin
DaveyM694-Oct-12 20:29
professionalDaveyM694-Oct-12 20:29 
AnswerRe: Basic Polymorphism Problem Pin
AmbiguousName4-Oct-12 20:56
AmbiguousName4-Oct-12 20:56 
GeneralRe: Basic Polymorphism Problem Pin
DaveyM694-Oct-12 21:35
professionalDaveyM694-Oct-12 21:35 
AnswerRe: Basic Polymorphism Problem Pin
AmbiguousName4-Oct-12 21:45
AmbiguousName4-Oct-12 21:45 
GeneralRe: Basic Polymorphism Problem Pin
DaveyM694-Oct-12 22:18
professionalDaveyM694-Oct-12 22:18 
AnswerRe: Basic Polymorphism Problem Pin
BobJanova5-Oct-12 0:52
BobJanova5-Oct-12 0:52 
GeneralRe: Basic Polymorphism Problem Pin
DaveyM695-Oct-12 1:19
professionalDaveyM695-Oct-12 1:19 
GeneralRe: Basic Polymorphism Problem Pin
BobJanova5-Oct-12 3:04
BobJanova5-Oct-12 3:04 
QuestionC# linq group by Pin
rachel_m4-Oct-12 17:43
rachel_m4-Oct-12 17:43 
AnswerRe: C# linq group by Pin
OriginalGriff4-Oct-12 23:19
mveOriginalGriff4-Oct-12 23:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.