public int CheckScheduleCount() { WCF.PlayerServiceClient client = new WCF.PlayerServiceClient(); try { using (OperationContextScope scope = new OperationContextScope(client.InnerChannel)) { SetHeader(scope); int result = client.CheckScheduleCount(); client.Close(); return result; } } catch (Exception exp) { MessageBox.Show(exp.Message); } return -1; }
public bool DownloadFile(string srcFile,string dstFile) { try { WCF.PlayerServiceClient client = new WCF.PlayerServiceClient(); using (OperationContextScope scope = new OperationContextScope(client.InnerChannel)) { SetHeader(scope); DlFileInfo dfinfo = new DlFileInfo(); dfinfo.Name = srcFile; dfinfo.Length = 1000000; dfinfo.StartPoint = 0; long filelen = -1; using (FileStream fstream = new FileStream(dstFile, FileMode.OpenOrCreate, FileAccess.Write)) { fstream.SetLength(0); while (dfinfo.StartPoint != filelen) { DlFileBuff buf = (client.DownloadFile(dfinfo)); if (buf == null) { throw new System.Exception("WCF File Download: Empty Buffer. It appears that file doesn't exist on server"); } int len = (int)(buf.CurrPoint - dfinfo.StartPoint); if (len > 0) { Byte[] barr = new Byte[4096]; fstream.Write(buf.BufStream, 0, len); /* while (buf.BufStream.Position <( len-1)) { int bufread = buf.BufStream.Read(barr, 0, 4096); fstream.Write(barr, 0, bufread); } */ } dfinfo.StartPoint = buf.CurrPoint; filelen = buf.FileSize; Application.DoEvents(); Application.DoEvents(); //Thread.Sleep(100); } client.Close(); } } } catch (Exception exp) { MessageBox.Show(exp.Message); return false; } return true; }
internal PlayElements.Schedule CheckSchedule(int i) { WCF.PlayerServiceClient client = new WCF.PlayerServiceClient(); try { using (OperationContextScope scope = new OperationContextScope(client.InnerChannel)) { SetHeader(scope); string xmlstr = client.DownloadSchedule(i); Schedule sche = ContentHelper.XMLStringToSchedule(xmlstr); return sche; } client.Close(); } catch (Exception exp) { MessageBox.Show(exp.Message); } return null; }