protected override object CreateModel(
            ControllerContext controllerContext,
            ModelBindingContext bindingContext,
            Type modelType)
        {
            ValueProviderResult result;

            result = bindingContext.ValueProvider.GetValue("RouteUrl");
            if (result == null)
            {
                throw new NotImplementedException("RouteUrl must be specified");
            }

            foreach (Type item in RP.GetPageTypesReprository())
            {
                if (result.AttemptedValue == SF.GetTypeRouteUrl(item))
                {
                    var model = Activator.CreateInstance(item);
                    bindingContext.ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, item);
                    return(model);
                }
            }

            throw new NotImplementedException("RouteUrl must be specified");
        }
        public ActionResult Index(string lang, string group)
        {
            ViewBag.MessageRed    = TempData["MessageRed"];
            ViewBag.MessageYellow = TempData["MessageYellow"];
            ViewBag.MessageGreen  = TempData["MessageGreen"];

            if (string.IsNullOrEmpty(lang))
            {
                lang = SF.GetLangCodeThreading();
            }
            ViewBag.Lang = lang;

            if (string.IsNullOrEmpty(group))
            {
                group = SF.GetFirstMenuGroup();
            }
            ViewBag.Group = group;

            var menuItems = _db.Menus.Where(x => x.Group == group && x.LangCode == lang).OrderBy(x => x.DisplayOrder).AsNoTracking().ToList();
            var model     = menuItems.Where(x => x.ParentID == 0).ToList();

            model.ForEach(x =>
            {
                x.Childrens = GetChildrens(x.ID, menuItems);//.Where(m => m.ParentID == x.ID).ToList();
            });
            return(View(model));
        }
        public IEnumerable <StatementSyntax> GetInitialization()
        {
            var inputEnumeratorType = _ienumerator.CreateGenericSyntax(_inputType);

            yield return(SH.LocalDeclaration(inputEnumeratorType, enumerator,
                                             SF.IdentifierName(inputParameter).Dot("GetEnumerator").Invoke()));
        }
        public override string GetUserNameByEmail(string email)
        {
            User user;

            if (SF.UseCurrentUserByEmail(email))
            {
                user = LS.CurrentUser;
            }
            else
            {
                user = _db.Users.FirstOrDefault(r => r.ApplicationName == applicationName && r.Email == email);
            }

            if (!SF.UseCurrentUserByEmail(email) && user != null)
            {
                _db.Entry(user).State = EntityState.Detached;
            }

            if (user == null)
            {
                return(string.Empty);
            }
            else
            {
                return(user.UserName);
            }
        }
        public override MembershipUser GetUser(string UserName, bool userIsOnline)
        {
            MembershipUser membershipUser = null;

            User user;

            if (SF.UseCurrentUserByUserName(UserName))
            {
                user = LS.CurrentUser;
            }
            else
            {
                user = _db.Users.FirstOrDefault(r => r.ApplicationName == applicationName && r.UserName == UserName);
            }

            if (user == null)
            {
                return(null);
            }
            membershipUser = GetMembershipUserFromPersitentObject(user);

            if (userIsOnline)
            {
                user.LastActivityDate = DateTime.Now;
                _db.SaveChanges();
            }

            if (!SF.UseCurrentUserByUserName(UserName) && user != null)
            {
                _db.Entry(user).State = EntityState.Detached;
            }

            return(membershipUser);
        }
示例#6
0
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //Set all deimal percision to normal uses (EF bug or )
            #region decimal fix
            foreach (var contextProperty in typeof(Db).GetProperties())
            {
                if (contextProperty.PropertyType.IsGenericType &&
                    contextProperty.PropertyType.GetGenericTypeDefinition() == typeof(DbSet <>))
                {
                    var entityType = contextProperty.PropertyType.GenericTypeArguments[0];

                    foreach (var decimalProperty in entityType.GetProperties().Where(p => p.PropertyType == typeof(decimal)))
                    {
                        var configurePropertyMethod =
                            GetType()
                            .GetMethod("ConfigureProperty", BindingFlags.Static | BindingFlags.NonPublic)
                            .MakeGenericMethod(entityType);
                        configurePropertyMethod.Invoke(null, new object[] { modelBuilder, decimalProperty });
                    }
                }
            }
            #endregion
            //register plugin models
            if (SF.UsePlugins())
            {
                //var entityMethod = typeof(DbModelBuilder).GetMethod("Entity");
                //foreach (var type in RP.GetPlugingsEntityModels())
                //{
                //    entityMethod.MakeGenericMethod(type)
                //        .Invoke(modelBuilder, new object[] { });
                //}
            }
            base.OnModelCreating(modelBuilder);
        }
        public ActionResult Edit(int ID, Settings item, List <string> Roles)
        {
            if (ModelState.IsValid)
            {
                List <string> DomainRoles = SF.GetRoleObjectsList().Where(r => r.IsSystem == true).Select(r => r.Title).ToList();
                if (Roles != null)
                {
                    DomainRoles.AddRange(Roles);
                }
                item.Roles = SF.RolesListToString(DomainRoles);

                _db.Entry(item).State = EntityState.Modified;
                _db.SaveChanges();

                //update lang name of pages
                AbstractPage ap = _db.AbstractPages.FirstOrDefault(r => r.ID == item.DomainPageID);
                SF.SetLanguageCode(ap, 100, item.LanguageCode);

                CleanCache.CleanOutputCache();
                CleanCache.CleanSettingsCache();
                CleanCache.CleanMenuCache();

                return(RedirectToAction("Index"));
            }
            item.Roles = SF.RolesListToString(Roles);
            return(View(item));
        }
示例#8
0
 public static void Match()
 {
     if (Client.Instance.isConnect && Client.Instance.pl_info.isLogin)
     {
         Client.Instance.Send(SF.GetProtocolHead(ProtoName.Match));
     }
 }
示例#9
0
        private void BeginCountCurrentCacheSize()
        {
            Task.Factory.StartNew(async() =>
            {
                IReadOnlyList <StorageFile> cacheFiles;
                try
                {
                    var storageFolder = await SF.GetFolderAsync(CacheDirectory);
                    cacheFiles        = await storageFolder.GetFilesAsync();
                }
                catch (Exception)
                {
                    return;
                }

                long cacheSizeInBytes = 0;

                foreach (var cacheFile in cacheFiles)
                {
                    var properties        = await cacheFile.GetBasicPropertiesAsync();
                    var fullCacheFilePath = cacheFile.Name;
                    try
                    {
                        cacheSizeInBytes += (long)properties.Size;
                        _lastAccessTimeDictionary.Add(fullCacheFilePath, properties.DateModified.DateTime.Milliseconds());
                    }
                    catch
                    {
                        ImageLog.Log("[error] can not get cache's file size: " + fullCacheFilePath);
                    }
                }
                CurrentCacheSizeInBytes += cacheSizeInBytes; // Updating current cache size
            });
        }
示例#10
0
 public static ClassDeclarationSyntax AddField(ClassDeclarationSyntax classDeclaration, string type, string name)
 {
     return(classDeclaration.AddMembers(
                SF.FieldDeclaration(SF.VariableDeclaration(SF.ParseTypeName(type),
                                                           SF.SeparatedList(new[] { SF.VariableDeclarator(SF.Identifier(name)) })))
                .AddModifiers(SF.Token(SyntaxKind.PrivateKeyword))));
 }
示例#11
0
 public static ParameterSyntax Parameter(TypeSyntax type, SyntaxToken identifier) =>
 SF.Parameter(
     EmptyAttributeList(),
     EmptyModifierList(),
     type,
     identifier,
     default(EqualsValueClauseSyntax));
示例#12
0
        private static async Task <Document> MakeMultiline(
            Document document,
            ArgumentListSyntax argumentList,
            CancellationToken cancellationToken)
        {
            var arguments = argumentList.Arguments.ToList();

            if (arguments.Count == 0)
            {
                return(document);
            }

            var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);

            if (tree == default)
            {
                return(document);
            }

            var currentIndent = argumentList.EstimateIndent(tree, cancellationToken);
            var indent        = currentIndent + Settings.IndentOneLevel;

            return(await RewriteArgumentList(
                       document,
                       argumentList,
                       Settings.EndOfLine,
                       Settings.EndOfLine,
                       SF.Whitespace(indent),
                       cancellationToken));
        }
示例#13
0
        public async Task<ISfResponse> RequestAsync(string sessionId, SF action, IEnumerable<string> args = null)
        {
            var uriWrapper = new SnFUriWrapper(sessionId, _serverUri, action, args);

            Log.Info("SID:    {0}", uriWrapper.SessionId);
            Log.Info("Action: {0}", uriWrapper.Action);
            Log.Info("Args:   {0}", uriWrapper.Args ?? "null");
            Log.Info("URL:    {0}", uriWrapper.RequestUri.AbsoluteUri);

            WebRequest webRequest = CreateWebRequest(uriWrapper);
            try
            {
                using (WebResponse response = await webRequest.GetResponseAsync())
                using (Stream stream = response.GetResponseStream())
                {
                    if (stream == null) throw new NotImplementedException();
                    using (var reader = new StreamReader(stream))
                        return new SfResponse(reader.ReadToEnd(), _serverUri);
                }
            }
            catch (WebException)
            {
                throw new NotImplementedException("Network connection lost.");
            }
        }
示例#14
0
 protected void Session_Start(object sender, EventArgs e)
 {
     if (Request.UrlReferrer != null)
     {
         SF.SetCookie("Referal", Request.UrlReferrer.ToString());
     }
 }
示例#15
0
        public void NoVoidTypeOfExpressionsInGeneratedCodeEver()
        {
            var dir     = new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, "Schemas"));
            var allXsds = dir.GetFiles("*.xsd", SearchOption.AllDirectories)
                          // Microsoft.Build schemas will have typeof(void) expressions due to the existence of bugs that predate this .net core port
                          .Where(f => !f.FullName.Contains("Microsoft.Build."))
                          .Select(f => f.FullName).ToArray();

            var allProcessableXsds = FileSystemUtilities.ResolvePossibleFileAndFolderPathsToProcessableSchemas(allXsds)
                                     .Select(fp => new FileInfo(fp));

            foreach (var xsd in allProcessableXsds)
            {
                var generatedCodeTree = Utilities.GenerateSyntaxTree(xsd);

                var root = generatedCodeTree.GetRoot();

                var allDescendents    = root.DescendantNodes().SelectMany(d => d.DescendantNodes());
                var allStatements     = allDescendents.OfType <StatementSyntax>();
                var allExpressions    = allStatements.SelectMany(s => s.DescendantNodes()).OfType <ExpressionSyntax>();
                var typeOfExpressions = allExpressions.OfType <TypeOfExpressionSyntax>().Distinct().ToArray();

                Assert.IsNotEmpty(typeOfExpressions);

                var typeOfVoid = SF.ParseExpression("typeof(void)");
                var nonVoidTypeOfExpressions = typeOfExpressions.Where(toe => !toe.IsEquivalentTo(typeOfVoid)).ToArray();
                var voidTypeOfExpressions    = typeOfExpressions.Where(toe => toe.IsEquivalentTo(typeOfVoid)).ToArray();

                Assert.IsNotEmpty(nonVoidTypeOfExpressions);
                Assert.IsEmpty(voidTypeOfExpressions);
            }
        }
示例#16
0
 public static ParameterListSyntax ParameterList(
     IEnumerable <ParameterSyntax> parameters,
     IEnumerable <SyntaxToken> separators) =>
 SF.ParameterList(
     SF.Token(SyntaxKind.OpenParenToken),
     SF.SeparatedList(parameters, separators),
     SF.Token(SyntaxKind.CloseParenToken));
示例#17
0
        public ActionResult _UpdateGalleryDitails(string folder)
        {
            string GalleryPath = Server.MapPath("~/Content/UserFiles/Users/" + folder + "/");
            List <ImageGalleryItem> allImages = SF.GalleryFile2List(GalleryPath, 120, 120, false, false);

            foreach (ImageGalleryItem item in allImages)
            {
                string order = Request["gallery_div_order_" + Url.Encode(item.FileName)];
                string title = Request["gallery_div_title_" + Url.Encode(item.FileName)];

                item.Title = title;

                if (!string.IsNullOrEmpty(order))
                {
                    int tempInt = 0;
                    int.TryParse(order, out tempInt);
                    if (tempInt != 0)
                    {
                        item.Order = tempInt;
                    }
                }
            }

            bool done = SF.GalleryList2File(allImages, GalleryPath);

            return(Content((done ? "בוצע" : "שגיאה")));
        }
示例#18
0
    /// <summary>
    /// Destroy a object.
    /// </summary>
    /// <param name="id">The id of the unit that being destroyed</param>
    public static void DestroyObj(byte id)
    {
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.DestroyObj);

        protocol.AddByte(id);
        Client.Instance.Send(protocol);
    }
示例#19
0
    public static void Chatting(string msg)
    {
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.Chatting);

        protocol.AddString(msg);
        Client.Instance.Send(protocol);
    }
示例#20
0
 public static void CanControll()
 {
     if (Client.Instance.isConnect && Client.Instance.pl_info.isLogin)
     {
         Client.Instance.Send(SF.GetProtocolHead(ProtoName.CanControll));
     }
 }
示例#21
0
        public string[] CollectedCounters()
        {
            string[]      summaryFile = Directory.GetFiles(pathSummary, "*.xml");
            List <string> listCounter = new List <string>();

            foreach (string SF in summaryFile)
            {
                string fileName = SF.Replace(pathSummary + "Summary ", "");
                fileName = fileName.Remove(fileName.Length - 4);
                if (!listCounter.Contains(fileName))
                {
                    listCounter.Add(fileName);
                }
            }

            if (listCounter.Count != 0)
            {
                string[] temp = new string[listCounter.Count];
                for (int i = 0; i < listCounter.Count; i++)
                {
                    temp[i] = listCounter[i];
                }

                return(temp);
            }
            else
            {
                return(null);
            }
        }
示例#22
0
        private static async Task <Document> RewriteArgumentList(
            Document document,
            ArgumentListSyntax argumentList,
            SyntaxTrivia openParenTrivia,
            SyntaxTrivia commaTrivia,
            SyntaxTrivia parameterTypeTrivia,
            CancellationToken cancellationToken)
        {
            var updatedArguments = argumentList.Arguments.Select(
                p => p.WithLeadingTrivia(parameterTypeTrivia));

            var separators = Enumerable.Repeat(
                SF.Token(SyntaxKind.CommaToken).WithTrailingTrivia(commaTrivia),
                argumentList.Arguments.Count() - 1);

            var updatedParameterList = SF.ArgumentList(
                SF.Token(SyntaxKind.OpenParenToken).WithTrailingTrivia(openParenTrivia),
                SF.SeparatedList(updatedArguments, separators),
                argumentList.CloseParenToken);

            var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);

            var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);

            var newRoot     = root.ReplaceNode(argumentList, updatedParameterList);
            var newDocument = document.WithSyntaxRoot(newRoot);

            return(newDocument);
        }
示例#23
0
        public ActionResult _UpdateGalleryDitails(string folder)
        {
            string UserFolder = string.Format("~/Content/UserFiles/{0}/{1}", LS.CurrentUser.RoleDefault, folder);

            string GalleryPath = Server.MapPath(UserFolder);
            List <ImageGalleryItem> allImages = SF.GalleryFile2List(GalleryPath, 120, 120, false, false);

            foreach (ImageGalleryItem item in allImages)
            {
                string order = Request["gallery_div_order_" + Url.Encode(item.FileName)];
                string title = Request["gallery_div_title_" + Url.Encode(item.FileName)];

                item.Title = title;

                if (!string.IsNullOrEmpty(order))
                {
                    int tempInt = 0;
                    int.TryParse(order, out tempInt);
                    if (tempInt != 0)
                    {
                        item.Order = tempInt;
                    }
                }
            }

            bool done = SF.GalleryList2File(allImages, GalleryPath);

            return(Content((done ? "Done" : "Error")));
        }
        public JsonpResult _TreeViewLoading(int?ID)
        {
            int parentId = (ID == null ? 0 : (int)ID);
            var pages    = RP.GetAdminMenuRepository();

            string domain = string.Empty;

            if (!HttpContext.Request.IsLocal && SF.UseMultiDomain())
            {
                domain = "http://" + RP.GetAdminCurrentSettingsRepository().Domain;
            }

            IEnumerable nodes = pages.Where(r => r.ParentID == parentId)
                                .Select(item => new
            {
                Text           = item.Title,
                ID             = item.ID.ToString(),
                hasChildren    = (pages.Count(r2 => r2.ParentID == item.ID) > 0),
                imageUrl       = domain + Url.Content(item.Image),
                Url            = (string.IsNullOrEmpty(item.RedirectTo) ? (domain + item.Url) : item.RedirectTo),
                SpriteCssClass = "",
                expanded       = (item.IsLangRoot),
                ReportsTo      = parentId
            });

            return(this.Jsonp(nodes));
        }
        private ClassDeclarationSyntax GenerateReadReplicaGrain(ClassDeclarationSyntax grainClass, ITypeSymbol swmrInterface)
        {
            string readReplicaGrainName             = SwmrUtils.GetReadReplicaGrainName(grainClass.Identifier.Text);
            string readReplicaInterfaceName         = SwmrUtils.GetReadReplicaInterfaceName(swmrInterface.Name);
            ClassDeclarationSyntax readReplicaGrain = GenerateClassSqueleton(readReplicaGrainName).WithBaseList(RoslynUtils.BaseList(new[] { "Grain", readReplicaInterfaceName }));

            string grainStateTypeName = FindGrainStateTypeName(grainClass);

            readReplicaGrain = readReplicaGrain.AddMembers(SF.FieldDeclaration(SF.VariableDeclaration(SF.ParseTypeName(grainStateTypeName), SF.SeparatedList(new[] { SF.VariableDeclarator(SF.Identifier("State")) }))).AddModifiers(SF.Token(SyntaxKind.PrivateKeyword)));

            readReplicaGrain = readReplicaGrain.AddMembers(GenerateReadReplicaOnActivateAsync(swmrInterface));

            foreach (ISymbol member in swmrInterface.GetMembers())
            {
                IMethodSymbol methodSymbol = member as IMethodSymbol;
                if (methodSymbol == null || !IsReadOnlyMethod(methodSymbol))
                {
                    continue;
                }
                MethodDeclarationSyntax methodImpl = RoslynUtils.FindImplementation(methodSymbol, grainClass);
                readReplicaGrain = readReplicaGrain.AddMembers(methodImpl.WithLeadingTrivia(SF.EndOfLine("")));
            }

            readReplicaGrain = readReplicaGrain.AddMembers(GenerateSetStateMethod(grainStateTypeName));

            return(readReplicaGrain);
        }
示例#26
0
 internal V_SF(SeamlessViewsContext Context, SF SF)
     : base(Context)
 {
     _SFKEY          = SF.SFKEY;
     _SURNAME        = SF.SURNAME;
     _FIRST_NAME     = SF.FIRST_NAME;
     _SECOND_NAME    = SF.SECOND_NAME;
     _PREF_NAME      = SF.PREF_NAME;
     _TITLE          = SF.TITLE;
     _FACULTY01      = SF.FACULTY01;
     _FACULTY02      = SF.FACULTY02;
     _FACULTY03      = SF.FACULTY03;
     _FACULTY04      = SF.FACULTY04;
     _SUBJECT01      = SF.SUBJECT01;
     _SUBJECT02      = SF.SUBJECT02;
     _SUBJECT03      = SF.SUBJECT03;
     _SUBJECT04      = SF.SUBJECT04;
     _SUBJECT05      = SF.SUBJECT05;
     _SUBJECT06      = SF.SUBJECT06;
     _SUBJECT07      = SF.SUBJECT07;
     _SUBJECT08      = SF.SUBJECT08;
     _SUBJECT09      = SF.SUBJECT09;
     _SUBJECT10      = SF.SUBJECT10;
     _FTE            = SF.FTE;
     _MAJORA         = SF.MAJORA;
     _MAJORB         = SF.MAJORB;
     _MAJORC         = SF.MAJORC;
     _PAYROLL_CLASS  = SF.PAYROLL_CLASS;
     _PAYROLL_REC_NO = SF.PAYROLL_REC_NO;
 }
示例#27
0
        public virtual void OnEdit()
        {
            if (SF.UsePermissions())
            {
                if (LS.CurrentUser.IsInRole("Admin"))
                {
                    List <string> PermissionsView = new List <string>();
                    PermissionsView.Add("Admin");
                    if (LS.CurrentHttpContext.Request["PermissionsView"] != null)
                    {
                        PermissionsView.AddRange(LS.CurrentHttpContext.Request.Form.GetValues("PermissionsView").ToList());
                    }
                    this.PermissionsView = SF.RolesListToString(PermissionsView);

                    List <string> PermissionsEdit = new List <string>();
                    PermissionsEdit.Add("Admin");
                    if (LS.CurrentHttpContext.Request["PermissionsEdit"] != null)
                    {
                        PermissionsEdit.AddRange(LS.CurrentHttpContext.Request.Form.GetValues("PermissionsEdit").ToList());
                    }
                    this.PermissionsEdit = SF.RolesListToString(PermissionsEdit);
                }
                else
                {
                    AbstractPage OldPage = LS.CurrentEntityContext.AbstractPages.FirstOrDefault(r => r.ID == ID);
                    LS.CurrentEntityContext.Entry(OldPage).State = EntityState.Detached;
                    this.PermissionsView = OldPage.PermissionsView;
                    this.PermissionsEdit = OldPage.PermissionsEdit;
                }
            }
        }
示例#28
0
        public static List <CustomMenuItem> GetSiteMap()
        {
            Settings s = GetCurrentSettings();
            List <CustomMenuItem> pages = GetMenuAllIncludeNoneAdminMenu(s.ID, SF.GetLangCodeThreading());

            return(pages);
        }
        private int SendEmail(OutEmail om, string to = "")
        {
            if (string.IsNullOrEmpty(to))
            {
                to = om.MailTo;
            }
            if (om.LastTry > DateTime.Now && DateTime.Now > om.LastTry.AddSeconds(TimeInterval))
            {
                return(-1);
            }
            SmtpClient  client   = new SmtpClient();
            string      MailFrom = ConfigurationManager.AppSettings["MailFrom"];
            MailMessage mm       = new MailMessage(MailFrom, to);

            mm.IsBodyHtml      = true;
            mm.SubjectEncoding = Encoding.GetEncoding(1255);
            mm.BodyEncoding    = Encoding.UTF8;
            if (mm.Subject != null)
            {
                mm.Subject = om.Subject.Replace("\r\n", "");
            }
            mm.Body = om.Body;
            try
            {
                client.Send(mm);
                return(0);
            }
            catch (Exception ex)
            {
                SF.LogError(ex);
                return(om.TimesSent + 1);
            }
        }
示例#30
0
        private static ClassDeclarationSyntax CreateClass(
            ClassDeclarationSyntax parentClass,
            ConstructorDeclarationSyntax constructor)
        {
            ObjectCreationExpressionSyntax CreateMoq(TypeSyntax moqType) =>
            EGH.CreateObject(
                moqType,
                SF.Argument(
                    EGH.MemberAccess(
                        GH.Identifier("MockBehavior"),
                        GH.Identifier("Strict"))));

            var mi = new MethodInspector(constructor);

            var recordBuilder = new RecordBuilder($"{mi.Name}Test")
                                .AddModifiers(Modifiers.Public);

            foreach (var p in mi.Parameters)
            {
                var mockedType = GetMockedType(p.Type);
                var moqType    = GH.GenericName("Mock", mockedType);
                recordBuilder.AddField(moqType, MockName(p.Name), CreateMoq(moqType));
            }

            recordBuilder.AddMethod(GenerateCreateSut(parentClass, mi));

            return(recordBuilder.Build());
        }
示例#31
0
        public static string GetSiteMapFormated()
        {
            Settings s = GetCurrentSettings();
            List <CustomMenuItem> pages = GetMenuAllIncludeNoneAdminMenu(s.ID, SF.GetLangCodeThreading());

            return(WriteChildMenu(pages.Where(r => r.Visible == true && r.ShowInSitemap == true).ToList(), null, 10, 1));
        }
示例#32
0
文件: SfRequest.cs 项目: ebeeb/SfSdk
        /// <summary>
        ///     Executes the <see cref="SfRequest" /> asynchronously.
        /// </summary>
        /// <param name="source">The addressed request source, which should be an instance of type <see cref="SnFRequestSource" /> in usual cases.</param>
        /// <param name="sessionId">A valid session ID, with the length of 32. <see cref="Session.EmptySessionId" /> is used for logging in.</param>
        /// <param name="action">The action which shall be executed. See <see cref="SF" /> which start with "Act".</param>
        /// <param name="args">Additional arguments like e.g. the search string for searches or the user credentials for logging in.</param>
        /// <returns>A <see cref="SfResponse" /> containing the result information.</returns>
        /// <exception cref="ArgumentNullException">When source or sessionId is null.</exception>
        /// <exception cref="ArgumentException">When sessionId has not a length of 32.</exception>
        public async Task<ISfResponse> ExecuteAsync(IRequestSource source, string sessionId, SF action, IEnumerable<string> args = null)
        {
            if (source == null) throw new ArgumentNullException("source");
            if (sessionId == null) throw new ArgumentNullException("sessionId");
            if (sessionId.Length != 32) throw new ArgumentException("sessionId must have a length of 32.", "sessionId");

            var id = Guid.NewGuid();

            Log.Info("Request started:  ID = {0}", id);
            var response = await source.RequestAsync(sessionId, action, args);
            Log.Info("Request finished: ID = {0}", id);
            
            return response;
        }
示例#33
0
        /// <summary>
        ///     Creates a instance of <see cref="SnFUriWrapper" />.
        /// </summary>
        /// <param name="sessionId">A valid session ID, with the length of 32. <see cref="Session.EmptySessionId" /> is used for logging in.</param>
        /// <param name="serverUri">The server URI where the request is going to be received on.</param>
        /// <param name="action">The action which shall be executed. See <see cref="SF" /> which start with "Act".</param>
        /// <param name="args">Additional arguments like e.g. the search string for searches or the user credentials for logging in.</param>
        /// <exception cref="ArgumentNullException">When sessionId or serverUri is null.</exception>
        /// <exception cref="ArgumentException">When sessionId has not a length of 32.</exception>
        public SnFUriWrapper(string sessionId, Uri serverUri, SF action, IEnumerable<string> args = null)
        {
            if (sessionId == null) throw new ArgumentNullException("sessionId");
            if (serverUri == null) throw new ArgumentNullException("serverUri");
            if (sessionId.Length != 32) throw new ArgumentException("sessionId must have a length of 32.", "sessionId");

            _sessionId = sessionId;
            _serverUri = serverUri;
            _action = ((int) action).ToString(CultureInfo.InvariantCulture);
            while (_action.Length < 3)
                _action = _action.Insert(0, "0");
            if (args != null) _args = string.Join(";", args);
            _requestUri = BuildRequestUri();
        }
示例#34
0
#pragma warning disable 1998
        public async Task<ISfResponse> RequestAsync(string sessionId, SF action, IEnumerable<string> args = null)
#pragma warning restore 1998
        {
            switch (action)
            {
                case SF.ActLogin:
                    if (args == null) throw new ArgumentException("Logging in requires the args: username, passwordHash, serverUrl");
                    var argsList = args.ToList();
                    if (argsList[0] == TestConstants.InvalidUsername || argsList[1] == TestConstants.InvalidPasswordHash)
                        return new SfResponse(TestConstants.ExistingError, TestConstants.ValidServerUri);
                    // 2013/04/27
                    const string loginResponse = "0021912230455/75298/1367106812/1362182092/837135956/4/0/5/572/2200/360/55499/-1/1204/14/4/5/3/103/103/4/103/3/1/1/1/0/6/1/2/17/21/30/20/24/0/0/0/0/0/0/0/2/0/0/2/2/1365774494/6/1001/3/0/5/2/3/0/0/0/26/0/0/0/0/0/0/0/0/0/0/0/0/0/5/1001/2/0/5/4/3/0/0/0/24/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/1/1001/4/14/0/0/0/0/0/0/1/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/1365774068/5/5/5/6/4/2/-98/-11/-64/17/11/7/105/420/105/0/1001/9/0/3/1/2/3/0/0/154/0/0/1001/2/0/2/1/4/2/0/0/25/0/0/1001/6/0/1/4/2/4/0/0/154/0/44/774/91/53/51/42/0/1363718552/5/1001/6/0/5/2/3/2/0/0/131/0/7/1001/9/0/1/5/4/3/0/0/141/0/4/1001/7/0/1/2/3/3/0/0/147/0/1/1002/11/33/1/4/3/0/0/0/96/0/4/1001/4/0/5/2/4/0/0/0/45/0/4/1003/21/0/1/4/3/3/0/0/126/1/1362943332/8/4/0/0/1/5/3/3/0/0/75/0/9/7/0/0/2/4/5/2/0/0/50/0/8/6/0/0/2/5/1/2/0/0/50/0/12/4/0/0/11/4/0/72/10/0/71/0/9/1/0/0/3/5/4/3/0/0/37/1/12/5/0/0/11/5/0/72/10/0/71/0/0/1/8601/3/0/0/0/0/0/0/1362946879/0/0/0/5/4/14/0/0/0/0/0/1365763903/5580/0/0/0/0/0/0/0/1362182092/5/0/3/13/0/1425/399/0/1/9/0/0/2/1362776202/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/98807380/98807380/98807380/0/0/0/0/1367106812/;0;8Lxm0i176U00216U74D2p0G38398R33f;0;452;0";
                    return new SfResponse(loginResponse, TestConstants.ValidServerUri);
                case SF.ActLogout:
                    // 2013/05/17
                    const string logoutResponse = "+187";
                    return new SfResponse(logoutResponse, TestConstants.ValidServerUri);
                case SF.ActScreenChar:
                    // 2014/05/25
                    const string respScreenBuildchar = "0041629341313/64210/1401043089/1400859115/1102867789/0/0/17/13629/17745/1964/10388/-1/71/0/11/36/1/206/207/6/1/8/2/5/1/0/2/2/3/41/129/42/99/84/0/79/0/68/41/6/85/6/61/47/2/2/1401039258/6/2005/95/0/4/3/2/14/0/0/235/0/3/2006/65/0/2/3/4/18/0/0/183/0/5/2003/44/0/5/4/3/4/4/0/129/0/4/2003/66/0/4/2/5/9/9/0/208/0/8/4/0/0/2/5/1/16/0/0/157/0/7/2002/41/0/2/3/5/8/0/0/90/0/9/5/0/0/2/1/3/2/0/0/10/0/0/0/0/0/0/0/0/0/0/0/0/0/1/2051/26/50/2/4/5/26/26/26/6308/0/0/0/0/0/0/0/0/0/0/0/0/0/0/2004/27/49/5/4/3/18/0/0/0/0/0/2002/47/0/4/5/1/2/2/0/0/0/0/4/0/0/2/1/3/2/0/0/0/0/0/2002/28/0/2/4/3/2/2/0/0/0/0/5/0/0/11/5/0/72/10/0/57/0/1401033532/17/17/17/4/3/6/-126/-39/-129/10/12/13/60/60/60/0/2005/32/44/5/4/2/26/18/0/858/0/0/2006/107/0/3/5/4/16/14/0/757/0/0/2003/27/0/4/2/1/8/6/0/163/0/72/138/102/66/26/45/3/1400979454/3/2003/43/0/3/2/4/10/0/0/655/0/7/2005/67/0/2/1/3/9/7/0/902/4/7/2004/55/0/3/4/1/5/3/0/479/2/6/2005/78/0/4/2/1/15/0/0/1387/0/3/2004/54/0/4/2/1/10/10/0/959/5/4/2005/41/0/5/3/4/1/1/0/376/0/1400976025/9/2/0/0/3/5/4/2/0/0/50/0/12/16/0/0/11/12/0/168/25/0/520/15/8/9/0/0/1/5/2/3/3/0/112/1/8/4/0/0/2/3/1/1/1/0/38/0/8/1/0/0/2/1/3/10/10/0/488/5/9/1/0/0/1/3/2/6/6/0/225/3/0/0/1502/3/2/10186/0/0/0/0/1400958006/0/0/0/311/26/50/0/1402130440/0/0/0/1400976123/1170/9/4/1401041958/1401039532/72/54/1/1400946467/17/4/23/118/16/34100/2005/0/0/25/0/0/1/1401038932/3/6/0/0/0/0/0/0/0/0/0/120/0/0/4/5/0/1401122745/1401206209/0/10/10/0/0/1102867789/1102867789/1102867789/1/1401039183/0/80/1401043089;;";
                    return new SfResponse(respScreenBuildchar, TestConstants.ValidServerUri);
                case SF.ActRequestChar:
                    // 2013/05/17
                    const string actRequestChar = "+1110000000000/4296/0/0/0/0/0/231/76364148/110062180/47329/2/-1/0/0/0/0/7/509/507/2/507/5/1/9/1/0/4/257/3/1001/1810/1001/1700/1200/275/4469/275/3251/2261/915/1713/914/1610/1110/0/0/0/6/2050/795/0/2/4/5/290/290/290/9685227/0/3/2057/1596/0/2/4/5/280/280/280/8847416/0/5/2051/1308/0/2/4/5/292/292/292/5241891/0/4/2057/1360/0/2/4/5/286/286/286/15595112/0/8/57/0/0/2/4/5/278/278/278/4381832/0/7/2050/1161/0/2/4/5/283/283/283/24626499/0/9/57/0/0/2/4/5/277/277/277/1711336/0/10/54/0/0/6/0/0/275/0/0/0/0/1/2008/322/898/2/3/4/952/0/0/9985111/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/-42/-55/-130/15/9/6/450/450/300/0/2008/422/782/2/1/5/510/422/0/10494642/0/8/4/0/0/1/5/3/253/209/0/3147157/0/0/2009/1295/0/3/1/2/488/0/0/6772186/0/1016200/516100/505400/10839800/10243100/9458500/2621444/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/8/3/0/11669/0/0/12/12/0/32/0/0/6220/322/898/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/231/100/4677/5203/1529/1000000000/47659/0/1/77/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/123/11/150/14/12/16/1370299355/1369802949/1372446217/25/25/25/25/0/0/0/0/0/0/0/1368809900;Der erste lvl 100 am 23.02.13 um 16:39##geb: 08.02.2013     18:00 Uhr#s1##;Shades of Night";
                    return new SfResponse(actRequestChar, TestConstants.ValidServerUri);
                case SF.ActScreenEhrenhalle:
                    // 2013/05/17
                    const string actScreenEhrenhalle = "+007-1/Hadrians S25/Shades of Night/231/47970/-2/brigada00/Shades of Night/231/47329/-3/seelenjäger/Insane/219/46668/-4/tofo/Shades of Night/224/46381/-5/VerführunG/Shades of Night/223/46293/-6/Pad/Shades of Night/221/46259/-7/Tenegros/Shades of Night/227/46228/-8/Xayne/Shades of Night/224/46186/-9/Araton/Shades of Night/227/46125/10/Blutseele/Insane/-221/46109/-11/Pizza/Insane/219/46107/-12/Susanno/Tigers and Dragons/221/45993/-13/MissGeschick/Insane/221/45967/14/Delphi/Shades of Night/-220/45946/-15/Pfledex/100 Fäuste/213/45945/;";
                    return new SfResponse(actScreenEhrenhalle, TestConstants.ValidServerUri);
                case SF.ActAlbum:
                    // 2014/05/19
                    // monsters     36/ 252
                    // valuables    18/ 246
                    // warrior      19/ 506
                    // mage         20/ 348
                    // scout        10/ 348
                    // --------------------
                    // total       103/1700
                    const string actAlbum = "192wOBBQAKgSYIELIQEBACJdE8AAAAAAAAAAAAAAAAAAAAAAAAAAAACAEhAIwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgRAGlAAAAAAAAAAAAAAAAAAAAAAAAIoAAAAAAAAAAAAAAAAAAgABAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAAAAAAAAAAAAAAAACEgAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAABYAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAAIEIAAAAAAAAAAAAAAAAAQsAAAAAAAAAAAAAAAAAAIIIAAAAAAAAAAAAAAAAIMAIAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAEjAEAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAEAIAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEAIAAAAAAAAAAAAAABAAACAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAEBAAAAAAAAAAAAAAAAAAA==";
                    return new SfResponse(actAlbum, TestConstants.ValidServerUri);
                default:
                    throw new NotImplementedException(action.ToString());
            }
        }
示例#35
0
 public static Select New(Parse parse, ExprList list, SrcList src, Expr where_, ExprList groupBy, Expr having, ExprList orderBy, SF selFlags, Expr limit, Expr offset)
 {
     Context ctx = parse.Ctx;
     Select newSelect = new Select();
     Debug.Assert(ctx.MallocFailed || offset == null || limit != null); // OFFSET implies LIMIT
     // Select standin;
     if (newSelect == null)
     {
         Debug.Assert(ctx.MallocFailed);
         //newSelect = standin;
         //_memset(newSelect, 0, sizeof(newSelect));
     }
     if (list == null)
         list = Expr.ListAppend(parse, null, Expr.Expr_(ctx, TK.ALL, null));
     newSelect.EList = list;
     if (src == null) src = new SrcList();
     newSelect.Src = src;
     newSelect.Where = where_;
     newSelect.GroupBy = groupBy;
     newSelect.Having = having;
     newSelect.OrderBy = orderBy;
     newSelect.SelFlags = selFlags;
     newSelect.OP = TK.SELECT;
     newSelect.Limit = limit;
     newSelect.Offset = offset;
     Debug.Assert(offset == null || limit != null);
     newSelect.AddrOpenEphms[0] = (OP) - 1;
     newSelect.AddrOpenEphms[1] = (OP) - 1;
     newSelect.AddrOpenEphms[2] = (OP) - 1;
     if (ctx.MallocFailed)
     {
         ClearSelect(ctx, newSelect);
         //if (newSelect != standin) C._tagfree(ctx, ref newSelect);
         newSelect = null;
     }
     else
         Debug.Assert(newSelect.Src != null || parse.Errs > 0);
     //Debug.Assert(newSelect != standin);
     return newSelect;
 }
示例#36
0
文件: SfResponse.cs 项目: ebeeb/SfSdk
 private void ProcessSuccess(SF success, string[] args)
 {
     switch (success)
     {
         case SF.RespLoginSuccess:
         case SF.RespLoginSuccessBought:
             Response = new LoginResponse(args);
             break;
         case SF.RespLogoutSuccess:
             Response = new LogoutResponse(args);
             break;
         case SF.ActScreenChar:
             Response = new CharacterResponse(args);
             break;
         case SF.RespPlayerScreen:
             Response = new CharacterResponse(args);
             break;
         case SF.ActScreenEhrenhalle:
             // TODO was hier?
     //                    var lastGuildShown = string.Empty;
         case SF.RespScreenGildenhalle:
             Response = new HallOfFameResponse(args);
             break;
         case SF.ActGuildJoinAttack:
             // TODO
             break;
         case SF.RespAlbum:
             Response = new ScrapbookResponse(args, _serverUri);
             break;
         default:
             var e = new ArgumentOutOfRangeException("success");
             Log.Error(e);
             throw e;
     }
 }
示例#37
0
文件: SfResponse.cs 项目: ebeeb/SfSdk
 private void ProcessError(SF error, string[] args)
 {
     switch (error)
     {
         case SF.ErrLoginFailed:
         case SF.ErrSessionIdExpired:
         case SF.ErrServerDown:
         case SF.ErrNoAlbum:
             Errors.Add(error);
             break;
         default:
             var e = new ArgumentOutOfRangeException("error");
             Log.Error(e);
             throw e;
     }
 }
示例#38
0
        void svc2_ExecuteServiceCompleted(object sender, SF.Proxy.ExecuteServiceCompletedEventArgs e)
        {
            SF.Proxy.Employee emp = e.Result;

            bindingSource1.DataSource = emp;
        }
示例#39
0
 public static Select New(Parse parse, int dummy1, SrcList src, int dummy2, int dummy3, int dummy4, int dummy5, SF selFlags, int dummy6, int dummy7) { return New(parse, null, src, null, null, null, null, selFlags, null, null); }
示例#40
0
 public void Test_That_SF_Can_Be_Played()
 {
     MovieFacade facade = new MovieFacade();
     IPlayer sfMovie = new SF();
     sfMovie.PlayMovie("Starwars");
 }