Пример #1
0
        public Shell(IEventAggregator eventAggregator, IModuleManager moduleManager)
        {
            InitializeComponent();

            this.receive_Aggregator = eventAggregator;
            this.send_Aggregator    = eventAggregator;

            this.moduleManager = moduleManager;

            //定义消息结构
            receiveMsgOrder = new ReceiveMsgOrder();
            //获取服务器端参数
            configModel = ConfigAccess.GetConfig();
            //获取客户端版本信息
            versionModel = VersionAccess.GetConfig();
            //获取连接信息类的单例
            connectParam = ConnectParam.GetInstance();
            //获取日志记录实例
            this.ilogger = ILogger.GetInstance();

            //订阅接收信息事件
            RequestEvent();

            //定义接收消息线程
            connectParam.ListenerMsgThread = new Thread(ListenerMsgThreadMethod);
            connectParam.ListenerMsgThread.IsBackground = true;

            //先建立连接及SSL通道,再发送
            ConnectToServer(MessageTypes.UPD + versionModel.AppVs + MessageTypes.NSP + versionModel.UpdateTime, //确认更新
                            configModel.LoginIP, int.Parse(configModel.LoginPort));
        }
Пример #2
0
        private void DeleteNodeJSFunction(Durados.DeleteEventArgs e)
        {
            NodeJS nodeJS = new NodeJS();

            string  ruleId   = e.PrimaryKey;
            DataRow ruleRow  = Map.GetConfigDatabase().Views[Rule].GetDataRow(ruleId);
            string  viewId   = ruleRow[Rules].ToString();
            string  viewName = null;

            if (viewId != null)
            {
                viewName = new ConfigAccess().GetViewNameByPK(viewId, Map.GetConfigDatabase().ConnectionString);

                if (string.IsNullOrEmpty(viewName))
                {
                    throw new Durados.DuradosException(string.Format(Messages.ViewNameNotFound, viewId));
                }
            }
            else
            {
                throw new Durados.DuradosException(string.Format(Messages.ViewNameNotFound, string.Empty));
            }

            string actionName   = ruleRow[Name].ToString();
            string functionName = Map.AppName + "_" + viewName + "_" + actionName;
            string folder       = Map.AppName + "/" + viewName + "/" + actionName;

            nodeJS.Delete(folder, functionName);
        }
Пример #3
0
        private string ObtieneLinkPago(int pIntIdWeb, int pIntIdPedido, int pIntIdCotSRV)
        {
            EncriptaCadena objNMEncriptaCadena = new EncriptaCadena();

            try
            {
                string strURLPago = "";
                if (pIntIdWeb == Webs_Cid.ID_WEB_NM_PERUTRIP)
                {
                    strURLPago = ConfigAccess.GetValueInAppSettings("URL_PAGO_SERVICIO_ONLINE_PERUTRIP");
                }
                else if (pIntIdWeb == Webs_Cid.DM_WEB_ID)
                {
                    strURLPago = ConfigAccess.GetValueInAppSettings("URL_PAGO_SERVICIO_ONLINE_DM");
                }
                else
                {
                    strURLPago = ConfigAccess.GetValueInAppSettings("URL_PAGO_SERVICIO_ONLINE");
                }

                string strIdEncrypt = objNMEncriptaCadena.DES_Encrypt(pIntIdPedido + ";" + pIntIdCotSRV, objNMEncriptaCadena.GetKEY(EncriptaCadena.TIPO_KEY.KEY_ENCRIPTA_NRO_PEDIDO_PAGO_ONLINE));

                return(strURLPago + "?id=" + strIdEncrypt);
            }
            catch (Exception ex)
            {
                return("Error");
            }
            finally
            {
                objNMEncriptaCadena = null;
            }
        }
Пример #4
0
        public static ConfigAccessor CreateConfig
            (string configFileName, string relativeDirPath, Encoding encoding, ConfigAccess access, string section)
        {
            var configPath = Path
                             .Combine(BaseDirectory, relativeDirPath, CONFIG_NAME_TEMPLATE.Format(configFileName as object));
            var config = _openedFiles.SingleOrDefault(c => c.FilePath == configPath);

            if (config == null)
            {
                FileStream configFile = IOUtils.TryCreateFileIfNotExistOrOpenOrNull(configPath);
                if (configFile == null)
                {
                    throw new Exception("Не удается получить доступ к файлу.");
                }
                else
                {
                    config = new ConfigStorageProxy(configFile);
                    _openedFiles.Add(config);
                }
            }
            var stream = config.GetNewStream(access, section);

            return(new ConfigAccessor(
                       new ConfigReaderWriter(stream, encoding, section),
                       new ConfigSourceInfo(true, configPath)));
        }
Пример #5
0
        public ActionResult Get(string name)
        {
            try
            {
                if (string.IsNullOrEmpty(name))
                {
                    return(new ViewNameWasNotSuppliedApiHttpException());
                }
                View view = GetView(name);
                if (view == null)
                {
                    return(new ViewNotFoundApiHttpException(name, Response));
                }

                ConfigAccess ConfigAccess = new ConfigAccess();
                var          pk           = ConfigAccess.GetViewPK(name, Map.GetConfigDatabase().ConnectionString);
                var          item         = RestHelper.Get(GetView("View"), pk, true, view_BeforeSelect, view_AfterSelect);

                Response.StatusCode = (int)HttpStatusCode.OK;

                return(Json(item, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                return(new UnexpectedApiHttpException(exception, Response));
            }
        }
Пример #6
0
        /// <summary>
        /// Set web master access for a specific view, and protect it by password
        /// </summary>
        /// <param name="viewPk"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public JsonResult SetWebMasterAccess(string viewPk, string password)
        {
            //Validate before set
            validateSetWebMasterAccess(password);

            //Get new user name
            DataRow userRow = Maps.Instance.DuradosMap.Database.GetUserRow();

            if (userRow == null)
            {
                throw new DuradosException("User not registered");
            }
            string userId         = Convert.ToString(userRow["ID"]);
            string userNameFormat = ConfigurationManager.AppSettings["MasterUserNameFormat"] ?? "master{0}@modubiz.com";
            string userName       = string.Format(userNameFormat, userId);

            //Create new master user
            bool existInUserAppTable         = isUserExistInUserAppTable(userName);
            bool existInUsersTable           = Maps.Instance.DuradosMap.Database.GetUserRow(userName) != null;
            bool existInCurrentAppUsersTable = Map.Database.GetUserRow(userName) != null;
            bool existInMembership           = MembershipService.ValidateUserExists(userName);

            CreateNewMasterUser(userName, password, !existInUsersTable, !existInMembership, !existInCurrentAppUsersTable, !existInUserAppTable);

            //Change web master access password if neccessary
            changeWebMasterPassword(existInMembership, existInUsersTable, userName, password);

            //Get WebMasterUrl;
            string viewName     = new ConfigAccess().GetViewNameByPK(viewPk, Map.GetConfigDatabase().ConnectionString);
            string WebMasterUrl = WixPlugInHelper.GetWebAccessUrl(Map.Url, viewName, userName);

            return(Json(WebMasterUrl));
        }
Пример #7
0
 private void SendToSalesforce(AgenciaPnr agenciaPnr, string token, string crmServer)
 {
     try
     {
         var agenciaPnrSf = ToSalesforceEntity(agenciaPnr);
         var responsePnr  = RestBase.ExecuteByKeyWithServer(crmServer, SalesforceKeys.PnrMethod, Method.POST, agenciaPnrSf, true, token);
         if (responsePnr.StatusCode.Equals(HttpStatusCode.OK))
         {
             dynamic jsonResponse = new JavaScriptSerializer().DeserializeObject(responsePnr.Content);
             try
             {
                 agenciaPnr.CodigoError   = jsonResponse[OutParameter.SF_CodigoError];
                 agenciaPnr.MensajeError  = jsonResponse[OutParameter.SF_MensajeError];
                 agenciaPnr.IdOportunidad = jsonResponse[OutParameter.SF_IdOportunidad];
                 agenciaPnr.LastMethod    = ConfigAccess.GetValueInAppSettings(SalesforceKeys.PnrMethod);
             }
             catch
             {
             }
         }
     }
     catch
     {
     }
 }
Пример #8
0
        private static bool IsAuthorizedUser(string authToken)
        {
            var token = ConfigAccess.GetValueInAppSettings(SecurityKeys.Token);

            // In this method we can handle our database logic here...
            return(authToken.Equals(token));
        }
Пример #9
0
        public static Dictionary <string, object> GetRuleAndAction(int actionId)
        {
            Map map = Maps.Instance.GetMap();

            ConfigAccess configAccess = new ConfigAccess();
            DataRow      row          = configAccess.GetRow("Rule", "ID", actionId.ToString(), map.GetConfigDatabase().ConnectionString);

            if (row == null)
            {
                throw new ActionNotFoundException(actionId);
            }
            int viewId = System.Convert.ToInt32(row["Rules"]);

            string name = row["Name"].ToString();

            View view = null;

            view = (View)map.Database.Views.Values.Where(v => v.ID == viewId).FirstOrDefault();
            if (view == null)
            {
                throw new ActionNotFoundException(actionId, viewId);
            }

            Rule rule = view.Rules[name];

            return(new Dictionary <string, object>()
            {
                { "view", view }, { "rule", rule }
            });
        }
Пример #10
0
        private void updateWindow_Loaded(object sender, RoutedEventArgs e)
        {
            viewModel.ConnectStatus = "获得服务器参数...";
            configModel             = ConfigAccess.GetConfig();

            viewModel.ConnectStatus = "连接服务器...";
            ConnectToServer(configModel.UpdateIP, configModel.UpdatePort);
        }
Пример #11
0
        /// <summary>
        /// Get details of current web master access settings- By check if master user is exists
        /// </summary>
        /// <param name="viewPk"></param>
        /// <returns></returns>
        public JsonResult GetWebMasterAccessDetails(string viewPk)
        {
            string          instance        = Request.QueryString["instance"];
            ConfigAccess    configAccess    = new ConfigAccess();
            string          viewName        = configAccess.GetViewNameByPK(viewPk, Map.GetConfigDatabase().ConnectionString);
            WebMasterAccess webMasterAccess = WixPlugInHelper.GetWebMasterAccessDetails(Map, instance, viewName);

            return(Json(webMasterAccess));
        }
Пример #12
0
        public Stream GetNewStream(ConfigAccess access, string section)
        {
            var stream = _streamAggregator.TryGetCreatedStream(section)
                         ?? _streamAggregator.CreateStream(section);
            {
                var thisSectionInfo = _sectionInfos.SingleOrDefault(si => si.Section.FullName == section);
                if (thisSectionInfo == null)
                {
                    _sectionInfos.Add(new SectionAccessInfo(new Section(section), false, false));
                }
            }
            var sectionInfos           = _sectionInfos.Where(si => si.Section.IsInsideSection(section));
            var readWriteStreamCreated = sectionInfos.Any(si => si.ReadWriteStreamCreated);
            var anyStreamCreated       = sectionInfos.Any(si => si.AnyStreamCreated);

            switch (access)
            {
            case ConfigAccess.READ_ONLY:
                if (readWriteStreamCreated)
                {
                    throw new InvalidOperationException("Не разрешается создавать поток с доступом на чтение, если поток с доступом на четение/запись уже был создан.");
                }
                else
                {
                    foreach (var si in sectionInfos)
                    {
                        si.AnyStreamCreated = true;
                    }
                    return(new StreamProxy(stream, false));
                }

            case ConfigAccess.READ_WRITE:
                if (readWriteStreamCreated)
                {
                    throw new InvalidOperationException("Поток с доступом на четение/запись уже был создан.");
                }
                else if (anyStreamCreated)
                {
                    throw new InvalidOperationException("Не разрешается создавать поток с доступом на четение/запись, если поток с любым уровнем доступа уже был создан.");
                }
                else
                {
                    foreach (var si in sectionInfos)
                    {
                        si.ReadWriteStreamCreated = true;
                        si.AnyStreamCreated       = true;
                    }
                    return(new StreamProxy(stream, true));
                }

            default:
                throw new NotSupportedException();
            }
        }
Пример #13
0
        public List <Country> CountryGetAllByRole(string user)
        {
            string cacheKey  = user + "Country";
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = dal.CountryGetAllByRole(user.Substring(user.LastIndexOf("\\") + 1));
                MarsV2Cache.AddObjectToCacheWithNoSlidingExpiry(cacheKey, cacheItem);
            }
            return(new List <Country>((List <Country>)cacheItem));
        }
Пример #14
0
        public List <CarGroup> CarGroupListGetByCountryID(string countryID)
        {
            string cacheKey  = "CarGroupAll_" + countryID;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = DAL.CarGroupListGetByCountryID(countryID);
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }
            return(new List <CarGroup>((List <CarGroup>)cacheItem));
        }
Пример #15
0
        public List <Country> CountryGetAll()
        {
            string cacheKey  = MarsV2Cache.CountryList;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = DAL.CountryGetAll();
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }
            return(new List <Country>((List <Country>)cacheItem));
        }
Пример #16
0
        public List <UserRole> UsersInRolesGet(string user)
        {
            string cacheKey  = user + "Roles";
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = dal.UsersInRolesGet(user.Substring(user.LastIndexOf("\\") + 1));
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }
            return(new List <UserRole>((List <UserRole>)cacheItem));
        }
Пример #17
0
        public static Operation GetToken()
        {
            try
            {
                var operation = new Operation();

                var serverName = ConfigAccess.GetValueInAppSettings(SalesforceKeys.AuthServer);
                var methodName = ConfigAccess.GetValueInAppSettings(SalesforceKeys.AuthMethod);
                var methodType = Method.POST;

                if (!int.TryParse(ConfigAccess.GetValueInAppSettings(SecurityKeys.AuthTimeoutKey), out int authTimeout))
                {
                    authTimeout = 0;
                }
                var client = new RestClient(serverName)
                {
                    Timeout = authTimeout
                };
                ServicePointManager.Expect100Continue      = true;
                ServicePointManager.DefaultConnectionLimit = 9999;
                ServicePointManager.SecurityProtocol       = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
                var request              = new RestRequest(methodName, methodType);
                var sf_authgranttype     = ConfigAccess.GetValueInAppSettings("AUTH_GRANT_TYPE");
                var sf_authclientid      = ConfigAccess.GetValueInAppSettings("AUTH_CLIENT_ID");
                var sf_auth_clientsecret = ConfigAccess.GetValueInAppSettings("AUTH_CLIENT_SECRET");
                var sf_authusername      = ConfigAccess.GetValueInAppSettings("AUTH_USERNAME");
                var sf_authpassword      = ConfigAccess.GetValueInAppSettings("AUTH_PASSWORD");

                request.AddParameter("grant_type", sf_authgranttype);
                request.AddParameter("client_id", sf_authclientid);
                request.AddParameter("client_secret", sf_auth_clientsecret);
                request.AddParameter("username", sf_authusername);
                request.AddParameter("password", sf_authpassword);

                var response = client.Execute(request);
                if (response.StatusCode != HttpStatusCode.OK && response.ErrorMessage != null)
                {
                    throw new Exception(response.ErrorMessage);
                }

                var content = response.Content;
                JsonManager.LoadText(content);                                               // Obtiene el json de response

                operation[OutParameter.SF_Token]   = JsonManager.GetSetting("access_token"); // Obtiene el Token
                operation[OutParameter.SF_UrlAuth] = JsonManager.GetSetting("instance_url"); // Obtiene el URL de la API de Salesforce

                return(operation);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #18
0
        public DownView(DownViewModel _downViewModel, IEventAggregator addgame_Aggregator)
        {
            InitializeComponent();

            this.DataContext        = _downViewModel;
            this.addgame_Aggregator = addgame_Aggregator;

            configModel   = ConfigAccess.GetConfig();
            downViewModel = _downViewModel;

            DeleteTemp();
        }
Пример #19
0
        internal static List <BranchHolder> GetAllBranches()
        {
            var cacheKey  = MarsV2Cache.MarsBranchList;
            var cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = ParameterDataAccess.GetAllBranches();
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <BranchHolder>)cacheItem);
        }
Пример #20
0
        /// <summary>
        /// Retrieves the List of Location Groups either from the Cache or Database
        /// </summary>
        /// <returns>Location Pool Ids and Names</returns>
        internal static List <LocationGroupHolder> GetAllLocationGroups()
        {
            var cacheKey  = MarsV2Cache.MarsLocationGroupList;
            var cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = ParameterDataAccess.GetAllLocationPools();
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <LocationGroupHolder>)cacheItem);
        }
Пример #21
0
        public List <CMSFleetPlan> CMSFleetPlanGetAll(bool hideScenarios)
        {
            string cacheKey  = hideScenarios ? MarsV2Cache.CMSFrozenZoneFleetPlanList : MarsV2Cache.CMSFleetPlanList;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = _dal.CMSFleetPlanGetAll(hideScenarios);
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <CMSFleetPlan>)cacheItem);
        }
Пример #22
0
        public List <CMSForecastType> CMSForecastTypeGetAll(bool frozenZoneSelected)
        {
            string cacheKey  = frozenZoneSelected ? MarsV2Cache.CMSForecastTypeWithAlreadyBooked : MarsV2Cache.CMSForecastTypeWithoutAlreadyBooked;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = _dal.CMSForecastTypeGetAll(frozenZoneSelected);
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <CMSForecastType>)cacheItem);
        }
Пример #23
0
        private void SendToSalesforce(Boleto boleto, string token, string crmServer)
        {
            var boletoSf       = ToSalesforceEntity(boleto);
            var responseBoleto = RestBase.ExecuteByKeyWithServer(crmServer, SalesforceKeys.BoletoMethod, Method.POST, boletoSf, true, token);

            if (responseBoleto.StatusCode.Equals(HttpStatusCode.OK))
            {
                JsonManager.LoadText(responseBoleto.Content);
                boleto.CodigoError  = JsonManager.GetSetting(OutParameter.SF_CodigoError);
                boleto.MensajeError = JsonManager.GetSetting(OutParameter.SF_MensajeError);
                boleto.LastMethod   = ConfigAccess.GetValueInAppSettings(SalesforceKeys.BoletoMethod);
            }
        }
Пример #24
0
        public List <CMSReportingTimeZone> CMSReportingTimeZoneGetAll()
        {
            string cacheKey  = MarsV2Cache.CMSReportingTimeZone;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = _dal.CMSReportingTimeZoneGetAll();
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <CMSReportingTimeZone>)cacheItem);
        }
Пример #25
0
        public object Search(ConfigAccess config, string q, int?id, int snippetLength, bool spaceAsWildcard, string highlightTag, int tabChars)
        {
            string whereStatement = GetWhereStatement(q.Replace("'", "''"), id, spaceAsWildcard);

            DataView dataView = config.GetRows(ViewName, whereStatement, Maps.Instance.GetMap().GetConfigDatabase().ConnectionString);

            if (dataView.Count == 0)
            {
                return(null);
            }

            return(GetResults(dataView, q, snippetLength, highlightTag, tabChars));
        }
Пример #26
0
        public static IRestResponse ExecuteByKeyWithServer(string serverName, string methodNameKey, Method methodType = Method.POST, object body = null, bool isAuth = false, string token = "")
        {
            var methodName = ConfigAccess.GetValueInAppSettings(methodNameKey);

            return(Execute(
                       serverName,
                       methodName,
                       methodType,
                       body,
                       isAuth,
                       token,
                       int.Parse(ConfigAccess.GetValueInAppSettings(SecurityKeys.CrmTimeoutKey))));
        }
Пример #27
0
        internal static List <string> GetAllLicencePlates()
        {
            var cacheKey  = MarsV2Cache.LicencePlate;
            var cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                using (var dataAccess = new MarsDBDataContext())
                {
                    cacheItem = NonRevParameterDataAccess.GetLicecePlates(dataAccess);
                }
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <string>)cacheItem);
        }
Пример #28
0
 private void SendToSalesforce(File file, string token, string crmServer)
 {
     try
     {
         var fileSf       = ToSalesforceEntity(file);
         var responseFile = RestBase.ExecuteByKeyWithServer(crmServer, SalesforceKeys.FileMethod, Method.POST, fileSf, true, token);
         if (responseFile.StatusCode.Equals(HttpStatusCode.OK))
         {
             dynamic jsonResponse = new JavaScriptSerializer().DeserializeObject(responseFile.Content);
             file.CodigoError  = jsonResponse[OutParameter.SF_CodigoError];
             file.MensajeError = jsonResponse[OutParameter.SF_MensajeError];
             file.LastMethod   = ConfigAccess.GetValueInAppSettings(SalesforceKeys.FileMethod);
         }
     }
     catch
     {
     }
 }
Пример #29
0
        /// <summary>
        /// Url 地址重写
        /// </summary>
        public void UrlRewrite_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context     = ((HttpApplication)sender).Context;
            string      requestPath = context.Request.Path.ToLower();

            string appPath = ConfigAccess <AppConfigInfo> .GetConfig().AppPath;

            if (requestPath.StartsWith(appPath))
            {
                requestPath = requestPath.Substring(appPath.Length);
                if (requestPath.IndexOf("/") == -1) //访问路径在网站根目录下
                {
                    return;
                }
                else
                {
                    if (requestPath.StartsWith("admin/") || requestPath.StartsWith("user/"))
                    {
                        return;
                    }
                    if (requestPath.EndsWith("index.aspx") || requestPath.EndsWith("/"))
                    {
                        string query = requestPath.Substring(0, requestPath.IndexOf("/"));
                        context.RewritePath(appPath + "index.aspx?city=" + query);
                        return;
                    }
                    else
                    {
                        UrlRewriteInfo urls = ConfigAccess <UrlRewriteInfo> .GetConfig();

                        foreach (UrlRewrite url in urls.UrlRewrite)
                        {
                            if (Regex.IsMatch(requestPath, url.Pattern, RegexOptions.None))
                            {
                                string query = Regex.Replace(requestPath, url.Pattern, url.QueryString, RegexOptions.None);

                                context.RewritePath(appPath + url.Page, string.Empty, string.Concat(query, "&", context.Request.QueryString));
                                return;
                            }
                        }
                    }
                }
            }
        }
Пример #30
0
        private void CreateNodeJSFunction(Durados.CreateEventArgs e)
        {
            NodeJS nodeJS = new NodeJS();

            string fileName = null;

            if (e.Values.ContainsKey(FileName))
            {
                fileName = e.Values[FileName].ToString();
            }

            string viewId = null;

            if (e.Values.ContainsKey("Rules_Parent"))
            {
                viewId = e.Values["Rules_Parent"].ToString();
            }
            string viewName = null;

            if (viewId != null)
            {
                viewName = new ConfigAccess().GetViewNameByPK(viewId, Map.GetConfigDatabase().ConnectionString);

                if (string.IsNullOrEmpty(viewName))
                {
                    throw new Durados.DuradosException(string.Format(Messages.ViewNameNotFound, viewId));
                }
            }

            string actionName = e.Values[Name].ToString();


            string cloudProvider = GetCloudVendor(e.Values);

            if (fileName == null)
            {
                fileName = actionName + ".zip";
            }
            string functionName = Map.AppName + "_" + viewName + "_" + actionName;
            string folder       = Map.AppName + "/" + viewName + "/" + actionName;

            nodeJS.Create(Maps.NodeJSBucket, folder, fileName, functionName, "handler", "handler", cloudProvider);
        }
Пример #31
0
        /// <summary>
        /// フォルダスキャン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Timer_Tick(object sender, EventArgs e)
        {
            try {
                if (Chat == null)
                    throw new NullReferenceException("スキャン先のパスが未指定です。");
                if (SelectedPatch == null) return;

                DirectoryInfo saveDir = new DirectoryInfo(Chat.FullName + "\\Save");
                if (!saveDir.Exists)
                    saveDir.Create();

                ConfigAccess config = new ConfigAccess();

                foreach (var file in Chat.EnumerateFiles().OrderBy(a => a.CreationTime)) {
                    var line = File.ReadAllLines(file.FullName, enc).LastOrDefault(a => new Regex("特別経験値").IsMatch(a));
                    if (line == null) continue;

                    var exp = Convert.ToInt32(new Regex("[0-9]+").Match(line).Value);
                    var unit = SelectedPatch.Units.FirstOrDefault(a => a.MExp == exp);
                    if (unit == null) continue;

                    var mob = SelectedPatch.Maps.SelectMany(a => a.Mobs).Where(
                        a => a.Id == unit.Id).OrderBy(a => a.Delay).FirstOrDefault();

                    // 次回時間設定
                    if (mob != null) {
                        var next = file.CreationTime.AddMinutes(mob.Delay * Properties.Settings.Default.RepopRate);
                        var random = next.AddMinutes(mob.Random * Properties.Settings.Default.RepopRate);

                        unit.Repop = (next == random)
                            ? next.ToString("HH:mm") : next.ToString("HH:mm") + "~" + random.ToString("HH:mm");
                    }

                    // カウンタ更新
                    if (config.Exists(unit.Id)) {
                        config.Increment(unit.Id);
                    } else {
                        config.Insert(unit.Id);
                    }

                    file.MoveTo(saveDir.FullName + "\\" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "-" + file.Name);
                }

                // カウンタ再読込
                foreach (var counter in config.KillCounters) {
                    var unit = SelectedPatch.Units.FirstOrDefault(a => a.Id == counter.Id);
                    if (unit != null)
                        unit.Kill = counter.Count;
                }

                MessageBar.Show(MessageType.Info, "Scan : " + DateTime.Now.ToString("HH:mm:ss"));
            } catch (Exception ex) {
                MessageBar.Show(MessageType.Error, ex.Message);
            }
        }