Dictionary<string, List<CallerInfo>> ReadValidCertificates(XmlReader parser) {
			var validCertificates = new Dictionary<string, List<CallerInfo>>();
			try {
				while (parser.Read()) {
					if (parser.IsStartElement() && parser.Name == "signing_certificate") {
						var name = parser[0];
						var packageName = parser[2];
						var isRelease = Convert.ToBoolean(parser[1]);
						var certificate = parser.ReadString();
						if (certificate != null)
							certificate = certificate.Replace("\\s|\\n", "");

						var info = new CallerInfo(name, packageName, isRelease, certificate);

						List<CallerInfo> infos; 
						validCertificates.TryGetValue(certificate, out infos);
						if (infos == null) {
							infos = new List<CallerInfo>();
							validCertificates.Add(certificate, infos);
						}
						LogHelper.Verbose(Tag, "Adding allowed caller: ", info.Name,
							" package=", info.PackageName, " release=", info.Release,
							" certificate=", certificate);
						infos.Add(info);
					}
				}
			} catch (XmlException e) {
				LogHelper.Error(Tag, e, "Could not read allowed callers from XML.");
			} catch (IOException e) {
				LogHelper.Error(Tag, e, "Could not read allowed callers from XML.");
			}
			return validCertificates;
		}
Ejemplo n.º 2
0
        public void PropagatesCallerInfoThroughExceptionDuringSignaling()
        {
            var module = new TestErrorLogModule();
            var mocks = new { Context = new Mock<HttpContextBase> { DefaultValue = DefaultValue.Mock } };
            using (var app = new HttpApplication())
            {
                var context = mocks.Context.Object;
                var callerInfo = new CallerInfo("foobar", "baz.cs", 42);
                var exception = new Exception();
                IDictionary actualData = null;
                module.LogExceptionOverride = (e, _) => actualData = new Hashtable(e.Data);
                
                module.OnErrorSignaled(app, new ErrorSignalEventArgs(exception, context, callerInfo));

                Assert.Equal(0, exception.Data.Count);
                Assert.NotNull(actualData);
                Assert.Equal(1, actualData.Count);
                var actualCallerInfo = (CallerInfo) actualData.Cast<DictionaryEntry>().First().Value;
                Assert.Same(callerInfo, actualCallerInfo);

                module.LogExceptionOverride = delegate { throw new TestException(); };

                Assert.Throws<TestException>(() => module.OnErrorSignaled(app, new ErrorSignalEventArgs(exception, context, callerInfo)));
                Assert.Equal(0, exception.Data.Count);
            }
        }
Ejemplo n.º 3
0
 public void NullStringsDuringInitializationBecomeEmpty()
 {                                             // ReSharper disable RedundantArgumentDefaultValue
     var info = new CallerInfo(null, null, 0); // ReSharper restore RedundantArgumentDefaultValue
     Assert.NotNull(info.MemberName);
     Assert.Equal(0, info.MemberName.Length);
     Assert.NotNull(info.FilePath);
     Assert.Equal(0, info.FilePath.Length);
 }
Ejemplo n.º 4
0
 public void Initialization()
 {
     const string member = "foobar";
     const string file = "baz.cs";
     const int line = 42;
     var info = new CallerInfo(member, file, line);
     Assert.Equal(member, info.MemberName);
     Assert.Equal(file, info.FilePath);
     Assert.Equal(line, info.LineNumber);
 }
Ejemplo n.º 5
0
        private void SetRibbonVisibility(InvoiceSubtypes.ValidationRuleSet validation)
        {
            Log.TraceWrite(CallerInfo.Create(), "entering, CurrentSelectedValidation=" + validation.ToString());
            // BtnSignatur.Visible = false;
            switch (validation)
            {
            case InvoiceSubtypes.ValidationRuleSet.Industries:
                rbGrpSignSend.Visible    = true;
                btnSendByMail.Visible    = true;
                btnSendByService.Visible = true;
                //  btnSignAndMail.Visible = true;
                gbtnZustellung.Visible = true;

                btnChangeFormType.Label = "Wechsel zu " + _invoiceView.InvoiceVariantList.GetText(InvoiceSubtypes.ValidationRuleSet.Government.ToString());
                break;

            case InvoiceSubtypes.ValidationRuleSet.Government:
                rbGrpSignSend.Visible = false;
                //   btnSendByMail.Visible = false;
                btnSendByService.Visible = false;
                btnSendByMail.Visible    = false;
                gbtnZustellung.Visible   = false;

                btnChangeFormType.Label = "Wechsel zu " + _invoiceView.InvoiceVariantList.GetText(InvoiceSubtypes.ValidationRuleSet.Industries.ToString());
                break;

            case InvoiceSubtypes.ValidationRuleSet.Invalid:
                Log.TraceWrite(CallerInfo.Create(), "Ruleset invalid");
                break;

            default:
                Log.TraceWrite(CallerInfo.Create(), "selection sot found");
                throw new ArgumentOutOfRangeException();
            }
            Log.TraceWrite(CallerInfo.Create(), "exiting");
        }
Ejemplo n.º 6
0
        public void CallerLoaded_ShouldPublish_OpenCallerEvent()
        {
            var callerInfo = new CallerInfo
            {
                CallerId     = Guid.NewGuid(),
                CallerName   = "Jon Doe",
                CallerNumber = 98608900
            };

            var serviceFactoryMock  = new Mock <IServiceFactory>();
            var eventMock           = new Mock <OpenCallerViewEvent>();
            var eventAggregatorMock = new Mock <IEventAggregator>();

            eventAggregatorMock.Setup(aggregator => aggregator.GetEvent <OpenCallerViewEvent>())
            .Returns(eventMock.Object);


            var phoneViewModel = new PhoneViewModel(serviceFactoryMock.Object);

            phoneViewModel._eventAggregator = eventAggregatorMock.Object;
            phoneViewModel.LoadCaller(callerInfo);

            eventMock.Verify(e => e.Publish(callerInfo.CallerId), Times.Once);
        }
        public void Setup()
        {
            StreamFactory sf         = StreamFactory.Instance;
            DateTime      Date       = new DateTime(DateTime.UtcNow.Ticks);
            string        HomeName   = String.Format("TestHome-{0}", Date.ToString("yyyy-MM-dd"));
            string        Caller     = String.Format("{0}", Date.ToString("HH-mm-ss"));
            string        AppName    = Caller;
            Random        rnd        = new Random();
            string        StreamName = String.Format("{0}", rnd.Next());

            FqStreamID fqstreamid = new FqStreamID(HomeName, AppName, StreamName);
            CallerInfo ci         = new CallerInfo(null, Caller, Caller, 1);

            sf.deleteStream(fqstreamid, ci);

            vds = sf.openValueDataStream <StrKey, ByteValue>(fqstreamid, ci,
                                                             null,
                                                             StreamFactory.StreamSecurityType.Plain,
                                                             CompressionType.None,
                                                             StreamFactory.StreamOp.Write);

            k1 = new StrKey("k1");
            k2 = new StrKey("k2");
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获得支付指令序列号对应的支付状态信息
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="bankVerInfo">银行版本</param>
        /// <param name="paymentSeqNo">支付指令序列号(在调用支付指令后系统返回的序列号(fSeqNo))</param>
        /// <returns></returns>
        public BankReturnModel <PaymentInfo[]> getPaymentState(CallerInfo caller, BankVersionInfo bankVerInfo, String paymentSeqNo)
        {
            string   error       = string.Empty;
            string   xmlString   = ICBCNCHelper.GetXmlString("QPAYENT");
            XML_EASY xmlPayState = new XML_EASY(xmlString);

            //设置头部信息
            xmlPayState.SetXMLNode("BankCode", "102"); //工行为 "102"
            xmlPayState.SetXMLNode("CIS", ConfigurationManager.AppSettings["cis"]);
            xmlPayState.SetXMLNode("ID", ConfigurationManager.AppSettings["id"]);

            xmlPayState.SetXMLNode("QryfSeqno", paymentSeqNo); //使用fSeqno来查询
            xmlPayState.SetXMLNode("QrySerialNo", "");         //值为空,则使用fSeqno来查询

            ICBC_NetSafeClient iCBC_NetSafeClient = CreateOneNC();
            string             seqNo, seqResult;

            iCBC_NetSafeClient.Run(xmlPayState.GetXML(), out seqNo, out seqResult);
            iCBC_NetSafeClient = null;

            xmlPayState.SetXML(seqResult);
            if (xmlPayState.LocateString("<error>") >= 0)
            {
                error = xmlPayState.GetXMLNode("error");
                throw new Exception(error);
            }

            string retCode           = xmlPayState.GetXMLNode("RetCode");

            if (retCode != "0")
            {
                //error = "error=" + xmlPayState.GetXMLNode("RetMsg");
                //throw new Exception(error);

                BankReturnModel <PaymentInfo[]> retMo = new BankReturnModel <PaymentInfo[]>();
                retMo.retCode   = retCode;
                retMo.retMsg    = xmlPayState.GetXMLNode("RetMsg");
                retMo.bankCode  = "102";
                retMo.fSeqno    = seqNo;
                retMo.transCode = "QPAYENT";
                retMo.tranDate  = xmlPayState.GetXMLNode("TranDate");
                retMo.tranTime  = xmlPayState.GetXMLNode("TranTime");
                return(retMo);
            }

            //取支付明细信息
            List <PaymentInfo> states = null;
            PaymentInfo        pInfo = null;

            string rdString = xmlPayState.GetXMLNode("rd");
            int    rdIndex  = xmlPayState.Index();

            //string result = xmlPayState.GetXMLNode("Result", rdIndex);
            if (!string.IsNullOrEmpty(rdString))
            {
                states = new List <PaymentInfo>();
                //循环获取明细
                do
                {
                    pInfo = getPaymentInfofromRd(bankVerInfo, rdString);
                    if (pInfo.submitDate == DateTime.MinValue)
                    {
                        pInfo.submitDate = this.convertToDateTime(xmlPayState.GetXMLNode("TranDate") + xmlPayState.GetXMLNode("TranTime"));
                    }
                    pInfo.paymentSeqNo = paymentSeqNo;
                    states.Add(pInfo);

                    rdString = xmlPayState.GetXMLNode("rd", rdIndex);
                    rdIndex  = xmlPayState.Index();
                }while (!string.IsNullOrEmpty(rdString));

                BankReturnModel <PaymentInfo[]> retMo = new BankReturnModel <PaymentInfo[]>();
                retMo.retCode             = retCode;
                retMo.retMsg              = xmlPayState.GetXMLNode("RetMsg");
                retMo.bankCode            = "102";
                retMo.fSeqno              = seqNo;
                retMo.transCode           = "QPAYENT";
                retMo.tranDate            = xmlPayState.GetXMLNode("TranDate");
                retMo.tranTime            = xmlPayState.GetXMLNode("TranTime");
                retMo.detailData          = new BankReturnDetailModel <PaymentInfo[]>();
                retMo.detailData.infoData = states.ToArray();

                return(retMo);
            }

            return(null);
        }
Ejemplo n.º 9
0
        public BankReturnModel <DetailInfo[]> getHistoryDetails(CallerInfo caller, BankAcnt bankAcnt, DateTime beginTime, DateTime endTime, decimal minAmt, decimal maxAmt, string nextTag, string currency)
        {
            string   error     = string.Empty;
            string   xmlString = ICBCNCHelper.GetXmlString("QHISD");
            XML_EASY xmlQPD    = new XML_EASY(xmlString);

            //设置头部信息
            xmlQPD.SetXMLNode("BankCode", "102"); //工行为 "102"
            xmlQPD.SetXMLNode("CIS", ConfigurationManager.AppSettings["cis"]);
            xmlQPD.SetXMLNode("ID", ConfigurationManager.AppSettings["id"]);

            xmlQPD.SetXMLNode("AccNo", bankAcnt.acntNo);                                //银行账号
            xmlQPD.SetXMLNode("MinAmt", (minAmt * 100).ToString());                     //发生额下限,人民币分为单位,把元转换为分
            xmlQPD.SetXMLNode("MaxAmt", (maxAmt * 100).ToString());                     //发生额上限,人民币分为单位,把元转换为分
            xmlQPD.SetXMLNode("NextTag", string.IsNullOrEmpty(nextTag) ? "" : nextTag); //下页标志
            xmlQPD.SetXMLNode("BeginDate", beginTime.ToString("yyyyMMdd"));
            xmlQPD.SetXMLNode("EndDate", endTime.ToString("yyyyMMdd"));

            ICBC_NetSafeClient iCBC_NetSafeClient = CreateOneNC();
            string             seqNo, seqResult;

            iCBC_NetSafeClient.Run(xmlQPD.GetXML(), out seqNo, out seqResult);
            iCBC_NetSafeClient = null;

            xmlQPD.SetXML(seqResult);
            if (xmlQPD.LocateString("<error>") >= 0)
            {
                error = xmlQPD.GetXMLNode("error");
                throw new Exception(error);
            }

            string retCode = xmlQPD.GetXMLNode("RetCode");

            if (retCode != "0")
            {
                //error = "error=" + xmlQPD.GetXMLNode("RetMsg");
                //throw new Exception(error);

                BankReturnModel <DetailInfo[]> retMo = new BankReturnModel <DetailInfo[]>();
                retMo.retCode   = retCode;
                retMo.retMsg    = xmlQPD.GetXMLNode("RetMsg");
                retMo.bankCode  = "102";
                retMo.fSeqno    = seqNo;
                retMo.transCode = "QHISD";
                retMo.tranDate  = xmlQPD.GetXMLNode("TranDate");
                retMo.tranTime  = xmlQPD.GetXMLNode("TranTime");
                return(retMo);
            }

            //取交易明细信息
            List <DetailInfo> states = null;
            DetailInfo        pInfo = null;

            string rdString = xmlQPD.GetXMLNode("rd");
            int    rdIndex = xmlQPD.Index();

            if (!string.IsNullOrEmpty(rdString))
            {
                states = new List <DetailInfo>();
                //循环获取交易明细
                do
                {
                    pInfo = getDetailInfofromRd(bankAcnt, rdString);
                    states.Add(pInfo);

                    rdString = xmlQPD.GetXMLNode("rd", rdIndex);
                    rdIndex  = xmlQPD.Index();
                }while (!string.IsNullOrEmpty(rdString));

                BankReturnModel <DetailInfo[]> retMo = new BankReturnModel <DetailInfo[]>();
                retMo.retCode             = retCode;
                retMo.retMsg              = xmlQPD.GetXMLNode("RetMsg");
                retMo.bankCode            = "102";
                retMo.fSeqno              = seqNo;
                retMo.transCode           = "QPAYENT";
                retMo.tranDate            = xmlQPD.GetXMLNode("TranDate");
                retMo.tranTime            = xmlQPD.GetXMLNode("TranTime");
                retMo.nextTag             = xmlQPD.GetXMLNode("NextTag"); //下页标志
                retMo.detailData          = new BankReturnDetailModel <DetailInfo[]>();
                retMo.detailData.infoData = states.ToArray();

                return(retMo);
            }

            return(null);
        }
Ejemplo n.º 10
0
 public ExpressionSyntax GenerateExpression(VisualScriptCompilerContext context, Slot slot)
 {
     // TODO: Out/ref
     // Other cases should have been handled by context.RegisterLocalVariable during code generation
     // It's also possible that this block is actually not executed and used as input, so we issue a warning anyway
     context.Log.Error($"No value found for slot {slot}. Note that out/ref slots are not implemented yet.", CallerInfo.Get());
     return(null);
 }
Ejemplo n.º 11
0
 public void Error(string message, params object[] objs)
 {
     Log.Error(message, CallerInfo.Create(), objs);
 }
Ejemplo n.º 12
0
 public void Init()
 {
     instance = new CallerInfo();
 }
Ejemplo n.º 13
0
 public static void LogDebug(this ILogger logger, CallerInfo caller)
 => logger.Log(LogLevel.Debug, 0, caller, null, null);
 public void CallerConnect(CallerInfo caller)
 {
     OnCallerConnect?.Invoke(this, caller);
 }
Ejemplo n.º 15
0
 public static void Information(string messageTemplate, CallerInfo callerInfo, params object[] propertyValues)
 {
     Serilog.Log.Logger
     .ForHere(callerInfo.CallerFilePath, callerInfo.CallerMemberName, callerInfo.CallerLineNumber)
     .Information(messageTemplate, propertyValues);
 }
Ejemplo n.º 16
0
 private void Thread_ExceptionOccur(object sender, EventArgs <Exception> e)
 {
     Log <Service> .Error(CallerInfo.Get("z:\\066B\\global2\\HeroesCode\\server\\UnifiedNetwork\\OperationService\\Service.cs", 220), "Unhandled exception", e.Value);
 }
Ejemplo n.º 17
0
        private ExecuteContext GetRightsContext(CallerInfo caller, InvokerData invoker, TeamspeakControl ts)
        {
            if (needsRecalculation)
            {
                cachedRights.Invalidate();
                needsRecalculation = false;
                ReadFile();
            }

            ExecuteContext execCtx;

            if (invoker != null)
            {
                if (cachedRights.TryGetValue(invoker.ClientUid, out execCtx))
                {
                    // TODO check if all fields are same
                    // if yes => returen
                    // if no => delete from cache
                    return(execCtx);
                }

                execCtx = new ExecuteContext();

                // Get Required Matcher Data:
                // In this region we will iteratively go through different possibilities to obtain
                // as much data as we can about our invoker.
                // For this step we will prefer query calls which can give us more than one information
                // at once and lazily fall back to other calls as long as needed.

                ulong[] availableGroups = null;
                if (ts != null)
                {
                    if (invoker.ClientId.HasValue &&
                        (needsAvailableGroups || needsAvailableChanGroups))
                    {
                        var result = ts.GetClientInfoById(invoker.ClientId.Value);
                        if (result.Ok)
                        {
                            availableGroups        = result.Value.ServerGroups;
                            execCtx.ChannelGroupId = result.Value.ChannelGroupId;
                        }
                    }

                    if (needsAvailableGroups && invoker.DatabaseId.HasValue && availableGroups == null)
                    {
                        var result = ts.GetClientServerGroups(invoker.DatabaseId.Value);
                        if (result.Ok)
                        {
                            availableGroups = result.Value;
                        }
                    }
                }

                if (availableGroups != null)
                {
                    execCtx.AvailableGroups = availableGroups;
                }
                execCtx.ClientUid = invoker.ClientUid;
                execCtx.Visibiliy = invoker.Visibiliy;
                execCtx.ApiToken  = invoker.Token;
            }
            else
            {
                execCtx = new ExecuteContext();
            }
            execCtx.IsApi = caller.ApiCall;

            ProcessNode(rootRule, execCtx);

            if (execCtx.MatchingRules.Count == 0)
            {
                return(execCtx);
            }

            foreach (var rule in execCtx.MatchingRules)
            {
                execCtx.DeclAdd.UnionWith(rule.DeclAdd);
            }

            if (invoker != null)
            {
                cachedRights.Store(invoker.ClientUid, execCtx);
            }

            return(execCtx);
        }
Ejemplo n.º 18
0
        public ExpressionSyntax GenerateExpression(Slot slot)
        {
            // Automatically flow to next execution slot (if it has a null name => default behavior)
            if (slot != null)
            {
                // 1. First check if there is a link and use its expression
                var sourceLink = method.Links.Values.FirstOrDefault(x => x.Target == slot);
                if (sourceLink != null)
                {
                    ExpressionSyntax expression;

                    // Generate code
                    var sourceBlock = sourceLink.Source.Owner;

                    var sourceExecutionBlock = sourceBlock as ExecutionBlock;
                    if (sourceExecutionBlock != null)
                    {
                        // If block is execution block, it must have been executed in all path until now
                        // Note: We don't care about non execution block, since we do a full expression evaluation on them.
                        ExecutionBlockLinkState sourceExecutionState;
                        if (!connectivityToCurrentBlock.TryGetValue(sourceExecutionBlock, out sourceExecutionState))
                        {
                            sourceExecutionState = ExecutionBlockLinkState.Never;
                        }

                        switch (sourceExecutionState)
                        {
                        case ExecutionBlockLinkState.Never:
                            Log.Error($"{slot} in block {slot.Owner} uses a value from execution block {sourceBlock}, however it is never executed. Slot will take default value instead.", CallerInfo.Get());
                            sourceBlock = null;
                            break;

                        case ExecutionBlockLinkState.Sometimes:
                            Log.Error($"{slot} in block {slot.Owner} uses a value from execution block {sourceBlock}, however it is executed but not in all cases. Are you using result from a conditional branch? Slot will take default value instead.", CallerInfo.Get());
                            // Note: we still let it generate code, so that the user can also see the error in the generated source code
                            //sourceBlock = null;
                            break;

                        case ExecutionBlockLinkState.Always:
                            // We're good, this value is always defined when we reach CurrentBlock
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }

                    // Only proceed if sourceBlock has not been nulled by previous checks
                    if (sourceBlock != null)
                    {
                        string localName;
                        if (outputSlotLocals.TryGetValue(sourceLink.Source, out localName))
                        {
                            expression = IdentifierName(localName);
                        }
                        else
                        {
                            expression = (sourceBlock as IExpressionBlock)?.GenerateExpression(this, sourceLink.Source);
                        }

                        if (expression != null)
                        {
                            // Add annotation on both source block and link (so that we can keep track of what block/link generated what source code)
                            expression = expression.WithAdditionalAnnotations(GenerateAnnotation(sourceLink.Source.Owner), GenerateAnnotation(sourceLink));

                            return(expression);
                        }
                    }
                }

                // 2. If a custom value is set, use it
                if (slot.Value != null)
                {
                    return(ParseExpression(slot.Value).WithAdditionalAnnotations(GenerateAnnotation(slot.Owner)));
                }

                // 3. Fallback: use slot name
                if (slot.Name != null)
                {
                    return(IdentifierName(slot.Name).WithAdditionalAnnotations(GenerateAnnotation(slot.Owner)));
                }
            }

            // TODO: Issue an error
            Log.Error($"{slot} in block {slot?.Owner} could not be resolved.", CallerInfo.Get());
            return(IdentifierName("unknown").WithAdditionalAnnotations(GenerateAnnotation(CurrentBlock)));
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            string       AzureaccountName = ConfigurationManager.AppSettings.Get("AccountName");
            string       AzureaccountKey  = ConfigurationManager.AppSettings.Get("AccountSharedKey");
            LocationInfo li = new LocationInfo(AzureaccountName, AzureaccountKey, SynchronizerType.Azure);

            /*
             * string dataFile = "D:\\b";
             * int KB = 1024;
             * int[] chunk_sizes = { 4*1024*KB , 8*1024*KB };
             *
             * for (int i = 1; i <= 1; i++)
             * {
             *  for (int threads = 1; threads <= 1; threads++)
             *  {
             *      foreach (int csize in chunk_sizes)
             *      {
             *          Console.Write(">");
             *          File.Copy(dataFile, dataFile + threads + "," + csize);
             *
             *          AzureHelper helper = new AzureHelper(AzureaccountName, AzureaccountKey, "foo123123", CompressionType.None, EncryptionType.None, null, null, new Logger(), csize, threads);
             *          long start = DateTime.Now.Ticks;
             *          helper.UploadFileAsChunks(dataFile + threads + "," + csize);
             *          long end = DateTime.Now.Ticks;
             *          Console.WriteLine(threads + "," + csize + "," + (((double)(end - start) / (double)10000000)) );
             *      }
             *
             *  }
             * }
             */



            li = null;
            FqStreamID fq_sid = new FqStreamID("1299-2716", "A", "TestBS");
            CallerInfo ci     = new CallerInfo(null, "A", "A", 1);

            StreamFactory sf = StreamFactory.Instance;

            sf.deleteStream(fq_sid, ci);

            IStream dfs_byte_val = sf.openValueDataStream <StrKey, ByteValue>(fq_sid, ci, li,
                                                                              StreamFactory.StreamSecurityType.Plain,
                                                                              CompressionType.None,
                                                                              StreamFactory.StreamOp.Write);

            StrKey k1 = new StrKey("k1");

            dfs_byte_val.Append(k1, new ByteValue(StreamFactory.GetBytes("k1-cmu")));
            dfs_byte_val.Append(k1, new ByteValue(StreamFactory.GetBytes("k1-msr")));

            dfs_byte_val.Seal(false);
            dfs_byte_val.Append(k1, new ByteValue(StreamFactory.GetBytes("k1-uw")));

            dfs_byte_val.Close();
            Console.ReadKey();


            dfs_byte_val = sf.openValueDataStream <StrKey, ByteValue>(fq_sid, ci, li,
                                                                      StreamFactory.StreamSecurityType.Plain,
                                                                      CompressionType.None,
                                                                      StreamFactory.StreamOp.Write);


            Console.WriteLine("Get in read : " + dfs_byte_val.Get(k1));
            IEnumerable <IDataItem> data = dfs_byte_val.GetAll(k1, 0, StreamFactory.NowUtc());

            foreach (IDataItem dataItem in data)
            {
                Console.WriteLine(dataItem.GetVal().ToString());
            }

            dfs_byte_val.Close();
            Console.ReadKey();

            /*
             * ValueSerializerBase<StrKey> vsb = new ValueSerializerBase<StrKey>();
             * Byte[] buffer1 = vsb.SerializeToByteStream().ToArray();
             * Byte[] buffer2 = SerializerHelper<StrKey>.SerializeToProtoStream(k1).ToArray();
             *
             * FileStream fout = new FileStream("tmp.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
             * BinaryWriter fs_bw = new BinaryWriter(fout);
             * fs_bw.Write(buffer1);
             * fs_bw.Write("-----W00t!-----");
             * fs_bw.Write(buffer2);
             * fs_bw.Write("-----W00t!-----");
             * fs_bw.Close();
             * fout.Close();
             */
        }
Ejemplo n.º 20
0
 public void PublishToPanel(string description)
 {
     Log.TraceWrite(CallerInfo.Create(), "desc=" + description);
     PublishToPanel("", "", "", description);
 }
Ejemplo n.º 21
0
        /// <summary>
        /// 获得对应银行账号的当前余额
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="bankCnt">银行账户信息</param>
        /// <param name="currency">币种</param>
        /// <returns></returns>
        public BalanceInfo getBalance(CallerInfo caller, BankAcnt bankCnt, string currency)
        {
            string error = string.Empty;
            var    acct  = bankCnt.acntNo.Trim();

            if (acct.Length < 19)
            {
                error = "账号长度错误!";
                throw new Exception(error);
            }

            //ICBCNCHelper ncHelper = ICBCNCHelper.GetInstance();
            string xmlString = ICBCNCHelper.GetXmlString("QACCBAL");

            InstallContext ic = new InstallContext();

            //初始化数据
            Type type = bankCnt.GetType();

            PropertyInfo[] ps = type.GetProperties();
            foreach (PropertyInfo i in ps)
            {
                object obj  = i.GetValue(bankCnt, null);
                string name = i.Name;
                if (obj != null)
                {
                    ic.Set(i.Name, obj.ToString());
                }
                else
                {
                    ic.Set(name, " ");
                }
            }

            //如果不写币种,会使用账户的币种

            /*
             * if (string.IsNullOrEmpty(currency)) {
             *  currency = "001"; //默认人名币
             * }
             */

            ic.Set("currency", currency);
            ic.Set("bankCode", bankCnt.swiftCode);
            ic.Set("cis", ConfigurationManager.AppSettings["cis"]);
            ic.Set("id", ConfigurationManager.AppSettings["id"]);

            //替换模板中的键为对应的值
            var newXmlStr = ReplaceHelper.ReplaceStringVar(xmlString, ic);


            ICBC_NetSafeClient iCBC_NetSafeClient = CreateOneNC();
            XML_EASY           balString          = new XML_EASY(newXmlStr);//new XML_EASY(ResourceSet.TransCode_QACCBAL_0010);

            if (acct.Length == 19)
            {
                balString.SetXMLNode("AccNo", acct);
            }
            //else if (acct.Length == 29 && acct[19] == '-')
            //{
            //    balString.SetXMLNode("AccNo", acct.Substring(0, 19));
            //    balString.SetXMLNode("AcctSeq", acct.Substring(20, 9));
            //}

            string seqNo, seqResult;

            iCBC_NetSafeClient.Run(balString.GetXML(), out seqNo, out seqResult);
            iCBC_NetSafeClient = null;

            balString.SetXML(seqResult);
            if (balString.LocateString("<error>") >= 0)
            {
                error = balString.GetXMLNode("error");
                throw new Exception(error);
            }
            string balMoney = balString.GetXMLNode("Balance");

            if (balMoney != null && balMoney.Length > 0)
            {
                BalanceInfo balInfo = new BalanceInfo();

                //取余额
                decimal balance = Convert.ToDecimal(balMoney) / 100.0m; //以币种的最小单位为单位,人民币的单位为分,转换为元要除以100

                //昨日余额
                decimal accBalance = this.getYuanMoney(balString.GetXMLNode("AccBalance"));

                //可用余额
                decimal usableBalance = this.getYuanMoney(balString.GetXMLNode("UsableBalance"));

                balInfo.bankAcnt = bankCnt; //账户信息

                balInfo.balance      = balance;
                balInfo.hisBalance   = accBalance;
                balInfo.availBalance = usableBalance;
                balInfo.acntType     = balString.GetXMLNode("AcctProperty"); //账户属性
                balInfo.currency     = balString.GetXMLNode("CurrType");     //币种

                string retTime = balString.GetXMLNode("QueryTime");
                if (!string.IsNullOrEmpty(retTime))
                {
                    balInfo.balanceDate = this.convertToDateTime(retTime);
                }

                balInfo.fSeqno = seqNo; //balString.GetXMLNode("fSeqno"); //指令包序列号

                //error = "Name=" + balString.GetXMLNode("AccName") + "|Balance=" + accBalance.ToString() + "|银行应答时间=" + balString.GetXMLNode("QueryTime");
                return(balInfo);
            }

            error = "银行RetMsg:" + balString.GetXMLNode("RetMsg");
            throw new Exception(error);
        }
Ejemplo n.º 22
0
 public BalanceInfo getBalance(CallerInfo caller, BankAcnt bankCnt, string currency)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 23
0
        /// <summary>
        /// 提交支付指令
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="payments">支付单据数组</param>
        /// <returns></returns>
        public BankReturnModel <PaymentInfo[]> submitPayment(CallerInfo caller, PaymentInfo[] payments)
        {
            if (payments.Length < 1)
            {
                throw new Exception("没有支付信息!");
            }

            string   xmlString = ICBCNCHelper.GetXmlString("PAYENT");
            XML_EASY xmlPay    = new XML_EASY(xmlString);
            string   xmlRd     = xmlPay.GetXMLNode("rd");

            var           newXmlStr = string.Empty;
            decimal       amount    = 0;
            int           num       = 0; //支付笔数或序号
            StringBuilder sb        = new StringBuilder();
            XML_EASY      xmlTmp    = new XML_EASY();
            string        s         = string.Empty;
            int           iseq      = 0;

            payments = payments.OrderBy(t => t.iSeqno).ToArray();  //iSeqno 在银行端支付时按rd的顺序,不按iSeqno来,需要先按iSeqno排序后,在生成rd
            foreach (PaymentInfo pay in payments)
            {
                num++;
                iseq = string.IsNullOrEmpty(pay.iSeqno)? num : int.Parse(pay.iSeqno);
                sb.Append("<rd>");
                sb.Append(this.dealwithPaymentRd(xmlRd, pay, iseq));
                sb.Append("</rd>");

                if (pay.amount != 0)
                {
                    amount += pay.amount;
                }
            }
            xmlPay.RepXMLNode("rd", sb.ToString());

            //设置头部信息
            xmlPay.SetXMLNode("BankCode", string.IsNullOrEmpty(payments[0].bankAcnt.swiftCode)?"102": payments[0].bankAcnt.swiftCode); //工行为 "102"
            xmlPay.SetXMLNode("CIS", ConfigurationManager.AppSettings["cis"]);
            xmlPay.SetXMLNode("ID", ConfigurationManager.AppSettings["id"]);

            //设置支付信息
            xmlPay.SetXMLNode("TotalNum", num.ToString("f0"));
            xmlPay.SetXMLNode("TotalAmt", amount.ToString("f0"));

            newXmlStr = xmlPay.GetXML();
            string result = this.ICBC_YQHL(newXmlStr);

            xmlPay.SetXML(result);
            if (xmlPay.LocateString("<error>") >= 0)
            {
                result = xmlPay.GetXMLNode("error");
                throw new Exception(result);
            }

            if (!string.IsNullOrEmpty(result))
            {
                XML_EASY xml_easy1 = new XML_EASY(result);
                BankReturnModel <PaymentInfo[]> retMo = new BankReturnModel <PaymentInfo[]>();

                retMo.bankCode     = xml_easy1.GetXMLNode("BankCode");
                retMo.transCode    = xml_easy1.GetXMLNode("TransCode");
                retMo.tranDate     = xml_easy1.GetXMLNode("TranDate");
                retMo.tranTime     = xml_easy1.GetXMLNode("TranTime");
                retMo.fSeqno       = xml_easy1.GetXMLNode("fSeqno");
                retMo.retCode      = xml_easy1.GetXMLNode("RetCode");
                retMo.retMsg       = xml_easy1.GetXMLNode("RetMsg");
                retMo.bankSerialNo = xml_easy1.GetXMLNode("SerialNo");


                string resultCode = xml_easy1.GetXMLNode("Result");
                if (string.IsNullOrEmpty(resultCode))
                {
                    //文件级返回

                    ////再次发送指令查询状态
                    //if (retMo.retCode == "0")
                    //{
                    //    Thread.Sleep(20 * 1000); //延时后再查询
                    //    return this.getPaymentState(caller, payments[0].bankAcnt.bankVersionInfo, retMo.fSeqno);
                    //}

                    //直接返回结果
                    retMo.detailData               = new BankReturnDetailModel <PaymentInfo[]>();
                    retMo.detailData.resultCode    = resultCode;
                    retMo.detailData.iRetCode      = xml_easy1.GetXMLNode("iRetCode");
                    retMo.detailData.iRetMsg       = xml_easy1.GetXMLNode("iRetMsg");
                    retMo.detailData.businessRefNo = xml_easy1.GetXMLNode("Ref");
                    retMo.detailData.infoData      = null; //payment;
                    return(retMo);
                }
                else
                {
                    //单笔明细支付,指令级返回
                    //retMo.detailData = new BankReturnDetailModel<PaymentInfo[]>();
                    //retMo.detailData.resultCode = resultCode;
                    //retMo.detailData.iRetCode = xml_easy1.GetXMLNode("iRetCode");
                    //retMo.detailData.iRetMsg = xml_easy1.GetXMLNode("iRetMsg");
                    //retMo.detailData.businessRefNo = xml_easy1.GetXMLNode("Ref");
                    //retMo.detailData.infoData = null; //payment;

                    string rdString = xml_easy1.GetXMLNode("rd");
                    int    rdIndex  = xml_easy1.Index();
                    //string result = xmlPayState.GetXMLNode("Result", rdIndex);
                    if (!string.IsNullOrEmpty(rdString))
                    {
                        var         states = new List <PaymentInfo>();
                        PaymentInfo pInfo  = null;
                        //循环获取明细
                        do
                        {
                            pInfo = getPaymentInfofromRd(payments[0].bankAcnt.bankVersionInfo, rdString);
                            pInfo.paymentSeqNo = xml_easy1.GetXMLNode("fSeqno");
                            if (pInfo.submitDate == DateTime.MinValue)
                            {
                                pInfo.submitDate = this.convertToDateTime(xml_easy1.GetXMLNode("TranDate") + xml_easy1.GetXMLNode("TranTime"));
                            }
                            states.Add(pInfo);

                            rdString = xml_easy1.GetXMLNode("rd", rdIndex);
                            rdIndex  = xml_easy1.Index();
                        }while (!string.IsNullOrEmpty(rdString));

                        retMo.detailData          = new BankReturnDetailModel <PaymentInfo[]>();
                        retMo.detailData.infoData = states.ToArray();

                        return(retMo);
                    }
                }
                return(retMo);
            }

            return(null);
        }
Ejemplo n.º 24
0
        private void ebI4p1Ribbon_Load(object sender, RibbonUIEventArgs e)
        {
            _settingsView = Globals.ThisDocument.SettingsViewModel;
            _ribbonView   = Globals.ThisDocument.RibbonViewModel;
            _invoiceView  = Globals.ThisDocument.InvoiceViewModel;
            Globals.ThisDocument.InvoiceViewModel.PropertyChanged            += InvoiceViewOnPropertyChanged;
            Globals.ThisDocument.InvoiceViewModel.RelatedDoc.PropertyChanged += RelatedViewPropertyChanged;

            Globals.ThisDocument.RegisterSingleEventSubscriber(InvoiceViewModel.InvoiceValidationOptionChanged, OnInvoiceValidationOptionChanged);

            Log.TraceWrite(CallerInfo.Create(), "Ribbon Load");
            Log.TraceWrite(CallerInfo.Create(), "group7 vibility is " + group7.Visible.ToString());
            group7.Visible = true;
            #region Invoice -> InvoiceViewModel
            // RibbonButton btnNewInvoice;
            RegisterCommand(btnNewInvoice, _invoiceView.ClearDocumentCommand);

            // RibbonButton BtnDetails;
            RegisterCommand(BtnDetails, _invoiceView.EditDetailsCommand);

            // RibbonButton BtnSave;
            RegisterCommand(BtnSave, _invoiceView.SaveEbinterfaceCommand);

            // RibbonButton BtnSkonto;
            RegisterCommand(BtnSkonto, _invoiceView.EditSkontoCommand);
            // RibbonButton BtnSaveAsTemplate;
            RegisterCommand(BtnSaveAsTemplate, _invoiceView.SaveTemplateCommand);
            // RibbonButton BtnLoadTemplate;
            RegisterCommand(BtnLoadTemplate, _invoiceView.LoadTemplateCommand);

            // Ribbonbutton BtnVerify
            RegisterCommand(btnVerify, _invoiceView.VerifyCommand);


            // RibbonButton btnMailAndSave;
            RegisterCommand(btnSendByMail, _invoiceView.SaveAndMailButton);
            // RibbonButton btnSendByService;
            RegisterCommand(btnSendByService, _invoiceView.RunZustellDienstButton);
            #endregion
            #region settings -> SettingsViewModel
            RegisterCommand(BtnEditSettings, _settingsView.EditEditRechnungsstellerCommand, true);
            RegisterCommand(gbtnKonto, _settingsView.EditKontoCommandButton);
            RegisterCommand(gbtnHandySignatur, _settingsView.HandySignaturButtonCommand);
            RegisterCommand(gbtnMail, _settingsView.MailButton);
            RegisterCommand(gbtnSaveLoc, _settingsView.SaveLocButton);
            RegisterCommand(gbtnZustellung, _settingsView.ZustellgButton);

            #endregion
            #region service -> RibbonViewModel

            // RibbonButton BtnEbInterface;
            RegisterCommand(BtnEbInterface, _ribbonView.EbInterfaceLinkButton);
            // RibbonButton BtnAustriaPro;
            RegisterCommand(BtnAustriaPro, _ribbonView.AustriaProButton);
            // RibbonButton BtnSignatur;
            //RegisterCommand(BtnSignatur, _ribbonView.SignaturButton);
            // RibbonButton btnErbGvAt;
            RegisterCommand(btnErbGvAt, _ribbonView.ErbGvAtButton);
            // RibbonButton BtnHelp;
            RegisterCommand(BtnHelp, _ribbonView.HelpButton);
            // RibbonButton btnSupport;
            RegisterCommand(btnSupport, _ribbonView.SupportButton);
            // RibbonButton BtnAbout;
            RegisterCommand(BtnAbout, _ribbonView.BtnAboutCommand, false);
            #endregion

            SetRibbonVisibility(_invoiceView.CurrentSelectedValidation);
            Type word = Type.GetTypeFromProgID("Word.Application.12");
            if (word == null)
            {
                // It is not Word 2007
                this.Base.Ribbon.RibbonUI.ActivateTabMso("TabAddIns");
            }
            Log.TraceWrite(CallerInfo.Create(), "Ribbon Load finished");
        }
Ejemplo n.º 25
0
 public virtual ISearchPolicy GetSearchPolicy(IRecipientSession recipientSession, CallerInfo callerInfo, ExchangeRunspaceConfiguration runspaceConfiguration, IBudget budget = null)
 {
     Recorder.Trace(2L, TraceType.InfoTrace, "SearchFactory.GetSearchPolicy");
     return(new SearchPolicy(recipientSession, callerInfo, runspaceConfiguration, budget));
 }
Ejemplo n.º 26
0
    public static void GoDoSomething()
    {
        int score = 12;

        Log.Information("Player scored: {Score}", CallerInfo.Create(), score);
    }
Ejemplo n.º 27
0
        new public List <RetVal> PredictOccupancy(long startSlotIndex, long endSlotIndex)
        {
            List <RetVal> retVal = new List <RetVal>();

            System.IO.StreamReader datafile = null;

            if (dataFilePath != null) //assuming datafile has one occupancy value per line read to startSlotIndex
            {
                string line;
                int    counter = 0;
                datafile = new System.IO.StreamReader(this.dataFilePath);
                if (startSlotIndex != 0)
                {
                    while ((line = datafile.ReadLine()) != null)
                    {
                        if (counter == startSlotIndex)
                        {
                            break;
                        }
                        counter++;
                    }
                }
            }

            StreamFactory streamFactory = StreamFactory.Instance;

            FqStreamID fq_sid = new FqStreamID("smartpreheat", "A", "TestBS");
            CallerInfo ci     = new CallerInfo(null, "A", "A", 1);

            streamFactory.deleteStream(fq_sid, ci);
            IStream occupancyGroundTruthStream = streamFactory.openValueDataStream <StrKey, ByteValue>(fq_sid, ci, null, StreamFactory.StreamSecurityType.Plain, CompressionType.None, StreamFactory.StreamOp.Write, null, 4 * 1024 * 1024, 1, new Logger());

            int slotIndex = 0; long startTime, retrievelTime, computeTime, insertTime;

            while (true)
            {
                startTime = DateTime.Now.Ticks;
                List <int>         currentPOV      = SmartConstructCurrentPOV(occupancyGroundTruthStream, slotIndex);
                List <List <int> > previousDaysPOV = SmartConstructPreviousPOV(occupancyGroundTruthStream, slotIndex);
                retrievelTime = DateTime.Now.Ticks - startTime;

                startTime = DateTime.Now.Ticks;
                int predictedOccupancy = Predict(currentPOV, previousDaysPOV);
                computeTime = DateTime.Now.Ticks - startTime;

                startTime = DateTime.Now.Ticks;
                int groundTruth;
                if (datafile == null) // if no datafile to read the ground truth from just append randomly
                {
                    groundTruth = random.Next(2);
                }
                else
                {
                    string line = datafile.ReadLine();
                    groundTruth = int.Parse(line);
                }

                currentPOV.Add(groundTruth);
                List <int> temp = new List <int>();
                foreach (List <int> previousPOV in previousDaysPOV)
                {
                    temp = temp.Concat(previousPOV).ToList();
                }
                temp = temp.Concat(currentPOV).ToList();
                occupancyGroundTruthStream.Append(occupancyKey, new ByteValue(temp.SelectMany(BitConverter.GetBytes).ToArray()), slotIndexBase + slotIndex);

                insertTime = DateTime.Now.Ticks - startTime;
                Console.WriteLine("Slot number {0} {1} {2} {3}", slotIndex, retrievelTime, computeTime, insertTime);

                using (results = File.AppendText(outputFilePath))
                    results.WriteLine("Slot number {0} {1} {2} {3}", slotIndex, retrievelTime, computeTime, insertTime);

                slotIndex++;
                //retVal.Add(new RetVal(endTime - startTime, predictedOccupancy));

                if (slotIndex == endSlotIndex)
                {
                    break;
                }
            }
            occupancyGroundTruthStream.Close();
            return(retVal);
        }
Ejemplo n.º 28
0
 public BankReturnModel <PaymentInfo[]> getPaymentState(CallerInfo caller, BankVersionInfo bankVerInfo, String paymentSeqNo)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 29
0
 public void Error(Exception exception, string message, params object[] objs)
 {
     Log.Error(exception, message, CallerInfo.Create(), objs);
 }
Ejemplo n.º 30
0
 public BankReturnModel <PaymentInfo[]> submitPayment(CallerInfo caller, PaymentInfo[] payment)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 31
0
 public BankReturnModel <DetailInfo[]> getCurrentDetails(CallerInfo caller, BankAcnt bankAcnt, decimal minAmt, decimal maxAmt, string nextTag, string currency)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 32
0
 protected bool Equals(CallerInfo other)
 {
     return(string.Equals(Name, other.Name) && SourceLineNumber == other.SourceLineNumber && string.Equals(SourceFilePath, other.SourceFilePath));
 }
Ejemplo n.º 33
0
 /// <summary>
 /// The send call to.
 /// </summary>
 /// <param name="agentId">
 /// TODO The agent id.
 /// </param>
 /// <param name="callInfo">
 /// TODO The call info.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 bool ITelephonyService.SendCallTo(Guid agentId, CallerInfo callInfo)
 {
     return(SendCallTo(agentId, callInfo));
 }
Ejemplo n.º 34
0
 public BankReturnModel <DetailInfo[]> getHistoryDetails(CallerInfo caller, BankAcnt bankAcnt, DateTime beginTime, DateTime endTime, decimal minAmt, decimal maxAmt, string nextTag, string currency)
 {
     throw new NotImplementedException();
 }