anurag.kyal 0 Newbie Poster

I was able to generate a graph successfully using the <asp:Chart> in asp .net with c# code behind feature but a hiccup came in because I want one of my axes to represent TIME which it doesnot seem to support. Are there any alternatives or can I do this : Plot the graph using relative time values and label them with time string? To clarify further, suppose I need to plot:

1. 10:30
2. 12:00
3. 15:30

Then I convert them into minutes relative from 00:00 as 630, 720, 930, Plot them and then label them as strings.

I will be really grateful for any help. It is really eating up my head!

Thanks in Advance :)

anurag.kyal 0 Newbie Poster

beacuse it didnt work that way either.

anurag.kyal 0 Newbie Poster

I want to insert records into the table History and I followed this process I found in some tutorial but I am getting this error. Please help me with this. i am a newbie to c#.

anurag.kyal 0 Newbie Poster
static void Main(string[] args)
        {
            string[,] fp = readFilePaths();
            OleDbConnection con = new OleDbConnection();
            OleDbDataAdapter da;
            DataSet ds = new DataSet();
            con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents and Settings/kyalanur/Desktop/Nav tool/PCGDataManager.mdb;User ID=;Password=;";
            string sq = "SELECT * FROM History";
            con.Open();
            da = new OleDbDataAdapter(sq, con);
            da.Fill(ds, "History");

            for (int i = 0; i < 284; i++)
            {
                if(true)
                {
                    //Enter into the dtabase
                    DataRow dr = ds.Tables["History"].NewRow();
                    dr[0] = DateTime.Today.Date.ToString();
                    dr[0] = fp[i,2];
                    dr[2] = generateFilePath(fp[i, 0], fp[i, 1]);
                    dr[3] = "  ";
                    dr[4] = "  ";
                    dr[5] = fp[i, 3];
                    ds.Tables["History"].Rows.Add(dr);
                    //OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
                    //da.UpdateCommand = cb.GetUpdateCommand();
                    da.Update(ds, "History");
                }
                else
                {

                }
            }
        }
anurag.kyal 0 Newbie Poster

i am not able to map. I used:
Subst K: \\server\file
but it seems it cant find the file.
And yeah, I have a problem using the network path. No implementation issues.
Is any other solution available?
Its urgent. Thanks in advance.

anurag.kyal 0 Newbie Poster

i didnt exactly understand what you meant by mapping.

All i want to do is check if the file exists or not. Will mappping helP?

anurag.kyal 0 Newbie Poster

Code:

FileInfo fi = new FileInfo("\\intranet.xyx.com\abc\efg\def.txt");
if (!fi.Exists)
Console.WriteLine("Doesnt exist!");

Prints doesnt exist whereas this file actually exists. It works fine with files on my computer but.

Is the method to access this file(on the intranet) wrong.

Infact, the VB code for the same:

try
Dim dummy As String = FileSystem.Dir("\\intranet.xyx.com\abc\efg\def.txt") 'This will cause an error if file is missing
System.Console.Write("yay")

Catch ex As Exception
System.Console.Write("NAy")
End Try

Works well!!!

Any help appreciated.. !!!

anurag.kyal 0 Newbie Poster

All I have to do is take an array of n integers and run p threads to sort equally divided p blocks of the same and finally merge them. There is occuring some problem in my code. If I run the threads one by one, by using pthread_join's before next thread, its working all good. This is some trivial error but now I cant give it more. Please help.

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>

void *func_sort(void *ptr);

typedef struct{
    int *arr;
    int n, p, start;
}arg;

main()
{
    pthread_t* th;
    int n, p, *arr, i, j, *fin, *count;
    arg* arg1;
    printf("n=");
    scanf("%d", &n);
    printf("p=");
    scanf("%d", &p);
    arr = (int*) malloc(n*sizeof(int));
    arg1 = (arg*) malloc(sizeof(arg));
    fin = (int*) malloc(n*sizeof(int));
    count = (int*) malloc(p*sizeof(int));
    th = (pthread_t*) malloc(sizeof(pthread_t)*p);

    for(i=0; i<n; i++)
    {
        arr[i] = rand()%1000;
    }
    printf("\nRandom Numbers Generated = %d\n",n);

    for(i=0; i<n; i++)
    {
        printf("%d:%d\n",i,arr[i]);
    }

    arg1->n=n;
    arg1->p=p;
    for(i=0; i<p; i++)
    {   
        count[i] = 0;
        arg1->arr = arr;
        arg1->start = i*(n/p);
        pthread_create(&th[i], NULL, func_sort, (void*)arg1);
    }       

    for(j=0; j<p; j++);
        pthread_join(th[j], NULL);

    printf("\nThreads completed:\n");       

    for(i=0; i<n; i++)
    {
        printf("%d:%d\n",(i/(n/p)),arr[i]);
        if((i+1)%(n/p)==0)
            printf("\n");
    }

//MERGER PART

    int k, min;
    j=0;

    while(j<n)
    {
        for(i=0; i<p; i++)
            if(count[i]<(n/p))
            {
                min = arr[i*(n/p)+count[i]];
                break;
            }

        for(i=0; i<p; i++)
        {
            if(arr[i*(n/p)+count[i]]<=min && count[i]<(n/p))
            {
                min = arr[i*(n/p)+count[i]];
                k = i;
            }
        }
        count[k]++;
        fin[j++] = min;
    }

    printf("Merging completed:\n"); 

    for(i=0; i<n; i++)
    {
        printf("%d\t", fin[i]);
    }
    printf("\n");
    exit(0);
}

void *func_sort(void *ptr)
{
    arg* arg1 = (arg*) ptr;
    int i, j, min, tj;
    for(i=arg1->start; …
anurag.kyal 0 Newbie Poster

hey winbatch!

m new to using threads and me too facing the same problem.. could you put some light onto the solution if you got any..

anurag.kyal 0 Newbie Poster

The problem is not killing the child.. it is killing the system process initiated by the chils and using wait()... i think.. it only waits till the child process is killed.. it doesnt bother about the system process!

and I am really sorry but the previous command kill -9 parentProcID isnt really clear !
parentProcId is the pid of parent?

anurag.kyal 0 Newbie Poster

I have a forked child process running which executes a system command

killing the child using os.kill(child_pid, SIGKILL) stops the child process but the system process continues !

Can something be done to stop the system process also?

A part of the code is something like this:
#Child
child_pid = os.fork()
if child_pid == 0:
res = os.system("python abc.py")
os.write(w, str(res))

python abc.py has an infinite loop. I want to stop that after a certain time for which i kill the child but I found out that the execution of the file still continues !!

Please help! Urgent!

Thanks in advance :)

anurag.kyal 0 Newbie Poster

Yeah i mean if i do somethin like
os.system('java out')
where out is the object of code and get some runtime error, the program(python script) should be able to know that the running malfunctioned !

anurag.kyal 0 Newbie Poster

Is is possible to check if the execution of a java program from python gives any error during runtime and compile time ?

Any help or sample code will be of real help..

Thanks in advance