Пример #1
0
        private void DoWalletQuery(QueryCriteria c)
        {
            int handle = 0;

            Global.BCCInit();
            //make a new bcc handle
            handle = BCCHelper.NewXpackHandle(@"KSLib\cpack.dat");
            //prepare input params
            BCCHelper.SetIntFieldByName(handle, 0, "lvol1", string.IsNullOrEmpty(c.CustomerId) ? 0 : Convert.ToInt32(c.CustomerId));
            BCCHelper.SetStringFieldByName(handle, 0, "sall_name", c.CustomerName);

            BCCHelper.SetIntFieldByName(handle, 0, "lvol3", string.IsNullOrEmpty(c.Category) ? 0 : Convert.ToInt32(c.Category));
            BCCHelper.SetIntFieldByName(handle, 0, "lvol5", string.IsNullOrEmpty(c.FeeType) ? 0 : Convert.ToInt32(c.FeeType));

            BCCHelper.SetStringFieldByName(handle, 0, "smarket_code2", c.Sex);
            BCCHelper.SetStringFieldByName(handle, 0, "scust_auth2", c.SchoolId);

            if (BCCHelper.SetRequestType(handle, 841601))
            {
                int           errCode       = 0;
                int           retCode       = -1;
                bool          hasMorePack   = false;
                StringBuilder errMsg        = new StringBuilder(255);
                bool          requestStatus = BCCHelper.CallRequest(handle, Global.Drtp_NO, Global.Drtp_Branch, Global.BCC_BaseFunction, 5000, ref errCode, errMsg);
                if (!requestStatus)
                {
                    Global.Logger.Warn(string.Format("BCCHelper.CallRequest[841601] failed! errorCode ={0} and errMsg= {1}", errCode, errMsg));
                    Invoke(new QueryResultInvoker(HideLoadingForm));
                    Invoke(new Action(RestoreUI));
                    return;
                }
                BCCHelper.GetRetCode(handle, ref retCode);
                int packageCnt = 0;
                do
                {
                    if (retCode != 0)
                    {
                        continue;
                    }
                    //show data rows of package into grid view
                    packageCnt++;
                    Global.Logger.Info("do package data show with package#:" + packageCnt);
                    DoPackageDataShow(handle);
                } while (hasMorePack = BCCHelper.HaveNextPack(handle) && BCCHelper.CallNext(handle, 5000, ref errCode, errMsg));
            }//
            else
            {
                Global.Logger.Info("BCCHelper.SetRequestType[841601] failed!");
            }
            //release cpack handle
            if (handle != 0)
            {
                BCCHelper.DeleteXpackHandle(handle);
                Global.Logger.Info("delete xpack handle");
            }
            //show data in grid
            Invoke(new QueryResultInvoker(AddCustomersToGrid));
            //hide loading form
            Invoke(new QueryResultInvoker(HideLoadingForm));
        } //end of DoWalletQuery(QueryCriteria c)
Пример #2
0
        public void DoTransfer()
        {
            int handle = 0;

            Global.BCCInit();
            //make a new bcc handle
            handle         = BCCHelper.NewXpackHandle(@"KSLib\cpack.dat");
            importedAmount = 0.0d;
            importedCnt    = 0;
            errors         = new List <string>();
            DateTime start = DateTime.Now;

            foreach (DataRow dr in dataSource.Rows)
            {
                BCCHelper.ResetPackHandle(handle);
                DoSingleEntryTrans(dr, handle);
            }
            AllEntryCompletedEventArgs e = new AllEntryCompletedEventArgs(dataSource.Rows.Count, "All Completed!");
            StringBuilder summary        = new StringBuilder();

            summary.Append(System.Environment.NewLine + "结果汇总:" + System.Environment.NewLine);
            summary.Append("\t原始记录数:" + dataSource.Rows.Count + System.Environment.NewLine);
            summary.Append("\t导入开始时间:" + start.ToString() + System.Environment.NewLine);
            summary.Append("\t导入结束时间:" + DateTime.Now.ToString() + System.Environment.NewLine);
            summary.AppendFormat("\t成功处理:{0}条,总金额:{1} {2}", importedCnt, importedAmount, System.Environment.NewLine);
            summary.Append("\t未能导入的名单如下:" + System.Environment.NewLine);
            summary.AppendFormat("{0}", FormatListToString(errors));
            e.Errors  = errors;
            e.Summary = summary.ToString();
            OnAllEntryCompleted(e);
        }
Пример #3
0
 public static void BCCInit()
 {
     if (!Global.BCC_Initialized)
     {
         Global.BCC_Initialized = BCCHelper.BCCCLTInit(1);
         BCCHelper.XPackInit(1);
         Drtp_NO = BCCHelper.AddDrtpNode(Global.Drtp_Host, int.Parse(Global.Drtp_Port));
         Global.BCC_Initialized = true;
     }
 }
Пример #4
0
        private string SignIn()
        {
            string key    = string.Empty;
            int    handle = 0;

            Global.BCCInit();
            //make a new bcc handle
            handle = BCCHelper.NewXpackHandle(@"KSLib\cpack.dat");
            //prepare input params
            string myIp  = Utility.GetHostIP();
            string myMac = Utility.GetHostMac();

            BCCHelper.SetStringFieldByName(handle, 0, "scust_limit", "192.168.0.127");
            BCCHelper.SetStringFieldByName(handle, 0, "scust_limit2", "00-21-5E-68-40-20");
            BCCHelper.SetStringFieldByName(handle, 0, "scert_no", "sungard kingstar gateway common version");
            if (BCCHelper.SetRequestType(handle, 950001))
            {
                int           errCode       = 0;
                int           retCode       = -1;
                StringBuilder errMsg        = new StringBuilder(255);
                bool          requestStatus = BCCHelper.CallRequest(handle, Global.Drtp_NO, Global.Drtp_Branch, Global.BCC_BaseFunction, 5000, ref errCode, errMsg);
                if (!requestStatus)
                {
                    Splasher.Status = "调用后台功能号失败:[950001]";
                    Global.Logger.Warn("BCCHelper.CallRequest [950001] failed and errorcode =" + errCode + errMsg);
                }
                BCCHelper.GetRetCode(handle, ref retCode);
                if (retCode == 0)
                {
                    StringBuilder val = new StringBuilder(256);
                    BCCHelper.GetStringFieldByName(handle, 0, "scust_limit", val, 256);
                    key             = val.ToString();
                    Splasher.Status = string.Format("签到成功:[{0}]", val);
                }
                else
                {
                    Splasher.Status = "子系统签到失败!";
                    Global.Logger.Warn("BCCHelper.CallRequest [950001] failed and return code = : " + retCode);
                }
            }
            else
            {
                Splasher.Status = "设置后台功能号失败:[950001]";
                Global.Logger.Warn("BCCHelper.SetRequestType [950001] failed!");
            }
            if (handle != 0)
            {
                BCCHelper.DeleteXpackHandle(handle);
            }
            return(key);
        } //end of SignIn()
Пример #5
0
 private void DoSingleWalletRegister(Customer c, int handle)
 {
     BCCHelper.ResetPackHandle(handle);
     BCCHelper.SetIntFieldByName(handle, 0, "lvol0", c.CustomerId);  //客户号
     //BCCHelper.SetIntFieldByName(handle, 0, "lvol1", 888);  //终端号
     if (BCCHelper.SetRequestType(handle, 846331))
     {
         int           errCode       = 0;
         int           retCode       = -1;
         StringBuilder errMsg        = new StringBuilder(255);
         bool          requestStatus = BCCHelper.CallRequest(handle, Global.Drtp_NO, Global.Drtp_Branch, Global.BCC_BaseFunction, 5000, ref errCode, errMsg);
         if (!requestStatus)
         {
             Global.Logger.Warn(string.Format("BCCHelper.CallRequest[846331] failed! errorCode ={0} and errMsg= {1}", errCode, errMsg));
             return;
         }
         BCCHelper.GetRetCode(handle, ref retCode);
         //int ser=0;
         //BCCHelper.GetIntFieldByName(handle, 0, "scust_no", ref ser);
         string ser  = BCCHelper.GetStringFieldByName(handle, 0, "scust_no");
         string pass = BCCHelper.GetStringFieldByName(handle, 0, "scust_limit");
         string msg  = BCCHelper.GetStringFieldByName(handle, 0, "vsmess");
         if (retCode != 0)
         {
             //fail to wallet registration
             frmLoading.NotifyIndicator(string.Format("failed ,customer#{0}:{1}", c.CustomerId, errMsg));
             Global.Logger.Warn(string.Format(" failed ,Customerid ={0} and errMsg= {1}", c.CustomerId, msg));
         }
         else
         {
             //succuess to wallet registration
             Customer target = customers.Find(delegate(Customer o)
             {
                 return(o.CustomerId == c.CustomerId);
             });
             //target.NetAccFlag = "1";
             //target.NetAccFlagDes = "已开通";
             Global.Logger.Info(string.Format("succ ,Customerid# = {0} and Wallet#= {1} ", c.CustomerId, ser));
             frmLoading.NotifyIndicator(string.Format("Customer#{0},ser#:{1} ", c.CustomerId, ser));
         }
     }
     else
     {
         Global.Logger.Info("BCCHelper.SetRequestType[846331] failed!");
     }
     //frmLoading.NotifyIndicator(customers.Count.ToString());
 }
Пример #6
0
        }     //end for function

        public static SortableBindingList <T> GetSorttableList <T>(int handle) where T : new()
        {
            SortableBindingList <T> list = new SortableBindingList <T>();
            int cnt = 0;

            BCCHelper.GetRecordCount(handle, ref cnt);
            for (int rowIndex = 0; rowIndex < cnt; rowIndex++)
            {
                //populate single entity for per row
                T              obj  = new T();
                Type           t    = typeof(T);
                PropertyInfo[] pros = t.GetProperties();
                foreach (PropertyInfo p in pros)
                {
                    object[] attrs = p.GetCustomAttributes(typeof(CPackAttribute), false);
                    if (attrs.Length > 0 && attrs[0] is CPackAttribute)
                    {
                        CPackAttribute cpa = attrs[0] as CPackAttribute;
                        if (cpa != null)
                        {
                            string field = cpa.FieldName;
                            if (cpa.FieldType == typeof(int))
                            {
                                int iVal = 0;
                                BCCHelper.GetIntFieldByName(handle, rowIndex, field, ref iVal);
                                p.SetValue(obj, iVal, null);
                            }
                            else if (cpa.FieldType == typeof(double))
                            {
                                double dVal = 0.0d;
                                BCCHelper.GetDoubleFieldByName(handle, rowIndex, field, ref dVal);
                                p.SetValue(obj, dVal, null);
                            }
                            else   //char[] type for CPack
                            {
                                string sval = BCCHelper.GetStringFieldByName(handle, rowIndex, field);
                                p.SetValue(obj, sval, null);
                            }
                        }
                    }
                } //end for foreach PropertyInfo
                //add entity to result list
                list.Add(obj);
            } //end for each row
            return(list);
        }
Пример #7
0
        private void DoWalletRegister(object obj)
        {
            List <Customer> list = obj as List <Customer>;

            if (list != null && list.Count > 0)
            {
                int handle = 0;
                Global.BCCInit();
                //make a new bcc handle
                handle = BCCHelper.NewXpackHandle(@"KSLib\cpack.dat");
                foreach (Customer c in list)
                {
                    DoSingleWalletRegister(c, handle);
                }
                //delete handle
                if (handle > 0)
                {
                    BCCHelper.DeleteXpackHandle(handle);
                }
                //hide form
                Invoke(new QueryResultInvoker(HideLoadingForm));
            }
        }
Пример #8
0
        private void DoSingleEntryTrans(DataRow dr, int handle)
        {
            string staffId  = GetFieldFromRow(dr, "XH");
            string name     = GetFieldFromRow(dr, "XM");
            string walletId = "";//GetFieldFromRow(dr, "WalletId");

            //商户编号
            BCCHelper.SetIntFieldByName(handle, 0, "lvol0", Convert.ToInt32(GetFieldFromRow(dr, "ShopId")));
            DataRow tmp = dataRelations.Rows.Find(staffId);

            if (tmp != null)
            {
                walletId = Convert.ToString(tmp["WalletId"]);
            }
            //电子账号
            BCCHelper.SetStringFieldByName(handle, 0, "scust_no", walletId);
            //定单编号
            BCCHelper.SetStringFieldByName(handle, 0, "sbankname", "000000");
            //支付总金额
            double tmpAmount = Convert.ToDouble(GetFieldFromRow(dr, "Mount"));

            BCCHelper.SetDoubleFieldByName(handle, 0, "damt0", tmpAmount);
            //订单日期
            BCCHelper.SetStringFieldByName(handle, 0, "sdate0", DateTime.Now.Date.ToString("yyMMdd"));
            //订单时间
            BCCHelper.SetStringFieldByName(handle, 0, "stime0", DateTime.Now.ToString("hhmmss"));
            //货币代码
            BCCHelper.SetStringFieldByName(handle, 0, "sstock_code", "CNY");
            //操作标志
            BCCHelper.SetIntFieldByName(handle, 0, "lvol1", 1);
            //交易备注	snote
            BCCHelper.SetStringFieldByName(handle, 0, "snote", GetFieldFromRow(dr, "Type"));
            string entryMsg  = "";
            bool   entryFlag = true;

            if (BCCHelper.SetRequestType(handle, 846340))
            {
                int           errCode       = 0;
                int           retCode       = -1;
                StringBuilder errMsg        = new StringBuilder(255);
                bool          requestStatus = BCCHelper.CallRequest(handle, Global.Drtp_NO, Global.Drtp_Branch, Global.BCC_BaseFunction, 1000, ref errCode, errMsg);
                if (!requestStatus)
                {
                    entryFlag = false;
                    entryMsg  = string.Format("CallRequest[846340] failed! errorCode ={0} and errMsg= {1}.学号={2},姓名={3}", errCode, errMsg, staffId, name);
                    Global.Logger.Warn(entryMsg);
                    errors.Add(string.Format("{0}\t{1}", staffId, name));
                }
                else
                {
                    BCCHelper.GetRetCode(handle, ref retCode);
                    if (retCode != 0)  //failture
                    {
                        entryFlag = false;
                        entryMsg  = string.Format("CallRequest[846340] failed and return code ={0}.学号={1},姓名={2}", retCode, staffId, name);
                        Global.Logger.Error(entryMsg);
                        errors.Add(string.Format("{0}\t{1}", staffId, name));
                    }
                    else         //succ
                    {
                        importedCnt++;
                        importedAmount += tmpAmount;
                        string serial = BCCHelper.GetStringFieldByName(handle, 0, "sphone3");
                        entryMsg = string.Format("CallRequest[846340] with succ  and  ser#{0}.学号={1},姓名={2}", serial, staffId, name);
                        Global.Logger.Info(entryMsg);
                    }
                }
            }
            else
            {
                entryMsg  = string.Format("SetRequestType[846340] failed.学号={0},姓名={1} ", staffId, name);
                entryFlag = false;
                Global.Logger.Error(entryMsg);
                errors.Add(string.Format("{0}\t{1}", staffId, name));
            }
            //raise event
            OnEntryCompleted(new EntryCompletedEventArgs(string.Format("{0}[{1}]", name, walletId), entryFlag, entryMsg));
        }
Пример #9
0
        private void PrepareRelations()
        {
            if (dtRelation == null)
            {
                dtRelation = new DataTable("relations");
                dtRelation.Columns.Add("StaffId", typeof(string));
                dtRelation.Columns.Add("Name", typeof(string));
                dtRelation.Columns.Add("WalletId", typeof(string));
                dtRelation.PrimaryKey = new DataColumn[] { dtRelation.Columns[0] };
            }
            dtRelation.Rows.Clear();

            int handle = 0;

            Global.BCCInit();
            //make a new bcc handle
            handle = BCCHelper.NewXpackHandle(@"KSLib\cpack.dat");
            if (BCCHelper.SetRequestType(handle, 841601))
            {
                int           errCode       = 0;
                int           retCode       = -1;
                bool          hasMorePack   = false;
                StringBuilder errMsg        = new StringBuilder(255);
                bool          requestStatus = BCCHelper.CallRequest(handle, Global.Drtp_NO, Global.Drtp_Branch, Global.BCC_BaseFunction, 5000, ref errCode, errMsg);
                if (!requestStatus)
                {
                    Global.Logger.Warn(string.Format("BCCHelper.CallRequest[841601] failed! errorCode ={0} and errMsg= {1}", errCode, errMsg));
                    return;
                }
                BCCHelper.GetRetCode(handle, ref retCode);
                //int packageCnt = 0;
                do
                {
                    if (retCode != 0)
                    {
                        continue;
                    }
                    //show data rows of package into grid view
                    int cnt = 0;
                    BCCHelper.GetRecordCount(handle, ref cnt);
                    for (int rowIndex = 0; rowIndex < cnt; rowIndex++)
                    {
                        DataRow dr = dtRelation.NewRow();
                        dr["StaffId"]  = BCCHelper.GetStringFieldByName(handle, rowIndex, "scust_auth2");
                        dr["Name"]     = BCCHelper.GetStringFieldByName(handle, rowIndex, "sname");
                        dr["WalletId"] = BCCHelper.GetStringFieldByName(handle, rowIndex, "sname2");
                        dtRelation.Rows.Add(dr);
                    }
                } while (hasMorePack = BCCHelper.HaveNextPack(handle) && BCCHelper.CallNext(handle, 5000, ref errCode, errMsg));
            }
            else
            {
                Global.Logger.Info("BCCHelper.SetRequestType[841601] failed!");
            }
            //release cpack handle
            if (handle != 0)
            {
                BCCHelper.DeleteXpackHandle(handle);
                Global.Logger.Info("delete xpack handle for request type= 841601");
            }
        }