主頁 > .NET開發 > 如何根據每種情況保持我在文本檔案中的位置?

如何根據每種情況保持我在文本檔案中的位置?

2022-01-22 02:31:28 .NET開發

我有 10 個文本檔案,其中包含一些由 rollnumber、源、目標和生成時間表示的資料包,它們也在 struct 中:

typedef struct Node 
{
    int rollnumber, src, dst;
    double gentime;
    struct Node *next;
} Node;

我想在每個時間單位打開每個檔案并能夠檢查是否生成了任何資料包。這意味著,生成時間必須小于我所在的時間單位。例如,在時間單位0-1中,我必須找到一個0<生成時間<1的資料包。因此,如果發生這種情況,該資料包將使用插入函式進入一個串列:

void insert_end ( Node **head, int rollnumber, int src, int dst, double gentime){
    struct Node * new_node = NULL;
    struct Node * last = NULL;
    new_node = (struct Node *)malloc(sizeof(struct Node));

    if (new_node == NULL)
    {
        printf("Failed to insert element. Out of memory");
        return;
    }

    new_node->rollnumber=rollnumber;
    new_node->src = src;
    new_node->dst=dst;
    new_node->gentime=gentime;
    new_node->next = NULL;

    if( *head == NULL)
    {
        *head = new_node;
        return;
    }
    last = *head;
    while(last->next) last = last->next;
    last->next = new_node;
}

我的代碼如下:

for (Time=1.0; Time<10.0; Time=Time 1.0){ //the time units checking them per one like: 0-1,1-2 etc..
        
        for(i=1;i<=10;i  ){ //because I have 10 text files
            
            char to_open[32];
            snprintf(to_open,32, "fptg_%d.txt", i);
            printf("\n\nFPTG_%d.txt\n", i);
            
            if ((file = fopen(to_open, "r")) == NULL)
            {
                break;
            }else{
                    
                    fseek(file , pos[i], SEEK_CUR);
                    fgets(line, sizeof(line), file);
                    sscanf(line,"%d %d %d %lf",&rollnumber, &src, &dst, &gentime);
                    printf("%s", line);
                    printf("Return value=%d\n",sscanf(line, " %d %d %d %lf", &rollnumber, &src, &dst, &gentime));
                    printf("gentime=%.1f\n", gentime);
                    pos[i] = ftell(file);
                    
                if(Time<gentime && gentime<Time 1.0){
                    insert_end ( &link[i], rollnumber, src, dst, gentime );
                    printf("Time=%0.1f\n", Time);  
                }else{
                    //do something else here and in the next time unit check the same packet again
                    }

                }    
            }
                
        }
}

My question is how will I be able if a packet does not insert in to the list to check the same packet in the next time unit? If a packet is inserting in the list, reading the next one is correct for what I want to do. But if a packet does not insert in to the list I do not want to go to the next one in the next time unit. Any help will be appreciated, thanks in advance!

Minimal Reproducible Example:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#define MAX_LINE_LENGTH 105

typedef struct Node {
    int rollnumber, src, dst;
    double gentime;
    struct Node *next;
} Node;

void
insert_end(Node **head, int rollnumber, int src, int dst, double gentime)
{
    struct Node *new_node = NULL;
    struct Node *last = NULL;

    new_node = (struct Node *) malloc(sizeof(struct Node));

    if (new_node == NULL) {
        printf("Failed to insert element. Out of memory");
        return;
    }

    new_node->rollnumber = rollnumber;
    new_node->src = src;
    new_node->dst = dst;
    new_node->gentime = gentime;
    new_node->next = NULL;

    if (*head == NULL) {
        *head = new_node;
        return;
    }
    last = *head;
    while (last->next)
        last = last->next;
    last->next = new_node;
}

void
output(Node *head)
{
    for (Node *current = head; current != NULL; current = current->next) {
        // printf("%d ", current->data);
        printf("Roll Number:-\t", current->rollnumber);
        printf("src:-\t", current->src);
        printf("dest:-\t", current->dst);
        printf("gentime:%0.1f\n", current->gentime);
    }
}

void
display(Node **set, int i)
{
    output(set[i]);
    putchar('\n');
}

int
remove_node_in_list(Node **set, size_t pos)
{
    int success = set[pos] != NULL;

    if (success) {
        Node *tmp = set[pos];

        set[pos] = set[pos]->next;
        free(tmp);
    }

    return success;
}

#define N   10

int
main(void)
{
    char line[MAX_LINE_LENGTH] = { 0 };
    int src, dst;
    int rollnumber;
    double gentime;
    int stations = 0;
    Node *link[N] = { 0 };
    int i = 1;
    static unsigned long pos[] = { 0 };
    FILE *file;
    char filename_format[] = "fptg_%d.txt";
    char filename[sizeof(filename_format)   4];
    bool intention[10];
    double Time = 12.0;
    int lower = 0, upper = 9, count = 1;

    srand(time(0));
    int num;
    int k = 1;
    struct node *head = NULL;

    // the time units checking them per one like: 0-1,1-2 etc..
    for (Time = 1.0; Time < 50.0; Time = Time   1.0) {

        // because I have 10 text files
        for (i = 1; i <= 10; i  ) {
            char to_open[32];

            snprintf(to_open, 32, "fptg_%d.txt", i);
            printf("\n\nFPTG_%d.txt\n", i);

            if ((file = fopen(to_open, "r")) == NULL) {
                break;
            }
            else {

                fseek(file, pos[i], SEEK_CUR);
                fgets(line, sizeof(line), file);
                sscanf(line, "%d %d %d %lf", &rollnumber, &src, &dst, &gentime);
                printf("%s", line);
                printf("Return value=%d\n", sscanf(line, " %d %d %d %lf", &rollnumber, &src, &dst, &gentime));
                printf("gentime=%.1f\n", gentime);
                pos[i] = ftell(file);

                if (Time < gentime && gentime < Time   1.0) {
                    insert_end(&link[i], rollnumber, src, dst, gentime);
                    printf("Time=%0.1f\n", Time);
                    for (int j = 0; j < count; j  ) {
                        int num = (rand() % (upper - lower   1))   lower;

                        printf("Random number:%d\n", num);

                        if (num == 1 || num == 6 || num == 8) {
                            intention[i] = true;
                            printf("ok\n");
                            stations  ;
                            printf("stations=%d\n", stations);
                            printf("intention[%d]=%d\n", i, intention[i]);
                            double offtime = gentime   12.0;

                            printf("channel off until: %.1f starting from: %.1f\n\n", offtime, gentime);

                        }
                        else {

                            intention[i] = false;

                            printf("intention[%d]=%d\n", i, intention[i]);
                        }

                    }
                }
                else {
                    printf("Not in the list\n");

                }

            }

        }
    }

    if (stations == 1) {
        for (int i = 1; i <= 10; i  ) {
            printf("intention[%d]=%d\n", i, intention[i]);
            if (intention[i] == true) {
                printf("link[%d]:\n", i);
                display(link, i);
                printf("i=%d\n", i);
                remove_node_in_list(link, i);
                printf("NEW:\n");
                display(link, i);
            }
        }

    }
    stations = 0;

    return 0;
}

The result I get for the first &second time unit is:

FPTG_1.txt
1       1       3       1.6
Return value=4
gentime=1.6
ok
Time=1.0
Random number:2
intention[1]=0


FPTG_2.txt
1       2       4       1.9
Return value=4
gentime=1.9
ok
Time=1.0
Random number:8
ok
stations=1
intention[2]=1
channel off until: 13.9 starting from: 1.9



FPTG_3.txt
1       3       7       1.2
Return value=4
gentime=1.2
ok
Time=1.0
Random number:7
intention[3]=0


FPTG_4.txt
1       4       18      0.2
Return value=4
gentime=0.2
Random number:9
intention[4]=0


FPTG_5.txt
1       5       19      0.2
Return value=4
gentime=0.2
Random number:0
intention[5]=0


FPTG_6.txt
1       6       3       0.1
Return value=4
gentime=0.1
Random number:0
intention[6]=0


FPTG_7.txt
1       7       6       0.0
Return value=4
gentime=0.0
Random number:0
intention[7]=0


FPTG_8.txt
1       8       17      0.5
Return value=4
gentime=0.5
Random number:4
intention[8]=0


FPTG_9.txt
1       9       6       0.1
Return value=4
gentime=0.1
Random number:1
ok
stations=2
intention[9]=1
channel off until: 12.1 starting from: 0.1



FPTG_10.txt
1       10      7       0.1
Return value=4
gentime=0.1
Random number:4
intention[10]=0

FPTG_1.txt
2       1       15      13.9
Return value=4
gentime=13.9
Random number:1
ok
stations=1
intention[1]=1
channel off until: 25.9 starting from: 13.9



FPTG_2.txt
2       2       19      14.0
Return value=4
gentime=14.0
Random number:6
ok
stations=2
intention[2]=1
channel off until: 26.0 starting from: 14.0



FPTG_3.txt
2       3       18      13.4
Return value=4
gentime=13.4
Random number:8
ok
stations=3
intention[3]=1
channel off until: 25.4 starting from: 13.4



FPTG_4.txt
2       4       12      12.8
Return value=4
gentime=12.8
Random number:8
ok
stations=4
intention[4]=1
channel off until: 24.8 starting from: 12.8



FPTG_5.txt
2       5       4       12.3
Return value=4
gentime=12.3
Random number:0
intention[5]=0


FPTG_6.txt
2       6       11      13.1
Return value=4
gentime=13.1
Random number:1
ok
stations=5
intention[6]=1
channel off until: 25.1 starting from: 13.1



FPTG_7.txt
2       7       13      12.8
Return value=4
gentime=12.8
Random number:2
intention[7]=0


FPTG_8.txt
2       8       14      13.5
Return value=4
gentime=13.5
Random number:4
intention[8]=0


FPTG_9.txt
2       9       11      14.0
Return value=4
gentime=14.0
Random number:0
intention[9]=0


FPTG_10.txt
2       10      9       12.1
Return value=4
gentime=12.1
Random number:7
intention[10]=0

and so it goes for the next time units. For example for the fptg_4.txt, in the first time unit it checks the first line of it: 1 4 18 0.2 but in the next time unit it goes to the next line: 2 4 12 12.8, even though it should have checked the same line because that packet represented by the previous line did not enter the list. So, my question is how is this possible?

uj5u.com熱心網友回復:

從我的熱門評論...

  1. 由于額外的 } [修復了我的編輯],您的 MRE 無法編譯。

  2. static unsigned long pos[] = { 0 };是錯誤的(它具有 UB--未定義的行為,因為它太短了)。它應該是:static unsigned long pos[11] = { 0 };

  3. 您從 1 開始對陣列進行索引。這意味著永遠不會使用第一個陣列元素,并且所有陣列都必須更大(例如int array[11];int array[10];您可能最好使用:for (i = 0; i < 10; i )然后:snprintf(to_open, 32, "fptg_%d.txt", i 1);

  4. 使用 fseek/ftell 是有問題的,因為輸入檔案是可變長度的文本。你想做什么?我能想到的唯一想法是你試圖讓你的串列按時間排序?

  5. 即使未存盤記錄,您也始終設定pos[i]為該值。ftell將線移動到pos[i] = ftell(file);線的下方/之后if (Time < gentime && gentime < Time 1.0) {(即在通話上方insert_end

  6. 完成最后一次更改后,位置問題得到解決。我得到 3479 行,而不是 192 行輸出。

  7. 但是,老實說,雖然我不確定您嘗試使用intention/stations代碼獲得什么效果,但多次重讀檔案并不是最好的方法。

  8. 我會讀取每個檔案一次,如果(例如)將其添加到串列中(gentime >= 1.0) && (gentime <= 50.0),然后在讀取所有檔案后,根據存盤的 gentime 對鏈接串列進行排序。

  9. 似乎意圖代碼可以在讀取回圈之外/之后完成,因為它們不依賴于彼此的資料。


其他錯誤:

  1. 永遠不會這樣做fclose,因此您有大量懸空的檔案流指標。
  2. 您從不檢查 的回傳值fgets,因此您沒有正確處理 EOF。
  3. 你打sscanf 了兩次電話。一次解碼該行,另一個只是列印回傳值sscanf
  4. 不要強制轉換的回傳值malloc請參閱:我是否強制轉換 malloc 的結果?

這是修改/更正的代碼:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>

#define MAX_LINE_LENGTH 105

typedef struct Node {
    int rollnumber, src, dst;
    double gentime;
    struct Node *next;
} Node;

void
insert_end(Node **head, int rollnumber, int src, int dst, double gentime)
{
    struct Node *new_node = NULL;
    struct Node *last = NULL;

    new_node = (struct Node *) malloc(sizeof(struct Node));

    if (new_node == NULL) {
        printf("Failed to insert element. Out of memory");
        return;
    }

    new_node->rollnumber = rollnumber;
    new_node->src = src;
    new_node->dst = dst;
    new_node->gentime = gentime;
    new_node->next = NULL;

    if (*head == NULL) {
        *head = new_node;
        return;
    }
    last = *head;
    while (last->next)
        last = last->next;
    last->next = new_node;
}

void
output(Node *head)
{
    for (Node *current = head; current != NULL; current = current->next) {
        // printf("%d ", current->data);
        printf("Roll Number:-\t", current->rollnumber);
        printf("src:-\t", current->src);
        printf("dest:-\t", current->dst);
        printf("gentime:%0.1f\n", current->gentime);
    }
}

void
display(Node **set, int i)
{
    output(set[i]);
    putchar('\n');
}

int
remove_node_in_list(Node **set, size_t pos)
{
    int success = set[pos] != NULL;

    if (success) {
        Node *tmp = set[pos];

        set[pos] = set[pos]->next;
        free(tmp);
    }

    return success;
}

#define N   10

int
main(void)
{
    char line[MAX_LINE_LENGTH] = { 0 };
    int src, dst;
    int rollnumber;
    double gentime;
    int stations = 0;
    Node *link[N] = { 0 };
    int i = 1;
    static unsigned long pos[N] = { 0 };
    FILE *file;
    bool intention[N];
    double Time = 12.0;
    int lower = 0,
        upper = 9,
        count = 1;

    srand(time(0));

    // the time units checking them per one like: 0-1,1-2 etc..
    for (Time = 1.0; Time < 50.0; Time = Time   1.0) {
        // because I have N text files
        for (i = 0; i < N; i  ) {
            char to_open[32];

            snprintf(to_open, 32, "fptg_%d.txt", i   1);
            printf("\n\nFILE/%d: %s Position:%ld (Time: %g)\n",
                i,to_open,pos[i],Time);

            if ((file = fopen(to_open, "r")) == NULL) {
                perror(to_open);
                break;
            }

            fseek(file, pos[i], SEEK_CUR);
#if 0
            fgets(line, sizeof(line), file);
#else
            char *cp = fgets(line, sizeof(line), file);
            fclose(file);
            if (cp == NULL)
                continue;
#endif

            int retval = sscanf(line, "%d %d %d %lf",
                &rollnumber, &src, &dst, &gentime);
            printf("%s", line);
            printf("Return value=%d\n", retval);
            printf("gentime=%.1f\n", gentime);

#if 0
            pos[i] = ftell(file);
#endif

            if (Time < gentime && gentime < Time   1.0) {
#if 1
                pos[i] = ftell(file);
#endif
                insert_end(&link[i], rollnumber, src, dst, gentime);
                printf("Time=%0.1f\n", Time);

                for (int j = 0; j < count; j  ) {
                    int num = (rand() % (upper - lower   1))   lower;

                    printf("Random number:%d\n", num);

                    if (num == 1 || num == 6 || num == 8) {
                        intention[i] = true;
                        printf("ok\n");
                        stations  ;
                        printf("stations=%d\n", stations);
                        printf("intention[%d]=%d\n", i, intention[i]);
                        double offtime = gentime   12.0;

                        printf("channel off until: %.1f starting from: %.1f\n\n", offtime, gentime);
                    }
                    else {
                        intention[i] = false;
                        printf("intention[%d]=%d\n", i, intention[i]);
                    }
                }
            }
            else {
                printf("Not in the list\n");
            }
        }
    }

    if (stations == 1) {
        for (int i = 0; i < N; i  ) {
            printf("intention[%d]=%d\n", i, intention[i]);
            if (intention[i] == true) {
                printf("link[%d]:\n", i);
                display(link, i);
                printf("i=%d\n", i);
                remove_node_in_list(link, i);
                printf("NEW:\n");
                display(link, i);
            }
        }
    }

    stations = 0;

    return 0;
}

我看到并做了所有的改變,非常感謝你!您認為我應該在代碼中的任何位置使用倒帶嗎?那會有幫助嗎?– 瓦賈普

rewind,[有效地]只是一個包裝fseek

正如我上面提到的,我會一次讀取所有檔案的所有行。然后,對串列進行排序。

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>

#define MAX_LINE_LENGTH 105

typedef struct Node {
    int rollnumber, src, dst;
    double gentime;
    struct Node *next;
} Node;

void
insert_end(Node **head, int rollnumber, int src, int dst, double gentime)
{
    struct Node *new_node;
    struct Node *last = NULL;

    new_node = malloc(sizeof(*new_node));

    if (new_node == NULL) {
        printf("Failed to insert element. Out of memory");
        return;
    }

    new_node->rollnumber = rollnumber;
    new_node->src = src;
    new_node->dst = dst;
    new_node->gentime = gentime;
    new_node->next = NULL;

    if (*head == NULL) {
        *head = new_node;
        return;
    }

    last = *head;
    while (last->next)
        last = last->next;

    last->next = new_node;
}

void
output(Node *head)
{
    for (Node *current = head; current != NULL; current = current->next) {
        // printf("%d ", current->data);
        printf("Roll Number:-\t", current->rollnumber);
        printf("src:-\t", current->src);
        printf("dest:-\t", current->dst);
        printf("gentime:%0.1f\n", current->gentime);
    }
}

void
display(Node **set, int i)
{
    output(set[i]);
    putchar('\n');
}

int
remove_node_in_list(Node **set, size_t pos)
{
    int success = set[pos] != NULL;

    if (success) {
        Node *tmp = set[pos];

        set[pos] = set[pos]->next;
        free(tmp);
    }

    return success;
}

int
sort_cmp(const void *vlhs,const void *vrhs)
{
    const Node *lhs = vlhs;
    const Node *rhs = vrhs;
    int cmp;

    do {
        cmp = -1;
        if (lhs->gentime < rhs->gentime)
            break;

        cmp = 1;
        if (lhs->gentime > rhs->gentime)
            break;

        cmp = 0;
    } while (0);

    return cmp;
}

void
sort_list(Node **head)
{
    size_t count;
    size_t idx;
    Node *cur;
    Node *prev;

    // get count of list
    count = 0;
    for (cur = *head;  cur != NULL;  cur = cur->next)
          count;

    // get flat array of node pointers
    Node **arr = malloc(sizeof(*arr) * count);

    // fill the array
    idx = 0;
    for (cur = *head;  cur != NULL;  cur = cur->next,   idx)
        arr[idx] = cur;

    qsort(arr,count,sizeof(*arr),sort_cmp);

    // repopulate linked list from array
    prev = NULL;
    for (idx = 0;  idx < count;    idx) {
        cur = arr[idx];
        cur->next = NULL;

        if (prev != NULL)
            prev->next = cur;
        else
            *head = cur;
    }

    free(arr);
}

#define N   10

#define TMIN    1.0
#define TMAX    50.0

int
main(void)
{
    char line[MAX_LINE_LENGTH] = { 0 };
    int src, dst;
    int rollnumber;
    double gentime;
    int stations = 0;
    Node *link[N] = { 0 };
    int i = 1;
    FILE *file;
    char *cp;
    bool intention[N] = { 0 };
    double Time = 12.0;
    int lower = 0,
        upper = 9,
        count = 1;

    srand(time(0));

    // because I have N text files
    for (i = 0; i < N; i  ) {
        char to_open[32];

        snprintf(to_open, 32, "fptg_%d.txt", i   1);
        printf("\nFILE/%d: %s\n",i,to_open);

        if ((file = fopen(to_open, "r")) == NULL) {
            perror(to_open);
            break;
        }

        while (1) {
            cp = fgets(line, sizeof(line), file);
            if (cp == NULL)
                break;

            int retval = sscanf(line, "%d %d %d %lf",
                &rollnumber, &src, &dst, &gentime);
            printf("%s", line);
            printf("Return value=%d\n", retval);
            printf("gentime=%.1f\n", gentime);

            if ((gentime >= TMIN) && (gentime < TMAX))
                insert_end(&link[i], rollnumber, src, dst, gentime);
            else
                printf("Not in the list\n");
        }

        fclose(file);
    }

    // sort all lists
    for (i = 0; i < N; i  )
        sort_list(&link[i]);

    // the time units checking them per one like: 0-1,1-2 etc..
    for (Time = TMIN; Time < TMAX; Time = Time   1.0) {
        for (int j = 0; j < count; j  ) {
            int num = (rand() % (upper - lower   1))   lower;

            printf("Random number:%d\n", num);

            if (num == 1 || num == 6 || num == 8) {
                intention[i] = true;
                printf("ok\n");
                stations  ;
                printf("stations=%d\n", stations);
                printf("intention[%d]=%d\n", i, intention[i]);
                double offtime = gentime   12.0;

                printf("channel off until: %.1f starting from: %.1f\n\n",
                    offtime, gentime);
            }
            else {
                intention[i] = false;
                printf("intention[%d]=%d\n", i, intention[i]);
            }
        }
    }

    if (stations == 1) {
        for (int i = 0; i < N; i  ) {
            printf("intention[%d]=%d\n", i, intention[i]);
            if (intention[i] == true) {
                printf("link[%d]:\n", i);
                display(link, i);
                printf("i=%d\n", i);
                remove_node_in_list(link, i);
                printf("NEW:\n");
                display(link, i);
            }
        }
    }

    stations = 0;

    return 0;
}

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/417891.html

標籤:

上一篇:同心方陣

下一篇:黑客等級問題中的運行時錯誤:C中的一維陣列

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • WebAPI簡介

    Web體系結構: 有三個核心:資源(resource),URL(統一資源識別符號)和表示 他們的關系是這樣的:一個資源由一個URL進行標識,HTTP客戶端使用URL定位資源,表示是從資源回傳資料,媒體型別是資源回傳的資料格式。 接下來我們說下HTTP. HTTP協議的系統是一種無狀態的方式,使用請求/ ......

    uj5u.com 2020-09-09 22:07:47 more
  • asp.net core 3.1 入口:Program.cs中的Main函式

    本文分析Program.cs 中Main()函式中代碼的運行順序分析asp.net core程式的啟動,重點不是剖析原始碼,而是理清程式開始時執行的順序。到呼叫了哪些實體,哪些法方。asp.net core 3.1 的程式入口在專案Program.cs檔案里,如下。ususing System; us ......

    uj5u.com 2020-09-09 22:07:49 more
  • asp.net網站作為websocket服務端的應用該如何寫

    最近被websocket的一個問題困擾了很久,有一個需求是在web網站中搭建websocket服務。客戶端通過網頁與服務器建立連接,然后服務器根據ip給客戶端網頁發送資訊。 其實,這個需求并不難,只是剛開始對websocket的內容不太了解。上網搜索了一下,有通過asp.net core 實作的、有 ......

    uj5u.com 2020-09-09 22:08:02 more
  • ASP.NET 開源匯入匯出庫Magicodes.IE Docker中使用

    Magicodes.IE在Docker中使用 更新歷史 2019.02.13 【Nuget】版本更新到2.0.2 【匯入】修復單列匯入的Bug,單元測驗“OneColumnImporter_Test”。問題見(https://github.com/dotnetcore/Magicodes.IE/is ......

    uj5u.com 2020-09-09 22:08:05 more
  • 在webform中使用ajax

    如果你用過Asp.net webform, 說明你也算是.NET 開發的老兵了。WEBform應該是2011 2013左右,當時還用visual studio 2005、 visual studio 2008。后來基本都用的是MVC。 如果是新開發的專案,估計沒人會用webform技術。但是有些舊版 ......

    uj5u.com 2020-09-09 22:08:50 more
  • iis添加asp.net網站,訪問提示:由于擴展配置問題而無法提供您請求的

    今天在iis服務器配置asp.net網站,遇到一個問題,記錄一下: 問題:由于擴展配置問題而無法提供您請求的頁面。如果該頁面是腳本,請添加處理程式。如果應下載檔案,請添加 MIME 映射。 WindowServer2012服務器,添加角色安裝完.netframework和iis之后,運行aspx頁面 ......

    uj5u.com 2020-09-09 22:10:00 more
  • WebAPI-處理架構

    帶著問題去思考,大家好! 問題1:HTTP請求和回傳相應的HTTP回應資訊之間發生了什么? 1:首先是最底層,托管層,位于WebAPI和底層HTTP堆疊之間 2:其次是 訊息處理程式管道層,這里比如日志和快取。OWIN的參考是將訊息處理程式管道的一些功能下移到堆疊下端的OWIN中間件了。 3:控制器處理 ......

    uj5u.com 2020-09-09 22:11:13 more
  • 微信門戶開發框架-使用指導說明書

    微信門戶應用管理系統,采用基于 MVC + Bootstrap + Ajax + Enterprise Library的技術路線,界面層采用Boostrap + Metronic組合的前端框架,資料訪問層支持Oracle、SQLServer、MySQL、PostgreSQL等資料庫。框架以MVC5,... ......

    uj5u.com 2020-09-09 22:15:18 more
  • WebAPI-HTTP編程模型

    帶著問題去思考,大家好!它是什么?它包含什么?它能干什么? 訊息 HTTP編程模型的核心就是訊息抽象,表示為:HttPRequestMessage,HttpResponseMessage.用于客戶端和服務端之間交換請求和回應訊息。 HttpMethod類包含了一組靜態屬性: private stat ......

    uj5u.com 2020-09-09 22:15:23 more
  • 部署WebApi隨筆

    一、跨域 NuGet參考Microsoft.AspNet.WebApi.Cors WebApiConfig.cs中配置: // Web API 配置和服務 config.EnableCors(new EnableCorsAttribute("*", "*", "*")); 二、清除默認回傳XML格式 ......

    uj5u.com 2020-09-09 22:15:48 more
最新发布
  • C#多執行緒學習(二) 如何操縱一個執行緒

    <a href="https://www.cnblogs.com/x-zhi/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2943582/20220801082530.png" alt="" /></...

    uj5u.com 2023-04-19 09:17:20 more
  • C#多執行緒學習(二) 如何操縱一個執行緒

    C#多執行緒學習(二) 如何操縱一個執行緒 執行緒學習第一篇:C#多執行緒學習(一) 多執行緒的相關概念 下面我們就動手來創建一個執行緒,使用Thread類創建執行緒時,只需提供執行緒入口即可。(執行緒入口使程式知道該讓這個執行緒干什么事) 在C#中,執行緒入口是通過ThreadStart代理(delegate)來提供的 ......

    uj5u.com 2023-04-19 09:16:49 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    <a href="https://www.cnblogs.com/huangxincheng/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/214741/20200614104537.png" alt="" /&g...

    uj5u.com 2023-04-18 08:39:04 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    一:背景 1. 講故事 前段時間協助訓練營里的一位朋友分析了一個程式卡死的問題,回過頭來看這個案例比較經典,這篇稍微整理一下供后來者少踩坑吧。 二:WinDbg 分析 1. 為什么會卡死 因為是表單程式,理所當然就是看主執行緒此時正在做什么? 可以用 ~0s ; k 看一下便知。 0:000> k # ......

    uj5u.com 2023-04-18 08:33:10 more
  • SignalR, No Connection with that ID,IIS

    <a href="https://www.cnblogs.com/smartstar/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/u36196.jpg" alt="" /></a>...

    uj5u.com 2023-03-30 17:21:52 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:15:33 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:13:31 more
  • C#遍歷指定檔案夾中所有檔案的3種方法

    <a href="https://www.cnblogs.com/xbhp/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/957602/20230310105611.png" alt="" /></a&...

    uj5u.com 2023-03-27 14:46:55 more
  • C#/VB.NET:如何將PDF轉為PDF/A

    <a href="https://www.cnblogs.com/Carina-baby/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2859233/20220427162558.png" alt="" />...

    uj5u.com 2023-03-27 14:46:35 more
  • 武裝你的WEBAPI-OData聚合查詢

    <a href="https://www.cnblogs.com/podolski/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/616093/20140323000327.png" alt="" /><...

    uj5u.com 2023-03-27 14:46:16 more