public static string FetchDescription(ProcessType value)
    {
        FieldInfo fi = value.GetType().GetField(value.ToString());

        DescriptionAttribute[] attributes =
            (DescriptionAttribute[])fi.GetCustomAttributes(
                typeof(DescriptionAttribute), false);
        return((attributes.Length > 0) ? attributes[0].Description : value.ToString());
    }
Exemple #2
0
        public async Task <string> GetProcessNumber(ProcessType processType, int id)
        {
            string prefix  = string.Empty;
            string process = processType.ToString();

            for (int i = 0; i < process.Length; i++)
            {
                if (char.IsUpper(process[i]))
                {
                    prefix += process[i];
                }
            }

            StringBuilder consecutiveNumberBuilder = new StringBuilder(id.ToString());

            for (int i = 0; i < 5 - consecutiveNumberBuilder.Length; i++)
            {
                consecutiveNumberBuilder.Insert(0, "0");
            }

            string prefixPart = _random.Next(100, 999).ToString();
            string bodyPart   = _random.Next(100, 999).ToString();

            return($"{prefix}{prefixPart}-{bodyPart}-{consecutiveNumberBuilder}");
        }
Exemple #3
0
        public BrowserCommandResult <bool> CreateProcess(string name, ProcessType type, string entity, int thinkTime = Constants.DefaultThinkTime)
        {
            Browser.ThinkTime(thinkTime);

            return(this.Execute(GetOptions("Create Process"), driver =>
            {
                SwitchToDialogFrame();

                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Process.Name]))
                .SendKeys(name);

                SetValue(new OptionSet()
                {
                    Name = Elements.ElementId[Reference.Process.Category], Value = type.ToString()
                });
                SetValue(new OptionSet()
                {
                    Name = Elements.ElementId[Reference.Process.Entity], Value = entity
                });

                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Process.BlankWorkflow]));

                driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Process.Create]));

                return true;
            }));
        }
Exemple #4
0
    public void SettingPagePesmission(Page page, ProcessType type)
    {
        CurrentType = type;
        string enableControl = type.ToString();

        foreach (Control control in page.Form.Controls)
        {
            if (control is WebControl)
            {
                if (((WebControl)control).Attributes[enableControl] != null)
                {
                    SetControlStatus(control, ((WebControl)control).Attributes[enableControl]);
                    //control.Visible = false;
                }
                else
                {
                    if (control.HasControls())
                    {
                        SettingControlPesmission(control);
                    }
                }
            }
            else
            {
                if (control.HasControls())
                {
                    SettingControlPesmission(control);
                }
            }
        }
    }
        /// <summary>
        ///   http://msdn.microsoft.com/en-us/library/b8ytshk6.aspx
        /// </summary>
        /// <typeparam name = "TReturnResult"></typeparam>
        /// <typeparam name = "TInputParam"></typeparam>
        /// <param name = "authType"></param>
        /// <param name = "processType"></param>
        /// <returns></returns>
        public IDciContext <TReturnResult, TInputParam> GetAuthenticationContext <TReturnResult, TInputParam>(
            AuthRequestType authType, ProcessType processType) where TInputParam : IDciParameter
        {
            var context = AuthenticationContexts.FirstOrDefault(x =>
                                                                x.Item3.Equals(authType.ToString(),
                                                                               StringComparison.CurrentCulture) &&
                                                                x.Item4.Equals(processType.ToString(),
                                                                               StringComparison.CurrentCulture));

            //Type[] typeArgs = { Type.GetType(context.Item4), Type.GetType(context.Item5) };

            var fileType = Type.GetType(context.Item2);

            //var constructed = fileType.MakeGenericType(typeArgs);

            if (fileType == null)
            {
                throw new Exception("Cannot resolve type for " + context.Item3);
            }

            //if (!typeof(IDciContext<TReturnResult, TInputParam>).IsAssignableFrom(constructed))
            //    throw new Exception(string.Format("{0} must be inherit from IDciContext<TReturnResult, TInputParam>", context.Item3));

            return((IDciContext <TReturnResult, TInputParam>)Activator.CreateInstance(fileType));
        }
Exemple #6
0
        public void loadLogo(ProcessType processTypeIn)
        {
            Debug.WriteLine("LoadLogo: " + processTypeIn.ToString());
            switch (processTypeIn)
            {
            case ProcessType.DDD_EGS:
                logoImage.Source = new BitmapImage(new Uri(@"/Assets/Logos/Logo_DDD.png", UriKind.Relative));
                break;

            default:
                break;
            }
        }
Exemple #7
0
 private void Invoke(Action action, ref Boolean isError, ProcessType processType)
 {
     try
     {
         action.Invoke();
     }
     catch (Exception exception)
     {
         _hasException = true;
         isError       = true;
         Exceptions.Add(processType.ToString(), exception);
     }
 }
Exemple #8
0
        public void LogExecutionTime(int ms, ProcessType winner)
        {
            Log($"The winners are {winner.ToString().ToLower()}s");
            Log("====================================================");
            Log("=====================Statistics=====================");
            Log("====================================================");

            foreach (var move in actorsMoves.OrderBy(m => m.Key))
            {
                Log($"The {getType(move.Key).ToString().ToLower()} #{move.Key} request {move.Value.NbAcceptedMoves + move.Value.NbTotalMoves} moves");
                Log($"The {getType(move.Key).ToString().ToLower()} #{move.Key} has {Math.Round(move.Value.NbAcceptedMoves / (double)move.Value.NbTotalMoves * 100)}% accepted moves");
            }

            Log($"Total execution time : {ms} ms");
        }
Exemple #9
0
        public static Process searchProcessByType(ProcessType processType)
        {
            string processName = processTypeGetString(processType);

            if (processName == null)
            {
                Debug.WriteLine("ProcessHelper > ProcessType string not found [" + processType.ToString() + "]"); return(null);
            }

            Process searchedProcess = Process.GetProcessesByName(processName).FirstOrDefault();

            if (searchedProcess == null)
            {
                Debug.WriteLine("ProcessHelper > Process not found [" + processName + "]"); return(null);
            }

            return(searchedProcess);
        }
Exemple #10
0
        public static void Add(
            int process_user_id,
            ProcessType type,
            string name,
            object datas
            )
        {
            var _dt = DateTime.Now;

            log.Add(
                getIPAddress(),
                process_user_id.ToString(),
                type.ToString(),
                name,
                JsonConvert.SerializeObject(datas),
                _dt.Year.ToString(),
                _dt.Month.ToString(),
                _dt.Day.ToString(),
                _dt.Hour.ToString(),
                _dt.Minute.ToString(),
                _dt.Second.ToString()
                );
        }
Exemple #11
0
        public DicomAction InitAction(string actionOp, ProcessType process, Client client, DicomDataSet ds)
        {
            DicomAction action = new DicomAction(process, this, client, ds);

            action.AETitle   = client.Association.Calling;
            action.ipAddress = client.PeerAddress;
            mf.EnableTimer(client, action.AETitle, false);
            mf.UpdateClient(client, "", actionOp);
            action.ActionComplete += new DicomAction.ActionCompleteHandler(action_ActionComplete);

            if (ds != null && SaveDSReceived && !Logger.DisableLogging)
            {
                string file;

                file = LogDS(process.ToString(), client, ds);
                mf.Log(actionOp, "Received from " + action.AETitle, file);
            }
            else
            {
                mf.Log(actionOp, "Received from " + action.AETitle);
            }

            return(action);
        }
        public static void Publish <T>(T data, ProcessType processType = ProcessType.Topic)
        {
            var type = data.GetType().AssemblyQualifiedName;

            RedisServices.HashSet(_keyListChannelName, new KeyValuePair <string, string>(type, processType.ToString()));

            string queueDataName = GetKeyQueueDataForChannel(type);

            RedisServices.TryEnqueue(queueDataName, JsonConvert.SerializeObject(data));
        }
        private void GetSelectedStrategyAndSymbol(Dictionary<string, List<string>> selectedStrategyAndSymbol, ProcessType _processType)
        {
            App.AppManager.DataMgr.ClearProcessSelectionIndication();
            if (fltdg.SelectedItems != null)
            {
                for (int i = 0; i < fltdg.SelectedItems.Count; i++)
                {
                    StrategyOrderInfo orderInfo = fltdg.SelectedItems[i] as StrategyOrderInfo;
                    if (orderInfo != null)
                    {
                        if (_processType == ProcessType.BUY
                            || _processType == ProcessType.SELL
                            || _processType == ProcessType.BOTH)
                        {
                            if (orderInfo.Status.Equals("Trading"))
                            {
                                if (_processType.ToString().ToLower().Equals(orderInfo.TradingMode.ToLower()))
                                {
                                    orderInfo.IsAlreadyHadSameProcess = true;
                                    //Avoid re-setting the symbol with same trading-mode as before
                                    continue;
                                }

                                orderInfo.InProcess = true;
                                if (!selectedStrategyAndSymbol.ContainsKey(orderInfo.StrategyId))
                                {
                                    selectedStrategyAndSymbol[orderInfo.StrategyId] = new List<string>();
                                }
                                selectedStrategyAndSymbol[orderInfo.StrategyId].Add(orderInfo.Symbol);
                            }
                        }
                        else if (_processType == ProcessType.UNLOCK)
                        {
                            if (orderInfo.Status.Equals("Locked"))
                            {
                                orderInfo.InProcess = true;
                                if (!selectedStrategyAndSymbol.ContainsKey(orderInfo.StrategyId))
                                {
                                    selectedStrategyAndSymbol[orderInfo.StrategyId] = new List<string>();
                                }
                                selectedStrategyAndSymbol[orderInfo.StrategyId].Add(orderInfo.Symbol);
                            }
                        }
                        else if (_processType == ProcessType.START)
                        {
                            if (!orderInfo.Status.Equals("Trading") && !orderInfo.Status.Equals("Locked"))
                            {
                                orderInfo.InProcess = true;
                                if (!selectedStrategyAndSymbol.ContainsKey(orderInfo.StrategyId))
                                {
                                    selectedStrategyAndSymbol[orderInfo.StrategyId] = new List<string>();
                                }
                                selectedStrategyAndSymbol[orderInfo.StrategyId].Add(orderInfo.Symbol);
                            }
                        }
                        else if (_processType == ProcessType.STOP)
                        {
                            if (!orderInfo.Status.Equals("Stopped") && !orderInfo.Status.Equals("Locked"))
                            {
                                orderInfo.InProcess = true;
                                if (!selectedStrategyAndSymbol.ContainsKey(orderInfo.StrategyId))
                                {
                                    selectedStrategyAndSymbol[orderInfo.StrategyId] = new List<string>();
                                }
                                selectedStrategyAndSymbol[orderInfo.StrategyId].Add(orderInfo.Symbol);
                            }
                        }
                        else if (orderInfo.Status.Equals("Locked"))
                        {
                            orderInfo.InProcess = true;
                            if (!selectedStrategyAndSymbol.ContainsKey(orderInfo.StrategyId))
                            {
                                selectedStrategyAndSymbol[orderInfo.StrategyId] = new List<string>();
                            }
                            selectedStrategyAndSymbol[orderInfo.StrategyId].Add(orderInfo.Symbol);
                        }
                        else
                        {
                            orderInfo.InProcess = true;
                            if (!selectedStrategyAndSymbol.ContainsKey(orderInfo.StrategyId))
                            {
                                selectedStrategyAndSymbol[orderInfo.StrategyId] = new List<string>();
                            }
                            selectedStrategyAndSymbol[orderInfo.StrategyId].Add(orderInfo.Symbol);
                        }
                    }
                }
            }
        }
        public void ProcessUpdatePriceUrl(Portal portal, PostalCode postalCode, PropertyType propertyType, List <UrlType> urlTypes, ProcessPostalCode processPostalCode, ProxyIp proxyIp, ProcessType processType)
        {
            var _appContext = new PropertyCrawler.Data.AppContext(true);

            var type    = propertyType == PropertyType.Sell ? "SALE" : "RENT";
            var urlType = propertyType == PropertyType.Sell ? "/property-for-sale" : "/property-to-rent";

            var currentUrls             = _appContext.Urls.Where(x => x.Type == (int)propertyType && x.PostalCodeId == postalCode.Id).ToList();
            var currentUrlIds           = currentUrls.Select(x => x.Id).OrderBy(x => x).ToList();
            var currentUrlPropertyCodes = currentUrls.Select(x => x.PropertyCode).OrderBy(x => x).ToList();
            var currentProperties       = _appContext.Properties.Where(x => x.UrlId.HasValue && currentUrlIds.Contains(x.UrlId.Value)).ToList();

            var proxy = new WebProxy()
            {
                Address               = String.IsNullOrWhiteSpace(proxyIp.Port) ? new Uri($"http://{proxyIp.Ip}"): new Uri($"http://{proxyIp.Ip}:{proxyIp.Port}"),
                BypassProxyOnLocal    = false,
                UseDefaultCredentials = false,

                // *** These creds are given to the proxy server, not the web server ***
                Credentials = new NetworkCredential(
                    userName: proxyIp.Username,
                    password: proxyIp.Password)
            };

            // Now create a client handler which uses that proxy

            var httpClientHandler = new HttpClientHandler()
            {
                Proxy = proxy,
            };

// Omit this part if you don't need to authenticate with the web server:
            //if (needServerAuthentication)
            //{
            //    httpClientHandler.PreAuthenticate = true;
            //    httpClientHandler.UseDefaultCredentials = false;

            //    // *** These creds are given to the web server, not the proxy server ***
            //    httpClientHandler.Credentials = new NetworkCredential(
            //        userName: serverUserName,
            //        password: serverPassword);
            // }


            //try
            //{
            using (var client = new HttpClient(handler: httpClientHandler, disposeHandler: true))
            {
                client.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
                client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36");
                client.DefaultRequestHeaders.Add("Accept-Language", "en-US,en;q=0.9,it;q=0.8,sq;q=0.7");
                var page        = 0;
                var queryString = $"/find.html?locationIdentifier={portal.OutCodeKey + postalCode.OutCode}&sortType=10&propertyTypes=&includeLetAgreed=false&mustHave=&dontShow=&furnishTypes=&keywords=";

                if (processType.ToString() == "LastWeek")
                {
                    queryString += "&maxDaysSinceAdded=7";
                }
                else if (processType.ToString() == "LastTwoWeeks")
                {
                    queryString += "&maxDaysSinceAdded=14";
                }

                var          pagesHtml     = client.GetStringAsync(portal.Url + urlType + queryString).Result;
                HtmlDocument pagesDocument = new HtmlDocument();
                pagesDocument.LoadHtml(pagesHtml);

                var allUrlCrawlerModels = new List <UrlCrawlerModel>();

                //a// class// propertyCard-priceLink
                var listOfUrlProperties = new PropertyUrlDetails();

                var jsonString = pagesDocument.DocumentNode.InnerHtml.Split("<script>window.jsonModel = ")[1].Split("}</script><script>")[0] + "}";

                var jsonObj = JsonConvert.DeserializeObject <PropertyUrlDetails>(jsonString);
                listOfUrlProperties.properties.AddRange(jsonObj.properties);

                var totalcount = int.Parse(pagesDocument.DocumentNode.SelectSingleNode(".//span[@class=\"searchHeader-resultCount\"]").InnerText.Replace(",", ""));

                var pages = (totalcount / 24) + ((totalcount % 24) == 0 ? 0 : 1);

                for (int i = 1; i < pages; i++)
                {
                    try
                    {
                        queryString = $"/find.html?locationIdentifier={portal.OutCodeKey + postalCode.OutCode}&sortType=10&index={24 * i}&propertyTypes=&includeLetAgreed=false&mustHave=&dontShow=&furnishTypes=&keywords=";

                        pagesHtml     = client.GetStringAsync(portal.Url + urlType + queryString).Result;
                        pagesDocument = new HtmlDocument();
                        pagesDocument.LoadHtml(pagesHtml);

                        jsonString = pagesDocument.DocumentNode.InnerHtml.Split("<script>window.jsonModel = ")[1].Split("}</script><script>")[0] + "}";

                        jsonObj = JsonConvert.DeserializeObject <PropertyUrlDetails>(jsonString);

                        listOfUrlProperties.properties.AddRange(jsonObj.properties);
                    }
                    catch (Exception ex)
                    {
                        break;
                    }
                }

                foreach (var prop in listOfUrlProperties.properties)
                {
                    var urlCrawlerModel = new UrlCrawlerModel
                    {
                        Price          = prop.price.amount,
                        PriceQualifier = prop.price.displayPrices[0].displayPriceQualifier,
                        PropertyCode   = prop.id,
                        UrlTypeId      = urlTypes.FirstOrDefault(a => prop.propertyUrl.Trim().Contains(a.UrlPortion))?.Id ?? null
                    };
                    allUrlCrawlerModels.Add(urlCrawlerModel);
                }
                allUrlCrawlerModels = allUrlCrawlerModels.Distinct().ToList();
                var pricePropertyList = new List <PropertyPrice>();



                //Find urls that don't exist any more at page

                //Update list with property codes
                var propertyCodesList = allUrlCrawlerModels.Select(x => x.PropertyCode).OrderBy(x => x).ToList();

                //Property Urls that already exist into database
                var currentExistentUrls   = currentUrls.Where(x => x.Active && propertyCodesList.Contains(x.PropertyCode)).ToList();
                var currentExistenturlsId = currentExistentUrls.Select(x => x.Id);

                var toBeLogicalDeleteIds = currentUrlIds.Except(currentExistenturlsId);

                //From current property url list  get what does not exist any more and updated into active false

                var toBeLogicDeletedUrls = currentUrls.Where(x => toBeLogicalDeleteIds.Contains(x.Id));   ///currentUrls.Except(currentExistentUrls).ToList();



                //logic delete base on propertycodes into Url and Properties table
                var dateNow = DateTime.UtcNow;
                foreach (var url in toBeLogicDeletedUrls)
                {
                    var urlToBeUpdated = url;
                    urlToBeUpdated.Active       = false;
                    urlToBeUpdated.DateModified = dateNow;
                    var propertyToBeUpdated = currentProperties.FirstOrDefault(x => x.UrlId.HasValue && x.UrlId == url.Id);
                    if (propertyToBeUpdated != null)
                    {
                        propertyToBeUpdated.DateModified = dateNow;
                        propertyToBeUpdated.Active       = false;
                        _appContext.Properties.Update(propertyToBeUpdated);
                    }
                    _appContext.Urls.Update(urlToBeUpdated);
                }

                _appContext.SaveChanges();
                //Existent



                foreach (var item in allUrlCrawlerModels)
                {
                    var existUrl = currentUrls.FirstOrDefault(x => x.PropertyCode == item.PropertyCode);
                    PropertyCrawler.Data.Property existProperty = null;
                    if (existUrl != null)
                    {
                        existProperty = currentProperties.FirstOrDefault(x => x.UrlId == existUrl.Id);
                    }

                    //Properties does not exists
                    //Insert into Url Table, Start the process Properties
                    if (existUrl == null)
                    {
                        var insertUrl = new Url
                        {
                            PropertyCode = item.PropertyCode,
                            Type         = (int)propertyType,
                            PortalId     = portal.Id,
                            DateModified = DateTime.Now,
                            DateAdded    = DateTime.Now,
                            Active       = true,
                            PostalCodeId = postalCode.Id,
                            UrlTypeId    = item.UrlTypeId
                        };
                        if (existProperty != null)
                        {
                            var property = existProperty;
                            property.Price = item.Price;
                            _appContext.Properties.Update(property);
                        }

                        _appContext.Urls.Add(insertUrl);
                        _appContext.SaveChanges();

                        if (existProperty == null)
                        {
                            ProcessProperty(portal, insertUrl, urlTypes.FirstOrDefault(x => x.Id == item.UrlTypeId), processPostalCode, proxyIp);
                        }
                    }
                    //else if (existUrlProperty.prop == null)
                    //{
                    //    ProcessProperty(portal, existUrlProperty.url, urlTypes.FirstOrDefault(x => x.Id == item.UrlTypeId), processPostalCode);
                    //}
                    //Property exist
                    //insert into priceProperty table
                    //Update Properties last Price
                    else
                    {
                        if (existProperty == null)
                        {
                            if (existUrl != null)
                            {
                                var updUrl = existUrl;
                                updUrl.Active = true;
                                _appContext.Urls.Update(updUrl);
                                _appContext.SaveChanges();
                                ProcessProperty(portal, updUrl, urlTypes.FirstOrDefault(x => x.Id == item.UrlTypeId), processPostalCode, proxyIp);
                            }
                            else
                            {
                                var insertUrl = new Url
                                {
                                    PropertyCode = item.PropertyCode,
                                    Type         = (int)propertyType,
                                    PortalId     = portal.Id,
                                    DateModified = DateTime.Now,
                                    DateAdded    = DateTime.Now,
                                    Active       = true,
                                    PostalCodeId = postalCode.Id,
                                    UrlTypeId    = item.UrlTypeId
                                };
                                _appContext.Urls.Add(insertUrl);
                                _appContext.SaveChanges();
                                ProcessProperty(portal, insertUrl, urlTypes.FirstOrDefault(x => x.Id == item.UrlTypeId), processPostalCode, proxyIp);
                            }
                        }
                        else
                        {
                            var priceProperty = new PropertyPrice
                            {
                                PropertyId     = existProperty.Id,
                                Price          = item.Price,
                                PriceQualifier = item.PriceQualifier,
                                DateModified   = DateTime.Now,
                                DateAdded      = DateTime.Now,
                                Active         = true
                            };

                            var updUrl = existUrl;
                            updUrl.Active = true;
                            _appContext.Urls.Update(updUrl);

                            var property = existProperty;
                            property.Price        = item.Price;
                            property.Active       = true;
                            property.DateModified = DateTime.UtcNow;

                            _appContext.PropertyPrices.Add(priceProperty);
                            _appContext.Properties.Update(property);
                            _appContext.SaveChanges();
                            //pricePropertyList.Add(priceProperty);
                        }
                    }
                }
                // _appContext.SaveChanges();
            }

            //}
            //catch (Exception ex)
            //{

            //}
        }
Exemple #15
0
        /// <summary>
        /// vytvoření sql commandu pro daný typ procesu (ReceptionConfirmation, KittingConfirmation ...)
        /// </summary>
        /// <param name="processType"></param>
        /// <returns></returns>
        private string createSqlCommand(ProcessType processType)
        {
            switch (processType)
            {
            case ProcessType.ReceptionConfirmationProcess:
                return("[dbo].[prCMRCins] @par1, @ReturnValue OUT, @ReturnMessage OUT");

            case ProcessType.KittingConfirmationProcess:
                return("[dbo].[prCMRCKins] @par1, @ReturnValue OUT, @ReturnMessage OUT");

            case ProcessType.ShipmentConfirmationProcess:
                return("[dbo].[prKiSHCins] @par1, @ReturnValue OUT, @ReturnMessage OUT");

            case ProcessType.ReturnedEquipmentProcess:
                return("[dbo].[prCMReturn] @par1, @ReturnValue OUT, @ReturnMessage OUT");

            case ProcessType.ReturnedItemProcess:
                return("[dbo].[prCMReturnedItem] @par1, @ReturnValue OUT, @ReturnMessage OUT");

            case ProcessType.ReturnedShipmentProcess:
                return("[dbo].[prCMReturnedShipment] @par1, @ReturnValue OUT, @ReturnMessage OUT");

            case ProcessType.RefurbishedConfirmationProcess:
                return("[dbo].[prRORF1ins] @par1, @ReturnValue OUT, @ReturnMessage OUT");

            case ProcessType.DeleteMessageConfirmationProcess:
                return("[dbo].[prCMDeleteMessage] @par1, @ReturnValue OUT, @ReturnMessage OUT");

            case ProcessType.CrmOrderConfirmationProcess:
                return("[dbo].[prCrmOrderC1ins]  @par1, @ReturnValue OUT, @ReturnMessage OUT");

            case ProcessType.CrmOrderApprovalProcess:
                return("[dbo].[prCrmOrderC2ins]  @par1, @ReturnValue OUT, @ReturnMessage OUT");

            default:
                throw new Exception(String.Format("Použit nepovolený process type [{0}]", processType.ToString()));
            }
        }