コード例 #1
0
 internal static extern void EM_Sharing_Share(ref ShareData data);
コード例 #2
0
 private static extern void _Share(ref ShareData data);
コード例 #3
0
ファイル: BaseShares.cs プロジェクト: thomasr3/MediaPortal-1
        protected void LoadSettings(string section, string defaultSharePath)
        {
            selectedSection = section;
            using (Settings xmlreader = new MPSettings())
            {
                string defaultShare = xmlreader.GetValueAsString(section, "default", "");
                RememberLastFolder    = xmlreader.GetValueAsBool(section, "rememberlastfolder", false);
                AddOpticalDiskDrives  = xmlreader.GetValueAsBool(section, "AddOpticalDiskDrives", true);
                SwitchRemovableDrives = xmlreader.GetValueAsBool(section, "SwitchRemovableDrives", true);

                for (int index = 0; index < MaximumShares; index++)
                {
                    string shareName = String.Format("sharename{0}", index);
                    string sharePath = String.Format("sharepath{0}", index);
                    string sharePin  = String.Format("pincode{0}", index);

                    string shareType       = String.Format("sharetype{0}", index);
                    string shareServer     = String.Format("shareserver{0}", index);
                    string shareLogin      = String.Format("sharelogin{0}", index);
                    string sharePwd        = String.Format("sharepassword{0}", index);
                    string sharePort       = String.Format("shareport{0}", index);
                    string shareRemotePath = String.Format("shareremotepath{0}", index);
                    string shareViewPath   = String.Format("shareview{0}", index);

                    string shareNameData = xmlreader.GetValueAsString(section, shareName, "");
                    string sharePathData = xmlreader.GetValueAsString(section, sharePath, "");
                    string sharePinData  = Util.Utils.DecryptPin(xmlreader.GetValueAsString(section, sharePin, ""));

                    // provide default shares
                    if (index == 0 && shareNameData == string.Empty)
                    {
                        shareNameData = VirtualDirectory.GetShareNameDefault(defaultSharePath);
                        sharePathData = defaultSharePath;
                        sharePinData  = string.Empty;

                        AddStaticShares(DriveType.DVD, "DVD");
                    }

                    bool   shareTypeData       = xmlreader.GetValueAsBool(section, shareType, false);
                    string shareServerData     = xmlreader.GetValueAsString(section, shareServer, "");
                    string shareLoginData      = xmlreader.GetValueAsString(section, shareLogin, "");
                    string sharePwdData        = xmlreader.GetValueAsString(section, sharePwd, "");
                    int    sharePortData       = xmlreader.GetValueAsInt(section, sharePort, 21);
                    string shareRemotePathData = xmlreader.GetValueAsString(section, shareRemotePath, "/");
                    int    shareLayout         = xmlreader.GetValueAsInt(section, shareViewPath,
                                                                         (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List);

                    // For Music Shares, we can indicate, if we want to scan them every time
                    bool shareScanData = false;
                    if (section == "music" || section == "movies")
                    {
                        string shareScan = String.Format("sharescan{0}", index);
                        shareScanData = xmlreader.GetValueAsBool(section, shareScan, true);
                    }
                    // For Movies Shares, we can indicate, if we want to create thumbs
                    bool thumbs        = true;
                    bool folderIsMovie = false;

                    if (section == "movies")
                    {
                        string thumbsCreate = String.Format("videothumbscreate{0}", index);
                        thumbs = xmlreader.GetValueAsBool(section, thumbsCreate, true);
                        string eachFolderIsMovie = String.Format("eachfolderismovie{0}", index);
                        folderIsMovie = xmlreader.GetValueAsBool(section, eachFolderIsMovie, false);
                    }

                    if (!String.IsNullOrEmpty(shareNameData))
                    {
                        ShareData newShare = new ShareData(shareNameData, sharePathData, sharePinData, thumbs);
                        newShare.IsRemote      = shareTypeData;
                        newShare.Server        = shareServerData;
                        newShare.LoginName     = shareLoginData;
                        newShare.PassWord      = sharePwdData;
                        newShare.Port          = sharePortData;
                        newShare.RemoteFolder  = shareRemotePathData;
                        newShare.DefaultLayout = (Layout)shareLayout;

                        if (section == "music" || section == "movies")
                        {
                            newShare.ScanShare = shareScanData;
                        }
                        // ThumbsCreate
                        if (section == "movies")
                        {
                            newShare.CreateThumbs      = thumbs;
                            newShare.EachFolderIsMovie = folderIsMovie;
                        }
                        AddShare(newShare, shareNameData.Equals(defaultShare));
                    }
                }
                if (AddOpticalDiskDrives)
                {
                    AddStaticShares(DriveType.DVD, "DVD");
                }
                if (section == "movies")
                {
                    sharesListView.Columns[2].Width = 210;
                    if (!sharesListView.Columns.Contains(columnHeader4))
                    {
                        sharesListView.Columns.Add(columnHeader4);
                    }
                    sharesListView.Columns[3].Width = 60;
                }
                else
                {
                    sharesListView.Columns[2].Width = 270;
                    if (sharesListView.Columns.Contains(columnHeader4))
                    {
                        sharesListView.Columns.Remove(columnHeader4);
                    }
                }
            }
        }
コード例 #4
0
ファイル: BaseShares.cs プロジェクト: thomasr3/MediaPortal-1
        protected void SaveSettings(string section)
        {
            if (AddOpticalDiskDrives)
            {
                AddStaticShares(DriveType.DVD, "DVD");
            }

            using (Settings xmlwriter = new MPSettings())
            {
                string defaultShare = string.Empty;

                for (int index = 0; index < MaximumShares; index++)
                {
                    string shareName       = String.Format("sharename{0}", index);
                    string sharePath       = String.Format("sharepath{0}", index);
                    string sharePin        = String.Format("pincode{0}", index);
                    string shareType       = String.Format("sharetype{0}", index);
                    string shareServer     = String.Format("shareserver{0}", index);
                    string shareLogin      = String.Format("sharelogin{0}", index);
                    string sharePwd        = String.Format("sharepassword{0}", index);
                    string sharePort       = String.Format("shareport{0}", index);
                    string shareRemotePath = String.Format("shareremotepath{0}", index);
                    string shareViewPath   = String.Format("shareview{0}", index);

                    xmlwriter.RemoveEntry(section, shareName);
                    xmlwriter.RemoveEntry(section, sharePath);
                    xmlwriter.RemoveEntry(section, sharePin);
                    xmlwriter.RemoveEntry(section, shareType);
                    xmlwriter.RemoveEntry(section, shareServer);
                    xmlwriter.RemoveEntry(section, shareLogin);
                    xmlwriter.RemoveEntry(section, sharePwd);
                    xmlwriter.RemoveEntry(section, sharePort);
                    xmlwriter.RemoveEntry(section, shareRemotePath);
                    xmlwriter.RemoveEntry(section, shareViewPath);

                    if (section == "music" || section == "movies")
                    {
                        string shareScan = String.Format("sharescan{0}", index);
                        xmlwriter.RemoveEntry(section, shareScan);
                    }

                    if (section == "movies")
                    {
                        string thumbs = String.Format("videothumbscreate{0}", index);
                        xmlwriter.RemoveEntry(section, thumbs);

                        string movieFolder = String.Format("eachfolderismovie{0}", index);
                        xmlwriter.RemoveEntry(section, movieFolder);
                    }

                    string shareNameData       = string.Empty;
                    string sharePathData       = string.Empty;
                    string sharePinData        = string.Empty;
                    bool   shareTypeData       = false;
                    string shareServerData     = string.Empty;
                    string shareLoginData      = string.Empty;
                    string sharePwdData        = string.Empty;
                    int    sharePortData       = 21;
                    string shareRemotePathData = string.Empty;
                    int    shareLayout         = (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List;
                    bool   shareScanData       = false;
                    //ThumbsCreate (default true)
                    bool thumbsCreate  = true;
                    bool folderIsMovie = false;

                    if (CurrentShares != null && CurrentShares.Count > index)
                    {
                        ShareData shareData = CurrentShares[index].Tag as ShareData;

                        if (shareData != null && !String.IsNullOrEmpty(shareData.Name))
                        {
                            shareNameData       = shareData.Name;
                            sharePathData       = shareData.Folder;
                            sharePinData        = shareData.PinCode;
                            shareTypeData       = shareData.IsRemote;
                            shareServerData     = shareData.Server;
                            shareLoginData      = shareData.LoginName;
                            sharePwdData        = shareData.PassWord;
                            sharePortData       = shareData.Port;
                            shareRemotePathData = shareData.RemoteFolder;
                            shareLayout         = (int)shareData.DefaultLayout;
                            shareScanData       = shareData.ScanShare;
                            // ThumbsCreate
                            thumbsCreate  = shareData.CreateThumbs;
                            folderIsMovie = shareData.EachFolderIsMovie;

                            if (CurrentShares[index] == DefaultShare)
                            {
                                defaultShare = shareNameData;
                            }

                            xmlwriter.SetValue(section, shareName, shareNameData);
                            xmlwriter.SetValue(section, sharePath, sharePathData);
                            xmlwriter.SetValue(section, sharePin, Util.Utils.EncryptPin(sharePinData));
                            xmlwriter.SetValueAsBool(section, shareType, shareTypeData);
                            xmlwriter.SetValue(section, shareServer, shareServerData);
                            xmlwriter.SetValue(section, shareLogin, shareLoginData);
                            xmlwriter.SetValue(section, sharePwd, sharePwdData);
                            xmlwriter.SetValue(section, sharePort, sharePortData.ToString());
                            xmlwriter.SetValue(section, shareRemotePath, shareRemotePathData);
                            xmlwriter.SetValue(section, shareViewPath, shareLayout);

                            if (section == "music" || section == "movies")
                            {
                                string shareScan = String.Format("sharescan{0}", index);
                                xmlwriter.SetValueAsBool(section, shareScan, shareScanData);
                            }
                            //ThumbsCreate
                            if (section == "movies")
                            {
                                string thumbs = String.Format("videothumbscreate{0}", index);
                                xmlwriter.SetValueAsBool(section, thumbs, thumbsCreate);

                                string folderMovie = String.Format("eachfolderismovie{0}", index);
                                xmlwriter.SetValueAsBool(section, folderMovie, folderIsMovie);
                            }
                        }
                    }
                }
                xmlwriter.SetValue(section, "default", defaultShare);
                xmlwriter.SetValueAsBool(section, "rememberlastfolder", RememberLastFolder);
                xmlwriter.SetValueAsBool(section, "AddOpticalDiskDrives", AddOpticalDiskDrives);
                xmlwriter.SetValueAsBool(section, "SwitchRemovableDrives", SwitchRemovableDrives);
            }
        }
コード例 #5
0
ファイル: MainWindow.cs プロジェクト: fenriv/NetOpen
        /// <summary>
        /// Получает список открытых ресурсов указанного IP, и сохраняет их в структуре
        /// </summary>
        /// <param name="CurIP"></param>
        public void CollectShares(object CurIP)
        {
            string server = (string)CurIP;
            bool accesible = true;
            int count=0;
            ShareData se = new ShareData();
            bool HasRes = false;
            se.ShareAdress = new List<string>();
            se.ShareName = new List<string>();

            if (server != null)
            {
                ShareCollection shi = ShareCollection.GetShares(server);
                System.IO.FileSystemInfo[] AllD=new FileSystemInfo[1];
                if (shi != null)
                {
                    foreach (Share si in shi)
                    {
                        accesible = true;
                        if (si.ShareType.ToString() == "Disk")
                        {
                            HasRes = true;
                            //Определяем доступны ли росшары
                            if (si.IsFileSystem)
                            {
                                count++;
                                try
                                {
                                    System.IO.DirectoryInfo d = si.Root;
                                    //System.IO.DirectoryInfo[] Flds = d.GetDirectories();
                                    AllD = null;
                                    AllD = d.GetFileSystemInfos();
                                    //d.Attributes=FileAttributes.
                                }
                                catch (Exception)
                                {
                                    accesible = false;
                                    count--;
                                }
                                if (accesible)
                                {
                                    se.ShareName.Add(si.NetName);
                                    se.ShareAdress.Add(si.ToString());
                                    se.NearFilesFolders = AllD;
                                    //MessageBox.Show(si.NetName + " " + si.ToString());
                                }
                            }
                        }
                    }
                    if (count > 0)
                    {
                        lock (locker) ShareList.Add(se);
                        ListViewItem[] fi=pcList.Items.Find(server, true);
                        foreach (ListViewItem it in fi)
                        {
                            it.ImageIndex = 13;
                        }
                    }
                }
            }
            if ((ThrShAc + 1) <numb) GetShStat.Text = "Полный список всех ресурсов в процессе создания..";
            else GetShStat.Text = "Полный список всех ресурсов создан.";
            thrsh.Text = Convert.ToString(ShareThrLst.Count-1);
            lock (locker) { ShareThrLst.Remove(Thread.CurrentThread); ThrShAc++;}
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: kwoonfai/FTDownloader
        private void button11_Click(object sender, EventArgs e)
        {
            ShareData dur12 = new ShareData("234871");
            ShareData dur9 = new ShareData("234871");
            string url12 = @"http://markets.ft.com/RESEARCH/Remote/UK/InteractiveChart/DrawInteractiveChart?symbol=234871&options={""StartDate"":""7/27/2013"",""EndDate"":""7/27/2014"",""LowerIndicator"":[],""UpperIndicator"":[],""Overlay"":[0,1,2],""ChartStyle"":3,""ChartScale"":1,""CursorStyle"":1,""Interval"":6,""Duration"":12,""Comparison"":[],""PortfolioName"":null,""Width"":950,""Height"":400,""ActiveTool"":null}";
            string url9 = @"http://markets.ft.com/RESEARCH/Remote/UK/InteractiveChart/DrawInteractiveChart?symbol=234871&options={""StartDate"":""7/27/2013"",""EndDate"":""7/27/2014"",""LowerIndicator"":[],""UpperIndicator"":[],""Overlay"":[0,1,2],""ChartStyle"":3,""ChartScale"":1,""CursorStyle"":1,""Interval"":6,""Duration"":9,""Comparison"":[],""PortfolioName"":null,""Width"":950,""Height"":400,""ActiveTool"":null}";

            WebClient wc = new WebClient();
            string content12 = wc.DownloadString(url12);
            string content9 = wc.DownloadString(url9);

            dur12.LoadJSONData(content12);
            dur9.LoadJSONData(content9);

            dur12.DumpData();
            dur9.DumpData();
        }
コード例 #7
0
ファイル: AppendData.cs プロジェクト: kwoonfai/FTDownloader
        void JSONIntoShareData(string id, string filecontent, ShareData sd)
        {
            Match chartpointmatch = Regex.Match(filecontent, @"WSOD.InteractiveChart.SetChartPoints\((.+?)\)");
            if (chartpointmatch.Success == false)
            {
                ErrorJSON("no datapoints in " + id);
                return;
            }
            string outerdata = chartpointmatch.Groups[1].Value;
            bool success;

            MatchCollection mm = Regex.Matches(outerdata, @"\\""(.+?)}");
            foreach (Match mmm in mm)
            {
                string extractedline = mmm.Groups[1].Value;
                MatchCollection line = Regex.Matches(extractedline, @":\\""(.+?)\\""");

                string date = line[0].Groups[1].Value;
                string open = line[2].Groups[1].Value; // [1] is UK date, [2] is descriptive date
                string high = line[3].Groups[1].Value;
                string low = line[4].Groups[1].Value;
                string close = line[5].Groups[1].Value; // is adjusted
                string volume = line[6].Groups[1].Value;
                success = sd.AddDataPoint(date, open, high, low, close, volume);
                if (success == false)
                    ErrorJSON("duplicate data " + date + " " + sd.symbol);
            }

            mm = Regex.Matches(filecontent, @"~overlayEvent_~(.+?)\.replace(.+?)\.replace");
            foreach (Match mmm in mm)
            {
                Match datematch = Regex.Match(mmm.Groups[2].Value, @"~overlayDate_~\\u003e(.+?)\\u003c");
                string date = datematch.Groups[1].Value;

                Match opmatch = Regex.Match(mmm.Groups[2].Value, @"~header_~\\u003e(.+?)\\u003c");
                string op = opmatch.Groups[1].Value;

                //MatchCollection values = Regex.Matches(mmm.Groups[1].Value, @"\\u003e(.+?)\.\\u003c"); // \u003e\u003cdiv\u003e1.00 in PCT.\u003c, \u003e\u003cdiv\u003e0.3812 in USD.\u003c

                // earnings
                // split
                // dividend
                // stock dividend
                MatchCollection values;
                if (op == "Earnings" || op == "Split") values = Regex.Matches(mmm.Groups[1].Value, @"\\u003e(.+?)\\u003c");
                else values = Regex.Matches(mmm.Groups[1].Value, @"\\u003e(.+?)\.\\u003c");

                foreach (Match value in values)
                {
                    string opext = value.Groups[1].Value;
                    opext = opext.Replace(@"\u003c", "");
                    opext = opext.Replace(@"\u003e", "");
                    opext = opext.Replace(@"div", "");

                    string[] splits = opext.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    if (splits.Length == 3) // ex 1.00 in PCT.
                    {
                        if (splits[2].IndexOf("PCT") != -1)
                            success = sd.AddEvent(date, op, splits[0], "PCT");
                        else
                            success = sd.AddEvent(date, op, splits[0], splits[2].Replace(".", ""));
                    }
                    else // no currency - earnings - probably in USD
                        success = sd.AddEvent(date, op, splits[0], "N/A");

                    if (success == false)
                        ErrorJSON("duplicate event " + date + " " + sd.symbol);
                }
            }
        }
コード例 #8
0
ファイル: BaseShares.cs プロジェクト: cmendozac/MediaPortal-1
    protected void AddShare(ShareData shareData, bool check)
    {
      ListViewItem listItem =
        new ListViewItem(new string[]
                           {
                             shareData.Name, 
                             shareData.HasPinCode ? "Yes" : "No", 
                             shareData.Folder,
                             shareData.CreateThumbs ? "Yes" : "No", 
                             shareData.ActiveConnection ? "Yes" : "No"
                           });

      if (shareData.IsRemote)
      {
        listItem.SubItems[2].Text = String.Format("ftp://{0}:{1}{2}", shareData.Server, shareData.Port,
                                                  shareData.RemoteFolder);
      }
      listItem.Tag = shareData;
      listItem.Checked = check;
      if (check)
      {
        currentlyCheckedItem = listItem;
      }

      if (!Util.Utils.IsNetwork(shareData.Folder))
      {
        listItem.SubItems[4].Text = string.Empty;
      }
      else
      {
        using (Profile.Settings xmlreader = new MPSettings())
        {
          listItem.SubItems[4].Text = xmlreader.GetValueAsString("macAddress", Util.Utils.GetServerNameFromUNCPath(shareData.Folder), null);
        }
      }

      sharesListView.Items.Add(listItem);
    }
コード例 #9
0
ファイル: AppendData.cs プロジェクト: kwoonfai/FTDownloader
        // load existing processed data
        // compare pearson signature
        // look for status.txt - Append or FirstDate operation / Append.txt, FirstDate.txt
        // load JSONTemp data
        // save in Compiled dir
        public void ProcessAppend(string id)
        {
            string dir = "compiled\\" + id + "\\";
            string datafile = dir + id + ".txt";
            string eventf = dir + id + ".events.txt";
            if (!File.Exists(datafile) || !File.Exists(eventf))
            {
                ErrorAppend("ProcessIDAppend: data or event file does not exist " + id); // should be done by AddID / QueueRestart
                return;
            }

            // status.txt
            string jsontemp = "JSONTemp\\" + id + "\\";
            string statusf = jsontemp + "status.txt";
            if (!File.Exists(statusf))
            {
                ErrorAppend("ProcessIDAppend: status file does not exist");
                return;
            }

            if (File.ReadAllText(statusf) == "Ok") return;
            if (File.ReadAllText(statusf) == "Skip") return;

            bool specialcase = false;
            if (File.ReadAllText(statusf).IndexOf("JSON") != -1 && !File.Exists(dir + id + ".0.txt"))
            {
                specialcase = true;
                File.WriteAllText(statusf, "Append");
            }

            string whattodo = File.ReadAllText(statusf);
            if (whattodo.IndexOf("Append") == -1 && specialcase == false) return;

            // append.txt
            string append = jsontemp + "Append.txt";
            if (!File.Exists(append))
            {
                Console.WriteLine("append.txt data file not found - " + id);
                return;
            }

            // load yahoo and get last updated date
            ShareData yahoosharedata = new ShareData(id);
            yahoosharedata.LoadYahooData(File.ReadAllText(datafile), File.ReadAllText(eventf));
            string yahoolastline = yahoosharedata[0]; // [0] is latest data
            string[] yahoosplit = yahoolastline.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            string yahoolastdate = yahoosplit[0];

            //if (id != "205778" && yahoolastdate == msftdate)
            //    return;

            // load append data
            ShareData appenddata = new ShareData(id);
            string appendlastline = "";

            appenddata.LoadJSONData(File.ReadAllText(append));
            appenddata.Sort();

            if (yahoolastline != appenddata[yahoolastdate])
            {
                // dividend, split occured
                ErrorAppend("dividend/split occured " + id);
                QueueRestart(id);
                return;
            }

            // look for pearson signature
            appendlastline = appenddata[0]; // [0] latest
            if (id != "234871")
            {
                string[] appendsplit = appendlastline.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string appendlastdate = appendsplit[0];
                if (appendlastline == m_pearson[appendlastdate])
                {
                    // delisted
                    ErrorAppend("delisted - " + id);
                    return;
                }
            }

            // combine
            if (yahoosharedata.LoadJSONData(File.ReadAllText(append)) == 0)
            {
                //ErrorAppend("no datapoints " + id);
                File.WriteAllText(statusf, "Ok");
                return;
            }
            File.WriteAllText(statusf, "Ok");
            yahoosharedata.Save();

            if (FinishedProcessingEvent != null)
                FinishedProcessingEvent(id);
        }
コード例 #10
0
ファイル: AppendData.cs プロジェクト: kwoonfai/FTDownloader
        public void ProcessJSON(string id)
        {
            string dir = "JSONTemp\\" + id + "\\";
            string statusf = dir + "status.txt";

            if (!File.Exists(statusf)) return;
            string content = File.ReadAllText(statusf);
            if (content.IndexOf("JSON") == -1) return;

            int count = 0;
            ShareData sd = new ShareData(id);
            for (; ; )
            {
                string path = dir + id + "." + count + ".txt";
                if (!System.IO.File.Exists(path))
                    break;
                JSONIntoShareData(id, File.ReadAllText(path), sd);
                count++;
            }
            sd.Save();
            File.WriteAllText(statusf, "Ok");
            if (FinishedProcessingEvent != null)
                FinishedProcessingEvent(id);
        }
コード例 #11
0
 public void Add(ShareData shareData)
 {
     _addedDataSubject.OnNext(shareData);
     _cacheService.SaveDataAsync(CacheFileName, _sharedData, CancellationToken.None);
 }
コード例 #12
0
 private void AddShareData(ShareData data)
 {
     _sharedData.Add(data);
 }
コード例 #13
0
ファイル: Form1.cs プロジェクト: kwoonfai/FTDownloader
 private void button12_Click(object sender, EventArgs e)
 {
     ShareData sd = new ShareData("76609819"); // el pollo // 76579297 sasbadi // 90481 empty russian
 }
コード例 #14
0
    protected void AddShare(ShareData shareData, bool check)
    {
      ListViewItem listItem =
        new ListViewItem(new string[]
                           {
                             shareData.Name, 
                             shareData.HasPinCode ? "Yes" : "No", 
                             shareData.Folder,
                             shareData.CreateThumbs ? "Yes" : "No", 
                             shareData.ActiveConnection ? "Yes" : "No"
                           });

      if (shareData.IsRemote)
      {
        listItem.SubItems[2].Text = String.Format("ftp://{0}:{1}{2}", shareData.Server, shareData.Port,
                                                  shareData.RemoteFolder);
      }
      listItem.Tag = shareData;
      listItem.Checked = check;
      if (check)
      {
        currentlyCheckedItem = listItem;
      }

      sharesListView.Items.Add(listItem);
    }
コード例 #15
0
    private void addButton_Click(object sender, EventArgs e)
    {
      EditShareForm editShare = new EditShareForm();

      DialogResult dialogResult = editShare.ShowDialog(this);

      if (dialogResult == DialogResult.OK)
      {
        ShareData shareData = new ShareData(editShare.ShareName, editShare.Folder, editShare.PinCode);
        shareData.IsRemote = editShare.IsRemote;
        shareData.Server = editShare.Server;
        shareData.LoginName = editShare.LoginName;
        shareData.PassWord = editShare.PassWord;
        shareData.Port = editShare.Port;
        shareData.ActiveConnection = editShare.ActiveConnection;
        shareData.RemoteFolder = editShare.RemoteFolder;
        shareData.DefaultLayout = ProperLayoutFromDefault(editShare.View);

        AddShare(shareData, currentlyCheckedItem == null);
      }
    }
コード例 #16
0
ファイル: BaseShares.cs プロジェクト: cmendozac/MediaPortal-1
    private void addButton_Click(object sender, EventArgs e)
    {
      EditShareForm editShare = new EditShareForm();
      
      if (selectedSection == "movies")
      {
        editShare.labelCreateThumbs.Visible = true;
        editShare.cbCreateThumbs.Visible = true;
        editShare.CreateThumbs = true;

        editShare.cbEachFolderIsMovie.Visible = true;
        editShare.EachFolderIsMovie = false;
      }
      else
      {
        editShare.labelCreateThumbs.Visible = false;
        editShare.cbCreateThumbs.Visible = false;
        editShare.CreateThumbs = true;

        editShare.cbEachFolderIsMovie.Visible = false;
        editShare.EachFolderIsMovie = false;
      }

      editShare.DonotFolderJpgIfPin = true;
      DialogResult dialogResult = editShare.ShowDialog(this);

      if (dialogResult == DialogResult.OK)
      {
        ShareData shareData = new ShareData(editShare.ShareName, editShare.Folder, editShare.PinCode, editShare.CreateThumbs);
        shareData.IsRemote = editShare.IsRemote;
        shareData.Server = editShare.Server;
        shareData.LoginName = editShare.LoginName;
        shareData.PassWord = editShare.PassWord;
        shareData.Port = editShare.Port;
        shareData.ActiveConnection = editShare.ActiveConnection;
        shareData.RemoteFolder = editShare.RemoteFolder;
        shareData.DefaultLayout = ProperLayoutFromDefault(editShare.View);
        shareData.EnableWakeOnLan = editShare.EnableWakeOnLan;
        shareData.DonotFolderJpgIfPin = editShare.DonotFolderJpgIfPin;

        //CreateThumbs
        if (selectedSection == "movies")
        {
          //int drivetype = Util.Utils.getDriveType(shareData.Folder);
          //if (drivetype != 2 && 
          //    drivetype != 5)
          //{
          shareData.CreateThumbs = editShare.CreateThumbs;
          shareData.EachFolderIsMovie = editShare.EachFolderIsMovie;
          //}
          //else
          //{
          //  shareData.CreateThumbs = false;
          //}
        }
        AddShare(shareData, currentlyCheckedItem == null);
      }
    }
コード例 #17
0
    protected void LoadSettings(string section, string defaultSharePath)
    {
      using (Settings xmlreader = new MPSettings())
      {
        string defaultShare = xmlreader.GetValueAsString(section, "default", "");
        RememberLastFolder = xmlreader.GetValueAsBool(section, "rememberlastfolder", false);
        AddOpticalDiskDrives = xmlreader.GetValueAsBool(section, "AddOpticalDiskDrives", true);
        SwitchRemovableDrives = xmlreader.GetValueAsBool(section, "SwitchRemovableDrives", true);

        for (int index = 0; index < MaximumShares; index++)
        {
          string shareName = String.Format("sharename{0}", index);
          string sharePath = String.Format("sharepath{0}", index);
          string sharePin = String.Format("pincode{0}", index);

          string shareType = String.Format("sharetype{0}", index);
          string shareServer = String.Format("shareserver{0}", index);
          string shareLogin = String.Format("sharelogin{0}", index);
          string sharePwd = String.Format("sharepassword{0}", index);
          string sharePort = String.Format("shareport{0}", index);
          string shareRemotePath = String.Format("shareremotepath{0}", index);
          string shareViewPath = String.Format("shareview{0}", index);

          string shareNameData = xmlreader.GetValueAsString(section, shareName, "");
          string sharePathData = xmlreader.GetValueAsString(section, sharePath, "");
          string sharePinData = Util.Utils.DecryptPin(xmlreader.GetValueAsString(section, sharePin, ""));

          // provide default shares
          if (index == 0 && shareNameData == string.Empty)
          {
            shareNameData = VirtualDirectory.GetShareNameDefault(defaultSharePath);
            sharePathData = defaultSharePath;
            sharePinData = string.Empty;

            AddStaticShares(DriveType.DVD, "DVD");
          }

          bool shareTypeData = xmlreader.GetValueAsBool(section, shareType, false);
          string shareServerData = xmlreader.GetValueAsString(section, shareServer, "");
          string shareLoginData = xmlreader.GetValueAsString(section, shareLogin, "");
          string sharePwdData = xmlreader.GetValueAsString(section, sharePwd, "");
          int sharePortData = xmlreader.GetValueAsInt(section, sharePort, 21);
          string shareRemotePathData = xmlreader.GetValueAsString(section, shareRemotePath, "/");
          int shareLayout = xmlreader.GetValueAsInt(section, shareViewPath,
                                                    (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List);

          // For Music Shares, we can indicate, if we want to scan them every time
          bool shareScanData = false;
          if (section == "music" || section == "movies")
          {
            string shareScan = String.Format("sharescan{0}", index);
            shareScanData = xmlreader.GetValueAsBool(section, shareScan, true);
          }

          if (!String.IsNullOrEmpty(shareNameData))
          {
            ShareData newShare = new ShareData(shareNameData, sharePathData, sharePinData);
            newShare.IsRemote = shareTypeData;
            newShare.Server = shareServerData;
            newShare.LoginName = shareLoginData;
            newShare.PassWord = sharePwdData;
            newShare.Port = sharePortData;
            newShare.RemoteFolder = shareRemotePathData;
            newShare.DefaultLayout = (Layout)shareLayout;

            if (section == "music" || section == "movies")
            {
              newShare.ScanShare = shareScanData;
            }

            AddShare(newShare, shareNameData.Equals(defaultShare));
          }
        }
        if (AddOpticalDiskDrives)
        {
          AddStaticShares(DriveType.DVD, "DVD");
        }
      }
    }
コード例 #18
0
ファイル: BaseShares.cs プロジェクト: cmendozac/MediaPortal-1
    protected void LoadSettings(string section, string defaultSharePath)
    {
      selectedSection = section;
      using (Settings xmlreader = new MPSettings())
      {
        string defaultShare = xmlreader.GetValueAsString(section, "default", "");
        RememberLastFolder = xmlreader.GetValueAsBool(section, "rememberlastfolder", false);
        AddOpticalDiskDrives = xmlreader.GetValueAsBool(section, "AddOpticalDiskDrives", true);
        SwitchRemovableDrives = xmlreader.GetValueAsBool(section, "SwitchRemovableDrives", true);

        for (int index = 0; index < MaximumShares; index++)
        {
          string shareName = String.Format("sharename{0}", index);
          string sharePath = String.Format("sharepath{0}", index);
          string sharePin = String.Format("pincode{0}", index);

          string shareType = String.Format("sharetype{0}", index);
          string shareServer = String.Format("shareserver{0}", index);
          string shareLogin = String.Format("sharelogin{0}", index);
          string sharePwd = String.Format("sharepassword{0}", index);
          string sharePort = String.Format("shareport{0}", index);
          string shareRemotePath = String.Format("shareremotepath{0}", index);
          string shareViewPath = String.Format("shareview{0}", index);
          string sharewakeonlan = String.Format("sharewakeonlan{0}", index);
          string sharedonotfolderjpgifpin = String.Format("sharedonotfolderjpgifpin{0}", index);
          
          string shareNameData = xmlreader.GetValueAsString(section, shareName, "");
          string sharePathData = xmlreader.GetValueAsString(section, sharePath, "");
          string sharePinData = Util.Utils.DecryptPassword(xmlreader.GetValueAsString(section, sharePin, ""));

          // provide default shares
          if (index == 0 && shareNameData == string.Empty)
          {
            shareNameData = VirtualDirectory.GetShareNameDefault(defaultSharePath);
            sharePathData = defaultSharePath;
            sharePinData = string.Empty;

            AddStaticShares(DriveType.DVD, "DVD");
          }

          bool shareTypeData = xmlreader.GetValueAsBool(section, shareType, false);
          string shareServerData = xmlreader.GetValueAsString(section, shareServer, "");
          string shareLoginData = xmlreader.GetValueAsString(section, shareLogin, "");
          string sharePwdData = Util.Utils.DecryptPassword(xmlreader.GetValueAsString(section, sharePwd, ""));
          int sharePortData = xmlreader.GetValueAsInt(section, sharePort, 21);
          string shareRemotePathData = xmlreader.GetValueAsString(section, shareRemotePath, "/");
          int shareLayout = xmlreader.GetValueAsInt(section, shareViewPath,
                                                    (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List);

          bool shareWakeOnLan = xmlreader.GetValueAsBool(section, sharewakeonlan, false);
          bool sharedonotFolderJpgIfPin = xmlreader.GetValueAsBool(section, sharedonotfolderjpgifpin, true);
          
          // For Music Shares, we can indicate, if we want to scan them every time
          bool shareScanData = false;
          if (section == "music" || section == "movies")
          {
            string shareScan = String.Format("sharescan{0}", index);
            shareScanData = xmlreader.GetValueAsBool(section, shareScan, true);
          }
          // For Movies Shares, we can indicate, if we want to create thumbs
          bool thumbs = true;
          bool folderIsMovie = false;

          if (section == "movies")
          {
            string thumbsCreate = String.Format("videothumbscreate{0}", index);
            thumbs = xmlreader.GetValueAsBool(section, thumbsCreate, true);
            string eachFolderIsMovie = String.Format("eachfolderismovie{0}", index);
            folderIsMovie = xmlreader.GetValueAsBool(section, eachFolderIsMovie, false);
          }

          if (!String.IsNullOrEmpty(shareNameData))
          {
            ShareData newShare = new ShareData(shareNameData, sharePathData, sharePinData, thumbs);
            newShare.IsRemote = shareTypeData;
            newShare.Server = shareServerData;
            newShare.LoginName = shareLoginData;
            newShare.PassWord = sharePwdData;
            newShare.Port = sharePortData;
            newShare.RemoteFolder = shareRemotePathData;
            newShare.DefaultLayout = (Layout)shareLayout;
            newShare.EnableWakeOnLan = shareWakeOnLan;
            newShare.DonotFolderJpgIfPin = sharedonotFolderJpgIfPin;
            
            if (section == "music" || section == "movies")
            {
              newShare.ScanShare = shareScanData;
            }
            // ThumbsCreate
            if (section == "movies")
            {
              newShare.CreateThumbs = thumbs;
              newShare.EachFolderIsMovie = folderIsMovie;
            }
            AddShare(newShare, shareNameData.Equals(defaultShare));
          }
        }
        if (AddOpticalDiskDrives)
        {
          AddStaticShares(DriveType.DVD, "DVD");
        }
        if (section == "movies")
        {
          sharesListView.Columns[2].Width = 210;
          if (!sharesListView.Columns.Contains(columnHeader4))
               sharesListView.Columns.Add(columnHeader4);
          sharesListView.Columns[3].Width = 60;
        }
        else
        {
          sharesListView.Columns[3].Width = 0;
         // if (sharesListView.Columns.Contains(columnHeader4))
         // sharesListView.Columns.Remove(columnHeader4);
        }
      }
    }
コード例 #19
0
ファイル: BaseShares.cs プロジェクト: thomasr3/MediaPortal-1
        private void editButton_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem selectedItem in sharesListView.SelectedItems)
            {
                ShareData shareData = selectedItem.Tag as ShareData;

                if (shareData != null)
                {
                    EditShareForm editShare = new EditShareForm();

                    editShare.ShareName = shareData.Name;
                    editShare.PinCode   = shareData.PinCode;
                    editShare.Folder    = shareData.Folder;

                    editShare.IsRemote         = shareData.IsRemote;
                    editShare.Server           = shareData.Server;
                    editShare.Port             = shareData.Port;
                    editShare.ActiveConnection = shareData.ActiveConnection;
                    editShare.LoginName        = shareData.LoginName;
                    editShare.PassWord         = shareData.PassWord;
                    editShare.RemoteFolder     = shareData.RemoteFolder;
                    editShare.View             = ProperDefaultFromLayout(shareData.DefaultLayout);
                    // CreateThumbs
                    int drivetype = Util.Utils.getDriveType(shareData.Folder);
                    if (selectedSection == "movies") // &&
                    //drivetype != 2 &&
                    //drivetype != 5)
                    {
                        editShare.labelCreateThumbs.Visible = true;
                        editShare.cbCreateThumbs.Visible    = true;
                        editShare.CreateThumbs = shareData.CreateThumbs;

                        editShare.cbEachFolderIsMovie.Visible = true;
                        editShare.EachFolderIsMovie           = shareData.EachFolderIsMovie;
                    }
                    else
                    {
                        editShare.labelCreateThumbs.Visible = false;
                        editShare.cbCreateThumbs.Visible    = false;
                        editShare.CreateThumbs = true;

                        editShare.cbEachFolderIsMovie.Visible = false;
                        editShare.EachFolderIsMovie           = false;
                    }

                    DialogResult dialogResult = editShare.ShowDialog(this);

                    if (dialogResult == DialogResult.OK)
                    {
                        shareData.Name    = editShare.ShareName;
                        shareData.Folder  = editShare.Folder;
                        shareData.PinCode = editShare.PinCode;

                        shareData.IsRemote         = editShare.IsRemote;
                        shareData.Server           = editShare.Server;
                        shareData.LoginName        = editShare.LoginName;
                        shareData.PassWord         = editShare.PassWord;
                        shareData.Port             = editShare.Port;
                        shareData.ActiveConnection = editShare.ActiveConnection;
                        shareData.RemoteFolder     = editShare.RemoteFolder;
                        shareData.DefaultLayout    = ProperLayoutFromDefault(editShare.View);
                        //CreateThumbs
                        if (selectedSection == "movies")
                        {
                            //if (drivetype != 2 &&
                            //    drivetype != 5)
                            //{
                            shareData.CreateThumbs      = editShare.CreateThumbs;
                            shareData.EachFolderIsMovie = editShare.EachFolderIsMovie;
                            //}
                            //else
                            //{
                            //  shareData.CreateThumbs = false;
                            //}
                        }
                        selectedItem.Tag = shareData;

                        selectedItem.SubItems[0].Text = shareData.Name;
                        selectedItem.SubItems[1].Text = shareData.HasPinCode ? "Yes" : "No";
                        selectedItem.SubItems[2].Text = shareData.Folder;
                        selectedItem.SubItems[3].Text = shareData.CreateThumbs ? "Yes" : "No";
                        if (shareData.IsRemote)
                        {
                            selectedItem.SubItems[2].Text = String.Format("ftp://{0}:{1}{2}", shareData.Server, shareData.Port,
                                                                          shareData.RemoteFolder);
                        }
                    }
                }
            }
        }
コード例 #20
0
ファイル: MainPage.xaml.cs プロジェクト: RaulVan/FMRadioPro
        /// <summary>
        /// 分享按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnShare_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BitmapImage bitmapImage = new BitmapImage();
                WriteableBitmap bitmap = await Screen();

                using (MemoryStream memoryStream = new MemoryStream())
                {
                    bitmap.SaveJpeg(memoryStream, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100);
                    bitmapImage.SetSource(memoryStream);
                }

                ShareData shareData = new ShareData();
                string content = "";
                if (string.IsNullOrWhiteSpace(txtPlayName.Text))
                {
                    content = "我正在使用FMRadioPro收听广播,分享一个好APP,支持CodeMonkey @十一_x 写APP赚钱娶媳妇。 ";
                }
                else
                {
                    content = string.Format("我正在使用FMRadioPro收听{0},分享一个好APP,支持CodeMonkey @十一_x 写APP赚钱娶媳妇。", txtPlayName.Text);
                }
                shareData.Content = content;

                shareData.Picture = bitmapImage;

                ShareOption option = new ShareOption();
                option.ShareCompleted = args =>
                {
                    if (args.StatusCode == UmengSocialSDK.UmEventArgs.Status.Successed)
                    {
                        //分享成功
                        // MessageBox.Show("分享成功");
                    }
                    else
                    {
                        //分享失败
                        //MessageBox.Show("分享失败");
                    }
                };

                UmengSocial.Share(AppConfig.AppKey, shareData, null, this, option);
            }
            catch (Exception ex)
            {
                UmengSDK.UmengAnalytics.TrackException(ex);
            }
        }
コード例 #21
0
        void RecvFromServer()
        {
            TimeSpan ts;

            while (true)
            {
                if (!_loginSuccess)
                {
                    Thread.Sleep(5);
                    continue;
                }
                ts = DateTime.Now - receiveDataStartTime;
                if (ts.TotalSeconds > 5)
                {
                    lock (receiveDataBuffer)
                    {
                        receiveDataBuffer.Clear();
                    }
                    tcpClient.Close();
                    _isTcpConnected = false;
                    _loginSuccess   = false;
                    this.Invoke(new Action(() =>
                    {
                        btn_Connect.Text  = "连接";
                        pictureBox1.Image = null;
                    }));
                    Thread.Sleep(5);
                    continue;
                }
                if (receiveDataBuffer.Count == 0)
                {
                    Thread.Sleep(5);
                    continue;
                }

                try
                {
                    List <byte[]> cmds        = new List <byte[]>();
                    int           removeCount = 0;
                    byte[]        buffers;
                    lock (receiveDataBuffer)
                    {
                        buffers = receiveDataBuffer.ToArray();
                    }
                    Package7E.UnPack(buffers, ref cmds, ref removeCount);
                    if (removeCount > 0)
                    {
                        lock (receiveDataBuffer)
                        {
                            receiveDataBuffer.RemoveRange(0, removeCount);
                        }
                    }

                    for (int i = 0; i < cmds.Count; i++)
                    {
                        BsonDataReader bsonDataReader = null;
                        try
                        {
                            MemoryStream msShareData = new MemoryStream(cmds[i]);
                            bsonDataReader = new BsonDataReader(msShareData);
                            JsonSerializer jsonSerializer = new JsonSerializer();
                            ShareData      shareData      = jsonSerializer.Deserialize <ShareData>(bsonDataReader);
                            switch (shareData.Type)
                            {
                            case "Text":
                                ShowResult(shareData.TextData);
                                break;

                            case "Image":
                                ShowImage(shareData.ImgData);
                                break;

                            default:
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        finally
                        {
                            if (bsonDataReader != null)
                            {
                                bsonDataReader.Close();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //Log.Error("RecvFromSlave Error", ex);
                }
                Thread.Sleep(5);
            }
        }