Пример #1
0
        public bool DeleteConsBySubGroupIdList(List <int> list)
        {
            bool ans = false;

            try
            {
                foreach (int ID in list)
                {
                    GroupConnection gpcon = (from r in DB.GroupConnections
                                             where r.GroupID == ID
                                             select r).FirstOrDefault();
                    if (gpcon != null)
                    {
                        DB.GroupConnections.Remove(gpcon);

                        gpcon = null;
                    }
                }

                DB.SaveChanges();
                ans = true;
            }
            catch (System.Exception)
            {
                ans = false;
            }
            return(ans);
        }
Пример #2
0
        /// <summary>
        /// Connects a group import to a group export with the given part and schedule connections described
        /// by the <paramref name="connection"/> object.
        /// </summary>
        /// <param name="connection">The object that describes how the group import and the group export should be connected.</param>
        /// <returns>A task that will finish when the connection action has completed.</returns>
        public Task Connect(GroupConnection connection)
        {
            var globalTask = Task.Factory.StartNew(
                () =>
            {
                var key = m_DatasetLock.LockForWriting();
                try
                {
                    m_CompositionLayer.Connect(connection);
                }
                finally
                {
                    m_DatasetLock.RemoveWriteLock(key);
                }
            });

            return(globalTask);
        }
Пример #3
0
        /// <summary>
        /// Connects the exporting group with the importing group via the given import.
        /// </summary>
        /// <param name="connection">The object that describes how the group import and the group export should be connected.</param>
        public void Connect(GroupConnection connection)
        {
            {
                Lokad.Enforce.Argument(() => connection);
                Lokad.Enforce.With <UnknownGroupCompositionIdException>(
                    m_Groups.ContainsKey(connection.ImportingGroup),
                    Resources.Exceptions_Messages_UnknownGroupCompositionId);
                Lokad.Enforce.With <UnknownGroupCompositionIdException>(
                    m_Groups.ContainsKey(connection.ExportingGroup),
                    Resources.Exceptions_Messages_UnknownGroupCompositionId);
            }

            m_GroupConnections.AddEdge(new GroupCompositionGraphEdge(connection.ImportingGroup, connection.GroupImport, connection.ExportingGroup));

            var importingParts = PartsForGroup(connection.ImportingGroup);
            var exportingParts = PartsForGroup(connection.ExportingGroup);

            ConnectParts(connection.PartConnections, importingParts, exportingParts);
        }
Пример #4
0
        public void Connect()
        {
            var lockKey     = new DatasetLockKey();
            var datasetLock = new Mock <ITrackDatasetLocks>();
            {
                datasetLock.Setup(d => d.LockForWriting())
                .Returns(lockKey)
                .Verifiable();
                datasetLock.Setup(d => d.RemoveWriteLock(It.IsAny <DatasetLockKey>()))
                .Callback <DatasetLockKey>(key => Assert.AreSame(lockKey, key))
                .Verifiable();
            }

            var originalConnection = new GroupConnection(
                new GroupCompositionId(),
                new GroupCompositionId(),
                GroupImportDefinition.CreateDefinition(
                    "a",
                    new GroupRegistrationId("a"),
                    null,
                    Enumerable.Empty <ImportRegistrationId>()),
                Enumerable.Empty <PartImportToPartExportMap>());
            var storage = new Mock <IStoreGroupsAndConnections>();
            {
                storage.Setup(s => s.Connect(It.IsAny <GroupConnection>()))
                .Callback <GroupConnection>(
                    id =>
                {
                    Assert.AreSame(originalConnection, id);
                });
            }

            var commands = new CompositionCommands(datasetLock.Object, storage.Object);
            var task     = commands.Connect(originalConnection);

            task.Wait();

            datasetLock.Verify(d => d.LockForWriting(), Times.Once());
            datasetLock.Verify(d => d.RemoveWriteLock(It.IsAny <DatasetLockKey>()), Times.Once());
        }
Пример #5
0
        /// <summary>
        /// Connects the given export to the given import.
        /// </summary>
        /// <param name="importingGroup">The ID of the group that owns the import.</param>
        /// <param name="importDefinition">The import.</param>
        /// <param name="exportingGroup">The ID of the group that owns the export.</param>
        /// <returns>A task which indicates when the connection has taken place.</returns>
        public Task Connect(
            GroupCompositionId importingGroup,
            GroupImportDefinition importDefinition,
            GroupCompositionId exportingGroup)
        {
            {
                Debug.Assert(importingGroup != null, "The ID of the importing group should not be a null reference.");
                Debug.Assert(importDefinition != null, "The import definition should not be a null reference.");
                Debug.Assert(exportingGroup != null, "The ID of the exporting group should not be a null reference.");
            }

            if (!Contains(importingGroup) || !Contains(exportingGroup))
            {
                throw new UnknownPartGroupException();
            }

            m_Diagnostics.Log(
                LevelToLog.Trace,
                HostConstants.LogPrefix,
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ProxyCompositionLayer_LogMessage_ConnectingGroups_WithImportAndExport,
                    importingGroup,
                    exportingGroup));

            var parts      = m_Connector.GenerateConnectionFor(m_Groups[importingGroup], importDefinition, m_Groups[exportingGroup]);
            var state      = new GroupConnection(importingGroup, exportingGroup, importDefinition, parts);
            var remoteTask = m_Commands.Connect(state);

            return(remoteTask.ContinueWith(
                       t =>
            {
                lock (m_Lock)
                {
                    m_GroupConnections.AddEdge(new CompositionLayerGroupEdge(importingGroup, importDefinition, exportingGroup));
                }
            }));
        }
Пример #6
0
        public void TestSetUp()
        {
            #region Init Definitions
            test = SetUpFixtureBase.extent.CreateTest(TestContext.CurrentContext.Test.Name);
            setUpWebDriver = new SetUpWebDriver();
            page = new Page(setUpWebDriver);
            testHelpers = new TestHelpers();
            objectsTests = new ObjectsTests();
            homePage = new HomePage(setUpWebDriver);
            topMenuPage = new TopMenuPage(setUpWebDriver);
            leftMenuPage = new LeftMenuPage(setUpWebDriver);
            createAlbumPage = new CreateAlbumPage(setUpWebDriver);
            userConnection = new UserConnection();
            albumConection = new AlbumConection();
            albumListPage = new AlbumListPage(setUpWebDriver);
            updateAlbumPage = new UpdateAlbumPage(setUpWebDriver);
            createGroupPage = new CreateGroupPage(setUpWebDriver);
            updateGroupPage = new UpdateGroupPage(setUpWebDriver);
            groupListPage = new GroupListPage(setUpWebDriver);
            groupConnection = new GroupConnection();
            #endregion

            Logger(Status.Info, "Empieza el test: " + TestContext.CurrentContext.Test.Name, true);
        }
Пример #7
0
        public bool SaveGroupCon(GroupConnection GC)
        {
            try
            {
                if (GC.ConectionID > 0)
                {
                    //==== UPDATE ====
                    DB.GroupConnections.Attach(GC);
                    DB.Entry(GC).State = EntityState.Modified;
                }
                else
                {
                    //==== INSERT ====
                    DB.GroupConnections.Add(GC);
                }

                DB.SaveChanges();
                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
Пример #8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if ((String.IsNullOrEmpty(editor1.Text) == false) &&
                (Abstract.Text.Length >= 130) &&
                (FileUpload1.HasFile) &&
                (String.IsNullOrEmpty(title.Text) == false) &&
                (String.IsNullOrEmpty(Abstract.Text) == false) &&
                (String.IsNullOrEmpty(Tags.Text) == false) &&
                (String.IsNullOrEmpty(KeyWords.Text) == false))
            {
                if (FileUpload1.FileBytes.Length > 1024 * 1024)
                {
                    diverror.InnerHtml = "حجم فایل بارگذاری شده بیشتر از 1 مگابایت است!";
                    return;
                }
                string ext = Path.GetExtension(FileUpload1.FileName).ToLower();
                if ((ext != ".jpg") && (ext != ".png"))
                {
                    diverror.InnerHtml = "فرمت فایل بارگذاری شده باید .jpg  یا .png  باشد!";
                    return;
                }

                Article ART = new Article();
                ART.Title   = title.Text;
                ART.Content = editor1.Text;

                string filename = Path.GetFileName(FileUpload1.FileName);
                string rand     = DBManager.CurrentTimeWithoutColons() + DBManager.CurrentPersianDateWithoutSlash();
                filename = rand + filename;
                string ps = Server.MapPath(@"~\img\") + filename;
                FileUpload1.SaveAs(ps);

                FileStream fStream  = File.OpenRead(ps);
                byte[]     contents = new byte[fStream.Length];
                fStream.Read(contents, 0, (int)fStream.Length);
                fStream.Close();

                ART.Image = "/img/" + filename;
                System.Drawing.Image img   = imgResize.ToImage(contents);
                System.Drawing.Image image = imgResize.Resize(img, 358, 358);

                string stream = Server.MapPath(@"~\img\") + "s" + filename;
                switch (FileUpload1.FileName.Substring(FileUpload1.FileName.IndexOf('.') + 1).ToLower())
                {
                case "jpg":
                    image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    break;

                case "jpeg":
                    image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    break;

                case "png":
                    image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    break;
                }

                ART.ImgFirstPage = "/img/" + "s" + filename;

                ART.Abstract     = Abstract.Text;
                ART.PostDateTime = OnlineTools.persianFormatedDate();
                ART.Visits       = 0;
                ART.Tags         = Tags.Text;
                ART.KeyWords     = KeyWords.Text;
                ArticleRepository ARTRep = new ArticleRepository();
                if (ARTRep.SaveArticle(ART))
                {
                    bool result = true;
                    GroupsConRepository GRConRepo = new GroupsConRepository();

                    int lastid = ARTRep.GetLastArticleID();
                    int count  = SelectedSubGroups.Items.Count;
                    if (count > 0)
                    {
                        for (int i = 0; i < count; i++)
                        {
                            GroupConnection GC = new GroupConnection();
                            GC.ArticleID = lastid;
                            GC.GroupID   = SelectedSubGroups.Items[i].Value.ToInt();
                            if (!GRConRepo.SaveGroupCon(GC))
                            {
                                result = false;
                            }
                        }
                    }
                    else
                    {
                        diverror.InnerText = "هیچ زیر گروهی انتخاب نشده است!";
                    }

                    if (!result)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی در زمان ثبت به وجود آمد،لطفا دوباره سعی کنید یا با پشتیبانی تماس بگیرید ! ');window.location ='/Admin/ManageBlogs'", true);
                    }
                    else
                    {
                        Response.Redirect("/Admin/ManageBlogs");
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی در زمان ثبت به وجود آمد،لطفا دوباره سعی کنید یا با پشتیبانی تماس بگیرید ! ');window.location ='/Admin/ManageBlogs'", true);
                }
            }
        }
Пример #9
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!(String.IsNullOrEmpty(editor1.Text) ||
                  String.IsNullOrEmpty(title.Text) ||
                  String.IsNullOrEmpty(Abstract.Text) ||
                  String.IsNullOrEmpty(Tags.Text) ||
                  String.IsNullOrEmpty(KeyWords.Text) || SelectedSubGroups.Items.Count == 0 || Abstract.Text.Count() < 130))
            {
                if (Session["newPostIDForEdit"] != null)
                {
                    int id = Session["newPostIDForEdit"].ToString().ToInt();
                    Session.Remove("newPostIDForEdit");
                    ArticleRepository repArt = new ArticleRepository();
                    GroupsRepository  repo   = new GroupsRepository();
                    Article           art    = repArt.FindeArticleByID(id);

                    art.Title   = title.Text;
                    art.Content = editor1.Text;

                    if (FileUpload1.HasFile)
                    {
                        if (FileUpload1.FileBytes.Length > 1024 * 1024)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حجم فایل بارگذاری شده بیشتر از 1 مگابایت است!')", true);

                            return;
                        }
                        string ext = Path.GetExtension(FileUpload1.FileName).ToLower();
                        if ((ext != ".jpg") && (ext != ".png"))
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('فرمت فایل بارگذاری شده باید .jpg  یا .png  باشد!')", true);

                            return;
                        }
                        string filename = Path.GetFileName(FileUpload1.FileName);
                        string rand     = DBManager.CurrentTimeWithoutColons() + DBManager.CurrentPersianDateWithoutSlash();
                        filename = rand + filename;
                        string ps = Server.MapPath(@"~\img\") + filename;
                        FileUpload1.SaveAs(ps);
                        FileStream fStream  = File.OpenRead(ps);
                        byte[]     contents = new byte[fStream.Length];
                        fStream.Read(contents, 0, (int)fStream.Length);
                        fStream.Close();
                        FileInfo fi = new FileInfo(Server.MapPath(@"~\img\") + art.Image.Substring(5));
                        fi.Delete();
                        FileInfo fil = new FileInfo(Server.MapPath(@"~\img\") + art.ImgFirstPage.Substring(5));
                        fil.Delete();
                        art.Image = "/img/" + filename;
                        System.Drawing.Image img   = imgResize.ToImage(contents);
                        System.Drawing.Image image = imgResize.Resize(img, 358, 358);



                        string stream = Server.MapPath(@"~\img\") + "s" + filename;
                        switch (FileUpload1.FileName.Substring(FileUpload1.FileName.IndexOf('.') + 1).ToLower())
                        {
                        case "jpg":
                            image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                            break;

                        case "jpeg":
                            image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                            break;

                        case "png":
                            image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                            break;
                        }

                        art.ImgFirstPage = "/img/" + "s" + filename;
                    }


                    art.Abstract = Abstract.Text;
                    art.Visits   = 0;
                    art.Tags     = Tags.Text;
                    art.KeyWords = KeyWords.Text;
                    ArticleRepository ARTRep = new ArticleRepository();
                    if (ARTRep.SaveArticle(art))
                    {
                        bool result = true;
                        GroupsConRepository GRConRepo = new GroupsConRepository();
                        GRConRepo.DeletArticleConnections(id);
                        List <int> SelectedSubGroupsList = new List <int>();

                        int lastid = id;
                        int count  = SelectedSubGroups.Items.Count;
                        if (count > 0)
                        {
                            for (int i = 0; i < count; i++)
                            {
                                GroupConnection GC = new GroupConnection();
                                GC.ArticleID = lastid;
                                GC.GroupID   = SelectedSubGroups.Items[i].Value.ToInt();
                                if (!GRConRepo.SaveGroupCon(GC))
                                {
                                    result = false;
                                }
                                else
                                {
                                    Response.Redirect("/Admin/ManageBlogs");
                                }
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('هیچ زیر گروهی انتخاب نشده است!')", true);
                        }

                        if (!result)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی در زمان ثبت به وجود آمد،لطفا دوباره سعی کنید یا با پشتیبانی تماس بگیرید ! ');window.location ='/Admin/ManageBlogs'", true);
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ثبت با موفقیت انجام شد!');window.location ='/Admin/ManageBlogs'", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی در زمان ثبت به وجود آمد،لطفا دوباره سعی کنید یا با پشتیبانی تماس بگیرید ! ');window.location ='/Admin/ManageBlogs'", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(' مشکلی در زمان لود کردن به وجود آمد دوباره سعی کنید ! ');window.location ='/Admin/ManageBlogs'", true);
                }
            }
        }
Пример #10
0
 public static Vector3 GetOriginPosition(this GroupConnection connection) => connection.transform.position + connection.Orientation * Vector3.forward;