コード例 #1
0
 internal void PrintLine()
 {
     Con.PrintLine();
 }
コード例 #2
0
 public void Dispose()
 {
     Con.Close();
 }
コード例 #3
0
    public string setDefaultOFCostAcct()
    {
        string return_val = "false";

        //---------
        SQL = "select   isnull(max(item_no),0) as item_no   from  item_cost  where elt_account_number = "
              + elt_account_number;

        DataTable      dt  = new DataTable();
        SqlDataAdapter ad2 = new SqlDataAdapter(SQL, Con);

        ad2.Fill(dt);

        int next_no = Int32.Parse(dt.Rows[0]["item_no"].ToString());

        next_no += 1;
        dt.Clear();

        SQL = "select  top 1 * from  gl  where elt_account_number = "
              + elt_account_number + "  and gl_account_type= '" + Account.COST_OF_SALES
              + "' and gl_master_type='EXPENSE' and gl_account_desc='Default Ocean Freight Cost'";

        //-----------------
        SqlDataAdapter ad    = new SqlDataAdapter(SQL, Con);
        GeneralUtility gUtil = new GeneralUtility();
        GLRecord       gRec  = new GLRecord();

        ad.Fill(dt);
        int gl_acct = 0;

        if (dt.Rows.Count == 0)
        {
            gl_acct = getNewGLAccount("EXPENSE");
            gRec    = createGLAccount(gl_acct, "Default Ocean Freight Cost", "EXPENSE", Account.COST_OF_SALES);
        }
        else
        {
            gl_acct = Int32.Parse(dt.Rows[0]["gl_account_number"].ToString());
        }
        Cmd            = new SqlCommand();
        Cmd.Connection = Con;
        Con.Open();
        SqlTransaction trans = Con.BeginTransaction();

        Cmd.Transaction = trans;

        try
        {
            SQL  = "INSERT INTO [item_cost] ";
            SQL += "( elt_account_number, ";
            SQL += "item_no,";
            SQL += "item_name,";
            SQL += "item_type,";
            SQL += "item_desc,";
            SQL += "unit_price,";
            SQL += "account_expense) ";
            SQL += "VALUES";
            SQL += "('" + elt_account_number;
            SQL += "','" + next_no;
            SQL += "','" + "OF";
            SQL += "','" + "Ocean Freight";
            SQL += "','" + "OCEAN FREIGHT";
            SQL += "','" + "0";
            SQL += "','" + gl_acct;
            SQL += "')";

            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();


            SQL             = "UPDATE [user_profile] ";
            SQL            += "set default_ocean_cost_item= '" + next_no + "'";
            SQL            += "where elt_account_number = " + elt_account_number;
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();


            trans.Commit();
            return_val = "true";
        }
        catch (Exception ex)
        {
            trans.Rollback();
            throw ex;
        }
        finally
        {
            Con.Close();
        }

        return(return_val);
    }
コード例 #4
0
        // Build SrcKit
        public virtual bool BuildSrcKit(string baseOutputDir, bool debugMode)
        {
            // Generate an Output directory name
            string outDir    = Path.Combine(baseOutputDir, this.CrossLibName);
            string outSrcDir = Path.Combine(outDir, "src");

            Con.WriteLine("BuildSrcKit for '{0}'...", this.IDString);
            Con.WriteLine("CrossLib Name: '{0}'.", this.CrossLibName);
            Con.WriteLine("BuildSrcKit Output Dir = '{0}'.", outDir);

            string tsFile    = Path.Combine(outDir, "TimeStamp.txt");
            string timeStamp = Str.DateTimeToStrShort(BuildSoftwareList.ListCreatedDateTime);

            Con.WriteLine("timestamp={0}", timeStamp);

            if (Directory.Exists(outDir))
            {
                bool ok = false;
                // See TimeStamp.txt file if the directory already exists
                try
                {
                    string[] ts = File.ReadAllLines(tsFile);
                    if (ts[0] == timeStamp)
                    {
                        ok = true;
                    }
                }
                catch
                {
                }

                if (ok)
                {
                    Con.WriteLine("Skipped for '{0}'.", this.IDString);
                    return(false);
                }
            }
            else
            {
                Directory.CreateDirectory(outDir);
            }

            // Copy the source code
            foreach (string srcDirName in SrcDirNameList)
            {
                string srcFullPath  = Path.Combine(Paths.BaseDirName, srcDirName);
                string destFullPath = Path.Combine(outSrcDir, srcDirName);
                bool   delete_bom   = true;

                if (Str.InStr(srcDirName, "\\hamcore"))
                {
                    delete_bom = false;
                }

                IO.CopyDir(srcFullPath, destFullPath, new IO.CopyDirPreCopyDelegate(CopySrcFilesDelegate), false, true, true, delete_bom);
            }
            IO.FileCopy(Path.Combine(Paths.BaseDirName, "CurrentBuild.txt"), Path.Combine(outSrcDir, "CurrentBuild.txt"), true, false);
            IO.FileCopy(Path.Combine(Paths.BaseDirName, "GlobalConst.h"), Path.Combine(outSrcDir, "GlobalConst.h"), true, false);
            IO.FileCopy(Path.Combine(Paths.BaseDirName, @"DebugFiles\Replace.h"), Path.Combine(outSrcDir, "Replace.h"), true, false);
            IO.FileCopy(Path.Combine(Paths.BaseDirName, @"bin\BuiltHamcoreFiles\hamcore_unix\hamcore.se2"),
                        Path.Combine(outSrcDir, @"bin\hamcore.se2"), true, false);

            // Copy Crosslibs
            IO.CopyDir(Path.Combine(this.CrossLibBaseDir, this.CrossLibName), Path.Combine(outSrcDir, @"lib"),
                       delegate(FileInfo fi)
            {
                if (fi.DirectoryName.IndexOf(@".svn", StringComparison.InvariantCultureIgnoreCase) != -1)
                {
                    return(false);
                }
                return(true);
            }, false, true, true, false);

            // Generate Makefile for compilation
            byte[] makeFileDataForCross = Str.NormalizeCrlf(Str.Utf8Encoding.GetBytes(GenerateMakeFileForCompile(outSrcDir, debugMode, true).ToString()), new byte[] { 10, });
            byte[] makeFileDataForSelf  = Str.NormalizeCrlf(Str.Utf8Encoding.GetBytes(GenerateMakeFileForCompile(outSrcDir, debugMode, false).ToString()), new byte[] { 10, });

            string makeFileName = Path.Combine(outSrcDir, "Makefile");

            File.WriteAllBytes(makeFileName, makeFileDataForCross);

            // TimeStamp.txt
            File.WriteAllText(tsFile, timeStamp);

            // Create a tar.gz
            string tarGzFileName = Path.Combine(outSrcDir, this.SrcKitFileName);

            Con.WriteLine("Creating '{0}'...", tarGzFileName);
            List <string> files = new List <string>();

            foreach (string srcDirName in Util.CombineArray <string>(SrcDirNameList, new string[] { "lib" }))
            {
                string   dirFullPath = Path.Combine(outSrcDir, srcDirName);
                string[] fileList    = Directory.GetFiles(dirFullPath, "*",
                                                          srcDirName.Equals("lib", StringComparison.InvariantCultureIgnoreCase) ? SearchOption.TopDirectoryOnly : SearchOption.AllDirectories);
                foreach (string fileName in fileList)
                {
                    files.Add(fileName);
                }
            }
            files.Add(Path.Combine(outSrcDir, @"CurrentBuild.txt"));
            files.Add(Path.Combine(outSrcDir, @"bin\hamcore.se2"));
            files.Add(Path.Combine(outSrcDir, @"Replace.h"));
            files.Add(Path.Combine(outSrcDir, @"GlobalConst.h"));

            files.Sort();
            TarPacker tar = new TarPacker();

            foreach (string file in files)
            {
                byte[] fileData = File.ReadAllBytes(file);
                tar.AddFileSimple(@"src\" + IO.GetRelativeFileName(file, outSrcDir),
                                  fileData,
                                  0, fileData.Length, File.GetLastWriteTime(file), "0000750", "0000640");
            }
            tar.AddFileSimple(@"src\Makefile", makeFileDataForSelf, 0, makeFileDataForSelf.Length, DateTime.Now, "0000750", "0000640");
            tar.Finish();
            byte[] tarGzData = tar.CompressToGZip();
            File.WriteAllBytes(tarGzFileName, tarGzData);

            IO.MakeDir(Paths.ReleaseSrckitDir);
            File.WriteAllBytes(Path.Combine(Paths.ReleaseSrckitDir, this.SrcKitFileName), tarGzData);

            Con.WriteLine("Completed.");

            return(true);
        }
コード例 #5
0
    public bool insertInvoiceRecord(ref InvoiceRecord ivRec, string tran_type)
    {
        ivRec.replaceQuote();
        bool return_val = false;
        int  loopV      = 0;
        int  invoice_no = getNewInvoiceNo();

        ArrayList AAJEntryList = ivRec.AllAccountsJournalList;

        for (int i = 0; i < AAJEntryList.Count; i++)
        {
            this.aajMgr.checkInitial_Acct_Record((AllAccountsJournalRecord)AAJEntryList[i]);
        }

        int next_tran_seq_no = this.aajMgr.getNextTranSeqNumber();

        //INSERT IV CHARGE ITEMS
        Cmd            = new SqlCommand();
        Cmd.Connection = Con;
        Con.Open();
        SqlTransaction trans = Con.BeginTransaction();

        Cmd.Transaction = trans;

        //try
        //  {
        ArrayList chList = ivRec.ChargeItemList;

        for (int i = 0; i < chList.Count; i++)
        {
            IVChargeItemRecord IVChR = (IVChargeItemRecord)chList[i];
            IVChR.replaceQuote();
            IVChR.Invoice_no = invoice_no;
            SQL             = "INSERT INTO [invoice_charge_item] ";
            SQL            += "( elt_account_number, ";
            SQL            += "invoice_no,";
            SQL            += "item_id,";
            SQL            += "item_no,";
            SQL            += "item_desc,";
            SQL            += "qty,";
            SQL            += "charge_amount,";
            SQL            += "import_export,";
            SQL            += "mb_no,";
            SQL            += "hb_no,";
            SQL            += "iType)";
            SQL            += "VALUES";
            SQL            += "('" + elt_account_number;
            SQL            += "','" + invoice_no;
            SQL            += "','" + IVChR.Item_id;
            SQL            += "','" + IVChR.Item_no;
            SQL            += "','" + IVChR.Item_desc;
            SQL            += "','" + IVChR.Qty;
            SQL            += "','" + IVChR.Charge_amount;
            SQL            += "','" + IVChR.Import_export;
            SQL            += "','" + IVChR.Mb_no;
            SQL            += "','" + IVChR.Hb_no;
            SQL            += "','" + IVChR.IType;
            SQL            += "')";
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();
        }
        //INSERT IV COST ITEMS
        ArrayList cstList = ivRec.CostItemList;
        int       bill_no = 0;

        for (int i = 0; i < cstList.Count; i++)
        {
            IVCostItemRecord IVCostR = (IVCostItemRecord)cstList[i];
            IVCostR.replaceQuote();
            SQL  = "INSERT INTO [invoice_Cost_item] ";
            SQL += "( elt_account_number, ";
            SQL += "invoice_no,";

            SQL += "item_id,";
            SQL += "item_no,";
            SQL += "item_desc,";
            SQL += "qty,";
            SQL += "ref_no,";
            SQL += "vendor_no,";
            SQL += "Cost_amount,";
            SQL += "import_export,";
            SQL += "mb_no,";
            SQL += "hb_no,";
            SQL += "iType)";
            SQL += "VALUES";
            SQL += "('" + elt_account_number;

            SQL            += "','" + invoice_no;
            SQL            += "','" + IVCostR.Item_id;
            SQL            += "','" + IVCostR.Item_no;
            SQL            += "','" + IVCostR.Item_desc;
            SQL            += "','" + IVCostR.Qty;
            SQL            += "','" + IVCostR.Ref_no;
            SQL            += "','" + IVCostR.Vendor_no;
            SQL            += "','" + IVCostR.Cost_amount;
            SQL            += "','" + IVCostR.Import_export;
            SQL            += "','" + IVCostR.Mb_no;
            SQL            += "','" + IVCostR.Hb_no;
            SQL            += "','" + IVCostR.IType;
            SQL            += "')";
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();
        }

        //INSERT BILL DETAILS WITH BILL_NUMBER BEING 0
        ArrayList bdList = ivRec.BillDetailList;

        for (int i = 0; i < bdList.Count; i++)
        {
            BillDetailRecord bDRec = (BillDetailRecord)bdList[i];
            bDRec.replaceQuote();

            SQL             = "INSERT INTO [bill_detail] ";
            SQL            += "( elt_account_number, ";
            SQL            += "item_ap,";
            SQL            += "item_id,";
            SQL            += "item_no,";
            SQL            += "item_amt,";
            SQL            += "is_manual,";
            SQL            += "item_expense_acct,";
            SQL            += "tran_date,";
            SQL            += "invoice_no,";
            SQL            += "agent_debit_no,";
            SQL            += "mb_no,";
            SQL            += "hb_no,";
            SQL            += "ref,";
            SQL            += "iType,";
            SQL            += "import_export,";
            SQL            += "bill_number,";
            SQL            += "vendor_number)";
            SQL            += "VALUES";
            SQL            += "('" + elt_account_number;
            SQL            += "','" + bDRec.item_ap;
            SQL            += "','" + bDRec.item_id;
            SQL            += "','" + bDRec.item_no;
            SQL            += "','" + bDRec.item_amt;
            SQL            += "','" + bDRec.is_manual;
            SQL            += "','" + bDRec.item_expense_acct;
            SQL            += "','" + bDRec.tran_date;
            SQL            += "','" + invoice_no;
            SQL            += "','" + bDRec.agent_debit_no;
            SQL            += "','" + bDRec.mb_no;
            SQL            += "','" + bDRec.hb_no;
            SQL            += "','" + bDRec.ref_no;
            SQL            += "','" + bDRec.iType;
            SQL            += "','" + bDRec.import_export;
            SQL            += "','" + bDRec.bill_number;
            SQL            += "','" + bDRec.vendor_number;
            SQL            += "')";
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();
        }


        SQL  = "DELETE FROM invoice_header WHERE elt_account_number =";
        SQL += elt_account_number + " and invoice_no="
               + invoice_no;
        Cmd.CommandText = SQL;
        Cmd.ExecuteNonQuery();


        //Insert IV Headers
        //INSERT BILL DETAILS WITH BILL_NUMBER BEING 0
        ArrayList ihList = ivRec.InvoiceHeaders;

        if (tran_type == "INV")
        {
            loopV = ihList.Count;
        }
        for (int i = 0; i < loopV; i++)
        {
            //ihList.Count
            IVHeaderRecord ihRec = (IVHeaderRecord)ihList[i];

            SQL  = "INSERT INTO [invoice_header] ";
            SQL += "( elt_account_number, ";
            SQL += "Carrier,";
            SQL += "ChargeableWeight,";
            SQL += "Consignee,";
            SQL += "Destination,";
            SQL += "ETA,";
            SQL += "ETD,";
            SQL += "FILE_NO,";
            SQL += "GrossWeight,";
            SQL += "hawb,";
            SQL += "invoice_no,";
            SQL += "mawb,";
            SQL += "Origin,";
            SQL += "Pieces,";
            SQL += "Shipper,";
            SQL += "unit)";
            SQL += "VALUES";

            SQL            += "('" + elt_account_number;
            SQL            += "','" + ihRec.Carrier;
            SQL            += "','" + ihRec.ChargeableWeight;
            SQL            += "','" + ihRec.Consignee;
            SQL            += "','" + ihRec.Destination;
            SQL            += "','" + ihRec.ETA;
            SQL            += "','" + ihRec.ETD;
            SQL            += "','" + ihRec.FILE;
            SQL            += "','" + ihRec.GrossWeight;
            SQL            += "','" + ihRec.hawb;
            SQL            += "','" + invoice_no;
            SQL            += "','" + ihRec.mawb;
            SQL            += "','" + ihRec.Origin;
            SQL            += "','" + ihRec.Pieces;
            SQL            += "','" + ihRec.Shipper;
            SQL            += "','" + ihRec.unit;
            SQL            += "')";
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();
        }



        //INSERT AAJ ENTRY WITH TRAN_TYPE BEING INV AND TRAN_NO BEING INVOICE_NO
        for (int i = 0; i < AAJEntryList.Count; i++)
        {
            ((AllAccountsJournalRecord)AAJEntryList[i]).replaceQuote();
            ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num = invoice_no;
            SQL  = "INSERT INTO [all_accounts_journal] ";
            SQL += "( elt_account_number, ";
            SQL += "tran_num,";
            SQL += "air_ocean,";
            //SQL += "inland_type,";  //added by stanley on 12/14
            SQL += "gl_account_number,";
            SQL += "gl_account_name,";
            SQL += "tran_seq_num,";
            SQL += "tran_type,";
            SQL += "tran_date,";
            SQL += "Customer_Number,";
            SQL += "Customer_Name,";
            SQL += "debit_amount,";
            SQL += "credit_amount,";
            SQL += "balance,";
            SQL += "previous_balance,";
            SQL += "gl_balance,";
            SQL += "gl_previous_balance)";
            SQL += "VALUES";
            SQL += "('" + elt_account_number;
            SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num;
            SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).air_ocean;
            //SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).inland_type; //added by stanley on 12/14
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_name;
            SQL            += "','" + next_tran_seq_no++;
            SQL            += "','" + tran_type;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_date;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_number;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_name;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).debit_amount;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).credit_amount;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).balance;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).previous_balance;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_balance;
            SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_previous_balance;
            SQL            += "')";
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();
        }
        //INSERT INVOICE RECORD
        SQL  = "INSERT INTO [invoice] ";
        SQL += "( elt_account_number, ";
        SQL += "accounts_receivable,";
        SQL += "agent_profit, ";
        SQL += "air_ocean, ";
        SQL += "inland_type, "; //added by stanley on 12/14
        SQL += "amount_charged,";
        SQL += "amount_paid, ";
        SQL += "Arrival_Dept, ";
        SQL += "balance, ";
        SQL += "Carrier, ";
        SQL += "consignee, ";
        SQL += "Customer_info, ";
        SQL += "Customer_Name, ";
        SQL += "Customer_Number, ";
        SQL += "deposit_to, ";
        SQL += "Description, ";
        SQL += "dest,";
        if (ivRec.entry_date != null)
        {
            SQL += "entry_date, ";
        }

        SQL += "entry_no, ";
        SQL += "existing_credits, ";
        SQL += "hawb_num, ";
        SQL += "import_export, ";
        SQL += "in_memo, ";
        SQL += "invoice_date, ";
        SQL += "invoice_no, ";
        SQL += "invoice_type, ";
        SQL += "is_org_merged, ";
        SQL += "lock_ap, ";
        SQL += "lock_ar, ";
        SQL += "mawb_num, ";
        SQL += "origin, ";
        SQL += "Origin_Dest, ";
        SQL += "pay_status, ";
        SQL += "pmt_method, ";
        SQL += "received_amt, ";
        SQL += "ref_no, ";
        SQL += "ref_no_Our, ";
        SQL += "AMS_No, ";//added by stanley on 12/13/2007
        SQL += "remarks, ";
        SQL += "sale_tax, ";
        SQL += "shipper, ";
        SQL += "subtotal, ";
        SQL += "term_curr, ";
        SQL += "term30, ";
        SQL += "term60, ";
        SQL += "term90, ";
        SQL += "Total_Charge_Weight,";
        SQL += "total_cost,";
        SQL += "Total_Gross_Weight,";
        SQL += "Total_Pieces ) ";
        SQL += "VALUES";
        SQL += "('" + base.elt_account_number;
        SQL += "','" + ivRec.accounts_receivable;
        SQL += "','" + ivRec.agent_profit;
        SQL += "','" + ivRec.air_ocean;
        SQL += "','" + ivRec.inland_type; //added by stanley on 12/14
        SQL += "','" + ivRec.amount_charged;
        SQL += "','" + ivRec.amount_paid;
        SQL += "','" + ivRec.Arrival_Dept;
        SQL += "','" + ivRec.balance;
        SQL += "','" + ivRec.Carrier;
        SQL += "','" + ivRec.consignee;
        SQL += "','" + ivRec.Customer_info;
        SQL += "','" + ivRec.Customer_Name;
        SQL += "','" + ivRec.Customer_Number;
        SQL += "','" + ivRec.deposit_to;
        SQL += "','" + ivRec.Description;
        SQL += "','" + ivRec.dest;
        if (ivRec.entry_date != null)
        {
            SQL += "','" + ivRec.entry_date;
        }
        SQL += "','" + ivRec.entry_no;
        SQL += "','" + ivRec.existing_credits;
        SQL += "','" + ivRec.hawb_num;
        SQL += "','" + ivRec.import_export;
        SQL += "','" + ivRec.in_memo;
        SQL += "','" + ivRec.invoice_date;
        SQL += "','" + invoice_no;
        SQL += "','" + "I";
        SQL += "','" + ivRec.is_org_merged;
        SQL += "','" + ivRec.lock_ap;
        SQL += "','" + ivRec.lock_ar;
        SQL += "','" + ivRec.mawb_num;
        SQL += "','" + ivRec.origin;
        SQL += "','" + ivRec.Origin_Dest;
        SQL += "','" + ivRec.pay_status;
        SQL += "','" + ivRec.pmt_method;
        SQL += "','" + ivRec.received_amt;
        SQL += "','" + ivRec.ref_no; // REF NO POINTS TO INVOICE!
        SQL += "','" + ivRec.ref_no_Our;
        SQL += "','" + ivRec.AMS_No; //add by stanley on 12/13/2007
        SQL += "','" + ivRec.remarks;
        SQL += "','" + ivRec.sale_tax;
        SQL += "','" + ivRec.shipper;
        SQL += "','" + ivRec.subtotal;
        SQL += "','" + ivRec.term_curr;
        SQL += "','" + ivRec.term30;
        SQL += "','" + ivRec.term60;
        SQL += "','" + ivRec.term90;
        SQL += "','" + ivRec.Total_Charge_Weight;
        SQL += "','" + ivRec.total_cost;
        SQL += "','" + ivRec.Total_Gross_Weight;
        SQL += "','" + ivRec.Total_Pieces;
        SQL += "')";

        Cmd.CommandText = SQL;
        Cmd.ExecuteNonQuery();

        trans.Commit();
        //UPDATE NEXT INVOICE NUMBER
        ivRec.Invoice_no = invoice_no;
        updateNextInvoiceNo(invoice_no);
        return_val = true;
        //  }
        //  catch (Exception ex)
        //{
        // trans.Rollback();
        //throw ex;
        //}
        //finally
        //{
        //  Con.Close();
        //}
        return(return_val);
    }
コード例 #6
0
 /// <summary>
 /// Cache_Report
 /// </summary>
 public static void Report()
 {
     Con.DPrint("{0,4:F1} megabyte data cache, used {1,4:F1} megabyte\n",
                _Capacity / (float)(1024 * 1024), _BytesAllocated / (float)(1024 * 1024));
 }
コード例 #7
0
        public bool Adicionar(Funcionario funcionario, int verifica)//Metódo que retorna um,ou seja,verdadeiro se o funcionario pôde ser adicionado de acordo com o valor passado para o verifica,se verifica=1 ele salva o funcionário com seus dados obrigatórios e não obrigatórios,já  se verifica=0 ele salva o funcionário somente com os dados obrigatórios, sem erro e se não ele retorna 0,ou seja,falso
        {
            try {
                if (verifica > 0)
                {
                    string inserir = "INSERT INTO funcionario(nome,cpf,rg,email,tituloeleitor,telresidencial,telcelular,datanascimento,sexo,estadocivil,funcao,dataadmissao,datademissao,ctps,salario,comissao,uf,cidade,endereco,numero,complemento,bairro,cep,obs) VALUES(@nome,@cpf,@rg,@email,@tituloeleitor,@telresidencial,@telcelular,@datanascimento,@sexo,@estadocivil,@funcao,@dataadmissao,@datademissao,@ctps,@salario,@comissao,@uf,@cidade,@endereco,@numero,@complemento,@bairro,@cep,@obs);";
                    AdFuncionario = new MySqlCommand(inserir, Con);
                    Con.Open();
                    AdFuncionario.Parameters.Add(new MySqlParameter("nome", funcionario.Nome));
                    AdFuncionario.Parameters.Add(new MySqlParameter("cpf", funcionario.CPF));
                    AdFuncionario.Parameters.Add(new MySqlParameter("rg", funcionario.RG));
                    AdFuncionario.Parameters.Add(new MySqlParameter("email", funcionario.Email));
                    AdFuncionario.Parameters.Add(new MySqlParameter("tituloeleitor", funcionario.TituloEleitor));
                    AdFuncionario.Parameters.Add(new MySqlParameter("telresidencial", funcionario.TelResidencial));
                    AdFuncionario.Parameters.Add(new MySqlParameter("telcelular", funcionario.TelCelular));
                    AdFuncionario.Parameters.Add(new MySqlParameter("datanascimento", funcionario.DataNascimento.ToString("yyyy-MM-dd")));
                    AdFuncionario.Parameters.Add(new MySqlParameter("sexo", funcionario.Sexo));
                    AdFuncionario.Parameters.Add(new MySqlParameter("estadocivil", funcionario.EstadoCivil));
                    AdFuncionario.Parameters.Add(new MySqlParameter("funcao", funcionario.Funcao));
                    AdFuncionario.Parameters.Add(new MySqlParameter("dataadmissao", funcionario.DataAdmissao.ToString("yyyy-MM-dd")));
                    AdFuncionario.Parameters.Add(new MySqlParameter("datademissao", funcionario.DataDemissao));
                    AdFuncionario.Parameters.Add(new MySqlParameter("ctps", funcionario.CTPS));
                    AdFuncionario.Parameters.Add(new MySqlParameter("salario", funcionario.Salario));
                    AdFuncionario.Parameters.Add(new MySqlParameter("comissao", funcionario.Comissao));
                    AdFuncionario.Parameters.Add(new MySqlParameter("uf", funcionario.Logradouro.Cidade.UF));
                    AdFuncionario.Parameters.Add(new MySqlParameter("cidade", funcionario.Logradouro.Cidade.Nome));
                    AdFuncionario.Parameters.Add(new MySqlParameter("endereco", funcionario.Logradouro.Endereco));
                    AdFuncionario.Parameters.Add(new MySqlParameter("numero", funcionario.Logradouro.Numero));
                    AdFuncionario.Parameters.Add(new MySqlParameter("complemento", funcionario.Logradouro.Complemento));
                    AdFuncionario.Parameters.Add(new MySqlParameter("bairro", funcionario.Logradouro.Bairro));
                    AdFuncionario.Parameters.Add(new MySqlParameter("cep", funcionario.Logradouro.CEP));
                    AdFuncionario.Parameters.Add(new MySqlParameter("obs", funcionario.Obs));
                    AdFuncionario.Prepare();
                    AdFuncionario.ExecuteNonQuery();
                    Con.Close();
                }
                else
                {
                    string inserir = "INSERT INTO funcionario(nome,cpf,rg,email,tituloeleitor,telresidencial,telcelular,datanascimento,sexo,estadocivil,funcao,dataadmissao,ctps,salario,comissao,uf,cidade,endereco,numero,complemento,bairro,cep,obs) VALUES(@nome,@cpf,@rg,@email,@tituloeleitor,@telresidencial,@telcelular,@datanascimento,@sexo,@estadocivil,@funcao,@dataadmissao,@ctps,@salario,@comissao,@uf,@cidade,@endereco,@numero,@complemento,@bairro,@cep,@obs);";
                    AdFuncionario = new MySqlCommand(inserir, Con);
                    Con.Open();
                    AdFuncionario.Parameters.Add(new MySqlParameter("nome", funcionario.Nome));
                    AdFuncionario.Parameters.Add(new MySqlParameter("cpf", funcionario.CPF));
                    AdFuncionario.Parameters.Add(new MySqlParameter("rg", funcionario.RG));
                    AdFuncionario.Parameters.Add(new MySqlParameter("email", funcionario.Email));
                    AdFuncionario.Parameters.Add(new MySqlParameter("tituloeleitor", funcionario.TituloEleitor));
                    AdFuncionario.Parameters.Add(new MySqlParameter("telresidencial", funcionario.TelResidencial));
                    AdFuncionario.Parameters.Add(new MySqlParameter("telcelular", funcionario.TelCelular));
                    AdFuncionario.Parameters.Add(new MySqlParameter("datanascimento", funcionario.DataNascimento.ToString("yyyy-MM-dd")));
                    AdFuncionario.Parameters.Add(new MySqlParameter("sexo", funcionario.Sexo));
                    AdFuncionario.Parameters.Add(new MySqlParameter("estadocivil", funcionario.EstadoCivil));
                    AdFuncionario.Parameters.Add(new MySqlParameter("funcao", funcionario.Funcao));
                    AdFuncionario.Parameters.Add(new MySqlParameter("dataadmissao", funcionario.DataAdmissao.ToString("yyyy-MM-dd")));
                    AdFuncionario.Parameters.Add(new MySqlParameter("ctps", funcionario.CTPS));
                    AdFuncionario.Parameters.Add(new MySqlParameter("salario", funcionario.Salario));
                    AdFuncionario.Parameters.Add(new MySqlParameter("comissao", funcionario.Comissao));
                    AdFuncionario.Parameters.Add(new MySqlParameter("uf", funcionario.Logradouro.Cidade.UF));
                    AdFuncionario.Parameters.Add(new MySqlParameter("cidade", funcionario.Logradouro.Cidade.Nome));
                    AdFuncionario.Parameters.Add(new MySqlParameter("endereco", funcionario.Logradouro.Endereco));
                    AdFuncionario.Parameters.Add(new MySqlParameter("numero", funcionario.Logradouro.Numero));
                    AdFuncionario.Parameters.Add(new MySqlParameter("complemento", funcionario.Logradouro.Complemento));
                    AdFuncionario.Parameters.Add(new MySqlParameter("bairro", funcionario.Logradouro.Bairro));
                    AdFuncionario.Parameters.Add(new MySqlParameter("cep", funcionario.Logradouro.CEP));
                    AdFuncionario.Parameters.Add(new MySqlParameter("obs", funcionario.Obs));
                    AdFuncionario.Prepare();
                    AdFuncionario.ExecuteNonQuery();
                    Con.Close();
                }
                verifica = 1;
            }

            catch   {
                verifica = 0;
            }
            return(verifica > 0);
        }
コード例 #8
0
 public void Insert(TEntity obj)
 {
     Con.Entry(obj).State = EntityState.Added; //inserindo..
     Con.SaveChanges();                        //executando.
 }
コード例 #9
0
 public void Update(TEntity obj)
 {
     Con.Entry(obj).State = EntityState.Modified; //atualizando..
     Con.SaveChanges();                           //executando..
 }
コード例 #10
0
 public List <TEntity> FindAll()
 {
     return(Con.Set <TEntity>().ToList());
 }
コード例 #11
0
 public TEntity FindById(int id)
 {
     return(Con.Set <TEntity>().Find(id));
 }
コード例 #12
0
 public void Delete(TEntity obj)
 {
     Con.Entry(obj).State = EntityState.Deleted; //excluindo..
     Con.SaveChanges();                          //executando..
 }
コード例 #13
0
        static int Count(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[DIR]", null, null, null, null),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string dir = vl.DefaultParam.StrValue;

            if (Str.IsEmptyStr(dir))
            {
                dir = Paths.SolutionBaseDirName;
            }

            string[] files = Directory.GetFiles(dir, "*", SearchOption.AllDirectories);

            int numLines     = 0;
            int numBytes     = 0;
            int numComments  = 0;
            int totalLetters = 0;

            Dictionary <string, int> commentsDict = new Dictionary <string, int>();

            foreach (string file in files)
            {
                string ext = Path.GetExtension(file);

                if (Str.StrCmpi(ext, ".c") || Str.StrCmpi(ext, ".cpp") || Str.StrCmpi(ext, ".h") ||
                    Str.StrCmpi(ext, ".rc") || Str.StrCmpi(ext, ".stb") || Str.StrCmpi(ext, ".cs") ||
                    Str.StrCmpi(ext, ".fx") || Str.StrCmpi(ext, ".hlsl"))
                {
                    if (Str.InStr(file, "\\.svn\\") == false && Str.InStr(file, "\\seedll\\") == false && Str.InStr(file, "\\see\\") == false && Str.InStr(file, "\\openssl\\") == false)
                    {
                        string[] lines = File.ReadAllLines(file);

                        numLines += lines.Length;
                        numBytes += (int)new FileInfo(file).Length;

                        foreach (string line in lines)
                        {
                            if (Str.InStr(line, "//") && Str.InStr(line, "// Validate arguments") == false)
                            {
                                if (commentsDict.ContainsKey(line) == false)
                                {
                                    commentsDict.Add(line, 1);
                                }
                                numComments++;

                                totalLetters += line.Trim().Length - 3;
                            }
                        }
                    }
                }
            }

            Con.WriteLine("{0} Lines,  {1} Bytes.  {2} Comments ({3} distinct, aver: {4})", Str.ToStr3(numLines), Str.ToStr3(numBytes),
                          Str.ToStr3(numComments), commentsDict.Count, totalLetters / numComments);

            return(0);
        }
コード例 #14
0
    public static void Aead_ChaCha20Poly1305_Ietf_Test()
    {
        string nonce_hex     = "07 00 00 00 40 41 42 43 44 45 46 47";
        string plaintext_hex =
            "4c 61 64 69 65 73 20 61 6e 64 20 47 65 6e 74 6c " +
            "65 6d 65 6e 20 6f 66 20 74 68 65 20 63 6c 61 73 " +
            "73 20 6f 66 20 27 39 39 3a 20 49 66 20 49 20 63 " +
            "6f 75 6c 64 20 6f 66 66 65 72 20 79 6f 75 20 6f " +
            "6e 6c 79 20 6f 6e 65 20 74 69 70 20 66 6f 72 20 " +
            "74 68 65 20 66 75 74 75 72 65 2c 20 73 75 6e 73 " +
            "63 72 65 65 6e 20 77 6f 75 6c 64 20 62 65 20 69 " +
            "74 2e";
        string aad_hex = "50 51 52 53 c0 c1 c2 c3 c4 c5 c6 c7";
        string key_hex = "80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f " +
                         "90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f";

        string rfc_mac = "1a:e1:0b:59:4f:09:e2:6a:7e:90:2e:cb:d0:60:06:91".Replace(':', ' ');
        string rfc_enc = "d3 1a 8d 34 64 8e 60 db 7b 86 af bc 53 ef 7e c2 " +
                         "a4 ad ed 51 29 6e 08 fe a9 e2 b5 a7 36 ee 62 d6 " +
                         "3d be a4 5e 8c a9 67 12 82 fa fb 69 da 92 72 8b " +
                         "1a 71 de 0a 9e 06 0b 29 05 d6 a5 b6 7e cd 3b 36 " +
                         "92 dd bd 7f 2d 77 8b 8c 98 03 ae e3 28 09 1b 58 " +
                         "fa b3 24 e4 fa d6 75 94 55 85 80 8b 48 31 d7 bc " +
                         "3f f4 de f0 8e 4b 7a 9d e5 76 d2 65 86 ce c6 4b " +
                         "61 16";

        var nonce     = nonce_hex._GetHexBytes().AsMemory();
        var plaintext = plaintext_hex._GetHexBytes().AsMemory();
        var aad       = aad_hex._GetHexBytes().AsMemory();
        var key       = key_hex._GetHexBytes().AsMemory();
        var encrypted = new byte[plaintext.Length + AeadChaCha20Poly1305MacSize].AsMemory();
        var decrypted = new byte[plaintext.Length].AsMemory();

        Con.WriteLine("Aead_ChaCha20Poly1305_Ietf_Test()");

        Aead_ChaCha20Poly1305_Ietf_Encrypt(encrypted, plaintext, key, nonce, aad);

        string encrypted_hex = encrypted.Slice(0, plaintext.Length).ToArray()._GetHexString(" ");
        string mac_hex       = encrypted.Slice(plaintext.Length, AeadChaCha20Poly1305MacSize).ToArray()._GetHexString(" ");

        Con.WriteLine($"Encrypted:\n{encrypted_hex}\n");

        Con.WriteLine($"MAC:\n{mac_hex}\n");

        var a = rfc_enc._GetHexBytes();

        if (encrypted.Slice(0, plaintext.Length).Span.SequenceEqual(a) == false)
        {
            throw new ApplicationException("encrypted != rfc_enc");
        }

        Con.WriteLine("Check OK.");

        if (Aead_ChaCha20Poly1305_Ietf_Decrypt(decrypted, encrypted, key, nonce, aad) == false)
        {
            throw new ApplicationException("Decrypt failed.");
        }
        else
        {
            Con.WriteLine("Decrypt OK.");

            if (plaintext.Span.SequenceEqual(decrypted.Span))
            {
                Con.WriteLine("Same OK.");
            }
            else
            {
                throw new ApplicationException("Different !!!");
            }
        }
    }
コード例 #15
0
 public DataSet ExecuteProcDataSet(string procName, out DbParameterCollection dbpc, params DbParameter[] param)
 {
     if (IsBeginTransaction)
     {
         try
         {
             Cmd.CommandType = CommandType.StoredProcedure;
             Cmd.CommandText = procName;
             Cmd.Parameters.AddRange(param);
             using (DbDataAdapter da = Factory.CreateDataAdapter())
             {
                 da.SelectCommand = Cmd;
                 DataSet ds = new DataSet();
                 da.Fill(ds);
                 dbpc = da.SelectCommand.Parameters;
                 return(ds);
             }
         }
         catch
         {
             try
             {
                 RollbackTransaction();
                 throw;
             }
             catch
             {
                 throw;
             }
         }
     }
     else
     {
         using (Con = Factory.CreateConnection())
         {
             using (Cmd = Con.CreateCommand())
             {
                 try
                 {
                     Con.ConnectionString = ConnectionString;
                     Cmd.CommandType      = CommandType.StoredProcedure;
                     Cmd.CommandText      = procName;
                     Cmd.Parameters.AddRange(param);
                     using (DbDataAdapter da = Factory.CreateDataAdapter())
                     {
                         da.SelectCommand = Cmd;
                         DataSet ds = new DataSet();
                         da.Fill(ds);
                         dbpc = da.SelectCommand.Parameters;
                         return(ds);
                     }
                 }
                 catch
                 {
                     Con.Close();
                     throw;
                 }
             }
         }
     }
 }
コード例 #16
0
    public bool insert_customer_credit(customerCreditRecord ccRec)//农贰调老 版快/Refund 老 版快
    {
        int return_val;

        ccRec.replaceQuote();

        ArrayList AAJEntryList = ccRec.all_accounts_journal_list;

        if (AAJEntryList == null)
        {
            AAJEntryList = new ArrayList();
        }
        for (int i = 0; i < AAJEntryList.Count; i++)
        {
            AAJMgr.checkInitial_Acct_Record((AllAccountsJournalRecord)AAJEntryList[i]);
        }
        int next_tran_seq_no = AAJMgr.getNextTranSeqNumber();

        int entry_no = getNextEntryNo(ccRec.customer_no);

        Cmd            = new SqlCommand();
        Cmd.Connection = Con;
        Con.Open();

        SqlTransaction trans = Con.BeginTransaction();

        Cmd.Transaction = trans;
        if (AAJEntryList.Count > 0)
        {
            for (int i = 0; i < AAJEntryList.Count; i++)
            {
                ((AllAccountsJournalRecord)AAJEntryList[i]).replaceQuote();

                if (((AllAccountsJournalRecord)AAJEntryList[i]).tran_num == null || ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num == 0)//Only when there is no entry
                {
                    ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num = entry_no;
                }

                SQL  = "INSERT INTO [all_accounts_journal] ";
                SQL += "( elt_account_number, ";
                SQL += "tran_num,";
                SQL += "gl_account_number,";
                SQL += "gl_account_name,";
                SQL += "tran_seq_num,";
                SQL += "tran_type,";
                SQL += "tran_date,";
                SQL += "Customer_Number,";
                SQL += "Customer_Name,";
                SQL += "debit_amount,";
                SQL += "credit_amount,";
                SQL += "balance,";
                SQL += "previous_balance,";
                SQL += "gl_balance,";
                SQL += "gl_previous_balance)";
                SQL += "VALUES";
                SQL += "('" + elt_account_number;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_name;
                SQL += "','" + next_tran_seq_no++;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_type;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_date;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_number;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_name;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).debit_amount;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).credit_amount;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).balance;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).previous_balance;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_balance;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_previous_balance;
                SQL += "')";

                Cmd.CommandText = SQL;
                Cmd.ExecuteNonQuery();
            }
        }

        SQL  = "INSERT INTO [customer_credit_info] ";
        SQL += "(elt_account_number, ";
        SQL += "customer_no,";
        SQL += "customer_name,";
        SQL += "tran_date,";
        SQL += "memo,";
        SQL += "entry_no,";
        SQL += "ref_no,";
        SQL += "invoice_no,";
        SQL += "credit)";
        SQL += "VALUES";
        SQL += "('" + elt_account_number;
        SQL += "','" + ccRec.customer_no;
        SQL += "','" + ccRec.customer_name;
        SQL += "','" + ccRec.tran_date;
        SQL += "','" + ccRec.memo;
        SQL += "','" + entry_no;
        SQL += "','" + ccRec.ref_no;
        SQL += "','" + ccRec.invoice_no;
        SQL += "','" + ccRec.credit;
        SQL += "')";


        Cmd.CommandText = SQL;
        return_val      = Cmd.ExecuteNonQuery();

        try
        {
            trans.Commit();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            Con.Close();
        }

        if (return_val == 1)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #17
0
        public static object?_DebugAsJson(this object?o, bool includeNull = false, bool escapeHtml = false, int?maxDepth = Json.DefaultMaxDepth, bool compact = false, bool referenceHandling = false, Type?type = null, JsonFlags jsonFlags = JsonFlags.None)
        {
            Con.WriteJsonDebug(o, includeNull, escapeHtml, maxDepth, compact, referenceHandling, type, jsonFlags);

            return(o);
        }
コード例 #18
0
        // メインループ
        async Task MainLoopAsync(CancellationToken cancel)
        {
            int numRetry = 0;

            int numOk = 0;

            int intervalCache = 0;

            string lastError = "";

            bool firstConnected = false;

            Con.WriteInfo($"DaemonCenterClient: Trying to connect to the DaemonCenter Server '{this.Settings.ServerUrl}' ...");

            while (this.GrandCancel.IsCancellationRequested == false)
            {
                int nextInterval;

                try
                {
                    nextInterval = await PerformOnceAsync(cancel);

                    if (firstConnected == false)
                    {
                        firstConnected = true;

                        Con.WriteInfo($"DaemonCenterClient: Connected OK.");
                    }

                    if (nextInterval == -1)
                    {
                        // 再起動が要求されたら、ここに飛ぶ。
                        // メインループを直ちに終了する。
                        break;
                    }
                    else
                    {
                        intervalCache = nextInterval;

                        nextInterval = Util.GenRandInterval(nextInterval);
                    }

                    numRetry = 0;

                    numOk++;
                    if (numOk == 1)
                    {
                        // 初回のみ nextInterval を 100 msec にする (直ちに再試行するようにする)
                        nextInterval = 100;
                    }
                }
                catch (Exception ex)
                {
                    firstConnected = false;

                    string errStr = ex._GetSingleException().ToString();

                    if (lastError != errStr)
                    {
                        lastError = errStr;
                        Con.WriteError($"DaemonCenterClient Error: {errStr}");
                    }

                    numRetry++;

                    numOk = 0;

                    if (intervalCache == 0)
                    {
                        nextInterval = Util.GenRandIntervalWithRetry(CoresConfig.DaemonCenterLibSettings.RetryIntervalMsecsStandard, numRetry,
                                                                     CoresConfig.DaemonCenterLibSettings.RetryIntervalMsecsMax);
                    }
                    else
                    {
                        nextInterval = Util.GenRandInterval(intervalCache);
                    }
                }

                await cancel._WaitUntilCanceledAsync(nextInterval);
            }
        }
コード例 #19
0
    public TelnetStreamWatcherBase(TelnetStreamWatcherOptions options)
    {
        this.Options = options;

        Listener = TcpIp.CreateTcpListener(new TcpListenParam(async(listener, sock) =>
        {
            try
            {
                Con.WriteDebug($"TelnetStreamWatcher({this.ToString()}: Connected: {sock.EndPointInfo._GetObjectDump()}");

                await using (var destStream = sock.GetStream())
                {
                    if (sock.Info.Ip.RemoteIPAddress == null || Options.IPAccessFilter(sock.Info.Ip.RemoteIPAddress) == false)
                    {
                        Con.WriteDebug($"TelnetStreamWatcher({this.ToString()}: Access denied: {sock.EndPointInfo._GetObjectDump()}");

                        await destStream.WriteAsync("You are not allowed to access to this service.\r\n\r\n"._GetBytes_Ascii());

                        await Task.Delay(100);

                        return;
                    }

                    using (var pipePoint = await SubscribeImplAsync())
                    {
                        // ソケットから Enter キー入力を待機する
                        Task keyInputTask = TaskUtil.StartAsyncTaskAsync(async() =>
                        {
                            using StreamReader lineReader = new StreamReader(destStream);

                            while (true)
                            {
                                string?line = await lineReader.ReadLineAsync();

                                if (line == null)
                                {
                                    break;
                                }

                                line = line.Trim();

                                if (line._IsSamei("s"))
                                {
                                    // Socket リストの表示
                                    var list = LocalNet.GetSockList().OrderBy(x => x.Connected);

                                    StringWriter w = new StringWriter();

                                    w.WriteLine();

                                    foreach (var sock in list)
                                    {
                                        string tmp = sock._GetObjectDump();
                                        w.WriteLine(tmp);
                                    }

                                    w.WriteLine();

                                    w.WriteLine($"Total sockets: {list.Count()}");

                                    w.WriteLine();

                                    byte[] data = w.ToString()._GetBytes_Ascii();

                                    var pipe = pipePoint;
                                    if (pipe.CounterPart != null)
                                    {
                                        lock (pipe.CounterPart.StreamWriter.LockObj)
                                        {
                                            if (pipe.CounterPart.StreamWriter.NonStopWriteWithLock(data, false, FastStreamNonStopWriteMode.DiscardExistingData) != 0)
                                            {
                                                // To avoid deadlock, CompleteWrite() must be called from other thread.
                                                // (CompleteWrite() ==> Disconnect ==> Socket Log will recorded ==> ReceiveLog() ==> this function will be called!)
                                                TaskUtil.StartSyncTaskAsync(() => pipe.CounterPart.StreamWriter.CompleteWrite(false), false, false)._LaissezFaire(true);
                                            }
                                        }
                                    }
                                }
                                else if (line._IsSamei("0"))
                                {
                                    // GC
                                    Dbg.WriteLine($"Manual GC0 is called by the administrator.");

                                    long start = Time.HighResTick64;
                                    GC.Collect(0, GCCollectionMode.Forced, true, true);
                                    long end = Time.HighResTick64;

                                    long spentTime = end - start;

                                    Dbg.WriteLine($"Manual GC0 Took Time: {spentTime} msecs.");
                                }
                                else if (line._IsSamei("1"))
                                {
                                    // GC
                                    Dbg.WriteLine($"Manual GC1 is called by the administrator.");

                                    long start = Time.HighResTick64;
                                    GC.Collect(1, GCCollectionMode.Forced, true, true);
                                    long end = Time.HighResTick64;

                                    long spentTime = end - start;

                                    Dbg.WriteLine($"Manual GC1 Took Time: {spentTime} msecs.");
                                }
                                else
                                {
                                    // GC
                                    Dbg.WriteLine($"Manual GC is called by the administrator.");

                                    long start = Time.HighResTick64;
                                    Dbg.GcCollect();
                                    long end = Time.HighResTick64;

                                    long spentTime = end - start;

                                    Dbg.WriteLine($"Manual GC Took Time: {spentTime} msecs.");
                                }
                            }
                        });

                        try
                        {
                            // ソケットに対して、pipePoint のストリームをそのまま非同期で流し込む
                            await using (var pipeStub = pipePoint.GetNetAppProtocolStub())
                                await using (var srcStream = pipeStub.GetStream())
                                {
                                    await srcStream.CopyToAsync(destStream, sock.GrandCancel);
                                }
                        }
                        finally
                        {
                            await UnsubscribeImplAsync(pipePoint);

                            await pipePoint.CleanupAsync(new DisconnectedException());

                            await keyInputTask._TryAwait(noDebugMessage: true);
                        }
                    }
                }
            }
            finally
            {
                Con.WriteDebug($"TelnetStreamWatcher({this.ToString()}: Disconnected: {sock.EndPointInfo._GetObjectDump()}");
            }
        },
                                                              "TelnetStreamWatcher",
                                                              this.Options.EndPoints.ToArray()));

        this.AddIndirectDisposeLink(this.Listener);
    }
コード例 #20
0
        public Task <string> Update(List <InvStockRequisitionModel> aModel)
        {
            try
            {
                Con.Open();
                Thread.Sleep(5);
                _trans = Con.BeginTransaction();
                const string query = @"UPDATE  tbl_INVSTOCK_REQUISITION SET
                                DisburseBy=@DisburseBy,DisburseDate=@DisburseDate,DisburseTime=@DisburseTime,UserName=@UserName,UserDtls=@UserDtls,DisburseNote=@DisburseNote,Status=@Status
                                WHERE ReqNo=@ReqNo ";
                var          cmd   = new SqlCommand(query, Con, _trans);
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@ReqNo", aModel.ElementAt(0).ReqNo);
                cmd.Parameters.AddWithValue("@DisburseBy", aModel.ElementAt(0).UserName);
                cmd.Parameters.AddWithValue("@DisburseDate", DateTime.Now.ToString("yyyy-MM-dd"));
                cmd.Parameters.AddWithValue("@DisburseTime", DateTime.Now.ToShortTimeString());
                cmd.Parameters.AddWithValue("@UserName", aModel.ElementAt(0).UserName);
                //  cmd.Parameters.AddWithValue("@BranchId", GetBranchIdByuserNameOpenCon(aModel.ElementAt(0).UserName, _trans));
                cmd.Parameters.AddWithValue("@UserDtls", aModel.ElementAt(0).UserDtls);
                cmd.Parameters.AddWithValue("@DisburseNote", aModel.ElementAt(0).DisburseNote);
                cmd.Parameters.AddWithValue("@Status", 4);
                cmd.ExecuteNonQuery();


                for (int i = 0; i < aModel.Count; i++)
                {
                    const string lcQuery = @"UPDATE  tbl_INVSTOCK_REQUISITION_DETAIL SET  DisburseQty=@DisburseQty WHERE MasterId=@MasterId AND ProductId=@ProductId";
                    var          cmd2    = new SqlCommand(lcQuery, Con, _trans);
                    cmd2.Parameters.Clear();
                    cmd2.Parameters.AddWithValue("@MasterId", aModel.ElementAt(i).MasterId);
                    cmd2.Parameters.AddWithValue("@ProductId", aModel.ElementAt(i).ProductId);
                    cmd2.Parameters.AddWithValue("@DisburseQty", aModel.ElementAt(i).DisburseQty);
                    cmd2.ExecuteNonQuery();
                }
                //------------tbl_INVSTOCK_StockLedger--------------------Start------------
                int    PnoId    = 84;
                var    branchId = GetBranchIdByuserNameOpenCon(aModel.ElementAt(0).UserName, _trans);
                string RefNo    = GetAutoIncrementNumberFromStoreProcedure(17, _trans);

                foreach (var stockReq in aModel)
                {
                    var listItem = new List <InvStockRequisitionModel>();

                    // string queryItem = @"select a.InvoiceNo,a.PurchasePrice,a.PnoId,a.CompanyId,a.ItemId,(a.InQty-a.OutQty+a.RtnQty) as BalQty from tbl_INVSTOCK_StockLedger as a where a.PnoId=" + PnoId + " and a.BranchId=" + branchId + " and a.ItemId=" + stockReq.ProductId + " order by InvoiceDate";
                    string queryItem = @"select a.InvoiceNo,a.PurchasePrice,a.PnoId,a.CompanyId,a.ItemId,SUM(a.InQty-a.OutQty+a.RtnQty)as BalQty from tbl_INVSTOCK_StockLedger as a where a.PnoId=" + PnoId + " and a.BranchId=" + branchId + " and a.ItemId=" + stockReq.ProductId + "  group by a.InvoiceNo,a.PurchasePrice,a.PnoId,a.CompanyId,a.ItemId,InvoiceDate  HAVING SUM(a.InQty-a.OutQty+a.RtnQty)>0  order by InvoiceDate";
                    cmd = new SqlCommand(queryItem, Con, _trans);
                    var rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        listItem.Add(new InvStockRequisitionModel()
                        {
                            BalQty        = Convert.ToDouble(rdr["BalQty"].ToString()),
                            ProductId     = Convert.ToInt32(rdr["ItemId"]),
                            CompanyId     = Convert.ToInt32(rdr["CompanyId"]),
                            PurchasePrice = Convert.ToDouble(rdr["PurchasePrice"]),
                            PnoId         = Convert.ToInt32(rdr["PnoId"]),
                            InvoiceNo     = rdr["InvoiceNo"].ToString(),
                        });
                    }
                    rdr.Close();

                    foreach (var item in listItem)
                    {
                        if (stockReq.DisburseQty != 0)
                        {
                            if (stockReq.DisburseQty >= item.BalQty)
                            {
                                //  tbl_PHAR_STOCKLEDGER Pharmacy OUt
                                var query_sl1 = @"INSERT INTO tbl_INVSTOCK_StockLedger (RefNo, RefDate, InvoiceNo, InvoiceDate, CompanyId, ItemId, PurchasePrice, OutQty, Status, PnoId, EntryDate, UserName, BranchId, Valid, EntryTime, RecevedBy, TrStatus) VALUES (@RefNo, @RefDate, @InvoiceNo, @InvoiceDate, @CompanyId, @ItemId, @PurchasePrice, @OutQty, @Status, @PnoId, @EntryDate, @UserName, @BranchId, @Valid, @EntryTime, @RecevedBy, @TrStatus)";
                                cmd = new SqlCommand(query_sl1, Con, _trans);
                                cmd.Parameters.Clear();
                                cmd.Parameters.AddWithValue("@RefNo", RefNo);
                                cmd.Parameters.AddWithValue("@RefDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd.Parameters.AddWithValue("@InvoiceNo", item.InvoiceNo);
                                cmd.Parameters.AddWithValue("@InvoiceDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd.Parameters.AddWithValue("@CompanyId", item.CompanyId);
                                cmd.Parameters.AddWithValue("@ItemId", item.ProductId);
                                cmd.Parameters.AddWithValue("@PurchasePrice", item.PurchasePrice);
                                cmd.Parameters.AddWithValue("@OutQty", item.BalQty);
                                cmd.Parameters.AddWithValue("@Status", "Out");
                                cmd.Parameters.AddWithValue("@PnoId", "84");
                                cmd.Parameters.AddWithValue("@EntryDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd.Parameters.AddWithValue("@UserName", stockReq.UserName);
                                cmd.Parameters.AddWithValue("@BranchId", GetBranchIdByuserNameOpenCon(stockReq.UserName, _trans));
                                cmd.Parameters.AddWithValue("@Valid", "1");
                                cmd.Parameters.AddWithValue("@EntryTime", DateTime.Now.ToShortTimeString());
                                cmd.Parameters.AddWithValue("@RecevedBy", stockReq.DisburseTo);
                                cmd.Parameters.AddWithValue("@TrStatus", stockReq.ReqNo);
                                cmd.ExecuteNonQuery();

                                //  tbl_PHAR_STOCKLEDGER SubStore IN
                                var query_In = @"INSERT INTO tbl_INVSTOCK_StockLedger (RefNo, RefDate, InvoiceNo, InvoiceDate, CompanyId, ItemId, PurchasePrice, InQty, Status, PnoId, EntryDate, UserName, BranchId, Valid, EntryTime, RecevedBy, TrStatus) VALUES (@RefNo, @RefDate, @InvoiceNo, @InvoiceDate, @CompanyId, @ItemId, @PurchasePrice, @InQty, @Status, @PnoId, @EntryDate, @UserName, @BranchId, @Valid, @EntryTime, @RecevedBy, @TrStatus)";
                                var cmd4     = new SqlCommand(query_In, Con, _trans);
                                cmd4.Parameters.Clear();
                                cmd4.Parameters.AddWithValue("@RefNo", RefNo);
                                cmd4.Parameters.AddWithValue("@RefDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd4.Parameters.AddWithValue("@InvoiceNo", item.InvoiceNo);
                                cmd4.Parameters.AddWithValue("@InvoiceDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd4.Parameters.AddWithValue("@CompanyId", item.CompanyId);
                                cmd4.Parameters.AddWithValue("@ItemId", item.ProductId);
                                cmd4.Parameters.AddWithValue("@PurchasePrice", item.PurchasePrice);
                                cmd4.Parameters.AddWithValue("@InQty", item.BalQty);
                                cmd4.Parameters.AddWithValue("@Status", "In");
                                cmd4.Parameters.AddWithValue("@PnoId", stockReq.DeptId);
                                cmd4.Parameters.AddWithValue("@EntryDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd4.Parameters.AddWithValue("@UserName", stockReq.UserName);
                                cmd4.Parameters.AddWithValue("@BranchId", GetBranchIdByuserNameOpenCon(stockReq.UserName, _trans));
                                cmd4.Parameters.AddWithValue("@Valid", "1");
                                cmd4.Parameters.AddWithValue("@EntryTime", DateTime.Now.ToShortTimeString());
                                cmd4.Parameters.AddWithValue("@RecevedBy", stockReq.DisburseTo);
                                cmd4.Parameters.AddWithValue("@TrStatus", stockReq.ReqNo);
                                cmd4.ExecuteNonQuery();
                                stockReq.DisburseQty -= item.BalQty;
                            }
                            else
                            {
                                var query_sl1 = @"INSERT INTO tbl_INVSTOCK_StockLedger (RefNo, RefDate, InvoiceNo, InvoiceDate, CompanyId, ItemId, PurchasePrice, OutQty, Status, PnoId, EntryDate, UserName, BranchId, Valid, EntryTime, RecevedBy, TrStatus) VALUES (@RefNo, @RefDate, @InvoiceNo, @InvoiceDate, @CompanyId, @ItemId, @PurchasePrice, @OutQty, @Status, @PnoId, @EntryDate, @UserName, @BranchId, @Valid, @EntryTime, @RecevedBy, @TrStatus)";
                                cmd = new SqlCommand(query_sl1, Con, _trans);
                                cmd.Parameters.Clear();
                                cmd.Parameters.AddWithValue("@RefNo", RefNo);
                                cmd.Parameters.AddWithValue("@RefDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd.Parameters.AddWithValue("@InvoiceNo", item.InvoiceNo);
                                cmd.Parameters.AddWithValue("@InvoiceDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd.Parameters.AddWithValue("@CompanyId", item.CompanyId);
                                cmd.Parameters.AddWithValue("@ItemId", item.ProductId);
                                cmd.Parameters.AddWithValue("@PurchasePrice", item.PurchasePrice);
                                cmd.Parameters.AddWithValue("@OutQty", stockReq.DisburseQty);
                                cmd.Parameters.AddWithValue("@Status", "Out");
                                cmd.Parameters.AddWithValue("@PnoId", "84");
                                cmd.Parameters.AddWithValue("@EntryDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd.Parameters.AddWithValue("@UserName", stockReq.UserName);
                                cmd.Parameters.AddWithValue("@BranchId", GetBranchIdByuserNameOpenCon(stockReq.UserName, _trans));
                                cmd.Parameters.AddWithValue("@Valid", "1");
                                cmd.Parameters.AddWithValue("@EntryTime", DateTime.Now.ToShortTimeString());
                                cmd.Parameters.AddWithValue("@RecevedBy", stockReq.DisburseTo);
                                cmd.Parameters.AddWithValue("@TrStatus", stockReq.ReqNo);
                                cmd.ExecuteNonQuery();

                                //

                                var query_In = @"INSERT INTO tbl_INVSTOCK_StockLedger (RefNo, RefDate, InvoiceNo, InvoiceDate, CompanyId, ItemId, PurchasePrice, InQty, Status, PnoId, EntryDate, UserName, BranchId, Valid, EntryTime, RecevedBy, TrStatus) VALUES (@RefNo, @RefDate, @InvoiceNo, @InvoiceDate, @CompanyId, @ItemId, @PurchasePrice, @InQty, @Status, @PnoId, @EntryDate, @UserName, @BranchId, @Valid, @EntryTime, @RecevedBy, @TrStatus)";
                                var cmd4     = new SqlCommand(query_In, Con, _trans);
                                cmd4.Parameters.Clear();
                                cmd4.Parameters.AddWithValue("@RefNo", RefNo);
                                cmd4.Parameters.AddWithValue("@RefDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd4.Parameters.AddWithValue("@InvoiceNo", item.InvoiceNo);
                                cmd4.Parameters.AddWithValue("@InvoiceDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd4.Parameters.AddWithValue("@CompanyId", item.CompanyId);
                                cmd4.Parameters.AddWithValue("@ItemId", item.ProductId);
                                cmd4.Parameters.AddWithValue("@PurchasePrice", item.PurchasePrice);
                                cmd4.Parameters.AddWithValue("@InQty", stockReq.DisburseQty);
                                cmd4.Parameters.AddWithValue("@Status", "In");
                                cmd4.Parameters.AddWithValue("@PnoId", stockReq.DeptId);
                                cmd4.Parameters.AddWithValue("@EntryDate", DateTime.Now.ToString("yyyy-MM-dd"));
                                cmd4.Parameters.AddWithValue("@UserName", stockReq.UserName);
                                cmd4.Parameters.AddWithValue("@BranchId", GetBranchIdByuserNameOpenCon(stockReq.UserName, _trans));
                                cmd4.Parameters.AddWithValue("@Valid", "1");
                                cmd4.Parameters.AddWithValue("@EntryTime", DateTime.Now.ToShortTimeString());
                                cmd4.Parameters.AddWithValue("@RecevedBy", stockReq.DisburseTo);
                                cmd4.Parameters.AddWithValue("@TrStatus", stockReq.ReqNo);
                                cmd4.ExecuteNonQuery();
                                stockReq.DisburseQty -= stockReq.DisburseQty;
                            }
                        }

                        else
                        {
                            break;
                        }
                    }
                }
                //------------tbl_INVSTOCK_StockLedger--------------------End------------
                _trans.Commit();
                Con.Close();
                return(Task.FromResult("Save Successful"));
            }
            catch (Exception exception)
            {
                if (Con.State == ConnectionState.Open)
                {
                    _trans.Rollback();
                    Con.Close();
                }
                return(Task.FromResult(exception.Message));
            }
        }
コード例 #21
0
        // Create a release
        public virtual void Release(string baseOutputDir)
        {
            string srcDir          = Path.Combine(baseOutputDir, this.CrossLibName + @"\src");
            string releaseFileName = Path.Combine(Paths.ReleaseDir, this.OutputFileName);

            Con.WriteLine("Generating '{0}'...", releaseFileName);

            List <string> files = new List <string>();
            string        gccOptionForLink;
            string        gccOptionForCompile;

            generateGccOptions(srcDir, false, false, out gccOptionForLink, out gccOptionForCompile);

            string targetName = this.Software.ToString();

            // Makefile
            StringWriter mk = GenerateMakeFileForRelease(srcDir);

            byte[] mkData = Str.NormalizeCrlf(Str.Utf8Encoding.GetBytes(mk.ToString()), new byte[] { 10 });

            TarPacker tar = new TarPacker();

            tar.AddFileSimple(targetName + @"\Makefile", mkData, 0, mkData.Length, DateTime.Now);

            // Install Script
            string isText = File.ReadAllText(Paths.UnixInstallScript);

            isText = Str.ReplaceStr(isText, "<TITLE>", TitleString, false);
            byte[] scriptData = Str.NormalizeCrlf(Str.Utf8Encoding.GetBytes(isText), new byte[] { 10 });
            tar.AddFileSimple(targetName + @"\.install.sh", scriptData, 0, scriptData.Length, DateTime.Now);

            // EULA
            Encoding enc = Str.Utf8Encoding;

            if (true)
            {
                string srcData = File.ReadAllText(Path.Combine(Paths.BinDirName, @"hamcore\eula.txt"),
                                                  enc);

                byte[] destData = enc.GetBytes(srcData);

                tar.AddFileSimple(targetName + @"\" + "ReadMeFirst_License.txt", destData, 0, destData.Length, DateTime.Now);
            }

            if (true)
            {
                string srcData = File.ReadAllText(Path.Combine(Paths.BinDirName, @"hamcore\authors.txt"),
                                                  enc);

                byte[] destData = enc.GetBytes(srcData);

                tar.AddFileSimple(targetName + @"\" + "Authors.txt", destData, 0, destData.Length, DateTime.Now);
            }

            if (true)
            {
                string srcData = File.ReadAllText(Path.Combine(Paths.BinDirName, @"hamcore\warning_ja.txt"),
                                                  enc);

                byte[] destData = enc.GetBytes(srcData);

                tar.AddFileSimple(targetName + @"\" + "ReadMeFirst_Important_Notices_ja.txt", destData, 0, destData.Length, DateTime.Now);
            }

            if (true)
            {
                string srcData = File.ReadAllText(Path.Combine(Paths.BinDirName, @"hamcore\warning_en.txt"),
                                                  enc);

                byte[] destData = enc.GetBytes(srcData);

                tar.AddFileSimple(targetName + @"\" + "ReadMeFirst_Important_Notices_en.txt", destData, 0, destData.Length, DateTime.Now);
            }

            if (true)
            {
                string srcData = File.ReadAllText(Path.Combine(Paths.BinDirName, @"hamcore\warning_cn.txt"),
                                                  enc);

                byte[] destData = enc.GetBytes(srcData);

                tar.AddFileSimple(targetName + @"\" + "ReadMeFirst_Important_Notices_cn.txt", destData, 0, destData.Length, DateTime.Now);
            }


            // Codes
            string[] dirs =
            {
                Path.Combine(srcDir, "code"),
                Path.Combine(srcDir, "lib"),
            };

            foreach (string dir in dirs)
            {
                string[] fileList = Directory.GetFiles(dir, "*.a", SearchOption.TopDirectoryOnly);

                if (Path.GetFileName(dir).Equals("code", StringComparison.InvariantCultureIgnoreCase))
                {
                    fileList = new string[]
                    {
                        Path.Combine(dir, string.Format("{0}.a", this.Software.ToString())),
                        Path.Combine(dir, "vpncmd.a"),
                    };
                }

                foreach (string fileName in fileList)
                {
                    if (Str.StrCmpi(Path.GetFileName(fileName), "libpcap.a") == false)
                    {
                        // Libpcap.a is not included in the release
                        byte[] fileData = File.ReadAllBytes(fileName);

                        tar.AddFileSimple(targetName + @"\" + IO.GetRelativeFileName(fileName, srcDir),
                                          fileData, 0, fileData.Length, DateTime.Now);
                    }
                }
            }

            // License file
            byte[] lsFileData = File.ReadAllBytes(Path.Combine(CrossLibBaseDir, @"License.txt"));
            tar.AddFileSimple(targetName + @"\lib\License.txt", lsFileData, 0, lsFileData.Length, DateTime.Now);

            // HamCore
            byte[] hcData = File.ReadAllBytes(Path.Combine(Paths.BaseDirName, string.Format(@"bin\BuiltHamcoreFiles\hamcore_unix\hamcore.se2")));
            tar.AddFileSimple(targetName + @"\hamcore.se2", hcData, 0, hcData.Length, DateTime.Now);

            // Generate a tar
            tar.Finish();
            byte[] tarData = tar.CompressToGZip();

            File.WriteAllBytes(releaseFileName, tarData);

            Con.WriteLine("Finished.");
        }
コード例 #22
0
 public void Dispose()
 {
     Con.Dispose();//this is what is actually disposed
 }
コード例 #23
0
ファイル: Win32BuildUtil.cs プロジェクト: NTek/SoftEtherVPN
        // Apply build number, version number, user name, and PC name to the source code
        public static void NormalizeSourceCode(int buildNumber, int version, string userName, string pcName, DateTime date)
        {
            DateTime now = date;

            char[] seps = { '\t', ' ', };

            int i = pcName.IndexOf(".");

            if (i != -1)
            {
                pcName = pcName.Substring(0, i);
            }

            userName = userName.ToLower();
            pcName   = pcName.ToLower();

            string[] files = Util.CombineArray <string>(
                Directory.GetFiles(Paths.BaseDirName, "*.h", SearchOption.AllDirectories));

            foreach (string file in files)
            {
                string dir = Path.GetDirectoryName(file);
                if (Str.InStr(dir, @"\.svn\") == false &&
                    Str.InStr(IO.GetRelativeFileName(file, Paths.BaseDirName), @"tmp\") == false)
                {
                    byte[] srcData = File.ReadAllBytes(file);

                    int      bomSize;
                    Encoding enc = Str.GetEncoding(srcData, out bomSize);
                    if (enc == null)
                    {
                        enc = Str.Utf8Encoding;
                    }
                    StringReader r = new StringReader(enc.GetString(Util.ExtractByteArray(srcData, bomSize, srcData.Length - bomSize)));
                    StringWriter w = new StringWriter();
                    bool         somethingChanged = false;

                    while (true)
                    {
                        string line = r.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        string newLine = null;

                        string[] tokens = line.Split(seps, StringSplitOptions.RemoveEmptyEntries);

                        if (tokens.Length >= 1)
                        {
                            if (file.EndsWith(".h", StringComparison.InvariantCultureIgnoreCase))
                            {
                                if (tokens.Length == 3)
                                {
                                    // Build number portion of the source code
                                    if (tokens[0].Equals("//") && tokens[1].Equals("Build") && Str.IsNumber(tokens[2]))
                                    {
                                        newLine = line.Replace(tokens[2], buildNumber.ToString());
                                    }
                                }
                            }

                            if (file.EndsWith(".h", StringComparison.InvariantCultureIgnoreCase))
                            {
                                if (tokens.Length == 3)
                                {
                                    // String part of the version information of Cedar.h
                                    if (tokens[0].Equals("#define") && tokens[1].Equals("CEDAR_BUILD"))
                                    {
                                        newLine = line.Replace(tokens[2], buildNumber.ToString());
                                    }

                                    if (tokens[0].Equals("#define") && tokens[1].Equals("CEDAR_VER"))
                                    {
                                        newLine = line.Replace(tokens[2], version.ToString());
                                    }

                                    if (tokens[0].Equals("#define") && tokens[1].Equals("BUILDER_NAME"))
                                    {
                                        newLine = line.Replace(tokens[2], "\"" + userName + "\"");
                                    }

                                    if (tokens[0].Equals("#define") && tokens[1].Equals("BUILD_PLACE"))
                                    {
                                        newLine = line.Replace(tokens[2], "\"" + pcName + "\"");
                                    }

                                    if (tokens[0].Equals("#define") && tokens[1].Equals("BUILD_DATE_Y"))
                                    {
                                        newLine = line.Replace(tokens[2], date.Year.ToString());
                                    }

                                    if (tokens[0].Equals("#define") && tokens[1].Equals("BUILD_DATE_M"))
                                    {
                                        newLine = line.Replace(tokens[2], date.Month.ToString());
                                    }

                                    if (tokens[0].Equals("#define") && tokens[1].Equals("BUILD_DATE_D"))
                                    {
                                        newLine = line.Replace(tokens[2], date.Day.ToString());
                                    }

                                    if (tokens[0].Equals("#define") && tokens[1].Equals("BUILD_DATE_HO"))
                                    {
                                        newLine = line.Replace(tokens[2], date.Hour.ToString());
                                    }

                                    if (tokens[0].Equals("#define") && tokens[1].Equals("BUILD_DATE_MI"))
                                    {
                                        newLine = line.Replace(tokens[2], date.Minute.ToString());
                                    }

                                    if (tokens[0].Equals("#define") && tokens[1].Equals("BUILD_DATE_SE"))
                                    {
                                        newLine = line.Replace(tokens[2], date.Second.ToString());
                                    }
                                }

                                if (tokens.Length >= 3)
                                {
                                    if (tokens[0].Equals("#define") && tokens[1].Equals("SUPPORTED_WINDOWS_LIST"))
                                    {
                                        newLine = "#define\tSUPPORTED_WINDOWS_LIST\t\t\"" + OSList.Windows.OSSimpleList + "\"";
                                    }
                                }
                            }
                        }

                        if (newLine == null || newLine == line)
                        {
                            w.WriteLine(line);
                        }
                        else
                        {
                            w.WriteLine(newLine);

                            somethingChanged = true;
                        }
                    }

                    if (somethingChanged)
                    {
                        byte[] retData = Str.ConvertEncoding(Str.Utf8Encoding.GetBytes(w.ToString()), enc, bomSize != 0);

                        File.WriteAllBytes(file, retData);

                        Con.WriteLine("Modified: '{0}'.", file);
                    }
                }
            }
        }
コード例 #24
0
ファイル: Download.cs プロジェクト: MintLily/BSLegacyUtil
        public static void DLGameAsync(string gameVersionInput)
        {
            gameVersion = gameVersionInput;
            //bool faulted = false;
            if (BuildInfo.isWindows)
            {
                if (!Directory.Exists(Environment.CurrentDirectory + "/Beat Saber"))
                {
                    Directory.CreateDirectory(Environment.CurrentDirectory + "/Beat Saber");
                }
            }
            else
            {
                if (!Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}Beat Saber"))
                {
                    Directory.CreateDirectory($"{AppDomain.CurrentDomain.BaseDirectory}Beat Saber");
                }
            }

            try { // https://steamdb.info/app/620980/history/
                manifestID = getManifestFromVersion(gameVersionInput);

                #region Old Switch Case

                /*faulted = false;
                 *
                 * switch (gameVersion) {
                 *  case "0.10.1":
                 *      manifestID = "6316038906315325420";
                 *      //faulted = false;
                 *      break;
                 *  case "0.10.2":
                 *      manifestID = "2542095265882143144";
                 *      faulted = false;
                 *      break;
                 *  case "0.10.2p1":
                 *      manifestID = "5611588554149133260";
                 *      faulted = false;
                 *      break;
                 *  case "0.11.0":
                 *      manifestID = "8700049030626148111";
                 *      faulted = false;
                 *      break;
                 *  case "0.11.1":
                 *      manifestID = "6574193224879562324";
                 *      faulted = false;
                 *      break;
                 *  case "0.11.2":
                 *      manifestID = "2707973953401625222";
                 *      faulted = false;
                 *      break;
                 *  case "0.12.0":
                 *      manifestID = "6094599000655593822";
                 *      faulted = false;
                 *      break;
                 *  case "0.12.0p1":
                 *      manifestID = "2068421223689664394";
                 *      faulted = false;
                 *      break;
                 *  case "0.12.1":
                 *      manifestID = "2472041066434647526";
                 *      faulted = false;
                 *      break;
                 *  case "0.12.2":
                 *      manifestID = "5325635033564462932";
                 *      faulted = false;
                 *      break;
                 *  case "0.13.0":
                 *      manifestID = "3102409495238838111";
                 *      faulted = false;
                 *      break;
                 *  case "0.13.0p1":
                 *      manifestID = "6827433614670733798";
                 *      faulted = false;
                 *      break;
                 *  case "0.13.1":
                 *      manifestID = "6033025349617217666";
                 *      faulted = false;
                 *      break;
                 *  case "0.13.2":
                 *      manifestID = "6839388023573913446";
                 *      faulted = false;
                 *      break;
                 *  case "1.0.0":
                 *      manifestID = "152937782137361764";
                 *      faulted = false;
                 *      break;
                 *  case "1.0.1":
                 *      manifestID = "7950322551526208347";
                 *      faulted = false;
                 *      break;
                 *  case "1.1.0":
                 *      manifestID = "1400454104881094752";
                 *      faulted = false;
                 *      break;
                 *  case "1.0.0p1":
                 *      manifestID = "1041583928494277430";
                 *      faulted = false;
                 *      break;
                 *  case "1.2.0":
                 *      manifestID = "3820905673516362176";
                 *      faulted = false;
                 *      break;
                 *  case "1.3.0":
                 *      manifestID = "2440312204809283162";
                 *      faulted = false;
                 *      break;
                 *  case "1.4.0":
                 *      manifestID = "3532596684905902618";
                 *      faulted = false;
                 *      break;
                 *  case "1.4.2":
                 *      manifestID = "1199049250928380207";
                 *      faulted = false;
                 *      break;
                 *  case "1.5.0":
                 *      manifestID = "2831333980042022356";
                 *      faulted = false;
                 *      break;
                 *  case "1.6.0":
                 *      manifestID = "1869974316274529288";
                 *      faulted = false;
                 *      break;
                 *  case "1.6.1":
                 *      manifestID = "6122319670026856947";
                 *      faulted = false;
                 *      break;
                 *  case "1.6.2":
                 *      manifestID = "4932559146183937357";
                 *      faulted = false;
                 *      break;
                 *  case "1.7.0":
                 *      manifestID = "3516084911940449222";
                 *      faulted = false;
                 *      break;
                 *  case "1.8.0":
                 *      manifestID = "3177969677109016846";
                 *      faulted = false;
                 *      break;
                 *  case "1.9.0":
                 *      manifestID = "7885463693258878294";
                 *      faulted = false;
                 *      break;
                 *  case "1.9.1":
                 *      manifestID = "6222769774084748916";
                 *      faulted = false;
                 *      break;
                 *  case "1.10.0":
                 *      manifestID = "6711131863503994755";
                 *      faulted = false;
                 *      break;
                 *  case "1.11.0":
                 *      manifestID = "1919603726987963829";
                 *      faulted = false;
                 *      break;
                 *  case "1.11.1":
                 *      manifestID = "3268824881806146387";
                 *      faulted = false;
                 *      break;
                 *  case "1.12.1":
                 *      manifestID = "2928416283534881313";
                 *      faulted = false;
                 *      break;
                 *  case "1.12.2":
                 *      manifestID = "543439039654962432";
                 *      faulted = false;
                 *      break;
                 *  case "1.13.0":
                 *      manifestID = "4635119747389290346";
                 *      faulted = false;
                 *      break;
                 *  case "1.13.2":
                 *      manifestID = "8571679771389514488";
                 *      faulted = false;
                 *      break;
                 *  case "1.13.4":
                 *      manifestID = "1257277263145069282";
                 *      faulted = false;
                 *      break;
                 *  case "1.13.5":
                 *      manifestID = "7007516983116400336";
                 *      faulted = false;
                 *      break;
                 *  case "1.14.0":
                 *      manifestID = "9218225910501819399";
                 *      faulted = false;
                 *      break;
                 *  case "1.15.0":
                 *      manifestID = "7624554893344753887";
                 *      faulted = false;
                 *      break;
                 *  case "1.16.0":
                 *      manifestID = "3667184295685865706";
                 *      faulted = false;
                 *      break;
                 *  case "1.16.1":
                 *      manifestID = "9201874499606445062";
                 *      faulted = false;
                 *      break;
                 *  case "1.16.2":
                 *      manifestID = "3692829915208062825";
                 *      faulted = false;
                 *      break;
                 *  case "1.16.3":
                 *      manifestID = "6392596175313869009";
                 *      faulted = false;
                 *      break;
                 *  case "1.16.4":
                 *      manifestID = "8820433629543698585";
                 *      faulted = false;
                 *      break;
                 *  case "1.17.0":
                 *      manifestID = "7826684224434229804";
                 *      faulted = false;
                 *      break;
                 *  case "1.17.1":
                 *      manifestID = "4668547658954826996";
                 *      faulted = false;
                 *      break;
                 *  case "1.18.0":
                 *      manifestID = "5599254819160454367";
                 *      faulted = false;
                 *      break;
                 *  case "1.18.1":
                 *      manifestID = "8961661233382948062";
                 *      faulted = false;
                 *      break;
                 *  case "1.18.2":
                 *      manifestID = "6835596583028648427";
                 *      faulted = false;
                 *      break;
                 *  case "1.18.3":
                 *      manifestID = "6558821762131072991";
                 *      faulted = false;
                 *      break;
                 *  default: // https://steamdb.info/app/620980/history/
                 *      manifestID = "";
                 *      faulted = true;
                 *      Con.Error("Invalid input. Please input a valid version number.");
                 *      Con.Space();
                 *      SelectGameVersion(true);
                 *      break;
                 * }
                 */

                #endregion
            } catch (Exception @switch) {
                //faulted = true;
                //Con.Error(@switch.ToString());
                Con.ErrorException(@switch.StackTrace, @switch.ToString());
                Con.Error("Invalid input. Please input a valid version number.");
                Con.Space();
                SelectGameVersion(true);
            }

            Con.Log($"Game Version: {gameVersionInput} => [{manifestID}] from year {getYearFromVersion(gameVersionInput)}");

            if (/*!faulted && */ !string.IsNullOrWhiteSpace(manifestID))
            {
                inputSteamLogin();
                try { // Program from https://github.com/SteamRE/DepotDownloader
                    Con.Space();
                    if (BuildInfo.isWindows)
                    {
                        download = Process.Start("dotnet",
                                                 "Depotdownloader\\DepotDownloader.dll -app 620980 -depot 620981 -manifest " + manifestID +
                                                 " -username " + steamUsername + " -password " + steamPassword +
                                                 " -dir \"Beat Saber\" -validate");
                    }
                    else
                    {
                        download = Process.Start("dotnet",
                                                 $"{AppDomain.CurrentDomain.BaseDirectory}Depotdownloader/DepotDownloader.dll -app 620980 -depot 620981 -manifest " +
                                                 manifestID +
                                                 " -username " + steamUsername + " -password " + steamPassword +
                                                 " -dir \"Beat Saber\" -validate");
                    }

                    if (download != null)
                    {
                        download.WaitForExit();
                        Con.Space();
                        if (string.IsNullOrWhiteSpace(gameVersion))
                        {
                            Con.LogSuccess("Finished downloading Beat Saber");
                        }
                        else
                        {
                            Con.LogSuccess($"Finished downloading Beat Saber {gameVersion}");
                        }

                        Con.Space();
                        Con.Log("Would you like to continue? [Y/N]");
                        Con.Input();
                        string @continue = Console.ReadLine();

                        if (@continue.ToLower().Contains("yes") || @continue.ToLower().Contains("y"))
                        {
                            BeginInputOption();
                        }
                        else
                        {
                            Utilities.Utilities.Kill();
                        }
                    }
                }
                catch (Exception downgrade) {
                    Con.ErrorException(downgrade.StackTrace, downgrade.ToString());
                }
            }
        }
コード例 #25
0
    public bool updateInvoiceRecord(ref InvoiceRecord ivRec, string tran_type)
    {
        bool return_val = false;
        int  loopV      = 0;

        ivRec.replaceQuote();

        int             invoice_no = ivRec.Invoice_no;
        ARStatusManager ARSMgr     = new ARStatusManager(elt_account_number);
        bool            ar_lock    = ARSMgr.FindIfPaymentProcessed(invoice_no);
        //UPDATE IV CHARGE ITEMS IF AR_NOT PROCESSED

        ArrayList AAJEntryList = ivRec.AllAccountsJournalList;

        Cmd            = new SqlCommand();
        Cmd.Connection = Con;
        Con.Open();
        SqlTransaction trans = Con.BeginTransaction();

        Cmd.Transaction = trans;

        try
        {
            if (!ar_lock)
            {
                //1) DELETE PREV IV CHARGE ITEMS WITH INVOICE_NO
                SQL  = "DELETE FROM invoice_charge_item WHERE elt_account_number =";
                SQL += elt_account_number + " and invoice_no="
                       + invoice_no;
                Cmd.CommandText = SQL;
                Cmd.ExecuteNonQuery();
                //2) INSERT IV CHARGE ITEM
                ArrayList chList = ivRec.ChargeItemList;
                for (int i = 0; i < chList.Count; i++)
                {
                    IVChargeItemRecord IVChR = (IVChargeItemRecord)chList[i];
                    IVChR.replaceQuote();
                    IVChR.Invoice_no = invoice_no;
                    SQL             = "INSERT INTO [invoice_charge_item] ";
                    SQL            += "( elt_account_number, ";
                    SQL            += "invoice_no,";
                    SQL            += "item_id,";
                    SQL            += "item_no,";
                    SQL            += "item_desc,";
                    SQL            += "qty,";
                    SQL            += "charge_amount,";
                    SQL            += "import_export,";
                    SQL            += "mb_no,";
                    SQL            += "hb_no,";
                    SQL            += "iType)";
                    SQL            += "VALUES";
                    SQL            += "('" + elt_account_number;
                    SQL            += "','" + IVChR.Invoice_no;
                    SQL            += "','" + IVChR.Item_id;
                    SQL            += "','" + IVChR.Item_no;
                    SQL            += "','" + IVChR.Item_desc;
                    SQL            += "','" + IVChR.Qty;
                    SQL            += "','" + IVChR.Charge_amount;
                    SQL            += "','" + IVChR.Import_export;
                    SQL            += "','" + IVChR.Mb_no;
                    SQL            += "','" + IVChR.Hb_no;
                    SQL            += "','" + IVChR.IType;
                    SQL            += "')";
                    Cmd.CommandText = SQL;
                    Cmd.ExecuteNonQuery();
                }
            }
            //INSERT IV COST ITEMS
            //1) DELETE UNLOCKED PREV IV COST ITEMS WITH INVOICE_NO
            SQL  = "DELETE FROM invoice_cost_item WHERE elt_account_number =";
            SQL += elt_account_number + "  and invoice_no="
                   + invoice_no;
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();

            //2) INSERT IV_COST_ITEM
            ArrayList cstList = ivRec.CostItemList;
            for (int i = 0; i < cstList.Count; i++)
            {
                IVCostItemRecord IVCostR = (IVCostItemRecord)cstList[i];
                IVCostR.replaceQuote();

                SQL             = "INSERT INTO [invoice_Cost_item] ";
                SQL            += "( elt_account_number, ";
                SQL            += "invoice_no,";
                SQL            += "item_id,";
                SQL            += "item_no,";
                SQL            += "item_desc,";
                SQL            += "qty,";
                SQL            += "ref_no,";
                SQL            += "vendor_no,";
                SQL            += "Cost_amount,";
                SQL            += "import_export,";
                SQL            += "mb_no,";
                SQL            += "hb_no,";
                SQL            += "iType)";
                SQL            += "VALUES";
                SQL            += "('" + elt_account_number;
                SQL            += "','" + invoice_no;
                SQL            += "','" + IVCostR.Item_id;
                SQL            += "','" + IVCostR.Item_no;
                SQL            += "','" + IVCostR.Item_desc;
                SQL            += "','" + IVCostR.Qty;
                SQL            += "','" + IVCostR.Ref_no;
                SQL            += "','" + IVCostR.Vendor_no;
                SQL            += "','" + IVCostR.Cost_amount;
                SQL            += "','" + IVCostR.Import_export;
                SQL            += "','" + IVCostR.Mb_no;
                SQL            += "','" + IVCostR.Hb_no;
                SQL            += "','" + IVCostR.IType;
                SQL            += "')";
                Cmd.CommandText = SQL;
                Cmd.ExecuteNonQuery();
            }
            //DELETE BILL_DETAIL WHITH INVOICE_NO THAT DOES NOT HAVE ANY BILL_NO ASSINGED

            SQL  = "DELETE FROM bill_detail WHERE elt_account_number =";
            SQL += elt_account_number + " and invoice_no="
                   + invoice_no + " and isnull(bill_number,0) =0";
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();
            //INSERT BILL DETAILS WITH BILL_NUMBER BEING 0 AND WHITH INVOICE_NO THAT DOES NOT HAVE ANY BILL_NO ASSINGED
            ArrayList bdList = ivRec.BillDetailList;
            for (int i = 0; i < bdList.Count; i++)
            {
                BillDetailRecord bDRec = (BillDetailRecord)bdList[i];
                bDRec.replaceQuote();
                if (bDRec.bill_number == 0)
                {
                    SQL             = "INSERT INTO [bill_detail] ";
                    SQL            += "( elt_account_number, ";
                    SQL            += "item_ap,";
                    SQL            += "item_id,";
                    SQL            += "item_no,";
                    SQL            += "item_amt,";
                    SQL            += "is_manual,";
                    SQL            += "item_expense_acct,";
                    SQL            += "tran_date,";
                    SQL            += "invoice_no,";
                    SQL            += "agent_debit_no,";
                    SQL            += "mb_no,";
                    SQL            += "hb_no,";
                    SQL            += "ref,";
                    SQL            += "iType,";
                    SQL            += "import_export,";
                    SQL            += "vendor_number)";
                    SQL            += "VALUES";
                    SQL            += "('" + elt_account_number;
                    SQL            += "','" + bDRec.item_ap;
                    SQL            += "','" + bDRec.item_id;
                    SQL            += "','" + bDRec.item_no;
                    SQL            += "','" + bDRec.item_amt;
                    SQL            += "','" + bDRec.is_manual;
                    SQL            += "','" + bDRec.item_expense_acct;
                    SQL            += "','" + bDRec.tran_date;
                    SQL            += "','" + invoice_no;
                    SQL            += "','" + bDRec.agent_debit_no;
                    SQL            += "','" + bDRec.mb_no;
                    SQL            += "','" + bDRec.hb_no;
                    SQL            += "','" + bDRec.ref_no;
                    SQL            += "','" + bDRec.iType;
                    SQL            += "','" + bDRec.import_export;
                    SQL            += "','" + bDRec.vendor_number;
                    SQL            += "')";
                    Cmd.CommandText = SQL;
                    Cmd.ExecuteNonQuery();
                }
            }

            //DELETE ALL ENTRY WITH TRAN_NO BEING INVOICE_NO AND TRAN_TYPE BEING "INV";
            SQL  = "DELETE FROM invoice_header WHERE elt_account_number =";
            SQL += elt_account_number + " and invoice_no="
                   + invoice_no;
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();

            //Insert IV Headers

            ArrayList ihList = ivRec.InvoiceHeaders;
            if (tran_type == "INV")
            {
                loopV = ihList.Count;
            }
            for (int i = 0; i < loopV; i++)
            {
                //ihList.Count
                IVHeaderRecord ihRec = (IVHeaderRecord)ihList[i];

                SQL             = "INSERT INTO [invoice_header] ";
                SQL            += "( elt_account_number, ";
                SQL            += "Carrier,";
                SQL            += "ChargeableWeight,";
                SQL            += "Consignee,";
                SQL            += "Destination,";
                SQL            += "ETA,";
                SQL            += "ETD,";
                SQL            += "FILE_NO,";
                SQL            += "GrossWeight,";
                SQL            += "hawb,";
                SQL            += "invoice_no,";
                SQL            += "mawb,";
                SQL            += "Origin,";
                SQL            += "Pieces,";
                SQL            += "Shipper,";
                SQL            += "unit)";
                SQL            += "VALUES";
                SQL            += "('" + elt_account_number;
                SQL            += "','" + ihRec.Carrier;
                SQL            += "','" + ihRec.ChargeableWeight;
                SQL            += "','" + ihRec.Consignee;
                SQL            += "','" + ihRec.Destination;
                SQL            += "','" + ihRec.ETA;
                SQL            += "','" + ihRec.ETD;
                SQL            += "','" + ihRec.FILE;
                SQL            += "','" + ihRec.GrossWeight;
                SQL            += "','" + ihRec.hawb;
                SQL            += "','" + invoice_no;
                SQL            += "','" + ihRec.mawb;
                SQL            += "','" + ihRec.Origin;
                SQL            += "','" + ihRec.Pieces;
                SQL            += "','" + ihRec.Shipper;
                SQL            += "','" + ihRec.unit;
                SQL            += "')";
                Cmd.CommandText = SQL;
                Cmd.ExecuteNonQuery();
            }

            //DELETE ALL ENTRY WITH TRAN_NO BEING INVOICE_NO AND TRAN_TYPE BEING "INV";
            SQL  = "DELETE FROM all_accounts_journal WHERE elt_account_number =";
            SQL += elt_account_number + " and tran_num="
                   + invoice_no + " and tran_type='" + tran_type + "'";
            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();

            int next_tran_seq_no = 0;

            SQL = "select max(tran_seq_num) from all_accounts_journal where elt_account_number = "
                  + elt_account_number;
            Cmd.CommandText = SQL;
            int current = 0;

            string id_str = Cmd.ExecuteScalar().ToString();
            if (id_str != "")
            {
                current = Int32.Parse(id_str);
            }
            else
            {
                current = 0;
            }

            next_tran_seq_no = current + 1;
            //INSERT AAJ ENTRY WITH TRAN_TYPE BEING INV AND TRAN_NO BEING INVOICE_NO
            for (int i = 0; i < AAJEntryList.Count; i++)
            {
                ((AllAccountsJournalRecord)AAJEntryList[i]).replaceQuote();
                ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num = invoice_no;
                SQL  = "INSERT INTO [all_accounts_journal] ";
                SQL += "( elt_account_number, ";
                SQL += "tran_num,";
                SQL += "gl_account_number,";
                SQL += "gl_account_name,";
                SQL += "tran_seq_num,";
                SQL += "air_ocean,";
                //SQL += "inland_type,"; //added by stanley on 12/14
                SQL += "tran_type,";
                SQL += "tran_date,";
                SQL += "Customer_Number,";
                SQL += "Customer_Name,";
                SQL += "debit_amount,";
                SQL += "credit_amount,";
                SQL += "balance,";
                SQL += "previous_balance,";
                SQL += "gl_balance,";
                SQL += "gl_previous_balance)";
                SQL += "VALUES";
                SQL += "('" + elt_account_number;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_name;
                SQL += "','" + next_tran_seq_no++;
                SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).air_ocean;
                //SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).inland_type;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_type;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_date;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_number;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_name;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).debit_amount;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).credit_amount;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).balance;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).previous_balance;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_balance;
                SQL            += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_previous_balance;
                SQL            += "')";
                Cmd.CommandText = SQL;
                Cmd.ExecuteNonQuery();
            }
            SQL  = "update invoice set ";
            SQL += "accounts_receivable= '" + ivRec.accounts_receivable + "', ";
            SQL += "agent_profit= '" + ivRec.agent_profit + "'  ,";
            SQL += "air_ocean= '" + ivRec.air_ocean + "'  ,";
            SQL += "inland_type= '" + ivRec.inland_type + "'  ,"; //added by stanley on 12/14
            SQL += "amount_charged= '" + ivRec.amount_charged + "'  ,";
            SQL += "amount_paid= '" + ivRec.amount_paid + "'  ,";
            SQL += "Arrival_Dept= '" + ivRec.Arrival_Dept + "'  ,";
            Decimal balace = ivRec.amount_charged - ivRec.amount_paid;
            SQL += "balance= '" + balace.ToString() + "'  ,";
            SQL += "Carrier= '" + ivRec.Carrier + "'  ,";
            SQL += "consignee= '" + ivRec.consignee + "'  ,";
            SQL += "Customer_info= '" + ivRec.Customer_info + "'  ,";
            SQL += "Customer_Name= '" + ivRec.Customer_Name + "'  ,";
            SQL += "Customer_Number= '" + ivRec.Customer_Number + "'  ,";
            SQL += "deposit_to= '" + ivRec.deposit_to + "'  ,";
            SQL += "Description= '" + ivRec.Description + "'  ,";
            SQL += "dest= '" + ivRec.dest + "'  ,";
            SQL += "entry_date= '" + ivRec.entry_date + "'  ,";
            SQL += "entry_no= '" + ivRec.entry_no + "'  ,";
            SQL += "existing_credits= '" + ivRec.existing_credits + "'  ,";
            SQL += "hawb_num= '" + ivRec.hawb_num + "'  ,";
            SQL += "import_export= '" + ivRec.import_export + "'  ,";
            SQL += "in_memo= '" + ivRec.in_memo + "'  ,";
            SQL += "invoice_date= '" + System.DateTime.Parse(ivRec.invoice_date) + "'  ,";
            SQL += "invoice_no= '" + ivRec.Invoice_no + "'  ,";
            SQL += "invoice_type= '" + ivRec.invoice_type + "'  ,";
            SQL += "is_org_merged= '" + ivRec.is_org_merged + "'  ,";
            SQL += "lock_ap= '" + ivRec.lock_ap + "'  ,";
            SQL += "lock_ar= '" + ivRec.lock_ar + "'  ,";
            SQL += "mawb_num= '" + ivRec.mawb_num + "'  ,";
            SQL += "origin= '" + ivRec.origin + "'  ,";
            SQL += "Origin_Dest= '" + ivRec.Origin_Dest + "'  ,";
            SQL += "pay_status= '" + ivRec.pay_status + "'  ,";
            SQL += "pmt_method= '" + ivRec.pmt_method + "'  ,";
            SQL += "received_amt= '" + ivRec.received_amt + "'  ,";
            SQL += "ref_no= '" + ivRec.ref_no + "'  ,";
            SQL += "ref_no_Our= '" + ivRec.ref_no_Our + "'  ,";
            SQL += "AMS_No= '" + ivRec.AMS_No + "'  ,";//added by stanley on 12/13/2007
            SQL += "remarks= '" + ivRec.remarks + "'  ,";
            SQL += "sale_tax= '" + ivRec.sale_tax + "'  ,";
            SQL += "shipper= '" + ivRec.shipper + "'  ,";
            SQL += "subtotal= '" + ivRec.subtotal + "'  ,";
            SQL += "term_curr= '" + ivRec.term_curr + "'  ,";
            SQL += "term30= '" + ivRec.term30 + "'  ,";
            SQL += "term60= '" + ivRec.term60 + "'  ,";
            SQL += "term90= '" + ivRec.term90 + "'  ,";
            SQL += "Total_Charge_Weight= '" + ivRec.Total_Charge_Weight + "'  ,";
            SQL += "total_cost= '" + ivRec.total_cost + "'  ,";
            SQL += "Total_Gross_Weight= '" + ivRec.Total_Gross_Weight + "'  ,";
            SQL += "Total_Pieces= '" + ivRec.Total_Pieces + "' ";
            SQL += " WHERE elt_account_number = " + elt_account_number + " and invoice_no=" + ivRec.Invoice_no;

            Cmd.CommandText = SQL;
            Cmd.ExecuteNonQuery();
            trans.Commit();
            return_val = true;
        }
        catch (Exception ex)
        {
            trans.Rollback();
            throw ex;
        }
        finally
        {
            Con.Close();
        }
        return(return_val);
    }
コード例 #26
0
 public DataTable GetDataTable(string sql, CommandType CommandType, params DbParameter[] param)
 {
     if (IsBeginTransaction)
     {
         try
         {
             Cmd.CommandType = CommandType;
             Cmd.CommandText = sql;
             Cmd.Parameters.AddRange(param);
             using (DbDataAdapter da = Factory.CreateDataAdapter())
             {
                 da.SelectCommand = Cmd;
                 DataTable dt = new DataTable();
                 da.Fill(dt);
                 return(dt);
             }
         }
         catch
         {
             try
             {
                 RollbackTransaction();
                 throw;
             }
             catch
             {
                 throw;
             }
         }
     }
     else
     {
         using (Con = Factory.CreateConnection())
         {
             using (Cmd = Con.CreateCommand())
             {
                 try
                 {
                     Con.ConnectionString = ConnectionString;
                     Cmd.CommandType      = CommandType;
                     Cmd.CommandText      = sql;
                     Cmd.Parameters.AddRange(param);
                     Con.Open();
                     using (DbDataAdapter da = Factory.CreateDataAdapter())
                     {
                         da.SelectCommand = Cmd;
                         DataTable dt = new DataTable();
                         da.Fill(dt);
                         return(dt);
                     }
                 }
                 catch
                 {
                     MessageBox.Show(Cmd.CommandText);
                     Con.Close();
                     throw;
                 }
             }
         }
     }
 }
コード例 #27
0
 // Logs a debug message.
 private static void Log(string message)
 {
     Con.Log(message);
 }
コード例 #28
0
 public DataRow GetDataRow(string sql, int index, CommandType CommandType, params DbParameter[] param)
 {
     if (IsBeginTransaction)
     {
         try
         {
             Cmd.CommandType = CommandType;
             Cmd.CommandText = sql;
             Cmd.Parameters.AddRange(param);
             using (DbDataAdapter da = Factory.CreateDataAdapter())
             {
                 da.SelectCommand = Cmd;
                 DataTable dt = new DataTable();
                 da.Fill(dt);
                 if (dt != null && dt.Rows.Count > 0)
                 {
                     return(dt.Rows[index]);
                 }
                 return(null);
             }
         }
         catch
         {
             try
             {
                 RollbackTransaction();
                 throw;
             }
             catch
             {
                 throw;
             }
         }
     }
     else
     {
         using (Con = Factory.CreateConnection())
         {
             using (Cmd = Con.CreateCommand())
             {
                 try
                 {
                     Con.ConnectionString = ConnectionString;
                     Cmd.CommandType      = CommandType;
                     Cmd.CommandText      = sql;
                     Cmd.Parameters.AddRange(param);
                     Con.Open();
                     using (DbDataAdapter da = Factory.CreateDataAdapter())
                     {
                         da.SelectCommand = Cmd;
                         DataTable dt = new DataTable();
                         da.Fill(dt);
                         if (dt != null && dt.Rows.Count > 0)
                         {
                             return(dt.Rows[index]);
                         }
                         return(null);
                     }
                 }
                 catch
                 {
                     Con.Close();
                     throw;
                 }
             }
         }
     }
 }
コード例 #29
0
        /// <summary>
        /// Author: Samuel Gardner
        /// </summary>
        public void LoadData()
        {
            var tempLineUp      = new List <Pokemon>();
            var getPokemonQuery = (TrainerName == string.Empty ? "SELECT `Pokemon1`,`MovesCSV1`,`Pokemon2`,`MovesCSV2`,`Pokemon3`,`MovesCSV3`" +
                                   ",`Pokemon4`,`MovesCSV4`,`Pokemon5`,`MovesCSV5`,`Pokemon6`,`MovesCSV6`" +
                                   " FROM sql3346222.TrainerLineup WHERE(UserID = @ID);" :
                                   "SELECT `Pokemon1`,`MovesCSV1`,`Pokemon2`,`MovesCSV2`,`Pokemon3`,`MovesCSV3`" +
                                   ",`Pokemon4`,`MovesCSV4`,`Pokemon5`,`MovesCSV5`,`Pokemon6`,`MovesCSV6`" +
                                   " FROM sql3346222.EliteFour WHERE(TrainerName = @Username);");


            //Get pokemon from DB
            Con.Open();
            MySqlCommand cmd = new MySqlCommand(getPokemonQuery, Con);

            if (TrainerName == string.Empty)
            {
                cmd.Parameters.Add(@"@ID", MySqlDbType.Int32);
                cmd.Parameters[@"@ID"].Value = TrainerId;
            }
            else
            {
                cmd.Parameters.Add(@"@Username", MySqlDbType.VarChar);
                cmd.Parameters[@"@Username"].Value = TrainerName;
            }
            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                var tasks = new Queue <Tuple <Task <PokeAPI.Pokemon>, List <Task <PokeAPI.Move> > > >();
                Dictionary <string, Task <PokeAPI.Pokemon> > requestedPokemon = new Dictionary <string, Task <PokeAPI.Pokemon> >();
                Dictionary <string, Task <PokeAPI.Move> >    requestedMoves   = new Dictionary <string, Task <PokeAPI.Move> >();
                Task <PokeAPI.Pokemon>      tempGetPoke = null;
                List <Task <PokeAPI.Move> > tempGetMove = null;
                while (reader.Read())
                {
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        if (i % 2 == 0)
                        {
                            //this record is a pokemon.
                            string cleaned = reader.GetString(i).Trim().ToLower();
                            if (requestedPokemon.ContainsKey(cleaned))
                            {
                                Console.WriteLine($"Pokemon {cleaned} already requested, removing redundancy...");
                                tempGetPoke = requestedPokemon[cleaned];
                            }
                            else
                            {
                                Console.WriteLine($"Starting request for pokemon: {cleaned}...");
                                tempGetPoke = DataFetcher.GetNamedApiObject <PokeAPI.Pokemon>(cleaned);
                                requestedPokemon.Add(cleaned, tempGetPoke);
                            }
                            //tempGetPoke.Start();
                        }
                        else
                        {
                            //this record is a moves.
                            tempGetMove = reader.GetString(i).Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x =>
                            {
                                string cleaned = x.Trim().ToLower();
                                if (requestedMoves.ContainsKey(cleaned))
                                {
                                    Console.WriteLine($"Move {cleaned} already requested, removing redundancy...");
                                    return(requestedMoves[cleaned]);
                                }
                                else
                                {
                                    Console.WriteLine($"Starting request for move: {cleaned}...");
                                    requestedMoves.Add(cleaned, DataFetcher.GetNamedApiObject <PokeAPI.Move>(cleaned));
                                    return(requestedMoves[cleaned]);
                                }
                            }).ToList();
                            //tempGetMove = GetMovesAsync(reader.GetString(i).Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray());
                            //tempGetMove.ForEach(x =>
                            //{
                            //    x.Start();
                            //});
                        }
                        if (tempGetMove != null && tempGetPoke != null)
                        {
                            tasks.Enqueue(new Tuple <Task <PokeAPI.Pokemon>, List <Task <PokeAPI.Move> > >(tempGetPoke, tempGetMove));
                            tempGetMove = null;
                            tempGetPoke = null;
                        }
                    }
                }
                //Task.WaitAll(tasks.Select(x => new List<Task>(x.Item2).Add(x.Item1)).Aggregate((x, y) => x.Concat(y).ToArray()));
                foreach (Tuple <Task <PokeAPI.Pokemon>, List <Task <PokeAPI.Move> > > e in tasks)
                {
                    Task.WaitAll((e.Item2.Select(x => (Task)x).Append((Task)e.Item1)).ToArray());
                    int hp = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "hp").BaseValue;
                    tempLineUp.Add(new Pokemon()
                    {
                        BaseHP         = hp,
                        ActingHP       = hp,
                        Attack         = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "attack").BaseValue,
                        Defense        = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "defense").BaseValue,
                        SpecialAttack  = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "special-attack").BaseValue,
                        SpecialDefense = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "special-defense").BaseValue,
                        Speed          = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "speed").BaseValue,
                        BackImageUri   = e.Item1.Result.Sprites.BackFemale ?? e.Item1.Result.Sprites.BackMale,
                        FrontImageUri  = e.Item1.Result.Sprites.FrontFemale ?? e.Item1.Result.Sprites.FrontMale,
                        Id             = e.Item1.Result.ID,
                        Species        = e.Item1.Result.Species.Name,
                        ConsoleMoves   = e.Item2.Select(x => new Move()
                        {
                            Damage     = x.Result.Power ?? 0,
                            IsPhysical = x.Result.DamageClass.Name == "physical",
                            Name       = x.Result.Name,
                            Type       = x.Result.Type.Name
                        }).ToList(),
                        ConsoleTypes = e.Item1.Result.Types.Select(x => x.Type.Name).ToList(),
                        Moves        = e.Item2.Select(x => new Web.Shared.Models.MoveModel()
                        {
                            Category    = x.Result.DamageClass.Name,
                            Damage      = x.Result.Power ?? 0,
                            Id          = x.Result.ID,
                            Name        = x.Result.Name,
                            ResourceUri = null,    //Not sure what to do about this field.
                            Seleted     = default, //Not sure what to do about this either.
コード例 #30
0
    static void Net_Test11_AcceptLoop()
    {
        if (test11_flag == false)
        {
            test11_flag = true;

            new ThreadObj(param =>
            {
                ThreadObj.Current.Thread.Priority = System.Threading.ThreadPriority.Highest;
                int last = 0;
                while (true)
                {
                    int value = Environment.TickCount;
                    int span  = value - last;
                    last      = value;
                    Console.WriteLine("tick: " + span);
                    ThreadObj.Sleep(100);
                }
            });
        }

        using (var listener = LocalNet.CreateTcpListener(new TcpListenParam(
                                                             async(listener2, sock) =>
        {
            while (true)
            {
                var stream = sock.GetStream();
                StreamReader r = new StreamReader(stream);

                while (true)
                {
                    string?line = await r.ReadLineAsync();

                    if (line._IsEmpty())
                    {
                        break;
                    }
                }
                int segmentSize = 400;
                int numSegments = 1000;
                int totalSize = segmentSize * numSegments;

                string ret =
                    $@"HTTP/1.1 200 OK
Content-Length: {totalSize}

";

                await stream.WriteAsync(ret._GetBytes_Ascii());

                byte[] buf = Util.Rand(numSegments);
                for (int i = 0; i < numSegments; i++)
                {
                    await stream.WriteAsync(buf);
                }
            }
        },
                                                             null,
                                                             80)))
        {
            Con.ReadLine(" > ");
        }
    }