protected void Page_Load(object sender, EventArgs e)
    {
        string userId      = HttpContext.Current.User.Identity.GetUserId();
        string strFileName = string.Empty;
        string strPath     = string.Empty;
        int    totalCount  = 0;

        Base64BinarySrtingToFile save = new Base64BinarySrtingToFile
        {
            FilePrefix = userId
        };

        save.SaveFileNew("FileUpload");


        bool issave = false;

        if (save.IsSaved)
        {
            issave      = true;
            strFileName = save.FileName;
            strPath     = save.Path;

            switch (save.Format)
            {
            case "csv":
                totalCount = new GsCsvReader(strPath, strFileName).ResultDataTable.Rows.Count;
                break;

            case "excel":
                totalCount = new ExcelReader(strPath, strFileName).GetDataSetCreatecolumn().Tables[0].Rows.Count;
                break;
            }

            Model_SubscriberImportTemp temp = new Model_SubscriberImportTemp
            {
                FileName    = save.FileName,
                Path        = save.Path,
                TotalRecord = totalCount
            };
            SubScriberImportController.ImportTemp(temp);
        }



        string res = (new BaseWebMethodAJax
        {
            success = issave,
            msg = "formet:" + save.Format + "  filename:" + save.FileName + save.Error + save.ErrorDetail,
            Totalrecord = totalCount.ToString(),
            KeyID = userId
        }).ObjectToJSON();

        AppTools.SendResponse(HttpContext.Current.Response, res);
    }
Ejemplo n.º 2
0
    public static int ImportNow(Model_SubscriberParamImport param)
    {
        int ret = 0;
        Model_SubscriberImportTemp import = new Model_SubscriberImportTemp();

        import = import.GetImportTemp();
        DataTable data = null;

        if (import != null)
        {
            try
            {
                FileInfo file = new FileInfo(HttpContext.Current.Server.MapPath(import.Path + import.FileName));

                if (file.Exists)
                {
                    string extension = file.Extension;

                    switch (extension)
                    {
                    case ".csv":
                        data = new GsCsvReader(import.Path, import.FileName).ResultDataTable;
                        break;

                    default:
                        data = new ExcelReader(import.Path, import.FileName).GetDataSetCreatecolumn().Tables[0];
                        break;
                    }


                    if (data.Rows.Count > 0)
                    {
                        Lock.AcquireWriterLock(Timeout.Infinite);
                        SubScriberImportController.TotalCompleted   = 0;
                        SubScriberImportController.PercentCompleted = 0.0M;
                        SubScriberImportController.Onprocess        = true;
                        Lock.ReleaseWriterLock();

                        API_ThreadPool cpool      = new API_ThreadPool();
                        object[]       parameters = new object[] { data, param };
                        cpool.QueueWork(parameters, ImportSubscriber);
                    }
                }
                ret = 1;
            }
            catch { }
        }



        return(ret);
    }
    protected void btnImport_Click(object sender, EventArgs e)
    {
        string strFileName = string.Empty;
        string strPath     = string.Empty;


        Base64BinarySrtingToFile save = new Base64BinarySrtingToFile
        {
            FilePrefix = "1"
        };

        save.SaveFileNew(HttpContext.Current.Request.Files["ctl00$MainContent$fileImport"]);



        if (save.IsSaved)
        {
            strFileName = save.FileName;
            strPath     = save.Path;

            DataTable data = null;

            data = new GsCsvReader(strPath, strFileName, 1, 26).ResultDataTable;

            if (data.Rows.Count > 0)
            {
                Model_Jobfunction cde = new Model_Jobfunction();
                //cde.DeleteAll();
                int count = 0;

                Model_JobFunctionListMain cm = new Model_JobFunctionListMain();


                Model_ReportSectionItem cc = new Model_ReportSectionItem();

                cc.Delete(6);
                foreach (DataRow row in data.Rows)
                {
                    if (count > 0)
                    {
                        Model_Jobfunction cSub = new Model_Jobfunction
                        {
                            JFID  = int.Parse(row[2].ToString()),
                            JGID  = int.Parse(row[0].ToString()),
                            Title = row[3].ToString()
                                    //Email = (row.Table.Columns.Contains("Email") ? (row["Email"] == DBNull.Value ? "" : (string)row["Email"]) : ""),
                                    //FirstName = (row.Table.Columns.Contains("FirstName") ? (row["FirstName"] == DBNull.Value ? "" : (string)row["FirstName"]) : ""),
                                    //LastName = (row.Table.Columns.Contains("LastName") ? (row["LastName"] == DBNull.Value ? "" : (string)row["LastName"]) : ""),
                                    //Sbin = true,
                                    //SGID = int.Parse(p.Group)
                        };
                        cSub.insert(cSub);
                        int intJobfcuntionID = int.Parse(row[2].ToString());

                        Model_ReportSectionItem sub = new Model_ReportSectionItem
                        {
                            ResultSectionID = 6,
                            Title           = row[3].ToString(),
                            Status          = true,
                            Priority        = count,
                            Code            = "T6" + count,
                            SUCID           = row[2].ToString(),
                            Short           = "",
                            Detail          = "",
                            PeopleTxt       = "",
                            CultureTxt      = "",
                            CompetitionTxt  = "",
                        };
                        sub.Insert(sub);

                        List <Model_JobFunctionListMain> cm1 = cm.GetAllActive();

                        int count1 = 4;
                        foreach (Model_JobFunctionListMain i1 in cm1.Where(o => o.Category == 1).OrderBy(o => o.Priority))
                        {
                            Model_JobFunctionListMap cj = new Model_JobFunctionListMap
                            {
                                JFID  = intJobfcuntionID,
                                JFMID = i1.JFMID,
                                Score = int.Parse(row[count1].ToString()),
                            };
                            cj.insert(cj);
                            count1 = count1 + 1;
                        }

                        int count2 = 22;
                        foreach (Model_JobFunctionListMain i2 in cm1.Where(o => o.Category == 2).OrderBy(o => o.Priority))
                        {
                            Model_JobFunctionListMap cj = new Model_JobFunctionListMap
                            {
                                JFID  = intJobfcuntionID,
                                JFMID = i2.JFMID,
                                Score = int.Parse(row[count2].ToString()),
                            };
                            cj.insert(cj);
                            count2 = count2 + 1;
                        }
                    }


                    count = count + 1;
                }
            }
        }



        Response.Redirect(Request.Url.ToString());
    }