Posts

Showing posts from 2016

data-tech FaxMan,FaxMan Jr and interfax alternative for sending fax

Last couple of day i spend time on sending Fax in C#.
i just find out 2 service provider can send fax.

data-tech's FaxMan or FaxMan Jr
 http://www.data-tech.com/products/fax.aspx 

and 3rd party web api
https://www.interfax.net/en

data-tech Fax SDK is not working on windows 10 and interfax API is not free for sending fax.

You easily send fax using Faxcomlib. for details please check the sample.

https://code.msdn.microsoft.com/C-Send-Fax-using-fax-Modem-357aca81


Thank you.


Common T-SQL

Recently i have completed  online training program on T-SQL from Edx.
I just share in my blog that will cover all basic T-SQL.


-- Display all columns for all customers SELECT * FROM SalesLT.Customer; -- Display customer name fields SELECT Title, FirstName, MiddleName, LastName, Suffix FROM SalesLT.Customer; -- Display title and last name with phone number SELECT Salesperson, Title + ' ' + LastName AS CustomerName, Phone FROM SalesLT.Customer;


-- Customer Companies SELECT CAST(CustomerID AS varchar) + ': ' + CompanyName AS CustomerCompany FROM SalesLT.Customer; --Sales Order Revisions SELECT SalesOrderNumber + ' (' + STR(RevisionNumber, 1) + ')' AS OrderRevision, CONVERT(nvarchar(30), OrderDate, 102) AS OrderDate FROM SalesLT.SalesOrderHeader;

-- Get middle names if known SELECT FirstName + ' ' + ISNULL(MiddleName + ' ', '')+ LastName AS CustomerName FROM SalesLT.Customer;…

The function import 'DBEntities' cannot be executed because it is not mapped to a store function.

Image
1. Open EDMX in to Design Mode
2. Click Model Browser then type the Store procedure name on search and press Enter.
   It will highlight the store procedure.






3. If you already try to add this store procedure, then in some case it create Function when you have a return value on your SP.  other wise it will not create the function. remove all from function.


3. If your SP has no return type then you may can use a simple return type value like :
SELECT 1 as DefaultValue  if you already have return type then you don't need that.


4. Select the Store procedure from model browser-> right click -> Add function Import.



5. Check Complex and Click Get column Information


6. Click on Create New Complex type.







7. It will create Function and complex type for that Store Procedure.


Click OK and Build your application.

C# convert a DateTime to an int value

long dtosDateValue = long.Parse(DateTime.Now.ToString("yyyyMMdd")); long dtosTimeValue = long.Parse(DateTime.Now.ToString("HHmmss")); long dtosDateTimeValue = long.Parse(DateTime.Now.ToString("yyyyMMddHHmmss"));

Step by Step Windows 2012 R2 Remote Desktop Services Configure and Deployment

sql auto increment jump

You resolve your auto increment  jumping from this

http://stackoverflow.com/questions/14146148/identity-increment-is-jumping-in-sql-server-database
you can also resolve the issue into another way if you are using EDMX.
Before inserting data into table get the max id value from your table.

int maxAge = context.Persons.Max(p => p.Age);
Now add your increment number maxAge+1  
Map the id value with your table.

NB: You table Identity specification : Is Identity Will be no.

C# read word document and get specific data from document

// Reding all word document from a specific folder foreach (string file in Directory.EnumerateFiles(@"D:\", "*.doc")) { //string contents = File.ReadAllText(file); Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); object miss = System.Reflection.Missing.Value; object path = file; // @"D:\35339.doc"; object readOnly = true; Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss); string totaltext = ""; for (int i = 0; i < 2; i++) // i set value 2 you can change { totaltext += " \r\n " + docs.Paragraphs[i + 1].Range.Text.ToString(); } // Getting data after specific …

The calling thread cannot access this object because a different thread owns it.

On your do work

private void worker_DoWork(object sender, DoWorkEventArgs e) { this.Dispatcher.Invoke((Action) (() => { // Your code })); }

C# - Process.Start a ClickOnce application

Image
string publisher_name = "ABCPublisher"; string product_name = "FaxManFMFFileCreator"; var shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\",publisher_name, "\\", product_name, ".appref-ms"); Process.Start(shortcutName);



Devexpress report Export in to file

Test is the devexpress report and you can export in different format.


XtraReport report = new Test(); report.CreateDocument(); report.ExportToText("D:\\test1.doc");

C# kill specific process

//Threading for speacific printer otherwise it will open default Faxman printer Task.Factory.StartNew(() => { Thread.Sleep(5000); // Killing Process of default printer Process[] processes = Process.GetProcessesByName("FaxManFMFFileCreator"); foreach (var process in processes) { process.Kill(); } });

The calling thread must be STA, because many UI components require this.

// Create a thread Thread newWindowThread = new Thread(new ThreadStart(() => { // You can use your code // Create and show the Window FaxImageLoad obj = new FaxImageLoad(destination); obj.Show(); // Start the Dispatcher Processing System.Windows.Threading.Dispatcher.Run(); })); // Set the apartment state newWindowThread.SetApartmentState(ApartmentState.STA); // Make the thread a background thread newWindowThread.IsBackground = true; // Start the thread newWindowThread.Start();

Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.":null

Create app.config and modify it


<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> </configuration>


devexpress wpf gridcontrol disable context menu

Image
If you want to disable any context menu item in devexpress grid like this.



In XAML


<dxg:GridControl x:Name="grdProfile" Width="1070" Height="400" HorizontalAlignment="Left" VerticalAlignment="Top" AutoGenerateColumns="None" ItemsSource="{Binding CusHisViewRefillHistoryList}" SelectedItem="{Binding SelectedCusHisViewRefillHistory}"> <dxg:GridControl.Columns> <dxg:GridColumn Width="100" Binding="{Binding RxNo}" Header="Rx #" /> <dxg:GridColumn Width="70" Binding="{Binding PhInitials}" Header="Ph. Initials" /> …