public int UnAssignUpazilla(ViewRegion viewRegion) { CommandObj.CommandText = "UDSP_UnAssignUpazilla"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.Clear(); CommandObj.Parameters.AddWithValue("@DistrictId", viewRegion.DistrictId); CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int); CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value); return(rowAffected); }
public LayoutView() { var dock = new DockPanel(); Content = dock; Header = new ViewRegion { Border = new Thickness(1), Padding = new Thickness(2, 1) }; dock.Add(Header, Dock.Top, 15); Body = new ViewRegion { Padding = new Thickness(2, 1) }; dock.Add(Body, Dock.Fill); }
public int UnAssignDistrictFromRegion(ViewRegion regionDetails, string reason, ViewUser user) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Parameters.Clear(); CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "UDSP_UnAssignDistrictFromRegion"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@RegionDetailsId", regionDetails.RegionDetailsId); CommandObj.Parameters.AddWithValue("@Reason", reason); CommandObj.Parameters.AddWithValue("@UnAssignedByUserId", user.UserId); CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int); CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output; // var parameters = CommandObj.Parameters; CommandObj.ExecuteNonQuery(); var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value); int result = UnAssignUpazilla(regionDetails); if (result > 0) { sqlTransaction.Commit(); } return(rowAffected); } catch (SqlException sqlException) { sqlTransaction.Rollback(); throw new Exception("Could not UnAssign district due to Sql Exception", sqlException); } catch (Exception exception) { sqlTransaction.Rollback(); throw new Exception("Could not UnAssign district", exception); } finally { ConnectionObj.Close(); CommandObj.Dispose(); CommandObj.Parameters.Clear(); } }
/// <summary> /// Creates and/or opens the given view content in the specified region /// </summary> /// <typeparam name="T">The type implementing the <see cref="T:Maestro.Shared.UI.IViewContent"/> interface</typeparam> /// <param name="title"></param> /// <param name="description"></param> /// <param name="region">The desired region to show the view content in</param> /// <param name="method">A method that will create the required view content the view content has not been created yet</param> /// <returns></returns> public T OpenContent <T>(string title, string description, ViewRegion region, CreateFunc <T> method) where T : IViewContent { var type = typeof(T); var wb = GetWorkbench(); if (_singletonViewContentTypes.ContainsKey(type.Name)) { foreach (var cnt in _singletonInstances) { if (type.IsAssignableFrom(cnt.GetType())) { if (!cnt.IsAttached) { wb.ShowContent(cnt); } cnt.Activate(); var h = this.ViewActivated; if (h != null) { h(this, new ViewEventArgs(cnt)); } //wb.CheckContainerStatus(); return((T)cnt); } } } T obj = method(); //(T)Activator.CreateInstance(type, true); SingletonViewContent svc = obj as SingletonViewContent; if (svc != null) { throw new InvalidOperationException(string.Format(Strings.Error_ViewContent_Not_Registered, type.Name)); } obj.Title = title; obj.Description = description; wb.ShowContent(obj); return(obj); }
public ViewRegion GetRegionDetailsById(int regionDetailsId) { try { CommandObj.CommandText = "UDSP_GetRegionDetailsById"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@RegionDetailsId", regionDetailsId); ConnectionObj.Open(); SqlDataReader reader = CommandObj.ExecuteReader(); ViewRegion region = null; if (reader.Read()) { region = new ViewRegion { RegionDetailsId = regionDetailsId, RegionId = Convert.ToInt32(reader["RegionId"]), RegionName = reader["RegionName"].ToString(), DivisionId = Convert.ToInt32(reader["DivisionId"]), DistrictId = Convert.ToInt32(reader["DistrictId"]), District = new District { DistrictId = Convert.ToInt32(reader["DistrictId"]), DistrictName = reader["DistrictName"].ToString() } }; } reader.Close(); return(region); } catch (Exception e) { throw new Exception("Could not Collect regions", e); } finally { ConnectionObj.Close(); CommandObj.Dispose(); CommandObj.Parameters.Clear(); } }
/// <summary> /// Shows the content. /// </summary> /// <param name="vc">The vc.</param> /// <param name="region">The region.</param> public void ShowContent(IViewContent vc, ViewRegion region) { TabManager tm = ServiceManager.Instance.GetService <TabManager>(); DockContent content = new DockContent(); content.TabText = vc.Title; content.Text = vc.Title; content.ToolTipText = vc.Title; content.CloseButton = vc.CanClose; switch (region) { case ViewRegion.Bottom: content.DockAreas = DockAreas.DockBottom; break; case ViewRegion.Top: content.DockAreas = DockAreas.DockTop; break; case ViewRegion.Left: content.DockAreas = DockAreas.DockLeft; break; case ViewRegion.Right: content.DockAreas = DockAreas.DockRight; break; case ViewRegion.Document: content.DockAreas = DockAreas.Document; break; case ViewRegion.Floating: content.DockAreas = DockAreas.Float; break; } vc.TitleChanged += delegate(object sender, EventArgs e) { content.TabText = vc.Title; content.Text = vc.Title; content.ToolTipText = vc.Title; }; vc.ViewContentClosing += delegate(object sender, EventArgs e) { if (vc.CanClose) { content.Close(); } }; content.ClientSize = vc.ContentControl.Size; content.CloseButton = vc.CanClose; vc.ContentControl.Dock = DockStyle.Fill; content.Controls.Add(vc.ContentControl); if (vc is IConnectionDependentView) { tm.Register((IConnectionDependentView)vc); } if (region == ViewRegion.Dialog) { content.StartPosition = FormStartPosition.CenterParent; content.ShowDialog(); } else { content.Show(contentPanel); } }
public Task <MiiverseContext> Authorize(NintendoNetworkSessionToken sessionToken, NintendoNetworkAuthenticationToken authenticationToken, string language = "en-US", ViewRegion region = ViewRegion.America) { // TODO: Handle authentication errors (bad passwords, network down) better. try { return(this.Client.PostAsync(AUTHORIZE_URI, new FormUrlEncodedContent(new Dictionary <string, string>() { ["client_id"] = sessionToken.ClientID, ["response_type"] = sessionToken.ResponseType, ["redirect_uri"] = sessionToken.RedirectUri.ToString(), ["state"] = sessionToken.State, ["nintendo_authenticate"] = string.Empty, ["nintendo_authorize"] = string.Empty, ["scope"] = string.Empty, ["lang"] = "ja-JP", ["username"] = authenticationToken.UserName, ["password"] = authenticationToken.Password, })).ContinueWith(r => this.Client.GetAsync(r.Result.Headers.Location)).Unwrap() .ContinueWith(r => { var cookie = this._clientHandler.CookieContainer.GetCookies(MiiverseConstantValues.MIIVERSE_DOMAIN_URI) .Cast <Cookie>() .Where(c => c.Name == "ms" && c.Path == "/" && c.Secure && c.HttpOnly) .OrderByDescending(c => c.Expires.Ticks) .First(); return new MiiverseContext(authenticationToken.UserName, sessionToken.ClientID, cookie.Value, language, region); })); } catch (Exception ex) { throw new Exception("Failed to Authenticate", ex); } }
public MiiverseContext(string userName, string clientID, string sessionValue, string language = "en-US", ViewRegion region = ViewRegion.America) { UserName = userName; ClientID = clientID; var handler = new HttpClientHandler() { AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, }; handler.CookieContainer.Add(MiiverseConstantValues.MIIVERSE_DOMAIN_URI, new Cookie("ms", sessionValue, "/", MiiverseConstantValues.MIIVERSE_DOMAIN) { Secure = true, HttpOnly = true, }); handler.CookieContainer.Add(MiiverseConstantValues.MIIVERSE_DOMAIN_URI, new Cookie("lang", language, "/", MiiverseConstantValues.MIIVERSE_DOMAIN) { Secure = true, HttpOnly = true, }); handler.CookieContainer.Add(MiiverseConstantValues.MIIVERSE_DOMAIN_URI, new Cookie("view_region_id", ((int)region).ToString(), "/", MiiverseConstantValues.MIIVERSE_DOMAIN) { Secure = true, HttpOnly = true, }); var client = new HttpClient(handler, true); client.DefaultRequestHeaders.Add("Accept-Language", $"{language},en;q=0.5"); client.DefaultRequestHeaders.Add("X-AUTOPAGERIZE", $"true"); Client = client; }
public int UnAssignDistrictFromRegion(ViewRegion regionDetails, string reason, ViewUser user) { return(_iRegionGateway.UnAssignDistrictFromRegion(regionDetails, reason, user)); }
/// <summary> /// Creates and/or opens the given view content in the specified region /// </summary> /// <typeparam name="T">The type implementing the <see cref="T:Maestro.Shared.UI.IViewContent"/> interface</typeparam> /// <param name="title"></param> /// <param name="description"></param> /// <param name="region">The desired region to show the view content in</param> /// <returns></returns> public T OpenContent <T>(string title, string description, ViewRegion region) where T : IViewContent { return(OpenContent <T>(title, description, region, () => { return (T)Activator.CreateInstance(typeof(T), true); })); }
/// <summary> /// Creates and/or opens the given view content in the specified region /// </summary> /// <typeparam name="T">The type implementing the <see cref="T:Maestro.Shared.UI.IViewContent"/> interface</typeparam> /// <param name="region">The desired region to show the view content in</param> /// <returns></returns> public T OpenContent <T>(ViewRegion region) where T : IViewContent { return(OpenContent <T>(null, null, region)); }
/// <summary> /// Creates and/or opens the given view content in the specified region /// </summary> /// <typeparam name="T">The type implementing the <see cref="T:Maestro.Shared.UI.IViewContent"/> interface</typeparam> /// <param name="region">The desired region to show the view content in</param> /// <param name="method">A method that will create the required view content the view content has not been created yet</param> /// <returns></returns> public T OpenContent <T>(ViewRegion region, CreateFunc <T> method) where T : IViewContent { return(OpenContent <T>(null, null, region, method)); }
/// <summary> /// Shows the content. /// </summary> /// <param name="vc">The vc.</param> /// <param name="region">The region.</param> public void ShowContent(IViewContent vc, ViewRegion region) { TabManager tm = ServiceManager.Instance.GetService<TabManager>(); DockContent content = new DockContent(); content.TabText = vc.Title; content.Text = vc.Title; content.ToolTipText = vc.Title; content.CloseButton = vc.CanClose; switch (region) { case ViewRegion.Bottom: content.DockAreas = DockAreas.DockBottom; break; case ViewRegion.Top: content.DockAreas = DockAreas.DockTop; break; case ViewRegion.Left: content.DockAreas = DockAreas.DockLeft; break; case ViewRegion.Right: content.DockAreas = DockAreas.DockRight; break; case ViewRegion.Document: content.DockAreas = DockAreas.Document; break; case ViewRegion.Floating: content.DockAreas = DockAreas.Float; break; } vc.TitleChanged += delegate(object sender, EventArgs e) { content.TabText = vc.Title; content.Text = vc.Title; content.ToolTipText = vc.Title; }; vc.ViewContentClosing += delegate(object sender, EventArgs e) { if(vc.CanClose) content.Close(); }; content.ClientSize = vc.ContentControl.Size; content.CloseButton = vc.CanClose; vc.ContentControl.Dock = DockStyle.Fill; content.Controls.Add(vc.ContentControl); if (vc is IConnectionDependentView) { tm.Register((IConnectionDependentView)vc); } if (region == ViewRegion.Dialog) { content.StartPosition = FormStartPosition.CenterParent; content.ShowDialog(); } else { content.Show(contentPanel); } }