Esempio n. 1
0
        /// <summary>
        ///     Initialize the onramp engine.
        /// </summary>
        /// <param name="onRampPatternComponent">
        ///     The off ramp pattern component.
        /// </param>
        public void Init(string onRampPatternComponent)
        {
            // Delegate event for ingestor where ReceiveMessageOnRamp is the event
            receiveMessageOnRampDelegate = ReceiveMessageOnRamp;

            LogEngine.WriteLog(
                ConfigurationBag.EngineName,
                "Start On Ramp engine.",
                Constant.LogLevelError,
                Constant.TaskCategoriesError,
                null,
                Constant.LogLevelInformation);

            // Inizialize the MSPC

            // Load event up stream external component
            var eventsUpStreamComponent = Path.Combine(
                ConfigurationBag.Configuration.DirectoryOperativeRootExeName,
                ConfigurationBag.Configuration.EventsStreamComponent);

            // Create the reflection method cached
            var assembly = Assembly.LoadFrom(eventsUpStreamComponent);

            // Main class loggingCreateOnRamptream
            var assemblyClass = (from t in assembly.GetTypes()
                                 let attributes = t.GetCustomAttributes(typeof(EventsOnRampContract), true)
                                                  where t.IsClass && attributes != null && attributes.Length > 0
                                                  select t).First();


            OnRampStream = Activator.CreateInstance(assemblyClass) as IOnRampStream;
            OnRampStream.Run(receiveMessageOnRampDelegate);
        }
Esempio n. 2
0
        /// <summary>
        /// 更改数据字典状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public OpResult ChangeStatus(int id)
        {
            var result = OpResult.Fail("状态变更失败");

            try
            {
                var model  = _dal.GetById(id);
                var model1 = model;
                model1.Status = !model.Status;
                _dal.UpdateStatus(model1);

                var logMsg = LogEngine.CompareModelToLog <SysDataDictionary>(Pharos.Sys.LogModule.数据字典, model, model1);
                logEngine.WriteInsert(logMsg, Pharos.Sys.LogModule.数据字典);

                result = OpResult.Success("数据保存成功");
                if (result.Successed)
                {
                    Pharos.Infrastructure.Data.Redis.RedisManager.Publish("SyncDatabase", new Pharos.ObjectModels.DTOs.DatabaseChanged()
                    {
                        CompanyId = Sys.SysCommonRules.CompanyId, StoreId = "-1", Target = "SysDataDictionary"
                    });
                }
            }
            catch (Exception e)
            {
                result = OpResult.Fail("状态变更失败" + e.Message);
            }
            return(result);
        }
Esempio n. 3
0
        private async void SendEndToEndMessage(SocketHandler socketHandler, ChatObject e)
        {
            var receiverInstances = new List <SocketHandler>();

            if (AllSocketInstances.ContainsKey(e.ReceiverName))
            {
                var rInstances = AllSocketInstances[e.ReceiverName];
                receiverInstances.AddRange(rInstances);
            }

            if (AllSocketInstances.ContainsKey(e.SenderName))
            {
                var sInstances = AllSocketInstances[e.SenderName]
                                 .Where(x => x.Id != socketHandler.Id);
                receiverInstances.AddRange(sInstances);
            }

            foreach (var item in receiverInstances.Where(m => m.IsActive))
            {
                try
                {
                    await item.SendMessage(e);

                    e.Delivered = true;
                }
                catch (Exception ex)
                {
                    LogEngine.Error(ex);
                }
            }
            _localDB.Add(e);
            await _localDB.SaveChangesAsync();
        }
Esempio n. 4
0
        /// <summary>
        ///     Sync a single configuration file
        /// </summary>
        public static void SyncLocalConfigurationFile(SyncConfigurationFile jitgSyncConfigurationFile)
        {
            try
            {
                //invia il file con tutta la di e metti nelle prop che e un evento o trigger e la dir, il contenuto nel body eventdata
                //fai il replace della dir

                var newFilenameDir =
                    jitgSyncConfigurationFile.Name.Replace(jitgSyncConfigurationFile.DirectoryOperativeRoot_ExeName, "");
                newFilenameDir = string.Concat(Configuration.DirectoryEndPoints(), "\\",
                                               jitgSyncConfigurationFile.Name, newFilenameDir);
                Directory.CreateDirectory(Path.GetDirectoryName(newFilenameDir));

                File.WriteAllBytes(newFilenameDir, jitgSyncConfigurationFile.FileContent);
            }
            catch (IOException ioException)
            {
                LogEngine.ConsoleWriteLine("-SYNC CONF. BUBBLING -", ConsoleColor.Red);
            }
            catch (UnauthorizedAccessException unauthorizedAccessException)
            {
                LogEngine.ConsoleWriteLine("-SYNC CONF. BUBBLING -", ConsoleColor.Red);
            }

            catch (Exception ex)
            {
                LogEngine.WriteLog(Configuration.General_Source,
                                   string.Format("Error in {0}", MethodBase.GetCurrentMethod().Name),
                                   Constant.Error_EventID_High_Critical_,
                                   Constant.TaskCategories_,
                                   ex,
                                   EventLogEntryType.Error);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Load the bubbling settings
        /// </summary>
        public static void InitializeOffRampEmbedded(SetEventActionEvent delegateActionEventEmbedded)
        {
            //Load Configuration
            GrabCaster.Framework.Base.Configuration.LoadConfiguration();

            LogEngine.EventViewerWriteLog(Configuration.EngineName,
                                          "Inizialize Off Ramp embedded messaging.",
                                          Constant.DefconOne,
                                          Constant.TaskCategoriesError,
                                          null,
                                          EventLogEntryType.Information);

            //Solve App domain environment
            var current = AppDomain.CurrentDomain;

            current.AssemblyResolve += HandleAssemblyResolve;


            int triggers = 0;
            int events   = 0;

            EventsEngine.InitializeTriggerEngine();
            EventsEngine.InitializeEmbeddedEvent(delegateActionEventEmbedded);
            //Load component list configuration
            EventsEngine.LoadBubblingEventList(ref triggers, ref events);

            //Load event list configuration
            EventsEngine.RefreshBubblingSetting();
        }
Esempio n. 6
0
        /// <summary>
        /// The delegate event executed by a event
        /// </summary>
        /// <param name="eventType">
        /// </param>
        /// <param name="context">
        /// EventActionContext cosa deve essere esuito
        /// </param>
        private static void delegateActionEventEmbedded(IEventType eventType, EventActionContext context)
        {
            lock (context)
            {
                try
                {
                    //If embedded mode and trigger source == embeddedtrigger then not execute the internal embedded delelegate
                    if (context.BubblingConfiguration.AssemblyClassType != typeof(GrabCaster.Framework.EmbeddedTrigger.EmbeddedTrigger))
                    {
                        setEventActionEventEmbedded(eventType, context);
                    }
                }
                catch (Exception ex)
                {
                    context.BubblingConfiguration.CorrelationOverride = null;

                    LogEngine.WriteLog(
                        Configuration.EngineName,
                        $"Error in {MethodBase.GetCurrentMethod().Name}",
                        Constant.DefconOne,
                        Constant.TaskCategoriesError,
                        ex,
                        EventLogEntryType.Error);
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        ///     Execute an embedded trigger
        /// </summary>
        /// <param name="componeId">
        /// </param>
        /// <param name="triggerEmbeddedBag"></param>
        /// <returns>
        ///     The <see cref="string" />.
        /// </returns>
        public static byte[] ExecuteEmbeddedTrigger(TriggerEmbeddedBag triggerEmbeddedBag)
        {
            try
            {
                eventStop            = new AutoResetEvent(false);
                SyncAsyncEventAction = SyncAsyncActionReceived;
                triggerEmbeddedBag.ActionContext.BubblingObjectBag.SyncronousToken = Guid.NewGuid().ToString();
                EventsEngine.SyncAsyncEventsAddDelegate(
                    triggerEmbeddedBag.ActionContext.BubblingObjectBag.SyncronousToken,
                    SyncAsyncActionReceived);

                EventsEngine.EngineExecuteEmbeddedTrigger(triggerEmbeddedBag);

                eventStop.WaitOne();

                return(_syncronousDataContext);
            }
            catch (Exception ex)
            {
                LogEngine.WriteLog(
                    ConfigurationBag.EngineName,
                    $"Error in {MethodBase.GetCurrentMethod().Name}",
                    Constant.LogLevelError,
                    Constant.TaskCategoriesError,
                    ex,
                    Constant.LogLevelError);
                return(null);
            }
        }
        private async void PhoneSubmitAction()
        {
            if (string.IsNullOrWhiteSpace(RollNo))
            {
                _dialog.ShowToastMessage("Invalid Roll Number");
            }
            else if (string.IsNullOrWhiteSpace(PhoneNo))
            {
                _dialog.ShowToastMessage("Invalid Mobile Number");
            }
            var response = await _memberHandler.VerifyPhoneNo(RollNo, PhoneNo);

            if (response != null && response.Actionstatus)
            {
                RegistrationState = RegistrationState.Mobile;
                try
                {
                    _platformService.VerifyPhoneNumber(PhoneNo,
                                                       VerifyOtpCommand, VerifyFailedCommand, CodeSentCommand, VerifyAuthCommand);
                }
                catch (Exception ex)
                {
                    LogEngine.Error(ex);
                }
            }
            else
            {
                _dialog.ShowMessage("Error", response?.Message);
            }
        }
Esempio n. 9
0
        protected override void OnException(ExceptionContext filterContext)
        {
            var err = DataCache.Get <string>("err");

            if (err != filterContext.Exception.Message)//不重复添加异常信息
            {
                LogEngine log = new LogEngine();
                log.WriteError(filterContext.Exception);
                DataCache.Set("err", filterContext.Exception.Message, 1);

                if (filterContext.HttpContext.Request.IsAjaxRequest() ||
                    filterContext.HttpContext.Request.HttpMethod.Equals("POST", StringComparison.CurrentCultureIgnoreCase))
                {
                    filterContext.ExceptionHandled = true;
                    var op = new OpResult()
                    {
                        Message = filterContext.Exception.Message
                    };
                    filterContext.Result = new ContentResult()
                    {
                        Content = op.ToJson()
                    };
                }
            }
        }
Esempio n. 10
0
 public override object Query(RefundQueryRequest reqModel)
 {
     try
     {
         var canObj = CanAccess();
         if (!canObj.Successed)
         {
             return(canObj);
         }
         var sxfReq = new SxfRefundQueryRequest(reqModel, MerchStoreModel);
         //sxf签名并请求
         var sxfResult = PayHelper.SendPost(MerchStoreModel.ApiUrl, PaySignHelper.ToDicAndSign(sxfReq, MerchModel.SecretKey3, "signature"));
         if (sxfResult.Successed)
         {
             //处理返回结果
             var sxfResultObj = JsonConvert.DeserializeObject <SxfRefundQueryResponse>(sxfResult.Data.ToString());
             var result       = sxfResultObj.ToRefundQueryResponse(MerchStoreModel);
             //Qct签名
             var rstRsp = PaySignHelper.ToDicAndSign(result, MerchModel.SecretKey, "sign");
             return(rstRsp);
         }
         else
         {
             return(sxfResult);
         }
     }
     catch (Exception ex)
     {
         LogEngine.WriteError(string.Format("退款订单查询请求异常:{0},请求参数:{1}", ex.Message, reqModel.ToJson()), null, LogModule.支付交易);
         return(QctPayReturn.Fail());
     }
 }
Esempio n. 11
0
 // InstallService

        /// <summary>
        /// Uninstalls the Windows Service.
        /// </summary>
        public static void UninstallService()
        {
            if (!IsInstalled())
            {
                LogEngine.WriteLog(
                    Configuration.EngineName, 
                    $"NT Service instance {ServiceName} is not installed.", 
                    Constant.DefconOne, 
                    Constant.TaskCategoriesConsole, 
                    null, 
                    EventLogEntryType.Warning);
                Console.ReadLine();

                return;
            }
 // if

            using (var installer = GetInstaller())
            {
                IDictionary state = new Hashtable();
                installer.Uninstall(state);
                LogEngine.WriteLog(
                    Configuration.EngineName, 
                    $"Service {ServiceName} Uninstallation completed.", 
                    Constant.DefconOne, 
                    Constant.TaskCategoriesConsole, 
                    null, 
                    EventLogEntryType.Information);
                Console.ReadLine();
            }
 // using
        }
Esempio n. 12
0
        /// <summary>
        /// 更改指定索引的负载
        /// </summary>
        /// <param name="nIndex">m_ThreadLoad's Index</param>
        /// <param name="newWeight">新权重</param>
        /// <returns></returns>
        public int ChangeWeight(int idxHeap, long newWeight)
        {
            //lock (m_lock)
            {
                int ret = 0;

                try
                {
                    _elements[idxHeap].Weight = newWeight;

                    if (idxHeap > HEAP0 && _elements[idxHeap].Weight <= _elements[idxHeap >> 1].Weight)
                    {
                        ret = UpHeap(idxHeap);
                    }
                    else
                    {
                        ret = DownHeap(idxHeap);
                    }
                }
                catch (Exception ex)
                {
                    LogEngine.Write(LOGTYPE.ERROR, "MinHeap::ChangeWeight(", idxHeap.ToString(), ",", newWeight.ToString(), "):", ex.Message);
                }

                return(ret);
            }
        }
Esempio n. 13
0
        public void StartRedisListener(SetEventOnRampMessageReceived setEventOnRampMessageReceived)
        {
            try
            {
                ConnectionMultiplexer redis =
                    ConnectionMultiplexer.Connect(ConfigurationBag.Configuration.RedisConnectionString);

                ISubscriber sub = redis.GetSubscriber();

                sub.Subscribe("*", (channel, message) =>
                {
                    byte[] byteArray = message;
                    BubblingObject bubblingObject = BubblingObject.DeserializeMessage(byteArray);
                    setEventOnRampMessageReceived(bubblingObject);
                });
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception ex)
            {
                LogEngine.WriteLog(
                    ConfigurationBag.EngineName,
                    $"Error in {MethodBase.GetCurrentMethod().Name}",
                    Constant.LogLevelError,
                    Constant.TaskCategoriesEventHubs,
                    ex,
                    Constant.LogLevelError);
            }
        }
Esempio n. 14
0
        public ActionResult AddBrandTitle(string title)
        {
            var re  = new OpResult();
            var obj = new ProductBrand();

            obj.CompanyId = CommonService.CompanyId;
            var source = ProductBrandService.Find(o => o.CompanyId == obj.CompanyId && o.Title == title);

            if (source != null)
            {
                re = OpResult.Success(source.BrandSN.ToString());
            }
            else
            {
                obj.Title   = title;
                obj.BrandSN = ProductBrandService.MaxSN;
                obj.State   = 1;
                re          = ProductBrandService.Add(obj);
                if (re.Successed)
                {
                    re.Message = obj.BrandSN.ToString();
                }
                #region 操作日志
                try
                {
                    var logMsg = LogEngine.CompareModelToLog <ProductBrand>(LogModule.品牌管理, obj);
                    logEngine.WriteInsert(logMsg, LogModule.品牌管理);
                }
                catch
                {
                }
                #endregion
            }
            return(Content(re.ToJson()));
        }
Esempio n. 15
0
        public int Push(T t)
        {
            if (this._capacity <= this._sizeUse)
            {
                this._capacity <<= 1;//扩容

                T[] newElements = new T[this._capacity];
                this._elements.CopyTo(newElements, 0);
                this._elements = newElements;

#if PROFILE
                LogEngine.Write(LOGTYPE.INFO, "MinHeap Push:", this._capacity.ToString());
#endif
            }
            int idxNew = this._sizeUse++;
            this._elements[idxNew] = t;
            t.HeapIndex            = idxNew;
            if (idxNew > HEAP0)
            {
                //TODO:临时加日志和校验,确定没有问题了,要去掉
                int ret = UpHeap(idxNew);
                if (ret < 1)
                {
                    LogEngine.Write(LOGTYPE.ERROR, "Push Fail");
                }

                return(ret);
            }
            else
            {
                return(idxNew);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="state">1是可用,2是暂停,3是注销,4是无效</param>
        /// <returns></returns>
        public OpResult UpState(string ids, int state)
        {
            OpResult opr = ExistState(ids, state);

            if (!opr.Successed)
            {
                return(opr);
            }
            else
            {
                try
                {
                    var idss = ids.Split(',').Select(o => int.Parse(o));
                    UpListByWhere(o => idss.Contains(o.Id), o =>
                    {
                        o.State = state;
                    });
                    return(OpResult.Success());
                }
                catch (Exception e)
                {
                    LogEngine.WriteError(e);
                    return(OpResult.Fail(e.InnerException.InnerException.Message));
                }
            }
        }
Esempio n. 17
0
        public static Assembly HandleAssemblyResolve(object sender, ResolveEventArgs args)
        {
            /* Load the assembly specified in 'args' here and return it,
             * if the assembly is already loaded you can return it here */
            try
            {
                if (args.Name.Substring(0, 10) == "Microsoft.")
                {
                    return(null);
                }
                if (args.Name.Substring(0, 7) == "System.")
                {
                    return(null);
                }

                return(EventsEngine.CacheEngineComponents[args.Name]);
            }
            catch (Exception ex)
            {
                var sb = new StringBuilder();
                sb.AppendLine(
                    $"Critical error in {MethodBase.GetCurrentMethod().Name} - The Assembly [{args.Name}] not found.");
                sb.AppendLine(
                    "Workaround: this error because a trigger or event is looking for a particular external library in reference, check if all the libraries referenced by triggers and events are in the triggers and events directories dll or registered in GAC.");

                LogEngine.WriteLog(
                    ConfigurationBag.EngineName,
                    sb.ToString(),
                    Constant.LogLevelError,
                    Constant.TaskCategoriesError,
                    ex,
                    Constant.LogLevelError);
                return(null);
            }
        }
        /// <summary>
        /// 发送完毕后处理
        /// </summary>
        /// <param name="e"></param>
        public void ProcessSend(SocketAsyncEventArgs e)
        {
            try
            {
                e.SetBuffer(null, 0, 0);// 清理发送缓冲区
                this.waitSendLen = 0;

                #region 发送速度检测

                long timeSpanTicks = DateTime.Now.Ticks - this.sendBeginTicks;
                if (timeSpanTicks > CommuEngine.MAX_WAIT_SEND_COMPLETE_TIME)//10s
                {
                    this.Break(CommuBreak.CLIENT_PROC_SLOW);
                }
                else
                {
                    CommuEngine.Instance.AddEvent(this.commuParam.socketId, EventType.Event_SendComplet);
                }

                #endregion
            }
            catch (Exception ex)
            {
                LogEngine.Write(LOGTYPE.ERROR, ex.ToString());
            }
        }
        public static void InitSecondaryPersistProvider()
        {
            try
            {
                secondaryPersistProviderEnabled  = ConfigurationBag.Configuration.SecondaryPersistProviderEnabled;
                secondaryPersistProviderByteSize = ConfigurationBag.Configuration.SecondaryPersistProviderByteSize;

                // Load the abrstracte persistent provider
                var devicePersistentProviderComponent = Path.Combine(
                    ConfigurationBag.Configuration.DirectoryOperativeRootExeName,
                    ConfigurationBag.Configuration.PersistentProviderComponent);

                // Create the reflection method cached
                var assemblyPersist = Assembly.LoadFrom(devicePersistentProviderComponent);

                // Main class logging
                var assemblyClassDpp = (from t in assemblyPersist.GetTypes()
                                        let attributes = t.GetCustomAttributes(typeof(DevicePersistentProviderContract), true)
                                                         where t.IsClass && attributes != null && attributes.Length > 0
                                                         select t).First();


                DevicePersistentProvider = Activator.CreateInstance(assemblyClassDpp) as IDevicePersistentProvider;
            }
            catch (Exception ex)
            {
                LogEngine.WriteLog(
                    ConfigurationBag.EngineName,
                    $"Error in {MethodBase.GetCurrentMethod().Name}",
                    Constant.LogLevelError,
                    Constant.TaskCategoriesEventHubs,
                    ex,
                    Constant.LogLevelError);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// 发送Post支付请求
        /// </summary>
        /// <param name="url"></param>
        /// <param name="paramsStr"></param>
        /// <returns></returns>
        public static QctPayReturn SendPost(this string url, string paramsStr)
        {
            string reqUrl = url + "?" + paramsStr;

            PayLogServer.WriteInfo(string.Format("发送交易请求:{0}", reqUrl));
            try
            {
                var httpRequest = (HttpWebRequest)WebRequest.Create(url);
                httpRequest.Method      = "POST";
                httpRequest.ContentType = "application/x-www-form-urlencoded";
                httpRequest.Timeout     = 45000;
                byte[] byteRequest = System.Text.Encoding.UTF8.GetBytes(paramsStr);
                httpRequest.ContentLength = byteRequest.Length;
                Stream requestStream = httpRequest.GetRequestStream();
                requestStream.Write(byteRequest, 0, byteRequest.Length);
                requestStream.Close();

                //获取服务端返回
                var response = (HttpWebResponse)httpRequest.GetResponse();
                //获取服务端返回数据
                StreamReader sr     = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                var          result = sr.ReadToEnd().Trim();
                sr.Close();
                result = HttpUtility.UrlDecode(result, Encoding.UTF8);
                return(QctPayReturn.Success(data: result));
            }
            catch (Exception ex)
            {
                var logEng = new LogEngine();
                logEng.WriteError(string.Format("发送交易请求异常:{0},请求地址:{1}", ex.Message, reqUrl), ex, LogModule.支付交易);
                return(QctPayReturn.Fail(code: PayConst.FAIL_CODE_20000, msg: "订单请求失败,服务器繁忙!"));
            }
        }
Esempio n. 21
0
        public Utility.OpResult Deletes(int[] ids)
        {
            var op = new OpResult();

            try
            {
                var devices = DevicesRepository.GetQuery(o => ids.Contains(o.Id));
                if (!devices.Any())
                {
                    op.Message = "查不到数据";
                    return(op);
                }
                var delDeviceId = devices.Select(o => o.DeviceId);
                var authorize   = DeviceAuthorizeRepository.GetQuery(o => delDeviceId.Contains(o.DeviceId));
                if (authorize.Any())
                {
                    op.Message = "无法删除,设备授权包含了要删除的设备";
                    return(op);
                }

                DevicesRepository.RemoveRange(devices.ToList());
                op.Successed = true;
                LogEngine.WriteDelete("移除设备", LogModule.设备管理);
            }
            catch (Exception ex)
            {
                op.Message = ex.Message;
                LogEngine.WriteError(ex);
            }
            return(op);
        }
Esempio n. 22
0
        public void StartRedisListener(SetEventOnRampMessageReceived setEventOnRampMessageReceived)
        {
            try
            {
                ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(Configuration.RedisConnectionString());

                ISubscriber sub = redis.GetSubscriber();

                sub.Subscribe("*", (channel, message) => {
                    byte[] byteArray = (byte[])message;
                    SkeletonMessage skeletonMessage = SkeletonMessage.DeserializeMessage(byteArray);
                    setEventOnRampMessageReceived(skeletonMessage);
                });
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception ex)
            {
                LogEngine.WriteLog(
                    Configuration.EngineName,
                    $"Error in {MethodBase.GetCurrentMethod().Name}",
                    Constant.DefconOne,
                    Constant.TaskCategoriesEventHubs,
                    ex,
                    EventLogEntryType.Error);
            }
        }
Esempio n. 23
0
 public MohidRunEngineData()
 {
     log = new LogEngine();
      dateFormat = "yyyy/MM/dd HH:mm:ss";
      provider = CultureInfo.InvariantCulture;
      LastOperationResult = true;
 }
Esempio n. 24
0
        public ActionResult Delete(int[] ids)
        {
            var list   = ProductBrandService.FindList(o => ids.Contains(o.Id));
            var brands = list.Select(o => o.BrandSN).ToList();
            var re     = new OpResult();

            if (ProductService.IsExist(o => o.BrandSN.HasValue && brands.Contains(o.BrandSN.Value)))
            {
                re.Message = "商品存在品牌关联";
            }
            else
            {
                re = ProductBrandService.Delete(list);
            }
            #region 16-04-05 操作日志
            try
            {
                foreach (var item in list)
                {
                    var logMsg = LogEngine.CompareModelToLog <ProductBrand>(LogModule.品牌管理, null, item);
                    logEngine.WriteDelete(logMsg, LogModule.品牌管理);
                }
            }
            catch
            {
            }

            #endregion

            return(new JsonNetResult(re));
        }
Esempio n. 25
0
 // StartService

        /// <summary>
        /// Stops the Windows Service.
        /// </summary>
        public static void StopService()
        {
            if (!IsInstalled())
            {
                return;
            }

            using (var controller = new ServiceController(ServiceName))
            {
                try
                {
                    if (controller.Status != ServiceControllerStatus.Stopped)
                    {
                        controller.Stop();
                        controller.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10));
                    }
 // if
                }
                catch (Exception ex)
                {
                    LogEngine.WriteLog(
                        Configuration.EngineName, 
                        "Error in " + MethodBase.GetCurrentMethod().Name, 
                        Constant.DefconOne, 
                        Constant.TaskCategoriesConsole, 
                        ex, 
                        EventLogEntryType.Error);
                    Console.ReadLine();

                    throw;
                }
 // try/catch
            }
 // usnig
        }
Esempio n. 26
0
 /// <summary>
 ///     Send local shared dll for the sync to the partner request
 /// </summary>
 /// <param name="Partner">Partner request to send</param>
 public static void SyncSendLocalDLLList(string DestinationPartner)
 {
     try
     {
         EventsEngine.UpdateAssemblyEventListShared();
         foreach (var jitgAssemblyEvent in EventsEngine.AssemblyEventListShared)
         {
             LogEngine.ConsoleWriteLine(
                 string.Format("SENT EVENT - {0} to {1}", jitgAssemblyEvent.FileName, DestinationPartner),
                 ConsoleColor.Green);
             OffRampEngineSending.SendMessageOnRamp(jitgAssemblyEvent, Configuration.MessageDataProperty.SyncSendLocalDLL,
                                                    DestinationPartner, null);
         }
     }
     catch (InvalidOperationException eoe)
     {
         LogEngine.ConsoleWriteLine(
             string.Format("Syncronization and Dictionaries rebuilded, Excpetion controlled - {0}", eoe.HResult),
             ConsoleColor.DarkRed);
     }
     catch (Exception ex)
     {
         LogEngine.WriteLog(Configuration.General_Source,
                            string.Format("Error in {0}", MethodBase.GetCurrentMethod().Name),
                            Constant.Error_EventID_High_Critical_,
                            Constant.TaskCategories_,
                            ex,
                            EventLogEntryType.Error);
     }
 }
Esempio n. 27
0
        public OpResult Save(TradersUser tradersUser, int id, System.Collections.Specialized.NameValueCollection nvl)
        {
            //验证
            var op = Verification(nvl, id);

            if (!op.Successed)
            {
                return(op);
            }
            else
            {
                try
                {
                    using (EFDbContext context = new EFDbContext())
                    {
                        using (TransactionScope transaction = new TransactionScope())
                        {
                            InsertUpdate(tradersUser, id);
                            //提交事务
                            transaction.Complete();
                            return(OpResult.Success());
                        }
                    }
                }
                catch (Exception e)
                {
                    LogEngine.WriteError(e);
                    return(OpResult.Fail(e.InnerException.InnerException.Message));
                }
            }
        }
        public bool CreateOffRampStream()
        {
            try
            {
                //EH Configuration
                connectionString = ConfigurationBag.Configuration.AzureNameSpaceConnectionString;
                eventHubName     = ConfigurationBag.Configuration.GroupEventHubsName;

                LogEngine.WriteLog(
                    ConfigurationBag.EngineName,
                    $"Event Hubs transfort Type: {ConfigurationBag.Configuration.ServiceBusConnectivityMode}",
                    Constant.LogLevelError,
                    Constant.TaskCategoriesError,
                    null,
                    Constant.LogLevelInformation);

                var builder = new ServiceBusConnectionStringBuilder(connectionString)
                {
                    TransportType =
                        TransportType.Amqp
                };

                eventHubClient = EventHubClient.CreateFromConnectionString(builder.ToString(), eventHubName);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Send the all bubbling configuration
        /// </summary>
        /// <param name="channelId">
        /// The Channel ID.
        /// </param>
        /// <param name="pointId">
        /// The Point ID.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string SyncSendBubblingConfiguration(string channelId, string pointId)
        {
            try
            {
                if (Base.Configuration.DisableExternalEventsStreamEngine())
                {
                    LogEngine.WriteLog(
                        Base.Configuration.EngineName,
                        "Warning the Device Provider Interface is disable, the GrabCaster point will be able to work in local mode only.",
                        Constant.DefconThree,
                        Constant.TaskCategoriesError,
                        null,
                        EventLogEntryType.Warning);

                    return
                        ("Warning the Device Provider Interface is disable, the GrabCaster point will be able to work in local mode only.");
                }

                SyncProvider.SyncSendBubblingConfiguration(channelId, pointId);
            }
            catch (Exception ex)
            {
                LogEngine.WriteLog(
                    Base.Configuration.EngineName,
                    $"Error in {MethodBase.GetCurrentMethod().Name}",
                    Constant.DefconOne,
                    Constant.TaskCategoriesError,
                    ex,
                    EventLogEntryType.Error);
                return(ex.Message);
            }

            return($"Syncronization Executed at {DateTime.Now}.");
        }
Esempio n. 30
0
        /// <summary>
        ///     Load the bubbling settings
        /// </summary>
        public static void InitializeOffRampEmbedded(ActionEvent delegateEmbedded)
        {
            //Load Configuration
            ConfigurationBag.LoadConfiguration();

            LogEngine.WriteLog(ConfigurationBag.EngineName,
                               "Inizialize Off Ramp embedded messaging.",
                               Constant.LogLevelError,
                               Constant.TaskCategoriesError,
                               null,
                               Constant.LogLevelInformation);

            //Solve App domain environment
            var current = AppDomain.CurrentDomain;

            current.AssemblyResolve += HandleAssemblyResolve;


            int triggers   = 0;
            int events     = 0;
            int components = 0;

            EventsEngine.InitializeTriggerEngine();
            EventsEngine.InitializeEmbeddedEvent(delegateEmbedded);
            //Load component list configuration
            EventsEngine.LoadAssemblyComponents(ref triggers, ref events, ref components);

            //Load event list configuration
            EventsEngine.RefreshBubblingSetting(false);
        }
Esempio n. 31
0
        public OpResult Save(TradersPaySecretKey tradersPaySecretKey, int id, DateTime dt, System.Collections.Specialized.NameValueCollection nvl)
        {
            //验证
            var op = Verification(nvl, id, tradersPaySecretKey);

            if (!op.Successed)
            {
                return(op);
            }
            else
            {
                try
                {
                    using (EFDbContext context = new EFDbContext())
                    {
                        using (TransactionScope transaction = new TransactionScope())
                        {
                            //商家支付主密钥
                            TradersPaySecretKey PaySecretKey = InsertUpdate(tradersPaySecretKey, id);
                            //支付方式
                            string h_PayManner = (nvl["h_PayManner"] ?? "").Trim();
                            if (!h_PayManner.IsNullOrEmpty())
                            {
                                JObject jObj = null;
                                jObj = JObject.Parse(h_PayManner);
                                JArray jlist = JArray.Parse(jObj["TradersPayChannel"].ToString());
                                tradersPayChannelService.DeleteByWhere(o => o.TPaySecrectId == PaySecretKey.TPaySecrectId);
                                foreach (JObject item in jlist)
                                {
                                    short  ChannelPayMode = Convert.ToInt16(item["ChannelPayMode"]);
                                    string PayNotifyUrl   = item["PayNotifyUrl"].ToString();
                                    string RfdNotifyUrl   = item["RfdNotifyUrl"].ToString();

                                    TradersPayChannel tradersPayChannel = new TradersPayChannel();
                                    tradersPayChannel.TPayChannelId  = CommonService.GUID.ToUpper();
                                    tradersPayChannel.TPaySecrectId  = PaySecretKey.TPaySecrectId;
                                    tradersPayChannel.ChannelPayMode = ChannelPayMode;
                                    tradersPayChannel.PayNotifyUrl   = PayNotifyUrl;
                                    tradersPayChannel.RfdNotifyUrl   = RfdNotifyUrl;
                                    tradersPayChannel.State          = 1;
                                    tradersPayChannel.CreateUID      = CurrentUser.UID;
                                    tradersPayChannel.CreateDT       = dt;
                                    tradersPayChannel.ModifyUID      = CurrentUser.UID;
                                    tradersPayChannel.ModifyDT       = dt;
                                    tradersPayChannelService.InsertUpdate(tradersPayChannel, 0);
                                }
                            }
                            //提交事务
                            transaction.Complete();
                            return(OpResult.Success());
                        }
                    }
                }
                catch (Exception e)
                {
                    LogEngine.WriteError(e);
                    return(OpResult.Fail(e.InnerException.InnerException.Message));
                }
            }
        }
Esempio n. 32
0
 public MM52TS()
 {
     acceptableFailure = false;
     log = new LogEngine("get.mm5.2.timeseries.log");
     logNode = new ConfigNode(DateTime.Now.ToString("yyyy-MM-dd.HHmmss"));
     WorkPath = new FilePath(@".\");
     WindsPath = new FilePath(@".\");
 }
Esempio n. 33
0
 public void Init()
 {
     sim = new MohidSimulation();
      log = new LogEngine();
      first = new List<InputFileTemplate>();
      next = new List<InputFileTemplate>();
      dateFormat = "yyyy/MM/dd HH:mm:ss";
      provider = CultureInfo.InvariantCulture;
 }
Esempio n. 34
0
 /// <summary>constructor</summary>
 /// <param name="targetLog">log engine to use</param>
 /// <param name="device">type of ios device</param>
 public iOSClient(LogEngine targetLog, iOSDevice device)
     : base(targetLog)
 {
     // set up action library
     _BatchCommandQueue_ = new List<string>();
     _IsBatchingCommands_ = false;
     _CommandIndex = -1;
     _CompiledAppPath = "";
     _StartAutomation(device);
 }
 public MohidRunEngineData()
 {
     sim = new MohidSimulation();
     log = new LogEngine();
     templatesStart = new List<InputFileTemplate>();
     templatesContinuation = new List<InputFileTemplate>();
     dateFormat = "yyyy/MM/dd HH:mm:ss";
     provider = CultureInfo.InvariantCulture;
     LastOperationResult = true;
 }
Esempio n. 36
0
 private void OnLogMessageCaptured(object sender, LogEngine.LogEventArgs e)
 {
     ConsoleWriteLine(e.Message);
 }
Esempio n. 37
0
 /// <summary>constructor</summary>
 /// <param name="targetLog">log engine to use</param>
 public iPadClient(LogEngine targetLog)
     : base(targetLog, iOSDevice.iPad)
 {
 }
Esempio n. 38
0
        public bool Reset()
        {
            fLastException = null;
             fStartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
             fCPTECFilesPath = @".\data\";
             fOutputPath = @".\output\";
             fIntervalToUse = 0;
             fCPTECFileNameTag = "";
             fOutputTag = "cptec_";
             fGlueExe = "glue.exe";
             fGlueExePath = @".\glue\";
             fGlueWorkingFolder = fGlueExePath;
             fOverwrite = true;
             fLogExecution = true;
             fLogFileTag = "";
             fLogFilePath = @".\";
             fLog = null;

             return true;
        }
Esempio n. 39
0
        public bool Run(ConfigNode cfg)
        {
            LoadCfg(cfg);
             if (!CheckUserInput())
            return false;

             if (fLogExecution)
             {
            fLog = new LogEngine(fLogFilePath + "log" + fLogFileTag + DateTime.Now.ToString("yyyyMMddHHmmss") + ".log");
             }

             bool result = false;

             try
             {
            result = GlueFiles();

            if (fLogExecution)
            {
               fLog.Save();
            }
             }
             catch (Exception)
             {
            if (fLogExecution)
            {
               fLog.Save();
            }
             }

             return result;
        }